git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit 729e040c557228fa592178b388f10dd47a498bc5
parent 0b16757feeffbfd0f4e0ab2db562a970cd8e6a7f
Author: toxa <untoxa@mail.ru>
Date:   Tue, 24 Nov 2020 23:03:53 +0300

safer copy-to-VRAM functions

Diffstat:
Mgbdk-lib/libc/gb/init_tt.s26++++++++------------------
Mgbdk-lib/libc/gb/set_1bit_data.s31++++++-------------------------
Mgbdk-lib/libc/gb/set_data.s21++++++---------------
3 files changed, 20 insertions(+), 58 deletions(-)

diff --git a/gbdk-lib/libc/gb/init_tt.s b/gbdk-lib/libc/gb/init_tt.s @@ -24,40 +24,30 @@ LD DE,#0x0400 ; One whole GB Screen .init_vram:: -1$: - SRL D - RR E - JR NC, 2$ - WAIT_STAT - LD A, B - LD (HL+),A -2$: SRL D RR E - JR NC, 3$ + JR NC, 1$ + WAIT_STAT LD A, B LD (HL+),A - LD (HL+),A -3$: +1$: LD A, D OR E RET Z INC D INC E - JR 5$ -4$: + JR 2$ +3$: WAIT_STAT LD A, B LD (HL+),A LD (HL+),A - LD (HL+),A - LD (HL+),A -5$: +2$: DEC E - JR NZ, 4$ + JR NZ, 3$ DEC D - JR NZ, 4$ + JR NZ, 3$ RET diff --git a/gbdk-lib/libc/gb/set_1bit_data.s b/gbdk-lib/libc/gb/set_1bit_data.s @@ -1,7 +1,5 @@ .include "global.s" - .globl .copy_vram - .area _BASE _set_bkg_1bit_data:: @@ -39,32 +37,15 @@ _set_sprite_1bit_data:: jr z, 2$ res 4, d 2$: - .rept 3 ; Repeat this 3 times to copy 12 bytes... - WAIT_STAT - ; We have 16 cycles free to access VRAM, during which we can expand 2 bytes into 4 bytes - ld a, (hl+) - ld (de), a - inc e ; inc de - ld (de), a - inc e ; inc de - ld a, (hl+) - ld (de), a - inc e ; inc de - ld (de), a - inc e ; inc de - .endm + ld b, #16 +3$: WAIT_STAT - ; We have 16 cycles free to access VRAM, during which we can expand 2 bytes into 4 byte - ld a, (hl+) - ld (de), a - inc e ; inc de - ld (de), a - inc e ; inc de ld a, (hl+) ld (de), a - inc e ; inc de - ld (de), a - inc de ; This actually can overflow into the high byte + inc de + + dec b + jr nz, 3$ dec c jr nz, 1$ diff --git a/gbdk-lib/libc/gb/set_data.s b/gbdk-lib/libc/gb/set_data.s @@ -1,7 +1,5 @@ .include "global.s" - .globl .copy_vram - ;; BANKED: checked .area _BASE @@ -40,22 +38,15 @@ _set_sprite_data:: jr z, 1$ res 4, d 1$: - .rept 5 - WAIT_STAT - ld a, (hl+) - ld (de), a - inc e ; inc de - ld a, (hl+) - ld (de), a - inc e ; inc de - ld a, (hl+) - ld (de), a - inc e ; inc de - .endm + ld b, #16 +3$: WAIT_STAT ld a, (hl+) ld (de), a - inc de ; This actually can overflow into the high byte + inc de + + dec b + jr nz, 3$ dec c jr nz, 2$

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.