Make Your Programs System Friendly! (Coding Guide)

Subliminal Extacy #04

Make your programs system friendly!

(tdm^k3l/h-prg)

After several years of playing the games, watching the demos, learning the Basic, the first sex experiences and bought the PC it is time to say "I want to make my programs system friendly".

You know it... On Monday you got superb idea how to make magic effect on Z80, on Tuesday you got another great idea. On Wednesday you got another (hey man! you are genius! :-) ) idea and the demo was born. You spent a lot of time and you had not enough power to do the final loader. Or you have only one ZX Spectrum (then, you are not normal 'cos every 8-Bit, 16-Bit and 32-Bit computer fan :) has 10 computers at least!) and you had no chance to test it. So, this article is for you, dear coder.

Maybe you know it.. maybe you feel it.. maybe you have got it .. errrrm STOP the joking - this is not Genetic Error from K3L! OK, maybe you know, there are a lot of ZX Spectrum clones all over the world, but there is a few real "standards". I will not describe the precise timing of multicolor effects etc. In this case, it is very important to test the type of computer. In this article I want to describe how to make the demo or cracked game working on all that standard Sinclair ZX Spectrum machines.

It is easy, when your production is for ZX Spectrum 48KB (BTW do you know this "poem"? [first used in Zabhmo 128] "Fuck is easy, fuck is funny, many people fuck for money. If you think that fuck is honye, fuck yourself and save your money!") Oh, I'm a bastard, I know... <take note I'm Hooy-Program member :-) >. Now it's time to say the truth (which is not out there, but inside your ZXS).

The memory problems:
  • ZX Interface I + ZX Microdrive make its own system variables and there is really big problem to LOAD "" programs under address 24500!

  • some others early disk systems expands original Sinclair variables like ZX Interface I

  • ZX Spectrum +2A(B) / +3 uses the last (23) page (its top approx. 4KB) for disk system and page 17 is the first when you are using RAM Disk.

The resume is:
  • your program must be loaded from address 25000 and up. There is no other limitations AFTER loading for classic 128KB machines (black Sinclair ZXS and grey Amstrad 128K)

  • when you want to make your program usable on +3 system like ZXS +2A(B)/+3, there is few rules you must follow.

  • never use OUT 32765,XX commands in Basic. As you know, this is obvious problem in 128Basic. Because system is clever than you and you SHOULD not know that system is using RAM switching. You have only bigger space for your Basic and you can PLAY command (see original 128 HandBook from Sinclair Research)

  • use "pack" programs like TomPack and other you like (maybe Trasher from Zilog) to reduce file size. Then, you can join several 16KB banks together in one file and after loading such file it is easy to depack and "ldir" it to the correct places. And what's more - it is fast. For example I can join the main programme located in base page (16) which is short with 19 and page 20 in one file. Then program like this will be used:

        org 25000
        ent $

;unpack 19th page
        ld a,19
        call bank
        ld hl,end+14000
        ld bc,10000
        call ldir

;unpack 20th page
        ld a,20
        call bank
        ld hl,end+14000+10000
        ld bc,11000
        call LDIR

;move main program to the correct place, depack
;and run it
        ld a,16
        ld hl,end+14000+10000
        ld de,end
        ld bc,12000
        ldir

;start the prg.
        jp end

LDIR    ld de,49152
        ldir
        call 49152
        ret

BANK    ld bc,32765
        out (32765),bc
        ret

END     nop

I hope there is no bug in this theoretical piece. But it should only describe the technique! And now is coming the most important thing for +3 machines. It is important to load and depack pages 17 and 23 at last together!!!!! Page 17 is not required when you disable RAM disk by calling +3 system functions (see +3 DOS reference handbook).

In most cases, especially when the program is your own :-) it is possible to apply these restrictions.

Share your thoughts about the article