move some things from targettest to samples
This commit is contained in:
72
samples/sym1/Makefile
Normal file
72
samples/sym1/Makefile
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
# Run 'make SYS=<target>'; or, set a SYS env.
|
||||
# var. to build for another target system.
|
||||
SYS ?= sym1
|
||||
|
||||
# Just the usual way to find out if we're
|
||||
# using cmd.exe to execute make rules.
|
||||
ifneq ($(shell echo),)
|
||||
CMD_EXE = 1
|
||||
endif
|
||||
|
||||
ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
DEL = -del /f
|
||||
RMDIR = rmdir /s /q
|
||||
else
|
||||
NULLDEV = /dev/null
|
||||
DEL = $(RM)
|
||||
RMDIR = $(RM) -r
|
||||
endif
|
||||
|
||||
ifdef CC65_HOME
|
||||
AS = $(CC65_HOME)/bin/ca65
|
||||
CC = $(CC65_HOME)/bin/cc65
|
||||
CL = $(CC65_HOME)/bin/cl65
|
||||
LD = $(CC65_HOME)/bin/ld65
|
||||
else
|
||||
AS := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
|
||||
CC := $(if $(wildcard ../../bin/cc65*),../../bin/cc65,cc65)
|
||||
CL := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
|
||||
LD := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
|
||||
endif
|
||||
|
||||
EXELIST_sym1 = \
|
||||
symHello.bin symTiny.bin symDisplay.bin symIO.bin symNotepad.bin
|
||||
|
||||
ifneq ($(EXELIST_$(SYS)),)
|
||||
samples: $(EXELIST_$(SYS))
|
||||
else
|
||||
samples: notavailable
|
||||
endif
|
||||
|
||||
# empty target used to skip systems that will not work with any program in this dir
|
||||
notavailable:
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
@echo "info: sym1 tests not available for" $(SYS)
|
||||
else
|
||||
# suppress the "nothing to be done for 'samples' message
|
||||
@echo > $(NULLDEV)
|
||||
endif
|
||||
|
||||
symHello.bin: symHello.c
|
||||
$(CL) -t sym1 -O -o symHello.bin symHello.c
|
||||
|
||||
symTiny.bin: symTiny.c
|
||||
$(CL) -t sym1 -O -o symTiny.bin symTiny.c
|
||||
|
||||
symDisplay.bin: symDisplay.c
|
||||
$(CL) -t sym1 -O -o symDisplay.bin symDisplay.c
|
||||
|
||||
symIO.bin: symIO.c
|
||||
$(CL) -t sym1 -C sym1-32k.cfg -O -o symIO.bin symIO.c
|
||||
|
||||
symNotepad.bin: symNotepad.c
|
||||
$(CL) -t sym1 -C sym1-32k.cfg -O -o symNotepad.bin symNotepad.c
|
||||
|
||||
clean:
|
||||
@$(DEL) symHello.bin 2>$(NULLDEV)
|
||||
@$(DEL) symTiny.bin 2>$(NULLDEV)
|
||||
@$(DEL) symDisplay.bin 2>$(NULLDEV)
|
||||
@$(DEL) symIO.bin 2>$(NULLDEV)
|
||||
@$(DEL) symNotepad.bin 2>$(NULLDEV)
|
||||
358
samples/sym1/symDisplay.c
Normal file
358
samples/sym1/symDisplay.c
Normal file
@@ -0,0 +1,358 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Sym-1 front panel display example
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sym1.h>
|
||||
|
||||
int main (void) {
|
||||
int delay = 10;
|
||||
int flashes = 255;
|
||||
int displayable = 1;
|
||||
int e = 0;
|
||||
int r = 0;
|
||||
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 ) {
|
||||
puts ("\n\n--- Reached 40 character limit. ---");
|
||||
}
|
||||
}
|
||||
|
||||
i--; // index is one past end
|
||||
|
||||
while ( z == 0 ) {
|
||||
puts ("\n\nHow many times (0 for forever) to repeat?");
|
||||
c = getchar();
|
||||
if ( (c >= '0') && (c <= '9') ) {// between 1 and 9 loops allowed
|
||||
z = 1; // a number was pressed
|
||||
t = c - '0'; // convert char to int
|
||||
puts ("\n\nLook at the front panel.\n");
|
||||
}
|
||||
else {
|
||||
puts ("\nWhat?");
|
||||
z = 0; // keep asking for a number
|
||||
}
|
||||
}
|
||||
|
||||
z = 0;
|
||||
while ( (z < t) || (t == 0) ) {
|
||||
|
||||
z++;
|
||||
|
||||
putchar ( '\r' ); // Send CR to console
|
||||
|
||||
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
|
||||
DISPLAY.d6 = DISP_1; // one at a time
|
||||
break;
|
||||
case '2':
|
||||
DISPLAY.d6 = DISP_2;
|
||||
break;
|
||||
case '3':
|
||||
DISPLAY.d6 = DISP_3;
|
||||
break;
|
||||
case '4':
|
||||
DISPLAY.d6 = DISP_4;
|
||||
break;
|
||||
case '5':
|
||||
DISPLAY.d6 = DISP_5;
|
||||
break;
|
||||
case '6':
|
||||
DISPLAY.d6 = DISP_6;
|
||||
break;
|
||||
case '7':
|
||||
DISPLAY.d6 = DISP_7;
|
||||
break;
|
||||
case '8':
|
||||
DISPLAY.d6 = DISP_8;
|
||||
break;
|
||||
case '9':
|
||||
DISPLAY.d6 = DISP_9;
|
||||
break;
|
||||
case '0':
|
||||
DISPLAY.d6 = DISP_0;
|
||||
break;
|
||||
case 'A':
|
||||
DISPLAY.d6 = DISP_A;
|
||||
break;
|
||||
case 'a':
|
||||
DISPLAY.d6 = DISP_A;
|
||||
break;
|
||||
case 'B':
|
||||
DISPLAY.d6 = DISP_b;
|
||||
break;
|
||||
case 'b':
|
||||
DISPLAY.d6 = DISP_b;
|
||||
break;
|
||||
case 'C':
|
||||
DISPLAY.d6 = DISP_C;
|
||||
break;
|
||||
case 'c':
|
||||
DISPLAY.d6 = DISP_c;
|
||||
break;
|
||||
case 'D':
|
||||
DISPLAY.d6 = DISP_d;
|
||||
break;
|
||||
case 'd':
|
||||
DISPLAY.d6 = DISP_d;
|
||||
break;
|
||||
case 'E':
|
||||
DISPLAY.d6 = DISP_E;
|
||||
break;
|
||||
case 'e':
|
||||
DISPLAY.d6 = DISP_e;
|
||||
break;
|
||||
case 'F':
|
||||
DISPLAY.d6 = DISP_F;
|
||||
break;
|
||||
case 'f':
|
||||
DISPLAY.d6 = DISP_F;
|
||||
break;
|
||||
case 'G':
|
||||
DISPLAY.d6 = DISP_G;
|
||||
break;
|
||||
case 'g':
|
||||
DISPLAY.d6 = DISP_g;
|
||||
break;
|
||||
case 'H':
|
||||
DISPLAY.d6 = DISP_H;
|
||||
break;
|
||||
case 'h':
|
||||
DISPLAY.d6 = DISP_h;
|
||||
break;
|
||||
case 'I':
|
||||
DISPLAY.d6 = DISP_I;
|
||||
break;
|
||||
case 'i':
|
||||
DISPLAY.d6 = DISP_i;
|
||||
break;
|
||||
case 'J':
|
||||
DISPLAY.d6 = DISP_J;
|
||||
break;
|
||||
case 'j':
|
||||
DISPLAY.d6 = DISP_J;
|
||||
break;
|
||||
case 'K':
|
||||
DISPLAY.d6 = DISP_K;
|
||||
break;
|
||||
case 'k':
|
||||
DISPLAY.d6 = DISP_K;
|
||||
break;
|
||||
case 'L':
|
||||
DISPLAY.d6 = DISP_L;
|
||||
break;
|
||||
case 'l':
|
||||
DISPLAY.d6 = DISP_L;
|
||||
break;
|
||||
case 'M':
|
||||
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':
|
||||
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':
|
||||
DISPLAY.d6 = DISP_n;
|
||||
break;
|
||||
case 'n':
|
||||
DISPLAY.d6 = DISP_n;
|
||||
break;
|
||||
case 'O':
|
||||
DISPLAY.d6 = DISP_O;
|
||||
break;
|
||||
case 'o':
|
||||
DISPLAY.d6 = DISP_o;
|
||||
break;
|
||||
case 'P':
|
||||
DISPLAY.d6 = DISP_P;
|
||||
break;
|
||||
case 'p':
|
||||
DISPLAY.d6 = DISP_P;
|
||||
break;
|
||||
case 'Q':
|
||||
DISPLAY.d6 = DISP_q;
|
||||
break;
|
||||
case 'q':
|
||||
DISPLAY.d6 = DISP_q;
|
||||
break;
|
||||
case 'R':
|
||||
DISPLAY.d6 = DISP_r;
|
||||
break;
|
||||
case 'r':
|
||||
DISPLAY.d6 = DISP_r;
|
||||
break;
|
||||
case 'S':
|
||||
DISPLAY.d6 = DISP_S;
|
||||
break;
|
||||
case 's':
|
||||
DISPLAY.d6 = DISP_S;
|
||||
break;
|
||||
case 'T':
|
||||
DISPLAY.d6 = DISP_t;
|
||||
break;
|
||||
case 't':
|
||||
DISPLAY.d6 = DISP_t;
|
||||
break;
|
||||
case 'U':
|
||||
DISPLAY.d6 = DISP_U;
|
||||
break;
|
||||
case 'u':
|
||||
DISPLAY.d6 = DISP_u;
|
||||
break;
|
||||
case 'V':
|
||||
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':
|
||||
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':
|
||||
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':
|
||||
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':
|
||||
DISPLAY.d6 = DISP_Y;
|
||||
break;
|
||||
case 'y':
|
||||
DISPLAY.d6 = DISP_Y;
|
||||
break;
|
||||
case 'Z':
|
||||
DISPLAY.d6 = DISP_Z;
|
||||
break;
|
||||
case 'z':
|
||||
DISPLAY.d6 = DISP_Z;
|
||||
break;
|
||||
case ' ':
|
||||
DISPLAY.d6 = DISP_SPACE;
|
||||
break;
|
||||
case '.':
|
||||
DISPLAY.d6 = DISP_PERIOD;
|
||||
break;
|
||||
case '-':
|
||||
DISPLAY.d6 = DISP_HYPHEN;
|
||||
break;
|
||||
case '\'':
|
||||
DISPLAY.d6 = DISP_APOSTR;
|
||||
break;
|
||||
case '"':
|
||||
DISPLAY.d6 = DISP_APOSTR;
|
||||
break;
|
||||
case '=':
|
||||
DISPLAY.d6 = DISP_EQUAL;
|
||||
break;
|
||||
case '_':
|
||||
DISPLAY.d6 = DISP_BOTTOM;
|
||||
break;
|
||||
case '/':
|
||||
DISPLAY.d6 = DISP_SLASH;
|
||||
break;
|
||||
case '\\':
|
||||
DISPLAY.d6 = DISP_BACKSLASH;
|
||||
break;
|
||||
default:
|
||||
displayable = 0; // Character not mapped
|
||||
}
|
||||
|
||||
if ( displayable ) {
|
||||
|
||||
putchar ( buffer[l] ); // Send it to the console
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
puts ("\n\nEnjoy your day!\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
39
samples/sym1/symHello.c
Normal file
39
samples/sym1/symHello.c
Normal file
@@ -0,0 +1,39 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Hello World for Sym-1
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sym1.h>
|
||||
|
||||
int main (void) {
|
||||
char c = 0x00;
|
||||
int d = 0x00;
|
||||
int l = 0x00;
|
||||
|
||||
printf ("\nHello World!\n\n");
|
||||
|
||||
for ( l = 0; l < 2; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
printf ("Type a line and press ENTER, please.\n\n");
|
||||
|
||||
while ( c != '\n' ) {
|
||||
c = getchar();
|
||||
}
|
||||
|
||||
printf ("\n\nThanks!\n\n");
|
||||
|
||||
for ( l = 0; l < 5; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
172
samples/sym1/symIO.c
Normal file
172
samples/sym1/symIO.c
Normal file
@@ -0,0 +1,172 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Sym-1 digital I/O interface example
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <sym1.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main (void) {
|
||||
unsigned char ddr1a = 0x00;
|
||||
unsigned char ior1a = 0x00;
|
||||
unsigned char ddr1b = 0x00;
|
||||
unsigned char ior1b = 0x00;
|
||||
unsigned char ddr2a = 0x00;
|
||||
unsigned char ior2a = 0x00;
|
||||
unsigned char ddr2b = 0x00;
|
||||
unsigned char ior2b = 0x00;
|
||||
unsigned char ddr3a = 0x00;
|
||||
unsigned char ior3a = 0x00;
|
||||
unsigned char ddr3b = 0x00;
|
||||
unsigned char ior3b = 0x00;
|
||||
unsigned char val = 0x00;
|
||||
int going = 0x01;
|
||||
int instr = 0x01;
|
||||
int l = 0x00;
|
||||
char* vp = 0x00;
|
||||
char cmd[20] = { 0x00 };
|
||||
|
||||
while ( going ) {
|
||||
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
|
||||
ddr1a = VIA1.ddra;
|
||||
ior1a = VIA1.pra;
|
||||
ddr1b = VIA1.ddrb;
|
||||
ior1b = VIA1.prb;
|
||||
ddr2a = VIA2.ddra;
|
||||
ior2a = VIA2.pra;
|
||||
ddr2b = VIA2.ddrb;
|
||||
ior2b = VIA2.prb;
|
||||
ddr3a = VIA3.ddra;
|
||||
ior3a = VIA3.pra;
|
||||
ddr3b = VIA3.ddrb;
|
||||
ior3b = VIA3.prb;
|
||||
|
||||
puts ("================== Digital I/O Status ==================");
|
||||
puts (" Port1A Port1B Port2A Port2B Port3A Port3B" );
|
||||
printf ("DDR %02X %02X %02X %02X %02X %02X\n\r",ddr1a,ddr1b,ddr2a,ddr2b,ddr3a,ddr3b);
|
||||
printf ("IOR %02X %02X %02X %02X %02X %02X\n\r",ior1a,ior1b,ior2a,ior2b,ior3a,ior3b);
|
||||
puts ("========================================================\n");
|
||||
|
||||
if ( instr ) {
|
||||
puts ("You can set any register by typing 'register value' so");
|
||||
puts ("as an example, to set register IOR2A with the top five");
|
||||
puts ("bits off and the bottom three on, type 'IOR2A 07'.");
|
||||
puts ("Press ENTER without any command to see register values");
|
||||
puts ("without changing any of them. Type 'help' to see these");
|
||||
puts ("instructions again and type 'quit' to end the program.\n");
|
||||
puts ("Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A");
|
||||
puts ("IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B.");
|
||||
instr = 0;
|
||||
}
|
||||
|
||||
printf ("\n Command: ");
|
||||
|
||||
fgets ( cmd, sizeof(cmd)-1, stdin );
|
||||
cmd[strlen(cmd)-1] = '\0';
|
||||
|
||||
if ( strncasecmp(cmd, "quit", 4) == 0 ) {
|
||||
going = 0;
|
||||
}
|
||||
else if ( strncasecmp(cmd, "help", 4) == 0 ) {
|
||||
instr = 1;
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr1a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.ddra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior1a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.pra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr1b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.ddrb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior1b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA1.prb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr2a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.ddra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior2a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.pra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr2b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.ddrb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior2b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA2.prb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr3a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.ddra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior3a", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.pra = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ddr3b", 5) == 0 ) {
|
||||
vp = strchr ( cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.ddrb = val;
|
||||
}
|
||||
}
|
||||
else if ( strncasecmp(cmd, "ior3b", 5) == 0 ) {
|
||||
vp = strchr (cmd, ' ' );
|
||||
if ( vp ) {
|
||||
val = (unsigned char) strtol( vp, NULL, 0 );
|
||||
VIA3.prb = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
puts ("\n\nEnjoy your day!\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
192
samples/sym1/symNotepad.c
Normal file
192
samples/sym1/symNotepad.c
Normal file
@@ -0,0 +1,192 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Sym-1 Notepad
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
//
|
||||
// Note: This program requires RAM memory in locations 0xE000 - 0xEFFF
|
||||
// Alternatively, the tape I/O buffer location and size can be
|
||||
// changed by altering the defined TAPIO values below.
|
||||
//
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <sym1.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TAPIO_ADDRESS 0xE000
|
||||
#define TAPIO_MAX_SIZE 0x0FFF
|
||||
|
||||
int main (void) {
|
||||
char c = 0x00;
|
||||
int l = 0x00;
|
||||
int p = 0x00;
|
||||
int error = 0x00;
|
||||
int running = 0x01;
|
||||
int writing = 0x01;
|
||||
int instruction_needed = 0x01;
|
||||
int heap_size = 0x00;
|
||||
char* tapio = (char*) TAPIO_ADDRESS;
|
||||
char* buffer;
|
||||
|
||||
heap_size = _heapmaxavail();
|
||||
|
||||
if ( heap_size > TAPIO_MAX_SIZE ) { // No need to malloc more than
|
||||
heap_size = TAPIO_MAX_SIZE; // the interface allows
|
||||
}
|
||||
|
||||
buffer = malloc ( heap_size );
|
||||
memset ( buffer, 0x00, heap_size );
|
||||
|
||||
if ( buffer == 0x00 ) {
|
||||
puts ("Memory full.");
|
||||
running = 0;
|
||||
}
|
||||
|
||||
tapio[0] = 0x00; // Check tape interface memory
|
||||
if ( tapio[0] != 0x00 )
|
||||
error = 1;
|
||||
|
||||
tapio[0] = 0xFF;
|
||||
if ( tapio[0] != 0xFF )
|
||||
error = 1;
|
||||
|
||||
tapio[TAPIO_MAX_SIZE] = 0x00;
|
||||
if ( tapio[TAPIO_MAX_SIZE] != 0x00 )
|
||||
error = 1;
|
||||
|
||||
tapio[TAPIO_MAX_SIZE] = 0xFF;
|
||||
if ( tapio[TAPIO_MAX_SIZE] != 0xFF )
|
||||
error = 1;
|
||||
|
||||
if ( error ) {
|
||||
printf ("\nNo memory at location %p, aborting.\n", tapio);
|
||||
running = 0;
|
||||
}
|
||||
else {
|
||||
memset ( tapio, 0, TAPIO_MAX_SIZE );
|
||||
}
|
||||
|
||||
|
||||
while ( running ) {
|
||||
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
|
||||
puts ("===================== Sym-1 Notepad ====================");
|
||||
|
||||
if ( instruction_needed ) {
|
||||
puts ("Enter text and you can save it to tape for reloading");
|
||||
puts ("later. There are four special 'command' characters:\n");
|
||||
puts (" Control-S Save to tape");
|
||||
puts (" Control-L Load from tape");
|
||||
puts (" Control-C Clear memory");
|
||||
puts (" Control-X Exit");
|
||||
puts ("========================================================\n");
|
||||
}
|
||||
|
||||
while ( writing ) {
|
||||
|
||||
c = getchar();
|
||||
|
||||
if ( c == 0x08 ) { // Backspace
|
||||
if ( p > 0 ) {
|
||||
buffer[p] = 0x00;
|
||||
p--;
|
||||
}
|
||||
}
|
||||
else if ( c == 0x13 ) { // Save
|
||||
puts ("\n========================= Save =========================");
|
||||
puts ("\nPress any key to save.");
|
||||
c = getchar();
|
||||
for ( l = 0; l <= p; l++ ) {
|
||||
tapio[l] = buffer[l];
|
||||
}
|
||||
l++;
|
||||
tapio[l] = 0x00;
|
||||
puts ("Saving to tape.");
|
||||
error = dumpt ( 'N', tapio, tapio+p );
|
||||
if ( error ) {
|
||||
puts ("\nTape error.");
|
||||
}
|
||||
else
|
||||
{
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
}
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
for ( l = 0; l <= p; l++ ) {
|
||||
putchar ( buffer[l] );
|
||||
}
|
||||
}
|
||||
else if ( c == 0x0C ) { // Load
|
||||
p = 0;
|
||||
puts ("\nLoading from tape.");
|
||||
memset ( buffer, 0, heap_size );
|
||||
memset ( tapio, 0, TAPIO_MAX_SIZE );
|
||||
error = loadt ( 'N' );
|
||||
if ( error ) {
|
||||
puts ("\nTape error.");
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( l = 0; l <= heap_size; l++ ) {
|
||||
buffer[l] = tapio[l];
|
||||
}
|
||||
|
||||
p = strlen ( buffer );
|
||||
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
|
||||
for ( l = 0; l <= p; l++ ) {
|
||||
putchar ( buffer[l] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( c == 0x03 ) { // Clear
|
||||
p = 0;
|
||||
memset ( buffer, 0, heap_size );
|
||||
putchar ( '\r' );
|
||||
for ( l = 0; l < 25; l++ ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
puts ("===================== Sym-1 Notepad ====================\n");
|
||||
}
|
||||
else if ( c == 0x18 ) { // Exit
|
||||
writing = 0;
|
||||
running = 0;
|
||||
}
|
||||
else {
|
||||
if ( p >= heap_size - 1 ) {
|
||||
puts ("\n========================= End =========================");
|
||||
puts ("Buffer full.");
|
||||
}
|
||||
else {
|
||||
if ( c == '\n' ) {
|
||||
putchar ( '\n' );
|
||||
}
|
||||
buffer[p] = c;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free ( buffer );
|
||||
|
||||
puts ("\nEnjoy your day!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
42
samples/sym1/symTiny.c
Normal file
42
samples/sym1/symTiny.c
Normal file
@@ -0,0 +1,42 @@
|
||||
// --------------------------------------------------------------------------
|
||||
// Hello World for Sym-1
|
||||
//
|
||||
// Uses only getchar, putchar and puts, generating smaller code than printf
|
||||
//
|
||||
// Wayne Parham
|
||||
//
|
||||
// wayne@parhamdata.com
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sym1.h>
|
||||
|
||||
int main (void) {
|
||||
char c = 0x00;
|
||||
int d = 0x00;
|
||||
int l = 0x00;
|
||||
|
||||
puts ("Hello World!\n");
|
||||
|
||||
puts ("Type a line and press ENTER, please:\n");
|
||||
|
||||
for ( l = 0; l < 2; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
|
||||
while ( c != '\n' ) {
|
||||
c = getchar();
|
||||
}
|
||||
|
||||
puts ("\n\nThanks!\n");
|
||||
|
||||
for ( l = 0; l < 5; l++ ) {
|
||||
beep();
|
||||
for ( d = 0; d < 10 ; d++ ) {
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user