1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-26 13:18:31 +00:00

Created a target and a library for the Commander X16 prototype computer.

This commit is contained in:
Greg King
2019-09-27 03:38:51 -04:00
parent 0896deedef
commit 18afc7c703
49 changed files with 2440 additions and 59 deletions
+52 -34
View File
@@ -1,4 +1,3 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -14,16 +13,15 @@
# define DYN_DRV 0
/*
** link existing drivers like this:
** Link existing drivers this way:
**
** cl65 -DJOYSTICK_DRIVER=c64_hitjoy_joy -o joy-test.prg joy-test.c
**
** for testing a new driver you will have to uncomment the define below, and
** link your driver like this:
** For testing a new driver, you need to uncomment the declaration below,
** and link your driver this way:
**
** co65 ../../target/c64/drv/joy/c64-hitjoy.joy -o hitjoy.s --code-label _hitjoy
** cl65 -DJOYSTICK_DRIVER=hitjoy -o joy-test.prg joy-test.c hitjoy.s
**
*/
/* extern char JOYSTICK_DRIVER; */
@@ -40,10 +38,8 @@
int main (void)
{
unsigned char j;
unsigned char count;
unsigned char i;
unsigned char i, count;
unsigned char Res;
unsigned char ch, kb;
clrscr ();
@@ -58,47 +54,69 @@ int main (void)
if (Res != JOY_ERR_OK) {
cprintf ("Error in joy_load_driver: %u\r\n", Res);
#if DYN_DRV
cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
cprintf ("OS: %u, %s\r\n", _oserror, _stroserror (_oserror));
#endif
exit (EXIT_FAILURE);
return EXIT_FAILURE;
}
count = joy_count ();
#if defined(__ATARI5200__) || defined(__CREATIVISION__)
cprintf ("JOYSTICKS: %d", count);
cprintf ("JOYSTICKS: %u.", count);
#else
cprintf ("Driver supports %d joystick(s)", count);
cprintf ("Driver supports %u joystick%s", count, count == 1 ? "." : "s.");
#endif
while (1) {
for (i = 0; i < count; ++i) {
gotoxy (0, i+1);
j = joy_read (i);
#if defined(__ATARI5200__) || defined(__CREATIVISION__)
cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s %02x",
#if defined(__NES__) || defined(__CX16__)
/* two lines for each device */
gotoxy (0, i * 2 +1);
cprintf ("%2u:%-6s%-6s%-6s%-6s\r\n"
" %-6s%-6s%-6s%-6s $%02X",
i,
JOY_UP(j)? " U " : " - ",
JOY_DOWN(j)? " D " : " - ",
JOY_LEFT(j)? " L " : " - ",
JOY_RIGHT(j)? " R " : " - ",
JOY_BTN_1(j)? " 1 " : " - ", j);
JOY_UP(j) ? " up " : " ---- ",
JOY_DOWN(j) ? " down " : " ---- ",
JOY_LEFT(j) ? " left " : " ---- ",
JOY_RIGHT(j) ? " right" : " ---- ",
JOY_BTN_1(j) ? "btn A " : " ---- ",
JOY_BTN_2(j) ? "btn B " : " ---- ",
JOY_BTN_3(j) ? "select" : " ---- ",
JOY_BTN_4(j) ? " start" : " ---- ",
j);
#else
cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s %02x",
/* one line for each device */
gotoxy (0, i + 1);
# if defined(__ATARI5200__) || defined(__CREATIVISION__)
cprintf ("%1u:%-3s%-3s%-3s%-3s%-3s %02X",
i,
JOY_UP(j)? " up " : " ---- ",
JOY_DOWN(j)? " down " : " ---- ",
JOY_LEFT(j)? " left " : " ---- ",
JOY_RIGHT(j)? "right " : " ---- ",
JOY_BTN_1(j)? "button" : " ---- ", j);
JOY_UP(j) ? " U " : " - ",
JOY_DOWN(j) ? " D " : " - ",
JOY_LEFT(j) ? " L " : " - ",
JOY_RIGHT(j) ? " R " : " - ",
JOY_BTN_1(j) ? " 1 " : " - ",
j);
# else
cprintf ("%2u: %-6s%-6s%-6s%-6s%-6s $%02X",
i,
JOY_UP(j) ? " up " : " ---- ",
JOY_DOWN(j) ? " down " : " ---- ",
JOY_LEFT(j) ? " left " : " ---- ",
JOY_RIGHT(j) ? "right " : " ---- ",
JOY_BTN_1(j) ? "button" : " ---- ",
j);
# endif
#endif
}
/* show pressed key, so we can verify keyboard is working */
kb = kbhit ();
ch = kb ? cgetc () : ' ';
gotoxy (1, i+2);
revers (kb);
cprintf ("kbd: %c", ch);
revers (0);
/* Show any pressed keys; so that we can verify that the keyboard is working. */
if (kbhit ()) {
#if defined(__NES__) || defined(__CX16__)
gotoxy (1, i * 2 + 2);
#else
gotoxy (1, i + 2);
#endif
cprintf ("keyboard: $%02X", cgetc ());
}
}
return 0;
return EXIT_SUCCESS;
}