summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluckytyphlosion <alan.rj.huang@gmail.com>2015-05-11 16:22:44 -0400
committerluckytyphlosion <alan.rj.huang@gmail.com>2015-05-11 16:22:44 -0400
commit9c06176db55b3c95a2d526f62de83f0893439d3a (patch)
treee9dbdb8c8442e3a5a285d4fc5a473d0f5a5900eb
parent85f10f671fd5a8eedaef27f6bc27986b7465696c (diff)
Update copy2.asm
-rw-r--r--home/copy2.asm42
1 files changed, 27 insertions, 15 deletions
diff --git a/home/copy2.asm b/home/copy2.asm
index 5f66fec8..ad863788 100644
--- a/home/copy2.asm
+++ b/home/copy2.asm
@@ -37,26 +37,38 @@ FarCopyData3::
FarCopyDataDouble::
; Expand bc bytes of 1bpp image data
-; from a:hl to 2bpp data at de.
- ld [$ff8b],a
+; from a:de to 2bpp data at hl.
+ ld [wd122+1],a
ld a,[H_LOADEDROMBANK]
push af
- ld a,[$ff8b]
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
-.loop
- ld a,[hli]
- ld [de],a
+ 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,.lessthan$100bytes
+ ld a,c
+ and a ; multiple of $100
+ jr z, .expandloop ; if so, do not increment b because the first instance of dec c results in underflow
+.lessthan$100bytes
+ inc b
+.expandloop
+ ld a,[de]
inc de
- ld [de],a
+ ld [hli],a
+ ld [hli],a
inc de
- dec bc
- ld a,c
- or b
- jr nz,.loop
+ dec c
+ jr nz, .expandloop
+ dec b
+ jr nz, .expandloop
pop af
- ld [H_LOADEDROMBANK],a
- ld [MBC1RomBank],a
+ call BankswitchCommon
ret
CopyVideoDataLCDEnabled::