Patch from Greg
git-svn-id: svn://svn.cc65.org/cc65/trunk@2191 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -2,14 +2,17 @@
|
|||||||
**
|
**
|
||||||
** Shows the ASCII (or ATASCII, PETSCII) codes of typed characters.
|
** Shows the ASCII (or ATASCII, PETSCII) codes of typed characters.
|
||||||
**
|
**
|
||||||
** 2002-12-25, Greg King <gngking@erols.com>
|
** 2003-03-09, Greg King <gngking@erols.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Define CONIO when you want to use the conio functions.
|
/* Define USE_STDIO, when you want to use the stdio functions.
|
||||||
** Undefine it when you want to use the stdio functions.
|
** Do not define it, when you want to use the conio functions.
|
||||||
** NOTE: Undefining CONIO will currently not work on the CBMs!!!
|
** NOTE: stdin on some targets is line-bufferred. You might need to type
|
||||||
|
** a key, then tap the return(enter)-key, in order to see each code.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
#define USE_STDIO
|
||||||
*/
|
*/
|
||||||
#define CONIO
|
|
||||||
|
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -18,10 +21,13 @@
|
|||||||
|
|
||||||
#define QUIT 'Q'
|
#define QUIT 'Q'
|
||||||
|
|
||||||
|
/* r -- row. t -- table-column.
|
||||||
|
*/
|
||||||
static unsigned char height, width, r, t;
|
static unsigned char height, width, r, t;
|
||||||
static int c;
|
static int c;
|
||||||
|
|
||||||
#ifdef CONIO
|
#ifndef USE_STDIO
|
||||||
|
|
||||||
# define PRINT cprintf
|
# define PRINT cprintf
|
||||||
# define PUT(c) cputc((char)(c))
|
# define PUT(c) cputc((char)(c))
|
||||||
|
|
||||||
@@ -32,19 +38,22 @@ static int GET(void) {
|
|||||||
PUT(c = (int)cgetc());
|
PUT(c = (int)cgetc());
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define PRINT printf
|
# define PRINT printf
|
||||||
# define GET getchar
|
# define GET getchar
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
|
||||||
# ifdef CONIO
|
# ifndef USE_STDIO
|
||||||
/* conio doesn't scroll! Avoid trouble by starting at the top
|
/* conio doesn't scroll! Avoid trouble by starting at the top
|
||||||
** of the screen, and never going "below" the bottom of the screen.
|
** of the screen, and never going "below" the bottom of the screen.
|
||||||
*/
|
*/
|
||||||
clrscr();
|
clrscr();
|
||||||
r = 7; /* allow for prompt */
|
r = 7; /* allow for prompt */
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* This prompt fits on the VIC-20's narrow screen.
|
/* This prompt fits on the VIC-20's narrow screen.
|
||||||
@@ -52,21 +61,24 @@ int main(void) {
|
|||||||
PRINT("Type characters to see\r\ntheir hexadecimal code\r\nnumbers:\r\n\n");
|
PRINT("Type characters to see\r\ntheir hexadecimal code\r\nnumbers:\r\n\n");
|
||||||
screensize(&width, &height); /* get the screen's dimensions */
|
screensize(&width, &height); /* get the screen's dimensions */
|
||||||
width /= 6; /* get number of codes on a line */
|
width /= 6; /* get number of codes on a line */
|
||||||
cursor(true);
|
cursor(true);
|
||||||
t = 0;
|
t = 0;
|
||||||
while ((c = GET()) != EOF) {
|
while ((c = GET()) != EOF) {
|
||||||
|
|
||||||
# ifdef CONIO
|
# ifndef USE_STDIO
|
||||||
if (r == height) {
|
if (r == height) {
|
||||||
clrscr();
|
clrscr();
|
||||||
|
t = 0;
|
||||||
PUT(c); /* echo char. again because screen was erased */
|
PUT(c); /* echo char. again because screen was erased */
|
||||||
r = 1;
|
r = 1;
|
||||||
}
|
}
|
||||||
|
if (c == '\n')
|
||||||
|
++r;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
PRINT("=$%02x ", c);
|
PRINT("=$%02x ", c);
|
||||||
if (c == QUIT)
|
if (c == QUIT)
|
||||||
break;
|
break;
|
||||||
if (++t == width) {
|
if (++t == width) {
|
||||||
PRINT("\r\n");
|
PRINT("\r\n");
|
||||||
++r;
|
++r;
|
||||||
|
|||||||
Reference in New Issue
Block a user