void main() { INT8 i; UINT8 input; UFIX16 amount; amount.U16 = 0x0000U; set_bkg_data(0, 42, roadTiles); set_bkg_tiles(0, 0, 32, 32, roadGrid); offsetIndex = 0; for (i = 0; i < 80; i++) { roadOffset[i] = 0; } SPRITES_8x8; SHOW_SPRITES; SHOW_BKG; HIDE_WIN; LYC_REG = 0x07U; STAT_REG = 0x20U; set_interrupts(VBL_IFLAG | LCD_IFLAG); add_LCD(HBLANK); add_VBL(VBLANK); enable_interrupts(); frameReady = 0; while (1) { if (frameReady == 0) { input = joypad(); if (input & J_LEFT) { amount.U8.intp -= 10; } if (input & J_RIGHT) { amount.U8.intp += 10; } MoveHr(&amount); frameReady = 1; } } }
void main() { /* Ensure mutual exclusion (not really necessary in this example)... */ disable_interrupts(); vbl_cnt = tim_cnt = 0; add_VBL(vbl); add_TIM(tim); enable_interrupts(); /* Set TMA to divide clock by 0x100 */ TMA_REG = 0x00U; /* Set clock to 4096 Hertz */ TAC_REG = 0x04U; /* Handle VBL and TIM interrupts */ set_interrupts(VBL_IFLAG | TIM_IFLAG); while(1) { print_counter(); delay(1000UL); } }