#include "init.h"
#include "ui/display.h"
-#include "ui/sprite.h"
#include "ui/event.h"
#include "ui/font.h"
+#include "ui/menu.h"
+#include "ui/sprite.h"
#include "util/util.h"
#include "jumpnrun/jumpnrun.h"
#endif
-/**************************************************************************/
-/*!
- Main program entry point. After reset, normal code execution will
- begin here.
+void usbmode(void) {
+ badge_framebuffer fb = { { { 0 } } };
+
+ badge_framebuffer_render_text(&fb, 23, 30, "USB-Modus");
+/*
+ badge_framebuffer_render_number(&fb, 23, 50, sizeof(jumpnrun_tile));
+ badge_framebuffer_render_number(&fb, 33, 50, sizeof(jumpnrun_item));
+ badge_framebuffer_render_number(&fb, 48, 50, sizeof(jumpnrun_enemy));
*/
-/**************************************************************************/
+ badge_framebuffer_flush(&fb);
+ usbMSCInit();
+ for(;;);
+}
+
+void scrolltest(void) {
+ char menu_buf[][15] = {
+ "foo",
+ "bar",
+ "baz",
+ "qux",
+ "foo",
+ "bar",
+ "baz",
+ "qux",
+ "foo",
+ "bar",
+ "baz",
+ "qux",
+ "foo",
+ "bar",
+ "baz",
+ "qux",
+ };
+
+ char const * menu_index[] = {
+ menu_buf[0],
+ menu_buf[1],
+ menu_buf[2],
+ menu_buf[3],
+ menu_buf[4],
+ menu_buf[5],
+ menu_buf[6],
+ menu_buf[7],
+ menu_buf[8],
+ menu_buf[9],
+ menu_buf[10],
+ menu_buf[11],
+ menu_buf[12],
+ menu_buf[13],
+ menu_buf[14],
+ menu_buf[15]
+ };
+
+ badge_scroll_text(menu_index, 16);
+}
+
int main(void)
{
- // Configure cpu and mandatory peripherals
- //systemInit();
-
cpuInit();
systickInit(CFG_SYSTICK_DELAY_IN_MS);
badge_init();
#endif
- /*
- nrf_init();
-
- for(uint8_t i = 1; ; ++i) {
- badge_framebuffer fb = { { { 0 } } };
-
- fb.data[2][86] = 0xff;
- fb.data[3][87] = nrf_read_reg(R_CONFIG);
- fb.data[4][86] = 0xff;
- for(uint8_t j = 0; j < i; j += 3) {
- fb.data[3][j / 3] = 0xff;
- }
-
- SCB_CLKOUTCLKDIV = i;
- badge_framebuffer_flush(&fb);
- systickDelay(200);
- }
- */
-
FATFS fs;
f_mount(0, &fs);
- {
- badge_framebuffer fb = { { { 0 } } };
-
- fb.data[0][0] = badge_framebuffer_render_text(&fb, 2, 10, "foobar");
-
- badge_framebuffer_flush(&fb);
- }
-
if(badge_input_raw() & BADGE_EVENT_KEY_DOWN) {
- usbMSCInit();
- for(;;);
+ usbmode();
}
badge_event_start();
- for(;;) {
- if(JUMPNRUN_ERROR == jumpnrun_play("smb.lvl")) {
- break;
- }
+ if(badge_input_raw() & BADGE_EVENT_KEY_UP) {
+ scrolltest();
}
- uint8_t buttons = 0;
-
- for(uint8_t i = 0; ; ++i) {
- badge_event_t event = badge_event_wait();
-
- 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 } } };
-
- 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;
- }
- }
- }
+ jumpnrun_play();
+ usbmode();
return 0;
}