Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve portability and multiple fixes #13

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

deltabeard
Copy link

This pull request fixes issue #10, and possibly #1 (I haven't got a macOS system to test with). I've written some details in the commit messages. I understand that this is a size sensitive demo, so I tried to make the changes as helpful as possible.

These changes should theoretically allow any system that is supported by SDL2 to run this project. I have tested Windows 10, which wasn't supported before.

These changes might increase the number of characters in the obfuscated version, but I have not made changes to it (is pokegb.cc generated automatically or manually?).

SDL_WINDOWPOS_CENTERED was added because without it the window is created in the top right corner and it is not possible to move it easily due to the title bar being off-screen, but this could be changed to a magic value in the obfuscated version.

Thanks.

This allows for improved cross-platform building. Tested working on
Windows 10 in a MinGW64 (w64devkit) development environment with the
following commit.

Signed-off-by: Mahyar Koshkouei <[email protected]>
Removes mmap() and other non-portable instructions. Only SDL2 functions
are used now. Tested working on Windows 10 in a MinGW64 development
environment.

This may fix issue binji#1, whereby a crash happens if rom.sav is not found.
Now, if rom.sav is not found, 32kB is allocated, and then later saved on
exit. Not tested on macOS.

Signed-off-by: Mahyar Koshkouei <[email protected]>
Fixes issue binji#10 whereby gameplay would run at the speed of the monitor
refresh rate. A delay is automatically calculated on each frame to slow
down the gameplay if required. Note that this does not speed up the
gameplay if the monitor has a refresh rate lower than 59 Hz. In such
cases, VSYNC should just be disabled in the source code.

Signed-off-by: Mahyar Koshkouei <[email protected]>
Might help reduce the number of bytes in the obfuscated version, and
hopefully compensate for the additions made in the previous commits.

Signed-off-by: Mahyar Koshkouei <[email protected]>
@deltabeard deltabeard marked this pull request as draft February 12, 2024 18:53
@deltabeard
Copy link
Author

Changed to draft because turning off vsync on line 145 causes the game to run too fast, which demonstrates that there is something wrong in the timing code I added.

Reduced length of variable name. Although this doesn't matter as it will
become obfuscated anyway.

Reduce speed_compensation calculation to single line.

Signed-off-by: Mahyar Koshkouei <[email protected]>
@deltabeard deltabeard marked this pull request as ready for review February 12, 2024 19:02
@binji
Copy link
Owner

binji commented Feb 13, 2024

Thanks for taking a look at this! Yeah, I ended up using the SDL filesystem functions for smolnes, which made it a lot more portable. It's a little sad to lose mmap though, since that will likely add a lot to the obfuscated code size. And yeah, I the obfuscated file is done by hand, so it's not easy to experiment with different code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants