geschrieben am 23.04.2011 10:55:57 in Basis-ROMs
(
Link
)
TO_ATTACK LDA FIRE_TIMER,x ; \ if time until spit >= $10
CMP #TIME_TO_SHOW ; | just go to normal walking code
BCS STATE_RUN ; /
INC SPRITE_IMG,x
INC SPRITE_IMG,x
LDA FIRE_TIMER,x ; throw fire if it's time
BNE NO_RESET
LDY $C2,x
LDA TIME_TILL_THROW,y
STA FIRE_TIMER,x
NO_RESET CMP #$01
BNE STATE_RUN
JSR SUB_FIRE_THROW
JSR Tele
LDA #$18
STA $1887
;===================================
; Init
;===================================
dcb "INIT"
LDA #$09
STA $14C8,x
RTL
dcb "MAIN"
PHB
PHK
PLB
LDA $1510,x
BNE TheEnd
JSR SpriteCode
TheEnd:
PLB
RTL
;===================================
; Main Code
;===================================
SpriteCode:
JSR Graphics
JSR WavyMotion
LDA #Gravity
STA $AA,x
BNE Return
JSL $01A7DC
BCC Return
STZ 14C8,x
BEQ Return
LDY #$0B ;\
Loop: ; |
LDA $14C8,y ; |
CMP #$0B ; |
BEQ Return ; |
DEY ; |
BPL Loop ;/
LDA #$02
STA $1DF9
LDA #$00
STA $1510,x
JSL $07FC3B ; l Zeichne Sterne
LDA #$08 ; l Spiel SFX ab
STA $1DFC
LDA #$00
STA $140D
LDA #$80
STA $7D
RTS
Return:
RTS
;===================================
; GFX Routine
;===================================
Graphics:
JSR GET_DRAW_INFO
LDA #$F0 ;\Move glitched tile
STA $0309,y ;/off screen.
LDA $00 ;\
STA $0300,y ; |This will prepare the X and Y positions so that we
LDA $01 ; |can draw the actual sprite.
STA $0301,y ;/
LDA #$A4 ;\This tells the game what tile we want to draw.
STA $0302,y ;/
LDA #%01001111 ;No Y-flip, X-flip, Lowest priority, Palette F, Page 4
ORA $64 ;\Store this stuff ^
STA $0303,y ;/
;INY ;\
;INY ; |Actually, this isn't necessary...
;INY ; |This is just necessary if we are drawing more than 1 tile (cause this just get the next tile in the OAM...)
;INY ;/
LDY #$02 ;Again, because we want the sprite to be 16 x 16.
LDA #$00 ;Something else for drawing the sprite.
JSL $01B7B3 ;This calls the routine that actually draws our sprite.
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GET_DRAW_INFO
; This is a helper for the graphics routine. It sets off screen flags, and sets up
; variables. It will return with the following:
;
; Y = index to sprite OAM ($300)
; $00 = sprite x position relative to screen boarder
; $01 = sprite y position relative to screen boarder
;
; It is adapted from the subroutine at $03B760
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SPR_T1: dcb $0C,$1C
SPR_T2: 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 SPR_T1,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 SPR_T2,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 ; /
;==================================================================
;Wavy Thing
;==================================================================
WavyMotion:
PHY ; Push Y in case something messes it up.
LDA $14 ; Get the sprite frame counter ..
LSR A ; 7F
LSR A ; 3F ; Tip: LSR #3.
LSR A ; 1F
AND #$07 ; Loop through these bytes during H-Blank. (WHAT?)
TAY ; Into Y.
LDA WavySpd,y ; Load Y speeds ..
STA $AA,x
JSL $01801A ; Update, with no gravity.
PLY ; Pull Y.
RTS
WavySpd: db $00,$F8,$F2,$F8,$00,$08,$0E,$08
;===================================
; EXPLOSION
;===================================
Explode:
LDA #$0D ;\Become a Bob-Omb
STA $9E,x ;/
LDA #$08 ;\Run routines normally
STA $14C8,x ;/
JSL $07F7D2 ;Reset sprite tables
LDA #$01 ;\Do something with a sprite table
STA $1534,x ;/
LDA #$40 ;\Do something with a sprite table
STA $1540,x ;/
LDA #$09 ;\Play SFX
STA $1DFC ;/
LDA #$1B ;\Set some sprite properties
STA $167A,x ;/
RTS