110 lines
2.3 KiB
C++
110 lines
2.3 KiB
C++
/**
|
|
@file frontend_nibble.ino
|
|
|
|
Experimental Licar frontend for Circuitmesss Nibble, unstable and unplayable,
|
|
but able to load a few of the smallest maps and allow driving a bit.
|
|
*/
|
|
|
|
#include <Arduino.h>
|
|
#include <EEPROM.h>
|
|
#include <CircuitOS.h>
|
|
#include <Nibble.h>
|
|
|
|
#define LCR_SETTING_RESOLUTION_X 128
|
|
#define LCR_SETTING_RESOLUTION_Y 128
|
|
#define LCR_SETTING_MUSIC 0
|
|
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 2
|
|
#define LCR_SETTING_GHOST_MAX_SAMPLES 0
|
|
#define LCR_LOADING_COMMAND wdt_reset();
|
|
#define S3L_SORT 0
|
|
#define S3L_Z_BUFFER 0
|
|
#define S3L_MAX_TRIANGLES_DRAWN 32
|
|
#define LCR_SETTING_MAP_MAX_BLOCKS 350
|
|
#define LCR_SETTING_MAX_MAP_VERTICES 300
|
|
#define LCR_SETTING_MAX_MAP_TRIANGLES 500
|
|
#define LCR_SETTING_REPLAY_MAX_SIZE 0
|
|
#define LCR_SETTING_CAR_SHADOW 0
|
|
#define LCR_SETTING_PARTICLES 0
|
|
#define LCR_SETTING_LOG_LEVEL 0
|
|
#define LCR_SETTING_LOD_DISTANCE 100
|
|
#define LCR_SETTING_CAR_ANIMATION_SUBDIVIDE 0
|
|
#define LCR_SETTING_FPS 25
|
|
#define LCR_SETTING_POTATO_GRAPHICS 1
|
|
#define LCR_SETTING_ENABLE_DATA_FILE 0
|
|
#define LCR_SETTING_ONLY_SMALL_MAPS 1
|
|
|
|
#include "game.h"
|
|
|
|
Display* display;
|
|
Sprite* sprite;
|
|
uint8_t buttons[6];
|
|
|
|
void LCR_drawPixel(unsigned long index, uint16_t color)
|
|
{
|
|
sprite->drawPixel(index % LCR_SETTING_RESOLUTION_X,index / LCR_SETTING_RESOLUTION_X,color);
|
|
}
|
|
|
|
void LCR_sleep(uint16_t timeMs)
|
|
{
|
|
}
|
|
|
|
uint8_t LCR_keyPressed(uint8_t key)
|
|
{
|
|
return key < 6 ? buttons[key] : 0;
|
|
}
|
|
|
|
char LCR_getNextDataFileChar(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void LCR_appendDataStr(const char *str)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 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)
|
|
#undef cbf
|
|
|
|
void setup()
|
|
{
|
|
wdt_disable();
|
|
Nibble.begin();
|
|
display = Nibble.getDisplay();
|
|
sprite = display->getBaseSprite();
|
|
|
|
for (uint8_t i = 0; i < 7; ++i)
|
|
buttons[i] = 0;
|
|
|
|
// 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)
|
|
|
|
#undef cb
|
|
|
|
LCR_gameInit(0,0);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
Input::getInstance()->loop(0);
|
|
LCR_gameStep(millis());
|
|
display->commit();
|
|
}
|