gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 15da22ad72b4781c4df50ba38a713407a298ba08 parent 5450ff5219897e416d8d39699d3348916ec7549e Author: Toxa <untoxa@mail.ru> Date: Thu, 19 Aug 2021 12:46:07 +0300 optimize .copy_vram a bit; add vmemcpy() alias for it. Diffstat:
| M | gbdk-lib/include/gb/gb.h | 21 | +++++++++++++++++++-- |
| M | gbdk-lib/libc/targets/gbz80/cpy_data.s | 63 | ++++++++++++++++++++++++++++++++++----------------------------- |
| M | gbdk-lib/libc/targets/gbz80/set_t.s | 2 | +- |
3 files changed, 54 insertions(+), 32 deletions(-)
diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h @@ -1362,7 +1362,7 @@ inline void hide_sprite(uint8_t nb) { -/** Copies Tile Pattern data to an address in VRAM +/** Copies arbitrary data to an address in VRAM @param vram_addr Pointer to destination VRAM Address @param data Pointer to source buffer @@ -1379,7 +1379,7 @@ void set_data(uint8_t *vram_addr, uint16_t len) NONBANKED __preserves_regs(b, c); -/** Copies Tile Pattern data from an address in VRAM into a buffer +/** Copies arbitrary data from an address in VRAM into a buffer @param vram_addr Pointer to source VRAM Address @param data Pointer to destination buffer @@ -1395,6 +1395,23 @@ void get_data(uint8_t *data, uint8_t *vram_addr, uint16_t len) NONBANKED __preserves_regs(b, c); +/** Copies arbitrary data from an address in VRAM into a buffer + + @param dest Pointer to destination buffer (may be in VRAM) + @param sour Pointer to source buffer (may be in VRAM) + @param len Number of bytes to copy + + Copies __len__ bytes from or to VRAM starting at __sour__ into a buffer or to VRAM at __dest__. + + GBC only: @ref VBK_REG determines which bank of Background tile patterns are written to. + \li VBK_REG=0 indicates the first bank + \li VBK_REG=1 indicates the second +*/ +void vmemcpy(uint8_t *dest, + uint8_t *sour, + uint16_t len) NONBANKED __preserves_regs(b, c); + + /** Sets a rectangular region of Tile Map entries at a given VRAM Address. diff --git a/gbdk-lib/libc/targets/gbz80/cpy_data.s b/gbdk-lib/libc/targets/gbz80/cpy_data.s @@ -1,39 +1,44 @@ - .include "global.s" + .include "global.s" - ;; BANKED: checked - .area _BASE - ;; Copy part (size = DE) of the VRAM from (BC) to (HL) + ;; BANKED: checked + .area _BASE + ;; Copy part (size = DE) of the VRAM from (BC) to (HL) .copy_vram:: + INC D + INC E + JR 2$ 1$: - WAIT_STAT + WAIT_STAT - LD A,(BC) - LD (HL+),A - INC BC - DEC DE - LD A,D - OR E - JR NZ,1$ - RET + LD A,(BC) + LD (HL+),A + INC BC +2$: + DEC E + JR NZ, 1$ + DEC D + JR NZ, 1$ + RET +_vmemcpy:: _set_data:: _get_data:: - PUSH BC + PUSH BC - LDA HL,9(SP) ; Skip return address and registers - LD A,(HL-) ; DE = len - LD D, A - LD A,(HL-) - LD E, A - LD A,(HL-) ; BC = src - LD B, A - LD A,(HL-) - LD C, A - LD A,(HL-) ; HL = dst - LD L,(HL) - LD H,A + LDA HL,9(SP) ; Skip return address and registers + LD A,(HL-) ; DE = len + LD D, A + LD A,(HL-) + LD E, A + LD A,(HL-) ; BC = src + LD B, A + LD A,(HL-) + LD C, A + LD A,(HL-) ; HL = dst + LD L,(HL) + LD H,A - CALL .copy_vram + CALL .copy_vram - POP BC - RET + POP BC + RET diff --git a/gbdk-lib/libc/targets/gbz80/set_t.s b/gbdk-lib/libc/targets/gbz80/set_t.s @@ -2,7 +2,7 @@ .globl .set_xy_tt - ;; BANKED: checked, imperfect + ;; BANKED: checked, imperfect .area _BASE ; void set_tiles(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t *vram_addr, const uint8_t *tiles);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.