Login
Back to forumReply to this topicGo to last reply

Posted By

Haegar
on 2024-04-22
12:03:47
 Input Filename

Does anyone have an idea how best to enter a file name and store it in memory (filename) including the length of the file name in assembler?
Everything I've had so far has either been too long and cumbersome (SCNKEY - $ff9f) or doesn't work the way I thought it would (BASIN - $ffcf).

Here is my loading routine:
.
.
.
lda #$01 ;
ldx #$08 ; loading from disc
ldy #$01 ; absolutely load
jsr $ffba ; Setlfs, set up logical file
Flange
lda #$xx ; Length of the file name
ldx # ldy #>filename ; Highbyte file name
jsr $ffbd ; Set name, file name passed

lda #$00 ; 0 = loading
ldx #$00 ; Lowbyte load address
ldy #$10 ; High byte loading address
jsr $ffd5 ; Load, loads file after $1000
.
.
.


filename
text "xxxxxxxxxxxxxxxxx"

Posted By

Csabo
on 2024-04-22
14:17:19
 Re: Input Filename

This is a lot easier to do from BASIC happy Which is why most of the old-school packers, etc. that asked for a filename also did it with simple INPUT commands.

Anyway, if you don't want to write your own custom input routine, you can use $FFCF. There are two things to take care of: 1) count the length of the input and 2) convert the screen codes. Those are still relatively simple. Here's an example:

        jsr $FF4F                       ; clear screen and print message
db $93,"ENTER FILENAME: ",0 ; this ensures fixed screen position
jsr $FFCF ; input
ldx #$10 ; count the length with a backwards loop
loop1 dex
lda $0C10,x ; fixed screen position
cmp #$20 ; space?
beq loop1 ; yes, keep looping back
txa ; at this point, X = length-1
tay
loop2 lda $0C10,y
cmp #$1B ; "z" or smaller?
bcs *+4
ora #$40 ; yes, convert to uppercase
sta $0C10,y
dey
bpl loop2


After this, you will have the length-1 in X, and the filename on $0C10. In the second loop, you may copy the filename to your variable if you like. This code doesn't deal with invalid input though.

Hope it helps happy

Posted By

Haegar
on 2024-04-22
16:19:57
 Re: Input Filename

Yes, great, seems to be exactly what I was trying to do. I had already tried using $ffcf, unfortunately it didn't work as hoped for me. I also made it too complicated happy.

The invalid input may come in the next step.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024