Back to the Directory Entry Structure table:
The offset to the cluster is at locations 20-21 and 26-27. The code to support this is:
4550 PRINT " ";:PRINT ((MA(DF+30)*65536)+(MA(DF+29)*256)+MA(DF+28)); 4560 AC=(65536*MA(DF+21))+(256*MA(DF+27))+MA(DF+26) 4570 PRINT "CLUSTER OFFSET";:PRINT AC
The result looks like this now.
*** DIRECTORY START *** SYSTEM~1. 0 CLUSTER OFFSET 3 HOCKEY.BAS 8377 CLUSTER OFFSET 5 HORSER~1.BAS 3014 CLUSTER OFFSET 6 HURKLE.BAS 1390 CLUSTER OFFSET 7 KINEMA.BAS 813 CLUSTER OFFSET 8 KING.BAS 8950 CLUSTER OFFSET 9 LABYRI~1.BAS 4988 CLUSTER OFFSET 10 LETTER.BAS 935 CLUSTER OFFSET 11 LIFE2.BAS 2298 CLUSTER OFFSET 12 ...
It should now be possible to replace the cluster offset with a value that gets typed in by the user. Wrote the code and is worked. Top part is:
270 GOSUB 5200:REM PRINT DIRECTORY 280 INPUT "FILE OFFSET";FS 360 GOSUB 5000:REM PRINT FILE AT 9
The file listing dumps the first block of the file. For QUBIC.BAS:
FILE OFFSET? 129 FILE OFFSET SECTOR 32704 000 35 30 20 50 52 49 4E 54 20 43 48 52 24 28 32 36 50 PRINT CHR$(26 010 29 3A 57 49 44 54 48 20 38 30 0D 0A 31 30 30 20 ):WIDTH 80..100 020 50 52 49 4E 54 20 54 41 42 28 33 33 29 3B 22 51 PRINT TAB(33);"Q 030 55 42 49 43 22 3A 50 52 49 4E 54 0D 0A 31 31 30 UBIC":PRINT..110 040 20 50 52 49 4E 54 20 54 41 42 28 31 35 29 3B 22 PRINT TAB(15);" 050 43 52 45 41 54 49 56 45 20 43 4F 4D 50 55 54 49 CREATIVE COMPUTI 060 4E 47 20 20 4D 4F 52 52 49 53 54 4F 57 4E 2C 20 NG MORRISTOWN, 070 4E 45 57 20 4A 45 52 53 45 59 22 0D 0A 31 32 30 NEW JERSEY"..120 080 20 50 52 49 4E 54 3A 50 52 49 4E 54 3A 50 52 49 PRINT:PRINT:PRI 090 4E 54 0D 0A 32 31 30 20 50 52 49 4E 54 20 22 44 NT..210 PRINT "D 0A0 4F 20 59 4F 55 20 57 41 4E 54 20 49 4E 53 54 52 O YOU WANT INSTR 0B0 55 43 54 49 4F 4E 53 22 3B 0D 0A 32 32 30 20 49 UCTIONS";..220 I 0C0 4E 50 55 54 20 43 24 0D 0A 32 33 30 20 49 46 20 NPUT C$..230 IF 0D0 4C 45 46 54 24 28 43 24 2C 31 29 3D 22 4E 22 20 LEFT$(C$,1)="N" 0E0 54 48 45 4E 20 33 31 35 0D 0A 32 34 30 20 49 46 THEN 315..240 IF 0F0 20 4C 45 46 54 24 28 43 24 2C 31 29 3D 22 59 22 LEFT$(C$,1)="Y" 100 20 54 48 45 4E 20 32 36 35 0D 0A 32 35 30 20 50 THEN 265..250 P 110 52 49 4E 54 20 22 49 4E 43 4F 52 52 45 43 54 20 RINT "INCORRECT 120 41 4E 53 57 45 52 2E 20 20 50 4C 45 41 53 45 20 ANSWER. PLEASE 130 54 59 50 45 20 27 59 45 53 27 20 4F 52 20 27 4E TYPE 'YES' OR 'N 140 4F 27 22 3B 0D 0A 32 36 30 20 47 4F 54 4F 20 32 O'";..260 GOTO 2 150 32 30 0D 0A 32 36 35 20 50 52 49 4E 54 0D 0A 32 20..265 PRINT..2 160 37 30 20 50 52 49 4E 54 20 22 54 48 45 20 47 41 70 PRINT "THE GA 170 4D 45 20 49 53 20 54 49 43 2D 54 41 43 2D 54 4F ME IS TIC-TAC-TO 180 45 20 49 4E 20 41 20 34 20 58 20 34 20 58 20 34 E IN A 4 X 4 X 4 190 20 43 55 42 45 2E 22 0D 0A 32 38 30 20 50 52 49 CUBE."..280 PRI 1A0 4E 54 20 22 45 41 43 48 20 4D 4F 56 45 20 49 53 NT "EACH MOVE IS 1B0 20 49 4E 44 49 43 41 54 45 44 20 42 59 20 41 20 INDICATED BY A 1C0 33 20 44 49 47 49 54 20 4E 55 4D 42 45 52 2C 20 3 DIGIT NUMBER, 1D0 57 49 54 48 20 45 41 43 48 22 0D 0A 32 39 30 20 WITH EACH"..290 1E0 50 52 49 4E 54 20 22 44 49 47 49 54 20 42 45 54 PRINT "DIGIT BET 1F0 57 45 45 4E 20 31 20 41 4E 44 20 34 20 49 4E 43 WEEN 1 AND 4 INC
One complication of loading BASIC programs is that BASIC is tokenized. There's a few ways to handle this.
- Do the tokenization and convert ASCII code to tokenized code at load time
- Load initially over serial port and save the file to the SD card as tokenized
- Intercept the BASIC LOAD/SAVE calls
- Could this be done at the I/O routine level? Or would BASIC need to be re-built? Hints are in here.
- Put the SD card code into an IOP16 core and emulate the serial port
- Advantage is this could be ported to any design - not just the OSI UK101
Thinking about other ways.
Loading C1P machine code should be much easier. The format is pretty simple:
000 2E 30 34 30 30 2F 41 32 0D 44 45 0D 41 39 0D 30 .0400/A2.DE.A9.0 010 34 0D 32 30 0D 33 45 0D 30 34 0D 32 30 0D 33 34 4.20.3E.04.20.34 020 0D 30 34 0D 41 39 0D 30 30 0D 38 44 0D 42 46 0D .04.A9.00.8D.BF. 030 30 34 0D 41 44 0D 42 46 0D 30 34 0D 32 30 0D 35 04.AD.BF.04.20.5 040 35 0D 30 34 0D 41 39 0D 32 30 0D 32 30 0D 45 45 5.04.A9.20.20.EE 050 0D 46 46 0D 41 44 0D 42 46 0D 30 34 0D 43 39 0D .FF.AD.BF.04.C9. 060 36 34 0D 46 30 0D 30 36 0D 45 45 0D 42 46 0D 30 64.F0.06.EE.BF.0 070 34 0D 34 43 0D 30 46 0D 30 34 0D 41 32 0D 33 36 4.4C.0F.04.A2.36 080 0D 41 39 0D 30 35 0D 32 30 0D 33 45 0D 30 34 0D .A9.05.20.3E.04. 090 32 30 0D 45 42 0D 46 46 0D 36 43 0D 46 43 0D 46 20.EB.FF.6C.FC.F 0A0 46 0D 41 32 0D 43 31 0D 41 39 0D 30 34 0D 32 30 F.A2.C1.A9.04.20
- . signals an address follows
- 0400 start loading code address
- / data entry mode
- AA - data
- 0D -next data - could possibly be CR and LF?
At the very least some facility for file names will need to be added to the LOAD/SAVE commands.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.