cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

lcd_isr_wobble.c (596B)


      1#include <gb/gb.h>
      2#include <gb/isr.h>
      3
      4const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
      5const uint8_t * scanline_offsets = scanline_offsets_tbl;
      6
      7void scanline_isr() CRITICAL INTERRUPT {
      8    SCX_REG = scanline_offsets[LY_REG & (uint8_t)7];
      9}
     10ISR_VECTOR(VECTOR_STAT, scanline_isr)
     11
     12void main() {
     13    LCDC_REG |= LCDCF_BG8000;
     14    STAT_REG = STATF_MODE00;
     15    set_interrupts(VBL_IFLAG | LCD_IFLAG);
     16    SHOW_BKG;
     17
     18    while (TRUE) {
     19        wait_vbl_done();        
     20        scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u];
     21    }
     22}