cadet1620 wrote
One way to get a larger screen buffer might be to use addresses 32768 - 65535. This gets a bit weird in hack since everything is signed. That screen would appear to be based at -32768.
Good idea. Actually the code could be pretty clean from the user perspective, as long as the compiler magically translates numbers larger than 32768 into their negative signed 16 bits equivalent. The machine code will basically get a negative number and the CPU simulator could use something like:
if(s >= 0) {
indx = s;
} else {
indx = 65536 - std::abs(s);
}
From the user perspective he works with unsigned 16 bit ints for indexes. It is actually quite nice because as long as you have the correct offset of an array (say -40000) you can go forward simply by adding +1 and because int16_t wraps up you will get the negative indexes in the correct order. The burden to convert negative indexes into positive ones resides with the CPU Emulator.