How to show sub-dirs on 1581-disks?

Started by MIRKOSOFT, June 27, 2010, 07:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!

I have longer time one trouble:

When I change directory on 1581-disk, e.g. "OPEN1,8,15,"/SUBDIR":CLOSE1" and want to show this directory, command LOAD"$",8 or DIRECTORY (C128) it shows correctly.

But when I use my own directory-program (code see below), always it shows root directory of 1581-disk.

Can anybody help me?


lda #1
ldx #<dirnam
ldy #>dirnam
jsr setnam

lda #1
ldx device
ldy secaddr
jsr setlfs
clc
jsr open
bcs end

ldx #$01
jsr chkin

jsr read
cmp #01
bne end
jsr read
jsr read
ragain: jsr read
jsr read
pha
jsr read
tay
pla
tax
tya
jsr digit // prints BLOCKS
lda #$20
back: jsr toscreen
jsr read
bne back
lda #$0d
jsr toscreen
lda 212
cmp #63
beq end
jsr read
cmp #$00
bne ragain
end: jsr clrch
lda #1
jsr close
rts


Many many thanks for every help.

Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

LokalHorst

Quote from: MIRKOSOFT on June 27, 2010, 07:39 PM
When I change directory on 1581-disk, e.g. "OPEN1,8,15,"/SUBDIR":CLOSE1" and want to show this directory, command LOAD"$",8 or DIRECTORY (C128) it shows correctly.

But when I use my own directory-program (code see below), always it shows root directory of 1581-disk.
Hi Mirko,
assuming the following:

lda #1
ldx #<dirnam  ;pointing to a lonesome '$'
ldy #>dirnam
jsr setnam      ;$ffbd
        lda #1
ldx device
ldy secaddr    ;$60 - see importand note *1)
jsr setlfs
clc  ;superfluous - not used for open
jsr open   ;$ffc0
bcs end

ldx #$01
jsr chkin   ;$ffc6
jsr read   ;$ffe4
cmp #01
bne end
jsr read
jsr read
ragain: jsr read
jsr read
pha
jsr read
tay
pla
tax
tya
jsr digit ;$8e32
lda #$20
back: jsr toscreen   ;$ffd2
jsr read
bne back
lda #$0d
jsr toscreen
lda 212
cmp #63
beq end
jsr read
cmp #$00
bne ragain
end: jsr clrch   ;$ffcc
lda #1
jsr close   ;$ffc3
rts


After copying the code to vice, it worked like it should, with the addresses as shown.
The code after 'ragain' can be changed to:
jsr read
tax
jsr read
jsr digit

other than that, the whole thing can be shortened to:
LDA #$09   ;Dev.No. 9 for my testing
STA $011C
LDA #'$'      ;Filename
STA $1100
LDA #$01    ;Lengh of Filename
JSR $A6C0   ;set parameters
JSR $A09E   ;do the dir
...
remember we're on the c128, why re-invent the wheel ?

*1) secondary address with open "$" :
- if you open "$" with secondary address of 1 (or other non-zero) the data is returned as it is stored in the BAM/DIR sectors (binary)
- if you use secondary addr. of 0 (better 96 or $60) the data returned is formatted as a basic listing with line numbers, basic links and such.

The most important part is missing - selecting the partition and read the error-channel thereafter.
anything other than:
02, selected partition,(start track),(end track)
means the partition isn't selected or non-existing.