Page 3 of 4
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 6:31 pm
by VincentF
I think I misunderstood the DOS commands issued by the FS calls, I thought that by "reading the status" you meant calling READST but it was just calling OPEN with a zero-length file ! ?
I'm not fully aware of all the features of the C64 / X16, so I'm still learning things everyday ^^
Sorry about the past answers >_< was dumb
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 6:49 pm
by Stefan
OK.
READST just tells you that you have reached end of file or that there is some error, but not which one.
By opening another file with secondary address 15 you may read the disk status text stream. The text stream is read with the same functions as a normal text file(call CHKIN, and then call CHRIN and READST in a loop until you get a non-zero status value).
"00, OK, 00,00" is returned if there was no error.
"62, FILE NOT FOUND,00,00" is returned on, you guessed it, file not found.
There are, of coarse, many other possible disk errors. Read the complete list in the 1541 user manual page 42 found here:
http://www.commodore.ca/wp-content/uploads/2018/11/commodore_vic_1541_floppy_drive_users_manual.pdf This is not entirely intuitive, being a Commodore legacy, when disk drives where almost computers of their own that you communicated with over the serial bus.
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 7:28 pm
by VincentF
Got this code to check if an error occurred, it's just for testing what do you think of it ?

Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 7:38 pm
by Stefan
Looks promising. You should probably use READST to check for errors/EOI instead of return value 0 from CHRIN.
What happens when you run this?
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 7:48 pm
by VincentF
Right now it's returning carry set (debugged the output and it made sense) but still no luck on the blinking, i'll try with the READST. I tried to check for zeroes but I need to CMP #$30 instead. (petscii zeroes)
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 7:49 pm
by Greg King
18 minutes ago, VincentF said:
Got this code to check if an error occurred, it's just for testing. What do you think of it?
The "00, ok" message is text, not binary numbers. That is, your code would read $30, $30.
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 7:53 pm
by Greg King
2 minutes ago, VincentF said:
Right now it's returning carry set (debugged the output and it made sense) but still no luck on the blinking, i'll try with the READST. I tried to check for zeroes but I need to CMP #$30 instead. (petscii zeroes)
Perhaps, you need to read the entire message. Do a loop. Read until it sees a $0D (carriage return).
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 8:13 pm
by Stefan
This seems to work. Also puts out the blinking light.
CLOSE = $ffc3
CLRCHN = $ffcc
SETLFS = $ffba
SETNAM = $ffbd
OPEN = $ffc0
CHKIN = $ffc6
CHROUT = $ffd2
CHRIN = $ffcf
READST =$ffb7
disk_status:
lda #15
ldx #8
ldy #15
jsr SETLFS
lda #0
jsr SETNAM
jsr OPEN
ldx #15
jsr CHKIN
: jsr CHRIN
pha
jsr READST
bne EOF
pla
jsr CHROUT
bra :-
EOF:
pla
lda #15
jsr CLOSE
jsr CLRCHN
rts
Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 8:15 pm
by VincentF
15 minutes ago, Greg King said:
Perhaps, you need to read the entire message. Do a loop. Read until it sees a $0D (carriage return).
It was that. Now that I read the entire message the blinking is finally gone !
? Thank you so much @Greg King and @Stefan for helping me figuring out the issue ! I learned a lot on the filesystem process thanks to you ?
It would be nice to document this kind of stuff somewhere for people like me ? It's sometimes hard to find the right documentation for the right problem

Devlog: Vixx (bullet hell game)
Posted: Tue Feb 02, 2021 10:46 pm
by Greg King
Does Vixx really need to know
why it can't read the high score file? Maybe, it's enough that your program knows when it can, and when it can't. If that's the case, then "check_disk_error:" actually wouldn't need to compare the status numbers. It merely would need to do something that stops people from yelling, "Hey buddy, you left your turn signal on!"
?
Your program would OPEN the file. If OPEN returned with the Carry flag set, then the device doesn't exist (someone forgot to attach a card to the emulator). If the flag is unset, then the file must be closed, at some later time -- no matter what else happenned.
Vixx would try to read the file. Then, if READST returned a non-zero value (the particular bits wouldn't matter), Vixx would "flush" the device's error channel.
If Vixx wanted to add a new high score to the file, then it would know that the score is the first one. Vixx would create the file.
But, if Vixx wanted to show a high scores screen, then it would show an empty screen (nobody has scored, yet).