CHAPTER 7
MASTERING YOUR PRODUCTIONS TO MEDIA

DISK MASTERING
Mastering games to disk - Making them presentable / The Picture Linker Method / Basic disk loader / Kernal M/C disk loader / IRQ Disk loader /
TAPE MASTERING
Mastering programs to tape /
AudioTape and WAVPRG / LoadOne / R-Load / S-Load / TapeToolBuild
 (Including Richard's Upgrade)

 CARTRIDGES
Building your own 16KB Cartridge

Please note that this is not an actual game programming chapter, but more on the theory/practical way on mastering your own creations to real C64 media, with some example snippets containing some of my additional implementation to existing subroutines.

Do you write, or have you ever written your own C64 games, or do you want to be an active developer, designing and creating your own productions for either fun, or submit them to software like Protovision, K&A Plus, Psytronik Software, etc?. Do you have a game you or a friend has made, and would like to create a disk or tape master for your own productions? If the answer is yes. Then may I suggest this chapter should be a helpful guide to help you develop disk/tape masters for your own productions? If you want to make cartridge ROM files out of your productions, then may I suggest you take a look at this handy chapter at CODEBASE64? I am sure that will help you out a bit.

MASTERING GAMES TO DISK - MAKING THEM PRESENTABLE

If you are to create a C64 game, and you would like to make the game presentable with a loader picture on a disk. You could present your production in different ways. These ideas are as follows:

SINGLE LOAD - PICTURE LINKER (SUITABLE FOR SMALL FILES)



A new game production can be presented without a loading bitmap, but of course if you want to really push the boat out. It would be even cooler to display a loading picture. There are different methods on linking pictures to your own programs. The easiest would be to use a C64 picture linker program from the public domain. There are plenty of those. Some of those have cool effects, can play music, and do other cool things. However, the best way would be to create your very own picture linker - and make it do things you want to. For example, you could add your own transition effects to the bitmap (This can be based on sprites or triggering the screen + colour RAM to do a cool effect. 

The example code (via the link below) shows an example of a standard picture linker, I created, which displays a koala paint picture.

VIEW PICTURE + MUSIC LINKER SOURCE

At $0801, we place a BASIC SYS start address (SYS2064), then at $0810 the main program's code is implemented. I created some self-mod pointers, in order to generate a smooth drawing transition effect on the raster splits inside the IRQ raster interrupt. Music is placed at $1000. The Koala paint picture is placed at $2000, where video RAM is copied from a relocated address and pasted to the default colour and screen RAM. Then at the end of the source file, at $4800 a program file is linked. The code is self-explained on how it works.

Back to top


DISK MASTERING VIA LOADING

There are different types of method in which you can master your very own C64 game to disk. Say you have written a game which is huge in size. A picture linker probably won't work for you. Instead you would need to implement your own disk loader. It is purely simple to implement a kernal disk loader, with a loading picture. There are some great DOS examples available for you to check out here in this chapter on CODEBASE64. Adding a loading picture and linking a KERNAL loader is really easy to do using any kind of C64 or crossplatform assembler. 

THE BASIC LOADER METHOD

BASIC commands can be used to generate a loader to load in data from disk to your C64, then run it. BASIC can be used to create a very simple loader system, although some machine code may be required as well to display a loading picture.

A basic command tends to be used to load some data, split picture data, run the machine code to display a loading picture, blank the screen again and then run the last part of the code where the game was executed. A simple BASIC loader for you. Example is: Loading a Koalapaint picture, running a picture displayer, then load BLAP 'N BASH! with a BASIC run. 

10 REM BLAP 'N BASH BASIC DISK LOADER
20 DV=PEEK(186):REM READ ANY DISK DEVICE NO
30 I=I+1
40 IF I=1 THEN GOTO 1000
50 IF I=2 THEN GOTO 1100
60 IF I=3 THEN GOTO 1200
1000 POKE53280,:POKE53281,0:PRINTCHR$(147):LOAD "A",DV,1:REM BLACK SCREEN, LOAD KOALAPIC
1100 LOAD"B",DV,1:LOAD CUSTOM KOALAPAINT PIC DATA MOVER/DISPLAY CODE
1200 SYS20480:LOAD"C",DV,1:REM RELOC/DISPLAY PIC DATA, LOAD GAME

Please also note that although this loading trick does work, after finished loading/decrunching. The bitmap will be messy during decompaction. A good solution would be to trigger a START + FINISH command in exomizer's decruncher to switch off the screen, before running the main decruncher (before compression of your game in Exomizer). For example:

Call exomizer to compress blapnbash.prg, set jump address to game start at $4000, set output name as blapnbash.prg (overwriting the previous filename). No decrunch effect set. Start decruncher by blanking the screen (#$0b set to $d011), then after decrunching finish the decruncher by restoring the screen (#$1b sta $d011) then run the game.

exomizer sfx $4000 blapnbash.prg -o blapnbash.prg -n -s "lda #$0b sta $d011" -f "lda #$1b sta $d011"

THE M/C KERNAL LOADER METHOD (SDIEC Compatibility/Cartridge Fastload, etc).



If you are writing a C64 game, and you wanted to have a loading picture display while loading without using any BASIC commands. A simple picture displayer, with a kernal load call disk loader will work - especially for SDIEC devices, etc. However one thing you should be careful about, when calling your own loader program is that the program should not OVERWRITE your loader code. Transferring loader code has always been the simplest solution to this sort of problem. Another advantage with the kernal loader is that it can be used on fastload cartridges, such as Action Replay, Retro Replay, 1541Ultimate 2, etc, if not blocked with the call JSR $ff84 - which will just override external fastloaders with the slow Kernal loader. Some software actually did that.

Here are some easy examples of disk access available in Codebase. Also if you own a real disk drive, then please also refer to your disk drive manual there are some DOS examples provided in the book. It should have some assembly m/c commands in the book. However, below is a small example of a simple disk picture loader with ultra thin loading stripes.

Anyway, I have made a custom loader example in C64Studio, in which allows you to import a koalapaint picture, relocate the picture and load in Zap Fight 2. The routine automatically disables fastload, to give chance for the person loading the game to see the picture. Fastload always switches the screen off during loading (Unless you are using TLR's SuperFluid freezer cartridge ROM). If you download the project. Load in the D64 image example.d64, then type LOAD"*",8 and RUN. The loading picture will appear on screen, and load with a flashing border.

Download the Pic + Kernal disk loader C64studio project

or

Just view the source code

IRQ / Custom Loaders



Adding IRQ/Custom loaders are another good alternative way to load programs through Disk. You can have great speed with some of these loader systems. Unfortunately this is not always a great idea, if the games are to be SDIEC compatible - Unless a basic kernal loading routine is added as an option for SDIEC devices. If options for SDIEC loading is set up, the disk loading phase can bypass the IRQ loader and use the standard KERNAL loader.  IRQ loaders are very good for presentation, trackmos, etc. For example, Let's Invade uses my implementation of Martin Piper's IRQ disk loader system. An option is displayed on screen asking if the user would like to enable the IRQ disk loader. If 'Y' is pressed, then the IRQ loader is enabled, loading the game to a specific load address, with music - followed by the PRESS SPACEBAR sprite afterwards. If 'N' is pressed, then the standard KERNAL loader is used instead, then the music plays and the PRESS SPACEBAR command is displayed. If using an IRQ disk loader. 

There are plenty of those IRQ loader systems available on the internet. It just takes some time to learn to implement an IRQ loading system to load in your specific program.

Back to top



TAPE MASTERING

Have you written a game and you wanted to master the game to tape/.tap format with a loading picture, etc then run the game so that your game has a spiffy loading picture and then run (or prompt the user to press spacebar). There are different methods in which can be used to master your programs to .tap or tape.

PC TAPE TOOL BUILDING PROGRAMS

The easiest method (without having to create a tape master disk) is to use a PC-based tape tool building utility. There are a few of these available which help you master your tape images. The only way to master these to real hardware would be to use a 1541Ultimate 2, or recording soundwaves of the .tap accurately through AUDIOTAP to tape, via a tape deck or to PC with external hardware that supports the C2N tape deck. I'll tell you more about this later. Here are a few example PC based tools, which create tape loader systems for your own programs.

AudioTap and WAVPRG

AudioTap is a tool that writes TAP files through an audio device on to a real tape. WAVPRG is slightly similar, except for that it allows you to convert data in TAP files into PRG files. Or PRG files into Tap/Wav files. You can simply stream the .tap file to a CD and use that on a HiFi stereo system to record your TAP file to a real tape. WAVPRG has its own special turbo loader, which looks something like this below:



The turbo loader system allows you to copy your standard program (PRG) or a program inside a T64 file. Then will generate a wave form or a .tap image with an autostart turbo. The turbo handles the BASIC run address in order to run a normal program.

Back to top



LoadONE by Joonas Lindberg



The second of the easiest of all PC based tape mastering tools, is LoadONE by Joonas Lindberg. It doesn't do anything too exciting. Nor does it display a loading picture, but it is quite fast. If your game doesn't require loading music or a loading picture. LoadOne is very good for this type of program. All you have to do is use the command prompt to set up the loader to compile and build a tap with a built in classic loader. Also the run address of your program needs to be set. Warning - There is no test pulse before loading an actual program. It starts with a green screen. Still it is good for its backup purposes or small games, requiring no awesome presentation.

Back to top



TAPGEN by Enthusi/Onslaught



TAPGen is a simple tape mastering utility, in which generates .tap with a tape loader, scroll text, koala paint picture with SID music. The loader first starts with a blank screen with black + white stripes. Then it displays a scroll text. After the scroll text has finished. A bitmap will display. The tape loader also has a clever progress bar. WARNING. This tool is not compatible with the 1541Ultimate 2.6 firmware, or lower. It might be compatible with the 3.2 firmware and the Ultimate 64. After being written to tape - It should work on real tape deck hardware anyhow. This program requires PYTHON run time files.

Make R-LOAD by TLR Design



If you have written programs which require no loading picture or loading music, during loading. Make R-Load is really awesome. It is a DASM based sourced utility, that allows you to link your own programs to a raster rolling tape loader. Also mastering the .tap to a real tape on a real C64 is very easy to handle. Simply modify the config.cnf file with notepad to set correct files and jump addresses of your programs. Additional  assembly source code to handle the is also included. You will need DASM cross assembly however to generate the loader.

You can also use tapmaster 0.4 to write the built .tap file to a real C64 tape via a full program. Filesize restrictions apply!

Back to top



Make S-Load by TLR Design



This is yet another alternative tape mastering loader system for displaying a bitmap with loading music with thin loading stripes. Make S-Load allows included source code, and a .cnf file (which can be edited in notepad) to setup the loader. The source files can be modified to create IRQ loading to load programs the way you want to. It doesn't aways have to be a loading picture with music. I managed to implement my thunderload loader games into this program as well. DASM cross assembler is also required for this program.

Like with R-Load, you can also use tapmaster 0.4 to write the built .tap to a real C64 tape via a full program. Yet again, filesize restrictions apply.

Back to top


TAPE TOOL BUILD by Martin Piper

TapeToolBuild (AKA Thunderload) by Martin Piper



This is the tape loader system I use a lot for my own / contributors productions. It is an ACME cross assembler coder's friendly tape mastering system, which allows you to generate .tap loaders any kind of way. You can basically edit any part in the IRQ tape loader's source code to enable it to display loading picture, music, run programs. The tape loader also comes with an intelligent load error detection, which will automatically stop the tape and display a red border. Rewinding the tape will hunt for the missing byte, and if found. The loader continues loading the data. Like with S-Load The main raster code can also be modified to add very cool screen effects, link additional code to the loader system. Also unlike S-Load. This tape loader allows you to custom the tape loading stripes. It also comes with a few different loader type features:

SmallLoader is a fun implementation of the classic Martech boot loader, which makes weird noises during loading. It sounds a bit like the old screeching Novaload, which I have fond memories about. :)

Novaishloader is a nice implementation of the flashing border version of the Novaload tape loader. Basically, you have a grey screen, with a filename in white, and the NOVAISHLOAD 123456 text in grey at the bottom.

Martyload is a fun implementation of the Cyberload's opening tape loader (The black bar, with cycling charset). The only difference is the colouring, also the loader (if border cycle enabled) will cycle the border colour per block loaded.

The default loader is a plain black screen with the filename text in white.

This loader also allows you to open the borders during loading. Simply remove ; in ScrollerMusicLoader.a OpenBorders = 1 and you'll get that cool feature.

To test for no errors in the loader source, after changes have been made, use:

ACME -v3 loaders.a

To test that your files (music, picture, game) are successfully converted to loadertune, picture, linkedgame use the command

ACME -v3 setmusic.a
ACME -v3 makepic.a
ACME - v3 linker.a

Always do this to check for errors.

For building the complete .tap image with the autoboot, tape turbo, etc, use:

ExampleBuild.bat

Generating a .tap imaged with TapeToolBuild is very simple, but writing to a real tape can be quite a challenge. I tend to create some additional separate assembly files for loading in the music, picture and game, and then link it all together inside a D64, with the assembled IRQTAPE1.A source. 

Please note that the IRQ tape loader system has its own default code. If you would like to display a loading picture as well as play music. Simply edit ScrollerMusicLoader.a to how you want it to work. Also edit the EXAMPLEBUILD.BAT file to add your extra files. A description of some of the commands is input inside the source.

TapeToolBuild and IRQ tape loader consist of the following source code (Either created or modified by me). Martin has given me kind permission to release these :)

The files in my TAPE TOOL BUILD UPGRADE are as follows:

UPDATED: LOADERS.A - The main boot loading setup (which blacks out the screen). 
NEW: LOADINGSTRIPES.TXT - The loading stripes scheme for the boot and irq turbo loader
UPDATED: TAPELOADERCIASMALL.A - Modified code I have made for the Quad Core tape loader, short and sweet, no silly Martech loader style noise :) You can make it how you like if you wish to.
UPDATED: TAPELOADERCIACOMMON.A - Modified code, in which I have made for the appearance of the tape loader system. Also links LOADINGSTRIPES.A sample code for the flashing border style
UPDATED: TAPELOADERCIAIRQ.A - Modified code I have added to the original turbo. Also links LOADINGSTRIPES.A code for the flashing border style
UPDATED: SCROLLERMUSICLOADER.A - Modfied code in order to display cool flashy effects in the IRQ raster routines, scroll a text, play music and also allow to show a picture before loading and running the main game, itself.
NEW: SETMUSIC.A - Assembly source file, in which sets up the loadname of the music to be linked to the loader.
NEW: MAKEPIC.A - Assembly source file in which sets up the position of the bitmap data to be forced into the loader. It also sets the filename of the bitmap
UPDATED: IRQTAPE.A - Assembly source that generates a manual tape master (Reading files A,B,C (A= Music, B=Koala Picture, C=Game) from disk, and writing everything manually to tape with the turbo loader as set by you) - This is useful for those of you who have problems writing .tap files to a real tape when mastering.
UPDATED: EXAMPLEBUILD.BAT - A batch file in order to assemble and run all of the files. Use the COMMAND PROMPT to check for errors in the code. This version puts up the assembled music, picture and game and puts it into tapetoolbuild.

Make sure you download the program with ACME cross assembler, etc on to your PC first. Then download my SCROLLER PICTURE MUSIC additional upgrade to the same directory as the original tape tool build. This will replace some of the older files, so make sure you have backed up the original TapeToolBuild directory Also, rename the EXAMPLEBUILD.txt to ExampleBuild.bat (or recreate it).

Quick update 12th July 2019: Someone on lemon64 contacted me to inform me about the missing assembly files, for linking binaries to form file names for the tape turbo. The files missing were:

SETMUSIC.A, MAKEPIC.A, LINKER.A

These example files have now been added to the .zip archive.

DOWNLOAD RICHARD'S TAPE TOOLBUILD UPGRADE


If this is too hard for you, then you might want to try the following TAPE MASTER PRO tools, which uses an implementation of Martin Piper's original IRQ tape turbo source. Those of which allow you to master your programs on disk to tape a similar way. Although filesize restrictions apply. Still manuals are provided with the 3 tools.

TAPE MASTER PRO V1.0
TAPE MASTER PRO V2.1
TAPE MASTER PRO V3.0

are all available on the TND Utilities page.

Back to top


Laze Ristoski's IRQ Tape Turbo Loader example (NINJALOAD)

Back in the early 2000's. Laze Ristoski had created an IRQ Turbo Tape loader, which he showed me, and it was pretty damn slow and hard to put together. That was unless you had JCASS with Multi-Save and Multiload sample code - Which was a real nightmare. The loader was able to display a loading picture and play music in the background, with a black border and very thin loading stripes. The source code was free to use and very customisable, but I couldn't really get the example code to work when assembling it at the time.

That was until 2018. :) I implemented a working version of the same code example as in the Codebase64 example, but I also modified the loader a little. It now can cycle the border per block loaded, in the style of Cyberload. I also generated a simple DISK/TAPE transfer routines as separate source files. So now I was able to master a loading tune, koalapaint picture and the game, itself from disk, and then master it to tape. The loading scheme was also altered slightly. So here's the working project and source for you to play around with, just for fun.

The files are as follows:

LOADER.ASM - The main turbo tape loader Compile this first, before compiling the other assembly files
LOADERINSTALL.ASM - Some additional code I added in order to automatically install the tape loader after linked to saver. Remember LOADER.ASM must be compiled first.
SAVER.ASM - The main mastering program. It puts everything together. Use the filenames in upper case, followed by * to change the name of the files to master from disk to tape.
INSTRUCTIONS.ASM - Just some handy instructions on how to get this program assembled and running.

After assembling, placing filenames on a master D64, running VICE and manually recording to .tap (Or through a real C64 tape). The result should turn out like this:




DOWNLOAD IRQ Turbo Tape C64Studio Project and source



And that wraps everything on mastering your own programs, and this chapter as a whole. I do hope you have found this feature to be interesting or useful and most important of them all. Fun!


Back to top




BUILDING YOUR OWN 16KB CARTRIDGE 

You may have discovered that I have mainly been talking about mastering programs to disk, and also to tape. However, what about making your own 16KB cartridge? Especially if you want to write a game that fits 16KB for RGCD 16KB cartridge competitions or maybe just for fun. So then how do we make a digital cartridge? There are two different ways. You could either code your own cartridge ROM boot code in your chosen assembler. Make it a raw .bin file and then master a cartridge using CARTCONV . Or, there is the alternative way, which I find to be a whole lot easier for me. Especially since I am very much used to C64Studio. Simply program your own cartridge ROM framework in C64Studio - without needing to use external tools. As C64Studio has its own 16KB cartridge build function.

When coding the cartridge ROM/BOOT up, it should aways start with the following command in your code:

                            !to "mycart.crt",cart16crt

Now another thing you should ALWAYS remember to do, is to place the cartridge header at the address $8000. Then add a few of these commands below, to accurately make a cartridge ROM boot.


      *=$8000
      !word launcher
      !word launcher
      !byte $c3,$c2,$cd,$38,$30 ;CBM 80

launcher 
   sei
   stx $d016
 
   jsr $fda3 ;prepare irq
   jsr $fd50 ;input memory
   jsr $fd15 ;initialise i/o
   jsr $ff5b ;initialise video memory
           

The above code creates a launcher, in which sets up the cartridge configuration. Now Let's do an experiment. At the end of this source. Add the following code:

 
    lda #$35
    sta $01
    inc $d020
    jmp *-3


    *=$c000 ;End address of 16KB cartridge

Compile and run through C64Studio's compiler.... Congratulations, you have made a simple cartridge  with a flashing border - Although that is rather pointless..


Now, let's try a different program. This time LINKING a program to the cartridge ROM, instead of flashing the border.

Before you do this, you MUST remember to set EXOMIZER to crunch your program using a specific command. This is because a cartridge ROM can overwrite memory $8000-$c000 with the incorrect code, if the decruncher is set to default. Your game data gets linked from the end of the cartridge code, through to $bfff. Which means your program should be 15KB or less.

exomizer sfx $4000 rogueninja.prg -o rogueninja.prg -x -Di_ram_entry=$37 -Di_ram_during=$34

You might want to add an optional command to exomizer, if your game doesn't have a default $01 status set before running the main program. That command is -f "lda #$36 sta $01" (Well, for my example that is).

Right, now copy your crunched game over to your cartridge framework project in C64Studio, and type in the following code:


;*****************************************
;*                                       *
;*       16kb cartridge framework        *
;*        c64 studio v6.0 version        *
;*  for the rgcd 16kb cartridge compo    *
;*                                       *
;*****************************************

      !to "my16kcart.crt",cart16crt

Decrunch_Address = $080d    ;Exomizer decrunch address
 
      *=$8000
      !word launcher
      !word launcher
      !byte $c3,$c2,$cd,$38,$30 ;CBM 80

launcher 
   sei
   stx $d016
 
   jsr $fda3 ;prepare irq
   jsr $fd50 ;input memory
   jsr $fd15 ;initialise i/o
   jsr $ff5b ;initialise video memory
   
    ;No interrupts or CIA should be enabled.
    ;disable these
   
     lda #0
     sta $d019
     sta $d01a
     lda #$81
     sta $dc0d
     sta $dd0d
     
     ;Copy the relocator code to $0100-$01ff
     
   ldx #$00
CopyRelocator
     lda Relocator,x
   sta $0100,x

   inx
   bne CopyRelocator
     
     ;If you want, set the border + background colour to the background colour of your game.
     
     lda #0
     sta $d020
     sta $d021
     
     sta $dbe7 ;Hide the single byte char if using a custom border flash code with '-x "border flash code"
     
   jmp $0100    

     ;The move code, which has been copied to $0100-$01ff
     
Relocator
   ldx #$00
RelocLoop   lda GameData,x
   sta $0801,x

   inx
   bne RelocLoop
   inc $0104    ;Self-mod code position
   inc $0107    ;for data relocation
   lda $0104
   cmp #$c0
   bne Relocator
     
     lda #$35        ;All kernal disabled, but this can be removed
     sta $01        ;if you don't think you need it!
     
   jmp Decrunch_Address



;import main game (Crunched with Exomizer or other packer)
GameData
   !bin "rogueninja.prg",,2
GameDataEnd

     !if GameDataEnd > $c000 {
         !error "GAME IS TOO LARGE TO FIT A 16KB CARTRIDGE"
    }
*=$c000
;Cartridge end!

Compile, then RUN...

MIX

If your program compiles and runs and WinVice runs your game 100% after fully testing. Congratulations, you now have a working 16KB cartridge. Otherwise you may need to configure Exomizer to allow the program to decrunch. If you get an ERROR during compiling "GAME IS TOO LARGE TO FIT A 16KB CARTRIDGE", you may need to trim down some of your data or code in your game.

Alternatively, I have also supplied the framework which you can use in C64Studio, it also consists of some instructions inside the code, that should help you link your 15KB or less game into the 16KB cartridge slot.



Click on the Disk icon to download the framework

Oh, and before I go. It is possible to also add additional code for fadeout and other bits before relocating and decrunching your own game - providing that you have enough memory in the Cartridge boot header code before importing your relocated game code data.

That's it. The end of this chapter!

Credit also goes  to Enthusi for the original cartridge ROM example which has inspired me to create my own version of the 16KB  cartridge framework