shithub: pokecrystal

Download patch

ref: 92e80be51b3ec02c77b3d0365722f0e8c50af2d7
parent: a99c75b7cd19cb267b4340d56a2197ddabcf99a3
author: IIMarckus <iimarckus@gmail.com>
date: Wed Jul 4 18:13:23 EDT 2012

Add Special 0x60, which checks the conditions for Snorlax to wake up.

--- a/main.asm
+++ b/main.asm
@@ -654,7 +654,7 @@
 	dbw $0a,$6567
 	dbw $05,$4209
 	dbw $3e,$7841
-	dbw $03,$443d
+	dbw BANK(SpecialSnorlaxAwake),SpecialSnorlaxAwake
 	dbw $01,$7413
 	dbw $01,$7418
 	dbw $01,$741d
@@ -728,7 +728,58 @@
 	dbw $24,$4a88
 	dbw $03,$4224
 
-INCBIN "baserom.gbc",$c224,$c5d2 - $c224
+INCBIN "baserom.gbc",$c224,$c43d - $c224
+
+SpecialSnorlaxAwake: ; 0xc43d
+; Check if the Poké Flute channel is playing, and if the player is standing
+; next to Snorlax.
+
+; outputs:
+; $c2dd is 1 if the conditions are met, otherwise 0.
+
+; check background music
+	ld a, [$c2c0]
+	cp $40 ; Poké Flute Channel
+	jr nz, .nope
+
+	ld a, [XCoord]
+	ld b, a
+	ld a, [YCoord]
+	ld c, a
+
+	ld hl, .ProximityCoords
+.loop
+	ld a, [hli]
+	cp $ff
+	jr z, .nope
+	cp b
+	jr nz, .nextcoord
+	ld a, [hli]
+	cp c
+	jr nz, .loop
+
+	ld a, $1
+	jr .done
+
+.nextcoord
+	inc hl
+	jr .loop
+
+.nope
+	xor a
+.done
+	ld [$c2dd], a
+	ret
+
+.ProximityCoords
+	db $21,$08
+	db $22,$0a
+	db $23,$0a
+	db $24,$08
+	db $24,$09
+	db $ff
+
+INCBIN "baserom.gbc",$c472,$c5d2 - $c472
 
 PrintNumber_PrintDigit: ; c5d2
 INCBIN "baserom.gbc",$c5d2,$c644 - $c5d2
--- a/wram.asm
+++ b/wram.asm
@@ -641,6 +641,19 @@
 Box14Name: ; 0xdb3a
 	ds 9
 
+SECTION "PlayerMapInfo", BSS[$dcb4]
+
+WarpNumber: ; 0xdcb4
+	ds 1
+MapGroup: ; 0xdcb5
+	ds 1 ; map group of current map
+MapNumber: ; 0xdcb6
+	ds 1 ; map number of current map
+YCoord: ; 0xdcb7
+	ds 1 ; current y coordinate relative to top-left corner of current map
+XCoord: ; 0xdcb8
+	ds 1 ; current x coordinate relative to top-left corner of current map
+
 SECTION "PlayerParty",BSS[$dcd7]
 
 PartyCount: ; 0xdcd7
--