Page 1 of 1

Re: F'n Balls

Posted: Fri Jul 12, 2019 12:01 pm
by andydansby
I’m going to have to work with Antonio about that, I believe it’s in the Sprite engine. The rest of the code is standard C in Z88dk. Sprites are in assembly. Any clues where to look that might cause the snow effect?

Andy

Re: F'n Balls

Posted: Fri Jul 12, 2019 1:24 pm
by Ast A. Moore
andydansby wrote: Fri Jul 12, 2019 12:01 pm I’m going to have to work with Antonio about that, I believe it’s in the Sprite engine. The rest of the code is standard C in Z88dk. Sprites are in assembly. Any clues where to look that might cause the snow effect?

Andy
Sure, look for an OUT instruction that triggers the paging and make sure it doesn’t hit any of the contended banks. The instruction is usually OUT (C),A, preceded by an LD A,bank_number/LD BC,$7FFD combo.

When I provide game fixes, I normally use a small architecture detection code and feed the appropriate bank number values, if necessary. In simple cases (when memory constraints are not an issue and speed isn’t an issue), you can simply choose a bank that is non-contended on the 128K/+2 machines (i.e. Bank 4 or 6).

Edit: Ah, now I see that during runtime, the instructions at $f1da set the bank to 1

LD A,$11
OUT (C),A

The bank switching code itself sits in Bank 0, however. So you might need to change the loader, too, so that the appropriate code is loaded in, say, Bank 4, and then change LD A,$11 to LD A,$14.

Re: F'n Balls

Posted: Fri Jul 12, 2019 2:01 pm
by Ast A. Moore
M’kay, this is a little puzzling. The loader is trivial enough to fix. Replace LD A,$11 at address $5b17 with LD A,$14. Now, the runtime code at $f1da is tricky—I can’t find it on the tape image. I guess it’s generated at runtime.

P.S. It is. There’s a lot of block moving and memory rearrangement (decryption?) going on.

Re: F'n Balls

Posted: Fri Jul 12, 2019 2:32 pm
by andydansby
Later on after work I can share my source code and Antonio’s code. It’s all open source.

It’ll be much easier to read.

Andy

Re: F'n Balls

Posted: Fri Jul 12, 2019 2:54 pm
by Ast A. Moore
Cool, except I’m not very good at C. Fortunately, bank switching isn’t rocket science, I think I’ll manage. ;)

Re: F'n Balls

Posted: Fri Jul 12, 2019 3:08 pm
by andydansby
FASE is pure assembly. My code interfaces with Antonio assembly via a function call. I’ll fill in the details a little later on.

Andy

Re: F'n Balls

Posted: Sun Jul 14, 2019 1:16 pm
by andydansby
With the tireless efforts of Ast. A Moore and Antonio Villena. I have compiled a new version of F'n Balls. Available at http://andyspeccysite.simplesite.com/. This update fixes several bugs 1)ULA rain on 128k Toast Rack and +2 Amstrad Models. 2) Key collecting bug discovered by Ast. A Moore.

Have fun.

Andy Dansby

Re: F'n Balls

Posted: Sun Jul 14, 2019 2:03 pm
by antoniovillena
About the bug, it's solved. That was ULA snow because I register was $FE and in 128K $C000 is switching between 2 pages (one of them is 7 for shadow and is contended). Solved with the help of Ast A Moore who suggest to change the I register to $3B.

About the bugs when launching on 48 BASIC on 128K machines, really there are no bugs. Just use Loader or 128K mode. I'll explain here. The engine has 3 types of machines. The loader detects the mode copy the routines and run.

Machine 0: 48K. Engine exploits floating bus (only 48K timings) for anti flickering. Good case
Machine 1: 128K. Engine exploits shadow video for anti flickering. Best case
Machine 2: Other. We don't have floating bus or shadow video (detected if paging is activated). Worst case

On machine 0 we have 26k cycles to repaint sprites, so we can manage 8 sprites without flickering. When detected the bottom bar disappears, because we paint a pattern to detect when electron beam paints this part of screen. This pattern is hidden with $00 attribute.
On machine 1 we have a whole frame (69k cycles), so we have more than 12 sprites without flickering.
On machine 2 we have only 14k cycles to repaint, that's 4-5 sprites without flickering.

The detection algorithm:

Code: Select all

IF paging available
  machine 1
ELSE
  IF bus floating
    machine 0
  ELSE
    machine 2
  END
END
The problem when you choose 48 BASIC on 128k machine (disable paging) is you have incorrect detection:
-On 128K detects machine 0, so the floating bus algorithm freezes because timings
-On +2A detects machine 2, so no freezes but less sprites without flickering

Machine 2 was thought to other non sinclair clones like Pentagon.