Removed remaining get_elapsed_time references
This commit is contained in:
parent
be15c42dd3
commit
33104aa248
@ -6,7 +6,7 @@ macro(rg_setup_compile_options)
|
||||
set(RG_TARGET "RG_TARGET_$ENV{RG_TARGET}")
|
||||
message("Target: ${RG_TARGET}")
|
||||
|
||||
component_compile_options(-D${RG_TARGET} ${ARGV})
|
||||
component_compile_options(-DRETRO_GO -D${RG_TARGET} ${ARGV})
|
||||
|
||||
if(NOT ";${ARGV};" MATCHES ";-O[0123gs];")
|
||||
# Only default to -O3 if not specified by the app
|
||||
|
||||
@ -183,8 +183,8 @@ void rg_audio_submit(int16_t *stereoAudioBuffer, size_t frameCount)
|
||||
|
||||
if (audioSink == RG_AUDIO_SINK_DUMMY)
|
||||
{
|
||||
usleep(RG_MAX(dummyBusyUntil - get_elapsed_time(), 1000));
|
||||
dummyBusyUntil = get_elapsed_time() + ((audioSampleRate * 1000) / sampleCount);
|
||||
usleep(RG_MAX(dummyBusyUntil - rg_system_timer(), 1000));
|
||||
dummyBusyUntil = rg_system_timer() + ((audioSampleRate * 1000) / sampleCount);
|
||||
written = bufferSize;
|
||||
}
|
||||
else if (audioSink == RG_AUDIO_SINK_SPEAKER)
|
||||
|
||||
@ -578,7 +578,7 @@ int rg_gui_dialog(const char *header, const rg_gui_option_t *options_const, int
|
||||
while (event != RG_DIALOG_CLOSE)
|
||||
{
|
||||
// TO DO: Add acceleration!
|
||||
joystick_old = (get_elapsed_time_since(joystick_last) > 300000) ? 0 : joystick;
|
||||
joystick_old = ((rg_system_timer() - joystick_last) > 300000) ? 0 : joystick;
|
||||
joystick = rg_input_read_gamepad();
|
||||
event = RG_DIALOG_VOID;
|
||||
|
||||
@ -621,7 +621,7 @@ int rg_gui_dialog(const char *header, const rg_gui_option_t *options_const, int
|
||||
sel = -1;
|
||||
}
|
||||
|
||||
joystick_last = get_elapsed_time();
|
||||
joystick_last = rg_system_timer();
|
||||
}
|
||||
|
||||
if (sel_old != sel)
|
||||
@ -956,7 +956,7 @@ int rg_gui_about_menu(const rg_gui_option_t *extra_options)
|
||||
}
|
||||
break;
|
||||
case 3000:
|
||||
unlink(rg_system_get_path(NULL, RG_PATH_CACHE_FILE, "crc32.bin"));
|
||||
unlink(RG_BASE_PATH_CACHE "/crc32.bin");
|
||||
rg_system_restart();
|
||||
break;
|
||||
case 4000:
|
||||
@ -1002,7 +1002,7 @@ int rg_gui_debug_menu(const rg_gui_option_t *extra_options)
|
||||
sprintf(stack_hwm, "%d", stats.freeStackMain);
|
||||
sprintf(heap_free, "%d+%d", stats.freeMemoryInt, stats.freeMemoryExt);
|
||||
sprintf(block_free, "%d+%d", stats.freeBlockInt, stats.freeBlockExt);
|
||||
sprintf(uptime, "%ds", (int)(get_elapsed_time() / 1000 / 1000));
|
||||
sprintf(uptime, "%ds", (int)(rg_system_timer() / 1000000));
|
||||
|
||||
int sel = rg_gui_dialog("Debugging", options, 0);
|
||||
|
||||
|
||||
@ -271,12 +271,12 @@ long rg_input_gamepad_last_read(void)
|
||||
if (!last_gamepad_read)
|
||||
return 0;
|
||||
|
||||
return get_elapsed_time_since(last_gamepad_read);
|
||||
return rg_system_timer() - last_gamepad_read;
|
||||
}
|
||||
|
||||
uint32_t rg_input_read_gamepad(void)
|
||||
{
|
||||
last_gamepad_read = get_elapsed_time();
|
||||
last_gamepad_read = rg_system_timer();
|
||||
return gamepad_state;
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,7 @@ static void netplay_task()
|
||||
}
|
||||
|
||||
netplay_player_t *packet_from = &players[packet.player_id];
|
||||
packet_from->last_contact = get_elapsed_time();
|
||||
packet_from->last_contact = rg_system_timer();
|
||||
|
||||
switch (packet.cmd)
|
||||
{
|
||||
@ -517,7 +517,7 @@ void rg_netplay_sync(void *data_in, void *data_out, uint8_t data_len)
|
||||
return;
|
||||
}
|
||||
|
||||
start_time = get_elapsed_time();
|
||||
start_time = rg_system_timer();
|
||||
|
||||
memcpy(&local_player->sync_data, data_in, data_len);
|
||||
|
||||
@ -564,7 +564,7 @@ void rg_netplay_sync(void *data_in, void *data_out, uint8_t data_len)
|
||||
}
|
||||
#endif
|
||||
|
||||
sync_time += get_elapsed_time_since(start_time);
|
||||
sync_time += rg_system_timer() - start_time;
|
||||
|
||||
if (++sync_count == 60)
|
||||
{
|
||||
|
||||
@ -55,7 +55,7 @@ NO_PROFILE void rg_profiler_start(void)
|
||||
LOCK_PROFILE();
|
||||
|
||||
memset(profile, 0, sizeof(rg_profile_t));
|
||||
profile->time_started = get_elapsed_time();
|
||||
profile->time_started = rg_system_timer();
|
||||
enabled = true;
|
||||
|
||||
UNLOCK_PROFILE();
|
||||
@ -73,7 +73,7 @@ NO_PROFILE void rg_profiler_print(void)
|
||||
|
||||
LOCK_PROFILE();
|
||||
|
||||
printf("RGD:PROF:BEGIN %d %lld\n", profile->total_frames, get_elapsed_time_since(profile->time_started));
|
||||
printf("RGD:PROF:BEGIN %d %d\n", profile->total_frames, (int)(rg_system_timer() - profile->time_started));
|
||||
|
||||
for (int i = 0; i < profile->total_frames; ++i)
|
||||
{
|
||||
@ -108,7 +108,7 @@ NO_PROFILE void __cyg_profile_func_enter(void *this_fn, void *call_site)
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
int64_t now = get_elapsed_time();
|
||||
int64_t now = rg_system_timer();
|
||||
|
||||
LOCK_PROFILE();
|
||||
|
||||
@ -118,7 +118,7 @@ NO_PROFILE void __cyg_profile_func_enter(void *this_fn, void *call_site)
|
||||
if (fn->enter_time != 0)
|
||||
fn->run_time += now - fn->enter_time;
|
||||
|
||||
fn->enter_time = get_elapsed_time(); // not now, because we delayed execution
|
||||
fn->enter_time = rg_system_timer(); // not now, because we delayed execution
|
||||
fn->num_calls++;
|
||||
|
||||
UNLOCK_PROFILE();
|
||||
@ -129,7 +129,7 @@ NO_PROFILE void __cyg_profile_func_exit(void *this_fn, void *call_site)
|
||||
if (!enabled)
|
||||
return;
|
||||
|
||||
int64_t now = get_elapsed_time();
|
||||
int64_t now = rg_system_timer();
|
||||
|
||||
LOCK_PROFILE();
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ static void update_statistics(void)
|
||||
counters.fullFrames = disp->counters.fullFrames;
|
||||
counters.busyTime = statistics.busyTime;
|
||||
counters.ticks = statistics.ticks;
|
||||
counters.updateTime = get_elapsed_time();
|
||||
counters.updateTime = rg_system_timer();
|
||||
|
||||
float elapsedTime = (counters.updateTime - previous.updateTime) / 1000000.f;
|
||||
statistics.busyPercent = RG_MIN((counters.busyTime - previous.busyTime) / (elapsedTime * 1000000.f) * 100.f, 100.f);
|
||||
@ -182,7 +182,7 @@ static void update_statistics(void)
|
||||
|
||||
static void system_monitor_task(void *arg)
|
||||
{
|
||||
time_t lastLoop = get_elapsed_time();
|
||||
int64_t lastLoop = rg_system_timer();
|
||||
bool ledState = false;
|
||||
|
||||
// Give the app a few seconds to start before monitoring
|
||||
@ -191,8 +191,8 @@ static void system_monitor_task(void *arg)
|
||||
|
||||
while (1)
|
||||
{
|
||||
int loopTime_us = get_elapsed_time_since(lastLoop);
|
||||
lastLoop = get_elapsed_time();
|
||||
int loopTime_us = lastLoop - rg_system_timer();
|
||||
lastLoop = rg_system_timer();
|
||||
|
||||
update_statistics();
|
||||
|
||||
@ -233,7 +233,7 @@ static void system_monitor_task(void *arg)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
static long loops = 0;
|
||||
static int loops = 0;
|
||||
if (((loops++) % 10) == 0)
|
||||
{
|
||||
rg_profiler_stop();
|
||||
@ -255,6 +255,11 @@ IRAM_ATTR void rg_system_tick(int busyTime)
|
||||
// WDT_RELOAD(WDT_TIMEOUT);
|
||||
}
|
||||
|
||||
IRAM_ATTR int64_t rg_system_timer(void)
|
||||
{
|
||||
return esp_timer_get_time();
|
||||
}
|
||||
|
||||
rg_stats_t rg_system_get_stats(void)
|
||||
{
|
||||
return statistics;
|
||||
@ -395,13 +400,14 @@ void rg_system_event(rg_event_t event, void *arg)
|
||||
app.handlers.event(event, arg);
|
||||
}
|
||||
|
||||
char *rg_system_get_path(char *buffer, rg_path_type_t pathType, const char *filename)
|
||||
char *rg_emu_get_path(rg_path_type_t pathType, const char *filename)
|
||||
{
|
||||
char *buffer = malloc(RG_PATH_MAX + 1);
|
||||
int type = pathType & ~0xFF;
|
||||
int slot = pathType & 0xFF;
|
||||
|
||||
if (!buffer)
|
||||
buffer = malloc(RG_PATH_MAX + 1);
|
||||
RG_PANIC("Out of memory!");
|
||||
|
||||
if (type == RG_PATH_SAVE_STATE || type == RG_PATH_SAVE_SRAM)
|
||||
strcpy(buffer, RG_BASE_PATH_SAVES);
|
||||
@ -436,12 +442,12 @@ char *rg_system_get_path(char *buffer, rg_path_type_t pathType, const char *file
|
||||
strcat(buffer, ".png");
|
||||
}
|
||||
|
||||
// Don't shrink the buffer, we could use the extra space (append extension, etc).
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool rg_emu_load_state(int slot)
|
||||
{
|
||||
char filename[RG_PATH_MAX + 1];
|
||||
bool success = false;
|
||||
|
||||
if (!app.romPath || !app.handlers.loadState)
|
||||
@ -450,8 +456,7 @@ bool rg_emu_load_state(int slot)
|
||||
return false;
|
||||
}
|
||||
|
||||
rg_system_get_path(filename, RG_PATH_SAVE_STATE + slot, app.romPath);
|
||||
|
||||
char *filename = rg_emu_get_path(RG_PATH_SAVE_STATE + slot, app.romPath);
|
||||
RG_LOGI("Loading state from '%s'.\n", filename);
|
||||
WDT_RELOAD(30 * 1000000);
|
||||
|
||||
@ -463,23 +468,22 @@ bool rg_emu_load_state(int slot)
|
||||
}
|
||||
|
||||
WDT_RELOAD(WDT_TIMEOUT);
|
||||
free(filename);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool rg_emu_save_state(int slot)
|
||||
{
|
||||
char filename[RG_PATH_MAX + 1];
|
||||
char tempname[RG_PATH_MAX + 8];
|
||||
bool success = false;
|
||||
|
||||
if (!app.romPath || !app.handlers.saveState)
|
||||
{
|
||||
RG_LOGE("No rom or handler defined...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
rg_system_get_path(filename, RG_PATH_SAVE_STATE + slot, app.romPath);
|
||||
char *filename = rg_emu_get_path(RG_PATH_SAVE_STATE + slot, app.romPath);
|
||||
char tempname[RG_PATH_MAX + 8];
|
||||
bool success = false;
|
||||
|
||||
RG_LOGI("Saving state to '%s'.\n", filename);
|
||||
WDT_RELOAD(30 * 1000000);
|
||||
@ -515,8 +519,7 @@ bool rg_emu_save_state(int slot)
|
||||
else
|
||||
{
|
||||
// Save succeeded, let's take a pretty screenshot for the launcher!
|
||||
rg_system_get_path(filename, RG_PATH_SCREENSHOT + slot, app.romPath);
|
||||
rg_emu_screenshot(filename, rg_display_get_status()->screen.width / 2, 0);
|
||||
rg_emu_screenshot(strcat(filename, ".png"), rg_display_get_status()->screen.width / 2, 0);
|
||||
|
||||
// And set bootflags to resume from this state on next boot
|
||||
if ((app.bootFlags & (RG_BOOT_ONCE|RG_BOOT_RESUME)) == 0)
|
||||
@ -527,6 +530,7 @@ bool rg_emu_save_state(int slot)
|
||||
}
|
||||
|
||||
#undef tempname
|
||||
free(filename);
|
||||
|
||||
rg_storage_commit();
|
||||
rg_system_set_led(0);
|
||||
@ -702,7 +706,7 @@ bool rg_system_save_trace(const char *filename, bool panic_trace)
|
||||
fprintf(fp, "Free memory: %d + %d\n", stats->freeMemoryInt, stats->freeMemoryExt);
|
||||
fprintf(fp, "Free block: %d + %d\n", stats->freeBlockInt, stats->freeBlockExt);
|
||||
fprintf(fp, "Stack HWM: %d\n", stats->freeStackMain);
|
||||
fprintf(fp, "Uptime: %ds (%d ticks)\n", (int)(get_elapsed_time() / 1000000), stats->ticks);
|
||||
fprintf(fp, "Uptime: %ds (%d ticks)\n", (int)(rg_system_timer() / 1000000), stats->ticks);
|
||||
if (panic_trace && panicTrace.message[0])
|
||||
fprintf(fp, "Panic message: %.256s\n", panicTrace.message);
|
||||
if (panic_trace && panicTrace.context[0])
|
||||
|
||||
@ -22,6 +22,11 @@ extern "C" {
|
||||
#define RG_TARGET_ODROID_GO
|
||||
#endif
|
||||
|
||||
#define RG_APP_LAUNCHER "launcher"
|
||||
#define RG_APP_FACTORY NULL
|
||||
|
||||
#define RG_PATH_MAX 255
|
||||
|
||||
#include "rg_audio.h"
|
||||
#include "rg_display.h"
|
||||
#include "rg_input.h"
|
||||
@ -77,9 +82,6 @@ typedef enum
|
||||
RG_EVENT_REDRAW,
|
||||
} rg_event_t;
|
||||
|
||||
#define RG_APP_LAUNCHER "launcher"
|
||||
#define RG_APP_FACTORY NULL
|
||||
|
||||
typedef bool (*rg_state_handler_t)(const char *filename);
|
||||
typedef bool (*rg_reset_handler_t)(bool hard);
|
||||
typedef void (*rg_event_handler_t)(int event, void *arg);
|
||||
@ -163,10 +165,11 @@ void rg_system_vlog(int level, const char *context, const char *format, va_list
|
||||
void rg_system_log(int level, const char *context, const char *format, ...) __attribute__((format(printf,3,4)));
|
||||
bool rg_system_save_trace(const char *filename, bool append);
|
||||
void rg_system_event(rg_event_t event, void *arg);
|
||||
char *rg_system_get_path(char *buffer, rg_path_type_t type, const char *filename);
|
||||
int64_t rg_system_timer(void);
|
||||
rg_app_t *rg_system_get_app(void);
|
||||
rg_stats_t rg_system_get_stats(void);
|
||||
|
||||
char *rg_emu_get_path(rg_path_type_t type, const char *arg);
|
||||
bool rg_emu_save_state(int slot);
|
||||
bool rg_emu_load_state(int slot);
|
||||
bool rg_emu_reset(int hard);
|
||||
@ -185,20 +188,19 @@ void *rg_alloc(size_t size, uint32_t caps);
|
||||
/* Utilities */
|
||||
|
||||
// Functions from esp-idf, we don't include their header but they will be linked
|
||||
extern int64_t esp_timer_get_time();
|
||||
extern uint32_t crc32_le(uint32_t crc, const uint8_t * buf, uint32_t len);
|
||||
|
||||
// long microseconds
|
||||
// These older macros do not guarantee a time unit in case retro-go was ported to a platform where
|
||||
// divisions were too slow or overflows were likely. However at this time it doesn't matter and much
|
||||
// of the code assumes microseconds so I will replace them by rg_system_timer() for clarity.
|
||||
#define get_frame_time(refresh_rate) (1000000 / (refresh_rate))
|
||||
// int64_t microseconds
|
||||
#define get_elapsed_time() esp_timer_get_time()
|
||||
// int64_t microseconds
|
||||
#define get_elapsed_time_since(start) (esp_timer_get_time() - (start))
|
||||
#define get_elapsed_time() (rg_system_timer())
|
||||
#define get_elapsed_time_since(start) (get_elapsed_time() - (start))
|
||||
|
||||
#define RG_TIMER_INIT() int _rgts_ = get_elapsed_time(), _rgtl_ = get_elapsed_time();
|
||||
#define RG_TIMER_INIT() int64_t _rgts_ = rg_system_timer(), _rgtl_ = rg_system_timer();
|
||||
#define RG_TIMER_LAP(name) \
|
||||
RG_LOGX("Lap %s: %.2f Total: %.2f\n", #name, get_elapsed_time_since(_rgtl_) / 1000.f, \
|
||||
get_elapsed_time_since(_rgts_) / 1000.f); _rgtl_ = get_elapsed_time();
|
||||
RG_LOGX("Lap %s: %.2f Total: %.2f\n", #name, (rg_system_timer() - _rgtl_) / 1000.f, \
|
||||
(rg_system_timer() - _rgts_) / 1000.f); _rgtl_ = rg_system_timer();
|
||||
|
||||
#define RG_MIN(a, b) ({__typeof__(a) _a = (a); __typeof__(b) _b = (b);_a < _b ? _a : _b; })
|
||||
#define RG_MAX(a, b) ({__typeof__(a) _a = (a); __typeof__(b) _b = (b);_a > _b ? _a : _b; })
|
||||
@ -220,8 +222,6 @@ extern uint32_t crc32_le(uint32_t crc, const uint8_t * buf, uint32_t len);
|
||||
|
||||
#define RG_DUMP(...) {}
|
||||
|
||||
#define RG_PATH_MAX 255
|
||||
|
||||
// Attributes
|
||||
|
||||
#ifndef IRAM_ATTR
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <rg_system.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define GB_WIDTH (160)
|
||||
#define GB_HEIGHT (144)
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
#define LOG_PRINTF(level, x...) rg_system_log(RG_LOG_USER, NULL, x)
|
||||
// #define LOG_PRINTF(level, x...) printf(x)
|
||||
#else
|
||||
#define LOG_PRINTF(level, x...) printf(x)
|
||||
#define IRAM_ATTR
|
||||
#endif
|
||||
|
||||
#define MESSAGE_ERROR(x, ...) LOG_PRINTF(1, "!! %s: " x, __func__, ## __VA_ARGS__)
|
||||
#define MESSAGE_WARN(x, ...) LOG_PRINTF(2, "** %s: " x, __func__, ## __VA_ARGS__)
|
||||
@ -17,6 +18,9 @@
|
||||
// #define MESSAGE_DEBUG(x, ...) LOG_PRINTF(4, ">> %s: " x, __func__, ## __VA_ARGS__)
|
||||
#define MESSAGE_DEBUG(x, ...) {}
|
||||
|
||||
#define GB_WIDTH (160)
|
||||
#define GB_HEIGHT (144)
|
||||
|
||||
typedef uint8_t byte;
|
||||
typedef uint8_t un8;
|
||||
typedef uint16_t un16;
|
||||
|
||||
@ -251,7 +251,7 @@ void app_main(void)
|
||||
rg_display_set_source_format(GB_WIDTH, GB_HEIGHT, 0, 0, GB_WIDTH * 2, RG_PIXEL_565_BE);
|
||||
|
||||
autoSaveSRAM = rg_settings_get_number(NS_APP, SETTING_SAVESRAM, 0);
|
||||
sramFile = rg_system_get_path(NULL, RG_PATH_SAVE_SRAM, app->romPath);
|
||||
sramFile = rg_emu_get_path(RG_PATH_SAVE_SRAM, app->romPath);
|
||||
|
||||
if (!rg_mkdir(rg_dirname(sramFile)))
|
||||
MESSAGE_ERROR("Unable to create SRAM folder...");
|
||||
|
||||
@ -140,11 +140,14 @@ extern UBYTE *gPrimaryFrameBuffer;
|
||||
//
|
||||
// Define logging functions
|
||||
//
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
// #define log_printf(x...) printf(x)
|
||||
#define log_printf(x...) rg_system_log(RG_LOG_USER, NULL, x)
|
||||
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define log_printf(x...) printf(x)
|
||||
#define rg_crc32(a, b, c) (0)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Define the interfaces before we start pulling in the classes
|
||||
|
||||
@ -570,9 +570,9 @@ static void show_file_info(retro_file_t *file)
|
||||
void application_show_file_menu(retro_file_t *file, bool advanced)
|
||||
{
|
||||
const char *rom_path = get_file_path(file);
|
||||
char *save_path = rg_system_get_path(NULL, RG_PATH_SAVE_STATE, rom_path);
|
||||
char *sram_path = rg_system_get_path(NULL, RG_PATH_SAVE_SRAM, rom_path);
|
||||
char *scrn_path = rg_system_get_path(NULL, RG_PATH_SCREENSHOT, rom_path);
|
||||
char *save_path = rg_emu_get_path(RG_PATH_SAVE_STATE, rom_path);
|
||||
char *sram_path = rg_emu_get_path(RG_PATH_SAVE_SRAM, rom_path);
|
||||
char *scrn_path = rg_emu_get_path(RG_PATH_SCREENSHOT, rom_path);
|
||||
bool has_save = access(save_path, F_OK) == 0;
|
||||
bool has_sram = access(sram_path, F_OK) == 0;
|
||||
bool is_fav = bookmark_exists(BOOK_TYPE_FAVORITE, file);
|
||||
|
||||
@ -105,12 +105,12 @@ static rg_gui_event_t about_app_cb(rg_gui_option_t *option, rg_gui_event_t event
|
||||
static void retro_loop(void)
|
||||
{
|
||||
tab_t *tab = gui_get_current_tab();
|
||||
int next_repeat = 0;
|
||||
int64_t next_repeat = 0;
|
||||
int64_t next_idle_event = 0;
|
||||
int repeats = 0;
|
||||
int joystick, prev_joystick;
|
||||
int change_tab = 0;
|
||||
int browse_last = -1;
|
||||
int next_idle_event = 0;
|
||||
bool redraw_pending = true;
|
||||
|
||||
while (true)
|
||||
@ -149,13 +149,13 @@ static void retro_loop(void)
|
||||
{
|
||||
joystick = gui.joystick;
|
||||
repeats = 0;
|
||||
next_repeat = get_elapsed_time() + 400000;
|
||||
next_repeat = rg_system_timer() + 400000;
|
||||
}
|
||||
else if (get_elapsed_time_since(next_repeat) >= 0)
|
||||
else if ((rg_system_timer() - next_repeat) >= 0)
|
||||
{
|
||||
joystick = gui.joystick;
|
||||
repeats++;
|
||||
next_repeat = get_elapsed_time() + 400000 / (repeats + 1);
|
||||
next_repeat = rg_system_timer() + 400000 / (repeats + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,13 +232,13 @@ static void retro_loop(void)
|
||||
if ((gui.joystick|joystick) & RG_KEY_ANY)
|
||||
{
|
||||
gui.idle_counter = 0;
|
||||
next_idle_event = get_elapsed_time() + 100000;
|
||||
next_idle_event = rg_system_timer() + 100000;
|
||||
}
|
||||
else if (get_elapsed_time() >= next_idle_event)
|
||||
else if (rg_system_timer() >= next_idle_event)
|
||||
{
|
||||
gui.idle_counter++;
|
||||
gui_event(TAB_IDLE, tab);
|
||||
next_idle_event = get_elapsed_time() + 100000;
|
||||
next_idle_event = rg_system_timer() + 100000;
|
||||
redraw_pending = true;
|
||||
gui.joystick = 0;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
static struct
|
||||
{
|
||||
uint counter, latch;
|
||||
unsigned counter, latch;
|
||||
bool enabled, wait_state;
|
||||
} irq;
|
||||
|
||||
|
||||
@ -199,9 +199,9 @@ typedef struct
|
||||
float cycle_rate;
|
||||
|
||||
struct {
|
||||
uint8 state;
|
||||
uint step;
|
||||
uint cycles;
|
||||
unsigned state;
|
||||
unsigned step;
|
||||
unsigned cycles;
|
||||
bool irq_occurred;
|
||||
bool disable_irq;
|
||||
} fc;
|
||||
@ -235,5 +235,5 @@ void apu_getcontext(apu_t *dest_apu);
|
||||
void apu_process(short *buffer, size_t num_samples, bool stereo);
|
||||
void apu_fc_advance(int cycles);
|
||||
|
||||
uint8 apu_read(uint address);
|
||||
void apu_write(uint address, uint8 value);
|
||||
uint8 apu_read(uint32 address);
|
||||
void apu_write(uint32 address, uint8 value);
|
||||
|
||||
@ -47,7 +47,9 @@
|
||||
/* Basic types */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
@ -81,9 +83,16 @@ enum
|
||||
/* End basic types */
|
||||
|
||||
/* Macros */
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
#define LOG_PRINTF(level, x...) rg_system_log(RG_LOG_USER, NULL, x)
|
||||
// #define LOG_PRINTF(level, x...) printf(x)
|
||||
#else
|
||||
#define LOG_PRINTF(level, x...) printf(x)
|
||||
#define DRAM_ATTR
|
||||
#define IRAM_ATTR
|
||||
#define rg_alloc(size, type) calloc(1, (size))
|
||||
#define crc32_le(a, b, c) (0)
|
||||
#endif
|
||||
|
||||
#ifdef NOFRENDO_DEBUG
|
||||
#define MESSAGE_ERROR(x, ...) LOG_PRINTF(1, "!! %s: " x, __func__, ## __VA_ARGS__)
|
||||
@ -110,7 +119,6 @@ enum
|
||||
|
||||
/* End macros */
|
||||
|
||||
#include <rg_system.h>
|
||||
#include <nes.h>
|
||||
|
||||
int nofrendo_init(int system, int sample_rate, bool stereo, void *blit, void *vsync, void *input);
|
||||
|
||||
@ -231,7 +231,7 @@ static void nsf_draw_overlay(void)
|
||||
{
|
||||
extern int nsf_current_song;
|
||||
char song[32];
|
||||
const nsfheader_t *header = nes->cart->data_ptr;
|
||||
const nsfheader_t *header = (nsfheader_t *)nes->cart->data_ptr;
|
||||
const rg_gui_option_t options[] = {
|
||||
{0, "Name ", (char *)header->name, 1, NULL},
|
||||
{0, "Artist ", (char *)header->artist, 1, NULL},
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
#include <rg_system.h>
|
||||
|
||||
// Enable debugging messages (hardware faults, fix-me, etc)
|
||||
#define ENABLE_DEBUGG 0
|
||||
|
||||
|
||||
@ -3,12 +3,19 @@
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
#define LOG_PRINTF(level, x...) rg_system_log(RG_LOG_USER, NULL, x)
|
||||
// #define LOG_PRINTF(level, x...) printf(x)
|
||||
#else
|
||||
#define LOG_PRINTF(level, x...) printf(x)
|
||||
#define IRAM_ATTR
|
||||
#define rg_crc32(a, b, c) (0)
|
||||
#endif
|
||||
|
||||
#define MESSAGE_ERROR(x...) LOG_PRINTF(1, "!! " x)
|
||||
#define MESSAGE_WARN(x...) LOG_PRINTF(2, " ! " x)
|
||||
|
||||
@ -40,7 +40,14 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
#define SCREENWIDTH (RG_SCREEN_WIDTH - RG_SCREEN_MARGIN_LEFT - RG_SCREEN_MARGIN_RIGHT)
|
||||
#define SCREENHEIGHT (RG_SCREEN_HEIGHT - RG_SCREEN_MARGIN_TOP - RG_SCREEN_MARGIN_BOTTOM)
|
||||
#else
|
||||
#define SCREENWIDTH 320
|
||||
#define SCREENHEIGHT 240
|
||||
#endif
|
||||
|
||||
// This must come first, since it redefines malloc(), free(), etc. -- killough:
|
||||
#include "z_zone.h"
|
||||
@ -73,15 +80,6 @@ typedef enum {
|
||||
none
|
||||
} GameMission_t;
|
||||
|
||||
// SCREENWIDTH and SCREENHEIGHT define the visible size
|
||||
#if defined(RG_SCREEN_WIDTH) && defined(RG_SCREEN_HEIGHT)
|
||||
#define SCREENWIDTH (RG_SCREEN_WIDTH - RG_SCREEN_MARGIN_LEFT - RG_SCREEN_MARGIN_RIGHT)
|
||||
#define SCREENHEIGHT (RG_SCREEN_HEIGHT - RG_SCREEN_MARGIN_TOP - RG_SCREEN_MARGIN_BOTTOM)
|
||||
#else
|
||||
#define SCREENWIDTH 320
|
||||
#define SCREENHEIGHT 240
|
||||
#endif
|
||||
|
||||
// killough 2/8/98: MAX versions for maximum screen sizes
|
||||
// allows us to avoid the overhead of dynamic allocation
|
||||
// when multiple screen sizes are supported
|
||||
|
||||
@ -55,7 +55,11 @@ void lprintf(OutputLevels lvl, const char *s, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, s);
|
||||
#ifdef RETRO_GO
|
||||
rg_system_vlog(RG_LOG_USER, NULL, s, arg);
|
||||
#else
|
||||
vprintf(s, arg);
|
||||
#endif
|
||||
// vprintf(s, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
@ -73,10 +77,15 @@ void lprintf(OutputLevels lvl, const char *s, ...)
|
||||
|
||||
void I_Error(const char *error, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
va_list arg;
|
||||
va_start(arg, error);
|
||||
#ifdef RETRO_GO
|
||||
char buffer[256];
|
||||
vsnprintf(buffer, sizeof(buffer), error, arg);
|
||||
va_end(arg);
|
||||
RG_PANIC(buffer);
|
||||
#else
|
||||
vprintf(error, arg);
|
||||
abort();
|
||||
#endif
|
||||
va_end(arg);
|
||||
}
|
||||
|
||||
@ -188,12 +188,12 @@ void I_InitGraphics(void)
|
||||
|
||||
int I_GetTimeMS(void)
|
||||
{
|
||||
return esp_timer_get_time() / 1000;
|
||||
return rg_system_timer() / 1000;
|
||||
}
|
||||
|
||||
int I_GetTime(void)
|
||||
{
|
||||
return ((esp_timer_get_time() * TICRATE) / 1000000);
|
||||
return ((rg_system_timer() * TICRATE) / 1000000);
|
||||
}
|
||||
|
||||
void I_uSleep(unsigned long usecs)
|
||||
@ -412,9 +412,9 @@ void I_SetMusicVolume(int volume)
|
||||
|
||||
void I_StartTic(void)
|
||||
{
|
||||
static uint64_t last_time = 0;
|
||||
static uint32_t prev_joystick = 0x0000;
|
||||
static uint32_t rg_menu_delay = 0;
|
||||
static int64_t last_time = 0;
|
||||
static int32_t prev_joystick = 0x0000;
|
||||
static int32_t rg_menu_delay = 0;
|
||||
uint32_t joystick = rg_input_read_gamepad();
|
||||
uint32_t changed = prev_joystick ^ joystick;
|
||||
event_t event = {0};
|
||||
@ -449,8 +449,8 @@ void I_StartTic(void)
|
||||
}
|
||||
}
|
||||
|
||||
rg_system_tick(get_elapsed_time_since(last_time));
|
||||
last_time = get_elapsed_time();
|
||||
rg_system_tick(rg_system_timer() - last_time);
|
||||
last_time = rg_system_timer();
|
||||
prev_joystick = joystick;
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
"C_Cpp.default.defines": [
|
||||
"PROJECT_VER",
|
||||
"RETRO_GO",
|
||||
"INLINE=",
|
||||
"uint=unsigned int",
|
||||
"CONFIG_FREERTOS_HZ=100",
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
#ifndef _RENDER_H_
|
||||
#define _RENDER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Pack RGB data into a 16-bit RGB 5:6:5 format */
|
||||
#define MAKE_PIXEL(r,g,b) (((r << 8) & 0xF800) | ((g << 3) & 0x07E0) | ((b >> 3) & 0x001F))
|
||||
|
||||
|
||||
@ -16,10 +16,16 @@ typedef signed long int int32;
|
||||
#include <malloc.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <rg_system.h>
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
#define LOG_PRINTF(level, x...) rg_system_log(RG_LOG_USER, NULL, x)
|
||||
// #define LOG_PRINTF(level, x...) printf(x)
|
||||
#else
|
||||
#define LOG_PRINTF(level, x...) printf(x)
|
||||
#define DRAM_ATTR
|
||||
#define IRAM_ATTR
|
||||
#define crc32_le(a, b, c) (0)
|
||||
#endif
|
||||
|
||||
#define MESSAGE_ERROR(x, ...) LOG_PRINTF(1, "!! %s: " x, __func__, ## __VA_ARGS__)
|
||||
#define MESSAGE_WARN(x, ...) LOG_PRINTF(2, "** %s: " x, __func__, ## __VA_ARGS__)
|
||||
|
||||
@ -14,7 +14,6 @@ CMemory Memory;
|
||||
uint32 OpenBus = 0;
|
||||
|
||||
#define match_nn(str) (strncmp(Memory.ROMName, (str), strlen((str))) == 0)
|
||||
extern uint32 crc32_le(uint32 crc, uint8 const * buf, uint32 len);
|
||||
|
||||
static int First512BytesCountZeroes(void)
|
||||
{
|
||||
|
||||
@ -13,7 +13,13 @@
|
||||
|
||||
#include "port.h"
|
||||
|
||||
#ifdef RETRO_GO
|
||||
#include <rg_system.h>
|
||||
#else
|
||||
#define IRAM_ATTR
|
||||
#define rg_alloc(size, type) calloc(1, size)
|
||||
#define crc32_le(a, b, c) (0)
|
||||
#endif
|
||||
|
||||
/* Experimental retro-go flags */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user