Klax - STE DMA sound patch

All about ST/STE games

Moderators: simonsunnyboy, Mug UK, Doctor Bob Gordon, ICS, Moderator Team

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Klax - STE DMA sound patch

Postby junosix » Wed Nov 22, 2017 2:11 pm

Spent the last few days patching up the classic puzzler Klax with some DMA routines to play the arcade samples on the STE, plays a lot nicer with them! Don't think I've introduced any problems with the modifications but if there's anything egregious then let me know and I'll make the changes.

https://youtu.be/H2RIa_VN39U
You do not have the required permissions to view the files attached to this post.
Last edited by junosix on Fri Dec 08, 2017 7:49 pm, edited 4 times in total.

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Wed Nov 22, 2017 2:14 pm

Ha! And I've just spotted something - no text when a new wave starts. I'll crack on with that this evening.

User avatar
Anima
Atari Super Hero
Atari Super Hero
Posts: 655
Joined: Fri Mar 06, 2009 9:43 am
Contact:

Re: Klax - STE DMA sound patch

Postby Anima » Wed Nov 22, 2017 4:15 pm

Thanks for the (ST)Enhancement. ;)

User avatar
vebxenon
Captain Atari
Captain Atari
Posts: 488
Joined: Fri Apr 24, 2015 12:10 pm

Re: Klax - STE DMA sound patch

Postby vebxenon » Wed Nov 22, 2017 7:42 pm

junosix wrote:Spent the last few days patching up the classic puzzler Klax with some DMA routines to play the arcade samples on the STE, plays a lot nicer with them! Don't think I've introduced any problems with the modifications but if there's anything egregious then let me know and I'll make the changes.

https://youtu.be/H2RIa_VN39U


Klax is one of my favorite games. Thanks very much! :cheers: :cheers:
Just a computer and videogame lover :)

- Atari Jr 2600 clone
- Atari 7800 Peritel
- Atari XEGS
- Atari Lynx II
- Atari Jaguar
- MiST Board

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Wed Nov 22, 2017 9:20 pm

vebxenon wrote:Klax is one of my favorite games. Thanks very much! :cheers: :cheers:

Same! My favourite puzzle game of all. Happy memories of playing it at an arcade in the summer of 1990 then being so excited to see an ST copy for sale a few months later. Shame they never added these sounds back in the day, it wouldn't have taken much more effort, I'm sure I'm playing it better with the proper sounds in.

Don't know why Wave 02 in the YT video I posted had no graphics in it, I've just played it again and they're there. I'll keep an eye on it.

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Tue Nov 28, 2017 1:14 am

Have removed the original disk image and added two files - a .zip with the .TOS executable that ought to be able to be run from a hard disk, and a disk image that uses a bootsector loader meaning it can be loaded into lower memory and run on 520STEs (and of course machines with more memory). Nice thing about this one is it sets the screen to black as soon as it starts booting which I think is a bit nicer.

bjkock
Atarian
Atarian
Posts: 3
Joined: Wed Sep 07, 2016 4:23 pm
Location: Sweden

Re: Klax - STE DMA sound patch

Postby bjkock » Thu Dec 07, 2017 7:23 am

Great Work, Thanks!

I have a problem loading the .TOS file on my STE (4MB) when my HD (SH204) is on.
Both the .ST and the .TOS version loads and runs perfectly from floppy if the HD is turned off, but as soon as I have booted the STE with the HD (with HDdriver 10.10) and try to run the .TOS file from the HD or the disk the file loads and the screen turns black and then the STE hangs.
I have disabled the Auto folder on the HD and no ACC or other programs are running in the background, so the STE is “clean”.
It seems that the Game somehow uses the same DMA routines as the HD and therefore it hangs when it tries to start the sound with the HD on.

Any clue to what the problem could be?
I know it´s not a faulty DMA chip since that is taken care of ;-)

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2909
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Klax - STE DMA sound patch

Postby AtariZoll » Thu Dec 07, 2017 3:43 pm

bjkock wrote:I have disabled the Auto folder on the HD and no ACC or other programs are running in the background, so the STE is “clean”.
It seems that the Game somehow uses the same DMA routines as the HD and therefore it hangs when it tries to start the sound with the HD on.
Any clue to what the problem could be? ...

Actually, it is not that clean. Hddriver takes lot of low RAM, especially when there is more RAM in machine. That affects many games, because they are not really 100% relocatable. Solution is to lower caches of Hddriver, or to use some other, not so RAM hungry one.
Negative feedback has usually positive effect.

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Thu Dec 07, 2017 6:17 pm

AtariZoll wrote:
bjkock wrote:I have disabled the Auto folder on the HD and no ACC or other programs are running in the background, so the STE is “clean”.
It seems that the Game somehow uses the same DMA routines as the HD and therefore it hangs when it tries to start the sound with the HD on.
Any clue to what the problem could be? ...

Actually, it is not that clean. Hddriver takes lot of low RAM, especially when there is more RAM in machine. That affects many games, because they are not really 100% relocatable. Solution is to lower caches of Hddriver, or to use some other, not so RAM hungry one.

The game starts at memory address $400 which is where a lot of system variables live, so any hard disk driver that lives down that end of the RAM will have a problem. I tested it via the hard disk support in Hatari which worked, but I haven't got a hard disk for my ST so can't test it for real. The code is definitely not relocatable (at least my DMA sound routines use absolute addresses for the sample data, and I would assume more likely than not that the game's code does similar stuff). Not sure what alternative hard disk drivers are out there that might not sit in such low RAM.

bjkock
Atarian
Atarian
Posts: 3
Joined: Wed Sep 07, 2016 4:23 pm
Location: Sweden

Re: Klax - STE DMA sound patch

Postby bjkock » Thu Dec 07, 2017 6:50 pm

junosix wrote:
AtariZoll wrote:
bjkock wrote:I have disabled the Auto folder on the HD and no ACC or other programs are running in the background, so the STE is “clean”.
It seems that the Game somehow uses the same DMA routines as the HD and therefore it hangs when it tries to start the sound with the HD on.
Any clue to what the problem could be? ...

Actually, it is not that clean. Hddriver takes lot of low RAM, especially when there is more RAM in machine. That affects many games, because they are not really 100% relocatable. Solution is to lower caches of Hddriver, or to use some other, not so RAM hungry one.

The game starts at memory address $400 which is where a lot of system variables live, so any hard disk driver that lives down that end of the RAM will have a problem. I tested it via the hard disk support in Hatari which worked, but I haven't got a hard disk for my ST so can't test it for real. The code is definitely not relocatable (at least my DMA sound routines use absolute addresses for the sample data, and I would assume more likely than not that the game's code does similar stuff). Not sure what alternative hard disk drivers are out there that might not sit in such low RAM.


Thank you for your replies guys!
Sounds like it´s HDdriver that´s the “bad guy” here.
I´ll will play around with some other Hard disk drivers and see if I can get it to run from HD.
In the mean time I´ll use an old fashion floppy to play this highly addictive game. :D

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2909
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Klax - STE DMA sound patch

Postby AtariZoll » Fri Dec 08, 2017 7:24 am

junosix wrote:...
The game starts at memory address $400 which is where a lot of system variables live, so any hard disk driver that lives down that end of the RAM will have a problem. I tested it via the hard disk support in Hatari which worked, but I haven't got a hard disk for my ST so can't test it for real. The code is definitely not relocatable (at least my DMA sound routines use absolute addresses for the sample data, and I would assume more likely than not that the game's code does similar stuff). Not sure what alternative hard disk drivers are out there that might not sit in such low RAM.

OK, things are clear now. Since I did lot of game fixes, reassembles, here are some things you need to know, care about:
Hard disk driver and his workspace, buffers, cache is normally placed in first free RAM area - in case of autoboot is is right after TOS workspace - actually it should go there, but it goes some 15 KB higher (depending from TOS version) , and those 15 KBs are lost, except some smart SW using them. Practically same is with AUTO start. So, in TOS 1.04 driver will load at address ~$A84E . If you load from Desktop, clean boot it will load even higher, after AES, Desktop workspace.
Hddriver will add lot of buffers on 4MB machine, over 100-150KB, and that's why it fails. With usage of some 50KB it would work most likely,

Now, considering concrete problem - not relocatable DMA sound sample addresses - that should be done relocatable. Yes, lot of games suffers from that problem - not being fully relocatable. I rearranged some - like Hard 'n' Heavy. Even if it is fully relocatable, like Uridium, some rearrangement is useful - they put large blocks of zeros in middle of code, for instance, instead using bss section after code, data for that.
Disassembling game can help - but that may be lot of work and time. In any case, you need to know memory usage, layout of it, to avoid conflicts, + then will know how mach RAM it needs. Ideal case is that game uses 1 contigous block of RAM only + screen buffer - and that is case of fully relocatable. Here to add that screen address must be not fixed too (error of Flight Simulator 2) - you use original address, what is top of RAM, or self set it there. So, on machines with more RAM, code can run at higher address, and still not reaching screen buffer space.
Negative feedback has usually positive effect.

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Fri Dec 08, 2017 10:48 am

Think I may have cracked it, in the .TOS version I have a small bit of code that loads all the code+data in one go, disables interrupts, copies the game from wherever it is currently into memory starting at $400 (as that's where the original game expects it to be) then jumps to $400. I think it's more that my relocating code was being overwritten as I hadn't set it high enough in memory rather than any conflict as such with the hard disk driver. So assuming that the hard disk version will be run on a 1040 at least, I've just changed the address of the relocating code to run higher in memory. I've attached it to my first post (klax_dma_1040_executable_version.zip), see if that does the trick. I could be more fancy and check the amount of RAM in the system then put my relocating code at the top of RAM relevant to that but I won't have a chance until after the weekend, be interested to see if this version does the job first though.

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2909
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Klax - STE DMA sound patch

Postby AtariZoll » Fri Dec 08, 2017 11:48 am

junosix wrote:Think I may have cracked it, in the .TOS version I have a small bit of code that loads all the code+data in one go, disables interrupts, copies the game from wherever it is currently into memory starting at $400 (as that's where the original game expects it to be) then jumps to $400. I think it's more that my relocating code was being overwritten as I hadn't set it high enough in memory rather than any conflict as such with the hard disk driver. So assuming that the hard disk version will be run on a 1040 at least, I've just changed the address of the relocating code to run higher in memory. I've attached it to my first post (klax_dma_1040_executable_version.zip), see if that does the trick. I could be more fancy and check the amount of RAM in the system then put my relocating code at the top of RAM relevant to that but I won't have a chance until after the weekend, be interested to see if this version does the job first though.

Hmm. - it game runs at fixed address, + it is very low in RAM then it is single load - after that no more disk access possible via TOS filesystem.
With fixed final address you actually don't need relocation of code what works during gameplay - it will be always on same address. I think that it's best to do needed relocations for that final address once (not by end user, but by coder), and save final code+data with all addresses as final ones. So will start faster, you can even pack it - and after depacking need only to jump to start.
Will check that new v. later ...
Negative feedback has usually positive effect.

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2909
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Klax - STE DMA sound patch

Postby AtariZoll » Fri Dec 08, 2017 7:34 pm

Checked that new exec (at top of DL in first post) - and it seems that is OK. Installed some 300KB RAMDISK before starting it, what should be even more than what Hddriver takes on 4MB machine - worked fine :D
Negative feedback has usually positive effect.

User avatar
Sturm
Atari maniac
Atari maniac
Posts: 93
Joined: Wed Aug 24, 2016 1:51 pm
Location: France

Re: Klax - STE DMA sound patch

Postby Sturm » Fri Dec 08, 2017 7:41 pm

Does it work on Falcon too ?

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Fri Dec 08, 2017 7:52 pm

AtariZoll wrote:Checked that new exec (at top of DL in first post) - and it seems that is OK. Installed some 300KB RAMDISK before starting it, what should be even more than what Hddriver takes on 4MB machine - worked fine :D

Hoorah! Thanks for testing it :D I take on-board the stuff you say about relocation and things but luckily it doesn't look like I need to worry about that for this one.

It ought to work on the Falcon in terms of not crashing or anything horrible like that, but the samples depend on the 6258Hz replay frequency in the STE, which as far as I'm aware is not supported on the Falcon (only the higher frequencies are). Should be okay on the Mega STE and TT though.

bjkock
Atarian
Atarian
Posts: 3
Joined: Wed Sep 07, 2016 4:23 pm
Location: Sweden

Re: Klax - STE DMA sound patch

Postby bjkock » Sun Dec 10, 2017 5:17 pm

junosix wrote:....... I've attached it to my first post (klax_dma_1040_executable_version.zip), see if that does the trick. .....


Yes indeed, that did the trick!
Now it works perfectly from HD on my STE :D

Did not get it to work on my Falcon 030 though, but since it is a 1040 STE game that´s not to much to worry about :D

Great work!

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2909
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Klax - STE DMA sound patch

Postby AtariZoll » Sun Dec 10, 2017 5:33 pm

It will not work on Falcon - as said sample freq is not supported on it.
Maybe to do version with 12.5 KHz samples ? I can do other things necessary for Falcon run.
Negative feedback has usually positive effect.

junosix
Captain Atari
Captain Atari
Posts: 222
Joined: Sun Jul 08, 2007 3:22 pm
Location: Plymouth

Re: Klax - STE DMA sound patch

Postby junosix » Tue Dec 12, 2017 1:12 am

I'll have a go at sticking in 12.5kHz samples in sometime. Am I right in thinking the Falcon doesn't need to have the values written to the YM volume registers lowered because the balance between YM+DMA in the Falcon is correctly done?

Glad you're enjoying it bjkock!

AtariZoll
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2909
Joined: Mon Feb 20, 2012 4:42 pm
Contact:

Re: Klax - STE DMA sound patch

Postby AtariZoll » Tue Dec 12, 2017 7:33 am

junosix wrote:I'll have a go at sticking in 12.5kHz samples in sometime. Am I right in thinking the Falcon doesn't need to have the values written to the YM volume registers lowered because the balance between YM+DMA in the Falcon is correctly done?

Yes, Falcon has well balanced YM-DMA levels. I noticed that it is balanced on STE in your patch. So, you did same as me with Xenon2.
I think that best is to do v. with 12.5KHz samples, original YM volumes. It will be OK for Falcon, and for STE machines with mixer fix + for modded Steem 3.2 - where can set YM and DMA audio levels separately. RAM should be no problem - all STEs have min 1MB.
Negative feedback has usually positive effect.


Social Media

     

Return to “Games - General”

Who is online

Users browsing this forum: No registered users and 2 guests