Posted By
Harry Potter on 2022-12-10 08:31:33
| Re: AdvSkel65/128k Plus4/cc65: Hannes memory not loaded properly
I fixed a bug in the code--I forgot what the bug was--and now, the room description prints properly, but the items in the room after the first print garbage. Also, the C64 versions currently don't work: they give me a blue screen with no text. Following are some code snippets that might be causing the problem:
------------------------------- .segment "MEMBANK"
_bank1_readbyte: ldy #0 bank1_readbyteoffs: sta ptr1 stx ptr1+1 bank1_readbyteoffs2: ;sta $FF02 sei lda #$32 sta $FD16 lda (ptr1),y ;sta $FF01 ldx #$33 stx $FD16 cli ldx #0 rts
.segment "LOWCODE"
_bank1_writebyte: ;jsr popa pha jsr popax sta ptr1 stx ptr1+1 pla ldy #0 jmp bank1_writebytedirect
.segment "MEMBANK"
bank1_writebytedirect: ;sta $FF02 sei pha lda #$32 sta $FD16 pla sta (ptr1),y lda #$33 sta $FD16 cli rts ------------------------- //Prints the name of the current item indicated by Itm1. static void __fastcall__ printitmname (void) { //printu (Itm1); printc (' '); #ifdef __USEFARMEM__ #ifdef __C128__ //bank1_print (bank1_readword((void*)&Item[Itm1].Name)); printtok (Item[Itm1].Name); #elif defined __C64__ printtok (hidereadw((void*)&Item[/*CurRoomInv<i>*/Itm1].Name)); #elif defined __PLUS4__ || defined __C128__ printtok (bank1_readword((void*)&Item[Itm1].Name)); #elif defined __ATARI__ || defined __APPLE2ENH__ printtok (aux_readword((void*)&Item[Itm1].Name)); #endif #else prints (Item[Itm1].Name); #endif }
//Verb to describe the current item or scene. void vLook (void)//char Itm1) { //static unsigned char i; static void (*func)(void); //If an item is specified: if (Itm1!=0xFF) { //If it is available in the player inventory, #ifdef __USEFARMEM__ if (SearchInvPlayer () || SearchInvRoom ()) { //get string address and print help text. if ((s=hidereadw((void*)&ItemPtr->Info))==0) { printscr ("No help available for that item."); return; } printtok (s); printcr (); #else if (SearchInvPlayer () || SearchInvRoom ()) { //get string address and print help text. if ((s=ItemPtr->Info)==0) { printscr ("No help available for that item."); return; } printscr (s); #endif } else { printnoitem (); } return; } //Otherwise, //get room information memcpy (0xC00, Player.RoomInv[CRoom], 8); getkey(); CurRoomInv=&Player.RoomInv[CRoom]; CRm=&Room[CRoom]; //print it, #ifdef __USEFARMEM__ printtok ((char*)hidereadw((void*)&CRm->Desc)); //printc ('a'); //call the room handler func=hidereadw((void*)&CRm->RoomHandler); //printc ('b'); #else printtok (CRm->Desc); //call the room handler func=(CRm->RoomHandler); #endif (*func) (); printcr(); //and list room items. for (i=0; i<8 && (Itm1=CurRoomInv<i>)!=0xFF;++i) { //printu (CurRoomInv+i); #ifdef __USEFARMEM__ prints ("There is a "); printitmname (); printscr (" here."); #else prints ("There is a "); printitmname (); printscr (" here."); #endif } //if (i) printcr(); }
|