-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support NES emulator with IDF v5 and ESP-BSP #20
base: master
Are you sure you want to change the base?
Conversation
@@ -3,4 +3,6 @@ | |||
nvs, data, nvs, 0x9000, 0x6000 | |||
phy_init, data, phy, 0xf000, 0x1000 | |||
factory, app, factory, 0x10000, 0x0E0000 | |||
nesgame, 0x40, 0x01, 0x100000, 0x300000 | |||
nesrom1, data, spiffs, 0x100000,0x100000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this marked as spiffs?
@@ -45,7 +45,7 @@ | |||
#ifdef PAL | |||
#define NES_REFRESH_RATE 50 | |||
#else /* !PAL */ | |||
#define NES_REFRESH_RATE 60 | |||
#define NES_REFRESH_RATE 40 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, a NTSC NES runs at 60FPS. Not sure why you did this, but please keep the defines that documents basic facts in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he had watchdog problems, just like me. But this is fixed by changing the compilation to PAL.
@@ -36,7 +36,7 @@ | |||
|
|||
/* Visible (NTSC) screen height */ | |||
#ifndef NES_VISIBLE_HEIGHT | |||
#define NES_VISIBLE_HEIGHT 224 | |||
#define NES_VISIBLE_HEIGHT 240 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This here causes the emulator to break due to memory allocation.
#define malloc(s) _my_malloc(s) | ||
//#define free(d) free(d);d=NULL | ||
#define strdup(s) _my_strdup((s)) | ||
|
||
extern void *_my_malloc(int size); | ||
#define free(d) \ | ||
do { \ | ||
free(d); \ | ||
d = NULL; \ | ||
} while (0) | ||
|
||
extern void *_my_malloc(size_t size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these modifications still needed?
@@ -127,7 +128,7 @@ static void *mem_guardalloc(int alloc_size, int guard_size) | |||
alloc_size = (alloc_size + 3) & ~3; | |||
|
|||
/* allocate memory */ | |||
orig = malloc(alloc_size + (guard_size * 2)); | |||
orig = heap_caps_malloc(alloc_size + (guard_size * 2), MALLOC_CAP_DEFAULT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all changes here? heaps_caps_malloc(, MALLOC_CAP_DEFAULT) iirc is the same as malloc().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this code in another project that extends this emulator and it worked. Even memory allocation was my problem and I found the solution here.
@@ -182,7 +182,7 @@ SNSS_WriteFileHeader (SNSS_FILE *snssFile) | |||
char writeBuffer[8]; | |||
|
|||
/* always place the SNSS tag in this field */ | |||
strncpy (&writeBuffer[0], "SNSS", 4); | |||
strncpy (&writeBuffer[0], "SNSS", 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting change. The original was correct actually, but I imagine the compiler complained about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are those img_*.c files in here?
@@ -36,7 +36,7 @@ | |||
|
|||
/* Visible (NTSC) screen height */ | |||
#ifndef NES_VISIBLE_HEIGHT | |||
#define NES_VISIBLE_HEIGHT 224 | |||
#define NES_VISIBLE_HEIGHT 240 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This here causes the emulator to break due to memory allocation.
This is updated the NES emulator portation for using ESP-BSP with latest IDF.