microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
477 stars 207 forks source link

support multiple MakeCode Aracade games on adafruit pygamer #4736

Open bill-uCoder opened 2 years ago

bill-uCoder commented 2 years ago

Would like the ability to load multiple MakeCode Aracade games onto hardware (Adafruit pygamer) https://www.adafruit.com/product/4242

My two cents on this 😊

The Microsoft MakeCode Arcade team could create an arcade example project “game selection screen” (gss). This gss project could then be written to the hardware and would act like a bootloader with menu options for the user. Upon reset, the gss project would scan the sdcard for special UF2 files (the ones with the offset)… and list the name of the games on the LCD for the user to browse. (simple text menu on the display would work) Then upon user selection the gss project would load/copy the UF2 file… onto the ATSAMD51J19… then jump from the gss project to the start of that loaded UF2 project. To load another game the user would need to reset the hardware to get back to the gss menu. Also note with this method gss is never overwritten... (until user loads a makecode arcade project from their laptop down to the hardware).

Microsoft Makecode team would have to give the arcade developer a two options to save the game as UF2 file: A. Save in UF2 format like it does today B. Or save in UF2 format with an address offset (to make room for the gss project)

mmoskal commented 2 years ago

I think it would be easiest if you built the GSS program at a special offset and built a special bootloader that starts the GSS (if present) not the game by default. The GSS should be able to flash the UF2 of the game quite easily (UF2 is very easy to interpret). This way there are no changes required in Arcade (except for you building GSS; you would need to hack the linker script when building locally).

To start the GSS you can use the menu program we use on RPi: https://github.com/microsoft/pxt-arcade-cabinet-menu

mmoskal commented 2 years ago

Actually, I think the simplest way to do it would be to write a custom bootloader (by forking https://github.com/microsoft/uf2-samdx1 or the Adafruit's fork) that would present the user with a menu. You could only go into that menu when say some button is pressed when the board is reset. The menu would read the list of games in SPI flash and have options to start a game (which would copy it from SPI to main flash) and also an option to save current game from main flash to SPI.

I think you can do that without any hacking on the Arcade side.