The previous logs found its way to the directory on an SD card when the first LBA contained a partition table. It was able to "roughly" read in the directory but had trouble with proper parsing when the directory had long file names.
This log is a quick solution to that issue. If successful, this should produce a clean listing of the part of the directory in the first LBA.
Directory entries are 32-bytes per entry. Here's the first directory LBA seperated into 32-byte chunks..
DIR SECTOR # 24576 96 0 READING LBA 24576 000 42 20 00 49 00 6E 00 66 00 6F 00 0F 00 72 72 00 B .I.n.f.o...rr. 010 6D 00 61 00 74 00 69 00 6F 00 00 00 6E 00 00 00 m.a.t.i.o...n... 020 01 53 00 79 00 73 00 74 00 65 00 0F 00 72 6D 00 .S.y.s.t.e...rm. 030 20 00 56 00 6F 00 6C 00 75 00 00 00 6D 00 65 00 .V.o.l.u...m.e. 040 53 59 53 54 45 4D 7E 31 20 20 20 16 00 99 98 8C SYSTEM~1 ..... 050 A9 54 A9 54 00 00 99 8C A9 54 03 00 00 00 00 00 .T.T.....T...... 060 41 48 00 6F 00 63 00 6B 00 65 00 0F 00 69 79 00 AH.o.c.k.e...iy. 070 2E 00 62 00 61 00 73 00 00 00 00 00 FF FF FF FF ..b.a.s......... 080 48 4F 43 4B 45 59 20 20 42 41 53 20 00 23 BD 8C HOCKEY BAS .#.. 090 A9 54 A9 54 00 00 F5 91 4D 54 05 00 B9 20 00 00 .T.T....MT... .. 0A0 41 48 00 6F 00 72 00 73 00 65 00 0F 00 63 52 00 AH.o.r.s.e...cR. 0B0 61 00 63 00 65 00 2E 00 62 00 00 00 61 00 73 00 a.c.e...b...a.s. 0C0 48 4F 52 53 45 52 7E 31 42 41 53 20 00 4B BD 8C HORSER~1BAS .K.. 0D0 A9 54 A9 54 00 00 01 92 4D 54 06 00 C6 0B 00 00 .T.T....MT...... 0E0 41 48 00 75 00 72 00 6B 00 6C 00 0F 00 39 65 00 AH.u.r.k.l...9e. 0F0 2E 00 62 00 61 00 73 00 00 00 00 00 FF FF FF FF ..b.a.s......... 100 48 55 52 4B 4C 45 20 20 42 41 53 20 00 52 BD 8C HURKLE BAS .R.. 110 A9 54 A9 54 00 00 F7 54 F1 52 07 00 6E 05 00 00 .T.T...T.R..n... 120 41 4B 00 69 00 6E 00 65 00 6D 00 0F 00 17 61 00 AK.i.n.e.m....a. 130 2E 00 62 00 61 00 73 00 00 00 00 00 FF FF FF FF ..b.a.s......... 140 4B 49 4E 45 4D 41 20 20 42 41 53 20 00 55 BD 8C KINEMA BAS .U.. 150 A9 54 A9 54 00 00 F7 54 F1 52 08 00 2D 03 00 00 .T.T...T.R..-... 160 41 4B 00 69 00 6E 00 67 00 2E 00 0F 00 DD 62 00 AK.i.n.g......b. 170 61 00 73 00 00 00 FF FF FF FF 00 00 FF FF FF FF a.s............. 180 4B 49 4E 47 20 20 20 20 42 41 53 20 00 58 BD 8C KING BAS .X.. 190 A9 54 A9 54 00 00 F7 54 F1 52 09 00 F6 22 00 00 .T.T...T.R...".. 1A0 42 69 00 63 00 00 00 FF FF FF FF 0F 00 A4 FF FF Bi.c............ 1B0 FF FF FF FF FF FF FF FF FF FF 00 00 FF FF FF FF ................ 1C0 01 6C 00 61 00 62 00 79 00 72 00 0F 00 A4 69 00 .l.a.b.y.r....i. 1D0 6E 00 74 00 68 00 2E 00 62 00 00 00 61 00 73 00 n.t.h...b...a.s. 1E0 4C 41 42 59 52 49 7E 31 42 41 53 20 00 5E BD 8C LABYRI~1BAS .^.. 1F0 A9 54 A9 54 00 00 F8 54 F1 52 0A 00 7C 13 00 00 .T.T...T.R..|...
A quick filter of each of the entries could be to look at the third byte. If the third byte is 0x00 then skip the record.
BASIC Code
The BASIC code is in GitHub here. So far, the code is able to read in the first directory block but it does a poor job of parsing the directory. Let's improve the directory code by looking at 32 byte chunks. The previous code stepped forward in 64 byte chunks but really should step in 32 byte chunks.
Here's the previous BASIC code:
4400 REM PRINT DIR ENTRY 4410 FOR I=0 TO 7 4420 IF MA(DF+I)<>32 THEN PRINT CHR$(MA(DF+I)); 4430 NEXT I 4440 PRINT "."; 4450 FOR I=8 TO 10 4460 IF MA(DF+I)<> 32 THEN PRINT CHR$(MA(DF+I)); 4470 NEXT I 4480 REM PRINT 4490 PRINT " ";:PRINT ((MA(DF+30)*65536)+(MA(DF+29)*256)+MA(DF+28)) 4500 RETURN 4600 PRINT "*** DIRECTORY ***" 4610 DF=128:REM DIR OFFSET 4620 GOSUB 4400:REM PRINT CURRENT DIR ENTRY 4630 DF=DF+64 4640 IF DF<512 GOTO 4620 4650 FF=DS+((9-2)*SC):REM MANUALLY ADDING FILE OFFSET 4660 L0=FF AND 255:L1=FF/256:L2=0:L3=0 4670 GOSUB 3800:REM POKE LBA VALS 4680 GOSUB 2200:REM CHECK CARD INIT STATUS 4690 GOSUB 2400:REM READ IN BLOCK 4700 GOSUB 3000:REM DUMP ARRAY 4710 RETURN
Instead of starting at 128,. start at 0. Then, look at the third byte. If it's not 0x00 print the entry. After doing that small change the directory listing looks good:
*** DIRECTORY *** SYSTEM~1. 0 HOCKEY.BAS 8377 HORSER~1.BAS 3014 HURKLE.BAS 1390 KINEMA.BAS 813 KING.BAS 8950 LABYRI~1.BAS 4988 READING LBA 25216
The size of the block is now displayed and longer file names are in 8.3 format. Also, the SySTEM~1 entry is shown.
The new directory parsing code is:
4600 PRINT "*** DIRECTORY ***" 4610 DF=0:REM START AT FIRST ENTRY 4620 IF MA(DF+2)<>0 THEN GOSUB 4400:REM PRINT CURRENT DIR ENTRY 4630 DF=DF+32 4640 IF DF<512 GOTO 4620 4650 FF=DS+((9-2)*SC):REM MANUALLY ADDING FILE OFFSET 4660 L0=FF AND 255:L1=FF/256:L2=0:L3=0 4670 GOSUB 3800:REM POKE LBA VALS 4680 GOSUB 2200:REM CHECK CARD INIT STATUS 4690 GOSUB 2400:REM READ IN BLOCK 4700 GOSUB 3000:REM DUMP ARRAY 4710 RETURN
Next - figure out how to find the next directory block. I think they are somehow chained?
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.