ref: deb392cf342cf21ee8c00eb37a1cf4d7d473997a
parent: 02add69d54728af139a3ade19052993443aee6ea
author: Snesrev <[email protected]>
date: Tue Aug 30 22:36:58 EDT 2022
Add Alt-Enter hotkey to toggle fullscreen. Co-authored-by: Rémy F <[email protected]>
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@
/tables/img/
/tables/old/
/saves/*.sav
+/.vs/
__pycache__
--- a/README.md
+++ b/README.md
@@ -68,6 +68,7 @@
| T | Toggle replay turbo |
| K | Clear all input history from current snapshot |
| F1-F10 | Load snapshot |
+| Alt+Enter | Toggle Fullscreen |
| Shift+F1-F10 | Save snapshot |
| Ctrl+F1-F10 | Replay the snapshot |
--- a/main.cpp
+++ b/main.cpp
@@ -52,7 +52,8 @@
printf("Failed to init SDL: %s\n", SDL_GetError());
return 1;
}
- SDL_Window* window = SDL_CreateWindow("Zelda3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 512, 480, 0);
+ uint32 win_flags = SDL_WINDOWPOS_UNDEFINED;
+ SDL_Window* window = SDL_CreateWindow("Zelda3", SDL_WINDOWPOS_UNDEFINED, win_flags, 512, 480, 0);
if(window == NULL) {
printf("Failed to create window: %s\n", SDL_GetError());
return 1;
@@ -101,9 +102,9 @@
// sdl loop
bool running = true;
SDL_Event event;
- uint32_t lastTick = SDL_GetTicks();
- uint32_t curTick = 0;
- uint32_t delta = 0;
+ uint32 lastTick = SDL_GetTicks();
+ uint32 curTick = 0;
+ uint32 delta = 0;
int numFrames = 0;
bool cpuNext = false;
bool spcNext = false;
@@ -110,48 +111,55 @@
int counter = 0;
bool paused = false;
bool turbo = true;
- uint32_t frameCtr = 0;
+ uint32 frameCtr = 0;
- printf("%d\n", *(int *)snes->cart->ram);
-
while(running) {
while(SDL_PollEvent(&event)) {
switch(event.type) {
- case SDL_KEYDOWN: {
- switch(event.key.keysym.sym) {
- case SDLK_e:
- if (snes) {
- snes_reset(snes, event.key.keysym.sym == SDLK_e);
- CopyStateAfterSnapshotRestore(true);
- }
- break;
- case SDLK_p: paused ^= true; break;
- case SDLK_w:
- PatchCommand('w');
- break;
- case SDLK_o:
- PatchCommand('o');
- break;
- case SDLK_k:
- PatchCommand('k');
- break;
- case SDLK_t:
- turbo = !turbo;
- break;
+ case SDL_KEYDOWN: {
+ bool skip_default = false;
+ switch(event.key.keysym.sym) {
+ case SDLK_e:
+ if (snes) {
+ snes_reset(snes, event.key.keysym.sym == SDLK_e);
+ CopyStateAfterSnapshotRestore(true);
}
- handleInput(event.key.keysym.sym, event.key.keysym.mod, true);
break;
- }
- case SDL_KEYUP: {
- handleInput(event.key.keysym.sym, event.key.keysym.mod, false);
+ case SDLK_p: paused ^= true; break;
+ case SDLK_w:
+ PatchCommand('w');
break;
- }
- case SDL_QUIT: {
- running = false;
+ case SDLK_o:
+ PatchCommand('o');
break;
+ case SDLK_k:
+ PatchCommand('k');
+ break;
+ case SDLK_t:
+ turbo = !turbo;
+ break;
+ case SDLK_RETURN:
+ if (event.key.keysym.mod & KMOD_ALT) {
+ win_flags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ SDL_SetWindowFullscreen(window, win_flags);
+ skip_default = true;
+ }
+ break;
}
+ if (!skip_default)
+ handleInput(event.key.keysym.sym, event.key.keysym.mod, true);
+ break;
}
+ case SDL_KEYUP: {
+ handleInput(event.key.keysym.sym, event.key.keysym.mod, false);
+ break;
+ }
+ case SDL_QUIT: {
+ running = false;
+ break;
+ }
}
+ }
if (paused) {
SDL_Delay(16);
--- a/zelda3.vcxproj
+++ b/zelda3.vcxproj
@@ -39,12 +39,12 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v142</PlatformToolset>
+ <PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">