git.y1.nz

gbdk-2020

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

commit 2a8675de7eb3a0ee513dcbc8cc2d9fe4f32535b0
parent 343687c4a94df73e02dcd44a604d84775ff39655
Author: Toxa <untoxa@mail.ru>
Date:   Mon, 15 Feb 2021 18:12:13 +0300

fix line drawing for line(50,50,23,22);

Diffstat:
Mgbdk-lib/examples/gb/filltest/filltest.c11+++++++++++
Mgbdk-lib/libc/gb/drawing.s27+++++++++++++++++++--------
2 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/gbdk-lib/examples/gb/filltest/filltest.c b/gbdk-lib/examples/gb/filltest/filltest.c @@ -4,6 +4,14 @@ #include <gb/gb.h> #include <gb/drawing.h> +void linetest(UBYTE x, UBYTE y, UBYTE w) { + color(DKGREY,WHITE,SOLID); + for (int i = -w; i <= w; i++) line(x,y,x+i,y-w); + for (int i = -w; i <= w; i++) line(x,y,x+w,y+i); + for (int i = -w; i <= w; i++) line(x,y,x+i,y+w); + for (int i = -w; i <= w; i++) line(x,y,x-w,y+i); +} + void main(void) { UBYTE a,b,c,d,e; @@ -34,6 +42,9 @@ void main(void) box(0,130,40,143,M_NOFILL); box(50,130,90,143,M_FILL); + + linetest(130, 100, 20); + /* Scroll the screen using the hardest method imaginable :) */ for (c=0; c<=143; c++) { for (b=0; b<=142; b++) { diff --git a/gbdk-lib/libc/gb/drawing.s b/gbdk-lib/libc/gb/drawing.s @@ -33,6 +33,7 @@ .area _DRAW_HEADER (ABS) .org 0x70 +.drawing_bits_tbl:: .byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01 .byte 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 @@ -704,6 +705,7 @@ swap$: JR NC,s1$ CPL INC A + s1$: LD (.delta_y),A LD H,A @@ -712,6 +714,7 @@ s1$: LD (.delta_y),A JR NC,s2$ CPL INC A + s2$: LD (.delta_x),A SUB H @@ -823,7 +826,7 @@ dx1$: LD A,B AND #7 - ADD #0x70 ; Table of bits is located at 0x0070 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 LD C,A LD B,#0x00 LD A,(BC) ; Get start bit @@ -934,7 +937,7 @@ nadj$: AND #7 ;just look at bottom 3 bits JR Z,2$ PUSH HL - ADD #0x70 ;Table of bits is located at 0x0070 + ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070 LD L,A LD H,#0x00 LD C,(HL) @@ -1014,8 +1017,16 @@ y2$: SUB E JR Z,y2a$ LD A,#0x00 - JR NC,y2a$ - LD A,#0xFF + +; JR NC,y2a$ ; old code; fix draw to up-left below +; LD A,#0xFF + + LD L,A ; invert delta if x1 less than x2 + LD A,B + SUB D + LD A,L + JR C,y2a$ + CPL y2a$: LD B,D @@ -1113,7 +1124,7 @@ dy1$: LD A,B AND #7 - ADD #0x70 ; Table of bits is located at 0x0070 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 LD C,A LD B,#0x00 LD A,(BC) ; Get start bit @@ -1190,7 +1201,7 @@ nchgy$: LD A,B ;check X AND #7 ;just look at bottom 3 bits PUSH HL - ADD #0x70 ;Table of bits is located at 0x0070 + ADD #<.drawing_bits_tbl ;Table of bits is located at 0x0070 LD L,A LD H,#0x00 LD A,(HL) ;Get mask bit @@ -1233,7 +1244,7 @@ nchgy$: LD A,B AND #7 - ADD #0x70 ; Table of bits is located at 0x0070 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 LD C,A LD B,#0x00 LD A,(BC) @@ -1412,7 +1423,7 @@ nchgy$: LD A,B AND #7 - ADD #0x70 ; Table of bits is located at 0x0070 + ADD #<.drawing_bits_tbl ; Table of bits is located at 0x0070 LD C,A LD B,#0x00 LD A,(BC)

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