Disclaimer: This post is for documentation and education purposes, to help someone who wonders about this same question in the future (if they know how to use the search bar)
I used an unmodified Adafruit PyGamer to conduct this experiment
I was recently wondering how hardware handles scaling the screen with this method:
namespace userconfig {
export const ARCADE_SCREEN_WIDTH = <width>;
export const ARCADE_SCREEN_HEIGHT = <height>;
}
This method works in the simulator (browser), but you obviously can’t display an image larger than 160x120
(MakeCode’s native resolution) on a 160x120
screen (the screen most arcade devices are equipped with).
So, I wanted to experiment and find out what happens if I try anyway. My hypotesis was that I was going to reach one of the following outcomes:
- The device panics and crashes
- The device crops the screen to display to show the top left
160x120
area - The device crops the screen, but the middle instead of the top left
- Arcade compiles with
160x120
in mind and pretends that the resolution was never changed
If you don’t want to listen to my yapping, and just want an answer, it’s NUMBER 4
If you do, stick around for the rest of my “report”.
After testing this out, I came to a conclusion. First and foremost, the project in fact compiled to my PyGamer with no issues, so I can rule out number 1. After loading the following code to the device, it’s immediately apparent we’re looking at the top left corner, so number 3 is also out of the question.
The size in the simulator is set to 320x240
(Upon loading this example to the device, we can see the tan colored top left corner)
(It’s hard to tell due to the lighting, but the screen is entirely tan)
Finally, it’s up to decide between options 2 and 4. You might notice the added debug text that logs the screen size on both devices, and that’s the final piece of the puzzle: when the code is compiled for hardware, the custom resolution is completely ignored! Why? Because the userconfig
settings are only meant for the simulator, and they’re usually unachievable on hardware anyway.
So, that concludes my experiment, and I hope it comes in handy at some point to somebody. If you want to add something, feel free to expand on this here in the replies if you have a device to do this on. It would be great if somebody would also test sprite and tilemap behaviour in these circumstances, becuase i’m just not bothered to do so.
Nerd yaps for way too long
Then, one final question remains: why? What is the point of this? Well, for one this post exists because it was on my todo list. However, the real point is practical application for bigger games/projects. Say, you want to enable simulator users to choose a bigger resolution for your game when playing in the browser, becuase you can. Now, you can’t change the resolution on runtime, but a possible solution is to use a method to check if you’re running in sim, and if you are just draw everything across the whole screen. Otherwise, draw everything to the top left 160x120
because that’s what you’re going to see on hardware or something along those lines. I would need to actually make that to verify it, but it sounds possible and that’s good enough for me.
That’s all I’ve got for today, toodles!