Bad Mood : Falcon030 'Doom'

All 680x0 related coding posts in this section please.

Moderators: Zorro 2, Moderator Team

User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

I did some experiments this evening with the gametick and I seem to be approaching something like a satisfactory compromise for performance vs gameplay.


Short version: The game is now running with approx 2 ticks per render (range bound between 1 and 3), using a modified version of the framerate-adaptive system. So movement speed remains constant as framerate fluctuates.

(Using the original, unmodified code, it wants to run about 6 ticks per render but ends up trying to do many more because of its own poor performance at 16mhz).


Long version:

First, I tried disabling framerate-adaptive behaviour - so the game plays like 'timedemo' mode with 2 ticks per render - and got that working, but the result was awful. The framerate is too variable and correlated with view direction as much as location. It feels like slow motion suddenly when you meet monsters, and entering a narrow corridor causes you to run unexpectedly. Not good.

I tried just capping the number of ticks allowed to per render to 2, and this also produced terrible results. The tick system generates event packets for each gametick and capping causes some of these to get dropped, so weird things happen. The most obvious problem is 'lag' from the controls - stepping sideways with a keypress doesn't actually happen until a few frames later. After mucking about with that for a while I abandoned the idea. It did work to limit spikes if the cap was set just above the average tick count, but set it lower and there are problems so it wasn't really helping.


While trawling through the code for the TryRunTicks and NetUpdate processes, I began to realize there is a sort of insidious flaw in there, which is probably due to the network stuff needing to be fast and synchronous and in constant contact with the other nodes. But it is a flaw from BM's point of view and is directly causing (really, amplifying) the worst case scenario when trying to track live ticks in realtime.

The whole gametick loop - which tries to tick the game enough times to catch up with the current realtime clock - is continuously checking the clock at different points within the process (!). The time is constantly moving on, so it keeps getting confused and finding more work to do, corresponding to the time taken by the gametick stuff itself. This is causing more ticks to happen than desired - it particularly encourages runaway spikes and nonlinear cost.

So I made some mods which trick the realtime clock into reporting time deltas only once per gametick 'turn' vs the renderer. The clock reports an accurate change in time, but only once. Sampling the clock within the gametick loop doesn't indicate any change in time, so the loop exits early. The time actually taken by the gametick process will register the next time round so no time actually gets lost.

This actually works. The game on average ticks one less than before, and the spikes have been ironed out. It would typically float around 2 ticks per frame, and rise to 3 on direction changes, spiking to 4-5 when you shoot something. Now it hangs around 1-2, and only jumps to 3 in a fight. That's quite a big saving given the high cost of each tick. The game feels basically the same. What's more, the lower average tick count means capping becomes safe to use, at around 3, for any untested worst-cases.

So the best solution seems to be:

- leave the adaptive gametick system mostly alone
- freeze realtime during the gametick catchup process, but keep track of the time wasted in there
- cap the tick count to 3 per render, max


These tests were done with a 12Hz tick frequency. I have also tested with 9Hz and that works even better but it causes some problems with AIs. I may return to that another time. The current setup is good enough for now.


On another topic - had some problems with the game not running reliably on a real Falcon. Turned out to be a few pieces of DSP code doing things which the DSP user manual warns are not legal, and cause undefined results :) Unfortunately Hatari accepted this code without complaint so I didn't notice the flaky behaviour until the last few days. This is mainly because I was trying to record a new video of gameplay - which needless to say, didn't happen :)
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3999
Joined: Sun Jul 31, 2011 1:11 pm

Re: Bad Mood : Falcon030 'Doom'

Post by Eero Tamminen »

dml wrote:On another topic - had some problems with the game not running reliably on a real Falcon. Turned out to be a few pieces of DSP code doing things which the DSP user manual warns are not legal, and cause undefined results :) Unfortunately Hatari accepted this code without complaint so I didn't notice the flaky behaviour until the last few days.
Good to know. Please report these to hatari-devel / Laurent.

Gametick stuff sounds good too. :-)
User avatar
LaurentS
Captain Atari
Captain Atari
Posts: 316
Joined: Mon Jan 05, 2009 5:41 pm

Re: Bad Mood : Falcon030 'Doom'

Post by LaurentS »

Hi Doug,

Yes please. Don't hesitate to report me the problems you encountered. If i can fix them...

Regards

Laurent/Thadoss
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

Hi Laurent,

In this case it's probably not needing fixed - it's undefined behaviour so I think there's no way you can emulate it accurately. The only solution is to avoid doing those things in the program (in this case, it was a jmp to end of do loop - not allowed).

:)
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

This is probably the last video for a while. Process just takes too long.

http://youtu.be/oBxiuxtspYU


I picked a heavy duty level with lots of textures and decoration and plenty of monsters, to give it a good proper test.

Quality isn't great - it was recorded off RGB display with a camcorder. There was sound but it was not captured well so I replaced it!
EvilFranky
Atari Super Hero
Atari Super Hero
Posts: 926
Joined: Thu Sep 11, 2003 10:49 pm
Location: UK

Re: Bad Mood : Falcon030 'Doom'

Post by EvilFranky »

Crazy! :mrgreen:
User avatar
FedePede04
Atari God
Atari God
Posts: 1215
Joined: Fri Feb 04, 2011 12:14 am
Location: Denmark

Re: Bad Mood : Falcon030 'Doom'

Post by FedePede04 »

Great Video....
nice to see a video of your work in progress,
but you are right it just take so long to make videos, special if you do a lot of cutting...
Atari will rule the world, long after man has disappeared

sometime my English is a little weird, Google translate is my best friend :)
rian_ata
Captain Atari
Captain Atari
Posts: 269
Joined: Mon Apr 24, 2006 10:00 pm
Location: Netherlands

Re: Bad Mood : Falcon030 'Doom'

Post by rian_ata »

Again and again I am impressed. Man, this is awesomeness in all its glory! :cheers:
User avatar
Cyprian
10 GOTO 10
10 GOTO 10
Posts: 3362
Joined: Fri Oct 04, 2002 11:23 am
Location: Warsaw, Poland

Re: Bad Mood : Falcon030 'Doom'

Post by Cyprian »

impressive Doug
ATW800/2 / V4sa / Lynx I / Mega ST 1 / 7800 / Portfolio / Lynx II / Jaguar / TT030 / Mega STe / 800 XL / 1040 STe / Falcon030 / 65 XE / 520 STm / SM124 / SC1435
DDD HDD / AT Speed C16 / TF536 / SDrive / PAK68/3 / Lynx Multi Card / LDW Super 2000 / XCA12 / SkunkBoard / CosmosEx / SatanDisk / UltraSatan / USB Floppy Drive Emulator / Eiffel / SIO2PC / Crazy Dots / PAM Net
http://260ste.atari.org
User avatar
shoggoth
Nature
Nature
Posts: 1447
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden

Re: Bad Mood : Falcon030 'Doom'

Post by shoggoth »

Pure awesomeness. Looking forward to another test binary!
Ain't no space like PeP-space.
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

Thanks everyone for kind comments and following the project. :cheers:
User avatar
yerzmyey
Atari Super Hero
Atari Super Hero
Posts: 602
Joined: Fri Sep 19, 2008 12:23 pm

Re: Bad Mood : Falcon030 'Doom'

Post by yerzmyey »

Hi there.
Is it possible to download it?
I gather it is this game? http://www.youtube.com/watch?v=oBxiuxts ... e=youtu.be
http://ym-digital.i-demo.pl/ ATARI 520ST music-band
http://ay-riders.speccy.cz/ ZX Spectrum music-band
http://yerzmyey.i-demo.pl/ ZX/A500/A1200/ST/XL music
https://soundcloud.com/yerzmyey ZX/A500/A1200/ST/STE/F030 music
http://z80.i-demo.pl/ MP3 archive of Z80 chip music
No good deed will escape unpunished.
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

yerzmyey wrote:Hi there.
Is it possible to download it?
I gather it is this game? http://www.youtube.com/watch?v=oBxiuxts ... e=youtu.be
Not quite yet but I'll post another test binary quite soon - I'm still fixing some bugs and the menus need straightened out.
EvilFranky
Atari Super Hero
Atari Super Hero
Posts: 926
Joined: Thu Sep 11, 2003 10:49 pm
Location: UK

Re: Bad Mood : Falcon030 'Doom'

Post by EvilFranky »

Doug,

I know it has already been stated that with a rework of the AI this engine would end up being even faster.

Do you think an even more Falcon specific engine could be made that would run even faster still? I'm under the impression that Bad Mood is constrained by the fact it's Doom and has to stick with Doom data files & its mechanics.

Does that make sense? :lol:

If you were to code a 3D FPS engine from scratch, would there be things you could do differently that would make a big difference?
User avatar
yerzmyey
Atari Super Hero
Atari Super Hero
Posts: 602
Joined: Fri Sep 19, 2008 12:23 pm

Re: Bad Mood : Falcon030 'Doom'

Post by yerzmyey »

dml wrote: Not quite yet but I'll post another test binary quite soon - I'm still fixing some bugs and the menus need straightened out.
I just wanted to say that this is utterly and totally incredible stuff and I'm shocked.
Great work and I do hope it will be finished. :)
The screen is 4 times bigger than on Amiga1200 (with similar speed of the game).
I wait for the game impatiently. ;)
http://ym-digital.i-demo.pl/ ATARI 520ST music-band
http://ay-riders.speccy.cz/ ZX Spectrum music-band
http://yerzmyey.i-demo.pl/ ZX/A500/A1200/ST/XL music
https://soundcloud.com/yerzmyey ZX/A500/A1200/ST/STE/F030 music
http://z80.i-demo.pl/ MP3 archive of Z80 chip music
No good deed will escape unpunished.
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

EvilFranky wrote: If you were to code a 3D FPS engine from scratch, would there be things you could do differently that would make a big difference?
You could make an engine faster than BadMood, yes. Id's 1990's tech isn't the last word on rendering and there are coders around better than me and probably with more time than I have. There are some things I would have done differently if I started from scratch now, although I do need to stop this sometime and do something else :)

Having said that, you could go quite far with BM as it is, and a homebrew game written in a mixture of C and asm. It could be up to 2x faster than this for the same sized display.
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

yerzmyey wrote: I just wanted to say that this is utterly and totally incredible stuff and I'm shocked.
Great work and I do hope it will be finished. :)
The screen is 4 times bigger than on Amiga1200 (with similar speed of the game).
I wait for the game impatiently. ;)
Thanks :) I forgot to note the resolution but I think it was the same as before 224 wide. Unfortunately LCD monitors and TVs make the game look more jerky than it should be on a real RGB monitor due to the high refresh rate - so I think it would have looked smoother back in those early days on a CRT. The video encoding/youtube smoothed it back out a bit but its still a bit noticeable...
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3999
Joined: Sun Jul 31, 2011 1:11 pm

Re: Bad Mood : Falcon030 'Doom'

Post by Eero Tamminen »

With 1.5MB alloc, overlay WADs work.

So far "mtfactor.wad" & "polygon.wad" are the only Doom II wads I got to load without the "fseek to insane value" problem.

"mtfactor.wad" scenery is a bit hard to see properly with BM, but it's problematic with PrBoom too as it has lots of height differences and tight corners. In BM it's also impossible to pick one of the stimpacks in the very beginning.

"polygon.wad" looks better in BM, but it has lower FPS and in some places it's really slow without any visible reason. I think I need to profile it a bit later.


Of the Doom I wads, "teutic.wad" and "eternity.wad" work well and e.g. last one is IMHO pretty nice.

For some reason other Doom I pwads got stuck at sound init. CPU was looping on some unnamed code coming after "init_font" (as it's unnamed, I think it could be code that sometimes shows in profiles assigned under "init_font").
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3999
Joined: Sun Jul 31, 2011 1:11 pm

Re: Bad Mood : Falcon030 'Doom'

Post by Eero Tamminen »

dml wrote:This is probably the last video for a while. Process just takes too long.
If you're demoing new visuals instead of FPS on real machine, you could record from the emulator using Hatari's video recording feature and a suitable timedemo + converting the resulting AVI file to something more compact afterwards. Timedemo usage may be needed because video recording slows down things quite a bit (depending on what compression you select).
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3999
Joined: Sun Jul 31, 2011 1:11 pm

Re: Bad Mood : Falcon030 'Doom'

Post by Eero Tamminen »

Eero Tamminen wrote:I also tried latest FreeDoom:
http://www.nongnu.org/freedoom/download.html

While the "Doom II" replacement WAD gives this from timedemo and trying to play myself:

Code: Select all

Demo is from a different game version!
Error: Z_Malloc: failed on allocation of 127436 bytes
With the version checks disabled, I get now this from FreeDoom doom2.wad replacement timedemo:

Code: Select all

Error: Bad music number 143
And this if I try to start a new game:

Code: Select all

Error: R_TextureNumForName: MFADEMAP.. not found
Eero Tamminen wrote: The "Ultimate Doom" replacement nearly works:
http://savannah.nongnu.org/download/fre ... latest.zip

It loaded with couple of warnings:

Code: Select all

WARNING: have to clip 4 chars from 'FLOOR4_8=�.bmp' base!
WARNING: have to clip 4 chars from 'TLITE6_5]�.bmp' base!
WARNING: have to clip 4 chars from 'TLITE6_1=�.bmp' base!
WARNING: have to clip 4 chars from 'FLOOR5_1M�.bmp' base!
WARNING: have to clip 4 chars from 'TLITE6_4M�.bmp' base!
And the timedemo started running. However, after a while the part around the screen got messed up and eventually demo playback stopped to this:

Code: Select all

Error: NetUpdate: netbuffer->numtics > BACKUPTICS
I still get the warnings and error, but the screen corruption is gone.

As I also see the "VILE" warnings on Doom II startup, maybe you didn't commit fix for the paths yet?
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

Eero Tamminen wrote:With 1.5MB alloc, overlay WADs work.

So far "mtfactor.wad" & "polygon.wad" are the only Doom II wads I got to load without the "fseek to insane value" problem.
Can you send me one or two of the ones which don't work? Smaller ones should be fine. But they should work with vanilla Doom II either under DOS or compiled from the Linux sources - not some fancy port as it's impossible to tell if they use unusual features. i can run Dos Doom II here to check that thankfully.
Eero Tamminen wrote: "mtfactor.wad" scenery is a bit hard to see properly with BM, but it's problematic with PrBoom too as it has lots of height differences and tight corners. In BM it's also impossible to pick one of the stimpacks in the very beginning.
I noticed the refusal to pick up some items. I think it's a problem with line-of-sight caching which I added recently getting stuck with certain objects. LOS tests are used for other less obvious things, like checking things near the player's feet.
Eero Tamminen wrote: "polygon.wad" looks better in BM, but it has lower FPS and in some places it's really slow without any visible reason. I think I need to profile it a bit later.
I found that the original Doom levels were very carefully made to use sectors efficiently. Many of the PWAD overlays were made much later, by people with faster boxes and a less well formed understanding of level efficiency. So some of those maps look nice, while saturating the machine.

Eero Tamminen wrote: Of the Doom I wads, "teutic.wad" and "eternity.wad" work well and e.g. last one is IMHO pretty nice.
eternity uses lots of concentric sectors to shade floors, in some places almost imperceptibly. I turned texturing off to find them and was surprised at what showed up.

It is expensive to draw though, with an average walls-per-subsector count averaging below 2. Fast maps average between 2-5.

I might post a screenshot to show what I mean.
Eero Tamminen wrote: For some reason other Doom I pwads got stuck at sound init. CPU was looping on some unnamed code coming after "init_font" (as it's unnamed, I think it could be code that sometimes shows in profiles assigned under "init_font").
Hard to say what that might be. If you keep a note of any which don't work but you are fairly sure are vanilla PWADs I'll look into it though. Should be possible to get all the 'normal' ones working and maybe a subset of the funny Boom/ZDoom ones if they dont depend on special features.
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

Eero Tamminen wrote:
With the version checks disabled, I get now this from FreeDoom doom2.wad replacement timedemo:

Code: Select all

Error: Bad music number 143
And this if I try to start a new game:

Code: Select all

Error: R_TextureNumForName: MFADEMAP.. not found
This is typical of a WAD/code mismatch. The code is trying to load named resources which aren't there or don't match in some way.

e.g. if you try to load DOOMU.WAD into Doom II you'll get this sort of thing.

Unfortunately, it's not a bug of mine to fix. It's a hunt through source ports to find out what these things are and what they are used for, if needed at all, and then possibly integrating changes (at the very least, changing the code).
Eero Tamminen wrote: The "Ultimate Doom" replacement nearly works:
http://savannah.nongnu.org/download/fre ... latest.zip

It loaded with couple of warnings:

Code: Select all

WARNING: have to clip 4 chars from 'FLOOR4_8=�.bmp' base!
WARNING: have to clip 4 chars from 'TLITE6_5]�.bmp' base!
WARNING: have to clip 4 chars from 'TLITE6_1=�.bmp' base!
WARNING: have to clip 4 chars from 'FLOOR5_1M�.bmp' base!
WARNING: have to clip 4 chars from 'TLITE6_4M�.bmp' base!
I suspect it's just an incomplete fix. I'll look again.
Eero Tamminen wrote: And the timedemo started running. However, after a while the part around the screen got messed up and eventually demo playback stopped to this:

Code: Select all

Error: NetUpdate: netbuffer->numtics > BACKUPTICS
That one is fairly straightforward. Demo lump incompatibility. There's no practical way to convert or support it, except to reinstate the version check for demo lumps. Which I think is what we should do here.
Eero Tamminen wrote:As I also see the "VILE" warnings on Doom II startup, maybe you didn't commit fix for the paths yet?
I did, but I think there was more to it than capping those wad directory strings to 8 chars. They must also be terminated (and not just space padded to 8). It has perhaps been luck that it has worked at all for most of the externally cached files. It's strange but probably easily fixed.
User avatar
dml
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3991
Joined: Sat Jun 30, 2012 9:33 am

Re: Bad Mood : Falcon030 'Doom'

Post by dml »

Eero Tamminen wrote: ... However, after a while the part around the screen got messed up and eventually demo playback stopped to this:
I missed that detail on first reading - this is more of a worry. It's probably caused by a bug I fixed quite recently but only if I haven't committed those changes.

Corruption round the window has only so far been caused by issues in floor rendering - the corruption looks like a floor or sky texture colour. That was the DSP code hazard bugs i mentioned before and hopefully is dealt with now.

It could also be caused by demo stream incompatibility but far more likely to be this problem above.
User avatar
bullis1
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2301
Joined: Tue Dec 12, 2006 2:32 pm
Location: Canada

Re: Bad Mood : Falcon030 'Doom'

Post by bullis1 »

I'm just chiming in to say (along with everybody else) that the video was jaw-dropping.
Member of the Atari Legend team
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 3999
Joined: Sun Jul 31, 2011 1:11 pm

Re: Bad Mood : Falcon030 'Doom'

Post by Eero Tamminen »

dml wrote:
Eero Tamminen wrote:With the version checks disabled, I get now this from FreeDoom doom2.wad replacement timedemo:

Code: Select all

Error: Bad music number 143
And this if I try to start a new game:

Code: Select all

Error: R_TextureNumForName: MFADEMAP.. not found
This is typical of a WAD/code mismatch. The code is trying to load named resources which aren't there or don't match in some way.

e.g. if you try to load DOOMU.WAD into Doom II you'll get this sort of thing.

Unfortunately, it's not a bug of mine to fix. It's a hunt through source ports to find out what these things are and what they are used for, if needed at all, and then possibly integrating changes (at the very least, changing the code).
Ok, in that case feel free to revert the version check disabling. I will try to look into Boom code at some point and port at least some of the version difference stuff to BM.

I guess I'll next check the non-working PWADs with original Doom.

dml wrote:
Eero Tamminen wrote: ... However, after a while the part around the screen got messed up and eventually demo playback stopped to this:
I missed that detail on first reading - this is more of a worry. It's probably caused by a bug I fixed quite recently but only if I haven't committed those changes.
As I mentioned above, the screen corruption issue had thankfully disappeared (while the warnings & error message remained).

Return to “680x0”