SHMUP

by djief

Game: SMW

Description:

LDA $0100
CMP #$14
BNE Exit2
LDA $9D
BEQ RunCode

Exit2:
RTL

RunCode:
PHB
PHK
PLB
LDA #$01
STA $13F1
LDA #$1D
STA $13E0
STZ $7D
STZ $01
LDA #$02
BIT $15
BMI Fast
LDA #$01
Fast:
STA $00

LDA $15
AND #$08
BEQ CheckDown
JSR Up

CheckDown:
LDA $15
AND #$04
BEQ CheckLeft
JSR Down

CheckLeft:
LDA $15
AND #$02
BEQ CheckRight
JSR Left

CheckRight:
LDA $15
AND #$01
BEQ CheckJump
JSR Right

CheckJump:
BIT $16
BPL Exit
JSR Shoot

Exit:
PLB
RTL

Up:
REP #$20
LDA $96
SEC
SBC $00
STA $96
SEP #$20
RTS

Down:
REP #$20
LDA $96
CLC
ADC $00
STA $96
SEP #$20
RTS

Left:
REP #$20
LDA $94
SEC
SBC $00
STA $94
SEP #$20
STZ $76
RTS

Right:
REP #$20
LDA $94
CLC
ADC $00
STA $94
SEP #$20
LDA #$01
STA $76
RTS

GetSlot:
LDX #$0B
.Loop
LDA $14C8,x
BNE .Next
BRA .FoundSlot
.Next
DEX
BPL .Loop
PLA
PLA
RTS
.FoundSlot
RTS


Random:
	PHX
	PHP
	PHA
	JSL $01ACF9
	PLX
	CPX #$FF
	BNE NORMALRT
	LDA $148B
	ADC $13
	BRA ENDRANDOM
NORMALRT:
	INX
	LDA $148B
	ADC $13
	STA $4202
	STX $4203
	NOP #4
	LDA $4217
ENDRANDOM:
	PLP
	PLX
RTS

Shoot:
	JSR GetSlot
	TXY
	LDA #$08
	JSR Random
	ASL
	TAX
	JMP (PointerTable,x)
.Return
RTS


PointerTable:
dw Shell,Bomb,Goomba,Buzzy,BabyYoshi,ThrowBlock,Grinder,Chuck,Mole


Mole:
	LDA #$03
	JSR SetPositionSpeed
        LDA #$BF
        STA $9E,x 
RTS

Chuck:
        LDA #$03
        JSR SetPositionSpeed
	LDA #$06
	JSR Random
	CMP #$05
	BCS .NoIncrease
	INC
	.NoIncrease
	CLC
	ADC #$91
        STA $9E,x
	LDA #$20
	STA $1564,x
RTS

Grinder:
	LDA #$03
	JSR SetPositionSpeed
        LDA #$B4
        STA $9E,x 
RTS

ThrowBlock:
	LDA #$53
	JSR SetPositionSpeed
	LDA #$0A
	STA $14C8,x
RTS

BabyYoshi:
	LDA #$2D
	JSR SetPositionSpeed
	LDA #$0A
	STA $14C8,x
RTS

Buzzy:
	LDA #$0F
	JSR SetPositionSpeed
	LDA #$0A
	STA $14C8,x
	LDA #$30
	STA $1540,x
	STA $C2,x
RTS

Goomba:
	LDA #$0F
	JSR SetPositionSpeed
	LDA #$0A
	STA $14C8,x
	LDA #$30
	STA $1540,x
	STA $C2,x
RTS

Bomb:
	LDA #$0D
	JSR SetPositionSpeed
	LDA #$0A
	STA $14C8,x
	LDA #$20
	STA $1540,x
RTS

Shell:
	LDA #$03
	JSR Random
	CLC
	ADC #$04
	JSR SetPositionSpeed
	LDA #$0A
	STA $14C8,x
RTS

XSpeeds:
db $C0,$40
XOffsetLow:
db $F5,$0B
XOffsetHigh:
db $FF,$00

SetPositionSpeed:
	TYX
	STA $9E,x
	JSL $07F7D2
	LDY $76
	LDA XOffsetHigh,y
	XBA
	LDA XOffsetLow,y
	REP #$20
	CLC
	ADC $94
	SEP #$20
	STA $E4,x
	XBA
	STA $14E0,x
	LDA $96
	STA $D8,x
	LDA $97
	STA $14D4,x
	LDA XSpeeds,y
	STA $B6,x
	LDA #$10
	STA $154C,x
	TYA
	STA $157C,x
RTS
back to listings