Browse Source

Added 48 test routines to miscInstrs.

* Added some comments to the functions include.
    * Flag bits are now included in defines.
    * Removed unused HeaderEnd define.
    * Added clearFlags and drawGrid library functions.
master
Ian Burgmyer 4 years ago
parent
commit
86062c553f
  1. 14
      common/defines.inc
  2. 63
      common/functions.inc
  3. 1199
      cpu/miscInstrs.asm

14
common/defines.inc

@ -18,11 +18,15 @@ OverrideIntJoypad SET 0
OverrideHeaderJump SET 0
;
; Memory Locations
;
HeaderEnd EQU $0150
; Flags
ZeroFlag SET 7
SubtractFlag SET 6
HalfCarryFlag SET 5
CarryFlag SET 4
; ===========
; HEADER DEFS
; ===========
;
; CGB Flag
;

63
common/functions.inc

@ -1,5 +1,7 @@
SECTION "functions", ROMX[$4000]
; Disables the LCD during the next vblank period.
; Clobbers HL.
_lcdDisable: MACRO
call waitVBlank
ld hl, $ff40
@ -8,6 +10,8 @@ _lcdDisable: MACRO
ld [hl], a
ENDM
; Enables the LCD immediately.
; Clobbers HL.
_lcdEnable: MACRO
ld hl, $ff40
ld a, [hl]
@ -15,6 +19,18 @@ _lcdEnable: MACRO
ld [hl], a
ENDM
; Completely the flags register.
; Modifies:
; F - End result: 0
clearFlags:
push bc
ld b, a
ld c, 0
push bc
pop af
pop bc
ret
; Clears the Nintendo logo tile data. This is intended to leave the screen open
; for simple (i.e. a bunch of boxes drawn with fillTile) test output.
clearLogo:
@ -43,6 +59,53 @@ clearLogo:
pop hl
ret
; Draws an inverted grid over where the Nintendo logo tile data normally
; resides. This is useful for tests that use a grid output, as it will make the
; tile number more obvious. This should be called after the tests are performed,
; as fillTile and fillTileEx will draw over the grid.
drawGrid:
push hl
push de
push bc
ld hl, $8010 ; Start address.
ld de, $8190 ; End address.
ld b, $f ; Used to find the top of each file.
_gridLoop:
ld a, l ; Check for the top of the tiles.
and b
jr z, _handleTop
; Invert the right side of the tile.
ld c, $01
ld a, [hl]
xor c
ld [hli], a
; See if we've reached the end.
ld a, h
cp d
jr nz, _gridLoop
ld a, l
cp e
jr nz, _gridLoop
; Fin.
pop bc
pop de
pop hl
ret
_handleTop:
; Each row is stuffed into two bytes, so two writes are required to fully
; invert the top row.
ld a, [hl]
cpl
ld [hli], a
ld a, [hl]
cpl
ld [hli], a
jr _gridLoop
; Writes a value across 16 bytes, starting at HL. Intended to fill a single tile.
; Parameters:
; B - The value to set the bytes to.

1199
cpu/miscInstrs.asm

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save