summaryrefslogtreecommitdiff
path: root/home/copy2.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home/copy2.asm')
-rw-r--r--home/copy2.asm146
1 files changed, 75 insertions, 71 deletions
diff --git a/home/copy2.asm b/home/copy2.asm
index 830440b0..bd1c0f78 100644
--- a/home/copy2.asm
+++ b/home/copy2.asm
@@ -1,65 +1,39 @@
-FarCopyData2::
-; Identical to FarCopyData, but uses hROMBankTemp
-; as temp space instead of wBuffer.
- ld [hROMBankTemp],a
- ld a,[H_LOADEDROMBANK]
- push af
- ld a,[hROMBankTemp]
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
- call CopyData
- pop af
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
- ret
-
-FarCopyData3::
-; Copy bc bytes from a:de to hl.
- ld [hROMBankTemp],a
- ld a,[H_LOADEDROMBANK]
- push af
- ld a,[hROMBankTemp]
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
- push hl
- push de
- push de
- ld d,h
- ld e,l
- pop hl
- call CopyData
- pop de
- pop hl
- pop af
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
- ret
-
-FarCopyDataDouble::
+FarCopyDataDouble:: ; 15d4 (0:15d4)
; Expand bc bytes of 1bpp image data
-; from a:hl to 2bpp data at de.
- ld [hROMBankTemp],a
+; from a:de to 2bpp data at hl.
+ ld [wd122+1],a
ld a,[H_LOADEDROMBANK]
push af
- ld a,[hROMBankTemp]
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
-.loop
- ld a,[hli]
- ld [de],a
- inc de
- ld [de],a
- inc de
- dec bc
+ ld a,[wd122+1]
+ call BankswitchCommon
+ ld a,h ; swap hl and de
+ ld h,d
+ ld d,a
+ ld a,l
+ ld l,e
+ ld e,a
+ ld a,b
+ and a
+ jr z,.eightbitcopyamount
ld a,c
- or b
- jr nz,.loop
+ and a ; multiple of $100
+ jr z, .expandloop ; if so, do not increment b because the first instance of dec c results in underflow
+.eightbitcopyamount
+ inc b
+.expandloop
+ ld a,[de]
+ inc de
+ ld [hli],a
+ ld [hli],a
+ dec c
+ jr nz, .expandloop
+ dec b
+ jr nz, .expandloop
pop af
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
+ call BankswitchCommon
ret
-CopyVideoData::
+CopyVideoData:: ; 15fe (0:15fe)
; Wait for the next VBlank, then copy c 2bpp
; tiles from b:de to hl, 8 tiles at a time.
; This takes c/8 frames.
@@ -70,11 +44,10 @@ CopyVideoData::
ld [H_AUTOBGTRANSFERENABLED], a
ld a, [H_LOADEDROMBANK]
- ld [hROMBankTemp], a
+ push af
ld a, b
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
+ call BankswitchCommon
ld a, e
ld [H_VBCOPYSRC], a
@@ -94,9 +67,8 @@ CopyVideoData::
.done
ld [H_VBCOPYSIZE], a
call DelayFrame
- ld a, [hROMBankTemp]
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
+ pop af
+ call BankswitchCommon
pop af
ld [H_AUTOBGTRANSFERENABLED], a
ret
@@ -110,7 +82,7 @@ CopyVideoData::
ld c, a
jr .loop
-CopyVideoDataDouble::
+CopyVideoDataDouble:: ; 1636 (0:1636)
; Wait for the next VBlank, then copy c 1bpp
; tiles from b:de to hl, 8 tiles at a time.
; This takes c/8 frames.
@@ -119,11 +91,10 @@ CopyVideoDataDouble::
xor a ; disable auto-transfer while copying
ld [H_AUTOBGTRANSFERENABLED], a
ld a, [H_LOADEDROMBANK]
- ld [hROMBankTemp], a
+ push af
ld a, b
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
+ call BankswitchCommon
ld a, e
ld [H_VBCOPYDOUBLESRC], a
@@ -143,9 +114,8 @@ CopyVideoDataDouble::
.done
ld [H_VBCOPYDOUBLESIZE], a
call DelayFrame
- ld a, [hROMBankTemp]
- ld [H_LOADEDROMBANK], a
- ld [MBC1RomBank], a
+ pop af
+ call BankswitchCommon
pop af
ld [H_AUTOBGTRANSFERENABLED], a
ret
@@ -159,7 +129,41 @@ CopyVideoDataDouble::
ld c, a
jr .loop
-ClearScreenArea::
+FillMemory:: ; 166e (0:166e)
+ push af
+ ld a,b
+ and a
+ jr z, .eightbitcopyamount
+ ld a,c
+ and a
+ jr z, .mulitpleof0x100
+.eightbitcopyamount
+ inc b
+.mulitpleof0x100
+ pop af
+.loop
+ ld [hli],a
+ dec c
+ jr nz, .loop
+ dec b
+ jr nz, .loop
+ ret
+
+Func_1681:: ; 1681 (0:1681)
+ push bc
+ ld b,a
+ ld a, [H_LOADEDROMBANK]
+ push af
+ ld a,b
+ call BankswitchCommon
+ ld b,[hl]
+ pop af
+ call BankswitchCommon
+ ld a,b
+ pop bc
+ ret
+
+ClearScreenArea:: ; 1692 (0:1692)
; Clear tilemap area cxb at hl.
ld a, " " ; blank tile
ld de, 20 ; screen width
@@ -177,7 +181,7 @@ ClearScreenArea::
jr nz, .y
ret
-CopyScreenTileBufferToVRAM::
+CopyScreenTileBufferToVRAM:: ; 16a4 (0:16a4)
; Copy wTileMap to the BG Map starting at b * $100.
; This is done in thirds of 6 rows, so it takes 3 frames.
@@ -212,7 +216,7 @@ CopyScreenTileBufferToVRAM::
ld [H_VBCOPYBGSRC], a
ret
-ClearScreen::
+ClearScreen:: ; 16dd (0:16dd)
; Clear wTileMap, then wait
; for the bg map to update.
ld bc, 20 * 18