@@ 1,8 1,8 @@
#include "pd_api.h"
#include "uxn.h"
-#include "devices/apu.h"
#include "devices/ppu.h"
-#include <time.h>
+
+#define BOOT_ROM_FILENAME "boot.rom"
static PlaydateAPI *pd = NULL;
@@ 192,31 192,28 @@ emu_start(void)
return 1;
}
-/* Misc */
+/* Lua */
-void
-read_buttons(void)
+
+static int
+reset(Uxn *u, char *filepath)
{
- PDButtons pushed, current, released;
- pd->system->getButtonState(¤t, &pushed, &released);
- if(pushed || released) {
- Uint8 state = 0x00;
- state |= !!(current & 0x20);
- state |= !!(current & 0x10) << 0x1;
- state |= !!(current & 0x40) << 0x2;
- state |= !!(current & 0x80) << 0x3;
- state |= !!(current & 0x04) << 0x4;
- state |= !!(current & 0x08) << 0x5;
- state |= !!(current & 0x01) << 0x6;
- state |= !!(current & 0x02) << 0x7;
- u.dev[0x82] = state;
- uxn_eval(&u, GETVEC(&u.dev[0x80]));
- }
+ free(u->ram);
+ if(!uxn_boot(u, (Uint8 *)calloc(0x10300, sizeof(Uint8)), emu_dei, emu_deo))
+ return emu_error("Boot", "Failed");
+ memset(&ppu, 0, sizeof(ppu));
+ /* memset(&apu, 0, sizeof(apu)); */
+ if(!emu_load(rom))
+ return 0;
+ uxn_eval(u, PAGE_PROGRAM);
+ return 1;
}
static int
menu_reset(lua_State *L)
{
+ if(!reset(&u, BOOT_ROM_FILENAME))
+ pd->system->error("Failed to reset Uxn.");
return 0;
}