Falcon030 Blitter emulation in Hatari [SOLVED!]

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.2.0

Moderators: simonsunnyboy, thothy, Moderator Team

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Falcon030 Blitter emulation in Hatari [SOLVED!]

Postby dhedberg » Tue Oct 16, 2018 3:04 pm

Hi,

I'm working on a project at the moment where I use the Blitter in the Falcon030. The code works perfectly well on a real Falcon030 at 50fps, but in Hatari the Blitter seems to use more cycles than on the real machine. How exact are the Falcon030 blitter emulation in Hatari? I'm using the blitter in HOG mode. I suspect it's the Blitter as I've never experienced the emulation to be slower than the real computer when only the CPU is used. It's usually the opposite then. It's a bit sad because I guess this means it'll be hard to produce a nice looking video (using Hatari) of this thing I'm working on.
Last edited by dhedberg on Wed Dec 05, 2018 8:54 pm, edited 1 time in total.
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
troed
Atari God
Atari God
Posts: 1438
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Falcon030 Blitter emulation in Hatari

Postby troed » Tue Oct 16, 2018 6:10 pm

I think you'll get better answers on the Hatari dev mailinglist, but, in general the 68030 emulation is not cycle exact and especially not when interfacing with other components of the system.

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Wed Oct 17, 2018 11:44 am

Thanks for the reply. I'll have tun run some more tests to try and figure out what's going on. In some cases I rely on the fact that the blitter and CPU can run in paralell on the F030 as long as the instructions and data accessed after starting the blitter are precached (no bus activity by CPU). Perhaps Hatari doesn't emulate this fully.
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Wed Oct 17, 2018 1:33 pm

dhedberg wrote:Thanks for the reply. I'll have tun run some more tests to try and figure out what's going on. In some cases I rely on the fact that the blitter and CPU can run in paralell on the F030 as long as the instructions and data accessed after starting the blitter are precached (no bus activity by CPU). Perhaps Hatari doesn't emulate this fully.

Hi
this behaviour is fully emulated for STE, any prefetched opcode will run in parallel if the blitter is started with an instruction which does the write to control register at the end.
As for falcon blitter, I never tested it :)
Theoretically, I guess it could even run several instructions if they were all cached and if none of those instruction require some memory access (for example several MUL / DIV using only Dx registers)
But as said above, even in cycle exact mode, 68030 is not always cycle exact for now, several internal 68030 behaviours are still not known and they affect the way opcodes are prefetched and the way instructions tail/head can sometimes run in parallel.

So for now, I'm afraid you won't get similar results under Hatari as under real HW :(

Nicolas

Edit : it's possible the number of cycles per word access is also wrong in Falcon mode, if you see a x2 difference it could be the case. If you have a simple example (that don't spoil your demo :) ) in hog mode with a screenshot of a real falcon, I could have a look (I guess you're trying to change colors with blitter ?)

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Wed Oct 17, 2018 11:43 pm

Hi Nicolas,

It doesn't seem to be a x2 difference in cycles. I was on the very edge of using 100% CPU time on real hardware so not a big deal. A bit of optimizing and the problem was gone.

However, I discovered a much more serious problem today when I put on the headphones for the first time since I started playing around with the blitter. It seems like Hatari doesn't like semi-heavy use of the blitter while replaying a MP2 using the NoCrow MP2 player (which is pretty heavy on the DSP). Clearing 1 bitplane each frame in HOG mode (which doesn't require very many scanlines on a Falcon) is enough for Hatari to mess up the sound. Sounds like the replay of the MP2 slows down quite a bit. The frame-rate isn't affected, only the sound/replay speed. This doesn't happen on real hardware. I tried removing everything else, and was only playing back the MP2 and clearing 1 bitplane each frame, and the result was the same. If you'd be willing to look into it I'd be most thankful. If I can provide anything to assist you please let me know. I'll be pretty busy the coming 3-4 weeks but after that I'll have more time again.
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Thu Oct 18, 2018 8:11 am

Hi
yes at the moment, blitter was really oriented toward STE mode, not falcon. And while the blitter is in hog mode, the dsp part is also suspended (instead of running it in parallel).
This should be an easy fix in the blitter code, but if you could provide me one simple program that just play an MP2 and a 2nd version that play the same MP2 while running blitter in hog mode , it would allow me to check the fix is correct.

Also, you might subscribe to the hatari-devel mailing list if you have pending issues with falcon emulation, this is is often faster to interact (and not all hatari developpers are reading atari-forum)

Nicolas

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Thu Oct 18, 2018 1:10 pm

Hi,

Sounds great! I'll gladly provide you with some programs, but It'll be a few weeks before I have the time. I'll reach out to you once I have something ready! Thanks a lot! Appreciate it!
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Thu Oct 18, 2018 1:18 pm

No problem, take your time ; I'm also rather limited on spare time at the moment, so as long as problems are fixed in the end, there's no rush.

EDIT : just to know how you could test this later with the devel version, which OS do you use ? Do you compile Hatari yourself ?

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Wed Dec 05, 2018 4:41 pm

Hi,
npomarede wrote:No problem, take your time ; I'm also rather limited on spare time at the moment, so as long as problems are fixed in the end, there's no rush.

Sorry for taking so long, but I've now sent you a PM with test programs. Please let me know if you need anything else. Thank you for taking your time to look into this! Hopefully the fix won't be too hard and make it into the next release of Hatari.

npomarede wrote:EDIT : just to know how you could test this later with the devel version, which OS do you use ? Do you compile Hatari yourself ?

I use Windows 10. I have never compiled Hatari myself, but if I remember correctly there was some kind person that setup a build server with nightly Windows builds a while ago. Hopefully it's still available.

Thanks,
Daniel
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Wed Dec 05, 2018 4:44 pm

Hi
no problem for the long time :)
In the meantime, I updated Hatari anyway to run DSP too while biltter is working, hopefully it should fix the issue ; you can get the devel version here : http://antarctica.no/~hatari/latest/
I will also try later the test program you sent me.

Nicolas

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Wed Dec 05, 2018 5:15 pm

Cool! Thanks! Tried the devel version but unfortunately there was no improvement.
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Wed Dec 05, 2018 5:44 pm

I can hear the difference in your test programs ; there was a copy/paste error in the code for my previous fix, from what I hear, sound is now correct when DSP runs at the same time as DSP.
The devel version at antartica.no should be updated in a few minutes I think.
Thanks for the report

Nicolas

EDIT : by the way, sound quality of this MP2 replayer is really good, I can't really hear the difference between the emulated Falcon playing it and playing the MP2 file directly on my PC :)

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Wed Dec 05, 2018 8:50 pm

Wow! THANK YOU!

It works like a charm and I'm most grateful for your work! I usually develop on real hardware but sometimes I don't have access to it and then I rely 100% on Hatari, and with my latest project it's been hard since I started using the Blitter, but now everything works again!

I'd really like to contribute to the Hatari project but with the little time I have over in the evenings, I haven't really gotten into it. Instead I've spent the time on programming demos, which is something I truly love. The Hatari team received a special thank you in my last demo (More, http://www.pouet.net/prod.php?which=76786), and you'll receive another one in the coming demo. With that said, if you're open for donations I'll gladly donate some money to the team as Hatari has been extremely valuable to me!

PS. I loved your Hatari 2.1 intro! Hope to see something more from you soon! :-) DS.
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Wed Dec 05, 2018 9:06 pm

dhedberg wrote:Wow! THANK YOU!

It works like a charm and I'm most grateful for your work! I usually develop on real hardware but sometimes I don't have access to it and then I rely 100% on Hatari, and with my latest project it's been hard since I started using the Blitter, but now everything works again!

I'd really like to contribute to the Hatari project but with the little time I have over in the evenings, I haven't really gotten into it. Instead I've spent the time on programming demos, which is something I truly love. The Hatari team received a special thank you in my last demo (More, http://www.pouet.net/prod.php?which=76786), and you'll receive another one in the coming demo. With that said, if you're open for donations I'll gladly donate some money to the team as Hatari has been extremely valuable to me!

Thanks for your words, that's what keeps the Atari scene alive :)
Some are working on emulators or fpga clones, some are still coding demos or games, it's often on our spare time, but in the end it's always with the pleasure of keeping the spirit intact.
And even coding demo can be an indirect contribution to Hatari, because it sometimes show what needs to be improved in the emulator (your "More" demo was really nice and polished, lots of work involved)
As for donations, some people already offered to donate, but we don't have a proper structure to collect money. So in my case I would accept you buy a beer with this money instead and drink it to the good health of Hatari :cheers:

PS. I loved your Hatari 2.1 intro! Hope to see something more from you soon! :-) DS.

Opposite problem from you, I'd like to spend more time on coding demos, but working on the emulator itself takes a lot of time :)
A small intro is already on its way for next release, nothing groundbreaking, just a small thing to celebrate a new release.

Nicolas

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Tue Dec 18, 2018 7:59 pm

Hi,

npomarede wrote:Thanks for your words, that's what keeps the Atari scene alive :)
Some are working on emulators or fpga clones, some are still coding demos or games, it's often on our spare time, but in the end it's always with the pleasure of keeping the spirit intact.
And even coding demo can be an indirect contribution to Hatari, because it sometimes show what needs to be improved in the emulator (your "More" demo was really nice and polished, lots of work involved)

Thank you! If you have not done so already, please give it a thumbs up at pouet.net: http://www.pouet.net/prod.php?which=76786
THAT really makes me stay motivated! :lol:

npomarede wrote:As for donations, some people already offered to donate, but we don't have a proper structure to collect money. So in my case I would accept you buy a beer with this money instead and drink it to the good health of Hatari.

Done! Beer was good! :cheers:

npomarede wrote:A small intro is already on its way for next release, nothing groundbreaking, just a small thing to celebrate a new release.

Great! Looking forward to both the next Hatari release and the intro!

If you would have the time I have one more thing I'd like to see in Hatari with regards to Falcon emulation and that is more accurate emulation of changes to the Videl palette. At the moment changes to the palette only take effect at each VBL in Hatari, making it impossible to switch palette in the middle of the screen for instance.

Also, your fix for the blitter + DSP really did wonder, but there's some inaccuracies with the blitter emulation. Falcon030 blitter emulation is slightly slower compared to real hardware. I know this can be due to several reasons such as the 68030 instruction pipeline, instruction and data caches, etc. I haven't really looked into it in any detail, and I haven't really exploited (at least not on purpose) the fact that the 030 can actually run in true parallel to the blitter after the blitter has been actived in hog mode on the Falcon030, as long as there are no bus accesses (everything pre-cached in the instruction/data cache). I think at least in parts of my code that will happen to a certain extent, which would explain why some effects takes too much time to fit in one VBI in Hatari but runs at 50fps on real hardware. I know this one is trickier to do right. One solution would be to just speed up the blitter emulation in Falcon030 mode a notch I guess? It would be better if it was faster rather than slower.

Thanks,
Daniel
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.

User avatar
npomarede
Atari God
Atari God
Posts: 1284
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Falcon030 Blitter emulation in Hatari

Postby npomarede » Wed Dec 19, 2018 10:52 am

dhedberg wrote:Thank you! If you have not done so already, please give it a thumbs up at pouet.net: http://www.pouet.net/prod.php?which=76786
THAT really makes me stay motivated! :lol:

Done , but in that case you need to thumb up hatari's intros too :)
Great! Looking forward to both the next Hatari release and the intro!

If you would have the time I have one more thing I'd like to see in Hatari with regards to Falcon emulation and that is more accurate emulation of changes to the Videl palette. At the moment changes to the palette only take effect at each VBL in Hatari, making it impossible to switch palette in the middle of the screen for instance.
I'm not too familiar with Videl at the moment as this part of the emulation was written by LaurentS IIRC, so I can't say.
Also, your fix for the blitter + DSP really did wonder, but there's some inaccuracies with the blitter emulation. Falcon030 blitter emulation is slightly slower compared to real hardware. I know this can be due to several reasons such as the 68030 instruction pipeline, instruction and data caches, etc. I haven't really looked into it in any detail, and I haven't really exploited (at least not on purpose) the fact that the 030 can actually run in true parallel to the blitter after the blitter has been actived in hog mode on the Falcon030, as long as there are no bus accesses (everything pre-cached in the instruction/data cache). I think at least in parts of my code that will happen to a certain extent, which would explain why some effects takes too much time to fit in one VBI in Hatari but runs at 50fps on real hardware. I know this one is trickier to do right. One solution would be to just speed up the blitter emulation in Falcon030 mode a notch I guess? It would be better if it was faster rather than slower

I think this just reaches the limitation of the current 68020/68030 emulation which is not fully cycle exact at the moment. Some instructions will appear to run faster or slower under Hatari (depending on pipeling, cache, bus accesses queuing and so on), so when you compare the emulated cpu with the emulated blitter or emulated dsp, you will notice that they don't increase cycles at the same pace as on real HW. Unfortunately, there's no immediate fix for this, this requires a much deeper analysis of the inner work of the 68020/68030 (as was done with the 68000 Motorola patents that can be found, except I never saw such detailed patents to describe the 68020/30 microcode)

Nicolas

User avatar
dhedberg
Atari Super Hero
Atari Super Hero
Posts: 932
Joined: Mon Aug 30, 2010 8:36 am
Contact:

Re: Falcon030 Blitter emulation in Hatari

Postby dhedberg » Thu Dec 20, 2018 12:34 am

npomarede wrote:
dhedberg wrote:Thank you! If you have not done so already, please give it a thumbs up at pouet.net: http://www.pouet.net/prod.php?which=76786
THAT really makes me stay motivated! :lol:

Done, but in that case you need to thumb up hatari's intros too :)Nicolas

Thank you! Appreciate it! I've paid you back now! :-)

npomarede wrote:
dhedberg wrote:If you would have the time I have one more thing I'd like to see in Hatari with regards to Falcon emulation and that is more accurate emulation of changes to the Videl palette. At the moment changes to the palette only take effect at each VBL in Hatari, making it impossible to switch palette in the middle of the screen for instance.

I'm not too familiar with Videl at the moment as this part of the emulation was written by LaurentS IIRC, so I can't say.

This was one thing that I intended to have a look at before I started programming demos again! Maybe after I've finished the demo I'm working on for the moment I'll have time to dig into the Hatari sources and see if I can help.

npomarede wrote:
dhedberg wrote:Also, your fix for the blitter + DSP really did wonder, but there's some inaccuracies with the blitter emulation. Falcon030 blitter emulation is slightly slower compared to real hardware. I know this can be due to several reasons such as the 68030 instruction pipeline, instruction and data caches, etc. I haven't really looked into it in any detail, and I haven't really exploited (at least not on purpose) the fact that the 030 can actually run in true parallel to the blitter after the blitter has been actived in hog mode on the Falcon030, as long as there are no bus accesses (everything pre-cached in the instruction/data cache). I think at least in parts of my code that will happen to a certain extent, which would explain why some effects takes too much time to fit in one VBI in Hatari but runs at 50fps on real hardware. I know this one is trickier to do right. One solution would be to just speed up the blitter emulation in Falcon030 mode a notch I guess? It would be better if it was faster rather than slower

I think this just reaches the limitation of the current 68020/68030 emulation which is not fully cycle exact at the moment. Some instructions will appear to run faster or slower under Hatari (depending on pipeling, cache, bus accesses queuing and so on), so when you compare the emulated cpu with the emulated blitter or emulated dsp, you will notice that they don't increase cycles at the same pace as on real HW. Unfortunately, there's no immediate fix for this, this requires a much deeper analysis of the inner work of the 68020/68030 (as was done with the 68000 Motorola patents that can be found, except I never saw such detailed patents to describe the 68020/30 microcode)

In the meantime I'll spend some more time to utilize the real hardware Blitter-CPU parallelism. ;-)

Thanks,
Daniel
Daniel, New Beat - http://newbeat.atari.org. Like demos? Have a look at our new Falcon030 demo MORE.


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 1 guest