Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Prevents keys in egg slots from being displaced if you have 6 keys ;
- ; ;
- ; A port of the 6 keys fix from SNES YI: ;
- ; https://www.smwcentral.net/?p=section&a=details&id=13207 ;
- ; ;
- ; Warning: Don't use 6 keys and a Super Star in the same level! If you collect ;
- ; a Super Star with 6 keys, the large Yoshi egg despawns and you softlock. ;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- .gba
- .open "sma3.gba", "sma3-6keys.gba", 0x08000000
- .org 0x0804C578
- .area @AreaEnd-org()
- ; r0: offset to sprite slot to be destroyed, from start of sprite structs
- ; r4: pointer to new egg's struct
- ldr r2,[0x0804C6D4] ; 0300702C: pointer to sprite structs
- ldr r1,[r2] ; 03002460: sprite structs
- add r2,r1,r0 ; pointer to sprite to be destroyed
- ldrh r0,[r2,0x32] ; sprite ID, to be destroyed
- cmp r0,0x27 ; 27: key
- bne @@NotKey
- mov r2,r4 ; if key, destroy new egg instead
- @@NotKey:
- ; mostly vanilla code starting at 0804C584
- ; excess instructions were removed, to avoid freespace usage
- mov r1,0x0
- mov r0,0x7 ;\
- strh r0,[r2,0x24] ;/ set sprite status to 7 (falling off screen)
- mov r0,r2
- add r0,0x5E ; sprite+5E
- strh r1,[r0] ; clear sprite+5E
- strh r1,[r0,0x1C] ; clear sprite+7A
- strh r1,[r0,0x18] ; clear sprite+76
- strh r1,[r0,0x14] ; clear sprite+72
- strh r1,[r0,0x10] ; clear sprite+6E
- strh r1,[r0,0xC] ; clear sprite+6A
- ldr r1,[0x0804C6D8] ; 08171FB0: sprite X velocities (00000100, FFFFFF00)
- add r0,0x41 ; sprite+9F
- ldrb r0,[r0]
- lsl r0,r0,0x1 ; offset table with [sprite+9F]*2
- ldr r0,[r1,r0]
- str r0,[r2,0x8] ; set sprite X velocity
- ldr r0,[0x0804C6DC] ; FFFFFC00
- str r0,[r2,0xC] ; set sprite Y velocity
- mov r0,0x40
- str r0,[r2,0x14] ; set sprite Y accel
- ; if new egg was destroyed, return early
- cmp r2,r4
- bne @AreaEnd
- b 0x0804C6AC ; return
- .fill @AreaEnd-org()
- .endarea
- .org 0x0804C5BC
- @AreaEnd:
- .close
Add Comment
Please, Sign In to add comment