Problems with FFD5 CBM LOAD API in X16

Get technical support from the community & developers with specific X16 programs if you can't find the solution elsewhere
(for general non-support related chat about programs please comment directly under the program in the software library)
User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Problems with FFD5 CBM LOAD API in X16

Post by JimmyDansbo »


I only press F11.

Keep in mind that in my test code I do no setup what so ever, I just jump directly to calling FFD5 without caring what is in any registers. I could just as well just do a SYS $FFD5 from basic, but wrote a 1-line assembler program to be able to add the .byte $DB to start the debugger.

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

Problems with FFD5 CBM LOAD API in X16

Post by svenvandevelde »



2 minutes ago, JimmyDansbo said:




I only press F11.



Keep in mind that in my test code I do no setup what so ever, I just jump directly to calling FFD5 without caring what is in any registers. I could just as well just do a SYS $FFD5 from basic, but wrote a 1-line assembler program to be able to add the .byte $DB to start the debugger.



Can you try this with my program pls? You'll see immediately what it does. Using F11, it does not jump into 00:d949. It seems to go over it, and shows the next statement back at image.png.e7e081e104f8a23c202ac00f1ea3dc68.png

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
SlithyMatt
Posts: 913
Joined: Tue Apr 28, 2020 2:45 am

Problems with FFD5 CBM LOAD API in X16

Post by SlithyMatt »


When stepping through the Kernal, it is important to understand that the emulator doesn't work exactly the same as hardware. If you are using the host file system, LOAD and SAVE will use native file I/O on the host, so data just "magically" moves between the host file system and the emulator RAM. If you use an SD card image, you will be running the actual Kernal code to transfer data byte by byte through the CPU, rather than skipping over all that.

User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Problems with FFD5 CBM LOAD API in X16

Post by JimmyDansbo »



9 hours ago, svenvandevelde said:




Can you try this with my program pls?



I just testet with your program and saw the same behavior that you are describing. I then tested with one of my own programs (that work just fine) and saw exactly the same behavior as in your program.

I believe that Matt is correct and what we are seeing is the emulator going off and doing weird stuff because we are not loading from an SD card image.

Just to be on the safe side, I tried modifying my VTUI example program to load the binary into banked memory at bank 4 and that also seems to work just fine.

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

Problems with FFD5 CBM LOAD API in X16

Post by svenvandevelde »



6 hours ago, SlithyMatt said:




When stepping through the Kernal, it is important to understand that the emulator doesn't work exactly the same as hardware. If you are using the host file system, LOAD and SAVE will use native file I/O on the host, so data just "magically" moves between the host file system and the emulator RAM. If you use an SD card image, you will be running the actual Kernal code to transfer data byte by byte through the CPU, rather than skipping over all that.



After a good sleep (I'm in Europe), I've also made an annotated video, showing you exactly what I'm doing, and what the issue is ...

https://streamable.com/usd5wn

Would you have any further thoughts why this is happening?

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

Problems with FFD5 CBM LOAD API in X16

Post by svenvandevelde »



6 hours ago, SlithyMatt said:




When stepping through the Kernal, it is important to understand that the emulator doesn't work exactly the same as hardware. If you are using the host file system, LOAD and SAVE will use native file I/O on the host, so data just "magically" moves between the host file system and the emulator RAM. If you use an SD card image, you will be running the actual Kernal code to transfer data byte by byte through the CPU, rather than skipping over all that.



So in summary, it is impossible to show the code at 00:D949?

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Problems with FFD5 CBM LOAD API in X16

Post by JimmyDansbo »



13 minutes ago, svenvandevelde said:




So in summary, it is impossible to show the code at 00:D949?



No, you just need to move your program and TEXT file into an SD card image and use that instead of using the host filesystem.

However, if the LOAD function returns to your program with a file not found error, it is probably because the file is not found.

I don't know about CC65, but I know that ACME sometimes has some strange behavior in converting from ASCII to PETSCII. 

Try changing


Quote




char status = cx16_LoadFileBanked(8, "TEXT", loadtext);



to


Quote




char status = cx16_LoadFileBanked(8, "text", loadtext);



Assuming that "TEXT" is the actual filename your program is trying to load.

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

Problems with FFD5 CBM LOAD API in X16

Post by svenvandevelde »



Just now, JimmyDansbo said:




No, you just need to move your program and TEXT file into an SD card image and use that instead of using the host filesystem.



However, if the LOAD function returns to your program with a file not found error, it is probably because the file is not found.



I don't know about CC65, but I know that ACME sometimes has some strange behavior in converting from ASCII to PETSCII. 



Try changing



to



Assuming that "TEXT" is the actual filename your program is trying to load.



Just note that I have my code working ... Shall we get into the real problem what I'm having and maybe we can find out what the error is?

I'm able to load the graphics into my program correctly, but I have a strange error. "sometimes it loads, and sometimes not".

The random factor is the "order of the routines" and "what routines are not commented out". Trust me, looking for weeks on this, and till today, cannot find the issue!

What I'll do, if you're okay to help me searching for the real issue, is to post the programs that I have in this thread, together with all the files.

I'll make a version that loads the files correctly, and one that does not load any file.

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

Problems with FFD5 CBM LOAD API in X16

Post by svenvandevelde »


So, this is the working program ...

Just copy all these files to a single folder, and run the program ...

If you have all working, you should see the picture attached.

I've removed all breakpoints from the program. When a bitmap file is not found however, it will display an error on the screen.


    char status = LoadFileBanked(8FILE_SPRITES, (dword)BANK_PLAYER);



    if(status!=$ff) printf("status = %x\n",status);



    status = LoadFileBanked(8FILE_ENEMY2, (dword)BANK_ENEMY2);



    if(status!=$ff) printf("status = %x\n",status);



    status = LoadFileBanked(8"TILES", (dword)BANK_TILES_SMALL);



    if(status!=$ff) printf("status = %x\n",status);



    status = LoadFileBanked(8"SQUAREMETAL", (dword)BANK_SQUAREMETAL);



    if(status!=$ff) printf("status = %x\n",status);



    status = LoadFileBanked(8"TILEMETAL", (dword)BANK_TILEMETAL);



    if(status!=$ff) printf("status = %x\n",status);



    



    // Load the palette in main banked memory.



    status = LoadFileBanked(8"PALETTES", (dword)BANK_PALETTE);



    if(status!=$ff) printf("status = %u",status);


There should be no error ...


2021-02-07.png
ENEMY2
PALETTES
PLAYER
Space.asm
Space.c
space.ld
Space.prg
SQUAREMETAL
TILEMETAL
TILES
KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
JimmyDansbo
Posts: 476
Joined: Sun Apr 26, 2020 8:10 pm
Location: Denmark
Contact:

Problems with FFD5 CBM LOAD API in X16

Post by JimmyDansbo »



22 minutes ago, svenvandevelde said:




Just copy all these files to a single folder, and run the program ...



Ok, that seems to work just fine ?

 

Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Post Reply