Page 1 of 1

Change directory - assembler

Posted: Sat Oct 28, 2023 3:30 pm
by unartic
Hi!

Being a highlevel programmer for several decades (started in the dos-ara) I'm now commited to learn assembly and x16 seems to be a great platform to do it on.

I'm using ca65.

I'm trying some 'random' basic stuff to get a feeling.

With SETLFS, SETNAM and LOAD using "$" as the filename, I'm able to load the filelist of the current directory.

Now I want to change the directory to a subdirectory and load a filelist from that directory. After some extensive googling, I'm not able to find it, so I hope somone can help me out here :-)

Re: Change directory - assembler

Posted: Sat Oct 28, 2023 6:54 pm
by desertfish
https://github.com/X16Community/x16-doc ... nd-channel

use the command channel (15) to send the command "CD:<directory>"

Re: Change directory - assembler

Posted: Sun Oct 29, 2023 6:07 pm
by unartic
Thanks! That was the missing link.

I now have this, but it doesn't work. Can you point me in the right direction?:
.org $080D
.segment "ONCE"

LOAD     = $FFD5
CLOSE    = $FFC3
SETLFS   = $FFBA
SETNAM   = $FFBD

jmp start


DOS_COMMAND: .byte "CD://DIR1/DIR2"
END_DOS_COMMAND:

tbuffer: .res 20000, $41

start:
   lda #2   ; Logical Number
   ldx #8   ; device
   ldy #15  ; control channel
   jsr SETLFS
   
   lda #(END_DOS_COMMAND-DOS_COMMAND) ; command length
   ldx #<DOS_COMMAND
   ldy #>DOS_COMMAND
   jsr SETNAM
   
   lda #0   ; load
   ldx #<tbuffer  ;don't know why this is needed for the command channel
   ldy #>tbuffer
   
   jsr LOAD
   
   lda #2
   jsr CLOSE 
  
    
rts

Re: Change directory - assembler

Posted: Mon Oct 30, 2023 5:15 am
by Stefan
I think you must use Kernal function OPEN, not LOAD.

The command gets executed, and then you may read the drive response from the opened file sequentially.

This is done by first setting the file as input with CHKIN and then read one char/byte at a time with CHRIN.

You need to clean up this when done with CLRCHN and CLOSE.