Skip to content

Commit

Permalink
Thu 9 Jan 2020 14:40:37 EST - added Super Go Play interlacing for NES
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneAndruszczenko committed Jan 9, 2020
1 parent 5dc2781 commit 4a9e05a
Show file tree
Hide file tree
Showing 8 changed files with 848 additions and 13 deletions.
Binary file modified .DS_Store
Binary file not shown.

Large diffs are not rendered by default.

207 changes: 207 additions & 0 deletions Components/super-go-play/nesemu-go/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include "nofrendo.h"
#include "esp_partition.h"
#include "esp_spiffs.h"

#include "esp_err.h"
#include "esp_log.h"
#include "esp_vfs_fat.h"
#include "driver/sdmmc_host.h"
#include "driver/sdspi_host.h"
#include "sdmmc_cmd.h"
#include <dirent.h>


#include "../components/odroid/odroid_settings.h"
#include "../components/odroid/odroid_system.h"
#include "../components/odroid/odroid_sdcard.h"
#include "../components/odroid/odroid_display.h"
#include "../components/odroid/odroid_input.h"

#ifdef CONFIG_IN_GAME_MENU_YES
#include "../components/odroid/odroid_hud.h"
#endif

const char* SD_BASE_PATH = "/sd";
static char* ROM_DATA = (char*)0x3f800000;

extern bool forceConsoleReset;


char *osd_getromdata()
{
printf("Initialized. ROM@%p\n", ROM_DATA);
return (char*)ROM_DATA;
}




static const char *TAG = "main";


int app_main(void)
{
printf("nesemu (%s-%s).\n", COMPILEDATE, GITREV);

nvs_flash_init();

odroid_system_init();

esp_err_t ret;


char* fileName;

char* romName = odroid_settings_RomFilePath_get();
if (romName)
{
fileName = odroid_util_GetFileName(romName);
if (!fileName) abort();

free(romName);
}
else
{
fileName = "nesemu-show3.nes";
}


int startHeap = esp_get_free_heap_size();
printf("A HEAP:0x%x\n", startHeap);


ili9341_init();

// Joystick.
odroid_input_gamepad_init();
odroid_input_battery_level_init();

//printf("osd_init: ili9341_prepare\n");
ili9341_prepare();

printf("*****\nHERE\n*****\n");
switch (esp_sleep_get_wakeup_cause())
{
case ESP_SLEEP_WAKEUP_EXT0:
{
printf("app_main: ESP_SLEEP_WAKEUP_EXT0 deep sleep reset\n");
break;
}

case ESP_SLEEP_WAKEUP_EXT1:
case ESP_SLEEP_WAKEUP_TIMER:
case ESP_SLEEP_WAKEUP_TOUCHPAD:
case ESP_SLEEP_WAKEUP_ULP:
case ESP_SLEEP_WAKEUP_UNDEFINED:
{
printf("app_main: Unexpected deep sleep reset\n");
odroid_gamepad_state bootState = odroid_input_read_raw();

if (bootState.values[ODROID_INPUT_MENU])
{
// Force return to menu to recover from
// ROM loading crashes

// Set menu application
odroid_system_application_set(0);

// Reset
esp_restart();
}

if (bootState.values[ODROID_INPUT_START])
{
// Reset emulator if button held at startup to
// override save state
forceConsoleReset = true; //emu_reset();
}
}
break;

default:
printf("app_main: Not a deep sleep reset\n");
break;
}

if (odroid_settings_StartAction_get() == ODROID_START_ACTION_RESTART)
{
forceConsoleReset = true;
odroid_settings_StartAction_set(ODROID_START_ACTION_NORMAL);
}


// Load ROM
char* romPath = odroid_settings_RomFilePath_get();
if (!romPath)
{
printf("osd_getromdata: Reading from flash.\n");

// copy from flash
spi_flash_mmap_handle_t hrom;

const esp_partition_t* part = esp_partition_find_first(0x40, 0, NULL);
if (part == 0)
{
printf("esp_partition_find_first failed.\n");
abort();
}

esp_err_t err = esp_partition_read(part, 0, (void*)ROM_DATA, 0x100000);
if (err != ESP_OK)
{
printf("esp_partition_read failed. size = %x (%d)\n", part->size, err);
abort();
}
}
else
{
printf("osd_getromdata: Reading from sdcard.\n");

// copy from SD card
esp_err_t r = odroid_sdcard_open(SD_BASE_PATH);
if (r != ESP_OK)
{
odroid_display_show_sderr(ODROID_SD_ERR_NOCARD);
abort();
}

size_t fileSize = odroid_sdcard_copy_file_to_memory(romPath, ROM_DATA);
printf("app_main: fileSize=%d\n", fileSize);
if (fileSize == 0)
{
odroid_display_show_sderr(ODROID_SD_ERR_BADFILE);
abort();
}

#ifdef CONFIG_IN_GAME_MENU_YES
char* save_name = odroid_util_GetFileName(romPath);
hud_check_saves(odroid_util_GetFileName(romPath));
#endif

r = odroid_sdcard_close();
if (r != ESP_OK)
{
odroid_display_show_sderr(ODROID_SD_ERR_NOCARD);
abort();
}

free(romPath);
}


printf("NoFrendo start!\n");

char* args[1] = { fileName };
nofrendo_main(1, args);

printf("NoFrendo died.\n");
asm("break.n 1");
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ DRAM_ATTR static const ili_init_cmd_t ili_init_cmds[] = {
//Set Gamma
{0xE0, {0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00}, 15},
{0XE1, {0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F}, 15},

// ILI9342 Specific
{0x36, {0x40|0x80|0x08}, 1}, // <-- ROTATE
{0x21, {0}, 0x80}, // <-- INVERT COLORS
Expand Down Expand Up @@ -968,8 +968,8 @@ odroid_display_set_scale(int width, int height, float aspect)

x_inc = SCREEN_WIDTH / x_scale;
y_inc = SCREEN_HEIGHT / y_scale;
x_origin = (SCREEN_WIDTH - (width * x_scale)) / 2.f;
y_origin = (SCREEN_HEIGHT - (height * y_scale)) / 2.f;
x_origin = 0;//(SCREEN_WIDTH - (width * x_scale)) / 2.f;
y_origin = 0;//(SCREEN_HEIGHT - (height * y_scale)) / 2.f;

printf("%dx%d@%.3f x_inc:%d y_inc:%d x_scale:%.3f y_scale:%.3f x_origin:%d y_origin:%d\n",
width, height, aspect, x_inc, y_inc, x_scale, y_scale, x_origin, y_origin);
Expand Down Expand Up @@ -1529,4 +1529,4 @@ odroid_buffer_diff_count(odroid_scanline *diff, int height)
y += diff[y].repeat;
}
return n_pixels;
}
}
Binary file modified Launchers/.DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions Launchers/retro-esp32/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@
int ext_length = strlen(EXTENSIONS[STEP]);
bool extenstion = strcmp(&file->d_name[rom_length - ext_length], EXTENSIONS[STEP]) == 0 && file->d_name[0] != '.';
if(extenstion || (file->d_type == 2)) {
SEEK[ROMS.total+1] = telldir(directory);
ROMS.total++;
SEEK[ROMS.total+1] = telldir(directory);
ROMS.total++;
}
}
free(file);
Expand All @@ -967,7 +967,7 @@
// printf("\n%s: freed & closed", path);
for(int n = 0; n < ROMS.total; n++) {
// printf("\nSEEK[%d]:%d ", n, SEEK[n]);
}
}
}

// printf("\n---------------------\n");
Expand Down Expand Up @@ -1007,7 +1007,7 @@
draw_text(center,134,message,false,false, false);
} else {
// printf("\nSEEK[%d]:%d", ROMS.offset, SEEK[ROMS.offset]);
rewinddir(directory);
rewinddir(directory);
seekdir(directory, SEEK[ROMS.offset]);
struct dirent *file;
int n =0;
Expand Down
12 changes: 7 additions & 5 deletions Scripts/helpers/process
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ then
make -j8
cp ./build/gnuboy-go.bin $FIRMWARE_PATH/Bins/

cd $GOPLAY_PATH

#cd $GOPLAY_PATH
cd $SUPER_GOPLAY_PATH
clear
echo "--------------------------------------------------------------------------"
echo -e "${game} ${green}Compiling ${cyan}nesemu-go${nc}"
Expand All @@ -187,11 +187,13 @@ then
make -j8
cp ./build/nesemu-go.bin $FIRMWARE_PATH/Bins/

cd $GOPLAY_PATH
clear
echo "--------------------------------------------------------------------------"
echo -e "${game} ${green}Compiling ${cyan}smsplusgx-go${nc}"
echo "--------------------------------------------------------------------------"
cd ../smsplusgx-go
#cd ../smsplusgx-go
cd smsplusgx-go
get_clean_option
get_config_option
make -j8
Expand All @@ -213,7 +215,7 @@ then
echo "--------------------------------------------------------------------------"
echo -e "${game} ${green}Compiling ${cyan}stella-odroid-go${nc}"
echo "--------------------------------------------------------------------------"
cd $EMULATOR_PATH
cd $EMULATOR_PATH
cd stella-odroid-go
get_clean_option
get_config_option
Expand Down Expand Up @@ -251,7 +253,7 @@ then
get_clean_option
get_config_option
make -j8
cp ./build/spectrum.bin $FIRMWARE_PATH/Bins/
cp ./build/spectrum.bin $FIRMWARE_PATH/Bins/
fi

cd $SRC_PATH
Binary file modified Tools/.DS_Store
Binary file not shown.

0 comments on commit 4a9e05a

Please sign in to comment.