skx / cpmulator

Golang CP/M emulator for zork, Microsoft BASIC, Turbo Pascal, Wordstar, lighthouse-of-doom, etc
MIT License
98 stars 3 forks source link

127 fcb state #128

Closed skx closed 2 months ago

skx commented 2 months ago

Use a better way of keeping track of file-handles

We used to assume that the address of the FCB entry which was used for opening a file would be used for later read/write operations, so we could cache our file-handles keyed on that address.

I've just noticed that multi-file projects in turbo-pascal jump around with their FCB addresses.

So on open/make file requests we store the original FCB address in FCB.AL[0,1] - which will be stable across operations, even if the FCB is in a different address.

I guess we could use file-no instead, but for the moment this seems simple. If N files are opened from the same FCB address we'll be in trouble, but we'll cross that bridge later.

This closes #127.