How to specify 1st byte to be ran in a tap file

edited October 2010 in Development
I am writing m/c to a tap file. When I load it in an emulator I have to go through the usual


I always thought TAPs couldnt specify a start, but I ran one earlier that started itself.

Any idea how this is done?

May be a simple question. Had a quick look in forum archive but couldnt find anything.


Post edited by carlinski on


  • edited October 2010
    Can you clarify by why you mean by "writing m/c to a tap file". Are you using a PC/Mac to convert Z80 code into a .tap file to then load into an emulator?

    A standard spectrum loader consists of a Header and a Block. The Header is 17 bytes long (19 once you include the "flag" byte (00 for header block) at the start and the "XOR checksum" byte at the end. Inside this 17 byte header is the fact that what follows is a "BYTES" block (code 3 I believe), its start address, and length and 10 character file name.

    The "data" block is the 2nd block you have to write which is basically the datablock you want to save/load with the same "flag" byte (FF this time for data block) at the beginning and "XOR checksum" at the end.

    To create a TAP file, each block must be proceeded with a two byte "length" which is 13h (19d) for the header block.

  • edited October 2010
    Yes, its z80 code from a pc into a .tap. I am using type 3, so I type load "" code to bring it in once I have selected the tap from the emulator.
  • edited October 2010
    Just to clarify, the tap is working perfectly. Just dont know how to make it autostart...
  • edited October 2010
    The tap can contain several blocks, and one of them must be one BASIC one that loads the machine code block and executes it.

    I have two programs that put binary code (or data) into a .tap file: BIN2TAP creates a BASIC header to run the code, and BIN2CODE that just creates the code block. Some assemblers, such as PASMO can also generate a .tap file directly, and I think there was a directive to specify a start address.

    Finally, if there's only one block in the TAP file, it might be that the BASIC variables and data was recorded in that file, so loading it keeps running the BASIC interpreter from where it was left in the moment of saving, and it was saved with somethink like:
    SAVE "autostart" CODE vararea,lenght : RANDOMIZE USR start

    (with vararea being the start address of basic variables)

    As you may see, there are several ways to do it... though I'm not sure if I'm answering your question or not. What's "type 3"?
  • edited October 2010
    Metalbrain wrote: »
    What's "type 3"?

    The type is 0,1,2 or 3 for a Program, Number array, Character array or Code file (respectively).
  • edited October 2010
    carlinski wrote: »
    Just to clarify, the tap is working perfectly. Just dont know how to make it autostart...

    Metalbrain give two methods. The first method is what I use and make use of an emulator to generate the TAP file bytes for the header block:
    10 LOAD "" CODE 30000
    20 RANDOMIZE USR 30000

    Create a TAP file in your emulator and place it in RECORD mode, then enter
    SAVE "Loader" LINE 10
    into your emulator and the basic loader will be stored in to a TAP file.

    That same TAP file (byte for byte) can be prefixed to your BYTES code to make the final TAP.

    Such a BASIC Loader TAP file generates the following bytes:

    13 00 00 00 4C 6F 61 64
    65 72 20 20 20 20 26 00
    0A 00 26 00 3B 28 00 FF
    00 0A 10 00 EF 22 22 AF
    33 30 30 30 30 0E 00 00
    30 75 00 0D 00 14 0E 00
    F9 C0 33 30 30 30 30 0E
    00 00 30 75 00 0D 86
  • edited October 2010
    You do it the same way as you did in the 1980's with a cassette.
  • edited October 2010
    Thanks, BloodBaz, perfect. Thats the way I will do it! And yes DrBeep, its just as it used to be done, just hadnt got my head around the true uses of a tap file.

Sign In or Register to comment.