Skip to content

Commit 4a9e05a

Browse files
Thu 9 Jan 2020 14:40:37 EST - added Super Go Play interlacing for NES
1 parent 5dc2781 commit 4a9e05a

File tree

8 files changed

+848
-13
lines changed

8 files changed

+848
-13
lines changed

.DS_Store

4 KB
Binary file not shown.

Components/super-go-play/nesemu-go/components/nofrendo-esp32/video_audio.c

Lines changed: 626 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#include "freertos/FreeRTOS.h"
2+
#include "esp_wifi.h"
3+
#include "esp_system.h"
4+
#include "esp_event.h"
5+
#include "esp_event_loop.h"
6+
#include "nvs_flash.h"
7+
#include "driver/gpio.h"
8+
#include "nofrendo.h"
9+
#include "esp_partition.h"
10+
#include "esp_spiffs.h"
11+
12+
#include "esp_err.h"
13+
#include "esp_log.h"
14+
#include "esp_vfs_fat.h"
15+
#include "driver/sdmmc_host.h"
16+
#include "driver/sdspi_host.h"
17+
#include "sdmmc_cmd.h"
18+
#include <dirent.h>
19+
20+
21+
#include "../components/odroid/odroid_settings.h"
22+
#include "../components/odroid/odroid_system.h"
23+
#include "../components/odroid/odroid_sdcard.h"
24+
#include "../components/odroid/odroid_display.h"
25+
#include "../components/odroid/odroid_input.h"
26+
27+
#ifdef CONFIG_IN_GAME_MENU_YES
28+
#include "../components/odroid/odroid_hud.h"
29+
#endif
30+
31+
const char* SD_BASE_PATH = "/sd";
32+
static char* ROM_DATA = (char*)0x3f800000;
33+
34+
extern bool forceConsoleReset;
35+
36+
37+
char *osd_getromdata()
38+
{
39+
printf("Initialized. ROM@%p\n", ROM_DATA);
40+
return (char*)ROM_DATA;
41+
}
42+
43+
44+
45+
46+
static const char *TAG = "main";
47+
48+
49+
int app_main(void)
50+
{
51+
printf("nesemu (%s-%s).\n", COMPILEDATE, GITREV);
52+
53+
nvs_flash_init();
54+
55+
odroid_system_init();
56+
57+
esp_err_t ret;
58+
59+
60+
char* fileName;
61+
62+
char* romName = odroid_settings_RomFilePath_get();
63+
if (romName)
64+
{
65+
fileName = odroid_util_GetFileName(romName);
66+
if (!fileName) abort();
67+
68+
free(romName);
69+
}
70+
else
71+
{
72+
fileName = "nesemu-show3.nes";
73+
}
74+
75+
76+
int startHeap = esp_get_free_heap_size();
77+
printf("A HEAP:0x%x\n", startHeap);
78+
79+
80+
ili9341_init();
81+
82+
// Joystick.
83+
odroid_input_gamepad_init();
84+
odroid_input_battery_level_init();
85+
86+
//printf("osd_init: ili9341_prepare\n");
87+
ili9341_prepare();
88+
89+
printf("*****\nHERE\n*****\n");
90+
switch (esp_sleep_get_wakeup_cause())
91+
{
92+
case ESP_SLEEP_WAKEUP_EXT0:
93+
{
94+
printf("app_main: ESP_SLEEP_WAKEUP_EXT0 deep sleep reset\n");
95+
break;
96+
}
97+
98+
case ESP_SLEEP_WAKEUP_EXT1:
99+
case ESP_SLEEP_WAKEUP_TIMER:
100+
case ESP_SLEEP_WAKEUP_TOUCHPAD:
101+
case ESP_SLEEP_WAKEUP_ULP:
102+
case ESP_SLEEP_WAKEUP_UNDEFINED:
103+
{
104+
printf("app_main: Unexpected deep sleep reset\n");
105+
odroid_gamepad_state bootState = odroid_input_read_raw();
106+
107+
if (bootState.values[ODROID_INPUT_MENU])
108+
{
109+
// Force return to menu to recover from
110+
// ROM loading crashes
111+
112+
// Set menu application
113+
odroid_system_application_set(0);
114+
115+
// Reset
116+
esp_restart();
117+
}
118+
119+
if (bootState.values[ODROID_INPUT_START])
120+
{
121+
// Reset emulator if button held at startup to
122+
// override save state
123+
forceConsoleReset = true; //emu_reset();
124+
}
125+
}
126+
break;
127+
128+
default:
129+
printf("app_main: Not a deep sleep reset\n");
130+
break;
131+
}
132+
133+
if (odroid_settings_StartAction_get() == ODROID_START_ACTION_RESTART)
134+
{
135+
forceConsoleReset = true;
136+
odroid_settings_StartAction_set(ODROID_START_ACTION_NORMAL);
137+
}
138+
139+
140+
// Load ROM
141+
char* romPath = odroid_settings_RomFilePath_get();
142+
if (!romPath)
143+
{
144+
printf("osd_getromdata: Reading from flash.\n");
145+
146+
// copy from flash
147+
spi_flash_mmap_handle_t hrom;
148+
149+
const esp_partition_t* part = esp_partition_find_first(0x40, 0, NULL);
150+
if (part == 0)
151+
{
152+
printf("esp_partition_find_first failed.\n");
153+
abort();
154+
}
155+
156+
esp_err_t err = esp_partition_read(part, 0, (void*)ROM_DATA, 0x100000);
157+
if (err != ESP_OK)
158+
{
159+
printf("esp_partition_read failed. size = %x (%d)\n", part->size, err);
160+
abort();
161+
}
162+
}
163+
else
164+
{
165+
printf("osd_getromdata: Reading from sdcard.\n");
166+
167+
// copy from SD card
168+
esp_err_t r = odroid_sdcard_open(SD_BASE_PATH);
169+
if (r != ESP_OK)
170+
{
171+
odroid_display_show_sderr(ODROID_SD_ERR_NOCARD);
172+
abort();
173+
}
174+
175+
size_t fileSize = odroid_sdcard_copy_file_to_memory(romPath, ROM_DATA);
176+
printf("app_main: fileSize=%d\n", fileSize);
177+
if (fileSize == 0)
178+
{
179+
odroid_display_show_sderr(ODROID_SD_ERR_BADFILE);
180+
abort();
181+
}
182+
183+
#ifdef CONFIG_IN_GAME_MENU_YES
184+
char* save_name = odroid_util_GetFileName(romPath);
185+
hud_check_saves(odroid_util_GetFileName(romPath));
186+
#endif
187+
188+
r = odroid_sdcard_close();
189+
if (r != ESP_OK)
190+
{
191+
odroid_display_show_sderr(ODROID_SD_ERR_NOCARD);
192+
abort();
193+
}
194+
195+
free(romPath);
196+
}
197+
198+
199+
printf("NoFrendo start!\n");
200+
201+
char* args[1] = { fileName };
202+
nofrendo_main(1, args);
203+
204+
printf("NoFrendo died.\n");
205+
asm("break.n 1");
206+
return 0;
207+
}

Components/super-go-play/odroid-go-common/components/odroid/odroid_display.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ DRAM_ATTR static const ili_init_cmd_t ili_init_cmds[] = {
161161
//Set Gamma
162162
{0xE0, {0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00}, 15},
163163
{0XE1, {0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F}, 15},
164-
164+
165165
// ILI9342 Specific
166166
{0x36, {0x40|0x80|0x08}, 1}, // <-- ROTATE
167167
{0x21, {0}, 0x80}, // <-- INVERT COLORS
@@ -968,8 +968,8 @@ odroid_display_set_scale(int width, int height, float aspect)
968968

969969
x_inc = SCREEN_WIDTH / x_scale;
970970
y_inc = SCREEN_HEIGHT / y_scale;
971-
x_origin = (SCREEN_WIDTH - (width * x_scale)) / 2.f;
972-
y_origin = (SCREEN_HEIGHT - (height * y_scale)) / 2.f;
971+
x_origin = 0;//(SCREEN_WIDTH - (width * x_scale)) / 2.f;
972+
y_origin = 0;//(SCREEN_HEIGHT - (height * y_scale)) / 2.f;
973973

974974
printf("%dx%d@%.3f x_inc:%d y_inc:%d x_scale:%.3f y_scale:%.3f x_origin:%d y_origin:%d\n",
975975
width, height, aspect, x_inc, y_inc, x_scale, y_scale, x_origin, y_origin);
@@ -1529,4 +1529,4 @@ odroid_buffer_diff_count(odroid_scanline *diff, int height)
15291529
y += diff[y].repeat;
15301530
}
15311531
return n_pixels;
1532-
}
1532+
}

Launchers/.DS_Store

0 Bytes
Binary file not shown.

Launchers/retro-esp32/main/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,8 @@
954954
int ext_length = strlen(EXTENSIONS[STEP]);
955955
bool extenstion = strcmp(&file->d_name[rom_length - ext_length], EXTENSIONS[STEP]) == 0 && file->d_name[0] != '.';
956956
if(extenstion || (file->d_type == 2)) {
957-
SEEK[ROMS.total+1] = telldir(directory);
958-
ROMS.total++;
957+
SEEK[ROMS.total+1] = telldir(directory);
958+
ROMS.total++;
959959
}
960960
}
961961
free(file);
@@ -967,7 +967,7 @@
967967
// printf("\n%s: freed & closed", path);
968968
for(int n = 0; n < ROMS.total; n++) {
969969
// printf("\nSEEK[%d]:%d ", n, SEEK[n]);
970-
}
970+
}
971971
}
972972

973973
// printf("\n---------------------\n");
@@ -1007,7 +1007,7 @@
10071007
draw_text(center,134,message,false,false, false);
10081008
} else {
10091009
// printf("\nSEEK[%d]:%d", ROMS.offset, SEEK[ROMS.offset]);
1010-
rewinddir(directory);
1010+
rewinddir(directory);
10111011
seekdir(directory, SEEK[ROMS.offset]);
10121012
struct dirent *file;
10131013
int n =0;

Scripts/helpers/process

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ then
175175
make -j8
176176
cp ./build/gnuboy-go.bin $FIRMWARE_PATH/Bins/
177177

178-
cd $GOPLAY_PATH
179-
178+
#cd $GOPLAY_PATH
179+
cd $SUPER_GOPLAY_PATH
180180
clear
181181
echo "--------------------------------------------------------------------------"
182182
echo -e "${game} ${green}Compiling ${cyan}nesemu-go${nc}"
@@ -187,11 +187,13 @@ then
187187
make -j8
188188
cp ./build/nesemu-go.bin $FIRMWARE_PATH/Bins/
189189

190+
cd $GOPLAY_PATH
190191
clear
191192
echo "--------------------------------------------------------------------------"
192193
echo -e "${game} ${green}Compiling ${cyan}smsplusgx-go${nc}"
193194
echo "--------------------------------------------------------------------------"
194-
cd ../smsplusgx-go
195+
#cd ../smsplusgx-go
196+
cd smsplusgx-go
195197
get_clean_option
196198
get_config_option
197199
make -j8
@@ -213,7 +215,7 @@ then
213215
echo "--------------------------------------------------------------------------"
214216
echo -e "${game} ${green}Compiling ${cyan}stella-odroid-go${nc}"
215217
echo "--------------------------------------------------------------------------"
216-
cd $EMULATOR_PATH
218+
cd $EMULATOR_PATH
217219
cd stella-odroid-go
218220
get_clean_option
219221
get_config_option
@@ -251,7 +253,7 @@ then
251253
get_clean_option
252254
get_config_option
253255
make -j8
254-
cp ./build/spectrum.bin $FIRMWARE_PATH/Bins/
256+
cp ./build/spectrum.bin $FIRMWARE_PATH/Bins/
255257
fi
256258

257259
cd $SRC_PATH

Tools/.DS_Store

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)