mirror of
https://github.com/nacabaro/nacapet.git
synced 2026-06-05 14:02:53 +00:00
Mierda
This commit is contained in:
parent
595faaf946
commit
ce23c44077
@ -23,18 +23,16 @@ void tft_initDisplay(TFT_eSPI &tft, uint16_t color) {
|
||||
void tft_initScreenBuffer(uint16_t color) {
|
||||
composite.setAttribute(PSRAM_ENABLE, true);
|
||||
|
||||
|
||||
// 2. Try to create the sprite
|
||||
if (composite.createSprite(240, 240)) {
|
||||
printf("SUCCESS: Composite sprite created.\n");
|
||||
composite.fillSprite(TFT_RED); // If this works, screen should turn RED
|
||||
composite.fillSprite(TFT_RED);
|
||||
} else {
|
||||
printf("FATAL: Composite sprite failed! No RAM/PSRAM.\n");
|
||||
return; // Stop here so we don't draw "lines"
|
||||
return;
|
||||
}
|
||||
|
||||
composite.setFreeFont(NULL); // Reset to default GLCD font
|
||||
composite.setTextFont(1); // Use the standard small font (scaled by size 4)
|
||||
composite.setFreeFont(NULL);
|
||||
composite.setTextFont(1);
|
||||
composite.setTextColor(TFT_BLUE);
|
||||
composite.setTextSize(4);
|
||||
composite.pushSprite(0, 0);
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
|
||||
|
||||
void draw_drawAttacks(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* attackSpriteData, int x, int y, uint8_t attackType, uint8_t attackSprite, bool flipped) {
|
||||
// spriteWidth/Height are already pre-scaled at load time
|
||||
int cleanWidth = attackSpriteData->spriteWidth + 6; // +4 to be safe
|
||||
int cleanWidth = attackSpriteData->spriteWidth + 6;
|
||||
draw_drawBackgroundSection(bg, x, y, cleanWidth, attackSpriteData->spriteHeight * 2);
|
||||
|
||||
switch(attackType) {
|
||||
|
||||
@ -10,13 +10,9 @@ void draw_drawBackground(TFT_eSprite& bg, int spr_w, int spr_h, int factor) {
|
||||
}
|
||||
|
||||
void draw_drawBackgroundSection(TFT_eSprite& bg, int x, int y, int w, int h) {
|
||||
// Get the raw 16-bit pixel buffer from the background sprite
|
||||
uint16_t* bgPtr = (uint16_t*)bg.getPointer();
|
||||
int bgStride = bg.width(); // Full row width — needed to advance between rows
|
||||
int bgStride = bg.width();
|
||||
|
||||
// pushImage assumes a contiguous (packed) source buffer, so feeding the
|
||||
// whole rectangle at once would read wrong pixels after the first row.
|
||||
// Instead, copy one row at a time, each time jumping by bgStride pixels.
|
||||
for (int row = 0; row < h; row++) {
|
||||
uint16_t* rowSrc = bgPtr + ((y + row) * bgStride) + x;
|
||||
composite.pushImage(x, y + row, w, 1, rowSrc);
|
||||
|
||||
@ -16,7 +16,6 @@ void draw_drawSprite(
|
||||
uint8_t spriteNumber,
|
||||
bool flipHorizontal
|
||||
) {
|
||||
// Sprites are pre-scaled at load time; width/height are already final.
|
||||
const int W = spriteData->spriteWidth;
|
||||
const int H = spriteData->spriteHeight;
|
||||
|
||||
@ -29,10 +28,8 @@ void draw_drawSprite(
|
||||
uint16_t* srcBuf = spriteData->spriteData[spriteNumber];
|
||||
|
||||
if (!flipHorizontal) {
|
||||
// Fast path: one memcpy of the whole frame
|
||||
memcpy(sprBuf, srcBuf, W * H * sizeof(uint16_t));
|
||||
} else {
|
||||
// Mirror each row horizontally
|
||||
for (int row = 0; row < H; row++) {
|
||||
const uint16_t* src = srcBuf + row * W;
|
||||
uint16_t* dst = sprBuf + row * W;
|
||||
|
||||
@ -8,9 +8,6 @@
|
||||
struct SpriteData* checkerboardPattern;
|
||||
|
||||
void menu_createCheckerboard() {
|
||||
// Build the pattern pre-scaled by SPRITE_SCALE (6) so that
|
||||
// draw_drawSprite can treat it identically to SPIFFS-loaded sprites.
|
||||
// Logical size: 34 wide × 1 tall → Scaled: 204 wide × 6 tall
|
||||
const uint8_t SCALE = 6;
|
||||
const uint8_t logicalW = 34;
|
||||
const uint8_t logicalH = 1;
|
||||
@ -27,7 +24,6 @@ void menu_createCheckerboard() {
|
||||
|
||||
uint16_t* buf = checkerboardPattern->spriteData[0];
|
||||
|
||||
// Fill: repeat each logical pixel as a SCALE×SCALE block across all rows
|
||||
for (uint16_t row = 0; row < scaledH; row++) {
|
||||
for (uint8_t col = 0; col < logicalW; col++) {
|
||||
uint16_t color = (col % 2 == 0) ? TFT_BLACK : TFT_TRANSPARENT;
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
|
||||
const char* TAG_S = "[STORAGE]";
|
||||
|
||||
// All sprites are upscaled by this factor at load time so draw_drawSprite
|
||||
// can skip the scaling loop entirely at runtime.
|
||||
#define SPRITE_SCALE 6
|
||||
|
||||
void storage_init() {
|
||||
@ -41,8 +39,6 @@ void storage_readFile(const char* path, struct SpriteData* spriteData) {
|
||||
const uint8_t scaledW = width * SPRITE_SCALE;
|
||||
const uint8_t scaledH = height * SPRITE_SCALE;
|
||||
|
||||
// Allocate scaled buffers in PSRAM (ps_malloc falls back to regular heap
|
||||
// automatically if PSRAM is not available for a given allocation).
|
||||
uint16_t** scaled = (uint16_t**) ps_malloc(spriteNumber * sizeof(uint16_t*));
|
||||
if (!scaled) {
|
||||
printf("%s PSRAM alloc failed for pointer table\n", TAG_S);
|
||||
@ -60,7 +56,6 @@ void storage_readFile(const char* path, struct SpriteData* spriteData) {
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary single-row scratch buffer in internal RAM for reading from file
|
||||
uint16_t* rowBuf = (uint16_t*) malloc(width * sizeof(uint16_t));
|
||||
if (!rowBuf) {
|
||||
printf("%s scratch alloc failed\n", TAG_S);
|
||||
@ -79,20 +74,16 @@ void storage_readFile(const char* path, struct SpriteData* spriteData) {
|
||||
uint16_t* dst = scaled[sprN];
|
||||
|
||||
for (int srcY = 0; srcY < height; srcY++) {
|
||||
// --- Read one source row, byte-swapping as we go ---
|
||||
for (int srcX = 0; srcX < width; srcX++) {
|
||||
uint8_t hi, lo;
|
||||
file.read(&hi, 1);
|
||||
file.read(&lo, 1);
|
||||
// File is big-endian RGB565; TFT_eSPI expects little-endian
|
||||
rowBuf[srcX] = (lo << 8) | hi;
|
||||
}
|
||||
|
||||
// --- Scale row vertically (repeat SPRITE_SCALE times) ---
|
||||
for (int dy = 0; dy < SPRITE_SCALE; dy++) {
|
||||
uint16_t* dstRow = dst + (srcY * SPRITE_SCALE + dy) * scaledW;
|
||||
|
||||
// --- Scale each pixel horizontally ---
|
||||
for (int srcX = 0; srcX < width; srcX++) {
|
||||
uint16_t color = rowBuf[srcX];
|
||||
uint16_t* dstPixel = dstRow + srcX * SPRITE_SCALE;
|
||||
@ -107,7 +98,6 @@ void storage_readFile(const char* path, struct SpriteData* spriteData) {
|
||||
free(rowBuf);
|
||||
file.close();
|
||||
|
||||
// Store scaled dimensions so the rest of the code sees the final size
|
||||
spriteData->spriteWidth = scaledW;
|
||||
spriteData->spriteHeight = scaledH;
|
||||
spriteData->spriteNumber = spriteNumber;
|
||||
@ -140,8 +130,6 @@ void storage_initBackground(const char* path, TFT_eSprite& bg) {
|
||||
uint8_t hi, lo;
|
||||
file.read(&lo, 1);
|
||||
file.read(&hi, 1);
|
||||
// Store directly into sprite buffer – no byte swap needed here since
|
||||
// background pixels are not going through the draw_drawSprite path.
|
||||
bgBuf[i] = (hi << 8) | lo;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user