#ifdef DINKR12 #include "../../dinkusr.h" #endif /* DINKR12 */ #include /* Substitute DINK functions for the functions. */ #ifdef DINKR12 #define getchar local_get_char #define putchar write_char int local_get_char() { /* get the keyboard parameter (which port are we using) then * call get_char with the keyboard value */ long keyboard = get_KEYBOARD(); return get_char(keyboard); } #else /* not DINKR12 */ /* notice if undefined DINKR12 */ /* This code is only for version of dink32 prior to Release 12.0, * which include the release R11.0.2 which use static addresses. * dink R12.0 and beyond use dynamic addresses. The addresses defined in this file depend on the locations of the functions. The addresses may be different with each version of DINK being built. Make sure the addresses matches with what are defined in the dink_dir/xref.txt before running this l2test program These addresses correspond to dink32 V11.0.2 */ #define getchar dink_get_char #define putchar dink_write_char /* These are the magic addresses for the DINK functions in Ver11.0.2 */ unsigned long (*dink_get_char)() = (unsigned long (*)()) 0x281a0; unsigned long (*dink_write_char)(char) = (unsigned long (*)(char)) 0x67ac; #endif /*DINKR12*/ #define DEFAULT 1 /* smallScanf is used to read one integer either in %d or %x format */ void smallscanf(char *fmt, int *v) { char ch; int no_runs = 0; switch(fmt[1]) { case 'd': /* decimal string */ while ((ch = getchar()) != 0xd) /* Carriage return? */ { if ( (ch == 0x7f) || (ch == 0x8)) /* Delete? */ { putchar(0x8); /* Backspace */ putchar(0x20); /* Overprint a space. */ putchar(0x8); /* Backspace */ /* Assume modulo arithmetic to subtract last digit added. */ no_runs = no_runs / 10; } else if ( (ch >= '0') && (ch <= '9')) /* A digit? */ { putchar(ch); /* Echo it and */ /* Accumulate the value. */ no_runs = (no_runs * 10) + (ch - 48); /* ASCII character - 48 equals the digit. */ } } *v = no_runs; /* Assign second Arg the value. */ return; case 'x': /* hex string */ while ((ch = getchar()) != 0xd) /* Carriage return? */ { if ( (ch == 0x7f) || (ch == 0x8)) /* Delete? */ { putchar(0x8); /* Backspace */ putchar(0x20); /* Overprint a space. */ putchar(0x8); /* Backspace */ /* Assume modulo arithmetic to subtract last digit added. */ no_runs = no_runs / 16; } else if ( (ch >= '0') && (ch <= '9')) /* A dec digit? */ { putchar(ch); /* Echo it and */ /* Accumulate the value. */ no_runs = (no_runs * 16) + (ch - 48); /* ASCII character - 48 equals the digit. */ } if ( (ch >= 'A') && (ch <= 'F')) /* A capital hex digit? */ { putchar(ch); /* Echo it and */ /* Accumulate the value. */ no_runs = (no_runs * 16) + (ch - 55); /* A = dec 10 */ /* ASCII character - 48 equals the digit. */ } if ( (ch >= 'a') && (ch <= 'f')) /* A small hex digit? */ { putchar(ch); /* Echo it and */ /* Accumulate the value. */ no_runs = (no_runs * 16) + (ch - 87); /* a = dec 10 */ /* ASCII character - 48 equals the digit. */ } } *v = no_runs; /* Assign second Arg the value. */ return; } }