git.y1.nz

gbdk-2020

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

commit 38394d4e5073d7e6e6968531bd766a456beebdd0
parent 06dee0fbad8e615a548db28a2dc7028a3f538eeb
Author: toxa <untoxa@mail.ru>
Date:   Wed, 28 Oct 2020 13:50:11 +0300

changed the default behaviour of LCD interrupt, now it waits for compatible mode by default as others, it was confusing to have it different.

Diffstat:
Mgbdk-lib/libc/gb/crt0.s62++++++++++++++++++++++++++++++--------------------------------
Mgbdk-lib/libc/gb/global.s8++++++++
Mgbdk-lib/libc/gb/lcd.s4++++
Mgbdk-lib/libc/gb/set_1bit_data.s6------
Mgbdk-lib/libc/gb/set_data.s6------
5 files changed, 42 insertions(+), 44 deletions(-)

diff --git a/gbdk-lib/libc/gb/crt0.s b/gbdk-lib/libc/gb/crt0.s @@ -81,9 +81,7 @@ _wait_int_handler:: POP HL ;; we return at least at the beginning of mode 2 -3$: LDH A,(.STAT) - AND #0x02 - JR NZ, 3$ + WAIT_STAT POP AF RETI @@ -266,6 +264,35 @@ _exit:: NOP JR 99$ ; Wait forever +_enable_interrupts:: + EI + RET + +_disable_interrupts:: + DI + RET + +_set_interrupts:: + DI + LDA HL,2(SP) ; Skip return address + XOR A + LDH (.IF),A ; Clear pending interrupts + LD A,(HL) + EI ; Enable interrupts + LDH (.IE),A ; interrupts are still disabled here + RET + + ;; Copy OAM data to OAM RAM +.start_refresh_OAM: + LD A,#>_shadow_OAM + LDH (.DMA),A ; Put A into DMA registers + LD A,#0x28 ; We need to wait 160 ns +1$: + DEC A + JR NZ,1$ + RET +.end_refresh_OAM: + .org .MODE_TABLE ;; Jump table for modes RET @@ -422,35 +449,6 @@ _display_off:: LDH (.LCDC),A ; Turn off screen RET - ;; Copy OAM data to OAM RAM -.start_refresh_OAM: - LD A,#>_shadow_OAM - LDH (.DMA),A ; Put A into DMA registers - LD A,#0x28 ; We need to wait 160 ns -1$: - DEC A - JR NZ,1$ - RET -.end_refresh_OAM: - -_enable_interrupts:: - EI - RET - -_disable_interrupts:: - DI - RET - -_set_interrupts:: - DI - LDA HL,2(SP) ; Skip return address - XOR A - LDH (.IF),A ; Clear pending interrupts - LD A,(HL) - EI ; Enable interrupts - LDH (.IE),A ; interrupts are still disabled here - RET - _remove_VBL:: PUSH BC LDA HL,4(SP) ; Skip return address and registers diff --git a/gbdk-lib/libc/gb/global.s b/gbdk-lib/libc/gb/global.s @@ -150,3 +150,11 @@ ;; Main user routine .globl _main + + ;; Macro definitions + +.macro WAIT_STAT ?lbl +lbl: ldh a, (.STAT) + and #2 ; Check if in LCD modes 0 or 1 + jr nz, lbl +.endm diff --git a/gbdk-lib/libc/gb/lcd.s b/gbdk-lib/libc/gb/lcd.s @@ -47,6 +47,10 @@ POP DE POP BC POP HL + + ;; we return at least at the beginning of mode 2 + WAIT_STAT + POP AF RETI diff --git a/gbdk-lib/libc/gb/set_1bit_data.s b/gbdk-lib/libc/gb/set_1bit_data.s @@ -4,12 +4,6 @@ .area _BASE -.macro WAIT_STAT ?lbl -lbl: ldh a, (.STAT) - and #2 ; Check if in LCD modes 0 or 1 - jr nz, lbl -.endm - _set_bkg_1bit_data:: _set_win_1bit_data:: ld d, #0x90 diff --git a/gbdk-lib/libc/gb/set_data.s b/gbdk-lib/libc/gb/set_data.s @@ -5,12 +5,6 @@ ;; BANKED: checked .area _BASE -.macro WAIT_STAT ?lbl -lbl: ldh a, (.STAT) - and #2 ; Check if in LCD modes 0 or 1 - jr nz, lbl -.endm - _set_bkg_data:: _set_win_data:: ld d, #0x90

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