|
|
|
@@ -15,6 +15,10 @@ |
|
|
|
#include "log.h" |
|
|
|
|
|
|
|
|
|
|
|
/* OS-specific file operations |
|
|
|
* Memory mapping specifically needs to be ported for each OS |
|
|
|
*/ |
|
|
|
|
|
|
|
static void* nese_map_file(FILE* file, int size) { |
|
|
|
void* addr = mmap(NULL, size, PROT_READ, MAP_SHARED, |
|
|
|
fileno(file), 0); |
|
|
|
@@ -38,6 +42,29 @@ static int nese_file_size(FILE* file) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Platform-specific allocation |
|
|
|
* GPU and CPU refer to emulator memory spaces |
|
|
|
* Note: GPU (and possibly CPU) regions may need |
|
|
|
* to be placed into internal ram for performance |
|
|
|
*/ |
|
|
|
|
|
|
|
void* nese_alloc_gpu(int size) { |
|
|
|
return calloc(1, size); |
|
|
|
} |
|
|
|
|
|
|
|
void* nese_alloc_cpu(int size) { |
|
|
|
return calloc(1, size); |
|
|
|
} |
|
|
|
|
|
|
|
void* nese_alloc(int size) { |
|
|
|
return calloc(1, size); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* SDL-specific init and entry point |
|
|
|
* This should be maximally reusable across platforms |
|
|
|
*/ |
|
|
|
|
|
|
|
typedef struct { |
|
|
|
const char* filename; |
|
|
|
FILE* file; |
|
|
|
@@ -137,6 +164,8 @@ int nese_frame_start(void* plat_data, uint8_t background) { |
|
|
|
platform_data* plat = (platform_data*)plat_data; |
|
|
|
|
|
|
|
SDL_Color ext = nes_palette[background]; |
|
|
|
// TODO: Compose color according to GPU format? |
|
|
|
// Why are R/B reversed on STM32? |
|
|
|
SDL_FillRect(plat->target, NULL, ((int)ext.r << 16) | |
|
|
|
((int)ext.g << 8) | ext.b); |
|
|
|
|
|
|
|
@@ -218,6 +247,7 @@ int nese_frame_ready(void* plat_data) { |
|
|
|
} |
|
|
|
putc('\n', stdout); |
|
|
|
*/ |
|
|
|
SDL_RenderFlush(plat->renderer); |
|
|
|
|
|
|
|
SDL_BlitSurface(plat->screen, NULL, plat->target, NULL); |
|
|
|
|
|
|
|
|