Page 3 of 4

Problems with FFD5 CBM LOAD API in X16

Posted: Sat Feb 06, 2021 9:24 pm
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.


Problems with FFD5 CBM LOAD API in X16

Posted: Sat Feb 06, 2021 9:28 pm
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


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 12:35 am
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.


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 6:57 am
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.


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 7:13 am
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?


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 7:20 am
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?


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 7:38 am
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.


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 7:42 am
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.


Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 8:05 am
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

Problems with FFD5 CBM LOAD API in X16

Posted: Sun Feb 07, 2021 8:28 am
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 ?