mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-11-11 15:54:49 +13:00
Recomment some copy/video functions in home.asm.
This commit is contained in:
parent
93b1361dff
commit
2317848cc4
397
home.asm
397
home.asm
|
|
@ -908,75 +908,56 @@ InterlaceMergeSpriteBuffers:: ; 16ea (0:16ea)
|
||||||
ld b, a
|
ld b, a
|
||||||
jp CopyVideoData
|
jp CopyVideoData
|
||||||
|
|
||||||
Underground_Coll:: ; 172f (0:172f)
|
|
||||||
INCBIN "gfx/tilesets/underground.tilecoll"
|
Underground_Coll:: INCBIN "gfx/tilesets/underground.tilecoll"
|
||||||
Overworld_Coll:: ; 1735 (0:1735)
|
Overworld_Coll:: INCBIN "gfx/tilesets/overworld.tilecoll"
|
||||||
INCBIN "gfx/tilesets/overworld.tilecoll"
|
|
||||||
RedsHouse1_Coll::
|
RedsHouse1_Coll::
|
||||||
RedsHouse2_Coll:: ; 1749 (0:1749)
|
RedsHouse2_Coll:: INCBIN "gfx/tilesets/reds_house.tilecoll"
|
||||||
INCBIN "gfx/tilesets/reds_house.tilecoll"
|
Mart_Coll::
|
||||||
Mart_Coll
|
Pokecenter_Coll:: INCBIN "gfx/tilesets/pokecenter.tilecoll"
|
||||||
Pokecenter_Coll:: ; 1753 (0:1753)
|
|
||||||
INCBIN "gfx/tilesets/pokecenter.tilecoll"
|
|
||||||
Dojo_Coll::
|
Dojo_Coll::
|
||||||
Gym_Coll:: ; 1759 (0:1759)
|
Gym_Coll:: INCBIN "gfx/tilesets/gym.tilecoll"
|
||||||
INCBIN "gfx/tilesets/gym.tilecoll"
|
Forest_Coll:: INCBIN "gfx/tilesets/forest.tilecoll"
|
||||||
Forest_Coll:: ; 1765 (0:1765)
|
House_Coll:: INCBIN "gfx/tilesets/house.tilecoll"
|
||||||
INCBIN "gfx/tilesets/forest.tilecoll"
|
|
||||||
House_Coll:: ; 1775 (0:1775)
|
|
||||||
INCBIN "gfx/tilesets/house.tilecoll"
|
|
||||||
ForestGate_Coll::
|
ForestGate_Coll::
|
||||||
Museum_Coll::
|
Museum_Coll::
|
||||||
Gate_Coll:: ; 177f (0:177f)
|
Gate_Coll:: INCBIN "gfx/tilesets/gate.tilecoll"
|
||||||
INCBIN "gfx/tilesets/gate.tilecoll"
|
Ship_Coll:: INCBIN "gfx/tilesets/ship.tilecoll"
|
||||||
Ship_Coll:: ; 178a (0:178a)
|
ShipPort_Coll:: INCBIN "gfx/tilesets/ship_port.tilecoll"
|
||||||
INCBIN "gfx/tilesets/ship.tilecoll"
|
Cemetery_Coll:: INCBIN "gfx/tilesets/cemetery.tilecoll"
|
||||||
ShipPort_Coll:: ; 1795 (0:1795)
|
Interior_Coll:: INCBIN "gfx/tilesets/interior.tilecoll"
|
||||||
INCBIN "gfx/tilesets/ship_port.tilecoll"
|
Cavern_Coll:: INCBIN "gfx/tilesets/cavern.tilecoll"
|
||||||
Cemetery_Coll:: ; 179a (0:179a)
|
Lobby_Coll:: INCBIN "gfx/tilesets/lobby.tilecoll"
|
||||||
INCBIN "gfx/tilesets/cemetery.tilecoll"
|
Mansion_Coll:: INCBIN "gfx/tilesets/mansion.tilecoll"
|
||||||
Interior_Coll:: ; 17a2 (0:17a2)
|
Lab_Coll:: INCBIN "gfx/tilesets/lab.tilecoll"
|
||||||
INCBIN "gfx/tilesets/interior.tilecoll"
|
Club_Coll:: INCBIN "gfx/tilesets/club.tilecoll"
|
||||||
Cavern_Coll:: ; 17ac (0:17ac)
|
Facility_Coll:: INCBIN "gfx/tilesets/facility.tilecoll"
|
||||||
INCBIN "gfx/tilesets/cavern.tilecoll"
|
Plateau_Coll:: INCBIN "gfx/tilesets/plateau.tilecoll"
|
||||||
Lobby_Coll:: ; 17b8 (0:17b8)
|
|
||||||
INCBIN "gfx/tilesets/lobby.tilecoll"
|
|
||||||
Mansion_Coll:: ; 17c0 (0:17c0)
|
|
||||||
INCBIN "gfx/tilesets/mansion.tilecoll"
|
|
||||||
Lab_Coll:: ; 17ca (0:17ca)
|
|
||||||
INCBIN "gfx/tilesets/lab.tilecoll"
|
|
||||||
Club_Coll:: ; 17d1 (0:17d1)
|
|
||||||
INCBIN "gfx/tilesets/club.tilecoll"
|
|
||||||
Facility_Coll:: ; 17dd (0:17dd)
|
|
||||||
INCBIN "gfx/tilesets/facility.tilecoll"
|
|
||||||
Plateau_Coll:: ; 17f0 (0:17f0)
|
|
||||||
INCBIN "gfx/tilesets/plateau.tilecoll"
|
|
||||||
|
|
||||||
; does the same thing as FarCopyData at 009D
|
|
||||||
; only difference is that it uses [$ff8b] instead of [wHPBarMaxHP] for a temp value
|
FarCopyData2::
|
||||||
; copy bc bytes of data from a:hl to de
|
; Identical to FarCopyData, but uses $ff8b
|
||||||
FarCopyData2:: ; 17f7 (0:17f7)
|
; as temp space instead of wBuffer.
|
||||||
ld [$ff8b],a
|
ld [$ff8b],a
|
||||||
ld a,[H_LOADEDROMBANK]
|
ld a,[H_LOADEDROMBANK]
|
||||||
push af
|
push af
|
||||||
ld a,[$ff8b]
|
ld a,[$ff8b]
|
||||||
ld [H_LOADEDROMBANK],a
|
ld [H_LOADEDROMBANK],a
|
||||||
ld [$2000],a
|
ld [MBC3RomBank],a
|
||||||
call CopyData
|
call CopyData
|
||||||
pop af
|
pop af
|
||||||
ld [H_LOADEDROMBANK],a
|
ld [H_LOADEDROMBANK],a
|
||||||
ld [$2000],a
|
ld [MBC3RomBank],a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; does a far copy but the source is de and the destination is hl
|
FarCopyData3::
|
||||||
; copy bc bytes of data from a:de to hl
|
; Copy bc bytes from a:de to hl.
|
||||||
FarCopyData3:: ; 180d (0:180d)
|
|
||||||
ld [$ff8b],a
|
ld [$ff8b],a
|
||||||
ld a,[H_LOADEDROMBANK]
|
ld a,[H_LOADEDROMBANK]
|
||||||
push af
|
push af
|
||||||
ld a,[$ff8b]
|
ld a,[$ff8b]
|
||||||
ld [H_LOADEDROMBANK],a
|
ld [H_LOADEDROMBANK],a
|
||||||
ld [$2000],a
|
ld [MBC3RomBank],a
|
||||||
push hl
|
push hl
|
||||||
push de
|
push de
|
||||||
push de
|
push de
|
||||||
|
|
@ -988,18 +969,18 @@ FarCopyData3:: ; 180d (0:180d)
|
||||||
pop hl
|
pop hl
|
||||||
pop af
|
pop af
|
||||||
ld [H_LOADEDROMBANK],a
|
ld [H_LOADEDROMBANK],a
|
||||||
ld [$2000],a
|
ld [MBC3RomBank],a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; copies each source byte to the destination twice (next to each other)
|
FarCopyDataDouble::
|
||||||
; copy bc source bytes from a:hl to de
|
; Expand bc bytes of 1bpp image data
|
||||||
FarCopyDataDouble:: ; 182b (0:182b)
|
; from a:hl to 2bpp data at de.
|
||||||
ld [$ff8b],a
|
ld [$ff8b],a
|
||||||
ld a,[H_LOADEDROMBANK]
|
ld a,[H_LOADEDROMBANK]
|
||||||
push af
|
push af
|
||||||
ld a,[$ff8b]
|
ld a,[$ff8b]
|
||||||
ld [H_LOADEDROMBANK],a
|
ld [H_LOADEDROMBANK],a
|
||||||
ld [$2000],a
|
ld [MBC3RomBank],a
|
||||||
.loop
|
.loop
|
||||||
ld a,[hli]
|
ld a,[hli]
|
||||||
ld [de],a
|
ld [de],a
|
||||||
|
|
@ -1012,212 +993,224 @@ FarCopyDataDouble:: ; 182b (0:182b)
|
||||||
jr nz,.loop
|
jr nz,.loop
|
||||||
pop af
|
pop af
|
||||||
ld [H_LOADEDROMBANK],a
|
ld [H_LOADEDROMBANK],a
|
||||||
ld [$2000],a
|
ld [MBC3RomBank],a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; copy (c * 16) bytes from b:de to hl during V-blank
|
CopyVideoData::
|
||||||
; transfers up to 128 bytes per V-blank
|
; Wait for the next VBlank, then copy c 2bpp
|
||||||
CopyVideoData:: ; 1848 (0:1848)
|
; tiles from b:de to hl, 8 tiles at a time.
|
||||||
ld a,[H_AUTOBGTRANSFERENABLED] ; save auto-transfer enabled flag
|
; This takes c/8 frames.
|
||||||
|
|
||||||
|
ld a, [H_AUTOBGTRANSFERENABLED]
|
||||||
push af
|
push af
|
||||||
xor a
|
xor a ; disable auto-transfer while copying
|
||||||
ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer while copying
|
ld [H_AUTOBGTRANSFERENABLED], a
|
||||||
ld a,[H_LOADEDROMBANK]
|
|
||||||
ld [$ff8b],a
|
ld a, [H_LOADEDROMBANK]
|
||||||
ld a,b
|
ld [$ff8b], a
|
||||||
ld [H_LOADEDROMBANK],a
|
|
||||||
ld [$2000],a
|
ld a, b
|
||||||
ld a,e
|
ld [H_LOADEDROMBANK], a
|
||||||
ld [H_VBCOPYSRC],a
|
ld [MBC3RomBank], a
|
||||||
ld a,d
|
|
||||||
ld [H_VBCOPYSRC + 1],a
|
ld a, e
|
||||||
ld a,l
|
ld [H_VBCOPYSRC], a
|
||||||
ld [H_VBCOPYDEST],a
|
ld a, d
|
||||||
ld a,h
|
ld [H_VBCOPYSRC + 1], a
|
||||||
ld [H_VBCOPYDEST + 1],a
|
|
||||||
|
ld a, l
|
||||||
|
ld [H_VBCOPYDEST], a
|
||||||
|
ld a, h
|
||||||
|
ld [H_VBCOPYDEST + 1], a
|
||||||
|
|
||||||
.loop
|
.loop
|
||||||
ld a,c
|
ld a, c
|
||||||
cp a,8 ; are there more than 128 bytes left to copy?
|
cp 8
|
||||||
jr nc,.copyMaxSize ; only copy up to 128 bytes at a time
|
jr nc, .keepgoing
|
||||||
.copyRemainder
|
|
||||||
ld [H_VBCOPYSIZE],a
|
.done
|
||||||
call DelayFrame ; wait for V-blank handler to perform the copy
|
ld [H_VBCOPYSIZE], a
|
||||||
ld a,[$ff8b]
|
call DelayFrame
|
||||||
ld [H_LOADEDROMBANK],a
|
ld a, [$ff8b]
|
||||||
ld [$2000],a
|
ld [H_LOADEDROMBANK], a
|
||||||
|
ld [MBC3RomBank], a
|
||||||
pop af
|
pop af
|
||||||
ld [H_AUTOBGTRANSFERENABLED],a ; restore original auto-transfer enabled flag
|
ld [H_AUTOBGTRANSFERENABLED], a
|
||||||
ret
|
ret
|
||||||
.copyMaxSize
|
|
||||||
ld a,8 ; 128 bytes
|
.keepgoing
|
||||||
ld [H_VBCOPYSIZE],a
|
ld a, 8
|
||||||
call DelayFrame ; wait for V-blank handler to perform the copy
|
ld [H_VBCOPYSIZE], a
|
||||||
ld a,c
|
call DelayFrame
|
||||||
sub a,8
|
ld a, c
|
||||||
ld c,a
|
sub 8
|
||||||
|
ld c, a
|
||||||
jr .loop
|
jr .loop
|
||||||
|
|
||||||
; copy (c * 8) source bytes from b:de to hl during V-blank
|
CopyVideoDataDouble::
|
||||||
; copies each source byte to the destination twice (next to each other)
|
; Wait for the next VBlank, then copy c 1bpp
|
||||||
; transfers up to 64 source bytes per V-blank
|
; tiles from b:de to hl, 8 tiles at a time.
|
||||||
CopyVideoDataDouble:: ; 1886 (0:1886)
|
; This takes c/8 frames.
|
||||||
ld a,[H_AUTOBGTRANSFERENABLED] ; save auto-transfer enabled flag
|
ld a, [H_AUTOBGTRANSFERENABLED]
|
||||||
push af
|
push af
|
||||||
xor a
|
xor a ; disable auto-transfer while copying
|
||||||
ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer while copying
|
ld [H_AUTOBGTRANSFERENABLED], a
|
||||||
ld a,[H_LOADEDROMBANK]
|
ld a, [H_LOADEDROMBANK]
|
||||||
ld [$ff8b],a
|
ld [$ff8b], a
|
||||||
ld a,b
|
|
||||||
ld [H_LOADEDROMBANK],a
|
ld a, b
|
||||||
ld [$2000],a
|
ld [H_LOADEDROMBANK], a
|
||||||
ld a,e
|
ld [MBC3RomBank], a
|
||||||
ld [H_VBCOPYDOUBLESRC],a
|
|
||||||
ld a,d
|
ld a, e
|
||||||
ld [H_VBCOPYDOUBLESRC + 1],a
|
ld [H_VBCOPYDOUBLESRC], a
|
||||||
ld a,l
|
ld a, d
|
||||||
ld [H_VBCOPYDOUBLEDEST],a
|
ld [H_VBCOPYDOUBLESRC + 1], a
|
||||||
ld a,h
|
|
||||||
ld [H_VBCOPYDOUBLEDEST + 1],a
|
ld a, l
|
||||||
|
ld [H_VBCOPYDOUBLEDEST], a
|
||||||
|
ld a, h
|
||||||
|
ld [H_VBCOPYDOUBLEDEST + 1], a
|
||||||
|
|
||||||
.loop
|
.loop
|
||||||
ld a,c
|
ld a, c
|
||||||
cp a,8 ; are there more than 64 source bytes left to copy?
|
cp 8
|
||||||
jr nc,.copyMaxSize ; only copy up to 64 source bytes at a time
|
jr nc, .keepgoing
|
||||||
.copyRemainder
|
|
||||||
ld [H_VBCOPYDOUBLESIZE],a
|
.done
|
||||||
call DelayFrame ; wait for V-blank handler to perform the copy
|
ld [H_VBCOPYDOUBLESIZE], a
|
||||||
ld a,[$ff8b]
|
call DelayFrame
|
||||||
ld [H_LOADEDROMBANK],a
|
ld a, [$ff8b]
|
||||||
ld [$2000],a
|
ld [H_LOADEDROMBANK], a
|
||||||
|
ld [MBC3RomBank], a
|
||||||
pop af
|
pop af
|
||||||
ld [H_AUTOBGTRANSFERENABLED],a ; restore original auto-transfer enabled flag
|
ld [H_AUTOBGTRANSFERENABLED], a
|
||||||
ret
|
ret
|
||||||
.copyMaxSize
|
|
||||||
ld a,8 ; 64 source bytes
|
.keepgoing
|
||||||
ld [H_VBCOPYDOUBLESIZE],a
|
ld a, 8
|
||||||
call DelayFrame ; wait for V-blank handler to perform the copy
|
ld [H_VBCOPYDOUBLESIZE], a
|
||||||
ld a,c
|
call DelayFrame
|
||||||
sub a,8
|
ld a, c
|
||||||
ld c,a
|
sub 8
|
||||||
|
ld c, a
|
||||||
jr .loop
|
jr .loop
|
||||||
|
|
||||||
; clears an area of the screen
|
ClearScreenArea::
|
||||||
; INPUT:
|
; Clear tilemap area cxb at hl.
|
||||||
; hl = address of upper left corner of the area
|
ld a, $7f ; blank tile
|
||||||
; b = height
|
ld de, 20 ; screen width
|
||||||
; c = width
|
.y
|
||||||
ClearScreenArea:: ; 18c4 (0:18c4)
|
|
||||||
ld a,$7F ; blank tile
|
|
||||||
ld de,20 ; screen width
|
|
||||||
.loop
|
|
||||||
push hl
|
push hl
|
||||||
push bc
|
push bc
|
||||||
.innerLoop
|
.x
|
||||||
ld [hli],a
|
ld [hli], a
|
||||||
dec c
|
dec c
|
||||||
jr nz,.innerLoop
|
jr nz, .x
|
||||||
pop bc
|
pop bc
|
||||||
pop hl
|
pop hl
|
||||||
add hl,de
|
add hl, de
|
||||||
dec b
|
dec b
|
||||||
jr nz,.loop
|
jr nz, .y
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; copies the screen tile buffer from WRAM to VRAM
|
CopyScreenTileBufferToVRAM::
|
||||||
; copying is done in 3 chunks of 6 rows each
|
; Copy wTileMap to the BG Map starting at b * $100.
|
||||||
; b: high byte of VRAM destination address ($98 or $9c for window tile map 0 or 1 resp.)
|
; This is done in thirds of 6 rows, so it takes 3 frames.
|
||||||
CopyScreenTileBufferToVRAM:: ; 18d6 (0:18d6)
|
|
||||||
ld c, $6
|
ld c, 6
|
||||||
ld hl, $0000
|
|
||||||
ld de, wTileMap
|
ld hl, $600 * 0
|
||||||
call InitScreenTileBufferTransferParameters
|
ld de, wTileMap + 20 * 6 * 0
|
||||||
|
call .setup
|
||||||
call DelayFrame
|
call DelayFrame
|
||||||
ld hl, $600
|
|
||||||
ld de, wTileMap + 20 * 6
|
ld hl, $600 * 1
|
||||||
call InitScreenTileBufferTransferParameters
|
ld de, wTileMap + 20 * 6 * 1
|
||||||
|
call .setup
|
||||||
call DelayFrame
|
call DelayFrame
|
||||||
ld hl, $c00
|
|
||||||
ld de, wTileMap + 20 * 12
|
ld hl, $600 * 2
|
||||||
call InitScreenTileBufferTransferParameters
|
ld de, wTileMap + 20 * 6 * 2
|
||||||
|
call .setup
|
||||||
jp DelayFrame
|
jp DelayFrame
|
||||||
|
|
||||||
InitScreenTileBufferTransferParameters:: ; 18fc (0:18fc)
|
.setup
|
||||||
ld a, d
|
ld a, d
|
||||||
ld [H_VBCOPYBGSRC+1], a
|
ld [H_VBCOPYBGSRC+1], a
|
||||||
call GetRowColAddressBgMap
|
call GetRowColAddressBgMap
|
||||||
ld a, l
|
ld a, l
|
||||||
ld [H_VBCOPYBGDEST], a ; $ffc3
|
ld [H_VBCOPYBGDEST], a
|
||||||
ld a, h
|
ld a, h
|
||||||
ld [H_VBCOPYBGDEST+1], a
|
ld [H_VBCOPYBGDEST+1], a
|
||||||
ld a, c
|
ld a, c
|
||||||
ld [H_VBCOPYBGNUMROWS], a ; $ffc5
|
ld [H_VBCOPYBGNUMROWS], a
|
||||||
ld a, e
|
ld a, e
|
||||||
ld [H_VBCOPYBGSRC], a ; $ffc1
|
ld [H_VBCOPYBGSRC], a
|
||||||
ret
|
ret
|
||||||
|
|
||||||
ClearScreen:: ; 190f (0:190f)
|
ClearScreen::
|
||||||
; clears all tiles in the tilemap,
|
; Clear wTileMap, then wait
|
||||||
; then wait three frames
|
; for the bg map to update.
|
||||||
ld bc,$0168 ; tilemap size
|
ld bc, 20 * 18
|
||||||
inc b
|
inc b
|
||||||
ld hl,wTileMap ; TILEMAP_START
|
ld hl, wTileMap
|
||||||
ld a,$7F ; $7F is blank tile
|
ld a, $7f
|
||||||
.loop
|
.loop
|
||||||
ld [hli],a
|
ld [hli], a
|
||||||
dec c
|
dec c
|
||||||
jr nz,.loop
|
jr nz, .loop
|
||||||
dec b
|
dec b
|
||||||
jr nz,.loop
|
jr nz, .loop
|
||||||
jp Delay3
|
jp Delay3
|
||||||
|
|
||||||
TextBoxBorder:: ; 1922 (0:1922)
|
|
||||||
; draw a text box
|
|
||||||
; upper-left corner at coordinates hl
|
|
||||||
; height b
|
|
||||||
; width c
|
|
||||||
|
|
||||||
; first row
|
TextBoxBorder::
|
||||||
|
; Draw a cxb text box at hl.
|
||||||
|
|
||||||
|
; top row
|
||||||
push hl
|
push hl
|
||||||
ld a,"┌"
|
ld a, "┌"
|
||||||
ld [hli],a
|
ld [hli], a
|
||||||
inc a ; horizontal border ─
|
inc a ; ─
|
||||||
call NPlaceChar
|
call NPlaceChar
|
||||||
inc a ; upper-right border ┐
|
inc a ; ┐
|
||||||
ld [hl],a
|
ld [hl], a
|
||||||
|
pop hl
|
||||||
|
|
||||||
|
ld de, 20
|
||||||
|
add hl, de
|
||||||
|
|
||||||
; middle rows
|
; middle rows
|
||||||
pop hl
|
.next
|
||||||
ld de,20
|
|
||||||
add hl,de ; skip the top row
|
|
||||||
|
|
||||||
.PlaceRow
|
|
||||||
push hl
|
push hl
|
||||||
ld a,"│"
|
ld a, "│"
|
||||||
ld [hli],a
|
ld [hli],a
|
||||||
ld a," "
|
ld a, " "
|
||||||
call NPlaceChar
|
call NPlaceChar
|
||||||
ld [hl],"│"
|
ld [hl], "│"
|
||||||
|
|
||||||
pop hl
|
pop hl
|
||||||
ld de,20
|
|
||||||
add hl,de ; move to next row
|
ld de, 20
|
||||||
|
add hl, de
|
||||||
dec b
|
dec b
|
||||||
jr nz,.PlaceRow
|
jr nz, .next
|
||||||
|
|
||||||
; bottom row
|
; bottom row
|
||||||
ld a,"└"
|
ld a, "└"
|
||||||
ld [hli],a
|
ld [hli], a
|
||||||
ld a,"─"
|
ld a, "─"
|
||||||
call NPlaceChar
|
call NPlaceChar
|
||||||
ld [hl],"┘"
|
ld [hl], "┘"
|
||||||
ret
|
ret
|
||||||
;
|
|
||||||
NPlaceChar:: ; 194f (0:194f)
|
NPlaceChar::
|
||||||
; place a row of width c of identical characters
|
; Place char a c times.
|
||||||
ld d,c
|
ld d, c
|
||||||
.loop
|
.loop
|
||||||
ld [hli],a
|
ld [hli], a
|
||||||
dec d
|
dec d
|
||||||
jr nz,.loop
|
jr nz, .loop
|
||||||
ret
|
ret
|
||||||
|
|
||||||
PlaceString:: ; 1955 (0:1955)
|
PlaceString:: ; 1955 (0:1955)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue