mirror of
https://github.com/nacabaro/nacapet.git
synced 2026-06-05 22:12:53 +00:00
Add upscaling on the egg screen
This commit is contained in:
parent
2ae5bc8bd4
commit
82a7d76b92
@ -1,6 +1,7 @@
|
|||||||
#include "lines.h"
|
#include "lines.h"
|
||||||
#include "memory/memory.h"
|
#include "memory/memory.h"
|
||||||
#include "defs/defs.h"
|
#include "defs/defs.h"
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
@ -40,39 +41,69 @@ void lines_getAvailableLines() {
|
|||||||
lineFile = root.openNextFile("r");
|
lineFile = root.openNextFile("r");
|
||||||
|
|
||||||
while (lineFile) {
|
while (lineFile) {
|
||||||
uint16_t bytesRead = lineFile.readBytes(header, headerSize);
|
uint16_t bytesRead = 0;
|
||||||
|
|
||||||
|
bytesRead += lineFile.readBytes(header, headerSize);
|
||||||
bytesRead += lineFile.read(&availableLines[allocCount].id, 1);
|
bytesRead += lineFile.read(&availableLines[allocCount].id, 1);
|
||||||
bytesRead += lineFile.readBytes(availableLines[allocCount].name, 16);
|
bytesRead += lineFile.readBytes(availableLines[allocCount].name, 16);
|
||||||
|
|
||||||
bytesRead += lineFile.read(&availableLines[allocCount].eggSprite.spriteWidth, 1);
|
uint8_t originalWidth;
|
||||||
bytesRead += lineFile.read(&availableLines[allocCount].eggSprite.spriteHeight, 1);
|
uint8_t originalHeight;
|
||||||
bytesRead += lineFile.read(&availableLines[allocCount].eggSprite.spriteNumber, 1); // Se coloca el cursor al principio de los datos de sprite
|
uint8_t spriteCount;
|
||||||
|
|
||||||
availableLines[allocCount].eggSprite.spriteNumber = 1; // Inutil, pero es que necesito hacer la lectura
|
bytesRead += lineFile.read(&originalWidth, 1);
|
||||||
|
bytesRead += lineFile.read(&originalHeight, 1);
|
||||||
|
bytesRead += lineFile.read(&spriteCount, 1);
|
||||||
|
|
||||||
availableLines[allocCount].eggSprite.spriteData = memory_allocate(
|
const uint8_t scaledWidth = originalWidth * SPRITE_SCALE;
|
||||||
availableLines[allocCount].eggSprite.spriteNumber,
|
const uint8_t scaledHeight = originalHeight * SPRITE_SCALE;
|
||||||
availableLines[allocCount].eggSprite.spriteWidth,
|
|
||||||
availableLines[allocCount].eggSprite.spriteHeight
|
availableLines[allocCount].eggSprite.spriteWidth = scaledWidth;
|
||||||
);
|
availableLines[allocCount].eggSprite.spriteHeight = scaledHeight;
|
||||||
|
availableLines[allocCount].eggSprite.spriteNumber = 1;
|
||||||
|
availableLines[allocCount].eggSprite.spriteData = memory_allocate(1, scaledWidth, scaledHeight);
|
||||||
|
|
||||||
|
uint16_t* spriteBuffer =
|
||||||
|
(uint16_t*) malloc(
|
||||||
|
originalWidth *
|
||||||
|
originalHeight *
|
||||||
|
sizeof(uint16_t)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!spriteBuffer) {
|
||||||
|
printf("[LINES] Failed to allocate sprite buffer\n");
|
||||||
|
|
||||||
|
lineFile.close();
|
||||||
|
lineFile = root.openNextFile();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t highByte;
|
uint8_t highByte;
|
||||||
uint8_t lowByte;
|
uint8_t lowByte;
|
||||||
|
|
||||||
for (int i = 0; i < availableLines[allocCount].eggSprite.spriteWidth * availableLines[allocCount].eggSprite.spriteHeight; i++) {
|
for (int i = 0; i < originalWidth * originalHeight; i++) {
|
||||||
bytesRead += lineFile.read(&highByte, 1);
|
bytesRead += lineFile.read(&highByte, 1);
|
||||||
bytesRead += lineFile.read(&lowByte, 1);
|
bytesRead += lineFile.read(&lowByte, 1);
|
||||||
|
|
||||||
uint16_t pixel = (highByte << 8) | lowByte;
|
spriteBuffer[i] = (highByte << 8) | lowByte;
|
||||||
|
|
||||||
availableLines[allocCount].eggSprite.spriteData[0][i] = pixel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utils_upscaleSprite(
|
||||||
|
spriteBuffer,
|
||||||
|
originalWidth,
|
||||||
|
originalHeight,
|
||||||
|
availableLines[allocCount].eggSprite.spriteData[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
free(spriteBuffer);
|
||||||
|
|
||||||
strcpy(availableLines[allocCount].fileName, lineFile.name());
|
strcpy(availableLines[allocCount].fileName, lineFile.name());
|
||||||
|
|
||||||
lineFile.close();
|
lineFile.close();
|
||||||
|
|
||||||
allocCount++;
|
allocCount++;
|
||||||
|
|
||||||
lineFile = root.openNextFile();
|
lineFile = root.openNextFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user