- switch(badge_event_type(event)) {
- case BADGE_EVENT_USER_INPUT: {
- buttons = badge_event_current_input_state();
- break;
- }
- case BADGE_EVENT_GAME_TICK: {
- badge_sprite const sp = { 4, 4, (uint8_t const *) "\xff\xff" };
- badge_framebuffer fb = { { { 0x80 } } };
-
- SSP_SSP0CR0 =
- SSP_SSP0CR0_DSS_8BIT // Data size = 8-bit
- | SSP_SSP0CR0_FRF_SPI // Frame format = SPI
- | SSP_SSP0CR0_SCR_8;
-
- gpioSetValue(RB_SPI_CS_DF, 0);
-
- uint8_t st;
- sspSend(0, "\x05", 1);
- sspReceive(0, &st, 1);
-
- gpioSetValue(RB_SPI_CS_DF, 1);
-
- fb.data[0][1] = st;
- /*
- for(int i = 0; i < 9 * 96; ++i) {
- fb.data[0][i] = 0xbb;
- }
- */
-
- if(buttons & BADGE_EVENT_KEY_UP) { badge_framebuffer_blt(&fb, 30, 10, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_DOWN) { badge_framebuffer_blt(&fb, 30, 50, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_LEFT) { badge_framebuffer_blt(&fb, 10, 30, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_RIGHT) { badge_framebuffer_blt(&fb, 50, 30, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_CENTER){ badge_framebuffer_blt(&fb, 30, 30, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_BTN_A) { badge_framebuffer_blt(&fb, 70, 10, &sp, 0); }
- if(buttons & BADGE_EVENT_KEY_BTN_B) { badge_framebuffer_blt(&fb, 70, 50, &sp, 0); }
-
- badge_framebuffer_flush(&fb);
- break;
- }
- }