git.y1.nz

gbdk-2020

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

commit 67335e5e285cccceb590626e10e707c2dc5dec9d
parent 0deca17c17229fd8716e49f1ffb0aba3d99ff803
Author: Toxa <untoxa@mail.ru>
Date:   Mon, 21 Dec 2020 15:49:34 +0300

linking of stdio fixed

Diffstat:
Mgbdk-lib/libc/gb/Makefile8+++++---
Agbdk-lib/libc/gb/color.s24++++++++++++++++++++++++
Mgbdk-lib/libc/gb/drawing.s46+++++-----------------------------------------
Agbdk-lib/libc/gb/drawing_isr.s23+++++++++++++++++++++++
Rgbdk-lib/libc/gb/ibmfixed.s -> gbdk-lib/libc/gb/f_ibm_full.s0
Mgbdk-lib/libc/gb/f_ibm_sh.s9+++++++++
Mgbdk-lib/libc/gb/font.s12++++++------
7 files changed, 72 insertions(+), 50 deletions(-)

diff --git a/gbdk-lib/libc/gb/Makefile b/gbdk-lib/libc/gb/Makefile @@ -7,10 +7,12 @@ PORT = gbz80 CSRC = digits.c gprint.c gprintf.c gprintln.c gprintn.c -ASSRC = cgb.s cpy_data.s drawing.s f_ibm_sh.s \ - f_italic.s f_min.s f_spect.s get_bk_t.s get_data.s \ +ASSRC = cgb.s cpy_data.s \ + drawing.s drawing_isr.s color.s \ + f_ibm_full.s f_ibm_sh.s f_italic.s f_min.s f_spect.s \ + get_bk_t.s get_data.s \ get_wi_t.s get_xy_t.s global.s \ - hiramcpy.s ibmfixed.s init_tt.s input.s \ + hiramcpy.s init_tt.s input.s \ pad.s sample.s \ serial.s set_bk_t.s \ set_data.s set_prop.s set_spr.s set_wi_t.s set_xy_t.s \ diff --git a/gbdk-lib/libc/gb/color.s b/gbdk-lib/libc/gb/color.s @@ -0,0 +1,24 @@ + .include "global.s" + + ;; Data + .area _BSS + ;; Foreground drawing colour +.fg_colour:: + .ds 1 + ;; Background drawing colour +.bg_colour:: + .ds 1 + ;; Drawing mode (.SOILD etc) +.draw_mode:: + .ds 1 + + .area _BASE +_color:: ; Banked + LDA HL,.BANKOV(SP) ; Skip return address and registers + LD A,(HL+) ; A = Foreground + LD (.fg_colour),a + LD A,(HL+) + LD (.bg_colour),a + LD A,(HL) + LD (.draw_mode),a + RET diff --git a/gbdk-lib/libc/gb/drawing.s b/gbdk-lib/libc/gb/drawing.s @@ -10,6 +10,9 @@ .globl .init_vram .globl .copy_vram + + .globl .drawing_lcd, .drawing_vbl + .globl .bg_colour, .fg_colour, .draw_mode .M_SOLID = 0x00 .M_OR = 0x01 @@ -40,15 +43,6 @@ ;; Data .area _BSS - ;; Foreground drawing colour -.fg_colour:: - .ds 1 - ;; Background drawing colour -.bg_colour:: - .ds 1 - ;; Drawing mode (.SOILD etc) -.draw_mode: - .ds 1 ;; Fill style .style: .ds 0x01 @@ -93,9 +87,9 @@ CALL .init_vram ; Init the charset at 0x8000 ;; Install interrupt routines - LD BC,#.vbl + LD BC,#.drawing_vbl CALL .add_VBL - LD BC,#.lcd + LD BC,#.drawing_lcd CALL .add_LCD LD A,#72 ; Set line at which LCD interrupt occurs @@ -151,26 +145,6 @@ RET -.vbl:: - LDH A,(.LCDC) - OR #0b00010000 ; Set BG Chr to 0x8000 - LDH (.LCDC),A - - LD A,#72 ; Set line at which LCD interrupt occurs - LDH (.LYC),A - - RET - - ;; Is the STAT check required, as we are already in the HBL? -.lcd:: - WAIT_STAT - - LDH A,(.LCDC) - AND #0b11101111 ; Set BG Chr to 0x8800 - LDH (.LCDC),A - - RET - ;; Draw a full-screen image at (BC) .draw_image:: LD HL,#0x8000+0x10*0x10 @@ -1622,16 +1596,6 @@ _getpix:: ; Banked POP BC RET -_color:: ; Banked - LDA HL,.BANKOV(SP) ; Skip return address and registers - LD A,(HL+) ; A = Foreground - LD (.fg_colour),a - LD A,(HL+) - LD (.bg_colour),a - LD A,(HL) - LD (.draw_mode),a - RET - _circle:: ; Banked PUSH BC diff --git a/gbdk-lib/libc/gb/drawing_isr.s b/gbdk-lib/libc/gb/drawing_isr.s @@ -0,0 +1,23 @@ + .include "global.s" + + .area _BASE + +.drawing_vbl:: + LDH A,(.LCDC) + OR #0b00010000 ; Set BG Chr to 0x8000 + LDH (.LCDC),A + + LD A,#72 ; Set line at which LCD interrupt occurs + LDH (.LYC),A + + RET + + ;; Is the STAT check required, as we are already in the HBL? +.drawing_lcd:: + WAIT_STAT + + LDH A,(.LCDC) + AND #0b11101111 ; Set BG Chr to 0x8800 + LDH (.LCDC),A + + RET diff --git a/gbdk-lib/libc/gb/ibmfixed.s b/gbdk-lib/libc/gb/f_ibm_full.s diff --git a/gbdk-lib/libc/gb/f_ibm_sh.s b/gbdk-lib/libc/gb/f_ibm_sh.s @@ -2,6 +2,15 @@ ;; BANKED: checked, imperfect .area _BASE + .globl font_load + ;; Perform tricks with banking to shift this font out of + ;; bank 0. Doesnt currently work as the encoding table + ;; must always be visible. +_font_load_ibm:: ; Banked + ld hl,#_font_ibm + call font_load + ret + ; 898 bytes giving ' '-'0'-'@'-'A'-'Z'-'???'-'a'-'z'-127 _font_ibm:: .byte 1+4 ; 128 character encoding diff --git a/gbdk-lib/libc/gb/font.s b/gbdk-lib/libc/gb/font.s @@ -364,8 +364,8 @@ font_set:: xor a ld (font_first_free_tile),a - .globl _font_load_ibm_fixed - call _font_load_ibm_fixed + .globl _font_load_ibm + call _font_load_ibm 3$: pop af push bc @@ -650,8 +650,8 @@ _posy:: ; Banked .area _BASE - .globl .vbl - .globl .lcd + .globl .drawing_vbl + .globl .drawing_lcd .globl .int_0x40 .globl .int_0x48 .globl .remove_int @@ -669,10 +669,10 @@ _posy:: ; Banked CALL .display_off ;; Remove any interrupts setup by the drawing routine - LD BC,#.vbl + LD BC,#.drawing_vbl LD HL,#.int_0x40 CALL .remove_int - LD BC,#.lcd + LD BC,#.drawing_lcd LD HL,#.int_0x48 CALL .remove_int 1$:

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