Login
Back to forumReply to this topicGo to last reply

Posted By

Harry Potter
on 2023-07-20
18:35:04
 MemBankP4/cc65: program doesn't load data to Hannes memory!

Hi! I've been working on a 128k Plus4 port of my AdvSkel65 program, and it doesn't seem to be successfully loading its Hannes memory data properly, as, when I use the bank1_memcpyfrom() function to copy the contents of the first 80 bytes of Hannes memory to the screen at 0xC00, I get all at signs, meaning all 0's, in turn meaning the data was not there at all. sad Following are the assembler code for the routines that write to the memory:
----------------------------
.segment "LOWCODE"

_bank1_writebyte:
;jsr popa
pha
jsr popax
sta ptr1
stx ptr1+1
pla
ldy #0
jmp bank1_writebytedirect

_bank1_writeword:
;jsr popax
pha
stx tmp1
jsr popax
sta ptr1
stx ptr1+1
pla
ldx tmp1
ldy #0
jmp bank1_writeworddirect



.segment "MEMBANK"

bank1_writebytedirect:
;sta $FF02
sei
pha
lda #$32
sta $FD16
pla
sta (ptr1),y
lda #$33
sta $FD16
cli
rts

bank1_writeworddirect:
pha
sei
lda #$32
sta $FD16
pla
;sta $FF02
sta (ptr1),y
iny
txa
sta (ptr1),y
lda #$33
sta $FD16
cli
rts
--------------------------------
and the code that reads the file:
--------------------------------
unsigned __fastcall__ bank1_cbm_read (unsigned char lfn, void* buffer, unsigned size)
/* Reads up to "size" bytes from a file to "buffer".
* Returns the number of actually read bytes, 0 if there are no bytes left
* (EOF) or -1 in case of an error. _oserror contains an errorcode then (see
* table below).
*/
{
static unsigned int bytesread;
static unsigned char tmp;

/* if we can't change to the inputchannel #lfn then return an error */
if (_oserror = cbm_k_chkin(lfn)) return -1;

bytesread = 0;
printc ('A');
while (bytesread<size && !cbm_k_readst()) {
tmp = cbm_k_basin();
/* the kernal routine BASIN sets ST to EOF if the end of file
* is reached the first time, then we have store tmp.
* every subsequent call returns EOF and READ ERROR in ST, then
* we have to exit the loop here immidiatly. */
if (cbm_k_readst() & 0xBF) break;
//++*(unsigned char*)0xC00;
//((unsigned char*)buffer)[bytesread++] = tmp;
//bank1_writebyte (((unsigned char*)buffer)[bytesread++], tmp);
bank1_writebyte (((unsigned char*)&buffer)[bytesread], tmp);
++bytesread;
//home(); printu (bytesread);
}
cbm_k_clrch();
//putchar ('-'); cgetc();
printc ('B');
return bytesread;
}
--------------------------------
BTW, B doesn't display, but some code that printed a dot to the screen at every byte read displayed many dots, indicating that the function is actually reading the information.

Posted By

Lord Voldemort
on 2023-07-22
04:13:11
 Re: MemBankP4/cc65: program doesn't load data to Hannes memory!

Don't you turn your back on me, Harry Potter!



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024