badvision / esp32_nesemu

Based on espressif's nesemu port with MittisBootloop's "Pretty Effect" menu. Supports PSX Controller and either SD Card or SPIFFS [Platform.IO]
41 stars 10 forks source link

identifier "spi_flash_mmap_handle_t" is undefinedC/C++(20) and identifier "SPI_FLASH_MMAP_DATA" is undefinedC/C++(20) #4

Open Jailin opened 1 year ago

Jailin commented 1 year ago

No idea what to do.

char osd_getromdata() { char romdata; spi_flash_mmap_handle_t handle; esp_err_t err;

// Locate our target ROM partition where the file will be loaded
esp_partition_t *part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, 0xFF, "rom");
if (part == 0)
    printf("Couldn't find rom partition!\n");

ifndef SKIP_MENU

// Open the file
printf("Reading rom from %s\n", selectedRomFilename);
FILE *rom = fopen(selectedRomFilename, "r");
long fileSize = -1;
if (!rom)
{
    printf("Could not read %s\n", selectedRomFilename);
    exit(1);
}

// First figure out how large the file is
fseek(rom, 0L, SEEK_END);
fileSize = ftell(rom);
rewind(rom);
if (fileSize > part->size)
{
    printf("Rom is too large!  Limit is %dk; Rom file size is %dkb\n",
           (int)(part->size / 1024),
           (int)(fileSize / 1024));
    exit(1);
}

// Copy the file contents into EEPROM memory
char buffer[READ_BUFFER_SIZE];
int offset = 0;
while (fread(buffer, 1, READ_BUFFER_SIZE, rom) > 0)
{
    if ((offset % 4096) == 0)
        esp_partition_erase_range(part, offset, 4096);
    esp_partition_write(part, offset, buffer, READ_BUFFER_SIZE);
    offset += READ_BUFFER_SIZE;
}
fclose(rom);
// free(buffer);
printf("Loaded %d bytes into ROM memory\n", offset);

else

size_t fileSize = part->size;

endif

// Memory-map the ROM partition, which results in 'data' pointer changing to memory-mapped location
err = esp_partition_mmap(part, 0, fileSize, SPI_FLASH_MMAP_DATA, (const void **)&romdata, &handle);
if (err != ESP_OK)
    printf("Couldn't map rom partition!\n");
printf("Initialized. ROM@%p\n", romdata);

return (char *)romdata;

}

paulo101977 commented 2 months ago

No idea what to do.

char osd_getromdata() { char romdata; spi_flash_mmap_handle_t handle; esp_err_t err;

// Locate our target ROM partition where the file will be loaded
esp_partition_t *part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, 0xFF, "rom");
if (part == 0)
  printf("Couldn't find rom partition!\n");

ifndef SKIP_MENU // Open the file printf("Reading rom from %s\n", selectedRomFilename); FILE *rom = fopen(selectedRomFilename, "r"); long fileSize = -1; if (!rom) { printf("Could not read %s\n", selectedRomFilename); exit(1); }

// First figure out how large the file is
fseek(rom, 0L, SEEK_END);
fileSize = ftell(rom);
rewind(rom);
if (fileSize > part->size)
{
  printf("Rom is too large!  Limit is %dk; Rom file size is %dkb\n",
         (int)(part->size / 1024),
         (int)(fileSize / 1024));
  exit(1);
}

// Copy the file contents into EEPROM memory
char buffer[READ_BUFFER_SIZE];
int offset = 0;
while (fread(buffer, 1, READ_BUFFER_SIZE, rom) > 0)
{
  if ((offset % 4096) == 0)
      esp_partition_erase_range(part, offset, 4096);
  esp_partition_write(part, offset, buffer, READ_BUFFER_SIZE);
  offset += READ_BUFFER_SIZE;
}
fclose(rom);
// free(buffer);
printf("Loaded %d bytes into ROM memory\n", offset);

else size_t fileSize = part->size; #endif

// Memory-map the ROM partition, which results in 'data' pointer changing to memory-mapped location
err = esp_partition_mmap(part, 0, fileSize, SPI_FLASH_MMAP_DATA, (const void **)&romdata, &handle);
if (err != ESP_OK)
  printf("Couldn't map rom partition!\n");
printf("Initialized. ROM@%p\n", romdata);

return (char *)romdata;

}

I'm continuing the project. I've already managed to compile it. I'm just making an error with images, but I'm almost solving it too. Follow the link: https://github.com/paulo101977/esp32_nesemu