summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
Diffstat (limited to 'home')
-rw-r--r--home/overworld.asm76
-rw-r--r--home/vblank.asm2
-rw-r--r--home/vcopy.asm51
3 files changed, 66 insertions, 63 deletions
diff --git a/home/overworld.asm b/home/overworld.asm
index 6b3a75c6..051d055e 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -555,10 +555,10 @@ CheckMapConnections:: ; 07ba (0:07ba)
jr z,.savePointer1
.pointerAdjustmentLoop1
ld a,[wWestConnectedMapWidth] ; width of connected map
- add a,$06
+ add a,MAP_BORDER * 2
ld e,a
- ld d,$00
- ld b,$00
+ ld d,0
+ ld b,0
add hl,de
dec c
jr nz,.pointerAdjustmentLoop1
@@ -591,10 +591,10 @@ CheckMapConnections:: ; 07ba (0:07ba)
jr z,.savePointer2
.pointerAdjustmentLoop2
ld a,[wEastConnectedMapWidth]
- add a,$06
+ add a,MAP_BORDER * 2
ld e,a
- ld d,$00
- ld b,$00
+ ld d,0
+ ld b,0
add hl,de
dec c
jr nz,.pointerAdjustmentLoop2
@@ -883,15 +883,15 @@ LoadTileBlockMap:: ; 09fc (0:09fc)
ld hl,wOverworldMap
ld a,[W_CURMAPWIDTH]
ld [hMapWidth],a
- add a,$06 ; border (east and west)
+ add a,MAP_BORDER * 2 ; east and west
ld [hMapStride],a ; map width + border
- ld b,$00
+ ld b,0
ld c,a
; make space for north border (next 3 lines)
add hl,bc
add hl,bc
add hl,bc
- ld c,$03
+ ld c,MAP_BORDER
add hl,bc ; this puts us past the (west) border
ld a,[W_MAPDATAPTR] ; tile map pointer
ld e,a
@@ -995,7 +995,7 @@ LoadTileBlockMap:: ; 09fc (0:09fc)
ret
LoadNorthSouthConnectionsTileMap:: ; 0ade (0:0ade)
- ld c,$03
+ ld c,MAP_BORDER
.loop
push de
push hl
@@ -1016,7 +1016,7 @@ LoadNorthSouthConnectionsTileMap:: ; 0ade (0:0ade)
inc h
.noCarry1
ld a,[W_CURMAPWIDTH]
- add a,$06
+ add a,MAP_BORDER * 2
add e
ld e,a
jr nc,.noCarry2
@@ -1029,7 +1029,7 @@ LoadNorthSouthConnectionsTileMap:: ; 0ade (0:0ade)
LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02)
push hl
push de
- ld c,$03
+ ld c,MAP_BORDER
.innerLoop
ld a,[hli]
ld [de],a
@@ -1045,7 +1045,7 @@ LoadEastWestConnectionsTileMap:: ; 0b02 (0:0b02)
inc h
.noCarry1
ld a,[W_CURMAPWIDTH]
- add a,$06
+ add a,MAP_BORDER * 2
add e
ld e,a
jr nc,.noCarry2
@@ -1387,7 +1387,7 @@ LoadCurrentMapView:: ; 0caa (0:0caa)
; update tile block map pointer to next row's address
pop de
ld a,[W_CURMAPWIDTH]
- add a,$06
+ add a,MAP_BORDER * 2
add e
ld e,a
jr nc,.noCarry
@@ -1418,7 +1418,7 @@ LoadCurrentMapView:: ; 0caa (0:0caa)
ld bc,$0002
add hl,bc
.copyToVisibleAreaBuffer
- coord de, 0, 0 ; base address for the tiles that are directly transfered to VRAM during V-blank
+ coord de, 0, 0 ; base address for the tiles that are directly transferred to VRAM during V-blank
ld b, SCREEN_HEIGHT
.rowLoop2
ld c, SCREEN_WIDTH
@@ -1662,7 +1662,7 @@ MoveTileBlockMapPointerWest:: ; 0e6f (0:0e6f)
ret
MoveTileBlockMapPointerSouth:: ; 0e79 (0:0e79)
- add a,$06
+ add a,MAP_BORDER * 2
ld b,a
ld a,[de]
add b
@@ -1675,7 +1675,7 @@ MoveTileBlockMapPointerSouth:: ; 0e79 (0:0e79)
ret
MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85)
- add a,$06
+ add a,MAP_BORDER * 2
ld b,a
ld a,[de]
sub b
@@ -1692,17 +1692,17 @@ MoveTileBlockMapPointerNorth:: ; 0e85 (0:0e85)
ScheduleNorthRowRedraw:: ; 0e91 (0:0e91)
coord hl, 0, 0
- call CopyToScreenEdgeTiles
+ call CopyToRedrawRowOrColumnSrcTiles
ld a,[wMapViewVRAMPointer]
- ld [H_SCREENEDGEREDRAWADDR],a
+ ld [hRedrawRowOrColumnDest],a
ld a,[wMapViewVRAMPointer + 1]
- ld [H_SCREENEDGEREDRAWADDR + 1],a
- ld a,REDRAWROW
- ld [H_SCREENEDGEREDRAW],a
+ ld [hRedrawRowOrColumnDest + 1],a
+ ld a,REDRAW_ROW
+ ld [hRedrawRowOrColumnMode],a
ret
-CopyToScreenEdgeTiles:: ; 0ea6 (0:0ea6)
- ld de,wScreenEdgeTiles
+CopyToRedrawRowOrColumnSrcTiles:: ; 0ea6 (0:0ea6)
+ ld de,wRedrawRowOrColumnSrcTiles
ld c,2 * SCREEN_WIDTH
.loop
ld a,[hli]
@@ -1714,7 +1714,7 @@ CopyToScreenEdgeTiles:: ; 0ea6 (0:0ea6)
ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2)
coord hl, 0, 16
- call CopyToScreenEdgeTiles
+ call CopyToRedrawRowOrColumnSrcTiles
ld a,[wMapViewVRAMPointer]
ld l,a
ld a,[wMapViewVRAMPointer + 1]
@@ -1724,11 +1724,11 @@ ScheduleSouthRowRedraw:: ; 0eb2 (0:0eb2)
ld a,h
and a,$03
or a,$98
- ld [H_SCREENEDGEREDRAWADDR + 1],a
+ ld [hRedrawRowOrColumnDest + 1],a
ld a,l
- ld [H_SCREENEDGEREDRAWADDR],a
- ld a,REDRAWROW
- ld [H_SCREENEDGEREDRAW],a
+ ld [hRedrawRowOrColumnDest],a
+ ld a,REDRAW_ROW
+ ld [hRedrawRowOrColumnMode],a
ret
ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3)
@@ -1742,15 +1742,15 @@ ScheduleEastColumnRedraw:: ; 0ed3 (0:0ed3)
add a,18
and a,$1f
or b
- ld [H_SCREENEDGEREDRAWADDR],a
+ ld [hRedrawRowOrColumnDest],a
ld a,[wMapViewVRAMPointer + 1]
- ld [H_SCREENEDGEREDRAWADDR + 1],a
- ld a,REDRAWCOL
- ld [H_SCREENEDGEREDRAW],a
+ ld [hRedrawRowOrColumnDest + 1],a
+ ld a,REDRAW_COL
+ ld [hRedrawRowOrColumnMode],a
ret
ScheduleColumnRedrawHelper:: ; 0ef2 (0:0ef2)
- ld de,wScreenEdgeTiles
+ ld de,wRedrawRowOrColumnSrcTiles
ld c,SCREEN_HEIGHT
.loop
ld a,[hli]
@@ -1773,11 +1773,11 @@ ScheduleWestColumnRedraw:: ; 0f08 (0:0f08)
coord hl, 0, 0
call ScheduleColumnRedrawHelper
ld a,[wMapViewVRAMPointer]
- ld [H_SCREENEDGEREDRAWADDR],a
+ ld [hRedrawRowOrColumnDest],a
ld a,[wMapViewVRAMPointer + 1]
- ld [H_SCREENEDGEREDRAWADDR + 1],a
- ld a,REDRAWCOL
- ld [H_SCREENEDGEREDRAW],a
+ ld [hRedrawRowOrColumnDest + 1],a
+ ld a,REDRAW_COL
+ ld [hRedrawRowOrColumnMode],a
ret
; function to write the tiles that make up a tile block to memory
diff --git a/home/vblank.asm b/home/vblank.asm
index 8ffae9f1..f69d4a86 100644
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -22,7 +22,7 @@ VBlank::
call AutoBgMapTransfer
call VBlankCopyBgMap
- call RedrawExposedScreenEdge
+ call RedrawRowOrColumn
call VBlankCopy
call VBlankCopyDouble
call UpdateMovingBgTiles
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 02caef29..69773cfe 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -33,23 +33,26 @@ ClearBgMap:: ; 1cf0 (0:1cf0)
jr nz,.loop
ret
-; When the player takes a step, a row or column of 2x2 tile blocks at the edge
-; of the screen toward which they moved is exposed and has to be redrawn.
-; This function does the redrawing.
-RedrawExposedScreenEdge:: ; 1d01 (0:1d01)
- ld a,[H_SCREENEDGEREDRAW]
+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.
+ ld a,[hRedrawRowOrColumnMode]
and a
ret z
ld b,a
xor a
- ld [H_SCREENEDGEREDRAW],a
+ ld [hRedrawRowOrColumnMode],a
dec b
jr nz,.redrawRow
.redrawColumn
- ld hl,wScreenEdgeTiles
- ld a,[H_SCREENEDGEREDRAWADDR]
+ ld hl,wRedrawRowOrColumnSrcTiles
+ ld a,[hRedrawRowOrColumnDest]
ld e,a
- ld a,[H_SCREENEDGEREDRAWADDR + 1]
+ ld a,[hRedrawRowOrColumnDest + 1]
ld d,a
ld c,SCREEN_HEIGHT
.loop1
@@ -58,7 +61,7 @@ RedrawExposedScreenEdge:: ; 1d01 (0:1d01)
inc de
ld a,[hli]
ld [de],a
- ld a,31
+ ld a,BG_MAP_WIDTH - 1
add e
ld e,a
jr nc,.noCarry
@@ -72,23 +75,24 @@ RedrawExposedScreenEdge:: ; 1d01 (0:1d01)
dec c
jr nz,.loop1
xor a
- ld [H_SCREENEDGEREDRAW],a
+ ld [hRedrawRowOrColumnMode],a
ret
.redrawRow
- ld hl,wScreenEdgeTiles
- ld a,[H_SCREENEDGEREDRAWADDR]
+ ld hl,wRedrawRowOrColumnSrcTiles
+ ld a,[hRedrawRowOrColumnDest]
ld e,a
- ld a,[H_SCREENEDGEREDRAWADDR + 1]
+ ld a,[hRedrawRowOrColumnDest + 1]
ld d,a
push de
- call .drawHalf ; draw upper half
+ call .DrawHalf ; draw upper half
pop de
- ld a,32 ; width of VRAM background map
+ ld a,BG_MAP_WIDTH ; width of VRAM background map
add e
ld e,a
- ; draw lower half
-.drawHalf
- ld c,10
+ ; fall through and draw lower half
+
+.DrawHalf
+ ld c,SCREEN_WIDTH / 2
.loop2
ld a,[hli]
ld [de],a
@@ -113,7 +117,7 @@ RedrawExposedScreenEdge:: ; 1d01 (0:1d01)
; background per V-blank. It cycles through which third it draws.
; This transfer is turned off when walking around the map, but is turned
; on when talking to sprites, battling, using menus, etc. This is because
-; the above function, RedrawExposedScreenEdge, is used when walking to
+; the above function, RedrawRowOrColumn, is used when walking to
; improve efficiency.
AutoBgMapTransfer:: ; 1d57 (0:1d57)
ld a,[H_AUTOBGTRANSFERENABLED]
@@ -302,12 +306,11 @@ VBlankCopyDouble::
VBlankCopy::
-; Copy [H_VBCOPYSIZE] 2bpp tiles
+; Copy [H_VBCOPYSIZE] 2bpp tiles (or 16 * [H_VBCOPYSIZE] tile map entries)
; from H_VBCOPYSRC to H_VBCOPYDEST.
-; Source and destination addresses
-; are updated, so transfer can
-; continue in subsequent calls.
+; Source and destination addresses are updated,
+; so transfer can continue in subsequent calls.
ld a, [H_VBCOPYSIZE]
and a