Kaizod
by dtothefourth
Game: SMW
Description: Ties a kaizo block generator to FreeRAM 7FB500
LDA $7FB500 BNE + RTL + LDA $71 BNE + LDA $7D BPL + CMP #$D8 BCC + LDA #$01 STA $1DFC REP #$20 LDA $94 STA $9A LDA $96 STA $98 LDA $19 AND #$00FF BNE ++++ LDA $98 CLC ADC #$0008 STA $98 ++++ LDA #$0000 STA $1933 LDA #$0132 JSR change_map16 SEP #$20 LDA #$03 LDX #$0D LDY #$00 JSL spawn_bounce_sprite LDA #$00 STA $1901,y LDA #$10 STA $7D LDA #$00 STA $7FB500 + RTL spawn_bounce_sprite: STA $05 STY $06 STX $07 LDA #$0F TRB $9A TRB $98 LDY #$03 .find_free LDA $1699,y BEQ .slot_found DEY BPL .find_free DEC $18CD BPL .alt_slot LDA #$03 STA $18CD .alt_slot LDY $18CD LDA $1699,y CMP #$07 BNE .no_turn_block_reset PEI ($02) PEI ($04) PEI ($06) PEI ($98) PEI ($9A) LDA $16A5,y STA $9A LDA $16AD,y STA $9B LDA $16A1,y CLC ADC #$0C AND #$F0 STA $98 LDA $16A9,y ADC #$00 STA $99 LDA $16C1,y STA $9C JSL $00BEB0 REP #$20 PLA STA $9A PLA STA $98 PLA STA $06 PLA STA $04 PLA STA $02 SEP #$20 .no_turn_block_reset LDY $18CD .slot_found LDA $05 STA $1699,y LDA #$00 STA $169D,y LDA $9A STA $16A5,y LDA $9B STA $16AD,y LDA $98 STA $16A1,y LDA $99 STA $16A9,y LDA $1933 LSR ROR STA $08 LDX $06 LDA.l $02873A,x STA $16B1,y LDA.l $02873E,x STA $16B5,y TXA ORA $08 STA $16C9,y LDA $07 STA $16C1,y LDA #$08 STA $16C5,y LDA #$00 STA $1901,y LDA $07 PHY PHK PEA.w .sprite_interact-1 PEA.w $B889-1 JML $0286ED .sprite_interact PLY LDX #$03 - LDA $17D0,x BEQ .found_free DEX BPL - DEC $1865 BPL .dont_reset LDA #$03 STA $1865 .dont_reset LDX $1865 .found_free JSL $05B34A INC $17D0,x LDA $9A AND #$F0 STA $17E0,x LDA $9B STA $17EC,x LDA $98 AND #$F0 CLC : ADC #$F0 STA $17D4,x LDA $99 SBC #$00 STA $17E8,x LDA $1933 STA $17E4,x LDA #$D0 STA $17D8,x RTL change_map16: PHX PHP REP #$10 TAX SEP #$20 PHB PHY PHX LDY $98 STY $0E LDY $9A STY $0C SEP #$30 LDA $5B LDX $1933 BEQ .layer1 LSR A .layer1 STA $0A LSR A BCC .horz LDA $9B LDY $99 STY $9B STA $99 .horz BCS .verticalCheck REP #$20 LDA $98 CMP $13D7 SEP #$20 BRA .check .verticalCheck LDA $99 CMP #$02 .check BCC .noEnd REP #$10 PLX PLY PLB PLP PLX RTS .noEnd LDA $9B STA $0B ASL A ADC $0B TAY REP #$20 LDA $98 AND.w #$FFF0 STA $08 AND.w #$00F0 ASL #2 ; 0000 00YY YY00 0000 XBA ; YY00 0000 0000 00YY STA $06 TXA SEP #$20 ASL A TAX LDA $0D LSR A LDA $0F AND #$01 ; 0000 000y ROL A ; 0000 00yx ASL #2 ; 0000 yx00 ORA #$20 ; 0010 yx00 CPX #$00 BEQ .noAdd ORA #$10 ; 001l yx00 .noAdd TSB $06 ; $06 : 001l yxYY LDA $9A ; X LowByte AND #$F0 ; XXXX 0000 LSR #3 ; 000X XXX0 TSB $07 ; $07 : YY0X XXX0 LSR A TSB $08 LDA $1925 ASL A REP #$31 ADC $00BEA8,x TAX TYA ADC $00,x TAX LDA $08 ADC $00,x TAX PLA ASL A TAY LSR A SEP #$20 STA $7E0000,x XBA STA $7F0000,x LSR $0A LDA $1933 REP #$20 BCS .vert BNE .horzL2 .horzL1 LDA $1A ;\ SBC #$007F ; |$08 : Layer1X - 0x80 STA $08 ;/ LDA $1C ; $0A : Layer1Y BRA + .horzL2 LDA $1E ;\ $08 : Layer2X STA $08 ;/ LDA $20 ;\ $0A : Layer2Y - 0x80 SBC #$007F ;/ BRA + .vert BNE .vertL2 LDA $1A ;\ $08 : Layer1X STA $08 ;/ LDA $1C ;\ $0A : Layer1Y - 0x80 SBC #$0080 ;/ BRA + .vertL2 LDA $1E ;\ SBC #$0080 ; |$08 : Layer2X - 0x80 STA $08 ;/ LDA $20 ; $0A : Layer2Y + STA $0A PHK PEA.w .return-1 PEA $804C JML $00C0FB .return PLY PLB PLP PLX RTSback to listings