git.y1.nz

gbdk-2020

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

commit 3872f632c5b53dd171d8766b938d3191a91a6575
parent 2113bc152bb7924630a2ea8733f4f77c89567ef4
Author: Toxa <untoxa@mail.ru>
Date:   Tue,  4 Jan 2022 12:03:18 +0300

gb/isr.h example of raw ISR vector construction

Diffstat:
Agbdk-lib/examples/gb/isr_vector/Makefile17+++++++++++++++++
Agbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c23+++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/gbdk-lib/examples/gb/isr_vector/Makefile b/gbdk-lib/examples/gb/isr_vector/Makefile @@ -0,0 +1,17 @@ +CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j -Wm-yS + +BINS = lcd_isr_wobble.gb + +all: $(BINS) + +compile.bat: Makefile + @echo "REM Automatically generated from Makefile" > compile.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat + +# Compile and link single file in one pass +%.gb: %.c + $(CC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi + diff --git a/gbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c b/gbdk-lib/examples/gb/isr_vector/lcd_isr_wobble.c @@ -0,0 +1,22 @@ +#include <gb/gb.h> +#include <gb/isr.h> + +const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0}; +const uint8_t * scanline_offsets = scanline_offsets_tbl; + +void scanline_isr() CRITICAL INTERRUPT { + SCX_REG = scanline_offsets[LY_REG & (uint8_t)7]; +} +ISR_VECTOR(VECTOR_STAT, scanline_isr) + +void main() { + LCDC_REG |= LCDCF_BG8000; + STAT_REG = STATF_MODE00; + set_interrupts(VBL_IFLAG | LCD_IFLAG); + SHOW_BKG; + + while (TRUE) { + wait_vbl_done(); + scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u]; + } +} +

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