;Proximity wrap fix, by GreenHammerBro. Please give credit, it takes more than a day of finding many of the sprites that has ;this problem. Also give credit to JackTheSpades for compressing the codes (I have learned how to make A register in 16-bit ;and CLC rolled into one REP opcode, no need to CLC). Sorry that I didn't use macros, its fine with numbers, but with names, ;I get confused. But don't worry, its not worth it, it just compress this file and nothing more (same size amount inserted ;to rom). ;This patch fixes bugs reguarding with the proximity check wrapping from the boarders of the screen, it fixes: ;-Thwomps ;-falling spike ;-yoshi egg ;-Splittin Chuck ;-Bouncin Chuck ;-Whistlin Chuck ;-Rip van fish ;-jumping Piranha plant (and its fire varient) ;-upsidedown piranha (and its classic varient) ;^If you find any other sprites not listed here and uses the proximity from smw (as in, not custom sprites), feel free to update ;this patch. ;Also, its compatable with alcaro's "Thwomp Face Flip", and is a sa-1 hybrid. ;SubHorizPos16Bit and SubVertPos16Bit was made by Sonikku. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;SA1 detector: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if read1($00FFD5) == $23 !SA1 = 1 sa1rom else !SA1 = 0 endif ; Example usage if !SA1 ; SA-1 base addresses ;Give thanks to absentCrowned for this: ;http://www.smwcentral.net/?p=viewthread&t=71953 !Base1 = $3000 ;>$0000-$00FF -> $3000-$30FF !Base2 = $6000 ;>$0100-$0FFF -> $6100-$6FFF and $1000-$1FFF -> $7000-$7FFF !SprTbl_E4 = $322C ;>Sprite X position, low byte. !SprTbl_14E0 = $326E ;>Sprite X position, high byte. !SprTbl_D8 = $3216 ;>Sprite Y position, low byte. !SprTbl_14D4 = $3258 ;>Sprite Y position, high byte. !SprTbl_1528 = $329A !SprTbl_7FAB9E = $6083 !SprTbl_157C = $3334 else ; Non SA-1 base addresses !Base1 = $0000 !Base2 = $0000 !SprTbl_E4 = $E4 ;>Sprite X position, low byte. !SprTbl_14E0 = $14E0 ;>Sprite X position, high byte. !SprTbl_D8 = $D8 ;>Sprite Y position, low byte. !SprTbl_14D4 = $14D4 ;>Sprite Y position, high byte. !SprTbl_1528 = $1528 !SprTbl_7FAB9E = $7FAB9E !SprTbl_157C = $157C endif ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;(A huge wall of) hijacks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $01AECB autoclean JML Thwompfix_sub ;>hijacks a part of the branch. nop #1 ;>JML takes 4 bytes total org $01AED7 autoclean JSL Thwompfix_range nop #3 org $01AEDE ;\modify branch to use signed just in case. BPL $05 ;/ org $01AEE5 autoclean JSL Thwompfix_range2 nop #3 org $01AEEC ;\modify branch to use signed just in case. BPL $0B ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $03924E autoclean JSL FallingSpike_sub_range nop #6 org $039258 ;\modify branch to use signed just in case. BPL $07 ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $01F76E autoclean JSL YoshiEgg_sub_range nop #6 org $01F778 ;\modify branch to use signed just in case. BPL $13 ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $02C360 ;\Whistlin chuck. autoclean JSL Chuck ;| nop #6 ;/ org $02C36A ;\modify branch to use signed just in case. BPL $04 ;/ org $02C602 ;\Splittin' and bouncin' chuck. autoclean JSL Chuck2 ;| nop #10 ;/ org $02C610 ;\modify branch to use signed just in case. BPL $06 ;/ org $02C64A ;\chargin chuck part where it runs noisly autoclean JSL Chuck3 ;|towards the player and silent if mario's nop #6 ;|Y position is far enough from the chuck's. org $02C654 ;| BPL $12 ;| org $02C6BA ;| autoclean JSL Chuck4 ;| nop #6 ;| org $02C6C4 ;| BPL $11 ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $02C05C ;\Horizontal check autoclean JSL RipVanFish ;| nop #5 ;| org $02C065 ;| BPL $14 ;/ org $02C067 ;\vertical check autoclean JSL RipVanFish2 ;| nop #5 ;| org $02C070 ;| BPL $09 ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $02E143 ;\Horizontal check autoclean JSL JumpingPiranhaPlant ;| nop #8 ;| org $02E14D ;| BMI $09 ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org $018ED0 ;\Horizontal check autoclean JSL ClassicPiranhaPlant ;| nop #6 ;| org $018EDF ;| BMI $0D ;/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Search freespace ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; freecode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;thwomp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Thwompfix_sub: ;>$01AECB BNE + ;>Restore code LDY #$D1 ;>current x position JSR SubHorizPos16Bit SEP #$20 JML $01AED0 ;>continue on determining which side mario is on. + JML $01AEF9 ;>Restore code Thwompfix_range: ;>$01AED7 REP #$21 ;>Clear carry and 16-bit A LDA $02 ;CLC ;suspicious look. ADC #$0040 ; CMP #$0080 ; SEP #$20 ; RTL Thwompfix_range2: ;>$01AEE5 REP #$21 LDA $02 ;angry and fall. ;CLC ; ADC #$0024 ; CMP #$0050 ; SEP #$20 ; RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Falling spike ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FallingSpike_sub_range: LDY #$D1 JSR SubHorizPos16Bit CLC ADC #$0040 CMP #$0080 SEP #$20 RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Yoshi egg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; YoshiEgg_sub_range: LDY #$D1 JSR SubHorizPos16Bit CLC ADC #$0020 CMP #$0040 SEP #$20 RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;chuck, not that this is actually where many sprites call this routine to face mario. ;I have breakpointed at address $01AD30 and keep "step into" until after the RTS, thank god ;that help me find the routine used by the splittin chuck that splits if you get close! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Chuck: ;>$02C360 LDY #$94 ;>Next frame x position. JSR SubHorizPos16Bit CLC ADC #$0030 CMP #$0060 SEP #$20 RTL Chuck2: ;>$02C602 LDY #$94 ;>Next frame x position. JSR SubHorizPos16Bit TYA STA !SprTbl_157C,x REP #$21 LDA $02 ;>Had to load $02 because its replaced by the TYA. ;CLC ADC #$0050 CMP #$00A0 SEP #$20 RTL Chuck3: LDY #$96 ;>Next frame y position. JSR SubVertPos16Bit CLC ADC #$0028 CMP #$0050 SEP #$20 RTL Chuck4: LDY #$96 ;>Next frame y position. JSR SubVertPos16Bit CLC ADC #$0030 CMP #$0060 SEP #$20 RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Rip van fish ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RipVanFish: ;>$02C05C LDY #$94 ;>Next frame x position. JSR SubHorizPos16Bit CLC ADC #$0030 CMP #$0060 SEP #$20 RTL RipVanFish2: ;>$02C067 LDY #$96 ;>Next frame y position. JSR SubVertPos16Bit CLC ADC #$0030 CMP #$0060 SEP #$20 RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Jumping Piranha plant and its fire varient. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; JumpingPiranhaPlant: ;>$02E143 LDY #$94 JSR SubHorizPos16Bit CLC ADC #$001B CMP #$0037 SEP #$20 RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Classic piranha plant and its upsidedown varient. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ClassicPiranhaPlant: ;>$018ED0 LDY #$D1 JSR SubHorizPos16Bit CLC ADC #$001B CMP #$0037 SEP #$20 RTL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;New SubHorizPos subroutine. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; input: either #$D1 or #$94 in Y ; output: Y=1 if mario right to the srite, A=absolute distance in 16-bit + stored into $02. SubHorizPos16Bit: LDA !SprTbl_14E0,x ;\Load x position high byte and transfer it to XBA ;/A's high byte (it still exist even if 8-bit A). LDA !SprTbl_E4,x ;>Load x position low byte. REP #$20 ;>only A is 16-bit, while xy is 8-bit. PHA ;preserve sprite x position LDA !Base1,y ;$00,y = either $D1 or $94 (sa-1) STA $00 ;mariox in $00 LDY #$00 ;so that if mario is on left (causing a >= 0 value), Y = 0 PLA ;restore sprite x back into A SEC SBC $00 ; A = spritex - mariox BPL .skipinvert ; branch if pos = spritex > mariox = mario left of sprite INY ; set Y=1 EOR #$FFFF ;\ A = -A = mariox - spritex INC ;/ .skipinvert STA $02 ; store distance RTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;SubVertPos subroutine 2, based on address $02D50C. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; input: either #$D3 or #$96 in Y ; output: Y=1 if mario right to the srite, A=absolute distance in 16-bit + stored into $02. SubVertPos16Bit: LDA !SprTbl_14D4,x ;\Load y position high byte and transfer it to XBA ;/A's high byte (it still exist even if 8-bit A). LDA !SprTbl_D8,x ;>Load y position low byte. REP #$20 ;>only A is 16-bit, while xy is 8-bit. PHA ;preserve sprite y position LDA !Base1,y ;$00,y = either $D1 or $94 (sa-1) STA $00 ;marioy in $00 LDY #$00 ;so that if mario is on left (causing a >= 0 value), Y = 0 PLA ;restore sprite x back into A SEC SBC $00 ; A = spritey - marioy BPL .skipinvert ; branch if pos = spritex > mariox = mario left of sprite INY ; set Y=1 EOR #$FFFF ;\ A = -A = mariox - spritex INC ;/ .skipinvert STA $02 ; store distance RTS