f0lg0/CHIP-8

Improving load_rom()

Closed this issue · 1 comments

f0lg0 commented

As suggested by a oh5nxo on Reddit, the function load_rom() could be improved in the following way:

void load_rom(char* filename) {
    FILE* fp = fopen(filename, "rb");

    // read program size into memory
    fread(memory + 0x200, 1, sizeof(memory) - 0x200, fp);

    fclose(fp);
}

From a quick first test, it seems good. Waiting to update to give it a better look.

f0lg0 commented

Implemented.