Created
November 20, 2019 21:37
-
-
Save aal89/bef40042d1272b3f26340883c0202080 to your computer and use it in GitHub Desktop.
CC65 hello world demo for NES with a fix (wa) for the open gap on the bottom line (taken from https://github.com/cc65/cc65/blob/master/samples/hello.c)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <string.h> | |
#include <conio.h> | |
#include <joystick.h> | |
#include <nes.h> | |
static const char text[] = "get on that nesdev"; | |
int main(void) | |
{ | |
unsigned char xsize, ysize; | |
/* Clear the screen, put cursor in upper left corner */ | |
clrscr(); | |
(void) textcolor(COLOR_WHITE); | |
(void) bordercolor(COLOR_BLACK); | |
(void) bgcolor(COLOR_BLACK); | |
/* Ask for the screen size */ | |
screensize(&xsize, &ysize); | |
/* Draw a border around the screen */ | |
// gotoxy(0, 0); | |
/* Top line */ | |
cputc(CH_ULCORNER); | |
chline(xsize - 2); | |
cputc(CH_URCORNER); | |
// /* Vertical line, left side */ | |
cvline(ysize - 1); | |
// /* Bottom line */ | |
cputc(CH_LLCORNER); | |
chline(xsize - 2); | |
cputc(CH_LRCORNER); | |
// /* Vertical line, right side */ | |
cvlinexy(xsize - 1, 1, ysize - 1); | |
// /* Write the greeting in the mid of the screen */ | |
gotoxy((xsize - strlen(text)) / 2, ysize / 2); | |
cprintf("%s", text); | |
// a workaround for the bug where a hline piece is missing in the bottom line | |
cputs(" "); | |
/* Wait for the user to press a button */ | |
joy_install (joy_static_stddrv); | |
while (!joy_read (JOY_1)) ; | |
joy_uninstall (); | |
/* Clear the screen again */ | |
clrscr(); | |
/* Done */ | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: