git.y1.nz

gbdk-2020

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

commit 3410b6183346136382d4faee83e1c1c8a7d978cb
parent c549acdba1797bc3f787af619222065ceb06c347
Author: toxa <untoxa@mail.ru>
Date:   Mon, 26 Oct 2020 13:36:20 +0300

fix .remove_int issue, it failed to remove 0x00YY value from [0xXX00, 0x00YY, 0] list; reduced crt0 size: some code was put out into the library

Diffstat:
Mgbdk-lib/libc/gb/Makefile1+
Agbdk-lib/libc/gb/clock.s16++++++++++++++++
Mgbdk-lib/libc/gb/crt0.s91+++++++++++++++++++++++--------------------------------------------------------
Mgbdk-lib/libc/gb/global.s2+-
Agbdk-lib/libc/gb/mode.s30++++++++++++++++++++++++++++++
5 files changed, 74 insertions(+), 66 deletions(-)

diff --git a/gbdk-lib/libc/gb/Makefile b/gbdk-lib/libc/gb/Makefile @@ -24,6 +24,7 @@ ASSRC = cgb.s cpy_data.s drawing.s f_ibm_sh.s \ ___sdcc_bcall_ehl.s ___sdcc_bcall.s \ mv_spr.s \ pad_ex.s \ + mode.s clock.s \ crt0.s ifeq ($(ASM),asxxxx) diff --git a/gbdk-lib/libc/gb/clock.s b/gbdk-lib/libc/gb/clock.s @@ -0,0 +1,16 @@ + .include "global.s" + + .title "System clock" + .module Clock + + ;; BANKED: checked + .area _HOME + +_clock:: + LD HL,#.sys_time + DI + LD A,(HL+) + EI ;; Interrupts are disabled for the next instruction... + LD D,(HL) + LD E,A + RET diff --git a/gbdk-lib/libc/gb/crt0.s b/gbdk-lib/libc/gb/crt0.s @@ -77,6 +77,20 @@ POP AF RETI + ;; VBlank default interrupt routine +.vbl: + LD HL,#.sys_time + INC (HL) + JR NZ,2$ + INC HL + INC (HL) +2$: + CALL .refresh_OAM + + LD A,#0x01 + LD (.vbl_done),A + RET + ;; GameBoy Header ;; DO NOT CHANGE... @@ -302,27 +316,11 @@ gsinit:: ret .area _HOME - ;; Call the initialization function for the mode specified in HL -.set_mode:: - LD A,L - LD (.mode),A - - ;; AND to get rid of the extra flags - AND #0x03 - LD L,A - LD BC,#.MODE_TABLE - SLA L ; Multiply mode by 4 - SLA L - ADD HL,BC - JP (HL) ; Jump to initialization routine - - ;; Add interrupt routine in BC to the interrupt list + + ;; Remove interrupt routine in BC from the VBL interrupt list + ;; falldown to .remove_int .remove_VBL:: LD HL,#.int_0x40 - JP .remove_int -.add_VBL:: - LD HL,#.int_0x40 - JP .add_int ;; Remove interrupt BC from interrupt list HL if it exists ;; Abort if a 0000 is found (end of list) @@ -332,6 +330,7 @@ gsinit:: LD A,(HL+) LD E,A LD D,(HL) + INC HL OR D RET Z ; No interrupt found @@ -342,16 +341,12 @@ gsinit:: CP B JR NZ,1$ - XOR A - LD (HL-),A - LD (HL),A - - ;; Now do a memcpy from here until the end of the list LD D,H LD E,L - INC HL - INC HL + DEC DE + DEC DE + ;; Now do a memcpy from here until the end of the list 2$: LD A,(HL+) LD (DE),A @@ -364,6 +359,11 @@ gsinit:: RET Z JR 2$ + ;; Add interrupt routine in BC to the VBL interrupt list + ;; falldown to .add_int +.add_VBL:: + LD HL,#.int_0x40 + ;; Add interrupt routine in BC to the interrupt list in HL .add_int:: 1$: @@ -378,21 +378,6 @@ gsinit:: LD (HL),C RET - - ;; VBlank interrupt -.vbl: - LD HL,#.sys_time - INC (HL) - JR NZ,2$ - INC HL - INC (HL) -2$: - CALL .refresh_OAM - - LD A,#0x01 - LD (.vbl_done),A - RET - ;; Wait for VBL interrupt to be finished .wait_vbl_done:: _wait_vbl_done:: @@ -446,17 +431,6 @@ _display_off:: JR NZ,1$ RET .end_refresh_OAM: - -_mode:: - LDA HL,2(SP) ; Skip return address - LD L,(HL) - LD H,#0x00 - JP .set_mode - -_get_mode:: - LD HL,#.mode - LD E,(HL) - RET _enable_interrupts:: EI @@ -501,18 +475,5 @@ _add_VBL:: POP BC RET -_clock:: - LD HL,#.sys_time - DI - LD A,(HL+) - EI - ;; Interrupts are disabled for the next instruction... - LD D,(HL) - LD E,A - RET - -__printTStates:: - RET - .area _HEAP _malloc_heap_start:: diff --git a/gbdk-lib/libc/gb/global.s b/gbdk-lib/libc/gb/global.s @@ -128,7 +128,7 @@ .globl __cpu ;; Global routines - .globl .set_mode +; .globl .set_mode ;; don't link mode.o by default .globl .reset diff --git a/gbdk-lib/libc/gb/mode.s b/gbdk-lib/libc/gb/mode.s @@ -0,0 +1,30 @@ + .include "global.s" + + .title "screen modes" + .module Modes + + ;; BANKED: checked + .area _HOME + +_mode:: + LDA HL,2(SP) ; Skip return address + LD L,(HL) + LD H,#0x00 + +.set_mode:: + LD A,L + LD (.mode),A + + ;; AND to get rid of the extra flags + AND #0x03 + LD L,A + LD BC,#.MODE_TABLE + SLA L ; Multiply mode by 4 + SLA L + ADD HL,BC + JP (HL) ; Jump to initialization routine + +_get_mode:: + LD HL,#.mode + LD E,(HL) + RET

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