Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Arduboy2 library ported to WASM4

License

NotificationsYou must be signed in to change notification settings

joshgoebel/Arduboy2-WASM4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a port of the Arduboy2 library to WASM-4.

At a very high level:

  • rips out all the legit hardware stuff (ports, I/O interfaces, sleep, etc)
  • mapsArduboy2::display to the center of the WASM-4 screen
  • maps the WASM-4 controller #1 toArduboy2Core::buttonsState()
  • bundles (for now)ArduboyTones and maps it'stone([one note]) function tow4.tone channel 1
  • adds some scaffolding for<Arduino.h> and friends to make porting most things easier
  • 1024 buffer is still needs for the screen since all the native functions are still drawing to that buffer, only indisplay is that translated to the native WASM-4 display
  • You can't use tight loops waiting for input, since WASM-4 is event driven andupdate is called at 60 FPS
  • You're stuck with 60 FPS (or an even multiple, 30, 15, etc.)

Example

To play it online:

https://ajoshguy.itch.io/mystic-balloons-w4

Requirements

  • A working C/C++ toolchain on your local machine for compiling
  • Working Make tooks, since you'll needmake to build
  • The WASM-4w4 console utility for running or bundling your cartridges

TODO

  • Restore sound inArduboy2Beep.cpp
  • more cleanups of the built-in functions
  • random does nothing
  • randomSeed does nothing
  • does not supportPrint orprint yet
  • Move palette setup and such things into the library
  • Is there some way to hideEEPROM.boot()?

Porting Mystic Balloons

Pretty much all the work was in the main sketch file:

Before:

voidsetup(){  arduboy.boot();  arduboy.audio.begin();  arduboy.bootLogoSpritesSelfMasked();  arduboy.setFrameRate(60);loadSetEEPROM();}voidloop() {if (!(arduboy.nextFrame()))return;if (gameState < STATE_GAME_NEXT_LEVEL && arduboy.everyXFrames(10))sparkleFrames = (++sparkleFrames) %5;  arduboy.pollButtons();  arduboy.clear();  ((FunctionPointer)pgm_read_word (&mainGameLoop[gameState]))();  arduboy.display();}

After:

Make sure you notice the functions have been renamed tostart andupdate.

voidstart(){  arduboy.boot();// we MUST set aside 1024 of RAM to allow us to easily// persist the entire EEPROM to disk correctly  EEPROM.boot();// does nothing currently, we're really always 60 FPS// but perhaps we can make it work with 15 or 30 in the future  arduboy.setFrameRate(60);  arduboy.audio.begin();loadSetEEPROM();}voidupdate() {if (stillBooting()) {return;  }// set our "black and white" pallette  PALETTE[0] =0x000000;  PALETTE[1] =0xffff99;if (!(arduboy.nextFrame()))return;if (gameState < STATE_GAME_NEXT_LEVEL && arduboy.everyXFrames(10))sparkleFrames = (++sparkleFrames) %5;  arduboy.pollButtons();  arduboy.clear();// this can be simplified since we have no PROGMEM on WASM-4  mainGameLoop[gameState]();  arduboy.display();}

Update is only called when the next frame is needed so essentiallynextFrame() is almost a NOP, but it still does useful things with regard to frame counting, etc. so it's best to leave it.

About

Arduboy2 library ported to WASM4

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp