Skip to content

Instantly share code, notes, and snippets.

@hrobeers
Created January 26, 2022 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrobeers/a72bb460e1ce9be8a2aebed82d66fa91 to your computer and use it in GitHub Desktop.
Save hrobeers/a72bb460e1ce9be8a2aebed82d66fa91 to your computer and use it in GitHub Desktop.
#include "wasm4.h"
const uint8_t smiley[] = {
0b11110000, 0b00001111,
0b11000000, 0b00000011,
0b00000100, 0b00010000,
0b00000100, 0b00010000,
0b00000000, 0b00000000,
0b00001100, 0b00110000,
0b11000011, 0b11000011,
0b11110000, 0b00001111,
};
int pal = 0;
uint32_t default_pal[4];
void start() {
default_pal[0] = PALETTE[0];
default_pal[1] = PALETTE[1];
default_pal[2] = PALETTE[2];
default_pal[3] = PALETTE[3];
}
void set_pal(int p) {
switch(p) {
case 1:
PALETTE[0] = default_pal[0];
PALETTE[1] = default_pal[1];
PALETTE[2] = 0x00ff00;
PALETTE[3] = 0x0000ff;
break;
default:
PALETTE[0] = default_pal[0];
PALETTE[1] = default_pal[1];
PALETTE[2] = 0xff0000;
PALETTE[3] = 0x00ff00;
break;
}
}
void update () {
set_pal(pal++%2);
*DRAW_COLORS = 2;
text("Hello from C++!", 10, 10);
*DRAW_COLORS = 0x1243;
uint8_t gamepad = *GAMEPAD1;
if (gamepad & BUTTON_1) {
*DRAW_COLORS = 0x1234;
}
blit(smiley, 76, 76, 8, 8, BLIT_2BPP);
//*DRAW_COLORS = *DRAW_COLORS & 0x000f;
*DRAW_COLORS = 2;
text("Press X to blink", 16, 90);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment