cscg22-gearboy

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

lcd_isr_wobble.c (678B)


      1#include <gb/gb.h>
      2#include <stdint.h>
      3#include <stdio.h>
      4
      5#include <gb/emu_debug.h>
      6
      7const uint8_t scanline_offsets_tbl[] = {0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0};
      8const uint8_t * scanline_offsets = scanline_offsets_tbl;
      9
     10void scanline_isr() {
     11    SCX_REG = scanline_offsets[LY_REG & (uint8_t)7];
     12}
     13
     14
     15void main() {
     16    printf("This is\na wobble\ntest\nfor DMG\n|\n|\n|\n|\n|");
     17    
     18    CRITICAL {
     19        STAT_REG = STATF_MODE01 | STATF_MODE00;
     20        add_LCD(scanline_isr);
     21    }
     22    set_interrupts(VBL_IFLAG | LCD_IFLAG);
     23
     24    while (1) {
     25        wait_vbl_done();        
     26        scanline_offsets = &scanline_offsets_tbl[(uint8_t)(sys_time >> 2) & 0x07u];
     27    }
     28}