diff --git a/README.md b/README.md index 529da8d..c47cc32 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ This game got some attention on 4chan: [1](https://archive.li/Yzcwt), [2](https: - Gamebino Meta (80 x 64, 48 MHz ARM, 32 KB RAM, 256 KB flash) - Ringo/MAKERphone (160 x 128, 160 MHz ARM, 520 KB RAM, 4 MB flash) - ESPboy (128 x 128, 160 MHz) + - Nibble (128 x 128, 160 MHz) - unofficial [bare metal Raspberry Pi port](https://github.com/msx80/anarch-baremetalpi) by msx80 - Has **completely NO external dependencies**, not even rendering or IO, that is left to each platform's frontend, but each frontend is very simple. Uses **no dynamic heap allocation** (no malloc). - Can fit into **less than 256 kb** (including all content, textures etc.). @@ -74,6 +75,7 @@ compiled: | Gamebuino Meta | 215 KB | 18 | 80 * 64 | < 32 KB | | Ringo (MAKERphone) | 1.3 MB | 35 | 160 * 128 | | | ESPboy | 376 KB | 22 | 128 * 128 | | +| Nibble | 416 KB | 35 | 128 * 128 | | | browser | 884 KB (whole output) | 35 | 512 * 320 | ~20 MB | system requirements: diff --git a/bin/Anarch_nibble_1-02.bin b/bin/Anarch_nibble_1-02.bin new file mode 100644 index 0000000..d2a659f Binary files /dev/null and b/bin/Anarch_nibble_1-02.bin differ diff --git a/index.html b/index.html index 51968c8..de1ce09 100644 --- a/index.html +++ b/index.html @@ -303,6 +303,7 @@
  • GB Meta
  • Ringo
  • ESPboy
  • +
  • Nibble
  • M$ Win$hit XP SDL
  • source code
  • more downloads
  • diff --git a/main_nibble.ino b/main_nibble.ino new file mode 100644 index 0000000..36adf08 --- /dev/null +++ b/main_nibble.ino @@ -0,0 +1,149 @@ + /** + @file main_nibble.ino + + This is Nibble (CircuitMess) implementation of the game front end. + + by Miloslav Ciz (drummyfish), 2021 + + Released under CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/) + plus a waiver of all other intellectual property. The goal of this work is to + be and remain completely in the public domain forever, available for any use + whatsoever. +*/ + +#include +#include +#include +#include + +#define PLUS_BRIGHTNESS 2 // this can be changed (max: 8) + +#define SFG_AVR 1 + +#define SFG_SCREEN_RESOLUTION_X 128 +#define SFG_SCREEN_RESOLUTION_Y 128 +#define SFG_FPS 35 + +#define SFG_RAYCASTING_MAX_STEPS 20 +#define SFG_RAYCASTING_SUBSAMPLE 2 +#define SFG_DIMINISH_SPRITES 1 +#define SFG_DITHERED_SHADOW 1 + +#define SFG_CAN_EXIT 0 /* If the game is compiled into loeader, this can be set + to 1 which will show the "exit" option in the menu. */ +#include "game.h" + +Display* display; +Sprite* sprite; +uint8_t buttons[7]; +uint16_t paletteRAM[256]; + +void SFG_setPixel(uint16_t x, uint16_t y, uint8_t colorIndex) +{ + sprite->drawPixel(x,y,paletteRAM[colorIndex]); +} + +uint32_t SFG_getTimeMs() +{ + return millis(); +} + +void SFG_sleepMs(uint16_t timeMs) +{ +} + +int8_t SFG_keyPressed(uint8_t key) +{ + return key < 7 ? buttons[key] : 0; +} + +void SFG_getMouseOffset(int16_t *x, int16_t *y) +{ +} + +void SFG_setMusic(uint8_t value) +{ +} + +void SFG_save(uint8_t data[SFG_SAVE_SIZE]) +{ +} + +void SFG_processEvent(uint8_t event, uint8_t data) +{ +} + +uint8_t SFG_load(uint8_t data[SFG_SAVE_SIZE]) +{ + return 0; +} + +void SFG_playSound(uint8_t soundIndex, uint8_t volume) +{ + switch (soundIndex) + { + case 0: Piezo.tone(120, 45); break; // shot + case 1: Piezo.tone(200, 30); break; // door + case 2: Piezo.tone(80, 60); break; // explosion + case 3: Piezo.tone(220, 50); break; // click + case 4: Piezo.tone(180, 60); break; // plasma + case 5: Piezo.tone(300, 10); break; // monster + default: break; + } +} + +// create button callbacks: + +#define cbf(b,n) void b ## _down() { buttons[n] = 255; } void b ## _up() { buttons[n] = 0; } +cbf(BTN_UP,0) +cbf(BTN_RIGHT,1) +cbf(BTN_DOWN,2) +cbf(BTN_LEFT,3) +cbf(BTN_A,4) +cbf(BTN_B,5) +cbf(BTN_C,6) +#undef cbf + +void setup() +{ + Nibble.begin(); + display = Nibble.getDisplay(); + sprite = display->getBaseSprite(); + + SFG_init(); + + for (uint8_t i = 0; i < 7; ++i) + buttons[i] = 0; + + // move palette to RAM plus increase brightness of the colors: + + for (int i = 0; i < 256; ++i) + { + int helper = i % 8; + helper = (helper < 8 - PLUS_BRIGHTNESS) ? PLUS_BRIGHTNESS : (7 - helper); + paletteRAM[i] = pgm_read_word(paletteRGB565 + i + helper); + } + + // register button callbacks: + + #define cb(b) \ + Input::getInstance()->setBtnPressCallback(b,b ## _down); \ + Input::getInstance()->setBtnReleaseCallback(b,b ## _up); + + cb(BTN_UP) + cb(BTN_DOWN) + cb(BTN_LEFT) + cb(BTN_RIGHT) + cb(BTN_A) + cb(BTN_B) + cb(BTN_C) + + #undef cb +} + +void loop() +{ + Input::getInstance()->loop(0); + SFG_mainLoopBody(); + display->commit(); +} diff --git a/media/nibble.gif b/media/nibble.gif new file mode 100644 index 0000000..7ea672a Binary files /dev/null and b/media/nibble.gif differ