Login
Back to forumReply to this topicGo to last reply

Posted By

Harry Potter
on 2022-06-09
14:31:49
 MemBankP1 demo program error

Hi! I am working on a demo program for my MemBankP4 library, a cc65 library and configuration to use some of the Hannes memory expansion. Right now, it only adds 59k. The demo program is a version of MadLibP4. The program seems to load and display the first screen properly, but, when it requests user input, the screen reprints itself several times, then the emulated computer crashes. Following is the function to print a character to the screen:

--------------------
_printscr:
jsr _prints
_printcr:
lda #13
;jmp _printc
_printc:
;sta tmp4
;lda #$D2
;jmp callkernal
sta ENABLE_ROM
jsr $FFD2
sta ENABLE_RAM
rts
-----------------
and the routine to get a key press:
-----------------
.proc _getkey
sta ENABLE_ROM
@lp:
jsr $ffe4 ;Call the getin kernal routine to
;lda #$E4
;jsr callkernal
;get the key-press.
cmp #0 ;Continue until key pressed.
beq @lp
ldx #0 ;Clear MSB because I keep seeing
;this done in cc65's source code.
sta ENABLE_RAM
rts ;Return.
.endproc
-------------------------


Posted By

SVS
on 2022-06-10
14:03:10
 Re: MemBankP1 demo program error

I would try to do the getkey procedure, under a not interruptable time: That is SEI ... CLI.

Posted By

Harry Potter
on 2022-06-11
09:42:17
 Re: MemBankP1 demo program error

Okay. I'll try that soon. happy

Posted By

Harry Potter
on 2022-06-11
18:21:27
 Re: MemBankP1 demo program error

It didn't work. sad

Posted By

Harry Potter
on 2022-06-11
18:24:17
 Re: MemBankP1 demo program error

I just tried using cgetc(). It didn't work, either.

Posted By

Harry Potter
on 2022-06-16
10:00:55
 Re: MemBankP1 demo program error

Could it be writing to the wrong RAM location? Following are the code to write to expansion RAM:

------------------------------
_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
jmp bank1_writeworddirect



.segment "MEMBANK"

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

bank1_writeworddirect:
pha
lda #$32
sta $FD16
pla
sta $FF02
sta (ptr1),y
iny
txa
sta (ptr1),y
lda #$33
sta $FD16
rts
------------------
and to load the banked data:
------------------
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;
while (bytesread 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();
return bytesread;
}
--------------


Posted By

Harry Potter
on 2022-07-09
14:56:19
 Re: MemBankP1 demo program error

I narrowed the bug down to between the call to $FFE4 and the RTS instruction in the getkey() function. I don't think I made any changes to the function code since the last post here. Also, cgetc() seems to exit with erroneous data when I don't press a key then crashes the system. sad I'm using WinVice xplus4 v. 3.0 and have the memory hack function set to Hannes 256k.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024