2018-06-24 14:09:41 +00:00
|
|
|
PhoneRing_CopyTilemapAtOnce:
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hCGB]
|
2017-12-25 00:35:35 +00:00
|
|
|
and a
|
|
|
|
jp z, WaitBGMap
|
|
|
|
ld a, [wSpriteUpdatesEnabled]
|
|
|
|
cp $0
|
|
|
|
jp z, WaitBGMap
|
|
|
|
|
2020-05-17 02:25:52 +00:00
|
|
|
; The following is a modified version of _CopyTilemapAtOnce
|
|
|
|
; that waits for [rLY] to be LY_VBLANK - 1 instead of $80 - 1.
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBGMapMode]
|
2017-12-25 00:35:35 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2020-05-17 02:25:52 +00:00
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hMapAnims]
|
2017-12-25 00:35:35 +00:00
|
|
|
push af
|
|
|
|
xor a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hMapAnims], a
|
2020-05-17 02:25:52 +00:00
|
|
|
|
2017-12-25 00:35:35 +00:00
|
|
|
.wait
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rLY]
|
2017-12-29 17:53:21 +00:00
|
|
|
cp LY_VBLANK - 1
|
2017-12-25 00:35:35 +00:00
|
|
|
jr c, .wait
|
|
|
|
|
|
|
|
di
|
2017-12-28 12:32:33 +00:00
|
|
|
ld a, BANK(vBGMap2)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rVBK], a
|
2020-02-13 17:30:13 +00:00
|
|
|
hlcoord 0, 0, wAttrmap
|
2020-05-17 02:25:52 +00:00
|
|
|
call .CopyBGMapViaStack
|
2017-12-28 12:32:33 +00:00
|
|
|
ld a, BANK(vBGMap0)
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [rVBK], a
|
2017-12-25 00:35:35 +00:00
|
|
|
hlcoord 0, 0
|
2020-05-17 02:25:52 +00:00
|
|
|
call .CopyBGMapViaStack
|
|
|
|
|
2017-12-25 00:35:35 +00:00
|
|
|
.wait2
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [rLY]
|
2017-12-29 17:53:21 +00:00
|
|
|
cp LY_VBLANK - 1
|
2017-12-25 00:35:35 +00:00
|
|
|
jr c, .wait2
|
|
|
|
ei
|
|
|
|
|
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hMapAnims], a
|
2017-12-25 00:35:35 +00:00
|
|
|
pop af
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hBGMapMode], a
|
2017-12-25 00:35:35 +00:00
|
|
|
ret
|
|
|
|
|
2020-05-17 02:25:52 +00:00
|
|
|
.CopyBGMapViaStack:
|
|
|
|
; Copy all tiles to vBGMap
|
2017-12-25 00:35:35 +00:00
|
|
|
ld [hSPBuffer], sp
|
|
|
|
ld sp, hl
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hBGMapAddress + 1]
|
2017-12-25 00:35:35 +00:00
|
|
|
ld h, a
|
|
|
|
ld l, 0
|
|
|
|
ld a, SCREEN_HEIGHT
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hTilesPerCycle], a
|
2017-12-25 00:35:35 +00:00
|
|
|
ld b, 1 << 1 ; not in v/hblank
|
2017-12-25 18:40:10 +00:00
|
|
|
ld c, LOW(rSTAT)
|
2017-12-25 00:35:35 +00:00
|
|
|
|
|
|
|
.loop
|
|
|
|
rept SCREEN_WIDTH / 2
|
|
|
|
pop de
|
2020-05-17 02:25:52 +00:00
|
|
|
; if in v/hblank, wait until not in v/hblank
|
2017-12-25 00:35:35 +00:00
|
|
|
.loop\@
|
2019-02-16 17:17:55 +00:00
|
|
|
ldh a, [c]
|
2017-12-25 00:35:35 +00:00
|
|
|
and b
|
|
|
|
jr nz, .loop\@
|
2020-05-17 02:25:52 +00:00
|
|
|
; load vBGMap
|
2017-12-25 00:35:35 +00:00
|
|
|
ld [hl], e
|
|
|
|
inc l
|
|
|
|
ld [hl], d
|
|
|
|
inc l
|
|
|
|
endr
|
|
|
|
|
|
|
|
ld de, BG_MAP_WIDTH - SCREEN_WIDTH
|
|
|
|
add hl, de
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hTilesPerCycle]
|
2017-12-25 00:35:35 +00:00
|
|
|
dec a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh [hTilesPerCycle], a
|
2017-12-25 00:35:35 +00:00
|
|
|
jr nz, .loop
|
|
|
|
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSPBuffer]
|
2017-12-25 00:35:35 +00:00
|
|
|
ld l, a
|
2018-08-25 18:28:22 +00:00
|
|
|
ldh a, [hSPBuffer + 1]
|
2017-12-25 00:35:35 +00:00
|
|
|
ld h, a
|
|
|
|
ld sp, hl
|
|
|
|
ret
|