summaryrefslogtreecommitdiff
path: root/home/vcopy.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home/vcopy.asm')
-rw-r--r--home/vcopy.asm80
1 files changed, 27 insertions, 53 deletions
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 69773cfe..da85e3e7 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -33,13 +33,13 @@ ClearBgMap:: ; 1cf0 (0:1cf0)
jr nz,.loop
ret
-RedrawRowOrColumn:: ; 1d01 (0:1d01)
; This function redraws a BG row of height 2 or a BG column of width 2.
; One of its main uses is redrawing the row or column that will be exposed upon
; scrolling the BG when the player takes a step. Redrawing only the exposed
; row or column is more efficient than redrawing the entire screen.
; However, this function is also called repeatedly to redraw the whole screen
; when necessary. It is also used in trade animation and elevator code.
+RedrawRowOrColumn:: ; 1ada (0:1ada)
ld a,[hRedrawRowOrColumnMode]
and a
ret z
@@ -119,15 +119,11 @@ RedrawRowOrColumn:: ; 1d01 (0:1d01)
; on when talking to sprites, battling, using menus, etc. This is because
; the above function, RedrawRowOrColumn, is used when walking to
; improve efficiency.
-AutoBgMapTransfer:: ; 1d57 (0:1d57)
+AutoBgMapTransfer:: ; 1b30 (0:1b30)
ld a,[H_AUTOBGTRANSFERENABLED]
and a
ret z
- ld hl,[sp + 0]
- ld a,h
- ld [H_SPTEMP],a
- ld a,l
- ld [H_SPTEMP + 1],a ; save stack pinter
+ ld [H_SPTEMP],sp ; save stack pinter
ld a,[H_AUTOBGTRANSFERPORTION]
and a
jr z,.transferTopThird
@@ -193,23 +189,19 @@ TransferBgRows:: ; 1d9e (0:1d9e)
jr nz, TransferBgRows
ld a, [H_SPTEMP]
- ld h, a
- ld a, [H_SPTEMP + 1]
ld l, a
+ ld a, [H_SPTEMP + 1]
+ ld h, a
ld sp, hl
ret
; Copies [H_VBCOPYBGNUMROWS] rows from H_VBCOPYBGSRC to H_VBCOPYBGDEST.
; If H_VBCOPYBGSRC is XX00, the transfer is disabled.
-VBlankCopyBgMap:: ; 1de1 (0:1de1)
+VBlankCopyBgMap:: ; 1bb5 (0:1bb5)
ld a,[H_VBCOPYBGSRC] ; doubles as enabling byte
and a
ret z
- ld hl,[sp + 0]
- ld a,h
- ld [H_SPTEMP],a
- ld a,l
- ld [H_SPTEMP + 1],a ; save stack pointer
+ ld [H_SPTEMP],sp ; save stack pointer
ld a,[H_VBCOPYBGSRC]
ld l,a
ld a,[H_VBCOPYBGSRC + 1]
@@ -226,7 +218,7 @@ VBlankCopyBgMap:: ; 1de1 (0:1de1)
jr TransferBgRows
-VBlankCopyDouble::
+VBlankCopyDouble:: ; 1bd1 (0:1bd1)
; Copy [H_VBCOPYDOUBLESIZE] 1bpp tiles
; from H_VBCOPYDOUBLESRC to H_VBCOPYDOUBLEDEST.
@@ -238,11 +230,7 @@ VBlankCopyDouble::
and a
ret z
- ld hl, [sp + 0]
- ld a, h
- ld [H_SPTEMP], a
- ld a, l
- ld [H_SPTEMP + 1], a
+ ld [H_SPTEMP],sp ; save stack pointer
ld a, [H_VBCOPYDOUBLESRC]
ld l, a
@@ -285,27 +273,20 @@ VBlankCopyDouble::
dec b
jr nz, .loop
- ld a, l
- ld [H_VBCOPYDOUBLEDEST], a
- ld a, h
- ld [H_VBCOPYDOUBLEDEST + 1], a
-
- ld hl, [sp + 0]
- ld a, l
- ld [H_VBCOPYDOUBLESRC], a
- ld a, h
- ld [H_VBCOPYDOUBLESRC + 1], a
+ ld [H_VBCOPYDOUBLESRC],sp
+ ld sp,hl ; load destination into sp to save time with ld [$xxxx],sp
+ ld [H_VBCOPYDOUBLEDEST], sp
ld a, [H_SPTEMP]
- ld h, a
- ld a, [H_SPTEMP + 1]
ld l, a
+ ld a, [H_SPTEMP + 1]
+ ld h, a
ld sp, hl
ret
-VBlankCopy::
+VBlankCopy:: ; 1c21 (0:1c21)
; Copy [H_VBCOPYSIZE] 2bpp tiles (or 16 * [H_VBCOPYSIZE] tile map entries)
; from H_VBCOPYSRC to H_VBCOPYDEST.
@@ -316,11 +297,7 @@ VBlankCopy::
and a
ret z
- ld hl, [sp + 0]
- ld a, h
- ld [H_SPTEMP], a
- ld a, l
- ld [H_SPTEMP + 1], a
+ ld [H_SPTEMP],sp
ld a, [H_VBCOPYSRC]
ld l, a
@@ -355,27 +332,20 @@ VBlankCopy::
dec b
jr nz, .loop
- ld a, l
- ld [H_VBCOPYDEST], a
- ld a, h
- ld [H_VBCOPYDEST + 1], a
-
- ld hl, [sp + 0]
- ld a, l
- ld [H_VBCOPYSRC], a
- ld a, h
- ld [H_VBCOPYSRC + 1], a
-
+ ld [H_VBCOPYSRC],sp
+ ld sp,hl
+ ld [H_VBCOPYDEST],sp
+
ld a, [H_SPTEMP]
- ld h, a
- ld a, [H_SPTEMP + 1]
ld l, a
+ ld a, [H_SPTEMP + 1]
+ ld h, a
ld sp, hl
ret
-UpdateMovingBgTiles::
+UpdateMovingBgTiles:: ; 1c75 (0:1c75)
; Animate water and flower
; tiles in the overworld.
@@ -383,6 +353,10 @@ UpdateMovingBgTiles::
and a
ret z ; no animations if indoors (or if a menu set this to 0)
+ ld a,[rLY]
+ cp $90 ; check if not in vblank period??? (maybe if vblank is too long)
+ ret c
+
ld a, [hMovingBGTilesCounter1]
inc a
ld [hMovingBGTilesCounter1], a