Bad programming practices, not good ways of program start

Started by Petari, 19-09-2022, 11:27:58

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Petari

This is something about I wanted to write long time ago. And since I regularly see diverse games for Atari ST  solutions, I saw, and see lot of not good solutions. Latest one is 'Crazy Harold to the Rescue' - found at atarimania . More lower.

Starting some SW, like game: that should be simple case, but not always. Even if it is just running it's starter file (exec), some do it not really good. And that happens with SW using TOS calls, regular files on floppies. SW what does not use TOS calls starts in most cases from floppy bootsector, and that's straight case.
When there is some regular starter file, like GAME.PRG it is started normally by doubleclick. Little help can be when there is DESKTOP.INF, saved with opened drive A: , and that PRG is in 'focus' .
What about starting it from AUTO folder ? Then user does not need to start it self. Well - here is first confusion - AUTO start (run) is only for SW what does not perform AES calls (GEM functions) . Because it starts before GEM init.  Too bad that Atari set it so, that extension must be PRG . While in normal start from DESKTOP ext. PRG is for SW using AES calls, and ext. TOS for SW not using AES calls ! Silly.
And there is plenty of SW starting from AUTO folder. Mostly games. Because most of them does not need GEM, windows, menus ...  I would say that some 40-50% of Atari games is such.
But there is number of games which do not use AES calls, and starts from DESKTOP - extension may be PRG or TOS. And that's not irrelevant. SW with TOS extension will start at lower address, so will be more RAM for it. But less than case of AUTO folder run. If extension is PRG will start at higher address - because some AES workspace is set first, and then comes space for program.  And that's just bad practice. In some cases that 20 KB diff may be working or not working.
So, rule #1:  if program does not use AES calls use AUTO run. If there is more of it on floppy, use TOS extension and Desktop start. Although, it is easy to make selection proggie for AUTO folder ...

SW what uses some AES calls - that would be Trap #2 with value 200 ($C8) in d0 before call. VDI call is Trap #2 with value $73 in d0 . And VDI works under GEMDOS (what's what is initialized before AUTO folder start).
I saw plenty of games where are few AES calls - so can not work from AUTO folder, but those calls could be solved via VDI too. And myself changed it in some games. But that's not so simple in most cases.
That would be bad practice #1 in coding. The result is less RAM for running SW, not so easy start.

Bad coding practice #2: putting plenty of workspace in middle of code. Saw games where is like 200 KB filled with zeros in middle of code - Armada . Main exec of game is about 400 KB, and it can be packed to some 110 KB, mostly because those zeros. Well, did they hear about section bss in TOS executables ? It is for workspace. TOS will clear it before start. And game will start faster, especially from floppy, and will take less space on disk too.

There is more what can be done better, more efficient in code. Maybe later will add something ...

Now the case of Crazy Harold ...  :
It is actually 4 SEUCK games on 1 720 KB floppy. Games self need to be started by *.SCK file selection.
What will start RUNGAME.PRG, which will start selected game's code - by name of SCK - like EDITFILE/LADYBIRD.ALL - when LADYBIRD.SCK is started.  Wait, how to start SCK file ?
It is solved via Install Application setting - for RUNGAME.PRG . And here's the problem . It is set as TTP type - what means TOS takes parameters - so LADYBIRD in this case, as name of SCK . And it starts fine, but there is small flashing square at top left of screen all time.  As result of starting it as TOS in fact. If it is started as PRG will be no square (and no parameter pass). Well, there is simple call to remove it when using TOS extension:
   dc.w $A00A                  *Line-A - cursor off
Should add it to SEUCK. Or better: using AUTO folder run. Well, I guess that it was used mostly/in most  cases of solo game on disk.
I added code for game selection, combined with depacking of RUNGAME.PRG, what just puts name of SCK file in basepage part for command line - and that solves start of desired game. And some space save on floppy.
It starts from AUTO folder, and no flashing square on screen when playing.
Will put hard disk adapt and floppy image of so modded 4 game compil. on my site today afternoon.

  •