conio_test.c (3111B)
1 /* 2 * Copyright 2021 Gerd Beuster (gerd@frombelow.net). This is free 3 * software under the GNU GPL v3 license or any later version. See 4 * COPYING in the root directory for details. 5 */ 6 7 #include <stdio.h> 8 #include <conio.h> 9 #include "../cc65_eris/os.h" 10 11 void print_stack_pointers(){ 12 unsigned cc65_sp, eris_sp; 13 unsigned char hw_sp; 14 get_stack_pointers(&hw_sp, &eris_sp, &cc65_sp); 15 cprintf("CC65 SP: %04X Eris SP: %04X HW SP: %02X\r\n", cc65_sp, eris_sp, hw_sp); 16 } 17 18 void main(void){ 19 unsigned i, j; 20 unsigned char c, x, y; 21 va_list a_list; 22 23 cgetc(); 24 clrscr(); 25 print_stack_pointers(); 26 cputs("Testing implementation of conio libray.\r\n"); 27 cputs("If you can read this, cputs works.\r\n"); 28 cprintf("If you can read this, cprintf %s.\r\n", "works"); 29 cputs("Press a key:"); 30 c = cgetc(); 31 clrscr(); 32 cputs("If this is the first line of an empty screen, clrscr works.\r\n"); 33 cprintf("If you pressed key \"%c\", cgetc works.\r\n", c); 34 cputs("Press a key."); 35 cgetc(); 36 clrscr(); 37 gotoxy(2, 1); 38 cputs("If this line starts at position (2,1), gotoxy works.\r\n"); 39 cputs("Press a key."); 40 cgetc(); 41 gotoxy(48, 1); 42 cclear(5); 43 gotoxy(0, 2); 44 cputs("If \"works\" above has been deleted, cclear works.\r\n"); 45 cputs("Press a key."); 46 cgetc(); 47 cclearxy(42, 2, 5); 48 gotoxy(0, 4); 49 cputs("If \"works\" above has been deleted, cclearxy works.\r\n"); 50 cputs("If this is a horizontal line of of length 3, chline works: "); 51 chline(3); 52 gotoxy(0, 6); 53 cputs("If this is a horizontal line of of length 3, chlinexy works: "); 54 gotoxy(0, 0); 55 chlinexy(61, 6, 3); 56 cputs("\r\ncputc : "); 57 cputc('O'); 58 cputc('K'); 59 cputsxy(0, 7, "cputcxy/cputsxy: "); 60 cputcxy(17, 7, 'O'); 61 cputcxy(18, 7, 'K'); 62 gotoxy(5,8); 63 cputs("This is a vertical line at x=5:\r\n"); 64 gotox(5); 65 cvline(5); 66 cputs("And here is a vertical line of length 3:\r\n"); 67 gotoy(14); 68 cvlinexy(5,15,3); 69 cputs("\r\nBusy waiting for pressing a key"); 70 i = 0; 71 while (!kbhit()) { 72 if((++i % 1000) == 0) { 73 cputc('.'); 74 } 75 } 76 c = cgetc(); 77 cprintf("\r\nYou pushed: \"%c\"\r\n", c); 78 cputs("Some text in "); 79 revers(1); 80 cputs("revers"); 81 revers(0); 82 cputs(".\r\n"); 83 screensize(&x, &y); 84 cprintf("The screensize is (%d, %d)\r\n", x, y); 85 cputs("Press a key."); 86 cgetc(); 87 for(i = 0; i < 0x100; i++) { 88 textcolor(i); 89 cprintf("Textcolor %d\r\n", i); 90 } 91 cputs("Press a key."); 92 cgetc(); 93 clrscr(); 94 gotoxy(2, 3); 95 x = wherex(); 96 y = wherey(); 97 cprintf("The current cursor position is (%d, %d)\r\n", x, y); 98 va_start(a_list, i); 99 vcprintf("vcprintf\r\n", a_list); 100 va_end(); 101 print_stack_pointers(); 102 cputs("*********************\r\n"); 103 cputs("conio test completed.\r\n"); 104 cputs("*********************\r\n"); 105 106 cputs("\r\n\r\nNow for something completely different.\r\n"); 107 cprintf("Here are the results of some calculations:\r\n"); 108 j = 3; 109 cprintf("%d * 10 = %d\r\n", j, 10*j); 110 i = 3; 111 ++i; 112 cprintf("%d / %d = %d\r\n", j*10, i, j*10/i); 113 i = 0; 114 cputs("\r\nSerial echo:\r\n"); 115 while(((c = cgetc()) != '\r') && (i++ <= 10)){ 116 cputc(c); 117 } 118 }