GAMENAM !BYTE 77, 65, 80 ; the word "map"
SAVEMAP
LDA #$01 ; logical file 1
LDX #$08 ; device 8
LDY #$FF ; (no command)
JSR $FFBA ; Kernal set logical file routine
LDY #<GAMENAM ; low byte of filename location
LDX #>GAMENAM ; high byte of filename location
LDA #$03 ; length of filename
JSR $FFBD ; kernal set-name routine.
LDA #$00 ; low byte of $4000
STA $05
LDA #$40 ; high byte of $4000
STA $06
LDX #$00 ; Low byte of $8000
LDY #$80 ; High byte of $8000
LDA #$05
JSR $FFD8 ; Start save routine.
RTS
Essentially, I want to create a file on the disk drive called "MAP" and it should contain the 16K worth of data from $4000 to $8000 in the VIC-20's memory. Now, this routine is creating a 16K file on the drive, but it has no name. It just shows up as "" on the disk. I can't for the life of me figure out what I am doing wrong. I mean, even if the pointer was off, the accumulator stores the length of the name, so the name should have at least 3 characters even if they are the wrong characters. Any thoughts?
carlsson wrote:I believe you have mixed up the X and Y registers. Try this:
LDX #<GAMENAM
LDY #>GAMENAM
If the file name points to a zero byte, the created file would be named empty string.
\
Thank you so much! That did solve the problem. I must have checked that 10 times and it looked right to me. At one point I had thought about swapping just to see what would happen, but, again, I was confused because I expected there would be at least some kind of name of 3 characters long..
Besides, shouldn't the file name string be terminated with a null character or it doesn't matter as you specify the length of it?
I found out by using Google, search for FFBA FFBD FFD8 until you find some relevant assembly language listings. Then look at how they used the routines, although it should be documented in some books as well. Since these Kernel calls are identical on the C64, you will get plenty of hits.