Skip to content

Instantly share code, notes, and snippets.

@aal89
Created November 20, 2019 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aal89/bef40042d1272b3f26340883c0202080 to your computer and use it in GitHub Desktop.
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)
#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;
}
@aal89
Copy link
Author

aal89 commented Nov 20, 2019

Output:
Screenshot 2019-11-20 at 22 47 55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment