Pls ignore, we fixed it together on the call :-). Macptr is working fine! The issue was that when the ptr gets to C000, it needs to be wrapped around to A000 when the bank changes after sequent load calls :-).
/**
* @brief Load a file to ram or (banked ram located between address 0xA000 and 0xBFFF), incrementing the banks.
* This function uses the new CX16 macptr kernal API at address $FF44.
*
* @param channel Input channel.
* @param device Input device.
* @param secondary Secondary channel.
* @param filename Name of the file to be loaded.
* @param bank The bank in banked ram to where the data of the file needs to be loaded.
* @param sptr The pointer between 0xA000 and 0xBFFF in banked ram.
* @return char status
* - not 0: Something is wrong! Kernal Error Code (https://commodore.ca/manuals/pdfs/commodore_error_messages.pdf)
* - 0: OK!
*/
unsigned char file_load_size(char channel, char device, char secondary, bram_bank_t dbank, bram_ptr_t dptr, size_t size)
{
#ifdef __DEBUG_FILE
printf("load file, c=%u, d=%u, s=%u, b=%x, p=%p, si=%u", channel, device, secondary, dbank, dptr, size);
#endif
unsigned char status = 0;
unsigned int read = 0;
unsigned int remaining = size;
byte bank_old = bank_get_bram();
bank_set_bram(dbank);
status = cbm_k_chkin(channel);
status = cbm_k_readst();
#ifdef __DEBUG_FILE
printf(", chkin status=%u", status);
#endif
if(status) return 0;
char* ptr = dptr;
unsigned int bytes = 0;
do {
if(!size) {
#ifdef __DEBUG_FILE
printf(", reading max ptr=%p", ptr);
#endif
bytes = cbm_k_macptr(0, ptr);
} else {
if(remaining >= 128) {
#ifdef __DEBUG_FILE
printf(", reading 128 ptr=%p", ptr);
#endif
bytes = cbm_k_macptr(128, ptr);
} else {
#ifdef __DEBUG_FILE
printf(", reading remaining=%u ptr=%p", remaining, ptr);
#endif
bytes = cbm_k_macptr(remaining, ptr);
}
}
status = cbm_k_readst();
#ifdef __DEBUG_FILE
printf(", macptr status=%u", status);
#endif
if(status & 0xBF) return 0;
if(bytes == 0xFFFF) {
printf("read error!!!");
cbm_k_chkin(0);
while(!getin());
cbm_k_chkin(channel);
break;
}
#ifdef __DEBUG_FILE
printf(", bytes=%u", bytes);
#endif
read += bytes;
ptr += bytes;
if(BYTE1(ptr) == 0xC0) ptr -= 0x2000;
remaining -= bytes;
#ifdef __DEBUG_FILE
printf(", size=%u, remaining=%u, read=%u", size, remaining, read);
#endif
} while ((status == 0) && ((size && remaining) || !size));
#ifdef __DEBUG_FILE
printf(", read bytes r=%u, status=%u\n", read, status);
#endif
bank_set_bram(bank_old);
cbm_k_chkin(0);
#ifdef __DEBUG_FILE
while(!getin());
#endif
return 0;
}