Some ideas for battery (saves) and controller input

Programming, for all ages and all languages.
Post Reply
gonzo
Posts: 12
Joined: Mon Dec 03, 2018 4:10 pm

Some ideas for battery (saves) and controller input

Post by gonzo »

I have a static machine image that I have an embedded gameboy color emulator inside. The OS doesnt really have a good disk driver or writable filesystem, so I need some ideas for how to save games. The GBC battery state is either 32kb (most times) or 128kb (sometimes).
My idea is to use a REST endpoint to send and receive savedata. Is there any other simpler way to do this? On bare metal the network solution seems best.

Another thought was controlling the emulator with joypad by reading linux /dev/input/js0: character special (13/0)
Then parsing that data and sending the button/axis states over network... again.

Do you know of anything that already parses joystick data and sends it over network? If so I would like to just use it. Wouldnt have to reinvent the wheel.

Fun fact, the screen is in 13h and since it only has 256 colors I have to trap on palette changes in the emulator and write the palette to VGA. I also do a color scaling to make the colors more appealing.
Its happening here: https://github.com/fwsGonzo/gamebro/blo ... ce.cpp#L97

One last question. 13h is 320x200, is it pointless to try to scale up the image in the emulator with this low resolution? I cant imagine it would look good. The DMG/CGB screen is 160x144 pixels.
And bonus fun fact: DMG is acronym for Dot Matrix Game which was the working title for the original Gameboy!

Thanks!
gonzo
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Some ideas for battery (saves) and controller input

Post by alexfru »

This might be helpful for scaling.
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Some ideas for battery (saves) and controller input

Post by nullplan »

@gonzo: I don't quite get you. Are you on bare metal or on Linux? Because if the former, nothing is stoppinng you from designating a disk partition as your save file. And if the latter then I don't know why you can't just save on disk somewhere.

As for the rest, you could probably just use netcat to send /dev/js0 to the network. That data is already interpreted. I don't think encapsulating it in JSON or something will add anything to your process. Same with the save data. I like netcat, it is so versatile.

But all of that means you have to implement a TCP/IP stack in addition to a GB emulator. You sure about this?
Carpe diem!
gonzo
Posts: 12
Joined: Mon Dec 03, 2018 4:10 pm

Re: Some ideas for battery (saves) and controller input

Post by gonzo »

nullplan wrote:@gonzo: I don't quite get you. Are you on bare metal or on Linux? Because if the former, nothing is stoppinng you from designating a disk partition as your save file. And if the latter then I don't know why you can't just save on disk somewhere.

As for the rest, you could probably just use netcat to send /dev/js0 to the network. That data is already interpreted. I don't think encapsulating it in JSON or something will add anything to your process. Same with the save data. I like netcat, it is so versatile.

But all of that means you have to implement a TCP/IP stack in addition to a GB emulator. You sure about this?
We already have a TCP/IP stack in modern C++ and a read-only filesystem. The OS is made for network functions, so its static and not configurable during run-time. It can run just fine on bare metal. I guess you are right about netcat, good idea. I will try to do that. I really want to control it with my gamepad.
Post Reply