2018-06-24 07:09:41 -07:00
|
|
|
MagnetTrain:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wScriptVar]
|
2015-11-16 18:46:36 -08:00
|
|
|
and a
|
|
|
|
jr nz, .ToGoldenrod
|
|
|
|
ld a, 1 ; forwards
|
2019-05-02 10:31:45 -07:00
|
|
|
lb bc, 8 * TILE_WIDTH, 12 * TILE_WIDTH
|
|
|
|
lb de, (11 * TILE_WIDTH) - (11 * TILE_WIDTH + 4), -12 * TILE_WIDTH
|
2015-11-16 18:46:36 -08:00
|
|
|
jr .continue
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.ToGoldenrod:
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, -1 ; backwards
|
2019-05-02 10:31:45 -07:00
|
|
|
lb bc, -8 * TILE_WIDTH, -12 * TILE_WIDTH
|
|
|
|
lb de, (11 * TILE_WIDTH) + (11 * TILE_WIDTH + 4), 12 * TILE_WIDTH
|
2015-11-16 18:46:36 -08:00
|
|
|
|
|
|
|
.continue
|
|
|
|
ld h, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wMagnetTrain)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-12-18 17:07:09 -08:00
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, h
|
2015-12-18 17:07:09 -08:00
|
|
|
ld [wMagnetTrainDirection], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, c
|
2015-12-18 17:07:09 -08:00
|
|
|
ld [wMagnetTrainInitPosition], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, b
|
2015-12-18 17:07:09 -08:00
|
|
|
ld [wMagnetTrainHoldPosition], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, e
|
2015-12-18 17:07:09 -08:00
|
|
|
ld [wMagnetTrainFinalPosition], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, d
|
2015-12-18 17:07:09 -08:00
|
|
|
ld [wMagnetTrainPlayerSpriteInitX], a
|
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hSCX]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hSCY]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2019-05-02 10:31:45 -07:00
|
|
|
call MagnetTrain_LoadGFX_PlayMusic
|
2015-11-16 18:46:36 -08:00
|
|
|
ld hl, hVBlank
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
2019-05-02 10:31:45 -07:00
|
|
|
ld [hl], 1
|
2015-11-16 18:46:36 -08:00
|
|
|
.loop
|
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
and a
|
|
|
|
jr z, .initialize
|
|
|
|
bit 7, a
|
|
|
|
jr nz, .done
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar PlaySpriteAnimations
|
2015-12-18 17:07:09 -08:00
|
|
|
call MagnetTrain_Jumptable
|
|
|
|
call MagnetTrain_UpdateLYOverrides
|
2016-05-10 09:31:49 -07:00
|
|
|
call PushLYOverrides
|
2015-11-16 18:46:36 -08:00
|
|
|
call DelayFrame
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.initialize
|
2015-12-18 17:07:09 -08:00
|
|
|
call MagnetTrain_Jumptable_FirstRunThrough
|
2015-11-16 18:46:36 -08:00
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hVBlank], a
|
2015-11-16 18:46:36 -08:00
|
|
|
call ClearBGPalettes
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hLCDCPointer], a
|
|
|
|
ldh [hLYOverrideStart], a
|
|
|
|
ldh [hLYOverrideEnd], a
|
|
|
|
ldh [hSCX], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wRequested2bppSource], a
|
|
|
|
ld [wRequested2bppSource + 1], a
|
|
|
|
ld [wRequested2bppDest], a
|
|
|
|
ld [wRequested2bppDest + 1], a
|
2020-10-26 12:45:57 -07:00
|
|
|
ld [wRequested2bppSize], a
|
2020-02-13 09:30:13 -08:00
|
|
|
call ClearTilemap
|
2015-12-18 17:07:09 -08:00
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hSCY], a
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hSCX], a
|
2015-11-16 18:46:36 -08:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2020-06-16 16:32:36 -07:00
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MagnetTrain_UpdateLYOverrides:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wLYOverridesBackup
|
2019-05-02 10:31:45 -07:00
|
|
|
ld c, 6 * TILE_WIDTH - 1
|
2018-01-11 12:36:11 -08:00
|
|
|
ld a, [wMagnetTrainOffset]
|
2015-11-16 18:46:36 -08:00
|
|
|
add a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hSCX], a
|
2015-12-18 17:07:09 -08:00
|
|
|
call .loadloop
|
2019-05-02 10:31:45 -07:00
|
|
|
ld c, 6 * TILE_WIDTH
|
2018-01-11 12:36:11 -08:00
|
|
|
ld a, [wMagnetTrainPosition]
|
2015-12-18 17:07:09 -08:00
|
|
|
call .loadloop
|
2019-05-02 10:31:45 -07:00
|
|
|
ld c, 6 * TILE_WIDTH + 1
|
2018-01-11 12:36:11 -08:00
|
|
|
ld a, [wMagnetTrainOffset]
|
2015-11-16 18:46:36 -08:00
|
|
|
add a
|
2015-12-18 17:07:09 -08:00
|
|
|
call .loadloop
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-16 18:46:36 -08:00
|
|
|
ld d, a
|
2018-01-11 12:36:11 -08:00
|
|
|
ld hl, wMagnetTrainOffset
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, [hl]
|
|
|
|
add d
|
2016-05-04 08:46:23 -07:00
|
|
|
add d
|
2015-11-16 18:46:36 -08:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2015-12-18 17:07:09 -08:00
|
|
|
.loadloop
|
2015-11-16 18:46:36 -08:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2015-12-18 17:07:09 -08:00
|
|
|
jr nz, .loadloop
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2019-05-02 10:31:45 -07:00
|
|
|
MagnetTrain_LoadGFX_PlayMusic:
|
2015-11-16 18:46:36 -08:00
|
|
|
call ClearBGPalettes
|
|
|
|
call ClearSprites
|
|
|
|
call DisableLCD
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar ClearSpriteAnims
|
2015-11-16 18:46:36 -08:00
|
|
|
call SetMagnetTrainPals
|
|
|
|
call DrawMagnetTrain
|
2019-05-02 10:31:45 -07:00
|
|
|
ld a, SCREEN_HEIGHT_PX
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hWY], a
|
2015-11-16 18:46:36 -08:00
|
|
|
call EnableLCD
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
|
|
|
ldh [hSCX], a
|
|
|
|
ldh [hSCY], a
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2020-06-16 16:32:36 -07:00
|
|
|
; Load the player sprite's standing frames
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wPlayerGender)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall GetPlayerIcon
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2017-12-28 04:32:33 -08:00
|
|
|
ld hl, vTiles0
|
2015-12-18 17:07:09 -08:00
|
|
|
ld c, 4
|
2015-11-16 18:46:36 -08:00
|
|
|
call Request2bpp
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2020-06-16 16:32:36 -07:00
|
|
|
; Load the player sprite's walking frames
|
2015-12-18 17:07:09 -08:00
|
|
|
ld hl, 12 tiles
|
2015-11-16 18:46:36 -08:00
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2017-12-28 04:32:33 -08:00
|
|
|
ld hl, vTiles0 tile $04
|
2015-12-18 17:07:09 -08:00
|
|
|
ld c, 4
|
2015-11-16 18:46:36 -08:00
|
|
|
call Request2bpp
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2015-12-18 17:07:09 -08:00
|
|
|
call MagnetTrain_InitLYOverrides
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
xor a
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [hli], a ; wJumptableIndex
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainInitPosition]
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [hli], a ; wMagnetTrainOffset
|
|
|
|
ld [hli], a ; wMagnetTrainPosition
|
|
|
|
ld [hli], a ; wMagnetTrainWaitCounter
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
ld de, MUSIC_MAGNET_TRAIN
|
|
|
|
call PlayMusic2
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
DrawMagnetTrain:
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 0
|
2015-11-16 18:46:36 -08:00
|
|
|
xor a
|
2015-12-18 17:07:09 -08:00
|
|
|
.loop
|
2015-11-16 18:46:36 -08:00
|
|
|
call GetMagnetTrainBGTiles
|
2019-05-02 10:31:45 -07:00
|
|
|
ld b, BG_MAP_WIDTH / 2
|
2015-11-16 18:46:36 -08:00
|
|
|
call .FillAlt
|
|
|
|
inc a
|
2019-05-02 10:31:45 -07:00
|
|
|
cp SCREEN_HEIGHT
|
2015-12-18 17:07:09 -08:00
|
|
|
jr c, .loop
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 6
|
2019-05-02 10:31:45 -07:00
|
|
|
ld de, MagnetTrainTilemap
|
2019-08-11 15:48:26 -07:00
|
|
|
ld c, SCREEN_WIDTH
|
2015-11-16 18:46:36 -08:00
|
|
|
call .FillLine
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 7
|
2019-08-11 15:48:26 -07:00
|
|
|
ld de, MagnetTrainTilemap + SCREEN_WIDTH
|
|
|
|
ld c, SCREEN_WIDTH
|
2015-11-16 18:46:36 -08:00
|
|
|
call .FillLine
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 8
|
2019-08-11 15:48:26 -07:00
|
|
|
ld de, MagnetTrainTilemap + (SCREEN_WIDTH * 2)
|
|
|
|
ld c, SCREEN_WIDTH
|
2015-11-16 18:46:36 -08:00
|
|
|
call .FillLine
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 9
|
2019-08-11 15:48:26 -07:00
|
|
|
ld de, MagnetTrainTilemap + (SCREEN_WIDTH * 3)
|
|
|
|
ld c, SCREEN_WIDTH
|
2015-11-16 18:46:36 -08:00
|
|
|
call .FillLine
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FillLine:
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .FillLine
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.FillAlt:
|
2015-11-16 18:46:36 -08:00
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
dec b
|
|
|
|
jr nz, .FillAlt
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMagnetTrainBGTiles:
|
2015-11-16 18:46:36 -08:00
|
|
|
push hl
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, MagnetTrainBGTiles
|
|
|
|
add hl, de
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, de
|
2015-11-16 18:46:36 -08:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MagnetTrainBGTiles:
|
2019-08-11 15:48:26 -07:00
|
|
|
; 2x18 tilemap, repeated in vertical strips for the background.
|
|
|
|
INCBIN "gfx/overworld/magnet_train_bg.tilemap"
|
2015-11-16 18:46:36 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MagnetTrain_InitLYOverrides:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wLYOverrides
|
|
|
|
ld bc, wLYOverridesEnd - wLYOverrides
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainInitPosition]
|
2015-11-16 18:46:36 -08:00
|
|
|
call ByteFill
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wLYOverridesBackup
|
|
|
|
ld bc, wLYOverridesBackupEnd - wLYOverridesBackup
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainInitPosition]
|
2015-11-16 18:46:36 -08:00
|
|
|
call ByteFill
|
2018-08-25 11:34:25 -07:00
|
|
|
ld a, LOW(rSCX)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hLCDCPointer], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SetMagnetTrainPals:
|
2019-05-02 10:31:45 -07:00
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-16 18:46:36 -08:00
|
|
|
|
|
|
|
; bushes
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 0
|
2017-12-29 15:59:50 -08:00
|
|
|
ld bc, 4 * BG_MAP_WIDTH
|
2018-01-10 22:45:27 -08:00
|
|
|
ld a, PAL_BG_GREEN
|
2015-11-16 18:46:36 -08:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; train
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 4
|
2017-12-29 15:59:50 -08:00
|
|
|
ld bc, 10 * BG_MAP_WIDTH
|
2018-01-10 22:45:27 -08:00
|
|
|
xor a ; PAL_BG_GRAY
|
2015-11-16 18:46:36 -08:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; more bushes
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 0, 14
|
2017-12-29 15:59:50 -08:00
|
|
|
ld bc, 4 * BG_MAP_WIDTH
|
2018-01-10 22:45:27 -08:00
|
|
|
ld a, PAL_BG_GREEN
|
2015-11-16 18:46:36 -08:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; train window
|
2015-11-20 08:47:52 -08:00
|
|
|
hlbgcoord 7, 8
|
2015-11-16 18:46:36 -08:00
|
|
|
ld bc, 6
|
2018-01-10 22:45:27 -08:00
|
|
|
ld a, PAL_BG_YELLOW
|
2015-11-16 18:46:36 -08:00
|
|
|
call ByteFill
|
|
|
|
|
2019-05-02 10:31:45 -07:00
|
|
|
ld a, 0
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MagnetTrain_Jumptable:
|
2020-07-01 10:13:49 -07:00
|
|
|
jumptable .Jumptable, wJumptableIndex
|
2015-11-16 18:46:36 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Jumptable:
|
2015-12-26 18:59:03 -08:00
|
|
|
dw .InitPlayerSpriteAnim
|
|
|
|
dw .WaitScene
|
|
|
|
dw .MoveTrain1
|
|
|
|
dw .WaitScene
|
|
|
|
dw .MoveTrain2
|
|
|
|
dw .WaitScene
|
|
|
|
dw .TrainArrived
|
2015-11-16 18:46:36 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Next:
|
2015-11-16 18:46:36 -08:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.InitPlayerSpriteAnim:
|
2019-05-02 10:31:45 -07:00
|
|
|
ld d, (8 + 2) * TILE_WIDTH + 5
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainPlayerSpriteInitX]
|
2015-11-16 18:46:36 -08:00
|
|
|
ld e, a
|
2017-12-08 21:50:59 -08:00
|
|
|
ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wPlayerGender)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2017-12-28 04:15:46 -08:00
|
|
|
ld a, [wPlayerGender]
|
2018-01-22 11:34:55 -08:00
|
|
|
bit PLAYERGENDER_FEMALE_F, a
|
2015-12-18 17:07:09 -08:00
|
|
|
jr z, .got_gender
|
2017-12-08 21:50:59 -08:00
|
|
|
ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_BLUE
|
2015-12-18 17:07:09 -08:00
|
|
|
.got_gender
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, b
|
2020-02-11 04:42:36 -08:00
|
|
|
call InitSpriteAnimStruct
|
2015-12-18 17:07:09 -08:00
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-16 18:46:36 -08:00
|
|
|
add hl, bc
|
2019-05-02 10:31:45 -07:00
|
|
|
ld [hl], 0
|
2015-12-18 17:07:09 -08:00
|
|
|
call .Next
|
2019-05-02 10:31:45 -07:00
|
|
|
ld a, 128
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [wMagnetTrainWaitCounter], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.MoveTrain1:
|
2015-12-18 17:07:09 -08:00
|
|
|
ld hl, wMagnetTrainHoldPosition
|
2018-01-11 12:36:11 -08:00
|
|
|
ld a, [wMagnetTrainPosition]
|
2015-11-16 18:46:36 -08:00
|
|
|
cp [hl]
|
2015-12-18 17:07:09 -08:00
|
|
|
jr z, .PrepareToHoldTrain
|
2015-11-16 18:46:36 -08:00
|
|
|
ld e, a
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-16 18:46:36 -08:00
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
add e
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [wMagnetTrainPosition], a
|
2015-12-02 14:59:05 -08:00
|
|
|
ld hl, wGlobalAnimXOffset
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-16 18:46:36 -08:00
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.PrepareToHoldTrain:
|
2015-12-18 17:07:09 -08:00
|
|
|
call .Next
|
2019-05-02 10:31:45 -07:00
|
|
|
ld a, 128
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [wMagnetTrainWaitCounter], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.WaitScene:
|
2018-01-11 12:36:11 -08:00
|
|
|
ld hl, wMagnetTrainWaitCounter
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-18 17:07:09 -08:00
|
|
|
jr z, .DoneWaiting
|
2015-11-16 18:46:36 -08:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.DoneWaiting:
|
2015-12-18 17:07:09 -08:00
|
|
|
call .Next
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.MoveTrain2:
|
2015-12-18 17:07:09 -08:00
|
|
|
ld hl, wMagnetTrainFinalPosition
|
2018-01-11 12:36:11 -08:00
|
|
|
ld a, [wMagnetTrainPosition]
|
2015-11-16 18:46:36 -08:00
|
|
|
cp [hl]
|
2015-12-18 17:07:09 -08:00
|
|
|
jr z, .PrepareToFinishAnim
|
2015-11-16 18:46:36 -08:00
|
|
|
ld e, a
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-16 18:46:36 -08:00
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
ld d, a
|
|
|
|
ld a, e
|
|
|
|
add d
|
2016-05-04 08:46:23 -07:00
|
|
|
add d
|
2018-01-11 12:36:11 -08:00
|
|
|
ld [wMagnetTrainPosition], a
|
2015-12-02 14:59:05 -08:00
|
|
|
ld hl, wGlobalAnimXOffset
|
2015-12-18 17:07:09 -08:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-16 18:46:36 -08:00
|
|
|
ld d, a
|
|
|
|
ld a, [hl]
|
|
|
|
add d
|
2016-05-04 08:46:23 -07:00
|
|
|
add d
|
2015-11-16 18:46:36 -08:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.PrepareToFinishAnim:
|
2015-12-18 17:07:09 -08:00
|
|
|
call .Next
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.TrainArrived:
|
2015-11-16 18:46:36 -08:00
|
|
|
ld a, $80
|
|
|
|
ld [wJumptableIndex], a
|
|
|
|
ld de, SFX_TRAIN_ARRIVED
|
|
|
|
call PlaySFX
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MagnetTrain_Jumptable_FirstRunThrough:
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall PlaySpriteAnimations
|
2015-12-18 17:07:09 -08:00
|
|
|
call MagnetTrain_Jumptable
|
|
|
|
call MagnetTrain_UpdateLYOverrides
|
2016-05-10 09:31:49 -07:00
|
|
|
call PushLYOverrides
|
2015-11-16 18:46:36 -08:00
|
|
|
call DelayFrame
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rSVBK]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2018-01-03 16:12:45 -08:00
|
|
|
ld a, BANK(wEnvironment)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDayPal]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2017-12-24 10:08:38 -08:00
|
|
|
ld a, [wEnvironment]
|
2015-11-16 18:46:36 -08:00
|
|
|
push af
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTimeOfDay]
|
2018-01-16 14:27:50 -08:00
|
|
|
maskbits NUM_DAYTIMES
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTimeOfDayPal], a
|
2023-08-04 09:45:50 -07:00
|
|
|
ld a, OUTDOOR_GRASSY
|
2017-12-24 10:08:38 -08:00
|
|
|
ld [wEnvironment], a
|
2023-07-26 08:01:20 -07:00
|
|
|
ld b, CGB_MAPPALS
|
|
|
|
call GetCGBLayout
|
2015-11-16 18:46:36 -08:00
|
|
|
call UpdateTimePals
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rBGP]
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wBGP], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rOBP0]
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wOBP0], a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rOBP1]
|
2015-12-23 11:00:29 -08:00
|
|
|
ld [wOBP1], a
|
2019-05-02 10:31:45 -07:00
|
|
|
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2017-12-24 10:08:38 -08:00
|
|
|
ld [wEnvironment], a
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTimeOfDayPal], a
|
2015-11-16 18:46:36 -08:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rSVBK], a
|
2015-11-16 18:46:36 -08:00
|
|
|
ret
|
|
|
|
|
2019-05-02 10:31:45 -07:00
|
|
|
MagnetTrainTilemap:
|
2019-08-11 15:48:26 -07:00
|
|
|
; 20x4 tilemap
|
|
|
|
INCBIN "gfx/overworld/magnet_train_fg.tilemap"
|