Add Missile Command game for T-Deck + desktop emulator
Game (examples/MissileCommand): - Classic Missile Command: 6 cities, 3 batteries x 10 missiles, escalating waves, smart bombs, score multiplier, session high score - Trackball aims, press/tap fires, keyboard A/S/D selects battery, screen tap aims+fires - Rendering: incremental TFT_eSPI drawing (persistent enemy trails that vanish on death, no AA-rocket trails, explosion circles that repair terrain, ghost-free crosshair) - Sound (sound_engine.cpp): non-blocking I2S task on core 0; wave-start alarm of four falling tones (like the original), sweeps/noise effects, U/V/M keyboard volume control with OSD, master volume scaling Emulator (emulator/): - SDL2 host that compiles the unmodified sketch against shim headers (Arduino, TFT_eSPI->framebuffer, GT911 touch, I2C keyboard, I2S->SDL audio); arrow keys emulate the trackball, --autoplay/--frames/--dump flags for headless smoke tests
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "emu_input.h"
|
||||
|
||||
/**
|
||||
* TwoWire shim. Address 0x55 behaves like the T-Deck keyboard controller:
|
||||
* requestFrom() pops at most `len` queued ASCII bytes; empty buffer returns 0
|
||||
* bytes (available() == 0), just like an absent keyboard.
|
||||
*/
|
||||
class TwoWire {
|
||||
public:
|
||||
void begin(int, int) {}
|
||||
void beginTransmission(uint8_t) { txBuf.clear(); }
|
||||
uint8_t endTransmission() { return 0; }
|
||||
size_t write(uint8_t b) { txBuf.push_back(b); return 1; }
|
||||
|
||||
uint8_t requestFrom(uint8_t /*addr*/, uint8_t len)
|
||||
{
|
||||
rx.clear();
|
||||
while (len-- > 0 && !emu::keyboard.empty()) {
|
||||
rx.push_back(emu::keyboard.front());
|
||||
emu::keyboard.pop_front();
|
||||
}
|
||||
return (uint8_t)rx.size();
|
||||
}
|
||||
uint8_t requestFrom(uint8_t a, uint8_t l, uint8_t) { return requestFrom(a, l); }
|
||||
|
||||
int available() { return (int)rx.size(); }
|
||||
|
||||
int read()
|
||||
{
|
||||
if (rx.empty()) return -1;
|
||||
int v = rx.front();
|
||||
rx.pop_front();
|
||||
return v;
|
||||
}
|
||||
|
||||
private:
|
||||
std::deque<uint8_t> txBuf;
|
||||
std::deque<uint8_t> rx;
|
||||
};
|
||||
|
||||
extern TwoWire Wire;
|
||||
Reference in New Issue
Block a user