1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-10 19:29:45 +00:00

Changes to I/O access

This commit is contained in:
Wayne Parham 2021-06-09 10:23:42 -05:00
parent 2a25921515
commit 7d6541274d
8 changed files with 219 additions and 583 deletions

View File

@ -91,6 +91,30 @@
#define DISP_LOW_LEFT 0x10 // Lower left segment #define DISP_LOW_LEFT 0x10 // Lower left segment
/*****************************************************************************/
/* Hardware */
/*****************************************************************************/
#include <_6522.h>
#define VIA1 (*(struct __6522*)0xA000) // U25
#define VIA2 (*(struct __6522*)0xA800) // U28
#define VIA3 (*(struct __6522*)0xAC00) // U29
struct _display {
unsigned char d0; // left-most seven-segment display
unsigned char d1; // second seven-segment display
unsigned char d2; // third seven-segment display
unsigned char d3; // fouth seven-segment display
unsigned char d4; // fifth seven-segment display
unsigned char d5; // sixth seven-segment display
unsigned char d6; // buffer byte to the right
};
#define DISPLAY (*(struct _display*)0xA640)
/*****************************************************************************/ /*****************************************************************************/
/* Code */ /* Code */
@ -98,55 +122,10 @@
int __fastcall__ beep (void); // Beep sound void beep (void); // Beep sound
void __fastcall__ set_D0 (unsigned char); // Set display digit 0 void fdisp (void); // Flash display
unsigned char __fastcall__ get_D0 (void); // Get value of display digit 0 int __fastcall__ loadt (unsigned char); // Read from tape (id)
void __fastcall__ set_D1 (unsigned char); // Set display digit 1 int __fastcall__ dumpt (unsigned char, const void*, const void*); // Write to tape (id, start_addr, end_addr)
unsigned char __fastcall__ get_D1 (void); // Get value of display digit 1
void __fastcall__ set_D2 (unsigned char); // Set display digit 2
unsigned char __fastcall__ get_D2 (void); // Get value of display digit 2
void __fastcall__ set_D3 (unsigned char); // Set display digit 3
unsigned char __fastcall__ get_D3 (void); // Get value of display digit 3
void __fastcall__ set_D4 (unsigned char); // Set display digit 4
unsigned char __fastcall__ get_D4 (void); // Get value of display digit 4
void __fastcall__ set_D5 (unsigned char); // Set display digit 5
unsigned char __fastcall__ get_D5 (void); // Get value of display digit 5
void __fastcall__ set_D6 (unsigned char); // Set byte to the right of display (leading buffer)
unsigned char __fastcall__ get_D6 (void); // Get value of memory byte to the right of display
void __fastcall__ fdisp (void); // Flash display
int __fastcall__ loadt (int); // Read from tape (id)
int __fastcall__ dumpt (int, int, int); // Write to tape (id, start_addr, end_addr)
void __fastcall__ set_DDR1A (unsigned char); // Set data direction register 1A (U25)
unsigned char __fastcall__ get_DDR1A (void); // Get value of data direction register 1A
void __fastcall__ set_IOR1A (unsigned char); // Set I/O register 1A
unsigned char __fastcall__ get_IOR1A (void); // Get value of I/O register 1A
void __fastcall__ set_DDR1B (unsigned char); // Set data direction register 1B (U25)
unsigned char __fastcall__ get_DDR1B (void); // Get value of data direction register 1B
void __fastcall__ set_IOR1B (unsigned char); // Set I/O register 1B
unsigned char __fastcall__ get_IOR1B (void); // Get value of I/O register 1B
void __fastcall__ set_DDR2A (unsigned char); // Set data direction register 2A (U28)
unsigned char __fastcall__ get_DDR2A (void); // Get value of data direction register 2A
void __fastcall__ set_IOR2A (unsigned char); // Set I/O register 2A
unsigned char __fastcall__ get_IOR2A (void); // Get value of I/O register 2A
void __fastcall__ set_DDR2B (unsigned char); // Set data direction register 2B (U28)
unsigned char __fastcall__ get_DDR2B (void); // Get value of data direction register 2B
void __fastcall__ set_IOR2B (unsigned char); // Set I/O register 2B
unsigned char __fastcall__ get_IOR2B (void); // Get value of I/O register 2B
void __fastcall__ set_DDR3A (unsigned char); // Set data direction register 3A (U29)
unsigned char __fastcall__ get_DDR3A (void); // Get value of data direction register 3A
void __fastcall__ set_IOR3A (unsigned char); // Set I/O register 3A
unsigned char __fastcall__ get_IOR3A (void); // Get value of I/O register 3A
void __fastcall__ set_DDR3B (unsigned char); // Set data direction register 3B (U29)
unsigned char __fastcall__ get_DDR3B (void); // Get value of data direction register 3B
void __fastcall__ set_IOR3B (unsigned char); // Set I/O register 3B
unsigned char __fastcall__ get_IOR3B (void); // Get value of I/O register 3B

View File

@ -1,220 +0,0 @@
;
; Wayne Parham (wayne@parhamdata.com)
;
; void set_DDR1A (int value);
; int get_DDR1A (void);
; void set_IOR1A (int value);
; int get_IOR1A (void);
; void set_DDR1B (int value);
; int get_DDR1B (void);
; void set_IOR1B (int value);
; int get_IOR1B (void);
; void set_DDR2A (int value);
; int get_DDR2A (void);
; void set_IOR2A (int value);
; int get_IOR2A (void);
; void set_DDR2B (int value);
; int get_DDR2B (void);
; void set_IOR2B (int value);
; int get_IOR2B (void);
; void set_DDR3A (int value);
; int get_DDR3A (void);
; void set_IOR3A (int value);
; int get_IOR3A (void);
; void set_DDR3B (int value);
; int get_DDR3B (void);
; void set_IOR3B (int value);
; int get_IOR3B (void);
;
.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
rts
.endproc
.proc _get_DDR1A: near
lda DDR1A ; Read data direction register for port 1A
ldx #>$0000 ;
rts ; Return DDR1A
.endproc
.proc _set_IOR1A: near
sta OR1A ; Write I/O register for port 1A
rts
.endproc
.proc _get_IOR1A: near
lda OR1A ; Read I/O register for port 1A
ldx #>$0000 ;
rts ; Return OR1A
.endproc
.proc _set_DDR1B: near
sta DDR1B ; Write data direction register for port 1B
rts
.endproc
.proc _get_DDR1B: near
lda DDR1B ; Read data direction register for port 1B
ldx #>$0000 ;
rts ; Return DDR1B
.endproc
.proc _set_IOR1B: near
sta OR1B ; Write I/O register for port 1B
rts
.endproc
.proc _get_IOR1B: near
lda OR1B ; Read I/O register for port 1B
ldx #>$0000 ;
rts ; Return OR1B
.endproc
.proc _set_DDR2A: near
sta DDR2A ; Write data direction register for port 2A
rts
.endproc
.proc _get_DDR2A: near
lda DDR2A ; Read data direction register for port 2A
ldx #>$0000 ;
rts ; Return DDR2A
.endproc
.proc _set_IOR2A: near
sta OR2A ; Write I/O register for port 2A
rts
.endproc
.proc _get_IOR2A: near
lda OR2A ; Read I/O register for port 2A
ldx #>$0000 ;
rts ; Return OR2A
.endproc
.proc _set_DDR2B: near
sta DDR2B ; Write data direction register for port 2B
rts
.endproc
.proc _get_DDR2B: near
lda DDR2B ; Read data direction register for port 2B
ldx #>$0000 ;
rts ; Return DDR2B
.endproc
.proc _set_IOR2B: near
sta OR2B ; Write I/O register for port 2B
rts
.endproc
.proc _get_IOR2B: near
lda OR2B ; Read I/O register for port 2B
ldx #>$0000 ;
rts ; Return OR2B
.endproc
.proc _set_DDR3A: near
sta DDR3A ; Write data direction register for port 3A
rts
.endproc
.proc _get_DDR3A: near
lda DDR3A ; Read data direction register for port 3A
ldx #>$0000 ;
rts ; Return DDR3A
.endproc
.proc _set_IOR3A: near
sta OR3A ; Write I/O register for port 3A
rts ; Return 0000
.endproc
.proc _get_IOR3A: near
lda OR3A ; Read I/O register for port 3A
ldx #>$0000 ;
rts ; Return OR3A
.endproc
.proc _set_DDR3B: near
sta DDR3B ; Write data direction register for port 3B
rts
.endproc
.proc _get_DDR3B: near
lda DDR3B ; Read data direction register for port 3B
ldx #>$0000 ;
rts ; Return DDR3B
.endproc
.proc _set_IOR3B: near
sta OR3B ; Write I/O register for port 3B
rts
.endproc
.proc _get_IOR3B: near
lda OR3B ; Read I/O register for port 3B
ldx #>$0000 ;
rts ; Return OR3B
.endproc

View File

@ -1,29 +1,12 @@
; ;
; Wayne Parham (wayne@parhamdata.com) ; Wayne Parham (wayne@parhamdata.com)
; ;
; int fdisp (void); ; void fdisp (void);
; void set_D0 (char segments);
; int get_D0 (void);
; void set_D1 (char segments);
; int get_D1 (void);
; void set_D2 (char segments);
; int get_D2 (void);
; void set_D3 (char segments);
; int get_D3 (void);
; void set_D4 (char segments);
; int get_D4 (void);
; void set_D5 (char segments);
; int get_D5 (void);
; void set_D6 (char segments);
; int get_D6 (void);
; ;
.include "sym1.inc" .include "sym1.inc"
.export _fdisp, _set_D0, _get_D0 .export _fdisp
.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" .segment "CODE"
@ -34,108 +17,3 @@
.endproc .endproc
.proc _set_D0: near
sta DISBUF0 ; Write Digit 0
rts
.endproc
.proc _get_D0: near
lda DISBUF0 ; Read Digit 0
ldx #>$0000 ;
rts ; Return DISBUF0
.endproc
.proc _set_D1: near
sta DISBUF1 ; Write Digit 1
rts
.endproc
.proc _get_D1: near
lda DISBUF1 ; Read Digit 1
ldx #>$0000 ;
rts
.endproc
.proc _set_D2: near
sta DISBUF2 ; Write Digit 2
rts
.endproc
.proc _get_D2: near
lda DISBUF2 ; Read Digit 2
ldx #>$0000 ;
rts ; Return DISBUF2
.endproc
.proc _set_D3: near
sta DISBUF3 ; Write Digit 3
rts
.endproc
.proc _get_D3: near
lda DISBUF3 ; Read Digit 3
ldx #>$0000 ;
rts ; Return DISBUF3
.endproc
.proc _set_D4: near
sta DISBUF4 ; Write Digit 4
rts
.endproc
.proc _get_D4: near
lda DISBUF4 ; Read Digit 4
ldx #>$0000 ;
rts ; Return DISBUF4
.endproc
.proc _set_D5: near
sta DISBUF5 ; Write Digit 5
rts
.endproc
.proc _get_D5: near
lda DISBUF5 ; Read Digit 5
ldx #>$0000 ;
rts ; Return DISBUF5
.endproc
.proc _set_D6: near
sta DISBUF6 ; Write byte to the right of display
rts
.endproc
.proc _get_D6: near
lda DISBUF6 ; Read byte to the right of display
ldx #>$0000 ;
rts ; Return DISBUF6
.endproc

View File

@ -29,7 +29,11 @@ begin: dec ptr2
beq done ; If buffer full, return beq done ; If buffer full, return
getch: jsr INTCHR ; Get character using Monitor ROM call getch: jsr INTCHR ; Get character using Monitor ROM call
and #$7F ; Clear hi bit 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 putch: ldy #$00 ; Put char into return buffer
sta (ptr1),y sta (ptr1),y

View File

@ -25,9 +25,8 @@ void main (void) {
puts( "\nType a message (40 chars max) and press ENTER, please:\n" ); puts( "\nType a message (40 chars max) and press ENTER, please:\n" );
while( (c != '\r') && (i < 41) ) { while( (c != '\n') && (i < 40) ) {
c = getchar(); c = getchar();
putchar( c );
buffer[i] = c; buffer[i] = c;
i++; i++;
if( i == 40 ) { if( i == 40 ) {
@ -40,7 +39,6 @@ void main (void) {
while( z == 0 ) { while( z == 0 ) {
puts( "\n\nHow many times (0 for forever) to repeat?" ); puts( "\n\nHow many times (0 for forever) to repeat?" );
c = getchar(); c = getchar();
putchar( c );
if( (c >= '0') && (c <= '9') ) { // between 1 and 9 loops allowed if( (c >= '0') && (c <= '9') ) { // between 1 and 9 loops allowed
z = 1; // a number was pressed z = 1; // a number was pressed
t = c - '0'; // convert char to int t = c - '0'; // convert char to int
@ -59,14 +57,13 @@ void main (void) {
putchar( '\r' ); // Send CR to console putchar( '\r' ); // Send CR to console
DISPLAY.d0 = DISP_SPACE; // Clear the display
set_D0( DISP_SPACE ); // Clear the display DISPLAY.d1 = DISP_SPACE;
set_D1( DISP_SPACE ); DISPLAY.d2 = DISP_SPACE;
set_D2( DISP_SPACE ); DISPLAY.d3 = DISP_SPACE;
set_D3( DISP_SPACE ); DISPLAY.d4 = DISP_SPACE;
set_D4( DISP_SPACE ); DISPLAY.d5 = DISP_SPACE;
set_D5( DISP_SPACE ); DISPLAY.d6 = DISP_SPACE;
set_D6( DISP_SPACE );
for( d = 0; d < flashes ; d++ ) { for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display fdisp(); // Display
@ -78,247 +75,247 @@ void main (void) {
switch( buffer[l] ) { // Put the typed charaters switch( buffer[l] ) { // Put the typed charaters
case '1': // into the display buffer case '1': // into the display buffer
set_D6( DISP_1 ); // one at a time DISPLAY.d6 = DISP_1; // one at a time
break; break;
case '2': case '2':
set_D6( DISP_2 ); DISPLAY.d6 = DISP_2;
break; break;
case '3': case '3':
set_D6( DISP_3 ); DISPLAY.d6 = DISP_3;
break; break;
case '4': case '4':
set_D6( DISP_4 ); DISPLAY.d6 = DISP_4;
break; break;
case '5': case '5':
set_D6( DISP_5 ); DISPLAY.d6 = DISP_5;
break; break;
case '6': case '6':
set_D6( DISP_6 ); DISPLAY.d6 = DISP_6;
break; break;
case '7': case '7':
set_D6( DISP_7 ); DISPLAY.d6 = DISP_7;
break; break;
case '8': case '8':
set_D6( DISP_8 ); DISPLAY.d6 = DISP_8;
break; break;
case '9': case '9':
set_D6( DISP_9 ); DISPLAY.d6 = DISP_9;
break; break;
case '0': case '0':
set_D6( DISP_0 ); DISPLAY.d6 = DISP_0;
break; break;
case 'A': case 'A':
set_D6( DISP_A ); DISPLAY.d6 = DISP_A;
break; break;
case 'a': case 'a':
set_D6( DISP_A ); DISPLAY.d6 = DISP_A;
break; break;
case 'B': case 'B':
set_D6( DISP_b ); DISPLAY.d6 = DISP_b;
break; break;
case 'b': case 'b':
set_D6( DISP_b ); DISPLAY.d6 = DISP_b;
break; break;
case 'C': case 'C':
set_D6( DISP_C ); DISPLAY.d6 = DISP_C;
break; break;
case 'c': case 'c':
set_D6( DISP_c ); DISPLAY.d6 = DISP_c;
break; break;
case 'D': case 'D':
set_D6( DISP_d ); DISPLAY.d6 = DISP_d;
break; break;
case 'd': case 'd':
set_D6( DISP_d ); DISPLAY.d6 = DISP_d;
break; break;
case 'E': case 'E':
set_D6( DISP_E ); DISPLAY.d6 = DISP_E;
break; break;
case 'e': case 'e':
set_D6( DISP_e ); DISPLAY.d6 = DISP_e;
break; break;
case 'F': case 'F':
set_D6( DISP_F ); DISPLAY.d6 = DISP_F;
break; break;
case 'f': case 'f':
set_D6( DISP_F ); DISPLAY.d6 = DISP_F;
break; break;
case 'G': case 'G':
set_D6( DISP_G ); DISPLAY.d6 = DISP_G;
break; break;
case 'g': case 'g':
set_D6( DISP_g ); DISPLAY.d6 = DISP_g;
break; break;
case 'H': case 'H':
set_D6( DISP_H ); DISPLAY.d6 = DISP_H;
break; break;
case 'h': case 'h':
set_D6( DISP_h ); DISPLAY.d6 = DISP_h;
break; break;
case 'I': case 'I':
set_D6( DISP_I ); DISPLAY.d6 = DISP_I;
break; break;
case 'i': case 'i':
set_D6( DISP_i ); DISPLAY.d6 = DISP_i;
break; break;
case 'J': case 'J':
set_D6( DISP_J ); DISPLAY.d6 = DISP_J;
break; break;
case 'j': case 'j':
set_D6( DISP_J ); DISPLAY.d6 = DISP_J;
break; break;
case 'K': case 'K':
set_D6( DISP_K ); DISPLAY.d6 = DISP_K;
break; break;
case 'k': case 'k':
set_D6( DISP_K ); DISPLAY.d6 = DISP_K;
break; break;
case 'L': case 'L':
set_D6( DISP_L ); DISPLAY.d6 = DISP_L;
break; break;
case 'l': case 'l':
set_D6( DISP_L ); DISPLAY.d6 = DISP_L;
break; break;
case 'M': case 'M':
set_D0( get_D1() ); DISPLAY.d0 = DISPLAY.d1;
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_M_1 ); DISPLAY.d5 = DISP_M_1;
set_D6( DISP_M_2 ); DISPLAY.d6 = DISP_M_2;
break; break;
case 'm': case 'm':
set_D0( get_D1() ); DISPLAY.d0 = DISPLAY.d1;
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_M_1 ); DISPLAY.d5 = DISP_M_1;
set_D6( DISP_M_2 ); DISPLAY.d6 = DISP_M_2;
break; break;
case 'N': case 'N':
set_D6( DISP_n ); DISPLAY.d6 = DISP_n;
break; break;
case 'n': case 'n':
set_D6( DISP_n ); DISPLAY.d6 = DISP_n;
break; break;
case 'O': case 'O':
set_D6( DISP_O ); DISPLAY.d6 = DISP_O;
break; break;
case 'o': case 'o':
set_D6( DISP_o ); DISPLAY.d6 = DISP_o;
break; break;
case 'P': case 'P':
set_D6( DISP_P ); DISPLAY.d6 = DISP_P;
break; break;
case 'p': case 'p':
set_D6( DISP_P ); DISPLAY.d6 = DISP_P;
break; break;
case 'Q': case 'Q':
set_D6( DISP_q ); DISPLAY.d6 = DISP_q;
break; break;
case 'q': case 'q':
set_D6( DISP_q ); DISPLAY.d6 = DISP_q;
break; break;
case 'R': case 'R':
set_D6( DISP_r ); DISPLAY.d6 = DISP_r;
break; break;
case 'r': case 'r':
set_D6( DISP_r ); DISPLAY.d6 = DISP_r;
break; break;
case 'S': case 'S':
set_D6( DISP_S ); DISPLAY.d6 = DISP_S;
break; break;
case 's': case 's':
set_D6( DISP_S ); DISPLAY.d6 = DISP_S;
break; break;
case 'T': case 'T':
set_D6( DISP_t ); DISPLAY.d6 = DISP_t;
break; break;
case 't': case 't':
set_D6( DISP_t ); DISPLAY.d6 = DISP_t;
break; break;
case 'U': case 'U':
set_D6( DISP_U ); DISPLAY.d6 = DISP_U;
break; break;
case 'u': case 'u':
set_D6( DISP_u ); DISPLAY.d6 = DISP_u;
break; break;
case 'V': case 'V':
set_D0( get_D1() ); DISPLAY.d0 = DISPLAY.d1;
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_V_1 ); DISPLAY.d5 = DISP_V_1;
set_D6( DISP_V_2 ); DISPLAY.d6 = DISP_V_2;
break; break;
case 'v': case 'v':
set_D0( get_D1() ); DISPLAY.d0 = DISPLAY.d1;
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_V_1 ); DISPLAY.d5 = DISP_V_1;
set_D6( DISP_V_2 ); DISPLAY.d6 = DISP_V_2;
break; break;
case 'W': case 'W':
set_D0( get_D1() ); DISPLAY.d0 = DISPLAY.d1;
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_W_1 ); DISPLAY.d5 = DISP_W_1;
set_D6( DISP_W_2 ); DISPLAY.d6 = DISP_W_2;
break; break;
case 'w': case 'w':
set_D0( get_D1() ); DISPLAY.d0 = DISPLAY.d1;
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_W_1 ); DISPLAY.d5 = DISP_W_1;
set_D6( DISP_W_2 ); DISPLAY.d6 = DISP_W_2;
break; break;
case 'Y': case 'Y':
set_D6( DISP_Y ); DISPLAY.d6 = DISP_Y;
break; break;
case 'y': case 'y':
set_D6( DISP_Y ); DISPLAY.d6 = DISP_Y;
break; break;
case 'Z': case 'Z':
set_D6( DISP_Z ); DISPLAY.d6 = DISP_Z;
break; break;
case 'z': case 'z':
set_D6( DISP_Z ); DISPLAY.d6 = DISP_Z;
break; break;
case ' ': case ' ':
set_D6( DISP_SPACE ); DISPLAY.d6 = DISP_SPACE;
break; break;
case '.': case '.':
set_D6( DISP_PERIOD ); DISPLAY.d6 = DISP_PERIOD;
break; break;
case '-': case '-':
set_D6( DISP_HYPHEN ); DISPLAY.d6 = DISP_HYPHEN;
break; break;
case '\'': case '\'':
set_D6( DISP_APOSTR ); DISPLAY.d6 = DISP_APOSTR;
break; break;
case '"': case '"':
set_D6( DISP_APOSTR ); DISPLAY.d6 = DISP_APOSTR;
break; break;
case '=': case '=':
set_D6( DISP_EQUAL ); DISPLAY.d6 = DISP_EQUAL;
break; break;
case '_': case '_':
set_D6( DISP_BOTTOM ); DISPLAY.d6 = DISP_BOTTOM;
break; break;
case '/': case '/':
set_D6( DISP_SLASH ); DISPLAY.d6 = DISP_SLASH;
break; break;
case '\\': case '\\':
set_D6( DISP_BACKSLASH ); DISPLAY.d6 = DISP_BACKSLASH;
break; break;
default: default:
displayable = 0; // Character not mapped displayable = 0; // Character not mapped
@ -328,12 +325,12 @@ void main (void) {
putchar( buffer[l] ); // Send it to the console putchar( buffer[l] ); // Send it to the console
set_D0( get_D1() ); // Scroll to the left DISPLAY.d0 = DISPLAY.d1; // Scroll to the left
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( get_D6() ); DISPLAY.d5 = DISPLAY.d6;
for( d = 0; d < flashes ; d++ ) { for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display fdisp(); // Display
@ -342,13 +339,13 @@ void main (void) {
} }
for( e = 0; e < 6; e++ ) { // Gradually fill the for( e = 0; e < 6; e++ ) { // Gradually fill the
set_D0( get_D1() ); // display with spaces DISPLAY.d0 = DISPLAY.d1; // display with spaces
set_D1( get_D2() ); DISPLAY.d1 = DISPLAY.d2;
set_D2( get_D3() ); DISPLAY.d2 = DISPLAY.d3;
set_D3( get_D4() ); DISPLAY.d3 = DISPLAY.d4;
set_D4( get_D5() ); DISPLAY.d4 = DISPLAY.d5;
set_D5( DISP_SPACE ); DISPLAY.d5 = DISP_SPACE;
set_D6( DISP_SPACE ); DISPLAY.d6 = DISP_SPACE;
for( d = 0; d < flashes ; d++ ) { for( d = 0; d < flashes ; d++ ) {
fdisp(); // Display fdisp(); // Display
} }

View File

@ -23,9 +23,8 @@ void main(void) {
} }
printf( "Type a line and press ENTER, please.\n\n" ); printf( "Type a line and press ENTER, please.\n\n" );
while( c != '\r' ) { while( c != '\n' ) {
c = getchar(); c = getchar();
putchar( c );
} }
printf( "\n\nThanks!\n\n" ); printf( "\n\nThanks!\n\n" );

View File

@ -12,24 +12,24 @@
#include <string.h> #include <string.h>
void main(void) { void main(void) {
int ddr1a = 0x00; unsigned char ddr1a = 0x00;
int ior1a = 0x00; unsigned char ior1a = 0x00;
int ddr1b = 0x00; unsigned char ddr1b = 0x00;
int ior1b = 0x00; unsigned char ior1b = 0x00;
int ddr2a = 0x00; unsigned char ddr2a = 0x00;
int ior2a = 0x00; unsigned char ior2a = 0x00;
int ddr2b = 0x00; unsigned char ddr2b = 0x00;
int ior2b = 0x00; unsigned char ior2b = 0x00;
int ddr3a = 0x00; unsigned char ddr3a = 0x00;
int ior3a = 0x00; unsigned char ior3a = 0x00;
int ddr3b = 0x00; unsigned char ddr3b = 0x00;
int ior3b = 0x00; unsigned char ior3b = 0x00;
int l = 0x00; unsigned char val = 0x00;
int val = 0x00; int going = 0x01;
int going = 0x01; int instr = 0x01;
int instr = 0x01; int l = 0x00;
char* vp = 0x00; char* vp = 0x00;
char cmd[20] = { 0x00 }; char cmd[20] = { 0x00 };
while( going ) { while( going ) {
@ -38,18 +38,18 @@ void main(void) {
putchar( '\n' ); putchar( '\n' );
} }
ddr1a = get_DDR1A(); ddr1a = VIA1.ddra;
ior1a = get_IOR1A(); ior1a = VIA1.pra;
ddr1b = get_DDR1B(); ddr1b = VIA1.ddrb;
ior1b = get_IOR1B(); ior1b = VIA1.prb;
ddr2a = get_DDR2A(); ddr2a = VIA2.ddra;
ior2a = get_IOR2A(); ior2a = VIA2.pra;
ddr2b = get_DDR2B(); ddr2b = VIA2.ddrb;
ior2b = get_IOR2B(); ior2b = VIA2.prb;
ddr3a = get_DDR3A(); ddr3a = VIA3.ddra;
ior3a = get_IOR3A(); ior3a = VIA3.pra;
ddr3b = get_DDR3B(); ddr3b = VIA3.ddrb;
ior3b = get_IOR3B(); ior3b = VIA3.prb;
puts( "================== Digital I/O Status ==================" ); puts( "================== Digital I/O Status ==================" );
puts( " Port1A Port1B Port2A Port2B Port3A Port3B" ); puts( " Port1A Port1B Port2A Port2B Port3A Port3B" );
@ -63,7 +63,7 @@ void main(void) {
puts( "bits off and the bottom three on, type 'IOR2A 07'." ); puts( "bits off and the bottom three on, type 'IOR2A 07'." );
puts( "Press ENTER without any command to see register values" ); puts( "Press ENTER without any command to see register values" );
puts( "without changing any of them. Type 'help' to see these" ); puts( "without changing any of them. Type 'help' to see these" );
puts( "instructions again and type 'stop' to end the program.\n"); puts( "instructions again and type 'quit' to end the program.\n");
puts( "Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A" ); puts( "Available registers: DDR1A, IOR1A, DDR1B, IOR1B, DDR2A" );
puts( "IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B." ); puts( "IOR2A, DDR2B, IOR2B, DDR3A, IOR3A, DDR3B and IOR3B." );
instr = 0; instr = 0;
@ -74,7 +74,7 @@ void main(void) {
fgets(cmd, sizeof(cmd)-1, stdin); fgets(cmd, sizeof(cmd)-1, stdin);
cmd[strlen(cmd)-1] = '\0'; cmd[strlen(cmd)-1] = '\0';
if( strncasecmp(cmd, "stop", 4) == 0) { if( strncasecmp(cmd, "quit", 4) == 0) {
going = 0; going = 0;
} }
else if( strncasecmp(cmd, "help", 4) == 0) { else if( strncasecmp(cmd, "help", 4) == 0) {
@ -83,85 +83,85 @@ void main(void) {
else if( strncasecmp(cmd, "ddr1a", 5) == 0) { else if( strncasecmp(cmd, "ddr1a", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_DDR1A( val ); VIA1.ddra = val;
} }
} }
else if( strncasecmp(cmd, "ior1a", 5) == 0) { else if( strncasecmp(cmd, "ior1a", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_IOR1A( val ); VIA1.pra = val;
} }
} }
else if( strncasecmp(cmd, "ddr1b", 5) == 0) { else if( strncasecmp(cmd, "ddr1b", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_DDR1B( val ); VIA1.ddrb = val;
} }
} }
else if( strncasecmp(cmd, "ior1b", 5) == 0) { else if( strncasecmp(cmd, "ior1b", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_IOR1B( val ); VIA1.prb = val;
} }
} }
else if( strncasecmp(cmd, "ddr2a", 5) == 0) { else if( strncasecmp(cmd, "ddr2a", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_DDR2A( val ); VIA2.ddra = val;
} }
} }
else if( strncasecmp(cmd, "ior2a", 5) == 0) { else if( strncasecmp(cmd, "ior2a", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_IOR2A( val ); VIA2.pra = val;
} }
} }
else if( strncasecmp(cmd, "ddr2b", 5) == 0) { else if( strncasecmp(cmd, "ddr2b", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_DDR2B( val ); VIA2.ddrb = val;
} }
} }
else if( strncasecmp(cmd, "ior2b", 5) == 0) { else if( strncasecmp(cmd, "ior2b", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_IOR2B( val ); VIA2.prb = val;
} }
} }
else if( strncasecmp(cmd, "ddr3a", 5) == 0) { else if( strncasecmp(cmd, "ddr3a", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_DDR3A( val ); VIA3.ddra = val;
} }
} }
else if( strncasecmp(cmd, "ior3a", 5) == 0) { else if( strncasecmp(cmd, "ior3a", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_IOR3A( val ); VIA3.pra = val;
} }
} }
else if( strncasecmp(cmd, "ddr3b", 5) == 0) { else if( strncasecmp(cmd, "ddr3b", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_DDR3B( val ); VIA3.ddrb = val;
} }
} }
else if( strncasecmp(cmd, "ior3b", 5) == 0) { else if( strncasecmp(cmd, "ior3b", 5) == 0) {
vp = strchr(cmd, ' '); vp = strchr(cmd, ' ');
if( vp ) { if( vp ) {
val = atoi( vp ); val = (unsigned char) strtol( vp, NULL, 0 );
set_IOR3B( val ); VIA3.prb = val;
} }
} }
} }

View File

@ -26,9 +26,8 @@ void main(void) {
} }
} }
while( c != '\r' ) { while( c != '\n' ) {
c = getchar(); c = getchar();
putchar( c );
} }
puts( "\n\nThanks!\n" ); puts( "\n\nThanks!\n" );