git.y1.nz

gbdk-2020

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

commit 2d05e1914be9147d643277a332c1ed00f7da6049
parent 3457eee3fb5c2a858b0e78391aefd3cf9c9bce10
Author: Toxa <untoxa@mail.ru>
Date:   Fri, 27 Jan 2023 22:46:51 +0300

fix .copy_vram calls in drawing.s/input.s/get_data.s

Diffstat:
Mgbdk-lib/libc/targets/sm83/cpy_data.s31++++++++++++++++++++-----------
Mgbdk-lib/libc/targets/sm83/drawing.s90+++++++++++++++++++++++++++++++++++++++----------------------------------------
Mgbdk-lib/libc/targets/sm83/get_data.s18+++++++++++-------
Mgbdk-lib/libc/targets/sm83/input.s28++++++++++++++--------------
4 files changed, 89 insertions(+), 78 deletions(-)

diff --git a/gbdk-lib/libc/targets/sm83/cpy_data.s b/gbdk-lib/libc/targets/sm83/cpy_data.s @@ -2,14 +2,23 @@ .area _CODE - .globl _vmemcpy, _set_data, _get_data + .globl _vmemcpy, _set_data, _get_data, .copy_vram +;DE: dest +;HL: src +;BC: len +.copy_vram:: + push bc + ld a, c + call cpy_vram + ret + +;DE: dest +;BC: src +;sp+2: len _vmemcpy:: _set_data:: _get_data:: - ;dest in de - ;src in bc - ;n in sp+2,sp+3 ldhl sp, #3 ld a, (hl-) ld l, (hl) @@ -17,15 +26,15 @@ _get_data:: ld b, a ld a, l ld l, c + +;DE: dest +;HL: src +;B,A: len +cpy_vram: srl b rra ld c, a - - ;dest in de (backup in sp+0,sp+1) - ;src in hl - ;n/2 in bc - ;LSB of bc in carry - jr nc, skip_one + jr nc, skip_one WAIT_STAT ld a, (hl+) @@ -39,7 +48,7 @@ skip_one: ;n/4 in bc inc b inc c - jr nc, test + jr nc, test jr copy_two .irp idx,copy_four,copy_two idx: diff --git a/gbdk-lib/libc/targets/sm83/drawing.s b/gbdk-lib/libc/targets/sm83/drawing.s @@ -1,7 +1,7 @@ -;; Optimised Drawing library +;; Optimised Drawing library ;; By Jon Fuge (jonny@q-continuum.demon.co.uk) based on original file ;; Updates -;; 990223 Michael Removed mod_col, splitting it up into +;; 990223 Michael Removed mod_col, splitting it up into ;; fg_colour, bg_colour, and draw_mode ;; Note: some optimisations are available with unneded PUSH DE/POP DE's @@ -9,7 +9,7 @@ .globl .init_vram .globl .copy_vram - + .globl .drawing_lcd, .drawing_vbl .globl .bg_colour, .fg_colour, .draw_mode @@ -37,30 +37,30 @@ .area _DATA ;; Fill style -.style: +.style: .ds 0x01 ;; Various varibles -.x_s: +.x_s: .ds 2 -.y_s: +.y_s: .ds 2 -.delta_x: +.delta_x: .ds 1 -.delta_y: +.delta_y: .ds 1 -.l_inc: +.l_inc: .ds 1 -.l_d: +.l_d: .ds 2 -.dinc1: +.dinc1: .ds 2 -.dinc2: +.dinc2: .ds 2 -.tx: +.tx: .ds 1 -.ty: +.ty: .ds 1 - + .area _HOME ;; Enter graphic mode @@ -132,15 +132,15 @@ LD (.fg_colour),A LD A,#0x00 ; White LD (.bg_colour),A - + EI ; Enable interrupts RET ;; Draw a full-screen image at (BC) .draw_image:: - LD HL,#0x8000+0x10*0x10 - LD DE,#0x1680 + LD DE,#0x8000+0x10*0x10 + LD BC,#0x1680 CALL .copy_vram ; Move the charset RET @@ -169,22 +169,20 @@ LD L,A ADD HL,DE - LD B,H ; BC = src - LD C,L - POP HL ; HL = dst - PUSH BC ; Save dst + POP DE + PUSH HL LD A,H OR L JR Z,1$ - LD DE,#0x10 + LD BC,#0x10 CALL .copy_vram 1$: - POP HL ; HL = dst - POP BC ; BC = src - LD A,B - OR C + POP DE + POP HL + LD A,D + OR E JR Z,2$ - LD DE,#0x10 + LD BC,#0x10 CALL .copy_vram 2$: RET @@ -220,9 +218,9 @@ LD (.y_s),A XOR A - LD (.x_s+1),A + LD (.x_s+1),A LD A,D - LD (.y_s+1),A + LD (.y_s+1),A CPL LD L,A LD H,#0xFF @@ -272,7 +270,7 @@ cloop$: LD A,L LD (.l_d+1),A JR cloop$ -ycirc$: +ycirc$: LD A,(.style) OR A CALL NZ,.verlin @@ -483,7 +481,7 @@ ycirc$: CALL .plot POP DE POP BC - + LD A,D OR A RET Z @@ -642,7 +640,7 @@ dbox$: LD (.fg_colour),A LD A,C LD (.bg_colour),A - .endif + .endif filllp$: LD A,(.x_s) LD B,A @@ -660,7 +658,7 @@ filllp$: INC A LD (.y_s),A JR filllp$ -swap$: +swap$: .if 0 LD A,(.mod_col) ;Swap fore + back colours. LD D,A @@ -810,7 +808,7 @@ dx1$: LD A,(.mod_col) LD D,A .endif - + LD A,(.delta_x) LD E,A @@ -915,7 +913,7 @@ nadj$: ;; Draw accelerated horizontal line .if 0 ;; xxx needed? - LD A,(.mod_col) + LD A,(.mod_col) LD D,A .endif @@ -1007,9 +1005,9 @@ y2$: SUB E JR Z,y2a$ LD A,#0x00 - + ; JR NC,y2a$ ; old code; fix draw to up-left below -; LD A,#0xFF +; LD A,#0xFF LD L,A ; invert delta if x1 less than x2 LD A,B @@ -1044,7 +1042,7 @@ y3$: LD A,(.mod_col) LD D,A .endif - + LD A,(.delta_y) LD E,A INC E @@ -1262,7 +1260,7 @@ nchgy$: CP #.M_XOR JR Z,20$ CP #.M_AND - JR Z,30$ + JR Z,30$ .endif ; Fall through to SOLID by default @@ -1478,7 +1476,7 @@ nchgy$: LD DE,#_font_ibm_fixed_tiles .endif - + ADD HL,DE LD D,H @@ -1538,7 +1536,7 @@ nchgy$: .endif JR NZ,5$ XOR B -5$: +5$: LD E,A .if 1 POP HL @@ -1697,7 +1695,7 @@ _plot:: LD (.fg_colour),A LD A,(HL+) ; mode LD (.draw_mode),A - + CALL .plot POP BC @@ -1737,9 +1735,9 @@ _draw_image:: ; Non banked as pointer CALL NZ,.gmode LDA HL,4(SP) ; Skip return address and registers - LD A,(HL+) ; HL = data - LD C,A - LD B,(HL) + LD A,(HL+) + LD H,(HL) + LD L,A ; HL = data CALL .draw_image diff --git a/gbdk-lib/libc/targets/sm83/get_data.s b/gbdk-lib/libc/targets/sm83/get_data.s @@ -94,8 +94,8 @@ _get_sprite_data:: ADD HL,HL ADD HL,HL ADD HL,HL - LD D,H ; DE = nb_tiles - LD E,L + LD B,H ; BC = nb_tiles + LD C,L 2$: POP HL ; HL = first_tile LD H,A @@ -104,15 +104,19 @@ _get_sprite_data:: ADD HL,HL ADD HL,HL - LD BC,#0x8000 - ADD HL,BC - LD B,H - LD C,L ; BC = source + LD DE,#0x8000 + ADD HL,DE + LD D,H + LD E,L ; DE = dest LDA HL,7(SP) LD A,(HL-) LD L,(HL) - LD H, A ; HL = data + LD H,D + LD D,A + LD A,L + LD L,E + LD E,A ; HL = sour, DE = dest CALL .copy_vram diff --git a/gbdk-lib/libc/targets/sm83/input.s b/gbdk-lib/libc/targets/sm83/input.s @@ -2,7 +2,7 @@ ;; Note that while gets uses a pointer, the pointer had better ;; be in non-banked RAM else bad things will happen. - + .globl .copy_vram .globl .set_xy_wtt .globl .mv_sprite @@ -76,9 +76,9 @@ AND #.T_MODE CALL Z,.tmode_out - LD BC,#.tp1 ; Move pointer - LD HL,#0x8000 - LD DE,#.endtp1-.tp1 + LD HL,#.tp1 + LD DE,#0x8000 + LD BC,#.endtp1-.tp1 CALL .copy_vram LD A,#<.MINACCEL ; Acceleration @@ -96,7 +96,7 @@ LD DE,#.KBDSIZE LD HL,#(0x20 * 2 + 2) ; X=2, Y=2 CALL set_recoded_win_tiles - + LD A,#.MINWNDPOSX LDH (.WX),A LD A,#.MAXWNDPOSY ; Hide window @@ -138,12 +138,12 @@ set_recoded_win_tiles:: LD H,A PUSH DE PUSH HL -4$: +4$: LD A,(BC) INC BC PUSH BC PUSH HL - + LD C,A LD HL,#(font_current+1) ; font_current+sfont_handle_font LD A,(HL+) @@ -159,19 +159,19 @@ set_recoded_win_tiles:: LD C,(HL) 5$: POP HL - + WAIT_STAT LD A,C LD (HL+),A - + POP BC - + DEC D JR NZ,4$ - + POP HL POP DE - + LD A,L ADD #0x20 LD L,A @@ -186,7 +186,7 @@ set_recoded_win_tiles:: ADD SP,#4 RET - + ;; Prompt the user for a char and return it in A .get_char: PUSH BC @@ -631,7 +631,7 @@ _gets:: .db 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27 .db 0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F .ascii "0123456789:" - .db 0x3B + .db 0x3B .ascii "<=>?" .ascii "@ABCDEFGHIJKLMNO" .ascii "PQRSTUVWXYZ[\]^_"

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