~rabbits/uxn-playdate

d65a61bddebbd051d94c469c7a07fbfe6671a254 — Devine Lu Linvega 23 days ago 61cc190
Fixed issue where time was created after init eval
3 files changed, 22 insertions(+), 8 deletions(-)

M Source/main.lua
M build.sh
M src/main.c
M Source/main.lua => Source/main.lua +9 -1
@@ 23,7 23,7 @@ local function mouse(dt)
	)
end

function playdate.update()
function update_time()
	local t = playdate.getTime()
	local days_in_month = { 31, t.year % 4 == 0 and 29 or 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
	local day_in_year = t.day - 1


@@ 41,6 41,10 @@ function playdate.update()
		day_in_year % 256,
		playdate.getGMTTime().hour ~= t.hour and 1 or 0
	)
end

function playdate.update()
	update_time()
	local frames_now
	local new_time = playdate.getCurrentTimeMilliseconds()
	if not frames then


@@ 80,3 84,7 @@ menu:addOptionsMenuItem(
		mouse_active = s == 'enabled'
	end
)

varvaraReset()
update_time()
varvaraInit()

M build.sh => build.sh +1 -2
@@ 3,12 3,11 @@
export PLAYDATE_SDK_PATH="/home/neauoire/Documents/playdate/PlaydateSDK-1.13.0"
TARGET="etc/wireworld.tal"


rm -rf bin
mkdir bin

# uxnasm $TARGET etc/boot.rom
cp ~/Git/oquonie/bin/result.rom etc/boot.rom
# cp ~/roms/catclock.rom etc/boot.rom 

clang-format -i src/main.c
clang-format -i src/devices/ppu.c

M src/main.c => src/main.c +12 -5
@@ 199,8 199,6 @@ emu_start(Uxn *u, char *filename)
		return emu_error("Boot", "Failed to start uxn.");
	if(!system_load(u, filename))
		return emu_error("Load", "Failed");
	if(!uxn_eval(u, PAGE_PROGRAM))
		return emu_error("Boot", "Failed to start rom.");
	return 1;
}



@@ 225,10 223,20 @@ apu_init(void)
/* Lua */

static int
eval_init(lua_State *L)
{
	if(!uxn_eval(&u, PAGE_PROGRAM))
		return emu_error("Boot", "Failed to start rom.");
	return 0;
}

static int
menu_reset(lua_State *L)
{
	if(!emu_start(&u, BOOT_ROM_FILENAME))
		pd->system->error("Failed to reset Uxn.");
	if(!uxn_eval(&u, PAGE_PROGRAM))
		return emu_error("Boot", "Failed to start rom.");
	return 0;
}



@@ 297,7 305,8 @@ static struct lua_function_pair fns[] = {
	{update_controller, "varvaraController"},
	{update_mouse, "varvaraMouse"},
	{update_screen, "varvaraScreen"},
	{menu_reset, "varvaraReset"}};
	{menu_reset, "varvaraReset"},
	{eval_init, "varvaraInit"}};

int
eventHandler(PlaydateAPI *playdate, PDSystemEvent event, uint32_t arg)


@@ 314,8 323,6 @@ eventHandler(PlaydateAPI *playdate, PDSystemEvent event, uint32_t arg)
			return emu_error("APU", "Start failed.");
		if(!ppu_init(&ppu, (uint32_t *)pd->graphics->getFrame()))
			return emu_error("PPU", "Start failed.");
		if(!emu_start(&u, BOOT_ROM_FILENAME))
			return emu_error("Emulator", "Start failed.");
	} else if(event == kEventInitLua) {
		const char *err;
		int i;