pokecrystal-board/engine/gfx/dma_transfer.asm

605 lines
9.4 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
HDMATransferAttrMapAndTileMapToWRAMBank3::
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer
2015-11-30 08:04:14 -08:00
decoord 0, 0
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call PadTilemapForHDMATransfer
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransferToWRAMBank3
2015-11-30 08:04:14 -08:00
ld a, $1
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call HDMATransferToWRAMBank3
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
HDMATransferTileMapToWRAMBank3::
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2015-11-30 08:04:14 -08:00
decoord 0, 0
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call PadTilemapForHDMATransfer
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransferToWRAMBank3
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
HDMATransferAttrMapToWRAMBank3:
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer
2015-11-30 08:04:14 -08:00
ld a, $1
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call HDMATransferToWRAMBank3
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
ReloadMapPart::
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer
2015-11-30 08:04:14 -08:00
decoord 0, 0
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call PadTilemapForHDMATransfer
2015-11-30 08:04:14 -08:00
call DelayFrame
2016-05-04 19:34:09 -07:00
2015-11-30 08:04:14 -08:00
di
ldh a, [rVBK]
2015-11-30 08:04:14 -08:00
push af
ld a, $1
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call HDMATransfer_Wait127Scanlines_toBGMap
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines_toBGMap
2015-11-30 08:04:14 -08:00
pop af
ldh [rVBK], a
2015-11-30 08:04:14 -08:00
ei
2016-05-04 19:34:09 -07:00
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
Mobile_ReloadMapPart:
2015-11-30 08:04:14 -08:00
ld hl, ReloadMapPart ; useless
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer
2015-11-30 08:04:14 -08:00
decoord 0, 0
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call PadTilemapForHDMATransfer
2015-11-30 08:04:14 -08:00
call DelayFrame
2016-05-04 19:34:09 -07:00
2015-11-30 08:04:14 -08:00
di
ldh a, [rVBK]
2015-11-30 08:04:14 -08:00
push af
ld a, $1
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call HDMATransfer_NoDI
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransfer_NoDI
2015-11-30 08:04:14 -08:00
pop af
ldh [rVBK], a
2015-11-30 08:04:14 -08:00
ei
2016-05-04 19:34:09 -07:00
2015-11-30 08:04:14 -08:00
ret
; unused
2016-05-04 19:34:09 -07:00
ld hl, .unreferenced_1040da
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
2016-05-04 19:34:09 -07:00
.unreferenced_1040da
2015-11-30 08:04:14 -08:00
ld a, $1
ldh [rVBK], a
2018-01-04 12:06:11 -08:00
ld a, BANK(w3_d800)
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
ld de, w3_d800
ldh a, [hBGMapAddress + 1]
ldh [rHDMA1], a
ldh a, [hBGMapAddress]
ldh [rHDMA2], a
2015-11-30 08:04:14 -08:00
ld a, d
ldh [rHDMA3], a
2015-11-30 08:04:14 -08:00
ld a, e
ldh [rHDMA4], a
2015-11-30 08:04:14 -08:00
ld a, $23
ldh [hDMATransfer], a
2015-12-22 19:19:33 -08:00
call WaitDMATransfer
2015-11-30 08:04:14 -08:00
ret
; unused
2016-05-04 19:34:09 -07:00
ld hl, .unreferenced_104101
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
2016-05-04 19:34:09 -07:00
.unreferenced_104101
2015-11-30 08:04:14 -08:00
ld a, $1
ldh [rVBK], a
ld a, BANK(w3_d800)
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
ld hl, w3_d800
2016-05-04 19:34:09 -07:00
call HDMATransferToWRAMBank3
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
OpenAndCloseMenu_HDMATransferTileMapAndAttrMap::
2015-12-09 15:25:44 -08:00
; OpenText
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2018-01-23 14:39:09 -08:00
; Transfer wAttrMap and Tilemap to BGMap
2016-05-04 19:34:09 -07:00
; Fill vBGAttrs with $00
; Fill vBGTiles with " "
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer
2015-11-30 08:04:14 -08:00
decoord 0, 0
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call PadTilemapForHDMATransfer
2015-11-30 08:04:14 -08:00
call DelayFrame
2015-12-09 15:25:44 -08:00
2015-11-30 08:04:14 -08:00
di
ldh a, [rVBK]
2015-11-30 08:04:14 -08:00
push af
ld a, $1
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call HDMATransfer_Wait123Scanlines_toBGMap
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransfer_Wait123Scanlines_toBGMap
2015-11-30 08:04:14 -08:00
pop af
ldh [rVBK], a
2015-11-30 08:04:14 -08:00
ei
ret
2018-06-24 07:09:41 -07:00
Mobile_OpenAndCloseMenu_HDMATransferTileMapAndAttrMap:
2015-12-22 19:19:33 -08:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
.Function:
2018-01-23 14:39:09 -08:00
; Transfer wAttrMap and Tilemap to BGMap
2016-05-04 19:34:09 -07:00
; Fill vBGAttrs with $00
; Fill vBGTiles with $ff
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call PadAttrMapForHDMATransfer
2015-11-30 08:04:14 -08:00
ld c, $ff
decoord 0, 0
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call PadMapForHDMATransfer
2016-05-04 19:34:09 -07:00
2015-11-30 08:04:14 -08:00
ld a, $1
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchAttrMap
call HDMATransfer_Wait127Scanlines_toBGMap
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines_toBGMap
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
CallInSafeGFXMode:
ldh a, [hBGMapMode]
2015-11-30 08:04:14 -08:00
push af
ldh a, [hMapAnims]
2015-11-30 08:04:14 -08:00
push af
xor a
ldh [hBGMapMode], a
ldh [hMapAnims], a
ldh a, [rSVBK]
2015-11-30 08:04:14 -08:00
push af
ld a, BANK(wScratchTileMap)
ldh [rSVBK], a
ldh a, [rVBK]
2015-11-30 08:04:14 -08:00
push af
2015-12-09 15:25:44 -08:00
2015-11-30 08:04:14 -08:00
call ._hl_
2015-12-09 15:25:44 -08:00
2015-11-30 08:04:14 -08:00
pop af
ldh [rVBK], a
2015-11-30 08:04:14 -08:00
pop af
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
pop af
ldh [hMapAnims], a
2015-11-30 08:04:14 -08:00
pop af
ldh [hBGMapMode], a
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
._hl_
jp hl
2015-11-30 08:04:14 -08:00
2018-06-24 07:09:41 -07:00
HDMATransferToWRAMBank3:
2016-05-04 19:34:09 -07:00
call _LoadHDMAParameters
2015-11-30 08:04:14 -08:00
ld a, $23
ldh [hDMATransfer], a
2015-11-30 08:04:14 -08:00
2018-06-24 07:09:41 -07:00
WaitDMATransfer:
2015-12-22 19:19:33 -08:00
.loop
2015-11-30 08:04:14 -08:00
call DelayFrame
ldh a, [hDMATransfer]
2015-11-30 08:04:14 -08:00
and a
2015-12-22 19:19:33 -08:00
jr nz, .loop
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
HDMATransfer_Wait127Scanlines_toBGMap:
2016-05-04 19:34:09 -07:00
; HDMA transfer from hl to [hBGMapAddress]
; hBGMapAddress -> de
; 2 * SCREEN_HEIGHT -> c
ldh a, [hBGMapAddress + 1]
2015-11-30 08:04:14 -08:00
ld d, a
ldh a, [hBGMapAddress]
2015-11-30 08:04:14 -08:00
ld e, a
2016-05-04 19:34:09 -07:00
ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait127Scanlines
2015-11-30 08:04:14 -08:00
2018-06-24 07:09:41 -07:00
HDMATransfer_Wait123Scanlines_toBGMap:
2016-05-04 19:34:09 -07:00
; HDMA transfer from hl to [hBGMapAddress]
2015-12-09 15:25:44 -08:00
; hBGMapAddress -> de
2016-05-04 19:34:09 -07:00
; 2 * SCREEN_HEIGHT -> c
2015-12-09 15:25:44 -08:00
; $7b --> b
ldh a, [hBGMapAddress + 1]
2015-11-30 08:04:14 -08:00
ld d, a
ldh a, [hBGMapAddress]
2015-11-30 08:04:14 -08:00
ld e, a
2016-05-04 19:34:09 -07:00
ld c, 2 * SCREEN_HEIGHT
jr HDMATransfer_Wait123Scanlines
2015-11-30 08:04:14 -08:00
2018-06-24 07:09:41 -07:00
HDMATransfer_NoDI:
2016-05-04 19:34:09 -07:00
; HDMA transfer from hl to [hBGMapAddress]
; [hBGMapAddress] --> de
; 2 * SCREEN_HEIGHT --> c
ldh a, [hBGMapAddress + 1]
2015-11-30 08:04:14 -08:00
ld d, a
ldh a, [hBGMapAddress]
2015-11-30 08:04:14 -08:00
ld e, a
2016-05-04 19:34:09 -07:00
ld c, 2 * SCREEN_HEIGHT
; [rHDMA1, rHDMA2] = hl & $fff0
2015-11-30 08:04:14 -08:00
ld a, h
ldh [rHDMA1], a
2015-11-30 08:04:14 -08:00
ld a, l
and $f0
ldh [rHDMA2], a
2016-05-04 19:34:09 -07:00
; [rHDMA3, rHDMA4] = de & $1ff0
2015-11-30 08:04:14 -08:00
ld a, d
and $1f
ldh [rHDMA3], a
2015-11-30 08:04:14 -08:00
ld a, e
and $f0
ldh [rHDMA4], a
2016-05-04 19:34:09 -07:00
; b = c | %10000000
2015-11-30 08:04:14 -08:00
ld a, c
dec c
or $80
ld b, a
2016-05-04 19:34:09 -07:00
; d = $7f - c + 1
2015-11-30 08:04:14 -08:00
ld a, $7f
sub c
ld d, a
2016-05-04 19:34:09 -07:00
; while [rLY] >= d: pass
2015-11-30 08:04:14 -08:00
.loop1
ldh a, [rLY]
2015-11-30 08:04:14 -08:00
cp d
jr nc, .loop1
2016-05-04 19:34:09 -07:00
; while not [rSTAT] & 3: pass
2015-11-30 08:04:14 -08:00
.loop2
ldh a, [rSTAT]
2015-11-30 08:04:14 -08:00
and $3
jr z, .loop2
2016-05-04 19:34:09 -07:00
; load the 5th byte of HDMA
2015-11-30 08:04:14 -08:00
ld a, b
ldh [rHDMA5], a
2016-05-04 19:34:09 -07:00
; wait until rLY advances (c + 1) times
ldh a, [rLY]
2015-11-30 08:04:14 -08:00
inc c
ld hl, rLY
.loop3
cp [hl]
jr z, .loop3
ld a, [hl]
dec c
jr nz, .loop3
ld hl, rHDMA5
res 7, [hl]
ret
2016-05-04 19:34:09 -07:00
HDMATransfer_Wait123Scanlines:
2015-11-30 08:04:14 -08:00
ld b, $7b
2016-05-04 19:34:09 -07:00
jr _continue_HDMATransfer
2015-11-30 08:04:14 -08:00
2016-05-04 19:34:09 -07:00
HDMATransfer_Wait127Scanlines:
2015-11-30 08:04:14 -08:00
ld b, $7f
2016-05-04 19:34:09 -07:00
_continue_HDMATransfer:
; a lot of waiting around for hardware registers
; [rHDMA1, rHDMA2] = hl & $fff0
2015-11-30 08:04:14 -08:00
ld a, h
ldh [rHDMA1], a
2015-11-30 08:04:14 -08:00
ld a, l
and $f0 ; high nybble
ldh [rHDMA2], a
2016-05-04 19:34:09 -07:00
; [rHDMA3, rHDMA4] = de & $1ff0
2015-11-30 08:04:14 -08:00
ld a, d
and $1f ; lower 5 bits
ldh [rHDMA3], a
2015-11-30 08:04:14 -08:00
ld a, e
and $f0 ; high nybble
ldh [rHDMA4], a
2016-05-04 19:34:09 -07:00
; e = c | %10000000
2015-11-30 08:04:14 -08:00
ld a, c
dec c
2016-05-04 19:34:09 -07:00
or $80
2015-11-30 08:04:14 -08:00
ld e, a
2016-05-04 19:34:09 -07:00
; d = b - c + 1
2015-11-30 08:04:14 -08:00
ld a, b
sub c
ld d, a
2016-05-04 19:34:09 -07:00
; while [rLY] >= d: pass
2015-11-30 08:04:14 -08:00
.ly_loop
ldh a, [rLY]
2015-11-30 08:04:14 -08:00
cp d
jr nc, .ly_loop
di
2016-05-04 19:34:09 -07:00
; while [rSTAT] & 3: pass
2015-11-30 08:04:14 -08:00
.rstat_loop_1
ldh a, [rSTAT]
2015-11-30 08:04:14 -08:00
and $3
jr nz, .rstat_loop_1
2016-05-04 19:34:09 -07:00
; while not [rSTAT] & 3: pass
2015-11-30 08:04:14 -08:00
.rstat_loop_2
ldh a, [rSTAT]
2015-11-30 08:04:14 -08:00
and $3
jr z, .rstat_loop_2
2016-05-04 19:34:09 -07:00
; load the 5th byte of HDMA
2015-11-30 08:04:14 -08:00
ld a, e
ldh [rHDMA5], a
2016-05-04 19:34:09 -07:00
; wait until rLY advances (c + 1) times
ldh a, [rLY]
2015-11-30 08:04:14 -08:00
inc c
ld hl, rLY
.final_ly_loop
cp [hl]
jr z, .final_ly_loop
ld a, [hl]
dec c
jr nz, .final_ly_loop
ld hl, rHDMA5
res 7, [hl]
ei
ret
2018-06-24 07:09:41 -07:00
_LoadHDMAParameters:
2015-11-30 08:04:14 -08:00
ld a, h
ldh [rHDMA1], a
2015-11-30 08:04:14 -08:00
ld a, l
ldh [rHDMA2], a
ldh a, [hBGMapAddress + 1]
2015-11-30 08:04:14 -08:00
and $1f
ldh [rHDMA3], a
ldh a, [hBGMapAddress]
ldh [rHDMA4], a
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
PadTilemapForHDMATransfer:
2015-11-30 08:04:14 -08:00
ld c, " "
jr PadMapForHDMATransfer
2015-11-30 08:04:14 -08:00
2018-06-24 07:09:41 -07:00
PadAttrMapForHDMATransfer:
2015-11-30 08:04:14 -08:00
ld c, $0
2018-06-24 07:09:41 -07:00
PadMapForHDMATransfer:
; pad a 20x18 map to 32x18 for HDMA transfer
; back up the padding value in c to hMapObjectIndexBuffer
ldh a, [hMapObjectIndexBuffer]
2015-11-30 08:04:14 -08:00
push af
ld a, c
ldh [hMapObjectIndexBuffer], a
2015-11-30 08:04:14 -08:00
; for each row on the screen
ld c, SCREEN_HEIGHT
.loop1
; for each tile in the row
ld b, SCREEN_WIDTH
.loop2
; copy from de to hl
ld a, [de]
inc de
ld [hli], a
dec b
jr nz, .loop2
; load the original padding value of c into hl for 32 - 20 = 12 rows
ldh a, [hMapObjectIndexBuffer]
2016-05-04 19:34:09 -07:00
ld b, BG_MAP_WIDTH - SCREEN_WIDTH
2015-11-30 08:04:14 -08:00
.loop3
ld [hli], a
dec b
jr nz, .loop3
dec c
jr nz, .loop1
; restore the original value of hMapObjectIndexBuffer
pop af
ldh [hMapObjectIndexBuffer], a
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
_Get2bpp::
2015-11-30 08:04:14 -08:00
; 2bpp when [rLCDC] & $80
; switch to WRAM bank 6
ldh a, [rSVBK]
2015-11-30 08:04:14 -08:00
push af
ld a, BANK(wScratchTileMap)
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
push bc
push hl
2016-05-04 19:34:09 -07:00
; Copy c tiles of the 2bpp from b:de to wScratchTileMap
2015-11-30 08:04:14 -08:00
ld a, b ; bank
ld l, c ; number of tiles
ld h, $0
; multiply by 16 (16 bytes of a 2bpp = 8 x 8 tile)
add hl, hl
add hl, hl
add hl, hl
add hl, hl
2015-11-30 08:04:14 -08:00
ld b, h
ld c, l
ld h, d ; address
ld l, e
2016-05-04 19:34:09 -07:00
ld de, wScratchTileMap
2015-11-30 08:04:14 -08:00
call FarCopyBytes
2015-11-30 08:04:14 -08:00
pop hl
pop bc
push bc
call DelayFrame
pop bc
ld d, h
ld e, l
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines
2015-11-30 08:04:14 -08:00
; restore the previous bank
pop af
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
_Get1bpp::
2015-11-30 08:04:14 -08:00
; 1bpp when [rLCDC] & $80
.loop
ld a, c
cp $10
jp c, .bankswitch
jp z, .bankswitch
push bc
push hl
push de
ld c, $10
call .bankswitch
pop de
ld hl, $80
add hl, de
ld d, h
ld e, l
pop hl
lb bc, 1, 0
add hl, bc
pop bc
ld a, c
sub $10
ld c, a
jr .loop
2018-06-24 07:09:41 -07:00
.bankswitch
ldh a, [rSVBK]
2015-11-30 08:04:14 -08:00
push af
ld a, BANK(wScratchTileMap)
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
push bc
push hl
ld a, b
ld l, c
ld h, $0
add hl, hl ; multiply by 8
add hl, hl ; multiply by 8
add hl, hl ; multiply by 8
2015-11-30 08:04:14 -08:00
ld c, l
ld b, h
ld h, d
ld l, e
2016-05-04 19:34:09 -07:00
ld de, wScratchTileMap
2015-11-30 08:04:14 -08:00
call FarCopyBytesDouble_DoubleBankSwitch
pop hl
pop bc
push bc
call DelayFrame
pop bc
ld d, h
ld e, l
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
call HDMATransfer_Wait127Scanlines
2015-11-30 08:04:14 -08:00
pop af
ldh [rSVBK], a
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
HDMATransfer_OnlyTopFourRows:
2016-05-04 19:34:09 -07:00
ld hl, .Function
2015-12-09 15:25:44 -08:00
jp CallInSafeGFXMode
2015-11-30 08:04:14 -08:00
2016-05-04 19:34:09 -07:00
.Function:
ld hl, wScratchTileMap
2015-11-30 08:04:14 -08:00
decoord 0, 0
2016-05-04 19:34:09 -07:00
call .Copy
ld hl, wScratchTileMap + $80
2018-01-23 14:39:09 -08:00
decoord 0, 0, wAttrMap
2016-05-04 19:34:09 -07:00
call .Copy
2015-11-30 08:04:14 -08:00
ld a, $1
ldh [rVBK], a
2015-11-30 08:04:14 -08:00
ld c, $8
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap + $80
2017-12-28 04:32:33 -08:00
debgcoord 0, 0, vBGMap1
2016-05-04 19:34:09 -07:00
call HDMATransfer_Wait127Scanlines
2015-11-30 08:04:14 -08:00
ld a, $0
ldh [rVBK], a
2015-11-30 08:04:14 -08:00
ld c, $8
2016-05-04 19:34:09 -07:00
ld hl, wScratchTileMap
2017-12-28 04:32:33 -08:00
debgcoord 0, 0, vBGMap1
2016-05-04 19:34:09 -07:00
call HDMATransfer_Wait127Scanlines
2015-11-30 08:04:14 -08:00
ret
2018-06-24 07:09:41 -07:00
.Copy:
2015-11-30 08:04:14 -08:00
ld b, 4
.outer_loop
ld c, SCREEN_WIDTH
.inner_loop
ld a, [de]
ld [hli], a
inc de
dec c
jr nz, .inner_loop
ld a, l
2016-05-04 19:34:09 -07:00
add BG_MAP_WIDTH - SCREEN_WIDTH
2015-11-30 08:04:14 -08:00
ld l, a
ld a, h
2018-02-04 10:16:40 -08:00
adc 0
2015-11-30 08:04:14 -08:00
ld h, a
dec b
jr nz, .outer_loop
ret