2018-01-24 16:17:05 +00:00
|
|
|
MagnetTrain: ; 8cc04
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2015-11-17 02:46:36 +00:00
|
|
|
and a
|
|
|
|
jr nz, .ToGoldenrod
|
|
|
|
ld a, 1 ; forwards
|
2015-12-19 01:07:09 +00:00
|
|
|
lb bc, $40, $60
|
|
|
|
lb de, (11 * 8) - (11 * 8 + 4), -$60
|
2015-11-17 02:46:36 +00:00
|
|
|
jr .continue
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.ToGoldenrod:
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, -1 ; backwards
|
2015-12-19 01:07:09 +00:00
|
|
|
lb bc, -$40, -$60
|
|
|
|
lb de, (11 * 8) + (11 * 8 + 4), $60
|
2015-11-17 02:46:36 +00:00
|
|
|
|
|
|
|
.continue
|
|
|
|
ld h, a
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wMagnetTrain)
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [rSVBK], a
|
2015-12-19 01:07:09 +00:00
|
|
|
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, h
|
2015-12-19 01:07:09 +00:00
|
|
|
ld [wMagnetTrainDirection], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, c
|
2015-12-19 01:07:09 +00:00
|
|
|
ld [wMagnetTrainInitPosition], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, b
|
2015-12-19 01:07:09 +00:00
|
|
|
ld [wMagnetTrainHoldPosition], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, e
|
2015-12-19 01:07:09 +00:00
|
|
|
ld [wMagnetTrainFinalPosition], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, d
|
2015-12-19 01:07:09 +00:00
|
|
|
ld [wMagnetTrainPlayerSpriteInitX], a
|
|
|
|
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [hSCX]
|
|
|
|
push af
|
|
|
|
ld a, [hSCY]
|
|
|
|
push af
|
2015-12-19 01:07:09 +00:00
|
|
|
call MagntTrain_LoadGFX_PlayMusic
|
2015-11-17 02:46:36 +00:00
|
|
|
ld hl, hVBlank
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld [hl], $1
|
|
|
|
.loop
|
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
and a
|
|
|
|
jr z, .initialize
|
|
|
|
bit 7, a
|
|
|
|
jr nz, .done
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar PlaySpriteAnimations
|
2015-12-19 01:07:09 +00:00
|
|
|
call MagnetTrain_Jumptable
|
|
|
|
call MagnetTrain_UpdateLYOverrides
|
2016-05-10 16:31:49 +00:00
|
|
|
call PushLYOverrides
|
2015-11-17 02:46:36 +00:00
|
|
|
call DelayFrame
|
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.initialize
|
2015-12-19 01:07:09 +00:00
|
|
|
call MagnetTrain_Jumptable_FirstRunThrough
|
2015-11-17 02:46:36 +00:00
|
|
|
jr .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop af
|
|
|
|
ld [hVBlank], a
|
|
|
|
call ClearBGPalettes
|
|
|
|
xor a
|
2016-06-14 02:53:33 +00:00
|
|
|
ld [hLCDCPointer], a
|
2016-05-05 19:07:37 +00:00
|
|
|
ld [hLYOverrideStart], a
|
|
|
|
ld [hLYOverrideEnd], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [hSCX], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wRequested2bppSource], a
|
|
|
|
ld [wRequested2bppSource + 1], a
|
|
|
|
ld [wRequested2bppDest], a
|
|
|
|
ld [wRequested2bppDest + 1], a
|
|
|
|
ld [wRequested2bpp], a
|
2015-11-17 02:46:36 +00:00
|
|
|
call ClearTileMap
|
2015-12-19 01:07:09 +00:00
|
|
|
|
2015-11-17 02:46:36 +00:00
|
|
|
pop af
|
|
|
|
ld [hSCY], a
|
|
|
|
pop af
|
|
|
|
ld [hSCX], a
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 8cc99
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
MagnetTrain_UpdateLYOverrides: ; 8cc99
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wLYOverridesBackup
|
2015-11-17 02:46:36 +00:00
|
|
|
ld c, $2f
|
2018-01-11 20:36:11 +00:00
|
|
|
ld a, [wMagnetTrainOffset]
|
2015-11-17 02:46:36 +00:00
|
|
|
add a
|
|
|
|
ld [hSCX], a
|
2015-12-19 01:07:09 +00:00
|
|
|
call .loadloop
|
2015-11-17 02:46:36 +00:00
|
|
|
ld c, $30
|
2018-01-11 20:36:11 +00:00
|
|
|
ld a, [wMagnetTrainPosition]
|
2015-12-19 01:07:09 +00:00
|
|
|
call .loadloop
|
2015-11-17 02:46:36 +00:00
|
|
|
ld c, $31
|
2018-01-11 20:36:11 +00:00
|
|
|
ld a, [wMagnetTrainOffset]
|
2015-11-17 02:46:36 +00:00
|
|
|
add a
|
2015-12-19 01:07:09 +00:00
|
|
|
call .loadloop
|
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-17 02:46:36 +00:00
|
|
|
ld d, a
|
2018-01-11 20:36:11 +00:00
|
|
|
ld hl, wMagnetTrainOffset
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [hl]
|
|
|
|
add d
|
2016-05-04 15:46:23 +00:00
|
|
|
add d
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.loadloop
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [hli], a
|
|
|
|
dec c
|
2015-12-19 01:07:09 +00:00
|
|
|
jr nz, .loadloop
|
2015-11-17 02:46:36 +00:00
|
|
|
ret
|
|
|
|
; 8ccc9
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
MagntTrain_LoadGFX_PlayMusic: ; 8ccc9
|
2015-11-17 02:46:36 +00:00
|
|
|
call ClearBGPalettes
|
|
|
|
call ClearSprites
|
|
|
|
call DisableLCD
|
2017-12-24 17:47:30 +00:00
|
|
|
callfar ClearSpriteAnims
|
2015-11-17 02:46:36 +00:00
|
|
|
call SetMagnetTrainPals
|
|
|
|
call DrawMagnetTrain
|
|
|
|
ld a, $90
|
|
|
|
ld [hWY], a
|
|
|
|
call EnableLCD
|
|
|
|
xor a
|
|
|
|
ld [hBGMapMode], a
|
|
|
|
ld [hSCX], a
|
|
|
|
ld [hSCY], a
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wPlayerGender)
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [rSVBK], a
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall GetPlayerIcon
|
2015-11-17 02:46:36 +00:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
2017-12-28 12:32:33 +00:00
|
|
|
ld hl, vTiles0
|
2015-12-19 01:07:09 +00:00
|
|
|
ld c, 4
|
2015-11-17 02:46:36 +00:00
|
|
|
call Request2bpp
|
2015-12-19 01:07:09 +00:00
|
|
|
ld hl, 12 tiles
|
2015-11-17 02:46:36 +00:00
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2017-12-28 12:32:33 +00:00
|
|
|
ld hl, vTiles0 tile $04
|
2015-12-19 01:07:09 +00:00
|
|
|
ld c, 4
|
2015-11-17 02:46:36 +00:00
|
|
|
call Request2bpp
|
2015-12-19 01:07:09 +00:00
|
|
|
call MagnetTrain_InitLYOverrides
|
2015-11-17 02:46:36 +00:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
xor a
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [hli], a ; wJumptableIndex
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainInitPosition]
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [hli], a ; wMagnetTrainOffset
|
|
|
|
ld [hli], a ; wMagnetTrainPosition
|
|
|
|
ld [hli], a ; wMagnetTrainWaitCounter
|
2015-11-17 02:46:36 +00:00
|
|
|
ld de, MUSIC_MAGNET_TRAIN
|
|
|
|
call PlayMusic2
|
|
|
|
ret
|
|
|
|
; 8cd27
|
|
|
|
|
|
|
|
DrawMagnetTrain: ; 8cd27
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 0
|
2015-11-17 02:46:36 +00:00
|
|
|
xor a
|
2015-12-19 01:07:09 +00:00
|
|
|
.loop
|
2015-11-17 02:46:36 +00:00
|
|
|
call GetMagnetTrainBGTiles
|
|
|
|
ld b, 32 / 2
|
|
|
|
call .FillAlt
|
|
|
|
inc a
|
|
|
|
cp $12
|
2015-12-19 01:07:09 +00:00
|
|
|
jr c, .loop
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 6
|
2015-11-17 02:46:36 +00:00
|
|
|
ld de, MagnetTrainTilemap1
|
|
|
|
ld c, 20
|
|
|
|
call .FillLine
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 7
|
2015-11-17 02:46:36 +00:00
|
|
|
ld de, MagnetTrainTilemap2
|
|
|
|
ld c, 20
|
|
|
|
call .FillLine
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 8
|
2015-11-17 02:46:36 +00:00
|
|
|
ld de, MagnetTrainTilemap3
|
|
|
|
ld c, 20
|
|
|
|
call .FillLine
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 9
|
2015-11-17 02:46:36 +00:00
|
|
|
ld de, MagnetTrainTilemap4
|
|
|
|
ld c, 20
|
|
|
|
call .FillLine
|
|
|
|
ret
|
|
|
|
; 8cd65
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.FillLine: ; 8cd65
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [de]
|
|
|
|
inc de
|
|
|
|
ld [hli], a
|
|
|
|
dec c
|
|
|
|
jr nz, .FillLine
|
|
|
|
ret
|
|
|
|
; 8cd6c
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.FillAlt: ; 8cd6c
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [hl], e
|
|
|
|
inc hl
|
|
|
|
ld [hl], d
|
|
|
|
inc hl
|
|
|
|
dec b
|
|
|
|
jr nz, .FillAlt
|
|
|
|
ret
|
|
|
|
; 8cd74
|
|
|
|
|
|
|
|
GetMagnetTrainBGTiles: ; 8cd74
|
|
|
|
push hl
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, MagnetTrainBGTiles
|
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-17 02:46:36 +00:00
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
; 8cd82
|
|
|
|
|
|
|
|
MagnetTrainBGTiles: ; 8cd82
|
2018-01-11 06:45:27 +00:00
|
|
|
; Alternating tiles for each line of the Magnet Train tilemap.
|
2015-11-17 02:46:36 +00:00
|
|
|
db $4c, $4d ; bush
|
|
|
|
db $5c, $5d ; bush
|
|
|
|
db $4c, $4d ; bush
|
|
|
|
db $5c, $5d ; bush
|
|
|
|
db $08, $08 ; fence
|
|
|
|
db $18, $18 ; fence
|
|
|
|
db $1f, $1f ; track
|
|
|
|
db $31, $31 ; track
|
|
|
|
db $11, $11 ; track
|
|
|
|
db $11, $11 ; track
|
|
|
|
db $0d, $0d ; track
|
|
|
|
db $31, $31 ; track
|
|
|
|
db $04, $04 ; fence
|
|
|
|
db $18, $18 ; fence
|
|
|
|
db $4c, $4d ; bush
|
|
|
|
db $5c, $5d ; bush
|
|
|
|
db $4c, $4d ; bush
|
|
|
|
db $5c, $5d ; bush
|
|
|
|
; 8cda6
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
MagnetTrain_InitLYOverrides: ; 8cda6
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wLYOverrides
|
|
|
|
ld bc, wLYOverridesEnd - wLYOverrides
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainInitPosition]
|
2015-11-17 02:46:36 +00:00
|
|
|
call ByteFill
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wLYOverridesBackup
|
|
|
|
ld bc, wLYOverridesBackupEnd - wLYOverridesBackup
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainInitPosition]
|
2015-11-17 02:46:36 +00:00
|
|
|
call ByteFill
|
2016-06-14 02:53:33 +00:00
|
|
|
ld a, rSCX - $ff00
|
|
|
|
ld [hLCDCPointer], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ret
|
|
|
|
; 8cdc3
|
|
|
|
|
|
|
|
SetMagnetTrainPals: ; 8cdc3
|
|
|
|
ld a, $1
|
|
|
|
ld [rVBK], a
|
|
|
|
|
|
|
|
; bushes
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 0
|
2017-12-29 23:59:50 +00:00
|
|
|
ld bc, 4 * BG_MAP_WIDTH
|
2018-01-11 06:45:27 +00:00
|
|
|
ld a, PAL_BG_GREEN
|
2015-11-17 02:46:36 +00:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; train
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 4
|
2017-12-29 23:59:50 +00:00
|
|
|
ld bc, 10 * BG_MAP_WIDTH
|
2018-01-11 06:45:27 +00:00
|
|
|
xor a ; PAL_BG_GRAY
|
2015-11-17 02:46:36 +00:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; more bushes
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 0, 14
|
2017-12-29 23:59:50 +00:00
|
|
|
ld bc, 4 * BG_MAP_WIDTH
|
2018-01-11 06:45:27 +00:00
|
|
|
ld a, PAL_BG_GREEN
|
2015-11-17 02:46:36 +00:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
; train window
|
2015-11-20 16:47:52 +00:00
|
|
|
hlbgcoord 7, 8
|
2015-11-17 02:46:36 +00:00
|
|
|
ld bc, 6
|
2018-01-11 06:45:27 +00:00
|
|
|
ld a, PAL_BG_YELLOW
|
2015-11-17 02:46:36 +00:00
|
|
|
call ByteFill
|
|
|
|
|
|
|
|
ld a, $0
|
|
|
|
ld [rVBK], a
|
|
|
|
ret
|
|
|
|
; 8cdf7
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
MagnetTrain_Jumptable: ; 8cdf7
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [wJumptableIndex]
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-12-19 01:07:09 +00:00
|
|
|
ld hl, .Jumptable
|
2015-11-17 02:46:36 +00:00
|
|
|
add hl, de
|
2016-05-04 15:46:23 +00:00
|
|
|
add hl, de
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2017-06-09 21:01:10 +00:00
|
|
|
jp hl
|
2015-11-17 02:46:36 +00:00
|
|
|
; 8ce06
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.Jumptable: ; 8ce06
|
2015-12-27 02:59:03 +00:00
|
|
|
dw .InitPlayerSpriteAnim
|
|
|
|
dw .WaitScene
|
|
|
|
dw .MoveTrain1
|
|
|
|
dw .WaitScene
|
|
|
|
dw .MoveTrain2
|
|
|
|
dw .WaitScene
|
|
|
|
dw .TrainArrived
|
2015-11-17 02:46:36 +00:00
|
|
|
; 8ce14
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.Next: ; 8ce14
|
2015-11-17 02:46:36 +00:00
|
|
|
ld hl, wJumptableIndex
|
|
|
|
inc [hl]
|
|
|
|
ret
|
|
|
|
; 8ce19
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.InitPlayerSpriteAnim: ; 8ce19
|
|
|
|
ld d, 10 * 8 + 5
|
|
|
|
ld a, [wMagnetTrainPlayerSpriteInitX]
|
2015-11-17 02:46:36 +00:00
|
|
|
ld e, a
|
2017-12-09 05:50:59 +00:00
|
|
|
ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_RED
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wPlayerGender)
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [rSVBK], a
|
2017-12-28 12:15:46 +00:00
|
|
|
ld a, [wPlayerGender]
|
2018-01-22 19:34:55 +00:00
|
|
|
bit PLAYERGENDER_FEMALE_F, a
|
2015-12-19 01:07:09 +00:00
|
|
|
jr z, .got_gender
|
2017-12-09 05:50:59 +00:00
|
|
|
ld b, SPRITE_ANIM_INDEX_MAGNET_TRAIN_BLUE
|
2015-11-17 02:46:36 +00:00
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.got_gender
|
2015-11-17 02:46:36 +00:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ld a, b
|
|
|
|
call _InitSpriteAnimStruct
|
2015-12-19 01:07:09 +00:00
|
|
|
ld hl, SPRITEANIMSTRUCT_TILE_ID
|
2015-11-17 02:46:36 +00:00
|
|
|
add hl, bc
|
|
|
|
ld [hl], $0
|
2015-12-19 01:07:09 +00:00
|
|
|
call .Next
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, $80
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [wMagnetTrainWaitCounter], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ret
|
|
|
|
; 8ce47
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.MoveTrain1: ; 8ce47
|
|
|
|
ld hl, wMagnetTrainHoldPosition
|
2018-01-11 20:36:11 +00:00
|
|
|
ld a, [wMagnetTrainPosition]
|
2015-11-17 02:46:36 +00:00
|
|
|
cp [hl]
|
2015-12-19 01:07:09 +00:00
|
|
|
jr z, .PrepareToHoldTrain
|
2015-11-17 02:46:36 +00:00
|
|
|
ld e, a
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-17 02:46:36 +00:00
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
add e
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [wMagnetTrainPosition], a
|
2015-12-02 22:59:05 +00:00
|
|
|
ld hl, wGlobalAnimXOffset
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-17 02:46:36 +00:00
|
|
|
add [hl]
|
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.PrepareToHoldTrain:
|
2015-12-19 01:07:09 +00:00
|
|
|
call .Next
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, $80
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [wMagnetTrainWaitCounter], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ret
|
|
|
|
; 8ce6d
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.WaitScene: ; 8ce6d
|
2018-01-11 20:36:11 +00:00
|
|
|
ld hl, wMagnetTrainWaitCounter
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [hl]
|
|
|
|
and a
|
2015-12-19 01:07:09 +00:00
|
|
|
jr z, .DoneWaiting
|
2015-11-17 02:46:36 +00:00
|
|
|
dec [hl]
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.DoneWaiting:
|
2015-12-19 01:07:09 +00:00
|
|
|
call .Next
|
2015-11-17 02:46:36 +00:00
|
|
|
ret
|
|
|
|
; 8ce7a
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.MoveTrain2: ; 8ce7a
|
|
|
|
ld hl, wMagnetTrainFinalPosition
|
2018-01-11 20:36:11 +00:00
|
|
|
ld a, [wMagnetTrainPosition]
|
2015-11-17 02:46:36 +00:00
|
|
|
cp [hl]
|
2015-12-19 01:07:09 +00:00
|
|
|
jr z, .PrepareToFinishAnim
|
2015-11-17 02:46:36 +00:00
|
|
|
ld e, a
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-17 02:46:36 +00:00
|
|
|
xor $ff
|
|
|
|
inc a
|
|
|
|
ld d, a
|
|
|
|
ld a, e
|
|
|
|
add d
|
2016-05-04 15:46:23 +00:00
|
|
|
add d
|
2018-01-11 20:36:11 +00:00
|
|
|
ld [wMagnetTrainPosition], a
|
2015-12-02 22:59:05 +00:00
|
|
|
ld hl, wGlobalAnimXOffset
|
2015-12-19 01:07:09 +00:00
|
|
|
ld a, [wMagnetTrainDirection]
|
2015-11-17 02:46:36 +00:00
|
|
|
ld d, a
|
|
|
|
ld a, [hl]
|
|
|
|
add d
|
2016-05-04 15:46:23 +00:00
|
|
|
add d
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [hl], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2016-04-10 18:42:14 +00:00
|
|
|
.PrepareToFinishAnim:
|
2015-12-19 01:07:09 +00:00
|
|
|
call .Next
|
2015-11-17 02:46:36 +00:00
|
|
|
ret
|
|
|
|
; 8cea2
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
.TrainArrived: ; 8cea2
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, $80
|
|
|
|
ld [wJumptableIndex], a
|
|
|
|
ld de, SFX_TRAIN_ARRIVED
|
|
|
|
call PlaySFX
|
|
|
|
ret
|
|
|
|
; 8ceae
|
|
|
|
|
2015-12-19 01:07:09 +00:00
|
|
|
MagnetTrain_Jumptable_FirstRunThrough: ; 8ceae
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall PlaySpriteAnimations
|
2015-12-19 01:07:09 +00:00
|
|
|
call MagnetTrain_Jumptable
|
|
|
|
call MagnetTrain_UpdateLYOverrides
|
2016-05-10 16:31:49 +00:00
|
|
|
call PushLYOverrides
|
2015-11-17 02:46:36 +00:00
|
|
|
call DelayFrame
|
|
|
|
ld a, [rSVBK]
|
|
|
|
push af
|
2018-01-04 00:12:45 +00:00
|
|
|
ld a, BANK(wEnvironment)
|
2015-11-17 02:46:36 +00:00
|
|
|
ld [rSVBK], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wTimeOfDayPal]
|
2015-11-17 02:46:36 +00:00
|
|
|
push af
|
2017-12-24 18:08:38 +00:00
|
|
|
ld a, [wEnvironment]
|
2015-11-17 02:46:36 +00:00
|
|
|
push af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wTimeOfDay]
|
2018-01-16 22:27:50 +00:00
|
|
|
maskbits NUM_DAYTIMES
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wTimeOfDayPal], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, $1
|
2017-12-24 18:08:38 +00:00
|
|
|
ld [wEnvironment], a
|
2015-12-22 23:03:00 +00:00
|
|
|
ld b, SCGB_MAPPALS
|
2015-11-17 02:46:36 +00:00
|
|
|
call GetSGBLayout
|
|
|
|
call UpdateTimePals
|
|
|
|
ld a, [rBGP]
|
2015-12-23 19:00:29 +00:00
|
|
|
ld [wBGP], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [rOBP0]
|
2015-12-23 19:00:29 +00:00
|
|
|
ld [wOBP0], a
|
2015-11-17 02:46:36 +00:00
|
|
|
ld a, [rOBP1]
|
2015-12-23 19:00:29 +00:00
|
|
|
ld [wOBP1], a
|
2015-11-17 02:46:36 +00:00
|
|
|
pop af
|
2017-12-24 18:08:38 +00:00
|
|
|
ld [wEnvironment], a
|
2015-11-17 02:46:36 +00:00
|
|
|
pop af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wTimeOfDayPal], a
|
2015-11-17 02:46:36 +00:00
|
|
|
pop af
|
|
|
|
ld [rSVBK], a
|
|
|
|
ret
|
|
|
|
; 8ceff
|
|
|
|
|
|
|
|
MagnetTrainTilemap1:
|
2018-01-11 06:45:27 +00:00
|
|
|
db $1f, $05, $06, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0a, $0a, $0a, $09, $0a, $0a, $0a, $0b, $0c, $1f
|
2015-11-17 02:46:36 +00:00
|
|
|
MagnetTrainTilemap2:
|
2018-01-11 06:45:27 +00:00
|
|
|
db $14, $15, $16, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1a, $1a, $1a, $19, $1a, $1a, $1a, $1b, $1c, $1d
|
2015-11-17 02:46:36 +00:00
|
|
|
MagnetTrainTilemap3:
|
2018-01-11 06:45:27 +00:00
|
|
|
db $24, $25, $26, $27, $07, $2f, $29, $28, $28, $28, $28, $28, $28, $29, $07, $2f, $2a, $2b, $2c, $2d
|
2015-11-17 02:46:36 +00:00
|
|
|
MagnetTrainTilemap4:
|
2018-01-11 06:45:27 +00:00
|
|
|
db $20, $1f, $2e, $1f, $17, $00, $2e, $1f, $1f, $1f, $1f, $1f, $1f, $2e, $17, $00, $1f, $2e, $1f, $0f
|
2015-11-17 02:46:36 +00:00
|
|
|
; 8cf4f
|