diff options
Diffstat (limited to 'home/copy2.asm')
-rw-r--r-- | home/copy2.asm | 136 |
1 files changed, 71 insertions, 65 deletions
diff --git a/home/copy2.asm b/home/copy2.asm index 830440b0..ad47c4a0 100644 --- a/home/copy2.asm +++ b/home/copy2.asm @@ -1,62 +1,36 @@ -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:: ; 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 [wFarCopyDataSavedROMBank],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,[wFarCopyDataSavedROMBank] + 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:: @@ -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 @@ -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,6 +129,42 @@ CopyVideoDataDouble:: ld c, a jr .loop +FillMemory:: + 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 + +GetFarByte:: +; get a byte from a:hl +; and return it in a + 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:: ; Clear tilemap area cxb at hl. ld a, " " ; blank tile |