Dann einfach :
Dann einfach :
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Frenzied Toroko
; by Sonikku
; Description: She stands where you place her, and when you get close, she
; transforms into her rabid form. She jumps, throws an aimed block at you, lands
; and throws another. She takes
PROJECT = $04 ; custom sprite number of ToroBlk.cfg
HP = $08 ; how many stomps before she faints.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; init JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "INIT"
JSR SUB_HORZ_POS
TYA
STA $157C,x
LDA #$08
STA $1602,x
RTL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main sprite JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dcb "MAIN"
PHB ; \
PHK ; | main sprite function, just calls local subroutine
PLB ; |
JSR START_HB_CODE ; |
PLB ; |
RTL ; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main sprite routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BLNKFRM dcb $08,$08,$08,$08,$08,$08,$08,$09
TRNSFRM dcb $0B,$0C
IDLEFRM dcb $00,$01,$03,$03
AIRCHAR dcb $04,$06
AIRSHOT dcb $05,$07
XSPD dcb $10,$F0
SPRX dcb $FF,$10
SPRX2 dcb $FF,$00
RETURN RTS
START_HB_CODE
LDA $15AC,x
BEQ NOSTUN
LDA $14
AND #$01
BNE NOGFX
NOSTUN JSR SUB_GFX
NOGFX LDA $9D
BNE RETURN
JSL $01802A
LDA $1594,x
JSL $0086DF
dcw STATE0&$FFFF
dcw STATE1&$FFFF
dcw STATE2&$FFFF
STATE0 LDA $1540,x
BEQ NOTIMR0
CMP #$01
BNE NOINC
LDA #$01
STA $1594,x
LDA #$40
STA $1540,x
LDA #$70
STA $163E,x
RTS
NOINC CMP #$70
BCS FRENZY1
CMP #$40
BCS FRENZY2
LDA #$10
STA $1DF9
LDA #$05
STA $1DFB
LDA $14
LSR A
LSR A
LSR A
AND #$01
TAY
LDA IDLEFRM,y
BRA STRFRM0
FRENZY1 LDA #$0A
BRA STRFRM0
FRENZY2 LDA $14
AND #$01
TAY
LDA TRNSFRM,y
STRFRM0 STA $1602,x
RTS
NOTIMR0 JSR SUB_HORZ_POS
LDA $0F
CLC
ADC #$40
CMP #$80
BCS STAND0
LDA #$90
STA $1540,x
RTS
STAND0 LDA $14
LSR A
LSR A
LSR A
AND #$07
TAY
LDA BLNKFRM,y
STA $1602,x
RETURN0 RTS
STATE1 LDA $15AC,x
BNE NOCON
JSL $01A7DC
BCC NOCON
LDA $7D
CMP #$10
BMI SPRWINS
JSL $01AA33
JSL $01AB99
LDA #$0B
STA $72
LDA #$13
STA $1DF9
STZ $AA,x
INC $C2,x
LDA #HP
CMP $C2,x
BNE NOKILL
LDA #$90
STA $1540,x
INC $1594,x
RTS
NOKILL LDA #$40
STA $15AC,x
RTS
SPRWINS JSL $00F5B7
NOCON JSR SUB_HORZ_POS
TYA
STA $157C,x
LDA $1588,x
AND #$03
BEQ NOWALL
STZ $B6,x
NOWALL LDA $1558,x
BEQ NOLAND
LDA #$02
STA $1602,x
RTS
NOLAND LDA $1540,x
BNE NOTIMR
LDA #$70
STA $1540,x
NOTIMR LDA $1588,x
AND #$04
BEQ INAIR
LDA $163E,x
BEQ RESET
CMP #$10
BCC PREJMP
STZ $B6,x
LDA #$02
STA $1602,x
BRA NOJMP
PREJMP LDA #$02
STA $1602,x
RTS
RESET LDA #$C8
STA $AA,x
JSR SUB_HORZ_POS
TYA
LDA XSPD,y
STA $B6,x
LDA #$FF
STA $163E,x
NOJMP LDA $1510,x
BEQ NOAIR
LDA #$10
STA $1558,x
STZ $B6,x
STZ $1510,x
LDA #$20
STA $1887
LDA #$09
STA $1DFC
LDA #$40
STA $1540,x
BRA NOAIR
INAIR LDA #$01
STA $1510,x
DEC $AA,x
LDA $14
AND #$01
BNE NOAIR
DEC $AA,x
DEC $AA,x
NOAIR LDA $1540,x
CMP #$04
BEQ SHOT
CMP #$06
BCC SHOTIN
CMP #$20
BCS SKIP
LDY $1510,x
LDA AIRCHAR,y
BRA STRFRM
SHOTIN LDY $1510,x
LDA AIRSHOT,y
BRA STRFRM
SKIP LDA $14
LSR A
LSR A
LSR A
AND #$01
TAY
LDA $1510,x
BEQ ONGND
INY
INY
ONGND LDA IDLEFRM,y
STRFRM STA $1602,x
RTS
SHOT LDY $1510,x
LDA AIRSHOT,y
STA $1602,x
JSL $02A9DE
BMI RETURN1
LDA #$01
STA $14C8,y
PHX
LDA #PROJECT
TYX
STA $7FAB9E,x
PLX
LDA $E4,x
CLC
ADC #$08
STA $00E4,y
LDA $14E0,x
ADC #$00
STA $14E0,y
LDA $D8,x
SEC
SBC #$0C
STA $00D8,y
LDA $14D4,x
SBC #$00
STA $14D4,y
PHX
TYX
JSL $07F7D2
JSL $0187A7
LDA #$08
STA $7FAB10,x
PLX
LDA #$50
JSR CODE_01BF6A
LDX $15E9
LDA $00
STA $00AA,y
LDA $01
STA $00B6,y
RETURN1 RTS
STATE2 STZ $B6,x
LDA $1540,x
CMP #$01
BEQ ENDLVL
CMP #$60
BCS GOBACK
CMP #$50
BCS FAINT
LDA #$0E
BRA STRFRM2
FAINT LDA #$0D
BRA STRFRM2
GOBACK LDA $14
AND #$01
TAY
LDA TRNSFRM,y
STRFRM2 STA $1602,x
RTS
ENDLVL LDA #$0B
STA $71
LDA #$05
STA $1DF9
LDA #$FF
STA $1DFB
STA $1493
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; aiming routine
; input: accumulator should be set to total speed (x+y)
; output: $00 = y speed, $01 = x speed
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CODE_01BF6A: STA $01
PHX ;\ preserve sprite indexes of Magikoopa and magic
PHY ;/
JSR SUB_VERT_POS ; $0E = vertical distance to Mario
STY $02 ; $02 = vertical direction to Mario
LDA $0E ;\ $0C = vertical distance to Mario, positive
BPL CODE_01BF7C ; |
EOR #$FF ; |
CLC ; |
ADC #$01 ; |
CODE_01BF7C: STA $0C ;/
JSR SUB_HORZ_POS ; $0F = horizontal distance to Mario
STY $03 ; $03 = horizontal direction to Mario
LDA $0F ;\ $0D = horizontal distance to Mario, positive
BPL CODE_01BF8C ; |
EOR #$FF ; |
CLC ; |
ADC #$01 ; |
CODE_01BF8C: STA $0D ;/
LDY #$00
LDA $0D ;\ if vertical distance less than horizontal distance,
CMP $0C ; |
BCS CODE_01BF9F ;/ branch
INY ; set y register
PHA ;\ switch $0C and $0D
LDA $0C ; |
STA $0D ; |
PLA ; |
STA $0C ;/
CODE_01BF9F: LDA #$00 ;\ zero out $00 and $0B
STA $0B ; | ...what's wrong with STZ?
STA $00 ;/
LDX $01 ;\ divide $0C by $0D?
CODE_01BFA7: LDA $0B ; |\ if $0C + loop counter is less than $0D,
CLC ; | |
ADC $0C ; | |
CMP $0D ; | |
BCC CODE_01BFB4 ; |/ branch
SBC $0D ; | else, subtract $0D
INC $00 ; | and increase $00
CODE_01BFB4: STA $0B ; |
DEX ; |\ if still cycles left to run,
BNE CODE_01BFA7 ;/ / go to start of loop
TYA ;\ if $0C and $0D was not switched,
BEQ CODE_01BFC6 ;/ branch
LDA $00 ;\ else, switch $00 and $01
PHA ; |
LDA $01 ; |
STA $00 ; |
PLA ; |
STA $01 ;/
CODE_01BFC6: LDA $00 ;\ if horizontal distance was inverted,
LDY $02 ; | invert $00
BEQ CODE_01BFD3 ; |
EOR #$FF ; |
CLC ; |
ADC #$01 ; |
STA $00 ;/
CODE_01BFD3: LDA $01 ;\ if vertical distance was inverted,
LDY $03 ; | invert $01
BEQ CODE_01BFE0 ; |
EOR #$FF ; |
CLC ; |
ADC #$01 ; |
STA $01 ;/
CODE_01BFE0: PLY ;\ retrieve Magikoopa and magic sprite indexes
PLX ;/
RTS ; return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; graphics routine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TILEMAP dcb $00,$02,$20,$22 ; #$00 (idle1)
dcb $04,$06,$24,$26 ; #$01 (idle2)
dcb $08,$0A,$28,$2A ; #$02 (jump)
dcb $0C,$0E,$2C,$2E ; #$03 (inair)
dcb $40,$42,$60,$62 ; #$04 (charge1)
dcb $44,$46,$64,$66 ; #$05 (throw1)
dcb $48,$4A,$68,$6A ; #$06 (charge2)
dcb $4C,$4E,$6C,$6E ; #$07 (throw2)
dcb $AC,$AE,$AC,$AE ; #$08 (stand1)
dcb $CC,$CE,$CC,$CE ; #$09 (stand2)
dcb $A0,$A2,$A0,$A2 ; #$0A (frenzy1)
dcb $80,$82,$80,$82 ; #$0B (frenzy2)
dcb $84,$86,$A4,$A6 ; #$0C (frenzy3)
dcb $A8,$AA,$A8,$AA ; #$0D (lost1)
dcb $88,$8A,$88,$8A ; #$0E (lost2)
X_OFFSET dcb $00,$10,$00,$10
dcb $10,$00,$10,$00
Y_OFFSET dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $F3,$F3,$03,$03
dcb $00,$00,$00,$00
dcb $00,$00,$00,$00
dcb $00,$00,$00,$00
dcb $00,$00,$00,$00
dcb $F0,$F0,$00,$00
dcb $00,$00,$00,$00
dcb $00,$00,$00,$00
BLKTILE dcb $8C,$8E
SUB_GFX JSR GET_DRAW_INFO ; sets y = OAM offset
LDA $157C,x ; \ $02 = direction
ASL A
ASL A
STA $02 ; /
LDA $1602,x
ASL A
ASL A
STA $03
PHX
LDX #$03
LOOP_START PHX
TXA
CLC
ADC $02
TAX
LDA X_OFFSET,x
CLC
ADC $00 ; \ tile x position = sprite y location ($01)
STA $0300,y ; /
PLX
PHX
TXA
CLC
ADC $03
TAX
LDA TILEMAP,x
STA $0302,y
LDA Y_OFFSET,x
CLC
ADC $01 ; \ tile y position = sprite x location ($00)
STA $0301,y ; /
PLX
PHX
LDX $15E9
LDA $15F6,x ; tile properties xyppccct, format
LDX $02 ; \ if direction == 0...
BEQ NO_FLIP ; |
ORA #$40 ; / ...flip tile
NO_FLIP ORA $64 ; add in tile priority of level
STA $0303,y ; store tile properties
PLX
INY ; \ increase index to sprite tile map ($300)...
INY ; | ...we wrote 1 16x16 tile...
INY ; | ...sprite OAM is 8x8...
INY ; / ...so increment 4 times
DEX
BPL LOOP_START
PLX
LDA $15A0,x
ORA $186C,x
BNE NOBLK
LDA $1602,x
CMP #$04
BEQ SHOW_HAMMER_TOO
CMP #$06
BEQ SHOW_HAMMER_TOO
NOBLK LDY #$02 ; \ 460 = 2 (all 16x16 tiles)
LDA #$03 ; | A = (number of tiles drawn - 1)
JSL $01B7B3 ; / don't draw if offscreen
RTS ; return
SHOW_HAMMER_TOO PHX
LDA $157C,x
BNE NO_ADJ
LDA $00
BRA FINISH
NO_ADJ LDA $00
CLC
ADC #$10
FINISH STA $0300,y
LDA $01 ; \ tile y position = sprite y location ($01) + tile displacement
SEC ; |
SBC #$0C
STA $0301,y ; /
LDA $14
AND #$01
TAX
LDA BLKTILE,x ; \ store tile
STA $0302,y ; /
PHX
TYA ; \ get index to sprite property map ($460)...
LSR A ; | ...we use the sprite OAM index...
LSR A ; | ...and divide by 4 because a 16x16 tile is 4 8x8 tiles
TAX ; |
LDA #$02
STA $0460,x ; /
PLX
LDA #$0F
STA $0303,y ; / store tile properties
PLX
INY ; | increase index to sprite tile map ($300)...
INY ; | ...we wrote 1 16x16 tile...
INY ; | ...sprite OAM is 8x8...
INY ; | ...so increment 4 times
LDY #$FF ; \ 02, because we didn't write to 460 yet
LDA #$04 ; | A = number of tiles drawn - 1
JSL $01B7B3 ; / don't draw if offscreen
RTS ; return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $B760 - graphics routine helper - shared
; sets off screen flags and sets index to OAM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;org $03B75C
TABLE1 dcb $0C,$1C
TABLE2 dcb $01,$02
GET_DRAW_INFO STZ $186C,x ; reset sprite offscreen flag, vertical
STZ $15A0,x ; reset sprite offscreen flag, horizontal
LDA $E4,x ; \
CMP $1A ; | set horizontal offscreen if necessary
LDA $14E0,x ; |
SBC $1B ; |
BEQ ON_SCREEN_X ; |
INC $15A0,x ; /
ON_SCREEN_X LDA $14E0,x ; \
XBA ; |
LDA $E4,x ; |
REP #$20 ; |
SEC ; |
SBC $1A ; | mark sprite invalid if far enough off screen
CLC ; |
ADC.W #$0040 ; |
CMP.W #$0180 ; |
SEP #$20 ; |
ROL A ; |
AND #$01 ; |
STA $15C4,x ; /
BNE INVALID ;
LDY #$00 ; \ set up loop:
LDA $1662,x ; |
AND #$20 ; | if not smushed (1662 & 0x20), go through loop twice
BEQ ON_SCREEN_LOOP ; | else, go through loop once
INY ; /
ON_SCREEN_LOOP LDA $D8,x ; \
CLC ; | set vertical offscreen if necessary
ADC TABLE1,y ; |
PHP ; |
CMP $1C ; | (vert screen boundry)
ROL $00 ; |
PLP ; |
LDA $14D4,x ; |
ADC #$00 ; |
LSR $00 ; |
SBC $1D ; |
BEQ ON_SCREEN_Y ; |
LDA $186C,x ; | (vert offscreen)
ORA TABLE2,y ; |
STA $186C,x ; |
ON_SCREEN_Y DEY ; |
BPL ON_SCREEN_LOOP ; /
LDY $15EA,x ; get offset to sprite OAM
LDA $E4,x ; \
SEC ; |
SBC $1A ; | $00 = sprite x position relative to screen boarder
STA $00 ; /
LDA $D8,x ; \
SEC ; |
SBC $1C ; | $01 = sprite y position relative to screen boarder
STA $01 ; /
RTS ; return
INVALID PLA ; \ return from *main gfx routine* subroutine...
PLA ; | ...(not just this subroutine)
RTS ; /
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SUB_HORZ_POS
; This routine determines which side of the sprite Mario is on. It sets the Y register
; to the direction such that the sprite would face Mario
; It is ripped from $03B817
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SUB_HORZ_POS LDY #$00 ;A:25D0 X:0006 Y:0001 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1020 VC:097 00 FL:31642
LDA $94 ;A:25D0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZCHC:1036 VC:097 00 FL:31642
SEC ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1060 VC:097 00 FL:31642
SBC $E4,x ;A:25F0 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizCHC:1074 VC:097 00 FL:31642
STA $0F ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1104 VC:097 00 FL:31642
LDA $95 ;A:25F4 X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1128 VC:097 00 FL:31642
SBC $14E0,x ;A:2500 X:0006 Y:0000 D:0000 DB:03 S:01ED P:envMXdiZcHC:1152 VC:097 00 FL:31642
BPL SPR_L16 ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1184 VC:097 00 FL:31642
INY ;A:25FF X:0006 Y:0000 D:0000 DB:03 S:01ED P:eNvMXdizcHC:1200 VC:097 00 FL:31642
SPR_L16 RTS ;A:25FF X:0006 Y:0001 D:0000 DB:03 S:01ED P:envMXdizcHC:1214 VC:097 00 FL:31642
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; SUB_VERT_POS
; This routine determines if Mario is above or below the sprite. It sets the Y register
; to the direction such that the sprite would face Mario
; It is ripped from $03B829
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SUB_VERT_POS LDY #$00 ;A:25A1 X:0007 Y:0001 D:0000 DB:03 S:01EA P:envMXdizCHC:0130 VC:085 00 FL:924
LDA $96 ;A:25A1 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdiZCHC:0146 VC:085 00 FL:924
CLC
ADC #$18
SEC ;A:2546 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizCHC:0170 VC:085 00 FL:924
SBC $D8,x ;A:2546 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizCHC:0184 VC:085 00 FL:924
STA $0E ;A:25D6 X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0214 VC:085 00 FL:924
LDA $97 ;A:25D6 X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0238 VC:085 00 FL:924
SBC $14D4,x ;A:2501 X:0007 Y:0000 D:0000 DB:03 S:01EA P:envMXdizcHC:0262 VC:085 00 FL:924
BPL SPR_L11 ;A:25FF X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0294 VC:085 00 FL:924
INY ;A:25FF X:0007 Y:0000 D:0000 DB:03 S:01EA P:eNvMXdizcHC:0310 VC:085 00 FL:924
SPR_L11 RTS ;A:25FF X:0007 Y:0001 D:0000 DB:03 S:01EA P:envMXdizcHC:0324 VC:085 00 FL:924