Browse Source

Added a grayscale/patterened tile fill function.

master
Ian Burgmyer 4 years ago
parent
commit
5d51184710
  1. 55
      common/functions.inc
  2. 29
      cpu/miscInstrs.asm

55
common/functions.inc

@ -46,6 +46,7 @@ clearLogo:
; Writes a value across 16 bytes, starting at HL. Intended to fill a single tile. ; Writes a value across 16 bytes, starting at HL. Intended to fill a single tile.
; Parameters: ; Parameters:
; B - The value to set the bytes to. ; B - The value to set the bytes to.
; HL - Destintion location.
; Modifies: ; Modifies:
; HL - End result: HL + 16 ; HL - End result: HL + 16
fillTile: fillTile:
@ -55,6 +56,60 @@ fillTile:
pop de pop de
ret ret
; Fills a 16 byte block with a specific pattern. Intended to fill a single tile
; with a specific grayscale or color shade.
; Parameters:
; B - The pattern to write:
; $00: $00 $00
; $01: $FF $00
; $02: $00 $FF
; $03: $FF $FF
; HL - Destintion location.
; Modifies:
; B - Set to $00 or $FF.
; HL - End result: HL + 16
fillTileEx:
push af
ld a, b
ld b, %11
and b
jr nz, _check3
; b = $00. Fill with plette entry 0.
ld b, $00
call fillTile
pop af
ret
_check3:
cp b
jr nz, _handleAlt
; b = $ff. Fill with palette entry 3.
ld b, $ff
call fillTile
pop af
ret
_handleAlt:
push de
ld b, %01
ld d, 16
ld e, $ff
cp b
ld a, 0
jr nz, _fillLoop
xor e
_fillLoop:
ld [hli], a
xor e
dec d
jr nz, _fillLoop
pop de
pop af
ret
; Copies up to 256 bytes of memory to another location. ; Copies up to 256 bytes of memory to another location.
; Parameter: ; Parameter:
; BC - Source location. ; BC - Source location.

29
cpu/miscInstrs.asm

@ -6,7 +6,7 @@ include "common/functions.inc"
SECTION "home", ROM0 SECTION "home", ROM0
ProgramStart: ProgramStart:
call clearLogo ;call clearLogo
_lcdDisable _lcdDisable
@ -15,20 +15,19 @@ ProgramStart:
ldh [$ff47], a ldh [$ff47], a
; TODO: Write actual tests. :) ; TODO: Write actual tests. :)
ld a, $ff ld hl, $8010
ld hl, $8014 ld b, $00
ld [hl], a call fillTileEx
ld hl, $8016
ld [hl], a ld b, $01
ld hl, $8019 call fillTileEx
ld [hl], a
ld hl, $801b ld b, $02
ld [hli], a call fillTileEx
ld [hli], a
ld [hli], a ld b, $03
ld [hli], a call fillTileEx
ld [hli], a
call memset
_lcdEnable _lcdEnable
.loop: .loop:

Loading…
Cancel
Save