Attachment | Size |
---|---|
printtok.c | 4.82 KB |
Hi! I'm working on a text adventure for cc65 called Adventures on Planet Smir 3, Episode 1. Right now, only Chapter 1 is mostly written. :( I have a C64 version and a Plus4 version online. If you want, I will give you an URL to them. Right now, I'm porting the code to the Apple2enh platform. Now, there are two nasty bugs with the display: the scoreboard is printing the wrong characters and flashing, and the printtok() routine I'm using to print compressed text is not expanding certain tokens properly. Printtok() accepts tokens as either one character from value #80-$9f and $E0-$FF or two characters starting with a '%.' For some reason, the latter is printed as literals. :( I attached the printtok.c module as used by the game and added the scoreboard-writing function below:
-------------------------
#ifdef __APPLE2ENH__void cleartop (void){gotoxy (0, 0); reverson(); for (i=39; i; --i) printc (32);}#elsevoid cleartop (void){home(); reverson(); for (i=39; i; --i) printc (32);}#endif
void DispScoreBoard (){/* Display status */#ifdef __APPLE2ENH__ c=wherey();#else c=taby;#endif //home(); //char s[70]; //gotoy(0); //revers(1); //reverson(); //hstrcpy (s, hidereadw((void*)&Room[CRoom].Name)); // printf ("\x13\x12Room: %-22.22Hs Score: %4d\x92\n", // //s,//Room[CRoom].Name, // hidereadw((void*)&Room[CRoom].Name), // Player.Score); //revers(0); //prints ("\x13Room: "); printtok (hidereadw((void*)&CRm->Name)); //DispScoreBoard2(); //cleartop();#if defined __PLUS4__// || defined __APPLE2ENH__ cleartop();#elif !defined __APPLE2ENH__ __asm__ ( "\tjsr\t_home\n" "\tjsr\t_reverson\n" "\tlda\t#32\n" "\tldy\t#39\n" //"\tsty\ttmp4\n" "@a00:\n" "\tjsr\t$FFD2\n" "\tdey\n" "\tbne\t@a00\n" );#endif#ifdef __APPLE2ENH__ //gotoxy (0, 0); ; reverson(); prints ("Room: "); printtok (CRm->Name); //Get row #. c=wherey(); //Home the cursor and turn reverse mode on. //home2(); gotoxy (0, 0); reverson (); //Clear score board. for (i=79; i; --i) printc (32); //Return to left of score board. //For some reason, when I issue "tabx=0;" or "gotox(0);" //here, the cursor doesn't move all the way to the left. //Even "tabx=1; --tabx;" doesn't work. I don't know why //this is, so I had to do a workaround. printcr(); gotoy (0); //Print score board.#ifdef __USEFARMEM__ prints ("Room: "); printh (hidereadw((void*)&CRm->Name)); tabx=69; prints ("Score "); printu (PlayerScore); //printcr ();#else prints ("Room: "); prints (CRm->Name); tabx=69; prints ("Score "); printu (PlayerScore); //printcr ();#endif //Clear reverse mode and return to orig. row. reversoff(); printcr (); gotoy (c);#elif defined __NOHIDE__ prints ("\x13Room: "); printtok (CRm->Name);#else prints ("\x13Room: "); printtokptr (&CRm->Name);#endif// getkey(); tabx=29; prints ("Score "); printu (PlayerScore); printcr ();#ifdef __APPLE2ENH__ reversoff(); printcr (); gotoy (c);#else goline(c);#endif /*cputc (13);*/}
Well...I found the bug with not expanding the tokens right: I was using printscr() instead of printtok() when printing common messages. I'm going to look in A2SimpleIO's code about the erroneous revderse error. I think it's with the printcr() function, as revers(1) produces the same problem as reverson().
I cleaned up the scoreboard code, and now it looks better but still has the blinking text bug. I saw some bugs in A2SimpleIO and tried to fix them, but it didn't help. :( I attached the code for reverson/off() and printc(). printc() is like putchar() but does virtually no extra processing and calls the ROM's COUT routine directly. Is my code correct?
---------------------------
printc.s
-------------------------------
.export _printc;, _printcr.import COUT
.include "apple2.inc"
.segment "LOWCODE"
;Address of kernal output routine for direct calls. The character is;already in .A._printc:;=COUT ;pha
;Quick reverse on/off selection. Uses the same technique as the normal;revers() function but more efficiently and without the fat..export _reverson, _reversoff, _flash
.include "apple2.inc"
_reverson: lda #$7F bne *+8_reversoff: lda #$FF bne *+4_flash: lda #$3F sta INVFLG rts
;lda #$FF ;sta $32 ;plaBIT $C082 ora #$80 and INVFLG jsr COUT bit $C080 rts
;The following routine has been moved to printscr.s to save three bytes.;Print return.;_printcr:; lda #13; jmp _printc-------------------------------
revers2.s
----------------------------------
BTW, sorry about not using attachments: I don't see an option to when replying. :(
I tried changing the #$7F in my reverson() function to #$3F, and now the text stopped blinking, but I'm still getting the wrong characters. Maybe I'm doing it wrong: how do I print reverse characters on an Apple2enh in assembler? I'm using some assembler with my A2SimpleIO library and text adventure for efficiency.
I just found the bug, and it's not my fault: inverse mode only works in 80-column mode. This text adventure, although it doesn't contain large strings, is better in 80-column mode, anyway.