Skip to content

Instantly share code, notes, and snippets.

@aal89

aal89/hello.c

Created Nov 20, 2019
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@aal89 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
You can’t perform that action at this time.