Add time fine tuning vars

This commit is contained in:
Tomislav Kopić 2024-06-12 20:23:07 +02:00
parent 45a827f016
commit ba21da0fab

View File

@ -25,6 +25,15 @@
//#define ENABLE_LOAD_HARCODED_STATE_WHEN_START //#define ENABLE_LOAD_HARCODED_STATE_WHEN_START
/***************************/ /***************************/
/***** Time and clock *****/
#define EMULATOR_CLOCK_SPEED 1002702 // this values seems to be diferent for every single board but generaly is around 1002700
// If game time is going faster than it should, increase this value by 1 to slow it down.
// fixed microsecond sleep between each frame used to fine tune the emulator time drift
#define FINE_TUNING_DELAY 24
// If game time is going faster than it should, increase this value
/**************************************************************************/
/***** Set display orientation, U8G2_MIRROR_VERTICAL is not supported *****/ /***** Set display orientation, U8G2_MIRROR_VERTICAL is not supported *****/
//#define U8G2_LAYOUT_NORMAL //#define U8G2_LAYOUT_NORMAL
#define U8G2_LAYOUT_ROTATE_180 #define U8G2_LAYOUT_ROTATE_180
@ -72,7 +81,7 @@ static void hal_sleep_until(timestamp_t ts) {
if (remaining > 0) { if (remaining > 0) {
delayMicroseconds(remaining); delayMicroseconds(remaining);
} }
delayMicroseconds(24); // fixed delay to compensate for emulator time drifting delayMicroseconds(FINE_TUNING_DELAY); // fixed delay to compensate for emulator time drifting
#endif #endif
} }
@ -335,7 +344,7 @@ void setup() {
tamalib_register_hal(&hal); tamalib_register_hal(&hal);
tamalib_set_framerate(TAMA_DISPLAY_FRAMERATE); tamalib_set_framerate(TAMA_DISPLAY_FRAMERATE);
// Tamagochi clock init // Tamagochi clock init
tamalib_init(1002700); tamalib_init(EMULATOR_CLOCK_SPEED);
#if defined(ENABLE_SAVE_STATUS) || defined(AUTO_SAVE_MINUTES) || defined(ENABLE_LOAD_STATE_FROM_EEPROM) #if defined(ENABLE_SAVE_STATUS) || defined(AUTO_SAVE_MINUTES) || defined(ENABLE_LOAD_STATE_FROM_EEPROM)
initEEPROM(); initEEPROM();