Created
March 27, 2021 14:00
-
-
Save nezza/1399aa00632b1cc2cefa9bb65d72f04c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gbdk-lib/include/gb/gb.h b/gbdk-lib/include/gb/gb.h | |
index 3426c3a..7d51ce4 100644 | |
--- a/gbdk-lib/include/gb/gb.h | |
+++ b/gbdk-lib/include/gb/gb.h | |
@@ -311,6 +311,7 @@ extern volatile UINT16 sys_time; | |
@see set_interrupts() with @ref SIO_IFLAG | |
*/ | |
void send_byte(void); | |
+void send_byte_slave(void); | |
/** Serial Link: Receive a byte from the serial port into @ref _io_in | |
diff --git a/gbdk-lib/libc/gb/serial.s b/gbdk-lib/libc/gb/serial.s | |
index 7e96374..19f0cc8 100644 | |
--- a/gbdk-lib/libc/gb/serial.s | |
+++ b/gbdk-lib/libc/gb/serial.s | |
@@ -36,7 +36,7 @@ | |
LDH (.SC),A ; Use external clock | |
LD A,#.DT_IDLE | |
- LDH (.SB),A ; Send IDLE byte | |
+ ;LDH (.SB),A ; Send IDLE byte | |
LD A,#0x80 | |
LDH (.SC),A ; Use external clock | |
@@ -88,8 +88,8 @@ _remove_SIO:: | |
XOR A | |
LDH (.SC),A ; Use external clock | |
- LD A,#.DT_IDLE | |
- LDH (.SB),A ; Reply with IDLE byte | |
+ ;LD A,#.DT_IDLE | |
+ ;LDH (.SB),A ; Reply with IDLE byte | |
4$: | |
LD A,#0x80 | |
LDH (.SC),A ; Enable transfer with external clock | |
@@ -135,6 +135,20 @@ _send_byte:: ; Banked | |
LDH (.SC),A ; Use internal clock | |
RET | |
+ | |
+ ;; Send byte in __io_out to the serial port | |
+.send_byte_slave: | |
+_send_byte_slave:: ; Banked | |
+ LD A,#.IO_SENDING | |
+ LD (__io_status),A ; Store status | |
+ LD A,#0x00 | |
+ LDH (.SC),A ; Use external clock | |
+ LD A,(__io_out) | |
+ LDH (.SB),A ; Send data byte | |
+ LD A,#0x80 | |
+ LDH (.SC),A ; Use internal clock | |
+ RET | |
+ | |
;; Receive byte from the serial port in __io_in | |
.receive_byte: | |
_receive_byte:: ; Banked | |
@@ -142,8 +156,10 @@ _receive_byte:: ; Banked | |
LD (__io_status),A ; Store status | |
XOR A | |
LDH (.SC),A ; Use external clock | |
- LD A,#.DT_RECEIVING | |
- LDH (.SB),A ; Send RECEIVING byte | |
+ LD A,(__io_out) | |
+ LDH (.SB),A ; Send data byte | |
+ ;LD A,#.DT_RECEIVING | |
+ ;LDH (.SB),A ; Send RECEIVING byte | |
LD A,#0x80 | |
LDH (.SC),A ; Use external clock | |
RET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment