Devlog: Vixx (bullet hell game)

All aspects of programming on the Commander X16.
VincentF
Posts: 75
Joined: Mon Jun 29, 2020 8:22 pm

Devlog: Vixx (bullet hell game)

Post by VincentF »


Thank you for your advice ! I'll try to add some check for the status this evening and see if it works better this way.

Just in case, here's the loading code :

loading_code.png.0b129673d63a3526b6041a10003cbcfa.png

Stefan
Posts: 465
Joined: Thu Aug 20, 2020 8:59 am

Devlog: Vixx (bullet hell game)

Post by Stefan »


OK. Please let us know if it solves your problem. Interesting issue after all.

User avatar
kliepatsch
Posts: 247
Joined: Thu Oct 08, 2020 9:54 pm

Devlog: Vixx (bullet hell game)

Post by kliepatsch »


You need to add ",s,r" or so to the file name to communicate to the disk driver that you are opening a sequential file (basically every file that isn't a BASIC or .PRG file IIRC) for reading.

When I tried around with files I had the same issue with blinking LED and couldn't figure out what was happening. The documentation isn't very clear about this.

For more info about this, I suggest reading https://en.m.wikipedia.org/wiki/Commodore_DOS

VincentF
Posts: 75
Joined: Mon Jun 29, 2020 8:22 pm

Devlog: Vixx (bullet hell game)

Post by VincentF »



30 minutes ago, kliepatsch said:




You need to add ",s,r" or so to the file name to communicate to the disk driver that you are opening a sequential file (basically every file that isn't a BASIC or .PRG file IIRC) for reading.



I know this already ^^ here's the filenames I use (when writing I do a len+2 to include the overwrite element) :

file_hiscore_len = 11

file_hiscore_w !pet "@:bhellsc,s,w"

file_hiscore_r !pet "bhellsc,s,r"

By the way, thank you for the link ?


12 hours ago, Stefan said:




OK. Please let us know if it solves your problem. Interesting issue after all.



Okay so I got some updates on why the sdcard get corrupted. It seems that a software on my computer had locked the file for reading and I suspect that was causing the issue (so this joins the problem when the sdcard is mounted on the local filesystem).

However, this does not prevent the sdcard activity light from blinking continuously only when we attempt to load a non-existing file. I need to investigate this further.

Stefan
Posts: 465
Joined: Thu Aug 20, 2020 8:59 am

Devlog: Vixx (bullet hell game)

Post by Stefan »


The blinking pixels at top right corner goes away after you read the disk status.

In assembly, you need to open yet another file for reading with secondary address 15 (=command channel) to do this.

Greg King
Posts: 162
Joined: Wed Jul 08, 2020 1:14 pm

Devlog: Vixx (bullet hell game)

Post by Greg King »


There are two bugs in your code:


  • It must call CLRCHN before calling CLOSE.


  • If the file doesn't exist, then a time-out status bit, not the end-of-file bit, is set.


VincentF
Posts: 75
Joined: Mon Jun 29, 2020 8:22 pm

Devlog: Vixx (bullet hell game)

Post by VincentF »


Thanks for the information ? I'll fix all of this asap


3 hours ago, Greg King said:




It must call CLRCHN before calling CLOSE.



I had previously switched CLRCHN and CLOSE but when trying to debug the file corruption + led activity light I noticed it was this way on x16-edit :

753575085_Screenshot_2021-02-02stefan-b-jakobssonx16-edit.png.3658f3fae899238a8fc003e6c450faf8.png


3 hours ago, Greg King said:




If the file doesn't exist, then a time-out status bit, not the end-of-file bit, is set.



Strangely, when opening the non existent file, here's what I got after OPEN and after READST :

  before_readst.png.bf9d60b0ab4b7bd97153134f49b95d3f.png  after_readst.png.11b37601bb5e50b3585970247cd5e44a.png

According to the documentation, READST should set bit 1 of the accumulator (so value = $02) but on my debugger it's just sending $00.

? If you got an idea of what I should look at... I'm checking for an EOF because that was how it was done on x16-edit (link) and it does work as intended.

The only remaining thing is to stop the SD card activity led from blinking.


On 1/31/2021 at 12:29 PM, Stefan said:




In assembly, you need to open yet another file for reading with secondary address 15 (=command channel) to do this.



I quickly tried to do that :

open15.png.afe7f72f22a6a154e89820f6ee8a15b9.png

(didn't set the name since it was done earlier)

But the blinking is still here ?

One thing I'll do is create a blank file, it should fix this issue once and for all.

Thank you for helping me figure this out ! ? It's really appreciated !

EDIT:  creating the file effectively fixed the blinking issue ^^

Greg King
Posts: 162
Joined: Wed Jul 08, 2020 1:14 pm

Devlog: Vixx (bullet hell game)

Post by Greg King »



5 hours ago, VincentF said:




The only remaining thing is to stop the SD card activity led from blinking.

I quickly tried to do that :

open15.png.afe7f72f22a6a154e89820f6ee8a15b9.png



(didn't set the name since it was done earlier)

But the blinking is still here ?



To what was the name set earlier?  You must call SETNAM with the accumulator set to zero (the other two registers don't matter when the "name" has zero length)!  Otherwise, the "name" string is sent as a DOS command (which might cause a syntax error).  Also, you actually must read the status message, in order to cancel the error.

VincentF
Posts: 75
Joined: Mon Jun 29, 2020 8:22 pm

Devlog: Vixx (bullet hell game)

Post by VincentF »



31 minutes ago, Greg King said:




To what was the name set earlier?



The file is  "bhellsc,s,r", and I called SETNAM with the accumulator set at value #11 (the length of the string)

Reading the documentation, I think I understand why I need to call with accumulator set at #0, that's because we don't want any file.

I find the OPEN command (and others file management commands) quite obscure because wherever I try to search information for it there is always some missing info. (for example secondary addresses)

Stefan
Posts: 465
Joined: Thu Aug 20, 2020 8:59 am

Devlog: Vixx (bullet hell game)

Post by Stefan »


Hi,

The read loop in my program stops if READST returns anything else than 0.

I have tested what return value you get from READST on file not found. And it is $42. That is $2 (time out read) + $40 (end of identity, sort of end of file). As your code tests for $40 that doesn't seem to explain your problem.

To read the disk status, you need to open the command channel with a zero length file name. Otherwise you are effectively sending the file name to the drive which will try to interpret it as a DOS command. In most cases this will cause a syntax error, and the blinking continues.

To see what I mean, try entering DOS "<anyfilename>" at the BASIC prompt. The blinking light turns on. Then read the status by entering just "DOS". You can see that the last error was syntax error.

I haven't tested it, but you might actually also need to read the byte stream from the command channel before closing it in order to make the blinking light go away. Only by reading the stream, you get to know what disk error occurred, if that's of any interest to you.

Finally, Greg and I discussed the order in which you should call CLOSE and CLRCHN some time ago. It's common to find C64 code examples online that first calls CLOSE and then CLRCHN. When testing this thourougly, I found that it doesn't matter in which order you call these functions. Having used X16 Edit for several months now, I have not had any file related problems with calling CLOSE first and CLRCHN second. I think you may rule out that this has anything to do with your problem.

Post Reply