Skip to content

Commit

Permalink
Reword comment to change references to 'output' to 'write' or 'copy'
Browse files Browse the repository at this point in the history
  • Loading branch information
lajohnston committed Feb 14, 2023
1 parent 4438000 commit 0b0d8b7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion docs/sprites.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The VDP holds a sprite table in VRAM containing the tile patterns and x and y positions of up to 64 on-screen sprites. It's generally advisable to work with a copy of this table in normal RAM so you can edit it efficiently. You can then transfer it to VRAM in bulk when it's safe to do so without causing graphical corruption i.e when the display is off or during VBlank (see [interrupts](./interrupts.md))

`sprites.asm` manages an efficient sprite buffer in RAM and lets you output it to VRAM when required.
`sprites.asm` manages an efficient sprite buffer in RAM and lets you write it to VRAM when required.

## Init

Expand Down
2 changes: 1 addition & 1 deletion palette.asm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

; Convert to --bbggrr
ld a, (\.\@blue * 16) + (\.\@green * 4) + \.\@red
out (c), a ; output color
out (c), a ; write color
.endm

;====
Expand Down
66 changes: 33 additions & 33 deletions scroll/metatiles.asm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
; Pointer to the metatile definitions
scroll.metatiles.ram.defsAddress: dw

; Base address + an offset to the current row or col being output
; Base address + an offset to the current row or col being written
scroll.metatiles.ram.defsWithOffset: dw

; How many metatile columns there are in the map (0-based; 0=1, 255=256)
Expand Down Expand Up @@ -341,16 +341,16 @@
; Load bytes/metatiles per map row
ld a, (scroll.metatiles.ram.bytesPerRow)

; Subtract metatiles we'll have already output.
; Subtract metatiles we'll have already written.
; Minus 1 as pointer isn't incremented for last one
sub scroll.metatiles.FULL_VISIBLE_METATILE_COLS - 1
ld i, a ; store result in I

; Prep tile output
ld b, tilemap.ROW_SIZE_BYTES ; bytes to output (1 row)
; Prep tile write
ld b, tilemap.ROW_SIZE_BYTES ; bytes to write (1 row)
ld de, (scroll.metatiles.ram.defsAddress) ; base definition address
ld ix, (scroll.metatiles.ram.topLeftTile.metatileAddress) ; map pointer
ld iyh, tilemap.MAX_VISIBLE_ROWS ; set IYH to rows to output
ld iyh, tilemap.MAX_VISIBLE_ROWS ; set IYH to rows to write

; Set IYL to subrows left in current row of metatiles
ld a, (scroll.metatiles.ram.topLeftTile.rowsRemaining)
Expand All @@ -360,9 +360,9 @@

_nextSubRow:
dec iyh ; decrement tilemap rows remaining
ret z ; return if no rows left to output
ret z ; return if no rows left to write

ld b, tilemap.ROW_SIZE_BYTES ; bytes to output (1 row)
ld b, tilemap.ROW_SIZE_BYTES ; bytes to write (1 row)

; Decrement subrows remaining in current metatile row
dec iyl
Expand Down Expand Up @@ -390,7 +390,7 @@
; Reset rows per metatile
ld iyl, scroll.metatiles.ROWS_PER_METATILE

; ...output next metatile
; ...write next metatile

;===
; Write a metatile along a row and return if there are no more bytes
Expand All @@ -411,7 +411,7 @@
outi
outi

; Go to next row when there are no more tiles to output in this row
; Go to next row when there are no more tiles to write in this row
.if scroll.metatiles.COLS_PER_METATILE > 8
; Jump is large to we can't use relative jump
jp z, _nextSubRow
Expand All @@ -420,7 +420,7 @@
.endif
.endr

; Keep outputting metatiles along the row
; Keep writing metatiles along the row
inc ix
jp _writeMetatileAlongRow
.ends
Expand Down Expand Up @@ -924,7 +924,7 @@
;
; @in b rowsRemaining in the left-most metatile
; @in c colsRemaining in the left-most metatile
; @in ix pointer to the left-most metatile to output
; @in ix pointer to the left-most metatile to copy
;====
.section "scroll.metatiles._populateRowBuffer" free
scroll.metatiles._populateRowBuffer:
Expand Down Expand Up @@ -995,14 +995,14 @@
;===
; Send the first metatile, which may have a column offset, to the buffer
;
; @in a the columns left to output for the current metatile
; @in a the columns left to copy for the current metatile
; @in de pointer to the buffer
; @in bc bytes to write to the buffer
;===
-:
; Output one tile
ldi ; output pattern number
ldi ; output tile attributes
; Copy one tile
ldi ; copy pattern number
ldi ; copy tile attributes
ret po ; return if current buffer is full (BC == 0)
dec a ; dec colsRemaining of current metatile
jp nz, - ; jump if no cols left in this metatile
Expand Down Expand Up @@ -1035,12 +1035,12 @@
; For each column in the metatile
.repeat scroll.metatiles.COLS_PER_METATILE index col
; Output one tile
ldi ; output pattern number
ldi ; output tile attributes
ldi ; copy pattern number
ldi ; copy tile attributes
ret po ; return if current buffer is full (BC == 0)
.endr

; Keep outputting metatiles (until BC == 0)
; Keep copying metatiles (until BC == 0)
jp _nextMetatile
.ends

Expand All @@ -1049,7 +1049,7 @@
;
; @in b rowsRemaining in the top-most metatile of the column
; @in c colsRemaining in the top-most metatile of the column
; @in ix pointer to the top-most metatileRef to output
; @in ix pointer to the top-most metatileRef to copy
;====
.section "scroll.metatiles._populateColBuffer" free
scroll.metatiles._populateColBuffer:
Expand All @@ -1070,15 +1070,15 @@
;===
; The top metatile may be partly off the top of the screen, so we'll
; need skip to the first visible subrow and draw from there. We also
; need to keep track of how many subrows to output before moving to the
; need to keep track of how many subrows to copy before moving to the
; next metatile.
;
; @in b rowsRemaining in the top metatile
; @in c colsRemaining in the top metatile
; @in de address of the definitions + offset to the subcol
; @in ix pointer to the top metatileRef in the column
;===
_outputTopMetatile:
_copyTopMetatile:
;===
; Add subrow offset
;===
Expand Down Expand Up @@ -1121,21 +1121,21 @@
tilemap.loadBCColBytes ; set BC to bytes to write

;===
; Output each potential subrow in the metatile
; Copy each potential subrow in the metatile
; Jump to _nextMetatileRow when iyl reaches 0
;===
.repeat scroll.metatiles.ROWS_PER_METATILE index row
; Output one tile
ldi ; output pattern number
ldi ; output tile attributes
; Copy one tile
ldi ; copy pattern number
ldi ; copy tile attributes

; Increment subrow (unless this is the last possible one)
.if row < scroll.metatiles.ROWS_PER_METATILE - 1
dec iyl ; dec rowsRemaining
jp z, _nextMetatileRow ; jump if no rows left in this metatile

; Skip remaining columns in metatile (total minus the one
; we've just output, multiplied by bytes)
; we've just copied, multiplied by bytes)
ld a, tilemap.TILE_SIZE_BYTES * (scroll.metatiles.COLS_PER_METATILE - 1)

.if scroll.metatiles.METATILE_DEF_SIZE_BYTES > 255
Expand All @@ -1159,9 +1159,9 @@

;===
; Copy a metatile column to the buffer, starting from the top subrow.
; Continues outputting metatiles until bytes remaining is 0.
; Continues writing metatiles until bytes remaining is 0.
;
; @in c bytes left to output in this column
; @in c bytes left to write in this column
; @in de pointer to column buffer
; @in ix pointer to metatileRef in the map
;===
Expand All @@ -1180,15 +1180,15 @@

; Each potential row in the metatile
.repeat scroll.metatiles.ROWS_PER_METATILE index row
; Output one tile
ldi ; output pattern number
ldi ; output tile attributes
ret po ; return if no more bytes to output (BC == 0)
; Copy one tile
ldi ; copy pattern number
ldi ; copy tile attributes
ret po ; return if no more bytes to copy (BC == 0)

; Increment subrow (unless this is the last possible one)
.if row < scroll.metatiles.ROWS_PER_METATILE - 1
; Skip remaining columns in metatile (total minus the one
; we've just output, multiplied by bytes)
; we've just copied, multiplied by bytes)
ld a, tilemap.TILE_SIZE_BYTES * (scroll.metatiles.COLS_PER_METATILE - 1)

.if scroll.metatiles.METATILE_DEF_SIZE_BYTES > 255
Expand Down
6 changes: 3 additions & 3 deletions scroll/tiles.asm
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@

; Draw the screen
ld hl, (scroll.tiles.ram.topLeft) ; point HL to topLeft pointer
ld d, tilemap.MAX_VISIBLE_ROWS ; number of rows to output
ld d, tilemap.MAX_VISIBLE_ROWS ; number of rows to write

; Set E to bytesPerRow
ld a, (scroll.tiles.ram.bytesPerRow); load bytesPerRow
Expand Down Expand Up @@ -364,9 +364,9 @@
tilemap.loadBCColBytes ; set BC to number of bytes to write

; Get bytes to add to point to the next row (bytes per row minus
; the 2 bytes we'll have just outputted)
; the 2 bytes we'll have just written)
ld a, (scroll.tiles.ram.bytesPerRow)
sub tilemap.TILE_SIZE_BYTES ; sub 2 bytes we'll have just outputted
sub tilemap.TILE_SIZE_BYTES ; sub 2 bytes we'll have just written
ld ixl, a ; preserve in ixl

; For each row in the column
Expand Down
4 changes: 2 additions & 2 deletions sprites.asm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
cp sprites.MAX_SPRITES ; compare with max sprites
jp nc, + ; skip if counter == max sprites
ld a, sprites.Y_TERMINATOR ; load y terminator into A
out (c), a ; output y terminator
out (c), a ; write y terminator
+:

; Point to x positions in VRAM and buffer
Expand All @@ -287,7 +287,7 @@
; VRAM address must be set
_noSprites:
ld a, sprites.Y_TERMINATOR ; load y terminator into A
out (c), a ; output y terminator
out (c), a ; write y terminator
ret
.ends

Expand Down
10 changes: 5 additions & 5 deletions tilemap.asm
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@
cp d ; compare value with terminator
ret z ; return if terminator byte found
out (tilemap.VDP_DATA_PORT), a ; write pattern ref
ld a, b ; write attributes
out (tilemap.VDP_DATA_PORT), a ; output attributes
ld a, b ; load attributes
out (tilemap.VDP_DATA_PORT), a ; write attributes
inc hl ; next char
jp tilemap.writeBytesUntil ; repeat
.ends
Expand Down Expand Up @@ -821,7 +821,7 @@

;===
; Second write
; Set B to ROW_SIZE_BYTES minus bytes outputted in first write
; Set B to ROW_SIZE_BYTES minus bytes written in first write
; Set HL to start of rowBuffer
;===
_secondWrite:
Expand Down Expand Up @@ -1146,10 +1146,10 @@
ld a, tilemap._writeColumn_writeAddressHigh; set A to high address
out (utils.vdp.VDP_COMMAND_PORT), a ; send to VDP

; Output tile
; Write tile
outi ; pattern ref
outi ; tile attributes
ret z ; return if no more tiles to output (B = 0)
ret z ; return if no more tiles to write (B = 0)
.endr

jp tilemap._writeColumn ; continue from row 0
Expand Down
10 changes: 5 additions & 5 deletions utils/outiBlock.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
;====
; Manages a big block of OUTI instructions, the fastest way to output data to
; Manages a big block of OUTI instructions, the fastest way to write data to
; the VDP
;====

Expand All @@ -14,7 +14,7 @@

;==
; The number of OUTI instructions in the OUTI block. This block is used to
; provide a fast means of outputting data to the VDP but requires a chunk of ROM
; provide a fast means of writing data to the VDP but requires a chunk of ROM
; space.
;
; Each OUTI transfers 1-byte. Lower values may mean transfers require multiple
Expand Down Expand Up @@ -58,7 +58,7 @@

;====
; Creates a block of OUTI instructions to provide the fastest means of
; outputting data to the VDP. Generate calls to this using the
; writing data to the VDP. Generate calls to this using the
; utils.outiBlock.write macro
;
; @in c the port to write to
Expand All @@ -80,7 +80,7 @@
;====
; Write data to VRAM using the fast OUTI block
;
; @in bytes the number of bytes to output
; @in bytes the number of bytes to write
; @in c the output port
; @in hl the source data address
;====
Expand Down Expand Up @@ -115,7 +115,7 @@
ld a, <(utils.outiBlock.lastOuti) ; load low-byte address of last outi

; Subtract outi instructions required
dec b ; exclude the byte the last outi will output
dec b ; exclude the byte the last outi will write
sub b ; subtract remaining bytes
sub b ; subtract again (1 outi = 2 bytes)
ld iyl, a ; set low-byte of address in IY
Expand Down

0 comments on commit 0b0d8b7

Please sign in to comment.