made memory copy a function instead of a macro
This commit is contained in:
@@ -1,8 +1,20 @@
|
|||||||
INCLUDE "hardware.inc"
|
INCLUDE "hardware.inc"
|
||||||
INCLUDE "utils.inc"
|
|
||||||
|
|
||||||
_VRAM_BG_TILES EQU $9000
|
_VRAM_BG_TILES EQU $9000
|
||||||
_SCREEN_BYTES EQU SCRN_X_B * SCRN_Y_B
|
|
||||||
|
SECTION "Memory Copy", ROM0
|
||||||
|
; hl = destination
|
||||||
|
; de = source
|
||||||
|
; bc = count
|
||||||
|
MemoryCopy:
|
||||||
|
ld a, [de]
|
||||||
|
ld [hl+], a
|
||||||
|
inc de
|
||||||
|
dec bc
|
||||||
|
ld a, b
|
||||||
|
or c
|
||||||
|
jr nz, MemoryCopy
|
||||||
|
ret
|
||||||
|
|
||||||
SECTION "V-Blank Interrupt Handler", ROM0[$40]
|
SECTION "V-Blank Interrupt Handler", ROM0[$40]
|
||||||
VBlankInterruptHandler:
|
VBlankInterruptHandler:
|
||||||
@@ -56,9 +68,20 @@ Start:
|
|||||||
ld [rBGP], a
|
ld [rBGP], a
|
||||||
|
|
||||||
; load tiles
|
; load tiles
|
||||||
MemCopy _VRAM_BG_TILES, Tile0, 16
|
ld hl, _VRAM_BG_TILES
|
||||||
MemCopy _VRAM_BG_TILES + 16, Tile1, 16
|
ld de, Tile0
|
||||||
MemCopy _VRAM_BG_TILES + 32, Tile2, 16
|
ld bc, 16
|
||||||
|
call MemoryCopy
|
||||||
|
|
||||||
|
ld hl, _VRAM_BG_TILES + 16
|
||||||
|
ld de, Tile1
|
||||||
|
ld bc, 16
|
||||||
|
call MemoryCopy
|
||||||
|
|
||||||
|
ld hl, _VRAM_BG_TILES + 32
|
||||||
|
ld de, Tile2
|
||||||
|
ld bc, 16
|
||||||
|
call MemoryCopy
|
||||||
|
|
||||||
; set scrolling to (0, 0)
|
; set scrolling to (0, 0)
|
||||||
xor a
|
xor a
|
||||||
@@ -66,7 +89,10 @@ Start:
|
|||||||
ld [rSCX], a
|
ld [rSCX], a
|
||||||
|
|
||||||
; init ram
|
; init ram
|
||||||
MemCopy _SCRN0, DefaultMap, 32 * 32
|
ld hl, _SCRN0
|
||||||
|
ld de, DefaultMap
|
||||||
|
ld bc, 32 * 32
|
||||||
|
call MemoryCopy
|
||||||
|
|
||||||
; enable screen with background
|
; enable screen with background
|
||||||
;ld a, LCDCF_ON | LCDCF_BGON
|
;ld a, LCDCF_ON | LCDCF_BGON
|
||||||
@@ -278,7 +304,8 @@ Start:
|
|||||||
;jr z, .waitPressA
|
;jr z, .waitPressA
|
||||||
|
|
||||||
jp .mainloop
|
jp .mainloop
|
||||||
|
|
||||||
|
SECTION "Table based conway's game of life step", ROM0
|
||||||
; bc = pointer to neighbor offsets
|
; bc = pointer to neighbor offsets
|
||||||
; destroys all registers
|
; destroys all registers
|
||||||
Conway:
|
Conway:
|
||||||
@@ -296,7 +323,7 @@ Conway:
|
|||||||
ld d, a
|
ld d, a
|
||||||
|
|
||||||
; check end of list
|
; check end of list
|
||||||
or e ; (a still contains d)
|
or a, e ; (a still contains d)
|
||||||
jp z, .decide
|
jp z, .decide
|
||||||
|
|
||||||
; advance bc to next neighbor
|
; advance bc to next neighbor
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
SECTION "Utils", ROM0
|
|
||||||
|
|
||||||
MemCopy: MACRO
|
|
||||||
ld hl, \1
|
|
||||||
ld de, \2
|
|
||||||
ld bc, \3
|
|
||||||
.memcpyloop\@
|
|
||||||
ld a, [de]
|
|
||||||
ld [hl+], a
|
|
||||||
inc de
|
|
||||||
dec bc
|
|
||||||
ld a, b
|
|
||||||
or c
|
|
||||||
jr nz, .memcpyloop\@
|
|
||||||
ENDM
|
|
||||||
|
|
||||||
StringCopy: MACRO
|
|
||||||
ld hl, \1
|
|
||||||
ld de, \2
|
|
||||||
.strcpyloop\@
|
|
||||||
ld a, [de]
|
|
||||||
ld [hl+], a
|
|
||||||
inc de
|
|
||||||
and a
|
|
||||||
jr nz, .strcpyloop\@
|
|
||||||
ENDM
|
|
||||||
Reference in New Issue
Block a user