コード例 #1
0
ファイル: hello.c プロジェクト: cc65/cc65
int main (void)
{
    unsigned char XSize, YSize;

    /* Set screen colors */
    (void) textcolor (COLOR_WHITE);
    (void) bordercolor (COLOR_BLACK);
    (void) bgcolor (COLOR_BLACK);

    /* Clear the screen, put cursor in upper left corner */
    clrscr ();

    /* Ask for the screen size */
    screensize (&XSize, &YSize);

    /* Draw a border around the screen */

    /* Top line */
    cputc (CH_ULCORNER);
    chline (XSize - 2);
    cputc (CH_URCORNER);

    /* Vertical line, left side */
    cvlinexy (0, 1, YSize - 2);

    /* Bottom line */
    cputc (CH_LLCORNER);
    chline (XSize - 2);
    cputc (CH_LRCORNER);

    /* Vertical line, right side */
    cvlinexy (XSize - 1, 1, YSize - 2);

    /* Write the greeting in the mid of the screen */
    gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
    cprintf ("%s", Text);

#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)

    /* Wait for the user to press a button */
    joy_install (joy_static_stddrv);
    while (!joy_read (JOY_1)) ;
    joy_uninstall ();

#else

    /* Wait for the user to press a key */
    cgetc ();

#endif

    /* Clear the screen again */
    clrscr ();

    /* Done */
    return EXIT_SUCCESS;
}
コード例 #2
0
ファイル: joy-test.c プロジェクト: Aliandrana/snesdev
int main (void)
{
    unsigned char j;
    unsigned char count;
    unsigned char i;

#ifdef __NES__
    extern void *co65_joy;
    unsigned char Res = joy_install (&co65_joy);
#else
    unsigned char Res = joy_load_driver (joy_stddrv);
#endif
    if (Res != JOY_ERR_OK) {
       	cprintf ("Error in joy_load_driver: %u\r\n", Res);
        cprintf ("os: %u, %s\r\n", _oserror, _stroserror (_oserror));
       	exit (EXIT_FAILURE);
    }

    clrscr ();
    count = joy_count ();
    cprintf ("Driver supports %d joystick(s)", count);
    while (1) {
	for (i = 0; i < count; ++i) {
	    gotoxy (0, i+1);
	    j = joy_read (i);
	    cprintf ("%2d: %-6s%-6s%-6s%-6s%-6s%-6s",
		     i,
       	       	     (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 " : " ---- ");
	}
    }
    return 0;
}