2015-07-12 12:27:24 +00:00
|
|
|
#include <conio.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <joystick.h>
|
2015-07-14 15:22:47 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2015-07-12 12:27:24 +00:00
|
|
|
|
|
|
|
static int datavar = 10;
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2015-08-29 13:58:57 +00:00
|
|
|
int stackvar = 42;
|
|
|
|
int i, j;
|
|
|
|
clock_t clk;
|
|
|
|
char* p;
|
2015-11-02 22:04:46 +00:00
|
|
|
unsigned char xsize, ysize, n, nn;
|
2015-08-29 13:58:57 +00:00
|
|
|
|
|
|
|
joy_install(&joy_static_stddrv);
|
|
|
|
|
|
|
|
clrscr();
|
|
|
|
screensize(&xsize, &ysize);
|
|
|
|
|
|
|
|
cputs("hello world");
|
|
|
|
cputsxy(0, 2, "colors:" );
|
|
|
|
for (i = 0; i < 16; ++i) {
|
|
|
|
textcolor(i);
|
|
|
|
cputc('X');
|
2015-07-16 14:00:32 +00:00
|
|
|
}
|
2015-08-29 13:58:57 +00:00
|
|
|
textcolor(1);
|
|
|
|
|
|
|
|
gotoxy(0,4);
|
|
|
|
cprintf("datavar: %02x\n\r", datavar);
|
|
|
|
cprintf("stackvar: %02x\n\r", stackvar);
|
|
|
|
|
|
|
|
j = joy_count();
|
2015-09-04 12:14:17 +00:00
|
|
|
gotoxy(0,9);
|
2015-08-29 13:58:57 +00:00
|
|
|
cprintf("Found %d Joysticks.", j);
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i) {
|
2015-09-04 12:14:17 +00:00
|
|
|
gotoxy(0, 16 + i);
|
2015-08-29 13:58:57 +00:00
|
|
|
p = malloc(16);
|
2015-09-04 12:14:17 +00:00
|
|
|
memcpy(p, "0123456789abcdef", 16);
|
2015-11-02 22:04:46 +00:00
|
|
|
cprintf("alloc'ed at: %04p - %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", p,
|
2015-08-29 13:58:57 +00:00
|
|
|
p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],
|
|
|
|
p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]
|
|
|
|
);
|
2015-07-12 12:27:24 +00:00
|
|
|
}
|
2015-11-02 22:04:46 +00:00
|
|
|
memcpy(p, main, 0); /* test that a zero length doesn't copy 64K */
|
2015-07-16 14:00:32 +00:00
|
|
|
|
2015-08-29 13:58:57 +00:00
|
|
|
gotoxy(0,ysize - 1);
|
|
|
|
for (i = 0; i < xsize; ++i) {
|
|
|
|
cputc('0' + i % 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
gotoxy(0,ysize - 2 - ((256 + xsize) / xsize));
|
|
|
|
for (i = 0; i < xsize; ++i) {
|
|
|
|
cputc('0' + i % 10);
|
|
|
|
}
|
|
|
|
for (i = 0; i < (xsize * 5); ++i) {
|
|
|
|
cputc('#');
|
|
|
|
}
|
|
|
|
gotoxy(0,ysize - 1 - ((256 + xsize) / xsize));
|
|
|
|
for (i = 0; i < 256; ++i) {
|
|
|
|
if ((i != '\n') && (i != '\r')) {
|
|
|
|
cputc(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i = get_tv();
|
|
|
|
gotoxy(30,0);
|
|
|
|
cputs("TV Mode: ");
|
|
|
|
switch(i) {
|
|
|
|
case TV_NTSC:
|
|
|
|
cputs("NTSC");
|
|
|
|
break;
|
|
|
|
case TV_PAL:
|
|
|
|
cputs("PAL");
|
|
|
|
break;
|
|
|
|
case TV_OTHER:
|
|
|
|
cputs("OTHER");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cprintf(" %dx%d", xsize, ysize);
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
gotoxy(13,4);
|
|
|
|
cprintf("%02x", datavar);
|
|
|
|
gotoxy(13,5);
|
|
|
|
cprintf("%02x", stackvar);
|
|
|
|
++datavar; ++stackvar;
|
|
|
|
|
2015-09-04 12:14:17 +00:00
|
|
|
gotoxy(0,7);
|
2015-08-29 13:58:57 +00:00
|
|
|
clk = clock();
|
|
|
|
cprintf("clock: %08lx", clk);
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i) {
|
2015-09-04 12:14:17 +00:00
|
|
|
gotoxy(0, 11 + i);
|
2015-08-29 13:58:57 +00:00
|
|
|
j = joy_read (i);
|
|
|
|
cprintf ("pad %d: %02x %-6s%-6s%-6s%-6s%-6s%-6s%-6s%-6s",
|
|
|
|
i, j,
|
|
|
|
(j & joy_masks[JOY_UP])? " up " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_DOWN])? " down " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_LEFT])? " left " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_FIRE])? " fire " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ",
|
|
|
|
(j & joy_masks[JOY_SELECT])? "select" : " ---- ",
|
|
|
|
(j & joy_masks[JOY_RUN])? " run " : " ---- ");
|
|
|
|
}
|
|
|
|
|
|
|
|
gotoxy(xsize - 10, 3);
|
2015-11-02 22:04:46 +00:00
|
|
|
nn = (n >> 5) & 1;
|
|
|
|
revers(nn);
|
|
|
|
cputc(nn ? 'R' : ' ');
|
2015-08-29 13:58:57 +00:00
|
|
|
cputs(" revers");
|
|
|
|
revers(0);
|
|
|
|
|
2015-11-02 22:04:46 +00:00
|
|
|
if ((n & 0x1f) == 0x00) {
|
|
|
|
nn = p[15];
|
|
|
|
((char*)memmove(p + 1, p, 15))[-1] = nn;
|
|
|
|
gotoxy(22, 19);
|
|
|
|
cprintf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
|
|
|
|
p[0],p[1],p[ 2],p[ 3],p[ 4],p[ 5],p[ 6],p[ 7],
|
|
|
|
p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
|
|
|
|
}
|
|
|
|
|
2015-08-29 13:58:57 +00:00
|
|
|
waitvblank();
|
|
|
|
++n;
|
|
|
|
}
|
2015-07-13 10:10:09 +00:00
|
|
|
}
|