2018-01-24 16:17:05 +00:00
|
|
|
; HealMachineAnim.Jumptable indexes
|
2018-01-18 05:57:06 +00:00
|
|
|
const_def
|
|
|
|
const HEALMACHINESTATE_LOADGFX
|
|
|
|
const HEALMACHINESTATE_PCLOADBALLS
|
|
|
|
const HEALMACHINESTATE_HOFLOADBALLS
|
|
|
|
const HEALMACHINESTATE_PLAYMUSIC
|
|
|
|
const HEALMACHINESTATE_HOFPLAYSFX
|
|
|
|
const HEALMACHINESTATE_FINISH
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
HealMachineAnim:
|
2015-11-11 21:11:08 +00:00
|
|
|
; If you have no Pokemon, don't change the buffer. This can lead to some glitchy effects if you have no Pokemon.
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2015-11-11 21:11:08 +00:00
|
|
|
and a
|
|
|
|
ret z
|
2018-01-23 22:39:09 +00:00
|
|
|
; The location of the healing machine relative to the player is stored in wScriptVar.
|
2015-11-11 21:11:08 +00:00
|
|
|
; 0: Up and left (Pokemon Center)
|
|
|
|
; 1: Left (Elm's Lab)
|
|
|
|
; 2: Up (Hall of Fame)
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
|
|
|
ld [wBuffer1], a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rOBP1]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wBuffer2], a
|
2015-11-11 21:11:08 +00:00
|
|
|
call .DoJumptableFunctions
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBuffer2]
|
2015-12-09 16:38:40 +00:00
|
|
|
call DmgToCgbObjPal1
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.DoJumptableFunctions:
|
2015-11-11 21:11:08 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wBuffer3], a
|
2015-11-11 21:11:08 +00:00
|
|
|
.jumpable_loop
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBuffer1]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, .Pointers
|
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBuffer3]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld e, a
|
|
|
|
inc a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wBuffer3], a
|
2015-11-11 21:11:08 +00:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
2018-01-18 05:57:06 +00:00
|
|
|
cp HEALMACHINESTATE_FINISH
|
2015-11-11 21:11:08 +00:00
|
|
|
jr z, .finish
|
|
|
|
ld hl, .Jumptable
|
|
|
|
rst JumpTable
|
|
|
|
jr .jumpable_loop
|
|
|
|
|
|
|
|
.finish
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Pointers:
|
2018-01-12 06:40:20 +00:00
|
|
|
; entries correspond to HEALMACHINE_* constants
|
2015-11-11 21:11:08 +00:00
|
|
|
dw .Pokecenter
|
|
|
|
dw .ElmLab
|
|
|
|
dw .HallOfFame
|
|
|
|
|
2018-01-18 05:57:06 +00:00
|
|
|
healmachineanimseq: MACRO
|
|
|
|
rept _NARG
|
|
|
|
db HEALMACHINESTATE_\1
|
|
|
|
shift
|
|
|
|
endr
|
|
|
|
ENDM
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Pokecenter:
|
2018-01-18 05:57:06 +00:00
|
|
|
healmachineanimseq LOADGFX, PCLOADBALLS, PLAYMUSIC, FINISH
|
2018-06-24 14:09:41 +00:00
|
|
|
.ElmLab:
|
2018-01-18 05:57:06 +00:00
|
|
|
healmachineanimseq LOADGFX, PCLOADBALLS, PLAYMUSIC, FINISH
|
2018-06-24 14:09:41 +00:00
|
|
|
.HallOfFame:
|
2018-01-18 05:57:06 +00:00
|
|
|
healmachineanimseq LOADGFX, HOFLOADBALLS, HOFPLAYSFX, FINISH
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Jumptable:
|
2018-01-18 05:57:06 +00:00
|
|
|
; entries correspond to HEALMACHINESTATE_* constants
|
2015-11-11 21:11:08 +00:00
|
|
|
dw .LoadGFX
|
|
|
|
dw .PC_LoadBallsOntoMachine
|
|
|
|
dw .HOF_LoadBallsOntoMachine
|
|
|
|
dw .PlayHealMusic
|
|
|
|
dw .HOF_PlaySFX
|
|
|
|
dw .dummy_5 ; never encountered
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.LoadGFX:
|
2015-11-11 21:11:08 +00:00
|
|
|
call .LoadPalettes
|
|
|
|
ld de, .HealMachineGFX
|
2017-12-28 12:32:33 +00:00
|
|
|
ld hl, vTiles0 tile $7c
|
2018-01-10 18:47:57 +00:00
|
|
|
lb bc, BANK(.HealMachineGFX), 2
|
2015-11-11 21:11:08 +00:00
|
|
|
call Request2bpp
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PC_LoadBallsOntoMachine:
|
2018-01-30 19:52:46 +00:00
|
|
|
ld hl, wVirtualOAMSprite32
|
2016-01-10 22:44:09 +00:00
|
|
|
ld de, .PC_ElmsLab_OAM
|
2015-11-11 21:11:08 +00:00
|
|
|
call .PlaceHealingMachineTile
|
|
|
|
call .PlaceHealingMachineTile
|
|
|
|
jr .LoadBallsOntoMachine
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.HOF_LoadBallsOntoMachine:
|
2018-01-30 19:52:46 +00:00
|
|
|
ld hl, wVirtualOAMSprite32
|
2016-01-10 22:44:09 +00:00
|
|
|
ld de, .HOF_OAM
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.LoadBallsOntoMachine:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2015-11-11 21:11:08 +00:00
|
|
|
ld b, a
|
|
|
|
.party_loop
|
|
|
|
call .PlaceHealingMachineTile
|
|
|
|
push de
|
|
|
|
ld de, SFX_SECOND_PART_OF_ITEMFINDER
|
|
|
|
call PlaySFX
|
|
|
|
pop de
|
|
|
|
ld c, 30
|
|
|
|
call DelayFrames
|
|
|
|
dec b
|
|
|
|
jr nz, .party_loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PlayHealMusic:
|
2015-11-11 21:11:08 +00:00
|
|
|
ld de, MUSIC_HEAL
|
|
|
|
call PlayMusic
|
|
|
|
jp .FlashPalettes8Times
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.HOF_PlaySFX:
|
2015-11-11 21:11:08 +00:00
|
|
|
ld de, SFX_GAME_FREAK_LOGO_GS
|
|
|
|
call PlaySFX
|
|
|
|
call .FlashPalettes8Times
|
|
|
|
call WaitSFX
|
|
|
|
ld de, SFX_BOOT_PC
|
|
|
|
call PlaySFX
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.dummy_5
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PC_ElmsLab_OAM:
|
`dsprite y, ypx, x, xpx, off, attr` -> `dbsprite x, y, xpx, ypx, off, attr`
2020-04-04 20:00:30 +00:00
|
|
|
dbsprite 4, 4, 2, 0, $7c, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 4, 4, 6, 0, $7c, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 4, 4, 0, 6, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 5, 4, 0, 6, $7d, PAL_OW_TREE | OBP_NUM | X_FLIP
|
|
|
|
dbsprite 4, 5, 0, 3, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 5, 5, 0, 3, $7d, PAL_OW_TREE | OBP_NUM | X_FLIP
|
|
|
|
dbsprite 4, 6, 0, 0, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 5, 6, 0, 0, $7d, PAL_OW_TREE | OBP_NUM | X_FLIP
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.HealMachineGFX:
|
2017-12-11 05:17:39 +00:00
|
|
|
INCBIN "gfx/overworld/heal_machine.2bpp"
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.HOF_OAM:
|
`dsprite y, ypx, x, xpx, off, attr` -> `dbsprite x, y, xpx, ypx, off, attr`
2020-04-04 20:00:30 +00:00
|
|
|
dbsprite 10, 7, 1, 4, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 10, 7, 6, 4, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 9, 7, 5, 3, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 11, 7, 2, 3, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 9, 7, 1, 1, $7d, PAL_OW_TREE | OBP_NUM
|
|
|
|
dbsprite 11, 7, 5, 1, $7d, PAL_OW_TREE | OBP_NUM
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.LoadPalettes:
|
2015-11-11 21:11:08 +00:00
|
|
|
call IsCGB
|
|
|
|
jr nz, .cgb
|
|
|
|
ld a, %11100000
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rOBP1], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
.cgb
|
|
|
|
ld hl, .palettes
|
2018-01-01 14:08:21 +00:00
|
|
|
ld de, wOBPals2 palette PAL_OW_TREE
|
2017-12-27 01:33:41 +00:00
|
|
|
ld bc, 1 palettes
|
2018-01-04 19:53:50 +00:00
|
|
|
ld a, BANK(wOBPals2)
|
2015-11-11 21:11:08 +00:00
|
|
|
call FarCopyWRAM
|
2020-08-03 21:41:01 +00:00
|
|
|
ld a, TRUE
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hCGBPalUpdate], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.palettes
|
2018-01-12 19:54:00 +00:00
|
|
|
INCLUDE "gfx/overworld/heal_machine.pal"
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.FlashPalettes8Times:
|
2018-01-12 19:54:00 +00:00
|
|
|
ld c, 8
|
2015-11-11 21:11:08 +00:00
|
|
|
.palette_loop
|
|
|
|
push bc
|
|
|
|
call .FlashPalettes
|
|
|
|
ld c, 10
|
|
|
|
call DelayFrames
|
|
|
|
pop bc
|
|
|
|
dec c
|
|
|
|
jr nz, .palette_loop
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.FlashPalettes:
|
2015-11-11 21:11:08 +00:00
|
|
|
call IsCGB
|
|
|
|
jr nz, .go
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rOBP1]
|
2015-11-11 21:11:08 +00:00
|
|
|
xor %00101000
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rOBP1], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
.go
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rSVBK]
|
2015-11-11 21:11:08 +00:00
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wOBPals2)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2015-11-11 21:11:08 +00:00
|
|
|
|
2018-01-01 14:08:21 +00:00
|
|
|
ld hl, wOBPals2 palette PAL_OW_TREE
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
push de
|
|
|
|
ld c, $3
|
|
|
|
.palette_loop_2
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hld]
|
|
|
|
ld d, a
|
|
|
|
dec hl
|
|
|
|
ld a, d
|
|
|
|
ld [hld], a
|
|
|
|
ld a, e
|
|
|
|
ld [hli], a
|
|
|
|
inc hl
|
2016-05-10 16:31:49 +00:00
|
|
|
inc hl
|
|
|
|
inc hl
|
2015-11-11 21:11:08 +00:00
|
|
|
dec c
|
|
|
|
jr nz, .palette_loop_2
|
|
|
|
pop de
|
|
|
|
dec hl
|
|
|
|
ld a, d
|
|
|
|
ld [hld], a
|
|
|
|
ld a, e
|
|
|
|
ld [hl], a
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rSVBK], a
|
2020-08-03 21:41:01 +00:00
|
|
|
ld a, TRUE
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hCGBPalUpdate], a
|
2015-11-11 21:11:08 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.PlaceHealingMachineTile:
|
2015-11-11 21:11:08 +00:00
|
|
|
push bc
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wBuffer1]
|
2016-01-10 22:44:09 +00:00
|
|
|
bcpixel 2, 4
|
2018-01-18 05:57:06 +00:00
|
|
|
cp HEALMACHINE_ELMS_LAB
|
2015-11-11 21:11:08 +00:00
|
|
|
jr z, .okay
|
2016-01-10 22:44:09 +00:00
|
|
|
bcpixel 0, 0
|
2015-11-11 21:11:08 +00:00
|
|
|
|
|
|
|
.okay
|
|
|
|
ld a, [de]
|
|
|
|
add c
|
|
|
|
inc de
|
2018-01-10 18:47:57 +00:00
|
|
|
ld [hli], a ; y
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [de]
|
|
|
|
add b
|
|
|
|
inc de
|
2018-01-10 18:47:57 +00:00
|
|
|
ld [hli], a ; x
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2018-01-10 18:47:57 +00:00
|
|
|
ld [hli], a ; tile id
|
2015-11-11 21:11:08 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
2018-01-10 18:47:57 +00:00
|
|
|
ld [hli], a ; attributes
|
2015-11-11 21:11:08 +00:00
|
|
|
pop bc
|
|
|
|
ret
|