Hello, quick question.
Why wouldn't the file open? The directory I am accessing is correct when I tried ls /path/to/*.bin , but it does not recognise the path as it seems.
uint8_t ram[0x10000];
int
load_file(m65xx_core_t* const m, const char* file_to_load, uint16_t addr)
{
printf("Trying to open file: '%s'\n", file_to_load);
FILE *f = fopen(file_to_load, "rb");
if(f == NULL)
{
fprintf(stderr, "**" RED " Error " RESET "** " "file couldn't be opened");
return 1;
}
fseek(f, 0, SEEK_END);
size_t file_size = ftell(f);
rewind(f);
if(file_size + addr > 0x10000)
{
fprintf(stderr, "\n**" RED "Error" RESET "** " "file size to large\n");
fclose(f);
return 1;
}
size_t file_read = fread(&ram[addr], sizeof(uint8_t), file_size, f);
if(file_read != file_size)
{
fprintf(stderr, "**" RED " Error " RESET "** " "file \"%s\" couldn't be read into memory" , file_to_load);
fclose(f);
return 1;
}
fclose(f);
return 0;
}
static int execute_allsuiteasm(m65xx_core_t* const m, const char* file_to_load) {
memset(ram, 0, 0x10000);
// Check if the file was loaded successfully
if (load_file(m, file_to_load, 0x4000) != 0) {
fprintf(stderr, "**" RED " Error " RESET "** failed to load file. Aborting execution.\n");
return 1; // Exit if file loading fails.
}
m65xx_power(m);
printf("\n** file loaded: " BOLD "%s" RESET " **\n", file_to_load);
while (1) {
m65xx_run(m);
if (m->pc == 0x45C0) {
if (rb(m, 0x0210) == 0xFF) {
printf(GREEN "✓" RESET " - test passed!\n");
} else {
printf(RED "✘" RESET " - test failed!\n");
}
break;
}
}
return 0;
}
main(): execute_allsuiteasm(&m, "../tests/AllSuiteA.bin");