Na, poca cosa

- Soporte para varios bichos  a la vez
- Algunos bugs menos
This commit is contained in:
Nacho 2025-06-01 01:54:36 +02:00
parent 4fa960562e
commit e138334e06
43 changed files with 645 additions and 335 deletions

View File

@ -16,3 +16,4 @@ monitor_speed = 115200
monitor_port = /dev/ttyUSB0
monitor_filters = esp32_exception_decoder
lib_deps = TFT_eSPI, fbiego/ESP32Time@^2.0.6, electroniccats/MPU6050@^1.4.3
build_flags = -Wl,-Map,output.map

View File

@ -21,7 +21,7 @@ void buttons_checkInactivity() {
screenKey = OFF_SCREEN;
} else if (currentTime - lastPressedButtonTime > LAST_PRESSED_BUTTON_THRESHOLD_TIME_US && !inactive) {
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
inactive = true;
}
}

View File

@ -7,7 +7,7 @@ struct BackgroundData {
uint8_t backgroundWidth;
uint8_t backgroundHeight;
uint8_t scaleFactor;
uint16_t* backgroundData;
uint16_t* backgroundData = NULL;
};
#endif

View File

@ -57,7 +57,8 @@
#define POOP_SCREEN_MENU 4
#define MEDICAL_SCREEN_MENU 5
#define SLEEP_SCREEN_MENU 6
#define SETTINGS_SCREEN_MENU 7
#define CHANGE_SCREEN_MENU 7
#define SETTINGS_SCREEN_MENU 8
// SCREENS THAT OPEN AFTER CLICKING ON A MENU ENTRY
#define STATUS_SCREEN 10
@ -67,7 +68,8 @@
#define CLEAR_POOP_SCREEN 14
#define MEDICAL_SCREEN 15
#define SLEEP_SCREEN 16
#define SETTINGS_SCREEN 17
#define CHANGE_SCREEN 17
#define SETTINGS_SCREEN 18
// ICONS FOR EACH MENU ENTRY (MENU.BIN)
#define STATUS_SCREEN_ICON 0
@ -77,10 +79,10 @@
#define CLEAR_POOP_ICON 4
#define MEDICAL_SCREEN_ICON 5
#define SLEEP_SCREEN_ICON 6
#define SETTINGS_SCREEN_ICON 7
#define CARE_MISTAKE_CALL_LIGHT 8
#define BED_SPRITE 9
#define EMPTY_EGG 10
#define SETTINGS_SCREEN_ICON 8
#define CARE_MISTAKE_CALL_LIGHT 9
#define BED_SPRITE 10
#define EMPTY_EGG 11
// SCREENS
#define OFF_SCREEN -1
@ -99,6 +101,7 @@
#define CARE_MISTAKE_SCREEN 23
#define POOPING_SCREEN 24
#define HAPPY_SCREEN 25
#define MAIN_SCREEN 26
// TRAINING MODES
#define TRAINING_SCREEN_1 30
@ -159,7 +162,7 @@ extern uint64_t lastPressedButtonTime;
extern uint64_t lastUpdateTime;
extern uint64_t lastBeepTime;
extern struct CharacterData charaData;
extern struct CharacterData* charaData;
extern struct tm timeInfo;
extern uint32_t dayUnixTime;
@ -188,6 +191,4 @@ extern Line_t** currentLine;
extern struct SpriteData mainCharacterSprites;
extern bool pauseLoop;
#endif

View File

@ -2,12 +2,18 @@
#define SPRITE_DATA_H
#include <stdint.h>
#include <stddef.h>
struct SpriteData {
uint8_t spriteWidth;
uint8_t spriteHeight;
uint8_t spriteNumber;
uint16_t** spriteData;
uint16_t** spriteData = NULL;
uint8_t lastX = 0;
uint8_t lastY = 0;
uint8_t lastW = 0;
uint8_t lastH = 0;
};
#endif

View File

@ -1,5 +1,6 @@
#include "display.h"
#include "defs/screen_defs.h"
#include "defs/defs.h"
int xPos = 0;
int yPos = 0;
@ -9,7 +10,8 @@ static const int BUF_H = 120;
void tft_initDisplay(TFT_eSPI &tft, uint16_t color) {
tft.init();
tft.begin();
tft.initDMA();
tft.setRotation(1);
tft.fillScreen(TFT_RED);
}
@ -21,8 +23,6 @@ void tft_initScreenBuffer(uint16_t color) {
composite1.setTextSize(4);
composite1.pushSprite(0, 0);
printf("STATUS1: %i", status);
status = composite2.createSprite(240, 120);
composite2.fillSprite(TFT_BLUE);
composite2.setTextColor(TFT_BLACK);
@ -37,6 +37,13 @@ void tft_drawBuffer() {
tft.endWrite();
}
/*void tft_drawBuffer() {
tft.startWrite();
tft.pushImageDMA(0, 0, 240, 120, (uint16_t*) composite1.getPointer());
tft.pushImageDMA(0, 120, 240, 120, (uint16_t*) composite2.getPointer());
tft.endWrite();
}*/
void tft_clearBuffer(TFT_eSprite &composite, uint16_t color) {
composite.fillSprite(color);
}
@ -48,23 +55,20 @@ void tft_clearBuffer(uint16_t color) {
void tft_drawCenteredText(const char* text, int size, int yGlobal) {
int textW = strlen(text) * size * 6;
int x = (SCREEN_WIDTH - textW) / 2;
int x = (SCREEN_WIDTH - textW) / 2;
if (yGlobal < BUF_H) {
// only top half
composite1.setTextSize(size);
composite1.setTextColor(TFT_BLACK);
composite1.drawString(text, x, yGlobal);
} else {
// only bottom half, adjust local Y
int yLocal = yGlobal - BUF_H;
composite2.setTextSize(size);
composite2.setTextColor(TFT_BLACK);
composite2.drawString(text, x, yLocal);
}
composite1.setTextSize(size);
composite1.setTextColor(TFT_BLACK);
composite1.drawString(text, x, yGlobal);
// only bottom half, adjust local Y
int yLocal = yGlobal - BUF_H;
composite2.setTextSize(size);
composite2.setTextColor(TFT_BLACK);
composite2.drawString(text, x, yLocal);
}
void tft_drawText(const char* text, uint8_t size, uint8_t x, uint8_t y, uint16_t color) {
void tft_drawText(const char* text, int size, int x, int y, uint16_t color) {
composite1.setTextSize(size);
composite1.setTextColor(color);
composite1.drawString(text, x, y);
@ -74,7 +78,7 @@ void tft_drawText(const char* text, uint8_t size, uint8_t x, uint8_t y, uint16_t
composite2.drawString(text, x, y - BUF_H);
}
void tft_drawRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t color) {
void tft_drawRectangle(int x, int y, int w, int h, uint16_t color) {
composite1.fillRect(x, y, w, h, color);
composite2.fillRect(x, y - BUF_H, w, h, color);
}

View File

@ -12,7 +12,7 @@ void tft_drawBuffer();
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color = TFT_WHITE);
void tft_clearBuffer(uint16_t color = TFT_WHITE);
void tft_drawCenteredText(const char* text, int factor, int y);
void tft_drawText(const char* text, uint8_t size, uint8_t x, uint8_t y, uint16_t color = TFT_BLACK);
void tft_drawRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t color = TFT_BLACK);
void tft_drawText(const char* text, int size, int x, int y, uint16_t color = TFT_BLACK);
void tft_drawRectangle(int x, int y, int w, int h, uint16_t color = TFT_BLACK);
#endif

View File

@ -9,9 +9,10 @@ void draw_drawSprite(
uint8_t factor, bool flipHorizontal = false
);
void draw_drawBackground(TFT_eSprite &bg, int spr_w, int spr_h, int factor);
void draw_drawBackgroundSection(TFT_eSprite &bg, int spr_w, int spr_h, int tft_x, int tft_y, int tft_w, int tft_h, int factor);
void draw_drawSpriteCentered(
TFT_eSprite &spr, struct SpriteData* spriteData, uint8_t spriteNumber, uint8_t factor, bool flipped = false, int y = -1
);
void draw_drawAttacks(TFT_eSprite &sprite, struct SpriteData* attackSpriteData, uint8_t x, uint8_t y, uint8_t attackType, uint8_t attackSprite, uint8_t factor, bool flipped = false);
void draw_drawAttacks(TFT_eSprite &sprite, struct SpriteData* attackSpriteData, int x, int y, uint8_t attackType, uint8_t attackSprite, uint8_t factor, bool flipped = false);
#endif

View File

@ -2,7 +2,7 @@
#include "defs/sprite_data.h"
void draw_drawAttacks(TFT_eSprite &sprite, struct SpriteData* attackSpriteData, uint8_t x, uint8_t y, uint8_t attackType, uint8_t attackSprite, uint8_t factor, bool flipped) {
void draw_drawAttacks(TFT_eSprite &sprite, struct SpriteData* attackSpriteData, int x, int y, uint8_t attackType, uint8_t attackSprite, uint8_t factor, bool flipped) {
switch(attackType) {
case 1:
draw_drawSprite(sprite, x, y, attackSpriteData, attackSprite, factor, flipped);

View File

@ -5,18 +5,79 @@ const char* TAG_DB = "[DRAW BG]";
void draw_drawBackground(TFT_eSprite &bg, int spr_w, int spr_h, int factor) {
int scaledWidth = spr_w * factor;
int scaledHeight = spr_h * factor;
for (int sy = 0; sy < scaledHeight; sy++) {
for (int sx = 0; sx < scaledWidth; sx++) {
int srcX = sx / factor;
int srcY = sy / factor;
// spr_w, spr_h = dimensions of the source sprite “bg”
// factor = integer scale factor
for (int srcY = 0; srcY < spr_h; srcY++) {
// Compute the top row in the scaled image that corresponds to srcY
int destRowBase = srcY * factor;
// For each “vertical tile” row within [0 .. factor-1]:
for (int dy = 0; dy < factor; dy++) {
int outY1 = destRowBase + dy; // Y in composite1
int outY2 = outY1 - 120; // Y in composite2
// Now loop over each source column
for (int srcX = 0; srcX < spr_w; srcX++) {
// Fetch the color exactly once for this source pixel
uint16_t color = bg.readPixel(srcX, srcY);
// Compute the leftmost column in the scaled image that corresponds to srcX
int destColBase = srcX * factor;
// For each “horizontal tile” column within [0 .. factor-1]:
for (int dx = 0; dx < factor; dx++) {
int outX = destColBase + dx;
composite1.drawPixel(outX, outY1, color);
composite2.drawPixel(outX, outY2, color);
}
}
}
}
}
// USO FUTURO
void draw_drawBackgroundSection(TFT_eSprite &bg, int spr_w, int spr_h, int tft_x, int tft_y, int tft_w, int tft_h, int factor) {
int srcX_start = tft_x / factor;
int srcX_end = (tft_x + tft_w - 1) / factor;
int srcY_start = tft_y / factor;
int srcY_end = (tft_y + tft_h - 1) / factor;
if (srcX_start < 0) srcX_start = 0;
if (srcY_start < 0) srcY_start = 0;
if (srcX_end >= spr_w) srcX_end = spr_w - 1;
if (srcY_end >= spr_h) srcY_end = spr_h - 1;
if (srcX_start > srcX_end || srcY_start > srcY_end) return;
for (int srcY = srcY_start; srcY <= srcY_end; srcY++) {
int destY_base = srcY * factor;
int blockY0 = destY_base;
int blockY1 = destY_base + (factor - 1);
int y0 = (blockY0 < tft_y) ? tft_y : blockY0;
int y1 = (blockY1 > (tft_y + tft_h - 1)) ? (tft_y + tft_h - 1) : blockY1;
if (y0 > y1) continue;
for (int srcX = srcX_start; srcX <= srcX_end; srcX++) {
int destX_base = srcX * factor;
int blockX0 = destX_base;
int blockX1 = destX_base + (factor - 1);
int x0 = (blockX0 < tft_x) ? tft_x : blockX0;
int x1 = (blockX1 > (tft_x + tft_w - 1)) ? (tft_x + tft_w - 1) : blockX1;
if (x0 > x1) continue;
uint16_t color = bg.readPixel(srcX, srcY);
composite1.drawPixel(sx, sy, color);
composite2.drawPixel(sx, sy - 120, color);
for (int y = y0; y <= y1; y++) {
for (int x = x0; x <= x1; x++) {
composite1.drawPixel(x, y, color);
composite2.drawPixel(x, y - 120, color);
}
}
}
}
}

View File

@ -8,7 +8,8 @@
const char* TAG_D = "[DRAW]";
void draw_drawSprite(
/*void draw_drawSprite(
TFT_eSprite &spr, int x, int y,
struct SpriteData* spriteData, uint8_t spriteNumber, uint8_t factor, bool flipHorizontal
) {
@ -37,9 +38,63 @@ void draw_drawSprite(
spr.pushToSprite(&composite1, x, y, TFT_TRANSPARENT);
spr.pushToSprite(&composite2, x, y - 120, TFT_TRANSPARENT);
spriteData->lastX = x;
spriteData->lastY = y;
spriteData->lastW = scaledWidth;
spriteData->lastH = scaledWidth;
//printf("%s: Sprite %d drawn at (%d, %d) %s\n", TAG_D, spriteNumber, x, y, (flipHorizontal ? "flipped" : ""));
}*/
void draw_drawSprite(
TFT_eSprite &spr,
int x, int y,
struct SpriteData* spriteData,
uint8_t spriteNumber,
uint8_t factor,
bool flipHorizontal
) {
int srcW = spriteData->spriteWidth;
int srcH = spriteData->spriteHeight;
int scaledW = srcW * factor;
int scaledH = srcH * factor;
if (spr.width() != scaledW || spr.height() != scaledH) {
spr.deleteSprite();
spr.createSprite(scaledW, scaledH);
}
uint16_t *sprBuf = (uint16_t *)spr.getPointer();
uint16_t *srcBuf = spriteData->spriteData[spriteNumber];
for (int srcY = 0; srcY < srcH; srcY++) {
int destYBase = srcY * factor;
for (int srcX = 0; srcX < srcW; srcX++) {
int useX = flipHorizontal ? (srcW - 1 - srcX) : srcX;
uint16_t raw = srcBuf[srcY * srcW + useX];
uint16_t color = (raw << 8) | (raw >> 8);
int destXBase = srcX * factor;
for (int dy = 0; dy < factor; dy++) {
int rowStart = (destYBase + dy) * scaledW + destXBase;
for (int dx = 0; dx < factor; dx++) {
sprBuf[rowStart + dx] = color;
}
}
}
}
spr.pushToSprite(&composite1, x, y, TFT_TRANSPARENT);
spr.pushToSprite(&composite2, x, y - 120, TFT_TRANSPARENT);
spriteData->lastX = x;
spriteData->lastY = y;
spriteData->lastW = scaledW;
spriteData->lastH = scaledH;
}
void draw_drawSpriteCentered(
TFT_eSprite &spr,
struct SpriteData* spriteData, uint8_t spriteNumber, uint8_t factor, bool flipped, int y

22
src/loop/loop.cpp Normal file
View File

@ -0,0 +1,22 @@
#include "loop.h"
#include "defs/defs.h"
#include "vpet/vpet/vpet.h"
bool pauseLoop = false;
bool loopPaused = false;
void loop_pauseLoop() {
pauseLoop = true;
while (!loopPaused) {
delay(10);
};
}
void loop_resumeLoop() {
lastPressedButtonTime = vpetLastEvaluationTime = esp_timer_get_time();
pauseLoop = false;
while (loopPaused) {
printf("[LOOP] Loop paused\n");
};
}

12
src/loop/loop.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef LOOP_H
#define LOOP_H
// Idealmente deberia de usar la habilidad de pausar tareas de FreeRTOS, pero no fufa
extern bool pauseLoop;
extern bool loopPaused;
void loop_pauseLoop();
void loop_resumeLoop();
#endif

View File

@ -1,10 +1,10 @@
#include <Arduino.h>
#include "defs/defs.h"
#include "display/display.h"
#include "memory/memory.h"
#include "storage/storage.h"
#include "animations/animations.h"
#include "debug/debug.h"
#include "defs/defs.h"
#include "defs/chara_data.h"
#include "menu/menu.h"
#include "buttons/buttons.h"
@ -13,6 +13,7 @@
#include "vpet/lines/lines.h"
#include "energy/energy.h"
#include "driver/rtc_io.h"
#include "loop/loop.h"
#include "menu/training/training_screens.h"
const char* TAG = "[MAIN]";
@ -36,7 +37,7 @@ struct SpriteData uiElementsData;
// Active character data
// TODO: Split into CHARA_COUNT_IN_DEVICE times
struct CharacterData charaData;
struct CharacterData* charaData;
uint8_t currentCharacter = 0;
// Boot flag, tells if the device clock has been initialized
@ -63,7 +64,6 @@ uint8_t eggNumber = 0;
// Tasks
TaskHandle_t secondLoop = NULL;
bool pauseLoop = false;
void loop2();
void secondCoreTask(void*);
@ -79,6 +79,8 @@ void setup() {
tft_initScreenBuffer(TFT_BLACK);
storage_init();
charaData = (struct CharacterData*) calloc(CHARA_COUNT_IN_DEVICE, sizeof(struct CharacterData));
storage_readFile("/menu.bin", &menuElementsData);
storage_readFile("/ui.bin", &uiElementsData);
@ -123,7 +125,7 @@ void loop() {
break;
case STATUS_SCREEN:
menu_statusScreen(bg, sprite, &uiElementsData, &charaData);
menu_statusScreen(bg, sprite, &uiElementsData);
break;
case OFF_SCREEN:
@ -189,6 +191,14 @@ void loop() {
case TRAINING_SCREEN_1:
training_screenTraining1(bg, sprite, &mainCharacterSprites, &uiElementsData);
break;
case MAIN_SCREEN:
menu_mainScreen();
break;
case CHANGE_SCREEN:
menu_changeCharaScreen(bg, sprite, &mainCharacterSprites, &uiElementsData);
break;
}
if (screenKey == IDLE_SCREEN || screenKey == OFF_SCREEN) {
@ -206,10 +216,11 @@ void loop2() {
if (screenOff) { energy_startLightSleep(); }
} else {
lastPressedButtonTime = esp_timer_get_time();
buttons_getPressedButtons();
buttons_getPressedButtons(); // REMOVE: Esto es porque tengo que shiftear el buffer de la pantalla
delay(100);
}
loopPaused = pauseLoop;
}
void secondCoreTask(void*) {

View File

@ -1,4 +1,5 @@
#include "memory.h"
#include "defs/sprite_data.h"
const char* TAG_M = "[MEMORY]";
@ -31,11 +32,12 @@ uint16_t** memory_allocate(uint8_t numSprite, uint8_t width, uint8_t height) {
}
void memory_free(uint8_t* ptr) {
if (ptr != NULL) {
free(ptr);
ptr = NULL;
} else {
printf("%s Pointer is already NULL\n", TAG_M);
void memory_free(struct SpriteData* spriteData) {
for (int i = 0; i < spriteData->spriteNumber; i++) {
free(spriteData->spriteData[i]);
}
free(spriteData->spriteData);
spriteData->spriteData = NULL;
}

View File

@ -13,6 +13,6 @@ struct spriteData {
};
uint16_t** memory_allocate(uint8_t numSprite, uint8_t width, uint8_t height);
void memory_free(uint8_t* ptr);
void memory_free(struct SpriteData* spriteData);
#endif

View File

@ -34,7 +34,7 @@ void menu_careMistakeScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteD
}
if (pressedButtons != 0) {
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
beepCounter = 0;
}

View File

@ -3,6 +3,7 @@
#include "display/display.h"
#include "defs/screen_defs.h"
#include "vpet/evolution/evolution.h"
#include "loop/loop.h"
struct SpriteData* checkerboardPattern;
@ -31,7 +32,6 @@ void menu_freeCheckerboard() {
}
// Don't worry, I hate this too
void menu_evolutionScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* mainCharacterSprites) {
menu_createCheckerboard();
TFT_eSprite checkerboard = TFT_eSprite(&tft);
@ -150,7 +150,9 @@ void menu_evolutionScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteDat
menu_freeCheckerboard();
pauseLoop = false;
screenKey = IDLE_SCREEN;
loop_resumeLoop();
screenKey = MAIN_SCREEN;
lastUpdateTime = 0; // Un pequeño empujoncito
}

View File

@ -0,0 +1,90 @@
#include "menu.h"
#include "buttons/buttons.h"
#include "draw/draw.h"
#include "loop/loop.h"
#include "defs/chara_data.h"
#include "storage/storage.h"
#include "display/display.h"
#include "defs/defs.h"
void menu_changeCharaScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* mainSpriteData, struct SpriteData* uiSpriteData) {
loop_pauseLoop();
uint8_t selectedChara = currentCharacter;
CharacterData* selectedCharaData = &charaData[selectedChara];
bool updateScreen = true;
for (;;) {
uint8_t pressedButtons = buttons_getPressedButtons();
switch (pressedButtons) {
case K1_PRESSED:
selectedChara++;
if (selectedChara >= CHARA_COUNT_IN_DEVICE) {
selectedChara = 0;
}
selectedCharaData = &charaData[selectedChara];
updateScreen = true;
break;
case K2_PRESSED:
currentCharacter = selectedChara;
loop_resumeLoop();
screenKey = MAIN_SCREEN;
menuKey = STATUS_SCREEN;
return;
break;
case K3_PRESSED:
char fileName[20];
sprintf(fileName, "/chara/%02x.bin", charaData[currentCharacter].idChara);
storage_readFile(fileName, mainSpriteData);
loop_resumeLoop();
screenKey = MAIN_SCREEN;
menuKey = STATUS_SCREEN;
return;
break;
default:
break;
}
delay(15);
if (updateScreen) {
draw_drawBackground(bg, 90, 90, 3);
if (selectedCharaData->hatched) {
char fileName[20];
sprintf(fileName, "/chara/%02x.bin", selectedCharaData->idChara);
storage_readFile(fileName, mainSpriteData);
draw_drawSprite(sprite, 18, 72, mainSpriteData, 0, 6);
} else {
tft_drawCenteredText("EMPTY", 4, 120);
}
draw_drawSprite(sprite, 174, 96, uiSpriteData, ARROW_ICON, 6);
tft_drawBuffer();
updateScreen = false;
}
uint64_t currentTime = esp_timer_get_time();
if (currentTime - lastPressedButtonTime > INACTIVITY_THRESHOLD_TIME_US) {
char fileName[20];
sprintf(fileName, "/chara/%02x.bin", charaData[currentCharacter].idChara);
storage_readFile(fileName, mainSpriteData);
loop_resumeLoop();
screenKey = MAIN_SCREEN;
menuKey = STATUS_SCREEN;
}
}
}

View File

@ -9,7 +9,8 @@ void menu_drawClock(TFT_eSprite &bg) {
uint8_t pressedButtons = buttons_getPressedButtons();
switch (pressedButtons) {
case K2_PRESSED:
screenKey = IDLE_SCREEN;
draw_drawBackground(bg, 90, 90, 3);
screenKey = MAIN_SCREEN;
break;
default:

View File

@ -24,7 +24,7 @@ void menu_eggHatchScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData
uint64_t currentTime = esp_timer_get_time();
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
if (charaData.hatchTimer <= currentLine[currentCharacter]->hatchTime) {
if (charaData[currentCharacter].hatchTimer <= currentLine[currentCharacter]->hatchTime) {
draw_drawBackground(bg, 90, 90, 3);
draw_drawSpriteCentered(sprite, &currentEgg->eggSprite, eggSpriteFrame, 6);
@ -34,7 +34,7 @@ void menu_eggHatchScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData
tft_drawBuffer();
} else if (charaData.hatchTimer > currentLine[currentCharacter]->hatchTime && !charaData.hatched) {
} else if (charaData[currentCharacter].hatchTimer > currentLine[currentCharacter]->hatchTime && !charaData[currentCharacter].hatched) {
for (int i = 0; i < 30; i++) {
tone(SPK_PIN, 4100, 35);
tone(SPK_PIN, 3500, 35);

View File

@ -26,7 +26,7 @@ void menu_lineSwitcher(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData*
break;
case K3_PRESSED:
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
return;
break;
@ -56,5 +56,5 @@ void menu_reloadEggs(uint8_t selectedEgg) {
vpetLastEvaluationTime = esp_timer_get_time();
charaData.hatching = true;
charaData[currentCharacter].hatching = true;
}

View File

@ -6,7 +6,7 @@
#include "vpet/vpet/vpet.h"
void menu_foodScreen(TFT_eSprite &bg, TFT_eSprite &mainChara, struct SpriteData* spriteData) {
if (charaData.sleepy) {
if (charaData[currentCharacter].sleepy) {
tone(SPK_PIN, BEEP_FREQ_HZ, BEEP_LEN_MS);
delay(100);
tone(SPK_PIN, BEEP_FREQ_HZ, BEEP_LEN_MS);
@ -35,28 +35,28 @@ void menu_foodScreen(TFT_eSprite &bg, TFT_eSprite &mainChara, struct SpriteData*
lastUpdateTime = 0;
switch(arrowPosition) {
case 0:
if (charaData.hunger < 8) {
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
charaData.hungerCareMistakeObtained = false;
charaData.weight++;
charaData.hunger++;
if (charaData[currentCharacter].hunger < 8) {
charaData[currentCharacter].hungerCareMistakeTimer = charaData[currentCharacter].initialStatsReductionTime;
charaData[currentCharacter].hungerCareMistakeObtained = false;
charaData[currentCharacter].weight++;
charaData[currentCharacter].hunger++;
screenKey = FEEDING_SCREEN;
submenuKey = FOOD_ICON;
} else {
screenKey = REFUSING_SCREEN;
if (!charaData.overfeedHappened) {
charaData.overfeed++;
charaData.overfeedHappened = true;
if (!charaData[currentCharacter].overfeedHappened) {
charaData[currentCharacter].overfeed++;
charaData[currentCharacter].overfeedHappened = true;
}
}
return;
break;
case 1:
if (charaData.strength < 8) {
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
charaData.strength++;
charaData.weight += 2;
if (charaData[currentCharacter].strength < 8) {
charaData[currentCharacter].strengthCareMistakeTimer = charaData[currentCharacter].initialStatsReductionTime;
charaData[currentCharacter].strength++;
charaData[currentCharacter].weight += 2;
screenKey = FEEDING_SCREEN;
submenuKey = PILL_ICON;
} else {

View File

@ -15,7 +15,7 @@ void menu_drawHappyScreen(
uint64_t currentTime = esp_timer_get_time();
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
if (frameCounter > 3) {
screenKey = IDLE_SCREEN; // TODO: Change for while battling
screenKey = MAIN_SCREEN; // TODO: Change for while battling
menuKey = STATUS_SCREEN;
return;

View File

@ -9,25 +9,7 @@
uint64_t lastUpdateTime = esp_timer_get_time();
void menu_drawIdleScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData, struct SpriteData* bigUiElements, struct SpriteData* smallUiElements) {
if (coldBoot) {
screenKey = TITLE_SCREEN;
return;
} else if (!charaData.hatched && !charaData.hatching) {
screenKey = EGG_EMPTY_SCREEN;
return;
} else if (!charaData.hatched && charaData.hatching) {
screenKey = EGG_HATCH_SCREEN;
return;
} else if (charaData.sleepy && !charaData.asleep) {
screenKey = SLEEPY_SCREEN;
return;
} else if ((charaData.sleepy && charaData.asleep) || charaData.asleep) {
screenKey = SLEEP_SCREEN;
return;
}
uint8_t pressedButtons = buttons_getPressedButtons();
switch (pressedButtons) {
case K1_PRESSED:
screenKey = MENU_SCREEN;
@ -43,17 +25,11 @@ void menu_drawIdleScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData
}
uint64_t currentTime = esp_timer_get_time();
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
draw_drawBackground(bg, 90, 90, 3);
uint8_t offsetX = menu_poopOverlay(bg, sprite, smallUiElements);
tft_clearBuffer(sprite, TFT_TRANSPARENT);
uint8_t offsetX = menu_poopOverlay(sprite, smallUiElements);
tft_clearBuffer(sprite, TFT_TRANSPARENT);
animate_performAnimation(sprite, spriteData, offsetX);
tft_clearBuffer(sprite, TFT_TRANSPARENT);
menu_uiOverlay(sprite, bigUiElements);
lastUpdateTime = currentTime;

27
src/menu/main_screen.cpp Normal file
View File

@ -0,0 +1,27 @@
#include "menu.h"
#include "defs/defs.h"
#include "defs/chara_data.h"
void menu_mainScreen() {
printf("[MAINSCR] on main screen\n");
if (coldBoot) {
screenKey = TITLE_SCREEN;
return;
} else if (!charaData[currentCharacter].hatched && !charaData[currentCharacter].hatching) {
screenKey = EGG_EMPTY_SCREEN;
return;
} else if (!charaData[currentCharacter].hatched && charaData[currentCharacter].hatching) {
screenKey = EGG_HATCH_SCREEN;
return;
} else if (charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep) {
screenKey = SLEEPY_SCREEN;
return;
} else if ((charaData[currentCharacter].sleepy && charaData[currentCharacter].asleep) || charaData[currentCharacter].asleep) {
screenKey = SLEEP_SCREEN;
return;
} else {
screenKey = IDLE_SCREEN;
return;
}
}

View File

@ -10,7 +10,7 @@ void menu_drawClockEdit(TFT_eSprite &bg);
void menu_drawTitle(TFT_eSprite &bg);
void menu_drawIdleScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData, struct SpriteData* bigUiElements, struct SpriteData* smallUiElements);
void menu_offScreen();
void menu_statusScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData, struct CharacterData* charaData);
void menu_statusScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData);
void menu_statusScreen_drawStat(TFT_eSprite &sprite, struct SpriteData* spriteData, int x, int y, const char* text, uint8_t statValue);
void menu_timerFinishedScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData);
void menu_uiOverlay(TFT_eSprite &charSprite, struct SpriteData* uiElements);
@ -34,7 +34,7 @@ void menu_poopScreen(
TFT_eSprite &bg, TFT_eSprite &sprite,
struct SpriteData* spriteData, struct SpriteData* smallUiElements, struct SpriteData* bigUiElements
);
uint8_t menu_poopOverlay(TFT_eSprite &sprite, struct SpriteData* smallUiElements);
uint8_t menu_poopOverlay(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* smallUiElements);
void menu_clearPoopScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData, struct SpriteData* bigUiElements, struct SpriteData* smallUiElements);
void menu_drawHappyScreen(
TFT_eSprite &bg, TFT_eSprite &sprite,
@ -45,6 +45,8 @@ void menu_eggHatchScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData
void menu_reloadEggs(uint8_t selectedEgg);
void menu_drawDeathScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* uiBigSprite, struct SpriteData* uiSmallSprite);
void menu_evolutionScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* mainCharacterSprites);
void menu_mainScreen();
void menu_changeCharaScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* mainSpriteData, struct SpriteData* uiSpriteData);
void menu_sleepScreen_sleepAction();
void menu_sleepScreen_recalculateSleep();

View File

@ -23,7 +23,7 @@ void menu_drawCurrentMenuOption(TFT_eSprite &bg, TFT_eSprite &icon, struct Sprit
break;
case K3_PRESSED:
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
menuKey = STATUS_SCREEN_MENU;
return;
break;
@ -58,15 +58,21 @@ void menu_drawCurrentMenuOption(TFT_eSprite &bg, TFT_eSprite &icon, struct Sprit
return;
break;
case CHANGE_SCREEN_MENU:
menuKey = STATUS_SCREEN;
screenKey = CHANGE_SCREEN;
return;
break;
default:
break;
}
return;
}
draw_drawSpriteCentered(icon, spriteData, menuKey % 8, 6);
draw_drawSpriteCentered(icon, spriteData, menuKey % 9, 6);
switch(menuKey % 9) {
switch(menuKey % 10) {
case STATUS_SCREEN_MENU:
tft_drawCenteredText("Status", 4, textYPos);
break;
@ -94,14 +100,18 @@ void menu_drawCurrentMenuOption(TFT_eSprite &bg, TFT_eSprite &icon, struct Sprit
case SLEEP_SCREEN_MENU:
tft_drawCenteredText("Sleep", 4, textYPos);
break;
case CHANGE_SCREEN_MENU:
tft_drawCenteredText("Change", 4, textYPos);
break;
case SETTINGS_SCREEN_MENU:
tft_drawCenteredText("Settings", 4, textYPos);
break;
case 8:
menuKey = 0;
screenKey = IDLE_SCREEN;
case 9:
menuKey = STATUS_SCREEN_MENU;
screenKey = MAIN_SCREEN;
return;
break;
}
@ -112,19 +122,19 @@ void menu_drawCurrentMenuOption(TFT_eSprite &bg, TFT_eSprite &icon, struct Sprit
}
void menu_sleepScreen_sleepAction() {
if (charaData.asleep && charaData.sleepy) {
if (charaData[currentCharacter].asleep && charaData[currentCharacter].sleepy) {
menu_sleepScreen_recalculateSleep();
charaData.sleepy = false;
charaData.asleep = false;
charaData[currentCharacter].sleepy = false;
charaData[currentCharacter].asleep = false;
charaData.sleepDisturbances++;
charaData[currentCharacter].sleepDisturbances++;
menuKey = STATUS_SCREEN;
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
} else {
charaData.asleep = true;
charaData[currentCharacter].asleep = true;
vpet_computeCallLight(); // Lo hago por cortesia, no me gusta
@ -135,10 +145,10 @@ void menu_sleepScreen_sleepAction() {
void menu_sleepScreen_recalculateSleep() {
uint32_t newSleepTime = (dayUnixTime + 3600) % SECONDS_IN_DAY;
uint32_t newWakeUpTime = charaData.wakeupTime + 3600;
uint32_t newWakeUpTime = charaData[currentCharacter].wakeupTime + 3600;
charaData.sleepTime = newSleepTime;
charaData.wakeupTime = newWakeUpTime;
charaData[currentCharacter].sleepTime = newSleepTime;
charaData[currentCharacter].wakeupTime = newWakeUpTime;
charaData.dynamicSleepDists++;
charaData[currentCharacter].dynamicSleepDists++;
}

View File

@ -8,7 +8,7 @@ void menu_offScreen() {
if (buttons != 0) {
tft_drawBuffer();
digitalWrite(BL_PIN, HIGH);
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
} else {
screenOff = true;
}

View File

@ -22,7 +22,7 @@ void menu_clearPoopScreen(
}
screenKey = HAPPY_SCREEN;
charaData.poopNumber = 0;
charaData[currentCharacter].poopNumber = 0;
return;
}

View File

@ -5,19 +5,23 @@
#include "defs/chara_data.h"
#include "display/display.h"
uint8_t menu_poopOverlay(TFT_eSprite &sprite, struct SpriteData* smallUiElements) {
static bool poopFlip = false;
const uint8_t poopStartY = 120;
uint8_t poopStartX = 174;
bool poopTop = false;
uint8_t menu_poopOverlay(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* smallUiElements) {
if (charaData[currentCharacter].poopNumber > 0) {
static bool poopFlip = false;
const uint8_t poopStartY = 120;
uint8_t poopStartX = 174;
bool poopTop = false;
for (int i = 0; i < charaData[currentCharacter].poopNumber; i++) {
draw_drawSprite(sprite, poopStartX, poopStartY - (48 * poopTop), smallUiElements, POOP_ICON, 6, poopFlip);
poopStartX -= (i % 2) * 48;
poopTop = !poopTop;
}
for (int i = 0; i < charaData.poopNumber; i++) {
draw_drawSprite(sprite, poopStartX, poopStartY - (48 * poopTop), smallUiElements, POOP_ICON, 6, poopFlip);
poopStartX -= (i % 2) * 48;
poopTop = !poopTop;
poopFlip = !poopFlip;
return 222 - (poopStartX + ((charaData[currentCharacter].poopNumber % 2 == 0) * 48));
}
poopFlip = !poopFlip;
return 222 - (poopStartX + ((charaData.poopNumber % 2 == 0) * 48));
return 0;
}

View File

@ -60,13 +60,13 @@ void menu_poopScreen(
} else if (animationFrame >= 6) {
if (
(charaData.hunger == 0 && !charaData.hungerCareMistakeObtained) ||
(charaData.strength == 0 && !charaData.strengthCareMistakeObtained) ||
(charaData.sleepy && !charaData.asleep && !charaData.sleepCareMistakeObtained)
(charaData[currentCharacter].hunger == 0 && !charaData[currentCharacter].hungerCareMistakeObtained) ||
(charaData[currentCharacter].strength == 0 && !charaData[currentCharacter].strengthCareMistakeObtained) ||
(charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep && !charaData[currentCharacter].sleepCareMistakeObtained)
) {
screenKey = CARE_MISTAKE_SCREEN;
} else {
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
}
menuKey = 0;

View File

@ -43,7 +43,7 @@ void menu_refuseScreen(TFT_eSprite &bg, TFT_eSprite &mainChara, struct SpriteDat
if (currentAnimationFrame > 4) {
currentAnimationFrame = 0;
soundPlayed = false;
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
}
tft_drawBuffer();

View File

@ -7,10 +7,10 @@
#include "defs/chara_data.h"
void menu_sleepyScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* charaSprites, struct SpriteData* uiSprites) {
if (!charaData.asleep && !charaData.sleepy) {
screenKey = IDLE_SCREEN;
if (!charaData[currentCharacter].asleep && !charaData[currentCharacter].sleepy) {
screenKey = MAIN_SCREEN;
return;
} else if (charaData.asleep && charaData.sleepy) {
} else if (charaData[currentCharacter].asleep && charaData[currentCharacter].sleepy) {
screenKey = SLEEP_SCREEN;
return;
}

View File

@ -10,11 +10,11 @@ void menu_sleepingScreen(
TFT_eSprite &bg, TFT_eSprite &sprite,
struct SpriteData* mainCharaData, struct SpriteData* bigUiElements, struct SpriteData* smallUIElements
) {
if (charaData.sleepy && !charaData.asleep) {
if (charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep) {
screenKey = SLEEPY_SCREEN;
return;
} else if (!charaData.sleepy && !charaData.asleep) {
screenKey = IDLE_SCREEN;
} else if (!charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep) {
screenKey = MAIN_SCREEN;
return;
}

View File

@ -6,7 +6,7 @@
#include "display/display.h"
#include "draw/draw.h"
void menu_statusScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData, struct CharacterData* charaData) {
void menu_statusScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* spriteData) {
tft_clearBuffer(sprite, TFT_TRANSPARENT);
uint8_t pressedButtons = buttons_getPressedButtons();
@ -21,9 +21,9 @@ void menu_statusScreen(TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData*
draw_drawBackground(bg, 90, 90, 3);
menu_statusScreen_drawStat(sprite, spriteData, 10, 10, "Hunger", charaData->hunger);
menu_statusScreen_drawStat(sprite, spriteData, 10, 80, "Strength", charaData->strength);
menu_statusScreen_drawStat(sprite, spriteData, 10, 150, "Effort", charaData->effort);
menu_statusScreen_drawStat(sprite, spriteData, 10, 10, "Hunger", charaData[currentCharacter].hunger);
menu_statusScreen_drawStat(sprite, spriteData, 10, 80, "Strength", charaData[currentCharacter].strength);
menu_statusScreen_drawStat(sprite, spriteData, 10, 150, "Effort", charaData[currentCharacter].effort);
tft_drawBuffer();
}

View File

@ -5,11 +5,13 @@
#include "buttons/buttons.h"
#include "display/display.h"
#include "draw/draw.h"
#include "loop/loop.h"
void training_screenTraining1(
TFT_eSprite &bg, TFT_eSprite &sprite,
struct SpriteData* mainCharaData, struct SpriteData* attackSprites
) {
draw_drawBackground(bg, 90, 90, 3);
draw_drawSpriteCentered(sprite, mainCharaData, 11, 6);
@ -28,15 +30,24 @@ void training_screenTraining1(
uint8_t attackPower = 0;
uint64_t currentTime = lastUpdateTime = esp_timer_get_time();
int16_t lineYPos = 0;
bool counted = false;
while (currentTime - lastUpdateTime < 8000000) {
while (currentTime - lastUpdateTime < 5000000) {
currentTime = esp_timer_get_time();
uint8_t buttonsRead = buttons_getPressedButtons();
switch (buttonsRead) {
case 8:
case 8:
attackPower++;
if (attackPower % 4 == 0) {
tft_drawRectangle(18, 168 - lineYPos, 18, 6, TFT_BLACK);
tft_drawBuffer();
lineYPos += 8;
} else {
delay(15);
}
break;
case 2:
@ -63,6 +74,9 @@ void training_screenTraining1(
attackResult = ATTACK_PATTERN_MEDIOCRE;
}
loop_pauseLoop();
training_displayTrainingResult(bg, sprite, mainCharaData, attackSprites, attackResult);
loop_resumeLoop();
}

View File

@ -17,7 +17,7 @@ void menu_uiOverlay(TFT_eSprite &charSprite, struct SpriteData* uiElements) {
snprintf(hourBuffer, 6, "%05d", stepCounter);
tft_drawText(hourBuffer, 2, 176, 4, TFT_WHITE);
if (charaData.careMistakeCallLight) {
if (charaData[currentCharacter].careMistakeCallLight) {
tft_clearBuffer(charSprite, TFT_TRANSPARENT);
draw_drawSprite(charSprite, 192, 192, uiElements, CARE_MISTAKE_CALL_LIGHT, 2);
}

View File

@ -22,18 +22,30 @@ void storage_readFile(const char* path, struct SpriteData* spriteData) {
size_t bytesRead = 0;
size_t fileSize = file.size();
bytesRead += file.read(&spriteData->spriteWidth, 1);
bytesRead += file.read(&spriteData->spriteHeight, 1);
bytesRead += file.read(&spriteData->spriteNumber, 1);
printf("%s Read header: width=%d, height=%d, numSprites=%d\n",
TAG_S, spriteData->spriteWidth, spriteData->spriteHeight, spriteData->spriteNumber);
uint8_t width, height, spriteNumber;
bytesRead += file.read(&width, 1);
bytesRead += file.read(&height, 1);
bytesRead += file.read(&spriteNumber, 1);
if (spriteData->spriteData != NULL) {
memory_free(spriteData);
}
spriteData->spriteWidth = width;
spriteData->spriteHeight = height;
spriteData->spriteNumber = spriteNumber;
spriteData->spriteData = memory_allocate(spriteData->spriteNumber, spriteData->spriteWidth, spriteData->spriteHeight);
printf(
"%s Read header: width=%d, height=%d, numSprites=%d\n",
TAG_S, spriteData->spriteWidth, spriteData->spriteHeight, spriteData->spriteNumber
);
fileSize = (fileSize - 3) / sizeof(uint16_t);
spriteData->spriteData = memory_allocate(spriteData->spriteNumber, spriteData->spriteWidth, spriteData->spriteHeight);
size_t bufferSize = spriteData->spriteNumber * spriteData->spriteWidth * spriteData->spriteHeight;
uint8_t highByte;

View File

@ -6,12 +6,12 @@
bool change_onChangeTimerComplete() {
for (int i = 0; i < currentLineCareInstr[currentCharacter]->numCareMistakesData; i++) {
if (
charaData.idChara == currentLineCareInstr[currentCharacter]->careMistakeData[i].currentChara &&
charaData[currentCharacter].idChara == currentLineCareInstr[currentCharacter]->careMistakeData[i].currentChara &&
change_evalCharacter(i)
) {
change_replaceCharaData(currentLineCareInstr[currentCharacter]->careMistakeData[i].nextChara);
change_resetRuntimeStats();
return true;
}
}
@ -21,26 +21,26 @@ bool change_onChangeTimerComplete() {
bool change_evalCharacter(uint8_t nextCharaId) {
CareMistakes_t* currentEvalCharacter = &(currentLineCareInstr[currentCharacter]->careMistakeData[nextCharaId]);
printf("[EVAL] cm=%i, of=%i, sd=%i, ef=%i\n", charaData.careMistakes, charaData.overfeed, charaData.sleepDisturbances, charaData.effort);
printf("[EVAL] cm=%i, of=%i, sd=%i, ef=%i\n", charaData[currentCharacter].careMistakes, charaData[currentCharacter].overfeed, charaData[currentCharacter].sleepDisturbances, charaData[currentCharacter].effort);
printf("[EVAL] MIN cm=%i, of=%i, sd=%i, ef=%i\n", currentEvalCharacter->minCareMistake, currentEvalCharacter->minOverfeeds, currentEvalCharacter->minSleepDist, currentEvalCharacter->minTraining);
printf("[EVAL] MAX cm=%i, of=%i, sd=%i, ef=%i\n", currentEvalCharacter->maxCareMistake, currentEvalCharacter->maxOverfeeds, currentEvalCharacter->maxSleepDist, currentEvalCharacter->maxTraining);
printf("[EVAL] stb=%i stw=%i\n", charaData.stageTotalBattled, charaData.stageTotalWon);
printf("[EVAL] stb=%i stw=%i\n", charaData[currentCharacter].stageTotalBattled, charaData[currentCharacter].stageTotalWon);
printf("[EVAL] MIN stb=%i stw=%i\n", currentEvalCharacter->totalBattles, currentEvalCharacter->wonBattles);
printf("[EVAL] NextID=%i\n", currentEvalCharacter->nextChara);
bool retV = (
(charaData.careMistakes >= currentEvalCharacter->minCareMistake) &&
(charaData.careMistakes <= currentEvalCharacter->maxCareMistake) &&
(charaData.overfeed >= currentEvalCharacter->minOverfeeds) &&
(charaData.overfeed <= currentEvalCharacter->maxOverfeeds) &&
(charaData.sleepDisturbances >= currentEvalCharacter->minSleepDist) &&
(charaData.sleepDisturbances <= currentEvalCharacter->maxSleepDist) &&
(charaData.effort >= currentEvalCharacter->minTraining) &&
(charaData.effort <= currentEvalCharacter->maxTraining) &&
(charaData.stageTotalBattled >= currentEvalCharacter->totalBattles) &&
(charaData.stageTotalWon >= currentEvalCharacter->wonBattles)
(charaData[currentCharacter].careMistakes >= currentEvalCharacter->minCareMistake) &&
(charaData[currentCharacter].careMistakes <= currentEvalCharacter->maxCareMistake) &&
(charaData[currentCharacter].overfeed >= currentEvalCharacter->minOverfeeds) &&
(charaData[currentCharacter].overfeed <= currentEvalCharacter->maxOverfeeds) &&
(charaData[currentCharacter].sleepDisturbances >= currentEvalCharacter->minSleepDist) &&
(charaData[currentCharacter].sleepDisturbances <= currentEvalCharacter->maxSleepDist) &&
(charaData[currentCharacter].effort >= currentEvalCharacter->minTraining) &&
(charaData[currentCharacter].effort <= currentEvalCharacter->maxTraining) &&
(charaData[currentCharacter].stageTotalBattled >= currentEvalCharacter->totalBattles) &&
(charaData[currentCharacter].stageTotalWon >= currentEvalCharacter->wonBattles)
);
printf("[EVAL] Res %i\n", retV);
@ -50,40 +50,40 @@ bool change_evalCharacter(uint8_t nextCharaId) {
void change_replaceCharaData(uint8_t nextCharaId) {
LineChara_t* currentEvalCharacter = &(currentLine[currentCharacter]->characters[nextCharaId]);
charaData.idChara = nextCharaId;
charaData.hp = currentEvalCharacter->hp;
charaData.bp = currentEvalCharacter->bp;
charaData.ap = currentEvalCharacter->ap;
charaData.stage = currentEvalCharacter->stage;
charaData.attribute = currentEvalCharacter->attribute;
charaData.spriteAttackId = currentEvalCharacter->attackSprite;
charaData.initialSleepTime = currentEvalCharacter->sleepTime;
charaData.initialWakeupTime = currentEvalCharacter->wakeTime;
charaData.initialChangeTimer = currentEvalCharacter->changeTime;
charaData.initialStatsReductionTime = currentEvalCharacter->depleteTime;
charaData.minWeight = currentEvalCharacter->minWeight;
charaData[currentCharacter].idChara = nextCharaId;
charaData[currentCharacter].hp = currentEvalCharacter->hp;
charaData[currentCharacter].bp = currentEvalCharacter->bp;
charaData[currentCharacter].ap = currentEvalCharacter->ap;
charaData[currentCharacter].stage = currentEvalCharacter->stage;
charaData[currentCharacter].attribute = currentEvalCharacter->attribute;
charaData[currentCharacter].spriteAttackId = currentEvalCharacter->attackSprite;
charaData[currentCharacter].initialSleepTime = currentEvalCharacter->sleepTime;
charaData[currentCharacter].initialWakeupTime = currentEvalCharacter->wakeTime;
charaData[currentCharacter].initialChangeTimer = currentEvalCharacter->changeTime;
charaData[currentCharacter].initialStatsReductionTime = currentEvalCharacter->depleteTime;
charaData[currentCharacter].minWeight = currentEvalCharacter->minWeight;
}
void change_resetRuntimeStats() {
charaData.careMistakes = 0;
charaData.effort = 0;
charaData.overfeed = 0;
charaData.sleepDisturbances = 0;
charaData.injuries = 0;
charaData[currentCharacter].careMistakes = 0;
charaData[currentCharacter].effort = 0;
charaData[currentCharacter].overfeed = 0;
charaData[currentCharacter].sleepDisturbances = 0;
charaData[currentCharacter].injuries = 0;
charaData.stageTotalBattled = 0;
charaData.stageTotalWon = 0;
charaData[currentCharacter].stageTotalBattled = 0;
charaData[currentCharacter].stageTotalWon = 0;
charaData.dynamicSleepDists = 0;
charaData[currentCharacter].dynamicSleepDists = 0;
charaData.sleepTime = charaData.initialSleepTime;
charaData.wakeupTime = charaData.initialWakeupTime;
charaData.changeTimerLeft = charaData.initialChangeTimer;
charaData[currentCharacter].sleepTime = charaData[currentCharacter].initialSleepTime;
charaData[currentCharacter].wakeupTime = charaData[currentCharacter].initialWakeupTime;
charaData[currentCharacter].changeTimerLeft = charaData[currentCharacter].initialChangeTimer;
}
void change_onChangeComplete() {
char spriteFileName[30];
snprintf(spriteFileName, 30, "/chara/%02x.bin", charaData.idChara);
snprintf(spriteFileName, 30, "/chara/%02x.bin", charaData[currentCharacter].idChara);
storage_readFile(spriteFileName, &mainCharacterSprites);
}

View File

@ -15,26 +15,26 @@ void lines_onHatchComplete() {
storage_readFile(spriteFileName, &mainCharacterSprites);
// Primero los datos del bicho actual en nuestra estructura de datos de confianza
charaData.hp = currentLine[currentCharacter]->characters[0].hp;
charaData.bp = currentLine[currentCharacter]->characters[0].bp;
charaData.ap = currentLine[currentCharacter]->characters[0].ap;
charaData[currentCharacter].hp = currentLine[currentCharacter]->characters[0].hp;
charaData[currentCharacter].bp = currentLine[currentCharacter]->characters[0].bp;
charaData[currentCharacter].ap = currentLine[currentCharacter]->characters[0].ap;
charaData.stage = currentLine[currentCharacter]->characters[0].stage;
charaData.attribute = currentLine[currentCharacter]->characters[0].attribute;
charaData.spriteAttackId = currentLine[currentCharacter]->characters[0].attackSprite;
charaData[currentCharacter].stage = currentLine[currentCharacter]->characters[0].stage;
charaData[currentCharacter].attribute = currentLine[currentCharacter]->characters[0].attribute;
charaData[currentCharacter].spriteAttackId = currentLine[currentCharacter]->characters[0].attackSprite;
charaData.sleepTime = charaData.initialSleepTime = currentLine[currentCharacter]->characters[0].sleepTime;
charaData.wakeupTime = charaData.initialWakeupTime = currentLine[currentCharacter]->characters[0].wakeTime;
charaData.initialChangeTimer = charaData.changeTimerLeft = currentLine[currentCharacter]->characters[0].changeTime;
charaData[currentCharacter].sleepTime = charaData[currentCharacter].initialSleepTime = currentLine[currentCharacter]->characters[0].sleepTime;
charaData[currentCharacter].wakeupTime = charaData[currentCharacter].initialWakeupTime = currentLine[currentCharacter]->characters[0].wakeTime;
charaData[currentCharacter].initialChangeTimer = charaData[currentCharacter].changeTimerLeft = currentLine[currentCharacter]->characters[0].changeTime;
charaData.initialStatsReductionTime = currentLine[currentCharacter]->characters[0].depleteTime;
charaData.minWeight = currentLine[currentCharacter]->characters[0].minWeight;
charaData[currentCharacter].initialStatsReductionTime = currentLine[currentCharacter]->characters[0].depleteTime;
charaData[currentCharacter].minWeight = currentLine[currentCharacter]->characters[0].minWeight;
// Luego le obligamos a que nazca con hambre
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
charaData[currentCharacter].hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
charaData[currentCharacter].strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
charaData.hatched = true;
charaData[currentCharacter].hatched = true;
vpet_computeCallLight();

View File

@ -16,10 +16,8 @@ void training_displayTrainingResult(
TFT_eSprite &bg, TFT_eSprite &sprite,
struct SpriteData* mainCharaData, struct SpriteData* attackSprites, uint8_t trainingResult
) {
pauseLoop = true;
charaData.effort++;
charaData.strengthCareMistakeTimer = charaData.initialChangeTimer;
charaData[currentCharacter].effort++;
charaData[currentCharacter].strengthCareMistakeTimer = charaData[currentCharacter].initialChangeTimer;
uint8_t* pattern = NULL;
switch (trainingResult) {
@ -27,10 +25,10 @@ void training_displayTrainingResult(
pattern = patternExcellent;
screenKey = HAPPY_SCREEN;
charaData.strength += 2;
charaData.weight -= 4;
if (charaData.weight < charaData.minWeight) {
charaData.weight -= charaData.minWeight;
charaData[currentCharacter].strength += 2;
charaData[currentCharacter].weight -= 4;
if (charaData[currentCharacter].weight < charaData[currentCharacter].minWeight) {
charaData[currentCharacter].weight -= charaData[currentCharacter].minWeight;
}
break;
@ -39,10 +37,10 @@ void training_displayTrainingResult(
pattern = patternGreat;
screenKey = HAPPY_SCREEN;
charaData.strength += 2;
charaData.weight -= 2;
if (charaData.weight < charaData.minWeight) {
charaData.weight = charaData.minWeight;
charaData[currentCharacter].strength += 2;
charaData[currentCharacter].weight -= 2;
if (charaData[currentCharacter].weight < charaData[currentCharacter].minWeight) {
charaData[currentCharacter].weight = charaData[currentCharacter].minWeight;
}
break;
@ -51,21 +49,21 @@ void training_displayTrainingResult(
pattern = patternGood;
screenKey = HAPPY_SCREEN;
charaData.strength += 1;
charaData.weight -= 2;
if (charaData.weight < charaData.minWeight) {
charaData.weight = charaData.minWeight;
charaData[currentCharacter].strength += 1;
charaData[currentCharacter].weight -= 2;
if (charaData[currentCharacter].weight < charaData[currentCharacter].minWeight) {
charaData[currentCharacter].weight = charaData[currentCharacter].minWeight;
}
break;
case ATTACK_PATTERN_BAD:
pattern = patternBad;
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
charaData.weight--;
if (charaData.weight < charaData.minWeight) {
charaData.weight = charaData.minWeight;
charaData[currentCharacter].weight--;
if (charaData[currentCharacter].weight < charaData[currentCharacter].minWeight) {
charaData[currentCharacter].weight = charaData[currentCharacter].minWeight;
}
break;
@ -73,19 +71,17 @@ void training_displayTrainingResult(
case ATTACK_PATTERN_MEDIOCRE:
default:
pattern = patternMediocre;
screenKey = IDLE_SCREEN;
screenKey = MAIN_SCREEN;
break;
}
for (int i = 0; i < NUM_ROUNDS; i++) {
training_trainingAttackSounds();
for (int j = 78; j >= 0; j -= 6) {
for (int j = 78; j >= -48; j -= 6) {
draw_drawBackground(bg, 90, 90, 3);
draw_drawSprite(sprite, 126, 72, mainCharaData, 11, 6);
tft_clearBuffer(sprite, TFT_TRANSPARENT);
draw_drawAttacks(sprite, attackSprites, j, 72, pattern[i], charaData.spriteAttackId, 6);
tft_clearBuffer(sprite, TFT_TRANSPARENT);
draw_drawAttacks(sprite, attackSprites, j, 72, pattern[i], charaData[currentCharacter].spriteAttackId, 6);
tft_drawBuffer();
}
@ -95,7 +91,6 @@ void training_displayTrainingResult(
lastPressedButtonTime = esp_timer_get_time();
pauseLoop = false;
}
// nOT FANCY

View File

@ -2,6 +2,7 @@
#include "defs/defs.h"
#include "defs/chara_data.h"
#include "vpet/evolution/evolution.h"
#include "loop/loop.h"
hw_timer_t *actionTimerDelta = NULL;
bool runVpetTasks = false;
@ -17,10 +18,10 @@ void vpet_initTimer() {
}
void vpet_computeCallLight() {
charaData.careMistakeCallLight = (
(charaData.hunger == 0 && !charaData.hungerCareMistakeObtained) ||
(charaData.strength == 0 && !charaData.strengthCareMistakeObtained) ||
(charaData.sleepy && !charaData.asleep && !charaData.sleepCareMistakeObtained)
charaData[currentCharacter].careMistakeCallLight = (
(charaData[currentCharacter].hunger == 0 && !charaData[currentCharacter].hungerCareMistakeObtained) ||
(charaData[currentCharacter].strength == 0 && !charaData[currentCharacter].strengthCareMistakeObtained) ||
(charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep && !charaData[currentCharacter].sleepCareMistakeObtained)
);
}
@ -28,70 +29,70 @@ bool vpet_evalSleep(uint8_t diff_sec) {
// Se devuelve true si quieres pausar los otros contadores
// False ejecutara los contadores correspondientes
if (
dayUnixTime < charaData.sleepTime &&
dayUnixTime > charaData.wakeupTime &&
charaData.sleepy
dayUnixTime < charaData[currentCharacter].sleepTime &&
dayUnixTime > charaData[currentCharacter].wakeupTime &&
charaData[currentCharacter].sleepy
// Esto se ejecuta cuando ya es hora de despertarse
// Resultado el personaje se despierta
) {
charaData.sleepCareMistakeCounter = 0;
charaData.sleepCareMistakeObtained = false;
charaData.gotLifeYearAdded = false;
charaData[currentCharacter].sleepCareMistakeCounter = 0;
charaData[currentCharacter].sleepCareMistakeObtained = false;
charaData[currentCharacter].gotLifeYearAdded = false;
charaData.sleepy = false;
charaData.asleep = false;
charaData[currentCharacter].sleepy = false;
charaData[currentCharacter].asleep = false;
if (charaData.dynamicSleepDists > 0) {
if (charaData[currentCharacter].dynamicSleepDists > 0) {
// Primero, el sleep time ahora está reventado, hay que restaurarlo
// fácil, simplemente recalcula a la hora de despertar
charaData.dynamicSleepDists--;
charaData[currentCharacter].dynamicSleepDists--;
charaData.sleepTime = (charaData.initialSleepTime + (charaData.dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
charaData.wakeupTime = (charaData.initialWakeupTime + (charaData.dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
charaData[currentCharacter].sleepTime = (charaData[currentCharacter].initialSleepTime + (charaData[currentCharacter].dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
charaData[currentCharacter].wakeupTime = (charaData[currentCharacter].initialWakeupTime + (charaData[currentCharacter].dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
}
return false;
} else if (
dayUnixTime < charaData.sleepTime &&
dayUnixTime > charaData.wakeupTime &&
charaData.asleep &&
charaData.sleepCareMistakeCounter < SLEEP_COUNTER_MAX
dayUnixTime < charaData[currentCharacter].sleepTime &&
dayUnixTime > charaData[currentCharacter].wakeupTime &&
charaData[currentCharacter].asleep &&
charaData[currentCharacter].sleepCareMistakeCounter < SLEEP_COUNTER_MAX
// Esto se ejecuta cuando mandamos a dormir al personaje
// durante el dia.
// Resultado, el personaje deberia de dormir una siesta
) {
charaData.sleepCareMistakeCounter += diff_sec;
charaData[currentCharacter].sleepCareMistakeCounter += diff_sec;
return true;
} else if (
dayUnixTime < charaData.sleepTime &&
dayUnixTime > charaData.wakeupTime &&
charaData.asleep &&
charaData.sleepCareMistakeCounter >= SLEEP_COUNTER_MAX
dayUnixTime < charaData[currentCharacter].sleepTime &&
dayUnixTime > charaData[currentCharacter].wakeupTime &&
charaData[currentCharacter].asleep &&
charaData[currentCharacter].sleepCareMistakeCounter >= SLEEP_COUNTER_MAX
// Esto se ejecuta cuando la siesta del personaje acaba
// Resultado, el personaje se despierta
) {
charaData.sleepCareMistakeCounter = 0;
charaData.asleep = false;
charaData[currentCharacter].sleepCareMistakeCounter = 0;
charaData[currentCharacter].asleep = false;
return false;
} else if (
(
dayUnixTime > charaData.sleepTime ||
dayUnixTime < charaData.wakeupTime
dayUnixTime > charaData[currentCharacter].sleepTime ||
dayUnixTime < charaData[currentCharacter].wakeupTime
) &&
!charaData.sleepy
!charaData[currentCharacter].sleepy
// Esto se ejecuta cuando la hora actual del sistema
// está en el intervalo temporal de las horas el las que el
// personaje duerme
// Resultado: el personaje se duerme, y se llama a la pantalla
// de se acabo el temporizador, ademas activa la call light
) {
charaData.sleepy = true;
charaData.careMistakeCallLight = true;
charaData[currentCharacter].sleepy = true;
charaData[currentCharacter].careMistakeCallLight = true;
screenKey = TIMER_FINISHED_SCREEN;
interruptKey = SLEEPY_SCREEN;
@ -99,45 +100,45 @@ bool vpet_evalSleep(uint8_t diff_sec) {
return true;
} else if (
charaData.sleepy && !charaData.asleep &&
charaData.sleepCareMistakeCounter < SLEEP_COUNTER_MAX &&
!charaData.sleepCareMistakeObtained
charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep &&
charaData[currentCharacter].sleepCareMistakeCounter < SLEEP_COUNTER_MAX &&
!charaData[currentCharacter].sleepCareMistakeObtained
// Esto se ejecuta cuando el personaje debería de estar durmiendo
// pero no se le ha mandado a dormir, empieza a contar para pasar
// un care mistake
) {
charaData.sleepCareMistakeCounter += diff_sec;
charaData[currentCharacter].sleepCareMistakeCounter += diff_sec;
return true;
} else if (
charaData.sleepy && !charaData.asleep &&
charaData.sleepCareMistakeCounter >= SLEEP_COUNTER_MAX &&
!charaData.sleepCareMistakeObtained
charaData[currentCharacter].sleepy && !charaData[currentCharacter].asleep &&
charaData[currentCharacter].sleepCareMistakeCounter >= SLEEP_COUNTER_MAX &&
!charaData[currentCharacter].sleepCareMistakeObtained
// Esto se ejecuta cuando el personaje deberia de estar durmiendo
// pero no se le ha mandado a dormir, y el contador ya ha llegado
// al tiempo maximo
// Resultado: se añade el care mistake y se activa la flag para
// evitar otro care mistake
) {
charaData.sleepCareMistakeObtained = true;
charaData.careMistakes++;
charaData[currentCharacter].sleepCareMistakeObtained = true;
charaData[currentCharacter].careMistakes++;
return true;
} else if (
!charaData.gotLifeYearAdded &&
!charaData[currentCharacter].gotLifeYearAdded &&
dayUnixTime < 60 // This stinks
// Esto se ejecuta cuando es media noche.
// Resultado: se incrementa la edad por 1
) {
charaData.age++;
charaData.gotLifeYearAdded = true;
charaData[currentCharacter].age++;
charaData[currentCharacter].gotLifeYearAdded = true;
return true;
} else if (
charaData.sleepy
charaData[currentCharacter].sleepy
) {
return true;
}
@ -152,64 +153,64 @@ void vpet_evalTimers() {
}
void vpet_reduceTimers(uint8_t diff_sec) {
if (charaData.hungerCareMistakeTimer > 0) {
charaData.hungerCareMistakeTimer -= diff_sec;
if (charaData[currentCharacter].hungerCareMistakeTimer > 0) {
charaData[currentCharacter].hungerCareMistakeTimer -= diff_sec;
}
if (charaData.strengthCareMistakeTimer > 0) {
charaData.strengthCareMistakeTimer -= diff_sec;
if (charaData[currentCharacter].strengthCareMistakeTimer > 0) {
charaData[currentCharacter].strengthCareMistakeTimer -= diff_sec;
}
if (charaData.changeTimerLeft > 0) {
charaData.changeTimerLeft -= diff_sec;
if (charaData[currentCharacter].changeTimerLeft > 0) {
charaData[currentCharacter].changeTimerLeft -= diff_sec;
}
}
void vpet_evalHungerTimer() {
if (
charaData.hungerCareMistakeTimer <= 0 &&
charaData.hunger > 0
charaData[currentCharacter].hungerCareMistakeTimer <= 0 &&
charaData[currentCharacter].hunger > 0
) {
charaData.hunger--;
charaData[currentCharacter].hunger--;
if (charaData.hunger > 0) {
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
if (charaData[currentCharacter].hunger > 0) {
charaData[currentCharacter].hungerCareMistakeTimer = charaData[currentCharacter].initialStatsReductionTime;
screenKey = TIMER_FINISHED_SCREEN;
interruptKey = POOPING_SCREEN;
} else {
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
charaData[currentCharacter].hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
screenKey = TIMER_FINISHED_SCREEN;
interruptKey = CARE_MISTAKE_SCREEN;
}
if (charaData.poopNumber < 8) {
charaData.poopNumber++;
if (charaData[currentCharacter].poopNumber < 8) {
charaData[currentCharacter].poopNumber++;
} else {
charaData.injured = true;
charaData.injuries++;
charaData[currentCharacter].injured = true;
charaData[currentCharacter].injuries++;
}
} else if (
charaData.hungerCareMistakeTimer <= 0 &&
charaData.hunger == 0 &&
!charaData.hungerCareMistakeObtained
charaData[currentCharacter].hungerCareMistakeTimer <= 0 &&
charaData[currentCharacter].hunger == 0 &&
!charaData[currentCharacter].hungerCareMistakeObtained
) {
charaData.hungerCareMistakeObtained = true;
charaData.careMistakes++;
charaData[currentCharacter].hungerCareMistakeObtained = true;
charaData[currentCharacter].careMistakes++;
}
}
void vpet_evalStrengthTimer() {
if (
charaData.strengthCareMistakeTimer <= 0 &&
charaData.strength > 0
charaData[currentCharacter].strengthCareMistakeTimer <= 0 &&
charaData[currentCharacter].strength > 0
) {
charaData.strength--;
if (charaData.strength > 0) {
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
charaData[currentCharacter].strength--;
if (charaData[currentCharacter].strength > 0) {
charaData[currentCharacter].strengthCareMistakeTimer = charaData[currentCharacter].initialStatsReductionTime;
} else {
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
charaData[currentCharacter].strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
if (interruptKey != POOPING_SCREEN) {
interruptKey = CARE_MISTAKE_SCREEN;
screenKey = TIMER_FINISHED_SCREEN;
@ -217,22 +218,22 @@ void vpet_evalStrengthTimer() {
}
} else if (
charaData.strengthCareMistakeTimer <= 0 &&
charaData.strength == 0 &&
!charaData.strengthCareMistakeObtained
charaData[currentCharacter].strengthCareMistakeTimer <= 0 &&
charaData[currentCharacter].strength == 0 &&
!charaData[currentCharacter].strengthCareMistakeObtained
) {
charaData.strengthCareMistakeObtained = true;
charaData.careMistakes++;
charaData[currentCharacter].strengthCareMistakeObtained = true;
charaData[currentCharacter].careMistakes++;
}
}
void vpet_evalChangeTimer() {
if (charaData.changeTimerLeft <= 0) {
if (charaData[currentCharacter].changeTimerLeft <= 0) {
if (change_onChangeTimerComplete()) {
screenKey = TIMER_FINISHED_SCREEN;
interruptKey = EVOLUTION_SCREEN;
pauseLoop = true;
}
}
@ -250,7 +251,7 @@ void vpet_runVpetTasks() {
uint64_t deltaUs = currentEvaluationTime - vpetLastEvaluationTime;
uint8_t diffSec = (deltaUs + 1000000 - 1000) / 1000000;
if (charaData.hatched) {
if (charaData[currentCharacter].hatched) {
vpet_computeCallLight();
if (!vpet_evalSleep(diffSec)) {
@ -260,10 +261,10 @@ void vpet_runVpetTasks() {
vpet_evalChangeTimer();
} else if (!charaData.hatched && charaData.hatching) {
charaData.hatchTimer += diffSec;
} else if (!charaData[currentCharacter].hatched && charaData[currentCharacter].hatching) {
charaData[currentCharacter].hatchTimer += diffSec;
if (charaData.hatchTimer > currentLine[currentCharacter]->hatchTime) {
if (charaData[currentCharacter].hatchTimer > currentLine[currentCharacter]->hatchTime) {
interruptKey = EGG_HATCH_SCREEN;
screenKey = TIMER_FINISHED_SCREEN;
}
@ -278,16 +279,16 @@ void vpet_runVpetTasks() {
}
void vpet_debugTimers(uint8_t diffSec) {
if (charaData.hatched) {
printf("[MAIN]: Hunger timer %d, hunger %d\n", charaData.hungerCareMistakeTimer, charaData.hunger);
printf("[MAIN]: Strength timer %d, strength %d\n", charaData.strengthCareMistakeTimer, charaData.strength);
printf("[MAIN]: Change timer %d\n", charaData.changeTimerLeft);
if (charaData[currentCharacter].hatched) {
printf("[MAIN]: Hunger timer %d, hunger %d\n", charaData[currentCharacter].hungerCareMistakeTimer, charaData[currentCharacter].hunger);
printf("[MAIN]: Strength timer %d, strength %d\n", charaData[currentCharacter].strengthCareMistakeTimer, charaData[currentCharacter].strength);
printf("[MAIN]: Change timer %d\n", charaData[currentCharacter].changeTimerLeft);
printf("[MAIN]: RTC time is %d\n", dayUnixTime);
printf("[MAIN]: Sleep counter is %d\n", charaData.sleepCareMistakeCounter);
printf("[MAIN]: Care mistake count is %d\n", charaData.careMistakes);
printf("[MAIN]: Is sleep care mistake tripped? %d\n", charaData.sleepCareMistakeObtained);
} else if(!charaData.hatched && charaData.hatching) {
printf("[DEBUG] hatchTimer=%i out of hatchTimer=%i\n", charaData.hatchTimer, currentLine[currentCharacter]->hatchTime);
printf("[MAIN]: Sleep counter is %d\n", charaData[currentCharacter].sleepCareMistakeCounter);
printf("[MAIN]: Care mistake count is %d\n", charaData[currentCharacter].careMistakes);
printf("[MAIN]: Is sleep care mistake tripped? %d\n", charaData[currentCharacter].sleepCareMistakeObtained);
} else if(!charaData[currentCharacter].hatched && charaData[currentCharacter].hatching) {
printf("[DEBUG] hatchTimer=%i out of hatchTimer=%i\n", charaData[currentCharacter].hatchTimer, currentLine[currentCharacter]->hatchTime);
}
}