forked from Apple-2-HW/gp2io
added Merlin source for main routines
Merlin32 compatible source for readbyte, sendbyte, and bufferedio routines
This commit is contained in:
parent
f73c667966
commit
7c5943956b
@ -26,6 +26,16 @@
|
||||
CLRAN3 = $C05F ;Set annunciator-3 output to 1
|
||||
|
||||
|
||||
..xx xx.. 3C
|
||||
.x.. ..x. 42
|
||||
x.x. .x.x a5
|
||||
x.x. .x.x a5
|
||||
x... ...x 81
|
||||
x.x. .x.x a5
|
||||
.x.x x.x. 5a
|
||||
..xx xx.. 3c
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// I2C
|
||||
@ -89,10 +99,10 @@ byte bufferLength[1];
|
||||
B10101110,
|
||||
B01101010,
|
||||
B10101110
|
||||
};*/
|
||||
};
|
||||
|
||||
byte I2CBuffer[8] = {
|
||||
B01111010, /* bit 7--0 */
|
||||
B01111010,
|
||||
B10111000,
|
||||
B00000000,
|
||||
B10111000,
|
||||
@ -100,8 +110,27 @@ byte I2CBuffer[8] = {
|
||||
B10101110,
|
||||
B01101010,
|
||||
B10101110
|
||||
};*/
|
||||
|
||||
byte I2CBuffer[8] = {
|
||||
B01010101, /* bit 7--0 */
|
||||
B10101010,
|
||||
B01010101,
|
||||
B10101010,
|
||||
B01010101,
|
||||
B10101010,
|
||||
B01010101,
|
||||
B10101010
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
1
|
||||
---
|
||||
6 | 7 | 2
|
||||
@ -126,9 +155,9 @@ byte ESPByte;
|
||||
|
||||
const int LED_PIN = 11;
|
||||
|
||||
int RGB_RED = 9;
|
||||
int RGB_GREEN = 10;
|
||||
int RGB_BLUE = 4;
|
||||
int RGB_RED = 10;
|
||||
int RGB_GREEN = 4;
|
||||
int RGB_BLUE = 9;
|
||||
|
||||
int ANN0_PIN = 5;
|
||||
int ANN1_PIN = 6;
|
||||
@ -159,30 +188,6 @@ int functionArray[] =
|
||||
//DEBUG is active until the AVR is reset or input timeout is reached.
|
||||
|
||||
void setup() {
|
||||
//LED MATRIX / 7 segment display
|
||||
|
||||
if (!i2c_init()) {
|
||||
Serial.println("I2C error. SDA or SCL are low");
|
||||
}
|
||||
if (!i2c_start(i2c_addr) ) {
|
||||
Serial.println("I2C device not found");
|
||||
}
|
||||
|
||||
i2c_write(0x21); // turn on oscillator
|
||||
i2c_stop();
|
||||
|
||||
// set blinkrate 0
|
||||
i2c_start(i2c_addr);
|
||||
i2c_write(HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (0 << 1));
|
||||
i2c_stop();
|
||||
|
||||
// set brightness to 15/15
|
||||
i2c_start(i2c_addr);
|
||||
i2c_write(HT16K33_CMD_BRIGHTNESS | 15);
|
||||
i2c_stop();
|
||||
|
||||
writeI2C(); // "Good"/"ok"
|
||||
|
||||
|
||||
pinMode(ANN2_PIN, INPUT); // annunciator 2
|
||||
pinMode(ANN3_PIN, INPUT); // annunciator 3
|
||||
@ -207,15 +212,64 @@ void setup() {
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
|
||||
|
||||
/*
|
||||
pinMode(14, OUTPUT);
|
||||
digitalWrite(14, HIGH);
|
||||
pinMode(15, OUTPUT);
|
||||
digitalWrite(15, HIGH);
|
||||
pinMode(16, OUTPUT);
|
||||
digitalWrite(16, HIGH);
|
||||
pinMode(17, OUTPUT);
|
||||
digitalWrite(17, HIGH);
|
||||
pinMode(18, OUTPUT);
|
||||
digitalWrite(18, HIGH);
|
||||
pinMode(19, OUTPUT);
|
||||
digitalWrite(19, HIGH);
|
||||
pinMode(20, OUTPUT);
|
||||
digitalWrite(20, HIGH);
|
||||
pinMode(21, OUTPUT);
|
||||
digitalWrite(21, HIGH);
|
||||
*/
|
||||
|
||||
Serial.begin(baud);
|
||||
// to ESP, other serial devices
|
||||
HWSERIAL.begin(baud);
|
||||
// HWSERIAL.begin(baud);
|
||||
|
||||
enablePinInterrupt(ANN2_PIN); // Apple ready to receive
|
||||
attachInterrupt(0, APPLERTS, RISING); // ANNUNCIATOR 0, Apple sending byte
|
||||
attachInterrupt(1, RECEIVINGBITS, CHANGE); // ANNUNCIATOR 1, Apple sending bits
|
||||
|
||||
setRGBOneShot(0, 0, 200); // blue = ready
|
||||
setRGBOneShot(200, 200, 200); // blue = ready
|
||||
|
||||
|
||||
//LED MATRIX / 7 segment display
|
||||
|
||||
if (!i2c_init()) {
|
||||
Serial.println("I2C error. SDA or SCL are low");
|
||||
}
|
||||
if (!i2c_start(i2c_addr) ) {
|
||||
Serial.println("I2C device not found");
|
||||
}
|
||||
|
||||
i2c_write(0x21); // turn on oscillator
|
||||
i2c_stop();
|
||||
|
||||
// set blinkrate 0
|
||||
i2c_start(i2c_addr);
|
||||
i2c_write(HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (0 << 1));
|
||||
i2c_stop();
|
||||
|
||||
// set brightness to 15/15
|
||||
i2c_start(i2c_addr);
|
||||
i2c_write(HT16K33_CMD_BRIGHTNESS | 15);
|
||||
i2c_stop();
|
||||
|
||||
writeI2C(); // "Good"/"ok"
|
||||
ClearI2C();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
@ -247,6 +301,8 @@ void loop()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} //loop
|
||||
|
||||
void IOMODERESET(long resetTime, String reason) {
|
||||
@ -260,7 +316,7 @@ void IOMODERESET(long resetTime, String reason) {
|
||||
Serial.print("MODE RESET ");
|
||||
Serial.println(reason);
|
||||
// Serial.println(TIMESINCELASTBYTE);
|
||||
setRGBOneShot(0, 0, 200);
|
||||
setRGBOneShot(200, 200, 200);
|
||||
|
||||
digitalWrite(PB0_PIN, LOW); // RTS off
|
||||
digitalWrite(PB1_PIN, LOW); // Bits out
|
||||
@ -270,6 +326,7 @@ void IOMODERESET(long resetTime, String reason) {
|
||||
// Serial.write(HWSERIALBuffer, 256);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -370,7 +427,7 @@ void sendByte (byte byteToSend, bool oneShot) {
|
||||
|
||||
|
||||
void APPLERTS() {
|
||||
// signal to start receiving bits from Apple II
|
||||
// signal to start receiving bits from Apple II"
|
||||
bitCount = 0;
|
||||
changeCount = 0;
|
||||
returnByte = B00000000;
|
||||
@ -453,6 +510,9 @@ void RECEIVINGBITS()
|
||||
|
||||
|
||||
void PROCESSBYTE(byte receivedByte) {
|
||||
|
||||
|
||||
|
||||
// char longstring[80] = "AT+CIPSTART=\"TCP\",\"www.option8llc.com\",80\n\r";
|
||||
// int rd, wr;
|
||||
String connectString;
|
||||
@ -665,16 +725,18 @@ void PROCESSBYTE(byte receivedByte) {
|
||||
case 4: // read and buffer 8 bytes to I2C buffer for matrix/7segment display
|
||||
if (functionLength == -1) { // first byte == message length
|
||||
functionLength = receivedByte;
|
||||
Serial.print("I2C ");
|
||||
Serial.println(functionLength);
|
||||
Serial.print("L");
|
||||
Serial.println(functionLength);
|
||||
} else {
|
||||
I2CBuffer[functionLength - 1] = receivedByte;
|
||||
Serial.println(receivedByte);
|
||||
// Serial.print("I2C Buffer ");
|
||||
// Serial.print(functionLength);
|
||||
// Serial.println(I2CBuffer[functionLength - 1]);
|
||||
|
||||
functionLength --;
|
||||
if (functionLength == 0) {
|
||||
writeI2C();
|
||||
Serial.print("I2C DONE");
|
||||
// Serial.print("I2C DONE");
|
||||
}
|
||||
|
||||
}
|
||||
@ -800,7 +862,7 @@ void drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
// if ((x < 0) || (x >= 8)) return;
|
||||
|
||||
// wrap around the x
|
||||
x += 7; // 0,0 => 7,0 // 7,0 => 14,0 // 1,0 => 8,0
|
||||
x += 7; // 0,0 => 7,0 // 7,0 => 14,0 // 1,0 => 8,0se
|
||||
x %= 8; // 7,0 => 7,0 // 14,0 => 6,0 // 8,0 => 0,0
|
||||
|
||||
if (color) {
|
||||
@ -824,14 +886,21 @@ void writeI2C(void) {
|
||||
i2c_write(0x00); // start address $00
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
// Serial.print("I2C write ");
|
||||
// Serial.println(I2CBuffer[i]);
|
||||
|
||||
// rotate the byte right by 1. "carry" bit gets rolled around
|
||||
I2CBuffer[i] = ((I2CBuffer[i] & 0x01) ? 0x80 : 0x00) | (I2CBuffer[i] >> 1);
|
||||
// seriously? ROR.
|
||||
|
||||
i2c_write(I2CBuffer[i]); // write the bits to turn on/off pixels
|
||||
i2c_write(0xff); // control/bitmask?
|
||||
|
||||
|
||||
|
||||
}
|
||||
i2c_stop();
|
||||
// Serial.println("I2C WROTE");
|
||||
}
|
||||
|
||||
void ClearI2C(void) {
|
||||
|
3
_FileInformation.txt
Normal file
3
_FileInformation.txt
Normal file
@ -0,0 +1,3 @@
|
||||
sendbyte=Type(00),AuxType(0000),VersionCreate(70),MinVersion(BE),Access(E3),FolderInfo1(000000000000000000000000000000000000),FolderInfo2(000000000000000000000000000000000000)
|
||||
readbyte=Type(00),AuxType(0000),VersionCreate(70),MinVersion(BE),Access(E3),FolderInfo1(000000000000000000000000000000000000),FolderInfo2(000000000000000000000000000000000000)
|
||||
bufferedio=Type(00),AuxType(0000),VersionCreate(70),MinVersion(BE),Access(E3),FolderInfo1(000000000000000000000000000000000000),FolderInfo2(000000000000000000000000000000000000)
|
BIN
bufferedio
Normal file
BIN
bufferedio
Normal file
Binary file not shown.
70
bufferedio.s
Normal file
70
bufferedio.s
Normal file
@ -0,0 +1,70 @@
|
||||
ORG $800
|
||||
BUFFERLENGTH EQU $08
|
||||
INPUTLENGTH EQU $07
|
||||
INPUTPTR EQU $06
|
||||
SENDBYTE EQU $0300
|
||||
READBYTE EQU $034A
|
||||
WAIT EQU $FCA8
|
||||
PRINTCR EQU $FD8E
|
||||
PRINTBYTE EQU $FDED
|
||||
ANN2HI EQU $C05D
|
||||
ANN2LO EQU $C05C
|
||||
KEYBUFFER EQU $0200
|
||||
|
||||
BUFFERIO JSR QUERYBUFFER ; start by querying the buffer length - is there anything waiting? returns with buffer length in $08
|
||||
LDA #$80 ; load control byte $80 "send buffer bytes"
|
||||
JSR SENDBYTE ; send control byte
|
||||
LDA BUFFERLENGTH ; load buffer length (or however much buffer you want sent)
|
||||
JSR SENDBYTE ; send message length byte
|
||||
BETWEENBYTES LDA #$28 ; wait a moment (betweenbytes)
|
||||
JSR WAIT ; wait
|
||||
JSR READBYTE ; CTS - send byte
|
||||
ORA #$80 ; clear byte 7 (for ASCII)
|
||||
JSR PRINTBYTE ; display byte on screen
|
||||
DEC BUFFERLENGTH ; count down bytes (countdownbuffer)
|
||||
LDA BUFFERLENGTH ; load Accumulator with new buffer length
|
||||
BNE BETWEENBYTES ; if there's more to come, loop (betweenbytes)
|
||||
JSR PRINTCR ; last byte. print CF/LF
|
||||
RTS ; return
|
||||
|
||||
GETLINE JSR $FD6A ; get line of input, input length in X reg
|
||||
TXA ; get input length into Accumulator
|
||||
STA INPUTLENGTH ; put input length into $07
|
||||
CLEARPTR LDA #$00 ; load zero into Accumulator
|
||||
STA INPUTPTR ; put zero into $06, keyboard buffer pointer
|
||||
LDA #$04 ; load Accumulator with control byte "write to buffer"
|
||||
JSR SENDBYTE ; send control byte
|
||||
LDA INPUTLENGTH ; load input length from $07
|
||||
JSR SENDBYTE ; send message length
|
||||
LOADBUFFER LDX INPUTPTR ; load X with keyboard buffer pointer (LOADBUFFER)
|
||||
LDA KEYBUFFER,X ; load Accumulator with bytes from keyboard buffer (start at $200)
|
||||
AND #$7F ; clear high bit (for ASCII on other end)
|
||||
JSR SENDBYTE ; send byte
|
||||
INC INPUTPTR ; increment keyboard buffer pointer
|
||||
LDA INPUTPTR ; load buffer pointer into Accumulator
|
||||
CMP INPUTLENGTH ; compare with message length
|
||||
BNE LOADBUFFER ; if not at end of message, loop to (LOADBUFFER)
|
||||
RTS ; return
|
||||
|
||||
QUERYBUFFER LDA #$40 ; control byte for query buffer length
|
||||
JSR SENDBYTE ; send control byte
|
||||
JSR TWIDDLE ; wait routine - gives GP2IO time to receive bytes from serial
|
||||
CTS STA ANN2LO ; set ANN2 to LOW (just in case it's floating high)
|
||||
JSR READBYTE ; CTS - ready for response byte with buffer length
|
||||
BEQ QUERYBUFFER ; if there's nothing in the buffer, loop until there is
|
||||
STA BUFFERLENGTH ; put the byte in $08
|
||||
RTS ; returns buffer length in $08 (BUFFERLENGTH)
|
||||
|
||||
TWIDDLE LDA #$7C ; |
|
||||
JSR PRINTCHAR ;
|
||||
LDA #$2F ; /
|
||||
JSR PRINTCHAR ;
|
||||
LDA #$2D ; -
|
||||
JSR PRINTCHAR ;
|
||||
LDA #$1C ; \
|
||||
PRINTCHAR JSR PRINTBYTE ; prints character to screen, high byte not set, inverse text
|
||||
LDA #$AA ; speed of animation
|
||||
JSR WAIT ; waits for a while
|
||||
LDA #$88 ; (backspace)
|
||||
JSR PRINTBYTE ; backspaces over current char to overwrite
|
||||
RTS ; RETURN
|
75
bufferedio_Output.txt
Normal file
75
bufferedio_Output.txt
Normal file
@ -0,0 +1,75 @@
|
||||
------+------------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
||||
Line | # File Line | Line Type | MX | Reloc | Size | Address Object Code | Source Code
|
||||
------+------------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
||||
1 | 1 bufferedio.s 1 | Directive | 11 | | 0 | 00/8000 | ORG $800
|
||||
2 | 1 bufferedio.s 2 | Equivalence | 11 | | 0 | 00/0800 | BUFFERLENGTH EQU $08
|
||||
3 | 1 bufferedio.s 3 | Equivalence | 11 | | 0 | 00/0800 | INPUTLENGTH EQU $07
|
||||
4 | 1 bufferedio.s 4 | Equivalence | 11 | | 0 | 00/0800 | INPUTPTR EQU $06
|
||||
5 | 1 bufferedio.s 5 | Equivalence | 11 | | 0 | 00/0800 | SENDBYTE EQU $0300
|
||||
6 | 1 bufferedio.s 6 | Equivalence | 11 | | 0 | 00/0800 | READBYTE EQU $034A
|
||||
7 | 1 bufferedio.s 7 | Equivalence | 11 | | 0 | 00/0800 | WAIT EQU $FCA8
|
||||
8 | 1 bufferedio.s 8 | Equivalence | 11 | | 0 | 00/0800 | PRINTCR EQU $FD8E
|
||||
9 | 1 bufferedio.s 9 | Equivalence | 11 | | 0 | 00/0800 | PRINTBYTE EQU $FDED
|
||||
10 | 1 bufferedio.s 10 | Equivalence | 11 | | 0 | 00/0800 | ANN2HI EQU $C05D
|
||||
11 | 1 bufferedio.s 11 | Equivalence | 11 | | 0 | 00/0800 | ANN2LO EQU $C05C
|
||||
12 | 1 bufferedio.s 12 | Equivalence | 11 | | 0 | 00/0800 | KEYBUFFER EQU $0200
|
||||
13 | 1 bufferedio.s 13 | Empty | 11 | | 0 | 00/0800 |
|
||||
14 | 1 bufferedio.s 14 | Code | 11 | | 3 | 00/0800 : 20 4B 08 | BUFFERIO JSR QUERYBUFFER ; start by querying the buffer length - is there anything waiting? returns with buffer length in $08
|
||||
15 | 1 bufferedio.s 15 | Code | 11 | | 2 | 00/0803 : A9 80 | LDA #$80 ; load control byte $80 "send buffer bytes"
|
||||
16 | 1 bufferedio.s 16 | Code | 11 | | 3 | 00/0805 : 20 00 03 | JSR {$0300} ; send control byte
|
||||
17 | 1 bufferedio.s 17 | Code | 11 | | 2 | 00/0808 : A5 08 | LDA {$08} ; load buffer length (or however much buffer you want sent)
|
||||
18 | 1 bufferedio.s 18 | Code | 11 | | 3 | 00/080A : 20 00 03 | JSR {$0300} ; send message length byte
|
||||
19 | 1 bufferedio.s 19 | Code | 11 | | 2 | 00/080D : A9 28 | BETWEENBYTES LDA #$28 ; wait a moment (betweenbytes)
|
||||
20 | 1 bufferedio.s 20 | Code | 11 | | 3 | 00/080F : 20 A8 FC | JSR {$FCA8} ; wait
|
||||
21 | 1 bufferedio.s 21 | Code | 11 | | 3 | 00/0812 : 20 4A 03 | JSR {$034A} ; CTS - send byte
|
||||
22 | 1 bufferedio.s 22 | Code | 11 | | 2 | 00/0815 : 09 80 | ORA #$80 ; clear byte 7 (for ASCII)
|
||||
23 | 1 bufferedio.s 23 | Code | 11 | | 3 | 00/0817 : 20 ED FD | JSR {$FDED} ; display byte on screen
|
||||
24 | 1 bufferedio.s 24 | Code | 11 | | 2 | 00/081A : C6 08 | DEC {$08} ; count down bytes (countdownbuffer)
|
||||
25 | 1 bufferedio.s 25 | Code | 11 | | 2 | 00/081C : A5 08 | LDA {$08} ; load Accumulator with new buffer length
|
||||
26 | 1 bufferedio.s 26 | Code | 11 | | 2 | 00/081E : D0 ED | BNE BETWEENBYTES ; if there's more to come, loop (betweenbytes)
|
||||
27 | 1 bufferedio.s 27 | Code | 11 | | 3 | 00/0820 : 20 8E FD | JSR {$FD8E} ; last byte. print CF/LF
|
||||
28 | 1 bufferedio.s 28 | Code | 11 | | 1 | 00/0823 : 60 | RTS ; return
|
||||
29 | 1 bufferedio.s 29 | Empty | 11 | | 0 | 00/0824 |
|
||||
30 | 1 bufferedio.s 30 | Code | 11 | | 3 | 00/0824 : 20 6A FD | GETLINE JSR $FD6A ; get line of input, input length in X reg
|
||||
31 | 1 bufferedio.s 31 | Code | 11 | | 1 | 00/0827 : 8A | TXA ; get input length into Accumulator
|
||||
32 | 1 bufferedio.s 32 | Code | 11 | | 2 | 00/0828 : 85 07 | STA {$07} ; put input length into $07
|
||||
33 | 1 bufferedio.s 33 | Code | 11 | | 2 | 00/082A : A9 00 | CLEARPTR LDA #$00 ; load zero into Accumulator
|
||||
34 | 1 bufferedio.s 34 | Code | 11 | | 2 | 00/082C : 85 06 | STA {$06} ; put zero into $06, keyboard buffer pointer
|
||||
35 | 1 bufferedio.s 35 | Code | 11 | | 2 | 00/082E : A9 04 | LDA #$04 ; load Accumulator with control byte "write to buffer"
|
||||
36 | 1 bufferedio.s 36 | Code | 11 | | 3 | 00/0830 : 20 00 03 | JSR {$0300} ; send control byte
|
||||
37 | 1 bufferedio.s 37 | Code | 11 | | 2 | 00/0833 : A5 07 | LDA {$07} ; load input length from $07
|
||||
38 | 1 bufferedio.s 38 | Code | 11 | | 3 | 00/0835 : 20 00 03 | JSR {$0300} ; send message length
|
||||
39 | 1 bufferedio.s 39 | Code | 11 | | 2 | 00/0838 : A6 06 | LOADBUFFER LDX {$06} ; load X with keyboard buffer pointer (LOADBUFFER)
|
||||
40 | 1 bufferedio.s 40 | Code | 11 | | 3 | 00/083A : BD 00 02 | LDA {$0200},X ; load Accumulator with bytes from keyboard buffer (start at $200)
|
||||
41 | 1 bufferedio.s 41 | Code | 11 | | 2 | 00/083D : 29 7F | AND #$7F ; clear high bit (for ASCII on other end)
|
||||
42 | 1 bufferedio.s 42 | Code | 11 | | 3 | 00/083F : 20 00 03 | JSR {$0300} ; send byte
|
||||
43 | 1 bufferedio.s 43 | Code | 11 | | 2 | 00/0842 : E6 06 | INC {$06} ; increment keyboard buffer pointer
|
||||
44 | 1 bufferedio.s 44 | Code | 11 | | 2 | 00/0844 : A5 06 | LDA {$06} ; load buffer pointer into Accumulator
|
||||
45 | 1 bufferedio.s 45 | Code | 11 | | 2 | 00/0846 : C5 07 | CMP {$07} ; compare with message length
|
||||
46 | 1 bufferedio.s 46 | Code | 11 | | 2 | 00/0848 : D0 EE | BNE LOADBUFFER ; if not at end of message, loop to (LOADBUFFER)
|
||||
47 | 1 bufferedio.s 47 | Code | 11 | | 1 | 00/084A : 60 | RTS ; return
|
||||
48 | 1 bufferedio.s 48 | Empty | 11 | | 0 | 00/084B |
|
||||
49 | 1 bufferedio.s 49 | Code | 11 | | 2 | 00/084B : A9 40 | QUERYBUFFER LDA #$40 ; control byte for query buffer length
|
||||
50 | 1 bufferedio.s 50 | Code | 11 | | 3 | 00/084D : 20 00 03 | JSR {$0300} ; send control byte
|
||||
51 | 1 bufferedio.s 51 | Code | 11 | | 3 | 00/0850 : 20 5E 08 | JSR TWIDDLE ; wait routine - gives GP2IO time to receive bytes from serial
|
||||
52 | 1 bufferedio.s 52 | Code | 11 | | 3 | 00/0853 : 8D 5C C0 | CTS STA {$C05C} ; set ANN2 to LOW (just in case it's floating high)
|
||||
53 | 1 bufferedio.s 53 | Code | 11 | | 3 | 00/0856 : 20 4A 03 | JSR {$034A} ; CTS - ready for response byte with buffer length
|
||||
54 | 1 bufferedio.s 54 | Code | 11 | | 2 | 00/0859 : F0 F0 | BEQ QUERYBUFFER ; if there's nothing in the buffer, loop until there is
|
||||
55 | 1 bufferedio.s 55 | Code | 11 | | 2 | 00/085B : 85 08 | STA {$08} ; put the byte in $08
|
||||
56 | 1 bufferedio.s 56 | Code | 11 | | 1 | 00/085D : 60 | RTS ; returns buffer length in $08 (BUFFERLENGTH)
|
||||
57 | 1 bufferedio.s 57 | Empty | 11 | | 0 | 00/085E |
|
||||
58 | 1 bufferedio.s 58 | Code | 11 | | 2 | 00/085E : A9 7C | TWIDDLE LDA #$7C ; |
|
||||
59 | 1 bufferedio.s 59 | Code | 11 | | 3 | 00/0860 : 20 6F 08 | JSR PRINTCHAR ;
|
||||
60 | 1 bufferedio.s 60 | Code | 11 | | 2 | 00/0863 : A9 2F | LDA #$2F ; /
|
||||
61 | 1 bufferedio.s 61 | Code | 11 | | 3 | 00/0865 : 20 6F 08 | JSR PRINTCHAR ;
|
||||
62 | 1 bufferedio.s 62 | Code | 11 | | 2 | 00/0868 : A9 2D | LDA #$2D ; -
|
||||
63 | 1 bufferedio.s 63 | Code | 11 | | 3 | 00/086A : 20 6F 08 | JSR PRINTCHAR ;
|
||||
64 | 1 bufferedio.s 64 | Code | 11 | | 2 | 00/086D : A9 1C | LDA #$1C ; \
|
||||
65 | 1 bufferedio.s 65 | Code | 11 | | 3 | 00/086F : 20 ED FD | PRINTCHAR JSR {$FDED} ; prints character to screen, high byte not set, inverse text
|
||||
66 | 1 bufferedio.s 66 | Code | 11 | | 2 | 00/0872 : A9 AA | LDA #$AA ; speed of animation
|
||||
67 | 1 bufferedio.s 67 | Code | 11 | | 3 | 00/0874 : 20 A8 FC | JSR {$FCA8} ; waits for a while
|
||||
68 | 1 bufferedio.s 68 | Code | 11 | | 2 | 00/0877 : A9 88 | LDA #$88 ; (backspace)
|
||||
69 | 1 bufferedio.s 69 | Code | 11 | | 3 | 00/0879 : 20 ED FD | JSR {$FDED} ; backspaces over current char to overwrite
|
||||
70 | 1 bufferedio.s 70 | Code | 11 | | 1 | 00/087C : 60 | RTS ; RETURN
|
||||
71 | 1 bufferedio.s 71 | Empty | 11 | | 0 | 00/087D |
|
||||
------+------------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
28
readbyte.s
Normal file
28
readbyte.s
Normal file
@ -0,0 +1,28 @@
|
||||
ORG $34A
|
||||
ANN2HI EQU $C05D
|
||||
ANN2LO EQU $C05C
|
||||
BUTT1 EQU $C062
|
||||
BYTETRCVD EQU $EF
|
||||
BUTT1HILO EQU $EE
|
||||
|
||||
|
||||
READBYTE LDX #$09 ; reading 8 bits requires 9 transitions.
|
||||
LDA #$00 ; clear the accumulator
|
||||
STA BYTETRCVD ; $EF is staging for received byte, set 0
|
||||
STA BUTT1HILO ; $EE is staging for each bit, set 0
|
||||
CTS STA ANN2HI ; set ANN2 HIGH, indicate to AVR "Clear to Send"
|
||||
LOOPSTART LDY #$FF ; start wait loop
|
||||
LOOPCOUNT INY ; Increment Y - rolls over to 0 on first run (loopcount)
|
||||
LDA BUTT1 ; check PB1 status hi/low
|
||||
AND #$80 ; clear 0-6 bits (just need bit 7, all others float)
|
||||
CMP BUTT1HILO ; compare Accumulator 7 bit with $EE, previous PB2 value
|
||||
BNE BITCHANGE ; if PB2 has changed state, store in $EE (bitchange)
|
||||
BEQ LOOPCOUNT ; bit hasn't changed yet, return to (loopcount)
|
||||
BITCHANGE STA BUTT1HILO ; (bitchange)
|
||||
CPY #$44 ; if the loop count is more than 68, bit is one. Bit is set in Carry
|
||||
ROL BYTETRCVD ; rotate the new bit into $EF, our result byte.
|
||||
DEX ; decrement X, our bit count
|
||||
BNE LOOPSTART ; if bit count is not yet full, loop back to (loopcount)
|
||||
CTSOFF STA ANN2LO ; if bit count is full, set ANN2 LOW, CTS off
|
||||
LDA BYTETRCVD ; puts received byte into Accumulator
|
||||
RTS ; return with byte in Accumulator
|
33
readbyte_Output.txt
Normal file
33
readbyte_Output.txt
Normal file
@ -0,0 +1,33 @@
|
||||
------+----------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
||||
Line | # File Line | Line Type | MX | Reloc | Size | Address Object Code | Source Code
|
||||
------+----------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
||||
1 | 1 readbyte.s 1 | Directive | 11 | | 0 | 00/8000 | ORG $34A
|
||||
2 | 1 readbyte.s 2 | Equivalence | 11 | | 0 | 00/034A | ANN2HI EQU $C05D
|
||||
3 | 1 readbyte.s 3 | Equivalence | 11 | | 0 | 00/034A | ANN2LO EQU $C05C
|
||||
4 | 1 readbyte.s 4 | Equivalence | 11 | | 0 | 00/034A | BUTT1 EQU $C062
|
||||
5 | 1 readbyte.s 5 | Equivalence | 11 | | 0 | 00/034A | BYTETRCVD EQU $EF
|
||||
6 | 1 readbyte.s 6 | Equivalence | 11 | | 0 | 00/034A | BUTT1HILO EQU $EE
|
||||
7 | 1 readbyte.s 7 | Empty | 11 | | 0 | 00/034A |
|
||||
8 | 1 readbyte.s 8 | Empty | 11 | | 0 | 00/034A |
|
||||
9 | 1 readbyte.s 9 | Code | 11 | | 2 | 00/034A : A2 09 | READBYTE LDX #$09 ; reading 8 bits requires 9 transitions.
|
||||
10 | 1 readbyte.s 10 | Code | 11 | | 2 | 00/034C : A9 00 | LDA #$00 ; clear the accumulator
|
||||
11 | 1 readbyte.s 11 | Code | 11 | | 2 | 00/034E : 85 EF | STA {$EF} ; $EF is staging for received byte, set 0
|
||||
12 | 1 readbyte.s 12 | Code | 11 | | 2 | 00/0350 : 85 EE | STA {$EE} ; $EE is staging for each bit, set 0
|
||||
13 | 1 readbyte.s 13 | Code | 11 | | 3 | 00/0352 : 8D 5D C0 | CTS STA {$C05D} ; set ANN2 HIGH, indicate to AVR "Clear to Send"
|
||||
14 | 1 readbyte.s 14 | Code | 11 | | 2 | 00/0355 : A0 FF | LOOPSTART LDY #$FF ; start wait loop
|
||||
15 | 1 readbyte.s 15 | Code | 11 | | 1 | 00/0357 : C8 | LOOPCOUNT INY ; Increment Y - rolls over to 0 on first run (loopcount)
|
||||
16 | 1 readbyte.s 16 | Code | 11 | | 3 | 00/0358 : AD 62 C0 | LDA {$C062} ; check PB1 status hi/low
|
||||
17 | 1 readbyte.s 17 | Code | 11 | | 2 | 00/035B : 29 80 | AND #$80 ; clear 0-6 bits (just need bit 7, all others float)
|
||||
18 | 1 readbyte.s 18 | Code | 11 | | 2 | 00/035D : C5 EE | CMP {$EE} ; compare Accumulator 7 bit with $EE, previous PB2 value
|
||||
19 | 1 readbyte.s 19 | Code | 11 | | 2 | 00/035F : D0 02 | BNE BITCHANGE ; if PB2 has changed state, store in $EE (bitchange)
|
||||
20 | 1 readbyte.s 20 | Code | 11 | | 2 | 00/0361 : F0 F4 | BEQ LOOPCOUNT ; bit hasn't changed yet, return to (loopcount)
|
||||
21 | 1 readbyte.s 21 | Code | 11 | | 2 | 00/0363 : 85 EE | BITCHANGE STA {$EE} ; (bitchange)
|
||||
22 | 1 readbyte.s 22 | Code | 11 | | 2 | 00/0365 : C0 44 | CPY #$44 ; if the loop count is more than 68, bit is one. Bit is set in Carry
|
||||
23 | 1 readbyte.s 23 | Code | 11 | | 2 | 00/0367 : 26 EF | ROL {$EF} ; rotate the new bit into $EF, our result byte.
|
||||
24 | 1 readbyte.s 24 | Code | 11 | | 1 | 00/0369 : CA | DEX ; decrement X, our bit count
|
||||
25 | 1 readbyte.s 25 | Code | 11 | | 2 | 00/036A : D0 E9 | BNE LOOPSTART ; if bit count is not yet full, loop back to (loopcount)
|
||||
26 | 1 readbyte.s 26 | Code | 11 | | 3 | 00/036C : 8D 5C C0 | CTSOFF STA {$C05C} ; if bit count is full, set ANN2 LOW, CTS off
|
||||
27 | 1 readbyte.s 27 | Code | 11 | | 2 | 00/036F : A5 EF | LDA {$EF} ; puts received byte into Accumulator
|
||||
28 | 1 readbyte.s 28 | Code | 11 | | 1 | 00/0371 : 60 | RTS ; return with byte in Accumulator
|
||||
29 | 1 readbyte.s 29 | Empty | 11 | | 0 | 00/0372 |
|
||||
------+----------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
2
sendbyte
Normal file
2
sendbyte
Normal file
@ -0,0 +1,2 @@
|
||||
…ο<E280A6>Yΐ&ο<>ΆLΆ
|
||||
<EFBFBD>[ΐΚΠύ<CEA0>ZΐΆΚΠύ<CEA0>Πδ<CEA0>Xΐ`
|
28
sendbyte.s
Normal file
28
sendbyte.s
Normal file
@ -0,0 +1,28 @@
|
||||
ORG $0300
|
||||
ANN0HI EQU $C059
|
||||
ANN0LO EQU $C058
|
||||
ANN1HI EQU $C05B
|
||||
ANN1LO EQU $C05A
|
||||
BYTETOSEND EQU $EF
|
||||
|
||||
SENDBYTE LDY #$08 ; load 8 for a full byte, loop counter
|
||||
STA BYTETOSEND ; put byte in zero page for safe keeping
|
||||
RTS STA ANN0HI ; annunciator 0 high, RTS
|
||||
SENDBIT ROL BYTETOSEND ; rotate byte left, high/MSB out to carry (sendbit)
|
||||
BCC SHORTLOOP ; "branch on carry clear" - if carry/bit = 0, goto #311 (short loop)
|
||||
LONGLOOP LDX #$14 ; if carry/bit = 1, load X with 20 (long loop)
|
||||
JMP SETANN1 ; jump over SHORTLOOP
|
||||
SHORTLOOP LDX #$0A ; if carry/bit = 0, load X with 10 (short loop)
|
||||
SETANN1 STA ANN1HI ; set annunciator 1 HIGH
|
||||
COUNTDOWN DEX ; decrement, countdown to setting ANN1 low (COUNTDOWN)
|
||||
BNE COUNTDOWN ; if X > 0, keep counting (goto COUNTDOWN)
|
||||
STA ANN1LO ; if done, set ANN1 LOW, countdown to getting next bit
|
||||
LDX #$05 ; reset counter for short "reset" transition. This lets the GP2IO stage the bit before the next interrupt
|
||||
COUNTDOWN2 DEX ; count down again (COUNTDOWN2)
|
||||
BNE COUNTDOWN2 ; if X > 0, keep counting (goto COUNTDOWN2)
|
||||
DEY ; decrement y, countdown bits sent
|
||||
BNE SENDBIT ; if y > 0, next bit (SENDBIT)
|
||||
RTSOFF STA ANN0LO ; annunciator 0 low, sending RTS OFF
|
||||
RTS ; return
|
||||
|
||||
|
32
sendbyte_Output.txt
Normal file
32
sendbyte_Output.txt
Normal file
@ -0,0 +1,32 @@
|
||||
------+----------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
||||
Line | # File Line | Line Type | MX | Reloc | Size | Address Object Code | Source Code
|
||||
------+----------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
||||
1 | 1 sendbyte.s 1 | Directive | 11 | | 0 | 00/8000 | ORG $0300
|
||||
2 | 1 sendbyte.s 2 | Equivalence | 11 | | 0 | 00/0300 | ANN0HI EQU $C059
|
||||
3 | 1 sendbyte.s 3 | Equivalence | 11 | | 0 | 00/0300 | ANN0LO EQU $C058
|
||||
4 | 1 sendbyte.s 4 | Equivalence | 11 | | 0 | 00/0300 | ANN1HI EQU $C05B
|
||||
5 | 1 sendbyte.s 5 | Equivalence | 11 | | 0 | 00/0300 | ANN1LO EQU $C05A
|
||||
6 | 1 sendbyte.s 6 | Equivalence | 11 | | 0 | 00/0300 | BYTETOSEND EQU $EF
|
||||
7 | 1 sendbyte.s 7 | Empty | 11 | | 0 | 00/0300 |
|
||||
8 | 1 sendbyte.s 8 | Code | 11 | | 2 | 00/0300 : A0 08 | SENDBYTE LDY #$08 ; load 8 for a full byte, loop counter
|
||||
9 | 1 sendbyte.s 9 | Code | 11 | | 2 | 00/0302 : 85 EF | STA {$EF} ; put byte in zero page for safe keeping
|
||||
10 | 1 sendbyte.s 10 | Code | 11 | | 3 | 00/0304 : 8D 59 C0 | RTS STA {$C059} ; annunciator 0 high, RTS
|
||||
11 | 1 sendbyte.s 11 | Code | 11 | | 2 | 00/0307 : 26 EF | SENDBIT ROL {$EF} ; rotate byte left, high/MSB out to carry (sendbit)
|
||||
12 | 1 sendbyte.s 12 | Code | 11 | | 2 | 00/0309 : 90 05 | BCC SHORTLOOP ; "branch on carry clear" - if carry/bit = 0, goto #311 (short loop)
|
||||
13 | 1 sendbyte.s 13 | Code | 11 | | 2 | 00/030B : A2 14 | LONGLOOP LDX #$14 ; if carry/bit = 1, load X with 20 (long loop)
|
||||
14 | 1 sendbyte.s 14 | Code | 11 | | 3 | 00/030D : 4C 12 03 | JMP SETANN1 ; jump over SHORTLOOP
|
||||
15 | 1 sendbyte.s 15 | Code | 11 | | 2 | 00/0310 : A2 0A | SHORTLOOP LDX #$0A ; if carry/bit = 0, load X with 10 (short loop)
|
||||
16 | 1 sendbyte.s 16 | Code | 11 | | 3 | 00/0312 : 8D 5B C0 | SETANN1 STA {$C05B} ; set annunciator 1 HIGH
|
||||
17 | 1 sendbyte.s 17 | Code | 11 | | 1 | 00/0315 : CA | COUNTDOWN DEX ; decrement, countdown to setting ANN1 low (COUNTDOWN)
|
||||
18 | 1 sendbyte.s 18 | Code | 11 | | 2 | 00/0316 : D0 FD | BNE COUNTDOWN ; if X > 0, keep counting (goto COUNTDOWN)
|
||||
19 | 1 sendbyte.s 19 | Code | 11 | | 3 | 00/0318 : 8D 5A C0 | STA {$C05A} ; if done, set ANN1 LOW, countdown to getting next bit
|
||||
20 | 1 sendbyte.s 20 | Code | 11 | | 2 | 00/031B : A2 05 | LDX #$05 ; reset counter for short "reset" transition. This lets the GP2IO stage the bit before the next interrupt
|
||||
21 | 1 sendbyte.s 21 | Code | 11 | | 1 | 00/031D : CA | COUNTDOWN2 DEX ; count down again (COUNTDOWN2)
|
||||
22 | 1 sendbyte.s 22 | Code | 11 | | 2 | 00/031E : D0 FD | BNE COUNTDOWN2 ; if X > 0, keep counting (goto COUNTDOWN2)
|
||||
23 | 1 sendbyte.s 23 | Code | 11 | | 1 | 00/0320 : 88 | DEY ; decrement y, countdown bits sent
|
||||
24 | 1 sendbyte.s 24 | Code | 11 | | 2 | 00/0321 : D0 E4 | BNE SENDBIT ; if y > 0, next bit (SENDBIT)
|
||||
25 | 1 sendbyte.s 25 | Code | 11 | | 3 | 00/0323 : 8D 58 C0 | RTSOFF STA {$C058} ; annunciator 0 low, sending RTS OFF
|
||||
26 | 1 sendbyte.s 26 | Code | 11 | | 1 | 00/0326 : 60 | RTS ; return
|
||||
27 | 1 sendbyte.s 27 | Empty | 11 | | 0 | 00/0327 |
|
||||
28 | 1 sendbyte.s 28 | Empty | 11 | | 0 | 00/0327 |
|
||||
------+----------------------+-------------+----+---------+------+-----------------------+-------------------------------------------------------------------
|
Loading…
Reference in New Issue
Block a user