I'm doing my experiments with PAL artifacting, I have simple program which display bitmap in 320x200 mode, and that's it.
Now I added 'calibration' into the code. It scrolls the image a bit when I press keys 1 to 4. I use HSCROL for that. But I run into interesting problems.
First some more info:
The code turns ROM off, all interrupts are pointed at RTI, and disabled. The code just sets up the display, and uses bitmap linked into the XEX, which is generated outside Atari code. The display list is simple, 200 lines, address is set on every line and hscrol is enabled. Dlist is looped using Dlist instruction, not in VBI. As I said, there is no interrupt.
This worked fine. Then I added simple loop, which reads keyboard, and if 1 is pressed it writes different value to hscrol register. Thing is the loop is not synchronized in any way. It runs as fast as possible. And time to time, when I pressed the key, the image disappeared. Altirra shows that Antic reads display list from completely wrong location. The CPU running fine, continues the loop.
So today I did some testing with Bob!k, we double checked everything. In the end we removed all keyboard reading, and left simple code:
loop lda random
This causes the problem every time, and fast, in less than a frame. Antic simply looses the way.
Now .. Altirra emulates this quite well. Everything we tested about this worked the same on real hardware. But reading through Altirra's hardware reference I didn't find this problem. There are many hscrol related 'bugs', but everything described just seem to make Antic read false data when reading VRAM .. not Dlist. Or at least that's the way I understood it. In my case it seems Antic reads false data as Dlist, which makes it miss the Dlist jump instruction.
So we added sta wsync into our code, just before writing to hscrol. We found, that we can write numbers up to 10 into hscrol. 8 was fine. 9 and 10 showed false data in the image, 11 killed the Dlist looping. In the end we found 4 extra nops after wsync make everything run smooth even with 15, and that's where I left it.
It clearly isn't anything new, I just don't know which of the 'bugs' described in the reference it is. For sure I never suspected writing to hscrol at wrong time can kill your Dlist.
Have anyone encountered this problem ? Is there some recommendation when exactly write to hscrol ? Does this apply to some other registers ?
Edited by R0ger, Thu May 31, 2018 3:32 PM.