For all commentators about AtariZoll's bug report: please look carefully at the code he provided in his initial post
. I'm afraid that most comments missed the key point.
Here is the relevant part:
Code: Select all
statVec jsr 0 *** ************ call previous (ROM) statvec ***********
* Need d0 negative , as release signal
st relFlag * Key pressed flag
AtariZoll: Here is what I understand from your code.
1) You install your own statvec callback, implemented at "statVec" label.
2) You call the previous statvec (ROM one) using self-modified code.
I have no problem with self-modifying code, it is valid when caches are off.
3) You call the ROM statvec directly with JSR. This violates the statvec contract.
The doc says that the parameter is present both in a0 and on the stack. So at the beginning of your own callback, the parameter will effectively be in a0 and (sp). Then you call the ROM statvec with jsr, which pushes the return address on the stack. So that ROM statvec will have the correct value in a0, but not on (sp). If it works on some TOS, it is by chance because the ROM implementation of statvec ignores the parameter in (sp).
4) You check d0.b after
calling the ROM statvec. This is a nonsense because, as it was already mentioned, the statvec callback is not supposed to return anything. So that d0.b has no real meaning, is just some garbage left by the implementation.
Points 3) and 4) are enough to say that your code is wrong, according to the documentation. Of course I admit it can work (I mean: not fail) on a particular implementation, but that's by chance. As it relies on undefined behaviour, it could fail on any other TOS-like operating system.
AtariZoll wrote:As said it works in all TOS versions 1.00-4.04 . I don't care for MagiC, Mint etc ...
No problem with that. You write code relying on undocumented (and even non-intentional) TOS features, so it will only work for those specific TOS versions. Some old games do that (STOS games...), so they need specific TOS versions. Usually, nowadays, people prefer to write clean code relying on documented behaviour. But everyone is free to code as he wants. I just say that such code will not work with EmuTOS, as, by choice, we don't implement TOS unintentional side effects.
Regarding to statvec contract: I'm surprised that statvec is called for key releases. I thought it was only called when receiving IKBD status packets, such as mouse moves or joystick events. It should be checked if EmuTOS really calls statvec on key releases, if Atari TOS does that.
Eero Tamminen wrote:As you've traced a lot of programs (mostly games I assume), can you say how much there's other Atari code (than your own game launchers) which rely on this behavior?
I would really be interested by the answer.