Samples cleanup

This commit is contained in:
Wayne Parham 2021-06-07 00:48:02 -05:00
parent a3fce656b7
commit 975e43892f
10 changed files with 0 additions and 947 deletions

View File

@ -1,361 +0,0 @@
// --------------------------------------------------------------------------
// Sym-1 front panel display example
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <stdio.h>
#include <sym1.h>
void 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 != '\r') && (i < 41) ) {
c = getchar();
putchar( c );
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();
putchar( c );
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
set_D0( DISP_SPACE ); // Clear the display
set_D1( DISP_SPACE );
set_D2( DISP_SPACE );
set_D3( DISP_SPACE );
set_D4( DISP_SPACE );
set_D5( DISP_SPACE );
set_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
set_D6( DISP_1 ); // one at a time
break;
case '2':
set_D6( DISP_2 );
break;
case '3':
set_D6( DISP_3 );
break;
case '4':
set_D6( DISP_4 );
break;
case '5':
set_D6( DISP_5 );
break;
case '6':
set_D6( DISP_6 );
break;
case '7':
set_D6( DISP_7 );
break;
case '8':
set_D6( DISP_8 );
break;
case '9':
set_D6( DISP_9 );
break;
case '0':
set_D6( DISP_0 );
break;
case 'A':
set_D6( DISP_A );
break;
case 'a':
set_D6( DISP_A );
break;
case 'B':
set_D6( DISP_b );
break;
case 'b':
set_D6( DISP_b );
break;
case 'C':
set_D6( DISP_C );
break;
case 'c':
set_D6( DISP_c );
break;
case 'D':
set_D6( DISP_d );
break;
case 'd':
set_D6( DISP_d );
break;
case 'E':
set_D6( DISP_E );
break;
case 'e':
set_D6( DISP_e );
break;
case 'F':
set_D6( DISP_F );
break;
case 'f':
set_D6( DISP_F );
break;
case 'G':
set_D6( DISP_G );
break;
case 'g':
set_D6( DISP_g );
break;
case 'H':
set_D6( DISP_H );
break;
case 'h':
set_D6( DISP_h );
break;
case 'I':
set_D6( DISP_I );
break;
case 'i':
set_D6( DISP_i );
break;
case 'J':
set_D6( DISP_J );
break;
case 'j':
set_D6( DISP_J );
break;
case 'K':
set_D6( DISP_K );
break;
case 'k':
set_D6( DISP_K );
break;
case 'L':
set_D6( DISP_L );
break;
case 'l':
set_D6( DISP_L );
break;
case 'M':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_M_1 );
set_D6( DISP_M_2 );
break;
case 'm':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_M_1 );
set_D6( DISP_M_2 );
break;
case 'N':
set_D6( DISP_n );
break;
case 'n':
set_D6( DISP_n );
break;
case 'O':
set_D6( DISP_O );
break;
case 'o':
set_D6( DISP_o );
break;
case 'P':
set_D6( DISP_P );
break;
case 'p':
set_D6( DISP_P );
break;
case 'Q':
set_D6( DISP_q );
break;
case 'q':
set_D6( DISP_q );
break;
case 'R':
set_D6( DISP_r );
break;
case 'r':
set_D6( DISP_r );
break;
case 'S':
set_D6( DISP_S );
break;
case 's':
set_D6( DISP_S );
break;
case 'T':
set_D6( DISP_t );
break;
case 't':
set_D6( DISP_t );
break;
case 'U':
set_D6( DISP_U );
break;
case 'u':
set_D6( DISP_u );
break;
case 'V':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_V_1 );
set_D6( DISP_V_2 );
break;
case 'v':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_V_1 );
set_D6( DISP_V_2 );
break;
case 'W':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_W_1 );
set_D6( DISP_W_2 );
break;
case 'w':
set_D0( get_D1() );
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_W_1 );
set_D6( DISP_W_2 );
break;
case 'Y':
set_D6( DISP_Y );
break;
case 'y':
set_D6( DISP_Y );
break;
case 'Z':
set_D6( DISP_Z );
break;
case 'z':
set_D6( DISP_Z );
break;
case ' ':
set_D6( DISP_SPACE );
break;
case '.':
set_D6( DISP_PERIOD );
break;
case '-':
set_D6( DISP_HYPHEN );
break;
case '\'':
set_D6( DISP_APOSTR );
break;
case '"':
set_D6( DISP_APOSTR );
break;
case '=':
set_D6( DISP_EQUAL );
break;
case '_':
set_D6( DISP_BOTTOM );
break;
case '/':
set_D6( DISP_SLASH );
break;
case '\\':
set_D6( DISP_BACKSLASH );
break;
default:
displayable = 0; // Character not mapped
}
if( displayable ) {
putchar( buffer[l] ); // Send it to the console
set_D0( get_D1() ); // Scroll to the left
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( get_D6() );
for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
}
}
for( e = 0; e < 6; e++ ) { // Gradually fill the
set_D0( get_D1() ); // display with spaces
set_D1( get_D2() );
set_D2( get_D3() );
set_D3( get_D4() );
set_D4( get_D5() );
set_D5( DISP_SPACE );
set_D6( DISP_SPACE );
for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display
}
}
}
puts( "\n\nEnjoy your day!\n\n" );
return;
}

View File

@ -1,40 +0,0 @@
// --------------------------------------------------------------------------
// Hello World for Sym-1
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <stdio.h>
#include <sym1.h>
void 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 != '\r' ) {
c = getchar();
putchar( c );
}
printf( "\n\nThanks!\n\n" );
for( l = 0; l < 5; l++ ) {
beep();
for( d = 0; d < 10 ; d++ ) {
}
}
return;
}

View File

@ -1,170 +0,0 @@
// --------------------------------------------------------------------------
// Sym-1 digital I/O interface example
//
// Wayne Parham
//
// wayne@parhamdata.com
// --------------------------------------------------------------------------
#include <sym1.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main(void) {
int ddr1a = 0x00;
int ior1a = 0x00;
int ddr1b = 0x00;
int ior1b = 0x00;
int ddr2a = 0x00;
int ior2a = 0x00;
int ddr2b = 0x00;
int ior2b = 0x00;
int ddr3a = 0x00;
int ior3a = 0x00;
int ddr3b = 0x00;
int ior3b = 0x00;
int l = 0x00;
int val = 0x00;
int going = 0x01;
int instr = 0x01;
char* vp = 0x00;
char cmd[20] = { 0x00 };
while( going ) {
putchar( '\r' );
for( l = 0; l < 25; l++ ) {
putchar( '\n' );
}
ddr1a = get_DDR1A();
ior1a = get_IOR1A();
ddr1b = get_DDR1B();
ior1b = get_IOR1B();
ddr2a = get_DDR2A();
ior2a = get_IOR2A();
ddr2b = get_DDR2B();
ior2b = get_IOR2B();
ddr3a = get_DDR3A();
ior3a = get_IOR3A();
ddr3b = get_DDR3B();
ior3b = get_IOR3B();
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 'stop' 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, "stop", 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 = atoi( vp );
set_DDR1A( val );
}
}
else if( strncasecmp(cmd, "ior1a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR1A( val );
}
}
else if( strncasecmp(cmd, "ddr1b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR1B( val );
}
}
else if( strncasecmp(cmd, "ior1b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR1B( val );
}
}
else if( strncasecmp(cmd, "ddr2a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR2A( val );
}
}
else if( strncasecmp(cmd, "ior2a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR2A( val );
}
}
else if( strncasecmp(cmd, "ddr2b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR2B( val );
}
}
else if( strncasecmp(cmd, "ior2b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR2B( val );
}
}
else if( strncasecmp(cmd, "ddr3a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR3A( val );
}
}
else if( strncasecmp(cmd, "ior3a", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR3A( val );
}
}
else if( strncasecmp(cmd, "ddr3b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_DDR3B( val );
}
}
else if( strncasecmp(cmd, "ior3b", 5) == 0) {
vp = strchr(cmd, ' ');
if( vp ) {
val = atoi( vp );
set_IOR3B( val );
}
}
}
return;
}

View File

@ -1,200 +0,0 @@
// --------------------------------------------------------------------------
// 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
void 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', (int) tapio, (int) 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] );
if( buffer[l] == '\r' ) {
putchar( '\n' );
}
}
}
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] );
if( buffer[l] == '\r' ) {
putchar( '\n' );
}
}
}
}
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 == '\r' ) {
putchar( '\n' );
}
buffer[p] = c;
putchar( c );
}
p++;
}
}
}
free( buffer );
puts( "\nEnjoy your day!\n" );
return;
}

View File

@ -1,43 +0,0 @@
// --------------------------------------------------------------------------
// 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>
void 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 != '\r' ) {
c = getchar();
putchar( c );
}
puts( "\n\nThanks!\n" );
for( l = 0; l < 5; l++ ) {
beep();
for( d = 0; d < 10 ; d++ ) {
}
}
return;
}

View File

@ -1,36 +0,0 @@
#!/usr/bin/env bash
#
# build.sh
if [ -f $1.c ]; then
echo
echo "--- Building $1 ---"
if [ -f $1.s ]; then
rm $1.s
fi
if [ -f $1.o ]; then
rm $1.o
fi
if [ -f $1.bin ]; then
rm $1.bin
fi
if [ -f $1.hex ]; then
rm $1.hex
fi
cc65 -t sym1 -O $1.c
ca65 $1.s
ld65 -C sym1.cfg -m $1.map -o $1.bin $1.o sym1.lib
if [ -f $1.bin ]; then
bin2hex $1.bin $1.hex > /dev/null 2>&1
fi
if [ -f $1.hex ]; then
echo "--- $1.hex made ---"
else
echo "--- $1.hex FAIL ---"
fi
fi

View File

@ -1,36 +0,0 @@
#!/usr/bin/env bash
#
# build.sh
if [ -f $1.c ]; then
echo
echo "--- Building $1 ---"
if [ -f $1.s ]; then
rm $1.s
fi
if [ -f $1.o ]; then
rm $1.o
fi
if [ -f $1.bin ]; then
rm $1.bin
fi
if [ -f $1.hex ]; then
rm $1.hex
fi
cc65 -t sym1 -O $1.c
ca65 $1.s
ld65 -C sym1-32k.cfg -m $1.map -o $1.bin $1.o sym1.lib
if [ -f $1.bin ]; then
bin2hex $1.bin $1.hex > /dev/null 2>&1
fi
if [ -f $1.hex ]; then
echo "--- $1.hex made ---"
else
echo "--- $1.hex FAIL ---"
fi
fi

View File

@ -1,36 +0,0 @@
#!/usr/bin/env bash
#
# build.sh
if [ -f $1.c ]; then
echo
echo "--- Building $1 ---"
if [ -f $1.s ]; then
rm $1.s
fi
if [ -f $1.o ]; then
rm $1.o
fi
if [ -f $1.bin ]; then
rm $1.bin
fi
if [ -f $1.hex ]; then
rm $1.hex
fi
cc65 -t sym1 -O $1.c
ca65 $1.s
ld65 -C sym1-4k.cfg -m $1.map -o $1.bin $1.o sym1.lib
if [ -f $1.bin ]; then
bin2hex $1.bin $1.hex > /dev/null 2>&1
fi
if [ -f $1.hex ]; then
echo "--- $1.hex made ---"
else
echo "--- $1.hex FAIL ---"
fi
fi

View File

@ -1,14 +0,0 @@
#!/usr/bin/env bash
#
# clean.sh
if [ -f $1.c ]; then
echo
echo "--- Cleaning $1 ---"
rm $1.s $1.o $1.map $1.bin $1.hex > /dev/null 2>&1
echo "--- Cleaned $1 ---"
fi

View File

@ -1,11 +0,0 @@
These simple build scripts can be used to build any single-file C program
you might write. Notice the diference in the linker line for the 4k build
compared with the 32k build. Small programs can be compiled with either
build script, but they won't run on a 4k machine if compiled for a 32k
system. So if you have a program that's small enough to fit in 4k, it is
probably better to build with the 4k script so it will run on Sym-1 machines
that do not have an expansion memory board.
Usage: build <program> (don't include the .c extension)
clean <program> (removes intermediate and output files)