-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timings issue when code runs in external RAM #5
Comments
It's hard to remember all implementation details as i did it several years ago :) If i remember correctly i've implemented extended RAM as a simple RAM extension without specific timings as there were no tests for that. I don't have real SAM Coupe so i can't test it. Describe the difference, so i will see if it possible to fix. |
It's not easy to describe, but I'll try. The code in external RAM in MIST core runs faster than in internal, as it should be. I'm going to write another test to check if it is exactly as fast as it should or not. The difference I see for now is the exact moment of the color change after out to the CLUT register. This causes a shift of the color change on screen. |
would be good to get a good description of extram timings. |
It seems that external RAM runs in exactly proper speed overall, but something somehow has to cause that shift... I have made some more tests and the screen effect while the code is running in internal RAM always looks exactly the same on both MIST and SimCoupe, but in external RAM is not. Sometimes it is the same, but more often it's not. I have to do more tests... Could you explain why the screen as a whole is shifted to the left by... 8 points? Or less? Border should be the same width on the letf and right but it's not. Maybe it has something to do with it? |
Actually i don't use MiST already long time. I'm using MiSTer with HDMI output where border is perfect. I remember on MiST it was ok on my old setup. |
For now it turned out that I don't have to use external RAM to spot the difference. The same is when I use ROM. When all code runs from internal RAM, the final effect is the same on every platform. But when instead of out (c),a I use call to ROM, to: out (c),a , ret , MIST core starts to differ from the real SAM or SimCoupe emulator. |
Well, for cycle accuracy, fix would be good. From other side, you don't have to execute code from extram. SAM Coupe gives enough sync methods like raster interrupt, to not depend on extram timings. |
It's quite the opposite. I have to execute code from external RAM to get better (faster, smoother) effects. It's just like fast RAM on Amiga. Accurate timings are necessary for effects based on changing colour definitions on the fly. |
Extram on real HW is physically separate device which is not interfering by anything, and only CPU have access to it. In the core, it's the same device as internal RAM. Core doesn't limit speed while RAM is accessed as extram, so it works at max speed, but it's slowed down by video memory access for rendering. While you can slow down the extram, you can't make it work faster by one line. It may need serious changes. Extram probably uses DRAM, so it also needs some refresh cycles. |
timings for internal RAM are controlled by contention model: Line 172 in c8e7a77
Of course it's correct for internal ram since it's well tested. |
The reason is rather ASIC contention, not memory. Writing to ASIC port can last longer because of the contention. I think a slight difference when ASIC should be busy can result in that shift in the moment of colour change. These moments of colour changes are correct most of the time, but one in several changes is too early or too late (I haven't figured out the direction yet). Does my way of thinking make sense? |
ASIC is accessed not only when code is in extram. |
I know that and that's why I think it could be ASIC. But meanwhile I have discovered a bug in z80 code in SAM core - the command CPIR takes the same time as LDIR, but should be faster (I use CPIR or LDIR for delay loops). CPI is ok. |
According to Z80 user manual both instructions use the same amount of clocks. |
Right! I should have checked it first! It was SimCoupe (and my) fault as the real SAM behaves just like MIST core in my cpir/ldir test. |
Recently I've been busy busy trying to catch a bug in ZX Spectrum core, but finally I have prepared two samples where the difference between MIST core and other platforms is clearly visible. |
looking at regular pattern in first test it seems the problem because of shared memory. |
Yes, I have real SAM with external RAM and SimCoupe exactly matches the HW. |
btw, while we talking about MiST here, i'm actually don't develop for MiST. |
So how my sample code work with MiSTer? Correctly or not? |
also wrong, same as MiST as code is basically the same. |
In your test which pages of extram you use? I want to try BRAM for those pages to see if it will fix the issue. |
I use pages 0 and 1 |
can you give me source code of first test from overscan2.zip? |
rept 300 Where inc hl and nop are only to make wider bars and synchronization. Inc hl is here only as a command that lasts 6 clock cycles (a bit more than nop). |
i've got some clue. it's about contention slots.. Strange it works fine when extram is not used. |
I now getting almost correct look of your test, but it's shifted one char to the right. |
Yes. I have compared them all before sharing. And I don't remember to see any difference in graphics between simcoupe and real HW. |
it makes me think there is another stage in redering pipeline which is not implemented yet. |
It's easier for me to write an example: |
SamCoupe.zip |
Great! All my tests and demos look ok now. Thanks! You can update the core code. The only "but" is that it unexpectedly haven't helped in NoAGA demo. Maybe there is another problem. I'll try to debug this demo and prepare a sample with still image showing what's wrong. |
So I have made a sample code with still frame from NoAGA demo, where the issue is clearly visible: |
while i understand purpose of screenshots, i don't understand what app on disk supposed to show. |
App on disk can be run on MiST/MiSTer and compared with simcoupe (or real HW if one has it). It also allows to check how the core modifications affect the result on screen. I can't do a clear screenshot from MiST, so it is better to run such test disk and see how the bug looks like. |
does it mean, it simulates the same timings with colors? So i can tweak the timings and if it will be correct, then column of dots will disappear? |
I don't know what you mean by "the same timings". The same as what? As my earlier tests? I don't know how to compare my previous tests with this one. I'm yet to check how wide that column can be and where it comes from. And yes, if the timigs were correct, then column of dots should disappear. |
Doesn't seem correct. In simcoupe your NoAGA-bug.dsk also has column of dots. |
No, it hasn't. But... I have checked all simcoupe versions I have and 1.0 is ok, the newest compilaton of 1.1 is ok, but every compilations between them show that line! I had no idea about it! I don't know how to explain that, because NoAGA demo works ok on every compilation! But I have to add that there is no line on real HW, I have just checked it. |
ok, fresh build of simcoupe has no that line. |
SamCoupe.zip |
Yes! Finally NoAGA works as it should. As everything else. Thank you! |
While writing a demo for SAM I have noticed a difference between MIST core and SimCoupe/real hardware when the code is executed from the external RAM. I have prepared the small example code to show it:
https://www.dropbox.com/s/bh4nj29tdvtcp4z/overscan.zip?dl=0
Screen looks significantly different than it should.
When it runs in the internal RAM, there is no difference between MIST core and others.
Maybe the same problem causes an issue in NoAGA demo.
The text was updated successfully, but these errors were encountered: