1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 22:30:12 +00:00
cc65/samples/sym1/symDisplay.c

359 lines
10 KiB
C
Raw Normal View History

// --------------------------------------------------------------------------
// Sym-1 front panel display example
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
2021-06-07 16:50:47 +00:00
#include <stdio.h>
#include <sym1.h>
int main (void) {
2021-06-15 21:39:28 +00:00
int delay = 10;
int flashes = 255;
int displayable = 1;
2021-06-15 21:39:28 +00:00
int e = 0;
2022-04-17 14:06:45 +00:00
int r = 0;
2021-06-15 21:39:28 +00:00
int d = 0;
int i = 0;
int l = 0;
int t = 0;
int z = 0;
char c = 0x00;
char buffer[41] = { 0x00 };
puts ("\nType a message (40 chars max) and press ENTER, please:\n");
while ( (c != '\n') && (i < 40) ) {
c = getchar();
buffer[i] = c;
i++;
if ( i == 40 ) {
2021-06-16 21:47:38 +00:00
puts ("\n\n--- Reached 40 character limit. ---");
}
}
i--; // index is one past end
while ( z == 0 ) {
2021-06-16 21:47:38 +00:00
puts ("\n\nHow many times (0 for forever) to repeat?");
c = getchar();
if ( (c >= '0') && (c <= '9') ) {// between 1 and 9 loops allowed
2022-04-17 14:06:45 +00:00
z = 1; // a number was pressed
t = c - '0'; // convert char to int
2021-06-16 21:47:38 +00:00
puts ("\n\nLook at the front panel.\n");
}
else {
2021-06-16 21:47:38 +00:00
puts ("\nWhat?");
z = 0; // keep asking for a number
}
}
z = 0;
while ( (z < t) || (t == 0) ) {
z++;
putchar ( '\r' ); // Send CR to console
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISP_SPACE; // Clear the display
DISPLAY.d1 = DISP_SPACE;
DISPLAY.d2 = DISP_SPACE;
DISPLAY.d3 = DISP_SPACE;
DISPLAY.d4 = DISP_SPACE;
DISPLAY.d5 = DISP_SPACE;
DISPLAY.d6 = DISP_SPACE;
for ( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
for ( l = 0; l <= i; l++ ) {
displayable = 1; // Assume character is mapped
switch ( buffer[l] ) { // Put the typed charaters
case '1': // into the display buffer
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_1; // one at a time
break;
case '2':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_2;
break;
case '3':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_3;
break;
case '4':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_4;
break;
case '5':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_5;
break;
case '6':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_6;
break;
case '7':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_7;
break;
case '8':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_8;
break;
case '9':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_9;
break;
case '0':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_0;
break;
case 'A':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_A;
break;
case 'a':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_A;
break;
case 'B':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_b;
break;
case 'b':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_b;
break;
case 'C':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_C;
break;
case 'c':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_c;
break;
case 'D':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_d;
break;
case 'd':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_d;
break;
case 'E':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_E;
break;
case 'e':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_e;
break;
case 'F':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_F;
break;
case 'f':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_F;
break;
case 'G':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_G;
break;
case 'g':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_g;
break;
case 'H':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_H;
break;
case 'h':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_h;
break;
case 'I':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_I;
break;
case 'i':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_i;
break;
case 'J':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_J;
break;
case 'j':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_J;
break;
case 'K':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_K;
break;
case 'k':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_K;
break;
case 'L':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_L;
break;
case 'l':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_L;
break;
case 'M':
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_M_1;
DISPLAY.d6 = DISP_M_2;
break;
case 'm':
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_M_1;
DISPLAY.d6 = DISP_M_2;
break;
case 'N':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_n;
break;
case 'n':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_n;
break;
case 'O':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_O;
break;
case 'o':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_o;
break;
case 'P':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_P;
break;
case 'p':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_P;
break;
case 'Q':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_q;
break;
case 'q':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_q;
break;
case 'R':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_r;
break;
case 'r':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_r;
break;
case 'S':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_S;
break;
case 's':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_S;
break;
case 'T':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_t;
break;
case 't':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_t;
break;
case 'U':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_U;
break;
case 'u':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_u;
break;
case 'V':
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_V_1;
DISPLAY.d6 = DISP_V_2;
break;
case 'v':
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_V_1;
DISPLAY.d6 = DISP_V_2;
break;
case 'W':
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_W_1;
DISPLAY.d6 = DISP_W_2;
break;
case 'w':
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1;
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_W_1;
DISPLAY.d6 = DISP_W_2;
break;
case 'Y':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_Y;
break;
case 'y':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_Y;
break;
case 'Z':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_Z;
break;
case 'z':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_Z;
break;
case ' ':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_SPACE;
break;
case '.':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_PERIOD;
break;
case '-':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_HYPHEN;
break;
case '\'':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_APOSTR;
break;
case '"':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_APOSTR;
break;
case '=':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_EQUAL;
break;
case '_':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_BOTTOM;
break;
case '/':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_SLASH;
break;
case '\\':
2021-06-09 15:23:42 +00:00
DISPLAY.d6 = DISP_BACKSLASH;
break;
default:
2021-05-13 19:43:16 +00:00
displayable = 0; // Character not mapped
}
if ( displayable ) {
putchar ( buffer[l] ); // Send it to the console
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1; // Scroll to the left
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISPLAY.d6;
for ( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
}
}
for ( e = 0; e < 6; e++ ) { // Gradually fill the
2021-06-09 15:23:42 +00:00
DISPLAY.d0 = DISPLAY.d1; // display with spaces
DISPLAY.d1 = DISPLAY.d2;
DISPLAY.d2 = DISPLAY.d3;
DISPLAY.d3 = DISPLAY.d4;
DISPLAY.d4 = DISPLAY.d5;
DISPLAY.d5 = DISP_SPACE;
DISPLAY.d6 = DISP_SPACE;
for ( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
}
}
2021-06-16 21:47:38 +00:00
puts ("\n\nEnjoy your day!\n\n");
return 0;
}