Add ESPboy frontend
This commit is contained in:
parent
79d3b92883
commit
7acfb64317
3 changed files with 146 additions and 3 deletions
139
frontend_espboy/frontend_espboy.ino
Normal file
139
frontend_espboy/frontend_espboy.ino
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/**
|
||||||
|
@file frontend_espboy.ino
|
||||||
|
|
||||||
|
Experimental Licar frontend for ESPboy, unstable and unplayable, but able to
|
||||||
|
load a few of the smallest maps and allow driving a bit.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Adafruit_MCP23017.h>
|
||||||
|
#include <Adafruit_MCP4725.h>
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
|
#define MCP23017address 0
|
||||||
|
#define MCP4725address 0x60
|
||||||
|
|
||||||
|
Adafruit_MCP23017 mcp;
|
||||||
|
Adafruit_MCP4725 dac;
|
||||||
|
TFT_eSPI tft;
|
||||||
|
|
||||||
|
#define LCR_SETTING_RESOLUTION_X 64
|
||||||
|
#define LCR_SETTING_RESOLUTION_Y 64
|
||||||
|
#define LCR_SETTING_MUSIC 0
|
||||||
|
#define LCR_SETTING_GHOST_MAX_SAMPLES 0
|
||||||
|
#define LCR_SETTING_332_COLOR 1
|
||||||
|
#define LCR_LOADING_COMMAND wdt_reset();
|
||||||
|
#define S3L_SORT 0
|
||||||
|
#define LCR_SETTING_MAP_MAX_BLOCKS 512
|
||||||
|
#define LCR_SETTING_MAX_MAP_VERTICES 500
|
||||||
|
#define LCR_SETTING_MAX_MAP_TRIANGLES 600
|
||||||
|
#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"
|
||||||
|
|
||||||
|
uint8_t gamescreen[LCR_SETTING_RESOLUTION_X * LCR_SETTING_RESOLUTION_Y];
|
||||||
|
uint8_t keys;
|
||||||
|
|
||||||
|
void LCR_drawPixel(unsigned long index, uint16_t color)
|
||||||
|
{
|
||||||
|
gamescreen[index] = color & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCR_sleep(uint16_t timeMs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t LCR_keyPressed(uint8_t key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case LCR_KEY_UP: return keys & 0x02; break;
|
||||||
|
case LCR_KEY_DOWN: return keys & 0x04; break;
|
||||||
|
case LCR_KEY_RIGHT: return keys & 0x08; break;
|
||||||
|
case LCR_KEY_LEFT: return keys & 0x01; break;
|
||||||
|
case LCR_KEY_A: return keys & 0x10; break;
|
||||||
|
case LCR_KEY_B: return keys & 0x20; break;
|
||||||
|
default: return 0; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
char LCR_getNextDataFileChar(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LCR_appendDataStr(const char *str)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
*((volatile uint32_t *) 0x60000900) &= ~(1); // disable watchdog
|
||||||
|
|
||||||
|
dac.begin(MCP4725address);
|
||||||
|
delay (100);
|
||||||
|
dac.setVoltage(0,false);
|
||||||
|
mcp.begin(MCP23017address);
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
// buttons
|
||||||
|
for (uint8_t i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
mcp.pinMode(i,INPUT);
|
||||||
|
mcp.pullUp(i,HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcp.pinMode(8,OUTPUT);
|
||||||
|
mcp.digitalWrite(8,LOW);
|
||||||
|
|
||||||
|
tft.begin();
|
||||||
|
delay(100);
|
||||||
|
tft.setRotation(0);
|
||||||
|
|
||||||
|
tft.setAddrWindow(0,128,0,128);
|
||||||
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
|
dac.setVoltage(4095,true); // backlight
|
||||||
|
|
||||||
|
LCR_gameInit(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
keys = ~mcp.readGPIOAB() & 255;
|
||||||
|
wdt_reset();
|
||||||
|
LCR_gameStep(millis());
|
||||||
|
|
||||||
|
for (int y = 0; y < LCR_SETTING_RESOLUTION_Y; ++y)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
uint8_t *pixel = gamescreen + y * LCR_SETTING_RESOLUTION_X;
|
||||||
|
|
||||||
|
for (int x = 0; x < LCR_SETTING_RESOLUTION_X; ++x)
|
||||||
|
{
|
||||||
|
uint16_t color = *pixel;
|
||||||
|
color =
|
||||||
|
((color & 0xe0) << 8) | ((color & 0x1c) << 6) | ((color & 0x03) << 3);
|
||||||
|
|
||||||
|
tft.pushColor(color);
|
||||||
|
tft.pushColor(color);
|
||||||
|
|
||||||
|
pixel++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
game.h
3
game.h
|
@ -366,8 +366,6 @@ struct
|
||||||
} dataFile;
|
} dataFile;
|
||||||
|
|
||||||
#define LCR_GHOST_SAMPLE_SIZE 5
|
#define LCR_GHOST_SAMPLE_SIZE 5
|
||||||
|
|
||||||
#if LCR_SETTING_GHOST_MAX_SAMPLES != 0
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint8_t active;
|
uint8_t active;
|
||||||
|
@ -379,7 +377,6 @@ struct
|
||||||
allow ghosts for even long replays. */
|
allow ghosts for even long replays. */
|
||||||
int16_t offset[3]; ///< Small correcting position offset.
|
int16_t offset[3]; ///< Small correcting position offset.
|
||||||
} ghost;
|
} ghost;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LCR_FPS_GET_MS
|
#ifdef LCR_FPS_GET_MS
|
||||||
uint16_t renderFrameMS;
|
uint16_t renderFrameMS;
|
||||||
|
|
|
@ -41,6 +41,13 @@
|
||||||
#define S3L_PERSPECTIVE_CORRECTION 0
|
#define S3L_PERSPECTIVE_CORRECTION 0
|
||||||
#define S3L_NEAR_CROSS_STRATEGY 1
|
#define S3L_NEAR_CROSS_STRATEGY 1
|
||||||
#define S3L_FLAT 1
|
#define S3L_FLAT 1
|
||||||
|
#define S3L_Z_BUFFER 0
|
||||||
|
|
||||||
|
#ifndef S3L_SORT
|
||||||
|
#define S3L_SORT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define S3L_MAX_TRIANGES_DRAWN 48
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define S3L_NEAR (10 * (S3L_F / 16)) // too low value will cause overflows
|
#define S3L_NEAR (10 * (S3L_F / 16)) // too low value will cause overflows
|
||||||
|
|
Loading…
Reference in a new issue