Firstloader

Publication: LISTing Newsletter
Date: March 1990
Pages: 5-9

TRY THIS TRY THIS TRY THIS

Syntax commissioned a custom program, written by David Ornstein, to convert your existing programs for the 2068 or 48K Spectrums.

This program translates input bytes from ZX/TS tapes to an equal number of output bytes in your 2068 that you must edit, and then save. Codes & program control structures differ in the two designs, making functionally identical programs use different numbers of bytes.

Create the program in two parts–the translation table shown here and the executable portion.

44000         32     130     129     131     136
44005        138     137     139     143     143
44010        143      34      96      36      58
44015         63      40      41      62      60
44020         61      43      45      42      47
44025         59      44      46      48      49
44030         50      51      52      53      54
44035         55      56      57      65      66
44040         67      68      69      70      71
44045         72      73      74      75      76
44050         77      78      79      80      81
44055         82      83      84      85      86
44060         87      88      89      90     165
44065        166     167      32      32      32
44070         32      32      32      32      32
44075         32      32      32      32      32
44080         32      32      32      32      32
44085         32      32      32      32      32
44090         32      32      32      32      32
44095         32      32      32      32      32
44100         32      32      32      32      32
44105         32      32      32      32      32
44110         32      32      32      32      32
44115         32      32      32      13      32
44120         32      32      32      32      32
44125         32      14      32     143     141
44130        142     140     135     133     134
44135   13[illegible]     143     143     143      34
44140         96      36      58      63      40
44145         41      62      60      61      43
44150         45      42      47      59      44
44155         46      48      49      50      51
44160         52      53      54      55      56
44165         57      65      66      67      68
44170         69      70      71      72      73
44175         74      75      76      77      78
44180         79      80      81      82      83
44185         84      85      86      87      88
44190         89      90      32     172     173
44195         32     175     176     177     178
44200        179     180     181     182     183
44205        184     185     186     187     188
44210        189     190     192     193     194
44215        195      94     197     198     199
44220        200     201     203     204     205
44225        224     225     226      32      32
44230        230      32     232     233     234
44235        235     236     237     238     239
44240        240     241     242     243     244
44245        245     246     247     248     249
44250        250     251      32     253     254
44255        255
Translation table addresses 44000-44255
Translation table addresses 44000-44255

Direct tables, such as this, consist of an address, derived from the input code, containing an entry that equals a desired output code. Our table address consists of the CODE of the ZX/TS character +44000. Entries consist of 2068 codes to produce the character, command, or function. If no one corresponding code exists, we pick a substitute to hold the space. Then we edit the translated program as needed.

Use the table shown to produce the translator as Syntax tested it. We suggest you fill the table area with code 127 as you begin. That way, listing the table produces (C) symbols if you miss any entries.

You can modify the translation table to substitute any byte. Add 44000 to the ZX/TS character code, then POKE that address in your 2068 with the code you want the program to contain. Codes below 32 trigger errors in the display.

For example, say you want SLOW changed to REM. You take 228, the ZX/TS code for SLOW, add 44000, and POKE 44228,234–the 2068 REM code.

You can enter the executable code in whatever form you find convenient–we’ve provided both hex and decimal listings–but only the assembler listing is annotated.

Save the 2068 program using SAVE”FIRSTLOADR”CODE 44000,1250. Make several copies & VERIFY each.

To use the tape, CLEAR 43999, then LOAD”FIRSTLOADR”CODE (enter). When the 2068 displays 0 OK, 0:1 Position your ZX/TS tape in the 5-second quiet spot. Activate the loader by typing RAND USR 45000, and observe the red and black stripes in the border area. Then start the ZX/TS tape and observe the stripes again as they change width, indicating ones and zeros in the incoming data.

You will need a lower volume setting than if you were loading to a ZX/TS from the same recorder. You may find a Winky board eases loading. In some cases a 0.2 uF capacitor in series with the center conductor of the ear cord and a 1k resistor shunting the 2068 ear jack permits a wider range of volume settings for the ZX/TS tapes.

When the converter finds the end of the VARS area on the tape it switches from load to convert. At completion, your 2068 will display 0 OK, 0:1. LIST your proram and look for junk, If your translation looks OK, save it to a 2068 tape before you proceed. If the screen fills with garbage, or you get no listing, or LOADing of the ZX/TS tape stops early, type NEW, then try a different volume setting.

Edit the 2068 version to account for differences in comments and codes. Of course you can also add color functions to the 2068 program thus created.

Not all keywords translate sensibly–check your output list for the following:

Keyword   Action
CHR$      Change char code
CODE      Change compared value
FAST      Delete SpacE
PAUSE 0   Delete or use PAUSE 1
PEEK      Change address
PLOT      Reprogram
POKE      Change address, data
UNPLOT    Reprogram SpacE
USR       Change address
SCROLL    Delete SpacE or use PRINT
SLOW      Delete SpacE
Shift Q   Change SpacE to """

Also, the program removes all ZX/TS inverse characters, substituting normal characters, and translates the half-tone character graphics to solid blacks of the same shape.

After editing, save the latest updated and enhanced program for use with the 2068.

By modifying the translation table, you can substitute user-defined graphics as you convert.

You can purchase this program on tape for $19.95 ppd from E-Z Key, Suite 75-STX 711 Southern Artery, Quincy, MA 02169. Call 617/773-1187 to use VISA or MC.

This table shows addresses to POKE, in steps of five, with the values reading left-to-right for the 5 successive locations. POKE them manually or write a loop to advance the address automatically. These decimal codes correspond to the hexadecimal assembly listing on the following pages.

45000        205      60     176     205     222
45005        175       6       7      54     118
45010         35      16     251     205      89
45015        176     205     142     176     201
45020        207       3      33       9     192
45025         17      12       0      25      54
45030        254     167     237      82     205
45035        251     175     113     124     254
45040          0      40     233     205      75
45045        176     205      46     176      24
45050        239      14       1       6       0
45055        205      68     176      62     127
45060        219     254      31      48      49
45065         23      23      23      56       2
45070         24     239     213      30     148
45075          6      26      29     219     254
45080         23      23     203     123     123
45085         56     244      16     244     209
45090         32       4     254      86      48
45095        213      63     203      17      48
45100        208     201      35     235      42
45105         20     192      55     237      82
45110        235     208     193     201     207
45115         12     205     251     175     203
45120        121      40     249     201     120
45125        238       2     211     254      71
45130        201      17      21     192     122
45135        188     192     123     189     192
45140        126     198     128     119     201
45145         33     125     192     126     254
45150        118     200     205     101     176
45155         24     247      17       4       0
45160         25      62     127     219     254
45165         31      48     202     126     254
45170        126      32       8      54      14
45175         17       6       0      25      24
45180        236     229      17     224     171
45185         38       0     111      25     126
45190        225     119      35     254      13
45195         32     220     201      17     125
45200        192     167     237      82      68
45205         77     197      42      75      92
45210         43     237      91      83      92
45215        213     205     187      18     209
45220        237      83      83      92     193
45225         35      35     235      33     125
45230        192     237     176     201

On the following pages you’ll find FIRSTLOADER code, assembled to location 45000. This excludes the translation table. Read columns as follows: hex address, hex code for instruction, assembler line number (ignore it), assembler label (for human use), then a Z80 instruction mnemonic or assembler pseudo-operator, operand mnemonics, and a semicolon followed by comments.

AFC8             00100            ORG     45000
AFC8 CD3CB0 00110 CALL FNAME
AFCB CDDEAF 00120 CALL LOADER
AFCE 0607 00130 LD B,7
AFD0 3676 00140 INCASE LD (HL),118; ZX/TS NL
AFD2 23 00150 INC HL
AFD3 10FB 00160 DJNZ INCASE
AFD5 CD59B0 00170 CALL XLATE
AFD8 CD8EB0 00180 CALL MAKPRG
AFDB C9 00190 RET
AFDC CF 00200 ERR3 RST 8
AFDD 03 00210 DEFB 3
C014 00220 E1LINE EQU 49172; ZX/TS E-LINE + 32K
C015 00230 E2LINE EQU 49173
AFDE 2109C0 00240 LOADER LD HL,49161; ZX/TS VERSN + 32K
AFE1 110C00 00250 LD DE,12
AFE4 19 00260 ADD HL,DE ; SKIP 12 BYTES HL PT 49173
AFE5 36FE 00270 LD (HL),00FEH; LOAD AT LEAST 256 BYTES
AFE7 A7 00280 AND A
AFE8 ED52 00290 SBC HL,DE
AFEA CDFBAF 00300 LL36 CALL INBYTE ; GET BYTE IN C
AFED 71 00310 LD (HL),C ; STORE THE ZX/TS BYTE
AFEE 7C 00320 LD A,H
AFEF FE00 00330 CP 0
AFF1 28E9 00340 JR Z,ERR3
AFF3 CD4BB0 00350 CALL EFIX ; IF HL=E2LINE ADD 128 TO HI
AFF6 CD2EB0 00360 CALL ENDBYT ; BYTE (IND HL). LAST BYTE?
AFF9 18EF 00370 JR LL36
AFFB 0E01 00380 INBYTE LD C,1
AFFD 0600 00390 LL3 LD B,0
AFFF CD44B0 00400 LL32 CALL BORDER ; FLIP COLOR
B002 3E7F 00410 LD A,007FH
B004 DBFE 00420 IN A,(00FEH)
B006 1F 00430 RRA
B007 3031 00440 JR NC,LL7 ; IF BREAK IS PRESSED
B009 17 00450 RLA
B00A 17 00460 RLA
B00B 17 00470 RLA
B00C 3802 00480 JR C,LL38 ; IF HAVE A SIGNAL
B00E 18EF 00490 JR LL32
B010 D5 00500 LL38 PUSH DE
B011 1E94 00510 LD E,148
B013 061A 00520 LL4 LD B,26
B015 1D 00530 LL5 DEC E
B016 DBFE 00540 IN A,(00FEH)
B018 17 00550 RLA
B019 17 00560 RLA
B01A CB7B 00570 BIT 7,E
B01C 7B 00580 LD A,E
B01D 38F4 00590 JR C,LL4
B01F 10F4 00600 DJNZ LL5
B021 D1 00610 POP DE
B022 2004 00620 JR NZ,LL6
B024 FE56 00630 CP 86
B026 30D5 00640 JR NC,LL3
B028 3F          00650 LL6        CCF
B029 CB11 00660 RL C
B02B 30D0 00670 JR NC,LL3
B02D C9 00680 RET
B02E 23 00690 ENDBYT INC HL ; WAS THAT THE LAST BYTE?
B02F EB 00700 EX DE,HL
B030 2A14C0 00710 LD HL,(E1LINE); IS HL PAST IND E1LINE?
B033 37 00720 SCF
B034 ED52 00730 SBC HL,DE
B036 EB 00740 EX DE,HL
B037 D0 00750 RET NC
B038 C1 00760 POP BC ; GO BACK TO MAIN ROUTINE
B039 C9 00770 RET
B03A CF 00780 LL7 RST 8
B03B 0C 00790 DEFB 12
B03C CDFBAF 00800 FNAME CALL INBYTE ; LOOK FOR 1ST INVERSE CHAR
B03F CB79 00810 BIT 7,C
B041 28F9 00820 JR Z,FNAME; KEEP LOOKING
B043 C9 00830 RET ; NOW START LOADING ZX CODE
B044 78 00840 BORDER LD A,B ; FLIP BORDER COLOR 2 OR 0
B045 EE02 00850 XOR 2
B047 D3FE 00860 OUT (00FEH),A
B049 47 00870 LD B,A
B04A C9 00880 RET
B04B 1115C0 00890 EFIX LD DE,E2LINE; DID I JUST LOAD TO E2LINE
B04E 7A 00900 LD A,D
B04F BC 00910 CP H ; COMPARE HI BYTE
B050 C0 00920 RET NZ
B051 7B 00930 LD A,E
B052 BD 00940 CP L ; COMPARE LO BYTE
B053 C0 00950 RET NZ
B054 7E 00960 LD A,(HL)
B055 C680 00970 ADD A,128 ; ADD 32K
B057 77 00980 LD (HL),A
B058 C9 00990 RET
B059 217DC0 01000 XLATE LD HL,49277; 1ST BYTE OF 1ST LINE #
B05C 7E 01010 LXL1 LD A,(HL) ; AT 16509+32K
B05D FE76 01020 CP 118 ; IS IT 1ST NL IN ZX D-FILE
B05F C8 01030 RET Z ; IF SO, YOU'RE DONE
B060 CD65B0 01040 CALL LINE
B063 18F7 01050 JR LXL1
B065 110400 01060 LINE LD DE,4 ; SKIP LINE # & LENGTH
B068 19 01070 ADD HL,DE
B069 3E7F 01080 LLIN1 LD A,007FH ; TEST BREAK ON 2068
B06B DBFE 01090 IN A,(00FEH); GET CHAR IN ACCUM
B06D 1F 01100 RRA
B06E 30CA 01110 JR NC,LL7 ; EXIT IF BREAK PRESSED
B070 7E 01120 LD A,(HL) ; GET BYTE
B071 FE7E 01130 CP 126 ; CHECK FOR ZX/TS SLUG
B073 2008 01140 JR NZ,LLIN2; GET CODE FROM TABLE
B075 360E 01150 LD (HL),14 ; SUBST 2068 SLUG
B077 110600 01160 LD DE,6 ; SKIP SLUG + 5 BYTES
B07A 19 01170 ADD HL,DE
B07B 18EC 01180 JR LLIN1 ; DO IT AGAIN
B07D E5          01190 LLIN2      PUSH    HL      ; STORE THE BYTE ADDRESS
B07E 11E0AB 01200 LD DE,44000; TABLE START ADDRESS
B081 2600 01210 LD H,0 ; PUT ZX/TS CHAR CODE IN HL
B083 6F 01220 LD L,A
B084 19 01230 ADD HL,DE ; ADDRESS OF BYTE IN TABLE
B085 7E 01240 LD A,(HL) ; GET BYTE FROM TABLE TO A
B086 E1 01250 POP HL ; RECALL BYTE ADDRESS
B087 77 01260 LD (HL),A ; PUT NEW CODE IN OLD ADDRESS
B088 23 01270 INC HL
B089 FE0D 01280 CP 13 ; CHECK FOR 2068 NL
B08B 20DC 01290 JR NZ,LLIN1; NO, DO IT AGAIN
B08D C9 01300 RET ; FINISHED THAT LINE
B08E 117DC0 01310 MAKPRG LD DE,49277; APPEND PROG TO 2068 CONTENT
B091 A7 01320 AND A
B092 ED52 01330 SBC HL,DE ; HL PT 1ST BYTE OF D-FILE
B094 44 01340 LD B,H ; BC = NO. BYTES IN PROGRAM
B095 4D 01350 LD C,L
B096 C5 01360 PUSH BC ; SAVE SIZE OF PROG
B097 2A4B5C 01370 LD HL,(23627); ADDRESS OF 2068 VARS
B09A 2B 01380 DEC HL
B09B ED5B535C 01390 LD DE,(23635); ADDR OF 2068 BASIC PROG
B09F D5 01400 PUSH DE ; SAVE PROG SYSVAR
B0A0 CDBB12 01410 CALL 4795 ; CALL ROM INSERT-USE 5717 ON
B0A3 D1 01420 POP DE ; SPECT-RESTORE PROG SYSVAR
B0A4 ED53535C 01430 LD (23635),DE
B0A8 C1 01440 POP BC ; BYTE COUNT OF PROG
B0A9 23 01450 INC HL
B0AA 23 01460 INC HL
B0AB EB 01470 EX DE,HL ; DE=DATA DESTINATION
B0AC 217DC0 01480 LD HL,49277; START OF STUFF TO MOVE
B0AF EDB0 01490 LDIR ; BLOCK MOVE
B0B1 C9 01500 RET
BORDER B044 00840   00400         LL36   AFEA 00300   00370
E1LINE C014 00220   00710         LL38   B010 00500   00480
E2LINE C015 00230   00890         LL4    B013 00520   00590
EFIX   B04B 00890   00350         LL5    B015 00530   00600
ENDBYT B02E 00690   00360         LL6    B028 00650   00620
ERR3   AFDC 00200   00340         LL7    B03A 00780   00440 01110
FNAME  B03C 00800   00110 00820   LLIN1  B069 01080   01180 01290
INBYTE AFFB 00380   00300 00800   LLIN2  B07D 01190   01140
INCASE AFD0 00140   00160         LOADER AFDE 00240   00120
LINE   B065 01060   01040         LXL1   B05C 01010   01050
LL3    AFFD 00390   00640 00670   MAKPRG B08E 01310   00180
LL32   AFFF 00400   00490         XLATE  B059 01000   00170

Only one change will make this program work with a 48K Spectrum as well. At B0A0H (45216 decimal), we call a ROM routine located at 4795 in the TS2068 and at 5717 in the Spectrum. These routines create an empty space, but you must fill it.

Most of this code is self-contained. Only the routine XLATE, located at 45145, passes a value to the code for MAKPRG. If you modify code, restore the value held in HL on return from address 45151 prior to calling MAKPRG.

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.