Skip to content

Commit

Permalink
Merge pull request davidgiven#166 from venomix666/nano6502
Browse files Browse the repository at this point in the history
Added a SERIAL driver for the Nano6502
  • Loading branch information
davidgiven authored Sep 5, 2024
2 parents 4372574 + a16cf0d commit 215aa53
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ the same time.
- To use, write the `nano6502.img` file into the SD-card using `dd` or your preferred SD-card image writer. If you are updating the image and want to preserve the data on all drives except `A`, write the `nano6502_sysonly.img` instead.
- User area 1 on drive `A` contains utilities for setting the text and background colors, and a demo application which blinks the onboard LEDs.
- A SERIAL driver is available for the second UART, connected to pin 25 (RX) and 26 (TX) of the FPGA (and the UART header on the nanoComp carrier board). The baudrate is currently fixed to 115200.
### KIM-1 with K-1013 FDC notes
Expand Down
97 changes: 94 additions & 3 deletions src/arch/nano6502/nano6502.S
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ uart_tx_done = $fe01
uart_rx_data = $fe02
uart_rx_avail = $fe03

uart_b_tx_data = $fe04
uart_b_tx_done = $fe05
uart_b_rx_data = $fe06
uart_b_rx_avail = $fe07

keyb_data_avail = $fe00
keyb_data = $fe01

Expand Down Expand Up @@ -309,7 +314,7 @@ zproc tty_conin
lda pending_key
zif_eq
tty_input_wait:
lda #IO_page_uart
lda #IO_page_uart
sta IO_page_reg
lda uart_rx_avail
beq tty_input_keyb
Expand Down Expand Up @@ -347,10 +352,10 @@ zendproc

; --- SCREEN driver -------------------------------------------------------

defdriver SCREEN, DRVID_SCREEN, drvstrat_SCREEN, 0
defdriver SCREEN, DRVID_SCREEN, drvstrat_SCREEN, drv_SERIAL

; SCREEN driver strategy routine
; Y = TTY opcode
; Y = SCREEN opcode

zproc drvstrat_SCREEN
jmpdispatch screen_jmptable_lo, screen_jmptable_hi
Expand Down Expand Up @@ -548,6 +553,92 @@ normal_style:
rts
zendproc


; --- SERIAL driver -------------------------------------------------------

; SERIAL driver strategy routine
; Y = SERIAL opcode

defdriver "SERIAL", DRVID_SERIAL, drvstrat_SERIAL, 0

zproc drvstrat_SERIAL
jmpdispatch serial_jmptable_lo, serial_jmptable_hi

serial_jmptable_lo:
jmptablo serial_inp
jmptablo serial_out
jmptablo serial_open
jmptablo serial_close
jmptablo serial_outp
jmptablo serial_in
serial_jmptable_hi:
jmptabhi serial_inp
jmptabhi serial_out
jmptabhi serial_open
jmptabhi serial_close
jmptabhi serial_outp
jmptabhi serial_in
zendproc

zproc serial_inp
lda #IO_page_uart
sta IO_page_reg
lda uart_b_rx_avail
zif_eq
; No data available
sec
rts
zendif
lda uart_b_rx_data
clc
rts
zendproc

zproc serial_out
sta ptr
lda #IO_page_uart
sta IO_page_reg
wait_serial_out:
lda uart_b_tx_done
beq wait_serial_out
lda ptr
sta uart_b_tx_data
rts
zendproc

serial_open:
serial_close:
rts

zproc serial_outp
sta ptr
lda #IO_page_uart
sta IO_page_reg

lda uart_b_tx_done
zif_eq
sec
rts
zendif
lda ptr
sta uart_b_tx_data
clc
rts
zendproc

zproc serial_in
lda #IO_page_uart
sta IO_page_reg

wait_serial_in:
lda uart_b_rx_avail
beq wait_serial_in

lda uart_b_rx_data
rts
zendproc

; -- Rest of the BIOS ---

; Sets the current DMA address.
Expand Down

0 comments on commit 215aa53

Please sign in to comment.