geschrieben am 20.03.2011 19:51:10
Ich habe mal wieder ein Problem:
In einigen Levels benutze ich eine Treasure Chest (wie in SMB3). Sie lässt beim Öffnen ein Item in der Itembox erscheinen und beendet automatisch das Level.
Nun habe ich aber die Itembox deaktiviert. Deshalb möchte ich, dass die Treasure Chest ein Item "ausspuckt", das Mario sofort verwenden kann und dann das Level beendet. Deshalb hab ich die asm-Datei etwas bearbeitet.
Die Treasure Chest spuckt das Item tatsächlich aus, beendet aber das Level nicht. Was muss ich am folgenden Code ändern, damit auch dies passiert:
Code;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Extra Property Byte 1
;; bit 0 - spawn a normal sprite (mushroom by default)
;;
;; Extra Property Byte 2
;; bit 0 - spawn a custom sprite (para-beetle by default)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GOAL_TIMER = $80
SOUND_TO_GEN = $36
EXTRA_BITS = $7FAB10
EXTRA_PROP_1 = $7FAB28
EXTRA_PROP_2 = $7FAB34
NEW_SPRITE_NUM = $7FAB9E
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite init JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "INIT"
INC $157C,x ; set direction to the left
RTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite code JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "MAIN"
PHB ; \
PHK ; | main sprite function, just calls local subroutine
PLB ; |
JSR SPRITE_CODE_START ; |
PLB ; |
RTL ; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite main code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPRITE_CODE_START LDA $1504,x ; \ if the state is set...
BEQ SKIP_GOAL_TIME ; /
JMP SET_GOAL_TIME ; set goal timer routine
SKIP_GOAL_TIME JSR SUB_GFX ; graphics routine
JSR SUB_OFF_SCREEN_X3 ; handle off screen situation
LDA $9D ; \ if sprites locked, return
BNE RETURN ; /
LDA $1588,x ; \ if sprite is in contact with the ground...
AND #$04 ; |
BEQ IN_AIR ; /
LDA #$10 ; \ set y speed
STA $AA,x ; /
IN_AIR JSL $01802A ; update position based on speed values
JSL $01A7DC ; check for Mario/sprite contact (carry set = contact)
BCC RETURN ; return if no contact
INC $1504,x ; set state
LDA #SOUND_TO_GEN ; \ sound effect
STA $1DFC ; /
LDA EXTRA_BITS,x ; \ set another item if the extra bit is set
AND #$04 ; |
BNE CUSTOM ; /
NORMAL LDA #$08 ; \ set sprite status for new sprite
STA $14C8,x ; /
LDA EXTRA_PROP_1,x ; \ sprite type
STA $9E,x ; /
JSL $07F7D2 ; reset sprite properties
BRA SHARED
CUSTOM LDA #$08 ; \ set sprite status for new sprite
STA $14C8,x ; /
LDA EXTRA_PROP_2,x ; \ sprite type
STA NEW_SPRITE_NUM,x ; /
JSL $07F7D2 ; reset sprite properties
JSL $0187A7 ; get table values for custom sprite
LDA #$88 ; \ mark as initialized
STA EXTRA_BITS,x ; /
SHARED LDA #$20 ; \ time to disable sprite's contact with Mario
STA $154C,x ; /
LDA $D8,x ; \ set y position (low byte)
SEC ; |
SBC #$0F ; |
STA $D8,x ; /
LDA $14D4,x ; \ set y position (high byte)
SBC #$00 ; |
STA $14D4,x ; /
LDA #$00 ; \ set sprite direction depending on Mario's x speed
LDY $7B ; |
BPL DIRECTION ; |
INC A ; |
DIRECTION STA $157C,x ; /
LDA #$C0 ; \ set y speed
STA $AA,x ; /
RETURN RTS ; return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; end level routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SET_GOAL_TIME LDA $1558,x ; \ if the timer is set...
BEQ SET_TIMER ; /
DEC A ; \ if the timer decreases
BNE RETURN ; /
END_LEVEL LDA $0DD5 ; \ if the secret event is set...
BEQ EXIT ; /
BPL RETURN ; return if set
EXIT LDA $E4,x ; \ set secret exit if the x position is set
AND #$10 ; |
BNE SECRET_EXIT ; /
NORMAL_EXIT LDA #$80 ; end level
LDA #$01 ; set midway flag to passed
STA $13CE ; store midway flag
BRA SHARED
SECRET_EXIT LDA #$80 ; end level
LDA #$01 ; set midway flag to passed
INC A ; set secret exit
STA $13CE ; store midway flag
SHARED STA $0DD5 ; activate secret event upon returning to the OW
INC $1DE9 ;
LDA #$0B ; \ set light/resolution
STA $0100 ; /
BRA RETURN
SET_TIMER LDA #GOAL_TIMER ; \ set timer
STA $1558,x ; /
BRA RETURN
...
(Ich schätze mal, dass das Level weiterhin erst beendet wird, wenn etwas in der Itembox erscheint)
Ursprünglich sah der Code so aus:
Code;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Extra Property Byte 1
;; bit 0 - put item in item box (mushroom by default)
;;
;; Extra Property Byte 2
;; bit 0 - put item in item box (flower by default)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GOAL_TIMER = $80
SOUND_TO_GEN = $36
EXTRA_BITS = $7FAB10
EXTRA_PROP_1 = $7FAB28
EXTRA_PROP_2 = $7FAB34
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite init JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "INIT"
INC $157C,x ; set direction to the left
RTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite code JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "MAIN"
PHB ; \
PHK ; | main sprite function, just calls local subroutine
PLB ; |
JSR SPRITE_CODE_START ; |
PLB ; |
RTL ; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite main code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPRITE_CODE_START LDA $1504,x ; \ if the state is set...
BEQ SKIP_GOAL_TIME ; /
JMP SET_GOAL_TIME ; set goal timer routine
SKIP_GOAL_TIME JSR SUB_GFX ; graphics routine
JSR SUB_OFF_SCREEN_X3 ; handle off screen situation
LDA $9D ; \ if sprites locked, return
BNE RETURN ; /
LDA $1588,x ; \ if sprite is in contact with the ground...
AND #$04 ; |
BEQ IN_AIR ; /
LDA #$10 ; \ set y speed
STA $AA,x ; /
IN_AIR JSL $01802A ; update position based on speed values
JSL $01A7DC ; check for Mario/sprite contact (carry set = contact)
BCC RETURN ; return if no contact
INC $1504,x ; set state
LDA #SOUND_TO_GEN ; \ sound effect
STA $1DFC ; /
LDA EXTRA_BITS,x ; \ set another item if the extra bit is set
AND #$04 ; |
BNE ITEM2 ; /
ITEM PHP ; Push Processor Status Register
LDA EXTRA_PROP_1,x ; \ put item in the item box
STA $0DC2 ; /
PLP ; Pull Processor Status Register
BRA SET_SMOKE
ITEM2 PHP ; Push Processor Status Register
LDA EXTRA_PROP_2,x ; \ put item in the item box
STA $0DC2 ; /
PLP ; Pull Processor Status Register
SET_SMOKE JSR SUB_SMOKE ; smoke routine
RETURN RTS ; return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; end level routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SET_GOAL_TIME LDA $1558,x ; \ if the timer is set...
BEQ SET_TIMER ; /
DEC A ; \ if the timer decreases
BNE RETURN ; /
END_LEVEL LDA $0DD5 ; \ if the secret event is set...
BEQ EXIT ; /
BPL RETURN ; return if set
EXIT LDA $E4,x ; \ set secret exit if the x position is set
AND #$10 ; |
BNE SECRET_EXIT ; /
NORMAL_EXIT LDA #$80 ; end level
LDA #$01 ; set midway flag to passed
STA $13CE ; store midway flag
BRA SHARED
SECRET_EXIT LDA #$80 ; end level
LDA #$01 ; set midway flag to passed
INC A ; set secret exit
STA $13CE ; store midway flag
SHARED STA $0DD5 ; activate secret event upon returning to the OW
INC $1DE9 ;
LDA #$0B ; \ set light/resolution
STA $0100 ; /
BRA RETURN
SET_TIMER LDA #GOAL_TIMER ; \ set timer
STA $1558,x ; /
BRA RETURN