diff --git a/emulator/src/shim/TFT_eSPI.h b/emulator/src/shim/TFT_eSPI.h index 1acf4d7..0716580 100644 --- a/emulator/src/shim/TFT_eSPI.h +++ b/emulator/src/shim/TFT_eSPI.h @@ -54,6 +54,8 @@ public: TFT_eSPI() {} void begin() {} + void startWrite() {} + void endWrite() {} void setRotation(uint8_t) {} int width() { return emuGfx::W; } int height() { return emuGfx::H; } diff --git a/examples/MiataDrive/MiataDrive.ino b/examples/MiataDrive/MiataDrive.ino index be7e77c..a9ca8ff 100644 --- a/examples/MiataDrive/MiataDrive.ino +++ b/examples/MiataDrive/MiataDrive.ino @@ -34,7 +34,7 @@ static int scrW, scrH; static const uint32_t FRAME_MS = 33; // ~30 fps static const int SEG_LEN = 200; // segment length (world units) static const int RUMBLE_SEGS = 3; // segments per rumble stripe -static const int DRAW_DIST = 90; // segments drawn ahead +static const int DRAW_DIST = 60; // segments drawn ahead static const float ROAD_W = 1000.0f; // road half-width (world units) static const float CAM_H = 1500.0f; // camera height above road static const float CAM_D = 0.84f; // 1/tan(fov/2), fov ~100 deg @@ -357,10 +357,9 @@ static void renderRoad() { const float HORIZON_Y = scrH * 0.36f; // sky down to just past the vanishing point int skyBot = (int)HORIZON_Y + 14; - for (int y = 0; y < skyBot; y++) { - uint16_t c = (y < skyBot * 2 / 5) ? colSkyHi : colSkyLo; - tft.drawFastHLine(0, y, scrW, c); - } + int skySplit = skyBot * 2 / 5; + tft.fillRect(0, 0, scrW, skySplit, colSkyHi); + tft.fillRect(0, skySplit, scrW, skyBot - skySplit, colSkyLo); float basePercent = fmodf(position_, SEG_LEN) / SEG_LEN; int baseIdx = ((int)(position_ / SEG_LEN)) % segCount; @@ -425,8 +424,8 @@ static void renderRoad() { // grass band uint16_t grass = light ? palGrassL[fog] : palGrassD[fog]; int yTop = iround(P2[n].y), yBot = iround(P1[n].y) - 1; - for (int y = yTop; y <= yBot; y++) - if (y < maxY) tft.drawFastHLine(0, y, scrW, grass); + if (yBot > (int)maxY - 1) yBot = (int)maxY - 1; + if (yTop <= yBot && yBot >= 0) tft.fillRect(0, yTop, scrW, yBot - yTop + 1, grass); // rumble strips (wide, for speed sensation) float r1 = P1[n].w / 6.0f, r2 = P2[n].w / 6.0f; @@ -836,6 +835,7 @@ static void drawEndScreen(bool win) { } static void render() { + tft.startWrite(); switch (gameState) { case ST_TITLE: drawTitle(); break; case ST_SPRITES: drawSpriteTest(); break; @@ -848,6 +848,7 @@ static void render() { drawHUD(); break; } + tft.endWrite(); } // ---------------------------------------------------------------------------