Skip to content

Commit 1529880

Browse files
committed
build and simulator fixes
1 parent 3d8fa19 commit 1529880

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

simulator/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ uint32_t ticksForNextKeyDown = 0;
5252

5353
bool handle_events()
5454
{
55-
loop();
55+
if (sleepMillisRemain > 0)
56+
{
57+
sleepMillisRemain--;
58+
}
59+
else
60+
{
61+
loop();
62+
}
5663

5764
SDL_Event event;
5865
SDL_PollEvent(&event);
@@ -94,14 +101,15 @@ bool handle_events()
94101
break;
95102
case SDLK_v:
96103
keysState |= 0x8;
104+
sleepMillisRemain = 0;
97105
break;
98106
}
99107

100108
}
101109
}
102110

103111
redraw();
104-
SDL_Delay(k_30_fpsSleepMs);
112+
SDL_Delay(1);
105113
return true;
106114
}
107115

simulator/pawos.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <chrono>
55

6+
int32_t sleepMillisRemain = 0;
7+
68
PetDisplay display(nullptr, 0, DISP_WIDTH, DISP_HEIGHT);
79

810
// used by usb and button interrupts to keep the device awake when in use
@@ -98,19 +100,13 @@ void loop(void)
98100
g::g_keyReleased = prevKeysState & ~(keysState);
99101
g::g_keyHeld = prevKeysState & keysState;
100102

101-
uint32_t t1 = millis();
102103
GameState *nextState = currentState->update();
103-
uint32_t d1 = millis() - t1;
104-
peakUpdateTime = (d1 > peakUpdateTime) ? d1 : peakUpdateTime;
105104

106105
if (nextState != currentState)
107106
{
108107
delete currentState;
109108
currentState = nextState;
110109

111-
peakDrawTime = 0;
112-
peakUpdateTime = 0;
113-
114110
switch (nextState->tick)
115111
{
116112
case k_tickTime30:
@@ -130,7 +126,6 @@ void loop(void)
130126
intBat = Util::batteryLevel();
131127
}
132128

133-
t1 = millis();
134129
if (currentState->redraw)
135130
{
136131
display.fillDisplayBuffer();
@@ -152,8 +147,6 @@ void loop(void)
152147
{
153148
dirtyFrameBuffer = false;
154149

155-
d1 = millis() - t1;
156-
peakDrawTime = (d1 > peakDrawTime) ? d1 : peakDrawTime;
157150
display.refresh();
158151
}
159152
}

simulator/pawos.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
#include <../../src/global.h>
1212
#include <../../src/states/gamestate.h>
1313

14+
#include <SDL.h>
15+
#include <SDL_rect.h>
1416

1517
void init();
1618
void loop(void);
1719

1820
extern PetDisplay display;
1921
extern uint8_t keysState;
22+
extern int32_t sleepMillisRemain;
2023

2124
class WatchdogSAMD {
2225
public:
@@ -36,7 +39,9 @@ class WatchdogSAMD {
3639
WATCHDOG_TIMER_128_S = 0xB
3740
};
3841

39-
void sleep(WatchdogSAMD::PawPet_WatchDog_Times m) {}
42+
void sleep(WatchdogSAMD::PawPet_WatchDog_Times m) {
43+
sleepMillisRemain = 64000;
44+
}
4045
};
4146

4247
#endif

tools/win/build.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ $projectRoot="$PSScriptRoot\..\.."
1212
$projectTools="$PSScriptRoot\..\..\tools"
1313

1414
$cmakePath = 'C:\Program` Files\CMake\bin\cmake.exe'
15-
$emsdkPath = "C:\Users\nano\dev\emsdk"
15+
16+
$ninjaPath = "$env:USERPROFILE\dev\ninja.exe"
17+
$emsdkPath = "$env:USERPROFILE\emsdk"
1618

1719
$buildargs = @()
1820

@@ -88,7 +90,7 @@ if ($webSimulator)
8890
$Env:SDL2_DIR="$projectRoot\simulator\SDL2"
8991

9092
Invoke-Expression "$cmakePath $cmakeArgs"
91-
Invoke-Expression "ninja.exe -C $buildFolder\html"
93+
Invoke-Expression "$ninjaPath -C $buildFolder\html"
9294
}
9395

9496
if ($simulator)
@@ -101,7 +103,7 @@ if ($simulator)
101103
New-Item -Path "$buildFolder\win32" -ItemType Directory -Force -ErrorAction Ignore
102104

103105
$msvc = & 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' -property installationpath -version 16.0
104-
106+
Write-Host $msvc
105107
Import-Module (Join-Path $msvc "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
106108

107109
Enter-VsDevShell -VsInstallPath $msvc -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'
@@ -117,7 +119,7 @@ if ($simulator)
117119

118120
# Start-Process -FilePath "$cmakePath" -ArgumentList $cmakeArgs -NoNewWindow -Wait
119121
Invoke-Expression "$cmakePath $cmakeArgs"
120-
Invoke-Expression "ninja.exe -C $buildFolder\win32"
122+
Invoke-Expression "$ninjaPath -C $buildFolder\win32"
121123
}
122124

123125

0 commit comments

Comments
 (0)