Flying Shark mod fix needed

General software. From trouble with the Banyan Tree to OCP Art Studio, post any general software chat here. Could include game challenges...
Post Reply
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Flying Shark mod fix needed

Post by Alessandro »

Another modification by @goodboy, Slider and Tiboh, this time of Flying Shark.

The mod adds sound effects and music from the Amstrad CPC version. Once again, when run on the 128/+2, it will show some nasty "snow effect" screen corruption, but only when game starts, not in the title screen, high score table etc.

This looks strange because it seems that the IM2 table begins at 65024, thus not in contended memory.

By the way, I also created a TAP file which will load on all Spectrums and change the music sound effects to 48K beeper or AY accordingly.

Would someone please investigate into this?

http://disegnareconlaluce.altervista.or ... gShark.zip
Old-User
Dizzy
Posts: 57
Joined: Fri Jan 20, 2023 7:48 pm

Re: Flying Shark mod fix needed

Post by Old-User »

@Alessandro :

Sorry for the side topic but I couldn't help noticing the original file is .trd and yet you were able to make a .tap file?
Do you know how to do that conversion or did it work just this time?
User avatar
bob_fossil
Manic Miner
Posts: 661
Joined: Mon Nov 13, 2017 6:09 pm

Re: Flying Shark mod fix needed

Post by bob_fossil »

Some initial findings:

The game uses IM2 and the IM2 table jumps to address $fdfd. In game this jumps to $a0c4 but in the title and high score it jumps to $a0b0 which is why you don't get the screen corruption there is it's executing different code on interrupt.

The interrupt function at $a0c4 is almost identical to the original game, except for the call instruction at $a112. In the AY patched version this calls address $a9a9. The original game calls $c772 here instead.

The function at $a9a9 pages in bank 1, calls $c000, pages in bank 0, does the original call to $c772, pages bank 1 back in, calls $c000 again before paging bank 0 back in and returning.

If you patch the call at $a112 to call $c772 (POKE 41235, 114 POKE 41236, 199) the corruption goes away - along with the AY effects. I suspect the code at $c000 in bank 1 is doing something it shouldn't.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Flying Shark mod fix needed

Post by Alessandro »

Old-User wrote: Wed Jul 19, 2023 9:08 pm @Alessandro :

Sorry for the side topic but I couldn't help noticing the original file is .trd and yet you were able to make a .tap file?
Do you know how to do that conversion or did it work just this time?
Put simply: You cannot convert a TRD file to a TAP per se. Even if the files on the disk image were stored the standard way, which for unfathomable reasons is never the case with Russian releases, you would still require to modify the loading routines so that they would employ the Spectrum's own ROM loading scheme instead of TR-DOS.

What I did was save a SZX snapshot file at a convenient point, when the program counter was at 24576 in this case, put a breakpoint there, and extract the RAM's content from 24510 to 65536. These addressess were inferred by looking at the code through Spectaculator's debugger. I was already aware that the game at that stage did not use any other memory bank other than 0, 2 and 5 because an earlier attempt with a Z80 snapshot and Z802TAP showed there was no data in stored in the memory banks.

bob_fossil wrote: Wed Jul 19, 2023 10:51 pm Some initial findings:

The game uses IM2 and the IM2 table jumps to address $fdfd. In game this jumps to $a0c4 but in the title and high score it jumps to $a0b0 which is why you don't get the screen corruption there is it's executing different code on interrupt.

The interrupt function at $a0c4 is almost identical to the original game, except for the call instruction at $a112. In the AY patched version this calls address $a9a9. The original game calls $c772 here instead.

The function at $a9a9 pages in bank 1, calls $c000, pages in bank 0, does the original call to $c772, pages bank 1 back in, calls $c000 again before paging bank 0 back in and returning.

If you patch the call at $a112 to call $c772 (POKE 41235, 114 POKE 41236, 199) the corruption goes away - along with the AY effects. I suspect the code at $c000 in bank 1 is doing something it shouldn't.
Maybe the answer lies here: there are four LDIR cycles starting at address 24629 which transfer some data from the main memory to bank 1, then revert to bank 0. This part of the program is only reached if the immediately previous JR NZ, 61662 instruction is not executed, i.e. if the content of 23867 is not zero. I found that in this case the game recognizes the hardware as "not 48K", so in the loader program I patched the code accordingly:

Code: Select all

  ORG 24300

  XOR A
  LD (23693),A       ; PAPER 0, INK 0, BRIGHT 0
  LD (23624),A       ; le ultime due righe hanno INK e PAPER 0
  CALL 3503          ; CLS

  LD IX,16384
  LD DE,06912        ; schermata di caricamento

  CALL CARICA

  LD IX,24510
  LD DE,41026

  CALL CARICA

  XOR A
  LD (23872),A
  LD (23873),A
  LD (23874),A

  LD A,(2899)
  CP 165             ; è un 48K ?
  JR Z, K48

  LD A,1
  LD (23867),A

INIZIO:

  JP 24576

CARICA:

  LD A,255
  SCF
  CALL 1366
  RET

K48:

  XOR A
  LD (23867),A
  JR INIZIO
User avatar
bob_fossil
Manic Miner
Posts: 661
Joined: Mon Nov 13, 2017 6:09 pm

Re: Flying Shark mod fix needed

Post by bob_fossil »

The following patched .sna file seems to fix the screen glitching on my +2.

http://www.thefossilrecord.co.uk/wp-con ... zx/fs5.zip

Long story short, I moved the music to another memory bank and then patched the code at $a9a9 (and a couple of other places) to page bank 20 in, instead of bank 17. It does crash when you lose your last life. I think I've missed out a page bank somewhere and it's jumping to code in the wrong bank.
User avatar
Andre Leao
Bugaboo
Posts: 3156
Joined: Mon Nov 13, 2017 9:28 am
Location: Portugal
Contact:

Re: Flying Shark mod fix needed

Post by Andre Leao »

Starting on September 10th, I will make available more than 20 TRD games and demos, some of them controversial / forbidden, converted to tzx. You know where you've heard in first place... ;)
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Flying Shark mod fix needed

Post by Alessandro »

@bob_fossil: I loaded the TAP under 128 emulation and placed a breakpoint at 24576, then tried substituting all the LD A, 17 instructions just before the bank switching ones with LD A, 20, but at the title screen, the program jumps somewhere around 62247 and finds nothing there, so the computer resets to 48 BASIC.
User avatar
bob_fossil
Manic Miner
Posts: 661
Joined: Mon Nov 13, 2017 6:09 pm

Re: Flying Shark mod fix needed

Post by bob_fossil »

Did the previous .sna file fix the screen corruption for you?

I've put an updated file at:

http://www.thefossilrecord.co.uk/wp-con ... zx/fs8.zip

The Game Over crash was due to an off by one error in one of my patches.

Assuming you've got the contents of bank 1 into bank 4, the following pokes should patch the game over to paging in bank 4 instead of bank 1.

Code: Select all

43356,20
43383,20
43416,20
41424,20
43308,20
43653,20
43673,121
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Flying Shark mod fix needed

Post by Alessandro »

@bob_fossil: Yes, I loaded the snapshot on an emulated 128 with DivIDE on SpecEmu, and it happened as you wrote. The same snapshot ran without problems on a +2A.

However, those addressess are not useful (i.e. there is no actual code there) when the TAP file ends loading and code is started at 24576. I noticed several LDIR instructions which transfer portions of code around the RAM; therefore, if I wish the TAP file to be able to run on all Spectrums including 48Ks, I need to correct it before such instructions are performed. I shall investigate further, then.
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Flying Shark mod fix needed

Post by Alessandro »

At last, I found the missing piece. Bob's suggestion of a POKE at address 43673 led me towards the correct path. The TAP file should now work on all Spectrums and play AY music and sound effects on the 128 and later models without "snow" on the 128/+2. Download link is unchanged (see first post).
Old-User
Dizzy
Posts: 57
Joined: Fri Jan 20, 2023 7:48 pm

Re: Flying Shark mod fix needed

Post by Old-User »

Alessandro wrote: Fri Jul 21, 2023 2:26 pm At last, I found the missing piece. Bob's suggestion of a POKE at address 43673 led me towards the correct path. The TAP file should now work on all Spectrums and play AY music and sound effects on the 128 and later models without "snow" on the 128/+2. Download link is unchanged (see first post).
Great work!
Thanks to Alessandro and Bob for this one. ;)
Old-User
Dizzy
Posts: 57
Joined: Fri Jan 20, 2023 7:48 pm

Re: Flying Shark mod fix needed

Post by Old-User »

Andre Leao wrote: Thu Jul 20, 2023 7:58 pm Starting on September 10th, I will make available more than 20 TRD games and demos, some of them controversial / forbidden, converted to tzx. You know where you've heard in first place... ;)
Could you just tell a little bit more about the games...?
It sounds interesting!
User avatar
Andre Leao
Bugaboo
Posts: 3156
Joined: Mon Nov 13, 2017 9:28 am
Location: Portugal
Contact:

Re: Flying Shark mod fix needed

Post by Andre Leao »

Old-User wrote: Fri Jul 21, 2023 5:32 pm Could you just tell a little bit more about the games...?
It sounds interesting!
Some MIAs, loads of demos, Doom, Black Raven, Mortal Kombat (several versions), and some more only available as TRD till now... ;)
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Flying Shark mod fix needed

Post by Alessandro »

Ahem :roll: Let's get back to the topic...

The TAP file will be added to the DivIDE/DivMMC collection in the next update. The already present TAP file of the original Firebird release will be kept for those who wish to play the game the traditional way on the 128 and later models.

Of course, there will be no change for 48K users, both files will load the game on their computers.
Chris23235
Microbot
Posts: 145
Joined: Wed Dec 29, 2021 11:59 am

Re: Flying Shark mod fix needed

Post by Chris23235 »

I gave it a try on the LMN128 and the Omni and it worked flawless without any snow. many thanks @Alessandro !

I played the game a lot over the years and without saying it definitely I had the impression that this version runs a tiny bit smoother than the original. Offloading the sound from to the soundchip seems to make a difference for this game. But maybe it is just my imagination.
User avatar
bob_fossil
Manic Miner
Posts: 661
Joined: Mon Nov 13, 2017 6:09 pm

Re: Flying Shark mod fix needed

Post by bob_fossil »

Here's my patch with the +2 trainer options from the original mod preserved:

http://www.thefossilrecord.co.uk/wp-con ... x/fsay.zip
User avatar
Alessandro
Dynamite Dan
Posts: 1910
Joined: Wed Nov 15, 2017 11:10 am
Location: Messina, Italy
Contact:

Re: Flying Shark mod fix needed

Post by Alessandro »

Chris23235 wrote: Sat Jul 22, 2023 11:29 am I gave it a try on the LMN128 and the Omni and it worked flawless without any snow. many thanks @Alessandro !

I played the game a lot over the years and without saying it definitely I had the impression that this version runs a tiny bit smoother than the original. Offloading the sound from to the soundchip seems to make a difference for this game. But maybe it is just my imagination.
I don't think it's your imagination :) I noticed the same on real hardware several times. After all, the sound chip removes some work from the CPU, and a slight increase in performance is to be expected.
Spezzi63
Drutt
Posts: 44
Joined: Sat Dec 28, 2019 1:36 pm

Re: Flying Shark mod fix needed

Post by Spezzi63 »

I like the trainer version very much.
If there were a defined "Load" in the loader, a +3e disk could also be created ;)
User avatar
bob_fossil
Manic Miner
Posts: 661
Joined: Mon Nov 13, 2017 6:09 pm

Re: Flying Shark mod fix needed

Post by bob_fossil »

I've updated the zip file linked in my previous post so it now contains a .dsk file. Seems to run from Loader under +3 emulation in Fuse. Not sure if this is what you need but at least I now know how to do disk releases for the +3. :)
Spezzi63
Drutt
Posts: 44
Joined: Sat Dec 28, 2019 1:36 pm

Re: Flying Shark mod fix needed

Post by Spezzi63 »

Tested successfully with my "+3e-DIP-Floppy-Interface" on the ZX Spectrum +2A
That's how it should be ;)
Post Reply