File tree Expand file tree Collapse file tree 4 files changed +24
-16
lines changed Expand file tree Collapse file tree 4 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,14 @@ uint32_t ticksForNextKeyDown = 0;
52
52
53
53
bool handle_events ()
54
54
{
55
- loop ();
55
+ if (sleepMillisRemain > 0 )
56
+ {
57
+ sleepMillisRemain--;
58
+ }
59
+ else
60
+ {
61
+ loop ();
62
+ }
56
63
57
64
SDL_Event event;
58
65
SDL_PollEvent (&event);
@@ -94,14 +101,15 @@ bool handle_events()
94
101
break ;
95
102
case SDLK_v:
96
103
keysState |= 0x8 ;
104
+ sleepMillisRemain = 0 ;
97
105
break ;
98
106
}
99
107
100
108
}
101
109
}
102
110
103
111
redraw ();
104
- SDL_Delay (k_30_fpsSleepMs );
112
+ SDL_Delay (1 );
105
113
return true ;
106
114
}
107
115
Original file line number Diff line number Diff line change 3
3
4
4
#include < chrono>
5
5
6
+ int32_t sleepMillisRemain = 0 ;
7
+
6
8
PetDisplay display (nullptr , 0 , DISP_WIDTH, DISP_HEIGHT);
7
9
8
10
// used by usb and button interrupts to keep the device awake when in use
@@ -98,19 +100,13 @@ void loop(void)
98
100
g::g_keyReleased = prevKeysState & ~(keysState);
99
101
g::g_keyHeld = prevKeysState & keysState;
100
102
101
- uint32_t t1 = millis ();
102
103
GameState *nextState = currentState->update ();
103
- uint32_t d1 = millis () - t1;
104
- peakUpdateTime = (d1 > peakUpdateTime) ? d1 : peakUpdateTime;
105
104
106
105
if (nextState != currentState)
107
106
{
108
107
delete currentState;
109
108
currentState = nextState;
110
109
111
- peakDrawTime = 0 ;
112
- peakUpdateTime = 0 ;
113
-
114
110
switch (nextState->tick )
115
111
{
116
112
case k_tickTime30:
@@ -130,7 +126,6 @@ void loop(void)
130
126
intBat = Util::batteryLevel ();
131
127
}
132
128
133
- t1 = millis ();
134
129
if (currentState->redraw )
135
130
{
136
131
display.fillDisplayBuffer ();
@@ -152,8 +147,6 @@ void loop(void)
152
147
{
153
148
dirtyFrameBuffer = false ;
154
149
155
- d1 = millis () - t1;
156
- peakDrawTime = (d1 > peakDrawTime) ? d1 : peakDrawTime;
157
150
display.refresh ();
158
151
}
159
152
}
Original file line number Diff line number Diff line change 11
11
#include < ../../src/global.h>
12
12
#include < ../../src/states/gamestate.h>
13
13
14
+ #include < SDL.h>
15
+ #include < SDL_rect.h>
14
16
15
17
void init ();
16
18
void loop (void );
17
19
18
20
extern PetDisplay display;
19
21
extern uint8_t keysState;
22
+ extern int32_t sleepMillisRemain;
20
23
21
24
class WatchdogSAMD {
22
25
public:
@@ -36,7 +39,9 @@ class WatchdogSAMD {
36
39
WATCHDOG_TIMER_128_S = 0xB
37
40
};
38
41
39
- void sleep (WatchdogSAMD::PawPet_WatchDog_Times m) {}
42
+ void sleep (WatchdogSAMD::PawPet_WatchDog_Times m) {
43
+ sleepMillisRemain = 64000 ;
44
+ }
40
45
};
41
46
42
47
#endif
Original file line number Diff line number Diff line change @@ -12,7 +12,9 @@ $projectRoot="$PSScriptRoot\..\.."
12
12
$projectTools = " $PSScriptRoot \..\..\tools"
13
13
14
14
$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"
16
18
17
19
$buildargs = @ ()
18
20
@@ -88,7 +90,7 @@ if ($webSimulator)
88
90
$Env: SDL2_DIR = " $projectRoot \simulator\SDL2"
89
91
90
92
Invoke-Expression " $cmakePath $cmakeArgs "
91
- Invoke-Expression " ninja.exe -C $buildFolder \html"
93
+ Invoke-Expression " $ninjaPath -C $buildFolder \html"
92
94
}
93
95
94
96
if ($simulator )
@@ -101,7 +103,7 @@ if ($simulator)
101
103
New-Item - Path " $buildFolder \win32" - ItemType Directory - Force - ErrorAction Ignore
102
104
103
105
$msvc = & ' C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' - property installationpath - version 16.0
104
-
106
+ Write-Host $msvc
105
107
Import-Module (Join-Path $msvc " Common7\Tools\Microsoft.VisualStudio.DevShell.dll" )
106
108
107
109
Enter-VsDevShell - VsInstallPath $msvc - SkipAutomaticLocation - DevCmdArguments ' -arch=x64 -no_logo'
@@ -117,7 +119,7 @@ if ($simulator)
117
119
118
120
# Start-Process -FilePath "$cmakePath" -ArgumentList $cmakeArgs -NoNewWindow -Wait
119
121
Invoke-Expression " $cmakePath $cmakeArgs "
120
- Invoke-Expression " ninja.exe -C $buildFolder \win32"
122
+ Invoke-Expression " $ninjaPath -C $buildFolder \win32"
121
123
}
122
124
123
125
You can’t perform that action at this time.
0 commit comments