From 6e79379405f09d3c51765db44a16c69b28289797 Mon Sep 17 00:00:00 2001 From: Wayne Parham Date: Sun, 9 May 2021 16:34:53 -0500 Subject: [PATCH] Synertek Systems Sym-1 machine-specific files --- libsrc/sym1/beep.s | 24 ++ libsrc/sym1/bitio.s | 230 +++++++++++++++++ libsrc/sym1/crt0.s | 65 +++++ libsrc/sym1/display.s | 154 ++++++++++++ libsrc/sym1/getchar.s | 21 ++ libsrc/sym1/libref.s | 3 + libsrc/sym1/putchar.s | 23 ++ libsrc/sym1/read.s | 54 ++++ libsrc/sym1/tapeio.s | 58 +++++ libsrc/sym1/write.s | 53 ++++ samples/symDisplay.c | 384 +++++++++++++++++++++++++++++ samples/symHello.c | 39 +++ samples/symIO.c | 170 +++++++++++++ samples/symTiny.c | 42 ++++ samples/tutorial/sym1/build | 36 +++ samples/tutorial/sym1/build_32k | 36 +++ samples/tutorial/sym1/build_4k | 36 +++ samples/tutorial/sym1/clean | 14 ++ samples/tutorial/sym1/readme.txt | 11 + samples/tutorial/sym1/symDisplay.c | 384 +++++++++++++++++++++++++++++ samples/tutorial/sym1/symHello.c | 39 +++ samples/tutorial/sym1/symIO.c | 170 +++++++++++++ samples/tutorial/sym1/symTiny.c | 42 ++++ 23 files changed, 2088 insertions(+) create mode 100644 libsrc/sym1/beep.s create mode 100644 libsrc/sym1/bitio.s create mode 100644 libsrc/sym1/crt0.s create mode 100644 libsrc/sym1/display.s create mode 100644 libsrc/sym1/getchar.s create mode 100644 libsrc/sym1/libref.s create mode 100644 libsrc/sym1/putchar.s create mode 100644 libsrc/sym1/read.s create mode 100644 libsrc/sym1/tapeio.s create mode 100644 libsrc/sym1/write.s create mode 100644 samples/symDisplay.c create mode 100644 samples/symHello.c create mode 100644 samples/symIO.c create mode 100644 samples/symTiny.c create mode 100644 samples/tutorial/sym1/build create mode 100644 samples/tutorial/sym1/build_32k create mode 100644 samples/tutorial/sym1/build_4k create mode 100644 samples/tutorial/sym1/clean create mode 100644 samples/tutorial/sym1/readme.txt create mode 100644 samples/tutorial/sym1/symDisplay.c create mode 100644 samples/tutorial/sym1/symHello.c create mode 100644 samples/tutorial/sym1/symIO.c create mode 100644 samples/tutorial/sym1/symTiny.c diff --git a/libsrc/sym1/beep.s b/libsrc/sym1/beep.s new file mode 100644 index 000000000..a1f978563 --- /dev/null +++ b/libsrc/sym1/beep.s @@ -0,0 +1,24 @@ +; --------------------------------------------------------------------------- +; beep.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.export _beep + +.segment "CODE" + +.proc _beep: near +; --------------------------------------------------------------------------- + jsr BEEP ; Beep + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc diff --git a/libsrc/sym1/bitio.s b/libsrc/sym1/bitio.s new file mode 100644 index 000000000..5aa0fde8b --- /dev/null +++ b/libsrc/sym1/bitio.s @@ -0,0 +1,230 @@ +; --------------------------------------------------------------------------- +; bitio.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.export _set_DDR1A, _get_DDR1A, _set_IOR1A, _get_IOR1A +.export _set_DDR1B, _get_DDR1B, _set_IOR1B, _get_IOR1B +.export _set_DDR2A, _get_DDR2A, _set_IOR2A, _get_IOR2A +.export _set_DDR2B, _get_DDR2B, _set_IOR2B, _get_IOR2B +.export _set_DDR3A, _get_DDR3A, _set_IOR3A, _get_IOR3A +.export _set_DDR3B, _get_DDR3B, _set_IOR3B, _get_IOR3B + +.segment "CODE" + +.proc _set_DDR1A: near +; --------------------------------------------------------------------------- + sta DDR1A ; Write data direction register for port 1A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR1A: near +; --------------------------------------------------------------------------- + lda DDR1A ; Read data direction register for port 1A + ldx #$00 ; + rts ; Return DDR1A +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR1A: near +; --------------------------------------------------------------------------- + sta OR1A ; Write I/O register for port 1A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR1A: near +; --------------------------------------------------------------------------- + lda OR1A ; Read I/O register for port 1A + ldx #$00 ; + rts ; Return OR1A +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR1B: near +; --------------------------------------------------------------------------- + sta DDR1B ; Write data direction register for port 1B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR1B: near +; --------------------------------------------------------------------------- + lda DDR1B ; Read data direction register for port 1B + ldx #$00 ; + rts ; Return DDR1B +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR1B: near +; --------------------------------------------------------------------------- + sta OR1B ; Write I/O register for port 1B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR1B: near +; --------------------------------------------------------------------------- + lda OR1B ; Read I/O register for port 1B + ldx #$00 ; + rts ; Return OR1B +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR2A: near +; --------------------------------------------------------------------------- + sta DDR2A ; Write data direction register for port 2A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR2A: near +; --------------------------------------------------------------------------- + lda DDR2A ; Read data direction register for port 2A + ldx #$00 ; + rts ; Return DDR2A +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR2A: near +; --------------------------------------------------------------------------- + sta OR2A ; Write I/O register for port 2A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR2A: near +; --------------------------------------------------------------------------- + lda OR2A ; Read I/O register for port 2A + ldx #$00 ; + rts ; Return OR2A +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR2B: near +; --------------------------------------------------------------------------- + sta DDR2B ; Write data direction register for port 2B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR2B: near +; --------------------------------------------------------------------------- + lda DDR2B ; Read data direction register for port 2B + ldx #$00 ; + rts ; Return DDR2B +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR2B: near +; --------------------------------------------------------------------------- + sta OR2B ; Write I/O register for port 2B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR2B: near +; --------------------------------------------------------------------------- + lda OR2B ; Read I/O register for port 2B + ldx #$00 ; + rts ; Return OR2B +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR3A: near +; --------------------------------------------------------------------------- + sta DDR3A ; Write data direction register for port 3A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR3A: near +; --------------------------------------------------------------------------- + lda DDR3A ; Read data direction register for port 3A + ldx #$00 ; + rts ; Return DDR3A +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR3A: near +; --------------------------------------------------------------------------- + sta OR3A ; Write I/O register for port 3A + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR3A: near +; --------------------------------------------------------------------------- + lda OR3A ; Read I/O register for port 3A + ldx #$00 ; + rts ; Return OR3A +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_DDR3B: near +; --------------------------------------------------------------------------- + sta DDR3B ; Write data direction register for port 3B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_DDR3B: near +; --------------------------------------------------------------------------- + lda DDR3B ; Read data direction register for port 3B + ldx #$00 ; + rts ; Return DDR3B +; --------------------------------------------------------------------------- +.endproc + +.proc _set_IOR3B: near +; --------------------------------------------------------------------------- + sta OR3B ; Write I/O register for port 3B + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_IOR3B: near +; --------------------------------------------------------------------------- + lda OR3B ; Read I/O register for port 3B + ldx #$00 ; + rts ; Return OR3B +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/crt0.s b/libsrc/sym1/crt0.s new file mode 100644 index 000000000..a85887991 --- /dev/null +++ b/libsrc/sym1/crt0.s @@ -0,0 +1,65 @@ +; --------------------------------------------------------------------------- +; crt0.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + + .export _init, _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + + .import _main + .import initlib, donelib, copydata, zerobss + .import __RAM_START__, __RAM_SIZE__ ; Linker generated + .import __STACKSIZE__ ; Linker generated + + .include "zeropage.inc" + .include "sym1.inc" + +; --------------------------------------------------------------------------- +; Place the startup code in a special segment + +.segment "STARTUP" + +; --------------------------------------------------------------------------- +; A little light housekeeping + +_init: jsr ACCESS ; Unlock System RAM + cld ; Clear decimal mode +; --------------------------------------------------------------------------- +; Turn off console echo + + lda TECHO + and #$7F + sta TECHO +; --------------------------------------------------------------------------- +; Set cc65 argument stack pointer + + lda #<(__RAM_START__ + __RAM_SIZE__) + sta sp + lda #>(__RAM_START__ + __RAM_SIZE__) + sta sp+1 +; --------------------------------------------------------------------------- +; Initialize memory storage + + jsr zerobss ; Clear BSS segment + jsr copydata ; Initialize DATA segment + jsr initlib ; Run constructors +; --------------------------------------------------------------------------- +; Call main() + + jsr _main +; --------------------------------------------------------------------------- +; Back from main (this is also the _exit entry) + +_exit: jsr donelib ; Run destructors + lda TECHO + ora #$80 ; Re-enable console echo + sta TECHO + jsr NACCES ; Lock System RAM + rts ; Re-enter Sym-1 monitor +; --------------------------------------------------------------------------- + diff --git a/libsrc/sym1/display.s b/libsrc/sym1/display.s new file mode 100644 index 000000000..530435d87 --- /dev/null +++ b/libsrc/sym1/display.s @@ -0,0 +1,154 @@ +; --------------------------------------------------------------------------- +; display.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.export _fdisp, _set_D0, _get_D0 +.export _set_D1, _get_D1, _set_D2, _get_D2 +.export _set_D3, _get_D3, _set_D4, _get_D4 +.export _set_D5, _get_D5, _set_D6, _get_D6 + +.segment "CODE" + +.proc _fdisp: near +; --------------------------------------------------------------------------- + jsr SCAND ; Flash Display + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D0: near +; --------------------------------------------------------------------------- + sta DISBUF0 ; Write Digit 0 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D0: near +; --------------------------------------------------------------------------- + lda DISBUF0 ; Read Digit 0 + ldx #$00 ; + rts ; Return DISBUF0 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D1: near +; --------------------------------------------------------------------------- + sta DISBUF1 ; Write Digit 1 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D1: near +; --------------------------------------------------------------------------- + lda DISBUF1 ; Read Digit 1 + ldx #$00 ; + rts ; Return DISBUF1 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D2: near +; --------------------------------------------------------------------------- + sta DISBUF2 ; Write Digit 2 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D2: near +; --------------------------------------------------------------------------- + lda DISBUF2 ; Read Digit 2 + ldx #$00 ; + rts ; Return DISBUF2 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D3: near +; --------------------------------------------------------------------------- + sta DISBUF3 ; Write Digit 3 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D3: near +; --------------------------------------------------------------------------- + lda DISBUF3 ; Read Digit 3 + ldx #$00 ; + rts ; Return DISBUF3 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D4: near +; --------------------------------------------------------------------------- + sta DISBUF4 ; Write Digit 4 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D4: near +; --------------------------------------------------------------------------- + lda DISBUF4 ; Read Digit 4 + ldx #$00 ; + rts ; Return DISBUF4 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D5: near +; --------------------------------------------------------------------------- + sta DISBUF5 ; Write Digit 5 + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D5: near +; --------------------------------------------------------------------------- + lda DISBUF5 ; Read Digit 5 + ldx #$00 ; + rts ; Return DISBUF5 +; --------------------------------------------------------------------------- +.endproc + + +.proc _set_D6: near +; --------------------------------------------------------------------------- + sta DISBUF6 ; Write byte to the right of display + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc + +.proc _get_D6: near +; --------------------------------------------------------------------------- + lda DISBUF6 ; Read byte to the right of display + ldx #$00 ; + rts ; Return DISBUF6 +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/getchar.s b/libsrc/sym1/getchar.s new file mode 100644 index 000000000..d82519ce0 --- /dev/null +++ b/libsrc/sym1/getchar.s @@ -0,0 +1,21 @@ +; --------------------------------------------------------------------------- +; getchar.s +; +; for Sym-1 +; +; Wayne Parham +; --------------------------------------------------------------------------- + +.include "sym1.inc" +.export _getchar + +.segment "CODE" + +.proc _getchar: near +; --------------------------------------------------------------------------- + jsr INTCHR ; Get character using Monitor ROM call + and #$7F ; Strip off top bit + ldx #$00 ; + rts ; Return char +; --------------------------------------------------------------------------- +.endproc diff --git a/libsrc/sym1/libref.s b/libsrc/sym1/libref.s new file mode 100644 index 000000000..9356d18dc --- /dev/null +++ b/libsrc/sym1/libref.s @@ -0,0 +1,3 @@ + + .import _exit + diff --git a/libsrc/sym1/putchar.s b/libsrc/sym1/putchar.s new file mode 100644 index 000000000..1b84416fe --- /dev/null +++ b/libsrc/sym1/putchar.s @@ -0,0 +1,23 @@ +; --------------------------------------------------------------------------- +; putchar.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" +.export _putchar + +.segment "CODE" + +.proc _putchar: near +; --------------------------------------------------------------------------- + jsr OUTCHR ; Send character using Monitor ROM call + lda #$00 ; + ldx #$00 ; + rts ; Return 0000 +; --------------------------------------------------------------------------- +.endproc diff --git a/libsrc/sym1/read.s b/libsrc/sym1/read.s new file mode 100644 index 000000000..f0b0194d2 --- /dev/null +++ b/libsrc/sym1/read.s @@ -0,0 +1,54 @@ +; --------------------------------------------------------------------------- +; read.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.import popax, popptr1 +.importzp ptr1, ptr2, ptr3 + +.export _read + +.proc _read +; --------------------------------------------------------------------------- + sta ptr3 + stx ptr3+1 ; Count in ptr3 + inx + stx ptr2+1 ; Increment and store in ptr2 + tax + inx + stx ptr2 + jsr popptr1 ; Buffer address in ptr1 + jsr popax + +begin: dec ptr2 + bne getch + dec ptr2+1 + beq done ; If buffer full, return + +getch: jsr INTCHR ; Get character using Monitor ROM call + jsr OUTCHR ; Echo it + and #$7F ; Clear hi bit and check for '\r' + cmp #$0D + bne putch + lda #$0A ; Replace with '\n' and set count to zero + +putch: ldy #$00 ; Put char into return buffer + sta (ptr1),y + inc ptr1 ; Increment pointer + bne begin + inc ptr1+1 + bne begin + +done: lda ptr3 + ldx ptr3+1 + rts ; Return count +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/tapeio.s b/libsrc/sym1/tapeio.s new file mode 100644 index 000000000..3a0c1fa5b --- /dev/null +++ b/libsrc/sym1/tapeio.s @@ -0,0 +1,58 @@ +; --------------------------------------------------------------------------- +; tapeio.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.import popax + +.export _loadt, _dumpt + +.segment "CODE" + +.proc _loadt: near +; --------------------------------------------------------------------------- + sta P1L ; Tape record ID to P1L + ldx #$00 + stx P1H + ldy #$80 + jsr LOADT ; Read data from tape + bcs error + lda #$00 + ldx #$00 ; Return 0000 if successful + jmp done +error: ldx #$00 + lda #$FF ; or 00FF if not +done: rts +; --------------------------------------------------------------------------- +.endproc + +.proc _dumpt: near +; --------------------------------------------------------------------------- + sta P3L ; End address + stx P3H + jsr popax + sta P2L ; Start address + stx P2H + jsr popax + sta P1L ; Tape Record ID + ldx #$00 + stx P1H + ldy #$80 + jsr DUMPT ; Write data to tape + bcs error + lda #$00 + ldx #$00 ; Return 0000 if successful + jmp done +error: ldx #$00 + lda #$FF ; or 00FF if not +done: rts +; --------------------------------------------------------------------------- +.endproc + diff --git a/libsrc/sym1/write.s b/libsrc/sym1/write.s new file mode 100644 index 000000000..843dddf1f --- /dev/null +++ b/libsrc/sym1/write.s @@ -0,0 +1,53 @@ +; --------------------------------------------------------------------------- +; write.s +; +; for Sym-1 +; +; Wayne Parham +; +; wayne@parhamdata.com +; --------------------------------------------------------------------------- + +.include "sym1.inc" + +.import popax, popptr1 +.importzp ptr1, ptr2, ptr3, tmp1 + +.export _write + +.proc _write +; --------------------------------------------------------------------------- + sta ptr3 + stx ptr3+1 ; Count in ptr3 + inx + stx ptr2+1 ; Increment and store in ptr2 + tax + inx + stx ptr2 + jsr popptr1 ; Buffer address in ptr1 + jsr popax + +begin: dec ptr2 + bne outch + dec ptr2+1 + beq done + +outch : ldy #0 + lda (ptr1),y + jsr OUTCHR ; Send character using Monitor call + cmp #$0A + bne next + lda #$0D ; If it is LF, add CR + jsr OUTCHR + +next: inc ptr1 + bne begin + inc ptr1+1 + jmp begin + +done: lda ptr3 + ldx ptr3+1 + rts ; Return count +; --------------------------------------------------------------------------- +.endproc + diff --git a/samples/symDisplay.c b/samples/symDisplay.c new file mode 100644 index 000000000..41eaf8b49 --- /dev/null +++ b/samples/symDisplay.c @@ -0,0 +1,384 @@ +// -------------------------------------------------------------------------- +// Sym-1 front panel display example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include + +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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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; +} diff --git a/samples/symHello.c b/samples/symHello.c new file mode 100644 index 000000000..99b4c57df --- /dev/null +++ b/samples/symHello.c @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------- +// Hello World for Sym-1 +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; + +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; +} diff --git a/samples/symIO.c b/samples/symIO.c new file mode 100644 index 000000000..c52a71b11 --- /dev/null +++ b/samples/symIO.c @@ -0,0 +1,170 @@ +// -------------------------------------------------------------------------- +// Sym-1 digital I/O interface example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; +#include ; +#include ; +#include ; + +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; +} diff --git a/samples/symTiny.c b/samples/symTiny.c new file mode 100644 index 000000000..b82e952ac --- /dev/null +++ b/samples/symTiny.c @@ -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 ; + +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; +} diff --git a/samples/tutorial/sym1/build b/samples/tutorial/sym1/build new file mode 100644 index 000000000..6688da0a3 --- /dev/null +++ b/samples/tutorial/sym1/build @@ -0,0 +1,36 @@ +#!/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 + diff --git a/samples/tutorial/sym1/build_32k b/samples/tutorial/sym1/build_32k new file mode 100644 index 000000000..555bda0b4 --- /dev/null +++ b/samples/tutorial/sym1/build_32k @@ -0,0 +1,36 @@ +#!/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 + diff --git a/samples/tutorial/sym1/build_4k b/samples/tutorial/sym1/build_4k new file mode 100644 index 000000000..502bb6aa9 --- /dev/null +++ b/samples/tutorial/sym1/build_4k @@ -0,0 +1,36 @@ +#!/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 + diff --git a/samples/tutorial/sym1/clean b/samples/tutorial/sym1/clean new file mode 100644 index 000000000..c0d77390e --- /dev/null +++ b/samples/tutorial/sym1/clean @@ -0,0 +1,14 @@ +#!/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 + diff --git a/samples/tutorial/sym1/readme.txt b/samples/tutorial/sym1/readme.txt new file mode 100644 index 000000000..74bcb5527 --- /dev/null +++ b/samples/tutorial/sym1/readme.txt @@ -0,0 +1,11 @@ +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 (don't include the .c extension) + clean (removes intermediate and output files) + diff --git a/samples/tutorial/sym1/symDisplay.c b/samples/tutorial/sym1/symDisplay.c new file mode 100644 index 000000000..41eaf8b49 --- /dev/null +++ b/samples/tutorial/sym1/symDisplay.c @@ -0,0 +1,384 @@ +// -------------------------------------------------------------------------- +// Sym-1 front panel display example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include + +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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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( get_D6() ); + set_D6( DISP_M_1 ); + for( d = 0; d < flashes ; d++ ) { + fdisp(); // Display + } + 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; +} diff --git a/samples/tutorial/sym1/symHello.c b/samples/tutorial/sym1/symHello.c new file mode 100644 index 000000000..99b4c57df --- /dev/null +++ b/samples/tutorial/sym1/symHello.c @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------- +// Hello World for Sym-1 +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; + +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; +} diff --git a/samples/tutorial/sym1/symIO.c b/samples/tutorial/sym1/symIO.c new file mode 100644 index 000000000..c52a71b11 --- /dev/null +++ b/samples/tutorial/sym1/symIO.c @@ -0,0 +1,170 @@ +// -------------------------------------------------------------------------- +// Sym-1 digital I/O interface example +// +// Wayne Parham +// +// wayne@parhamdata.com +// -------------------------------------------------------------------------- + +#include ; +#include ; +#include ; +#include ; + +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; +} diff --git a/samples/tutorial/sym1/symTiny.c b/samples/tutorial/sym1/symTiny.c new file mode 100644 index 000000000..b82e952ac --- /dev/null +++ b/samples/tutorial/sym1/symTiny.c @@ -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 ; + +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; +}