|Project NES op de ledbanner 🐄|
|Name||NES op de ledbanner 🐄|
|Information||Putting a NES game (in this case Mario) on the ledbanner|
I thought it would be fun to do it.
How to run
go run ./go/src/glitter.jemoeders.website/biodiscus/ledbanner_nes/main.go ./mario/out/mario.so ./mario/rom/mario2.nes | ledcat --dim 0.4 hexws2811 > /dev/ttyACM0
For this project different parts where
- A plugin system
- To allow the camera to be different for different displays, a display of 150x16 has different mapping rules than a 1920x1080 display.
- Look at the build script in the test_plugin folder to compile the plugin.
- A ledbanner "emulator", to make local development easy and fast
- Ledcat's demo feature wasn't nice when this feature was created.
- Run Web/test.html from the browser to emulate the ledbanner display.
- A socket to send controller inputs to the server
- Run Web/index.html from the browser to send the input to the server.
During the project quite a lot of problems where encountered, the idea behind this entry is to help people not make the same mistake or allow this to help solve the problem.
A size of a NES is 256x240 (Vertical x Horizontal) pixels, while the size of the ledbanner is 150x16. To solve this, I've tried a few thing:
- Stretching the image horizontal and vertical to fit the led banner perfectly, by stretching the whole game isn't recognizable
- Stretching the image horizontal and keep the aspect ratio, this way the game becomes recognizable but Mario can jump off screen
- Scaling the image and keeping the original aspect ratio, this made Mario 1x2 (width x height) pixels and made the game not recognizable
- Track the position and state of Mario and scaling and moving the area according to those variables, this makes the game way harder but Mario is recognizable
A plugin was written where the NES memory can be used to control the camera, this allows "anyone" to create a correct mapping for the display. A project that I'd love to do right now is map Mario for the Kubusje.
To much data was send to ledcat, while it did run on 60 FPS it also made the input fall a second behind. This was fixed by adding a delay when rendering a single frame.
Link to delay when rendering a frame
Mario is hidden due to frame skipping, to make the game appear to run faster than it's actually doing. Frame skipping was implemented on every second frame, which also happens to be the frame when mario is invuranble after taking damage. This was solved by putting the frame skip on every third frame.
Camera would move before mario
There was a problem with the camera moving to a position before Mario was visually at that place. This was fixed by keeping a buffer and taking data out of it two frames later.
Link to y position from a buffer
Emulator and different mappins
All different kind of emulators use different kinds of memory mappings (?). Making imposible to play certain games on the emulator. The emulator chosen for this project, was chosen because it supported Mario 🤷♂️. The NES emulator that's modified is: , in this version there are a lot of Stdout prints, which is not ideal when you need to send pixels/colors to Stdout to ledcat.
Stuff that still needs to happend, but I can't be bothered to fix it.
- When you die it's just a blank screen, a game over text added to it can be a nice feature.
- When falling the screen scales back before the player has landed, this should be fixed by only scaling back when Mario landed.
- When falling from the screen, the screen scrolls to a black screen.
- When jumping from a high thing and reaching the top of the screen, there is 1 frame that is black and after that will go back to the correct color.
- When scaling the left and right should be duplicated, otherwise it's really uggly.
~ Gopper 🐄