--- /dev/null
+/*\r
+ * cputc.c\r
+ *\r
+ * void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);\r
+ * void __fastcall__ cputc (char c);\r
+ */\r
+\r
+#include <conio.h>\r
+\r
+/* Implements a 25 by 25 screen in the 1024 bytes video ram (32 by 32) */\r
+#define LINEWIDTH 0x20\r
+#define SCREENBASE ((char *) 0xd000)\r
+#define TOP_OFFSET 4\r
+#define LEFT_OFFSET 3\r
+#define SCREENVISBASE (SCREENBASE + 4 * LINEWIDTH + LEFT_OFFSET)\r
+#define WIDTH 25\r
+#define HEIGHT 25\r
+\r
+static unsigned char xpos = 0;\r
+static unsigned char ypos = 0;\r
+\r
+void __fastcall__ cputc(char c)\r
+{\r
+ char * const cp = SCREENVISBASE + ypos * LINEWIDTH + xpos;\r
+\r
+ *cp = c;\r
+\r
+ xpos += 1;\r
+ if (xpos > WIDTH - 1) {\r
+ xpos = 0;\r
+ ypos += 1;\r
+\r
+ if (ypos > HEIGHT - 1) {\r
+ ypos = 0;\r
+ }\r
+ }\r
+}\r
+\r
+void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c)\r
+{\r
+ xpos = x > WIDTH - 1 ? WIDTH - 1 : x;\r
+ ypos = y > HEIGHT - 1 ? HEIGHT - 1 : y;\r
+\r
+ cputc(c);\r
+}\r
+\r
+unsigned char wherex (void)\r
+{\r
+ return xpos;\r
+}\r
+\r
+unsigned char wherey (void)\r
+{\r
+ return ypos;\r
+}\r
+\r
+void __fastcall__ gotox (unsigned char x)\r
+{\r
+ xpos = x;\r
+}\r
+\r
+void __fastcall__ gotoy (unsigned char y)\r
+{\r
+ ypos = y;\r
+}\r
+\r
+void __fastcall__ gotoxy (unsigned char x, unsigned char y)\r
+{\r
+ xpos = x;\r
+ ypos = y;\r
+}\r