I''ve been working on a cartridge library for the C64 and have been creating a demo for the Magic Desk cartridge format.� Most of it seems to work, even the banking strategy.� However, I'm having a problem: certain library functions aren't functioning properly.� cputsxy() displays garbage.� As the text starts in the proper location, it seems to me that either cputchar() or cputs() is at fault.� The _randomize() and rand() functions produce results that are too regular for my purpose.� I copy the LOWCODE, CODE, DATA, RODATA and bank access code to RAM upon startup, so unavailability of these functions shouldn't be a problem.� Some code snippets follow: -------------------------- void __fastcall__ bankrun (unsigned char codeid); --------------------------_bankrun: �;cmp�#-1 �;bne�*+5 �;jmp�_exit �asl �asl �tax �lda�_codetable,x �sta�ptr1 �lda�_codetable+1,x �sta�ptr1+1 �lda�_codetable+2,x �sta�$DE00 �lda�#$00 �sta�sp �lda�#$D0 �sta�sp+1 �ldx�#$00 �txs �jmp�(ptr1) -------------------------- magiccart.h -------------------------- //Main routine table.� Define in your code as the locations of your main //parts, where each entry determines a module in your program. //Put in RODATA segment. extern const struct codetable { �void*��calladdr;�//Address of routine in cartridge bank. �unsigned char�bank, ��//Bank containing routine. ���x;��//Padding--no meaning. } codetable []; //Transfer control to a different module in your code. void __fastcall__ bankrun (char p);�//p is the ID of the module, as in the codetable �����//subscript. -------------------------- main.c -------------------------- #define numparts 2 #pragma codeseg��("CODE2") #pragma rodataseg�("RODATA2") static const unsigned char partid[]={1,2}; void main() { �unsigned char c; �bgcolor (1); bordercolor (4); //textcolor (5); �//clrscr(); �puts�("\f\x93\x12\x89 Screen Demo of MagicDesk cartridge fmt.\x92" ��"�� by \x9aJoseph Rose\x99, a.k.a. \x96\x12Harry Potter\x99\n" ��"----------------------------------------\x90" ��"Choose your demo:\n\n" ��"1.� Ink Blot\n" ��"2.� \x1C""C\x81o\x9El\x1Eo\x1Fr\x90 Ink Blot\n" ��); �while (1) { ��c=cgetc()-'1'; ��if (c<numparts) bankrun (partid[c]); �} } #pragma rodataseg�("RODATA") const struct codetable codetable [] = { �{&main,��1}, �{&blot,��2}, �{&colorblot,�2} }; #pragma rodataseg�("RODATA2") -------------------------- blot.c -------------------------- #pragma codeseg��("CODE3") #pragma rodataseg�("RODATA3") ... void blot () { �static unsigned i; �_randomize (); �bordercolor (3); bgcolor(1); textcolor (0); �clrscr (); �for (i=0; i<20*40; ++i) {revers (rand()&1); cputc(' ');} �revers(0); �cputcxy (0,24,"Press any key to continue..."); �while (!kbhit()); �cgetc(); �bankrun (0); } -------------------------- I compiled the program with cl65, and the above is the problem.� When I did it the long way, (i.e. cc65/ca65/ld65) the screen flashed then displayed the C64's blue screen without the text.� If it helps, I didn't implement the IRQ stub. -------------------------- Joseph Rose, a.k.a. Harry Potter Working magic in the computer community ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Thu Mar 22 18:10:32 2012
This archive was generated by hypermail 2.1.8 : 2012-03-22 18:10:36 CET