Skip to content

Conversation

@espzav
Copy link

@espzav espzav commented Jun 6, 2023

This is updated the NES emulator portation for using ESP-BSP with latest IDF.

phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 0x0E0000
nesgame, 0x40, 0x01, 0x100000, 0x300000
nesrom1, data, spiffs, 0x100000,0x100000
Copy link
Member

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?

#define NES_REFRESH_RATE 50
#else /* !PAL */
#define NES_REFRESH_RATE 60
#define NES_REFRESH_RATE 40
Copy link
Member

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.

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.

/* Visible (NTSC) screen height */
#ifndef NES_VISIBLE_HEIGHT
#define NES_VISIBLE_HEIGHT 224
#define NES_VISIBLE_HEIGHT 240
Copy link
Member

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?

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.

Comment on lines +49 to +59
#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);
Copy link
Member

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?


/* allocate memory */
orig = malloc(alloc_size + (guard_size * 2));
orig = heap_caps_malloc(alloc_size + (guard_size * 2), MALLOC_CAP_DEFAULT);
Copy link
Member

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().

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.


/* always place the SNSS tag in this field */
strncpy (&writeBuffer[0], "SNSS", 4);
strncpy (&writeBuffer[0], "SNSS", 5);
Copy link
Member

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.

Copy link
Member

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?

/* Visible (NTSC) screen height */
#ifndef NES_VISIBLE_HEIGHT
#define NES_VISIBLE_HEIGHT 224
#define NES_VISIBLE_HEIGHT 240

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants