1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-21 23:29:16 +00:00

Make use of our read/write mappers

This commit is contained in:
Peter Evans 2017-12-12 15:00:47 -06:00
parent e019b6daee
commit 7da3c2ec20

View File

@ -95,6 +95,12 @@ vm_segment_set(vm_segment *segment, size_t index, vm_8bit value)
return ERR_OOB;
}
// Check if we have a write mapper
if (segment->write_table[index]) {
segment->write_table[index](segment, index, value);
return OK;
}
segment->memory[index] = value;
return OK;
}
@ -117,6 +123,11 @@ vm_segment_get(vm_segment *segment, size_t index)
exit(1);
}
// We may have a read mapper for this address
if (segment->read_table[index]) {
return segment->read_table[index](segment, index);
}
return segment->memory[index];
}