This change introduces simulated baud rates in the ACIA. Baud rate is controlled just as in the real 6551, by writing to the ACIA's control register. Baud rates between 50 and 19,200 baud are selectable. A baud rate of 0 has special meaning, and turns off all simulated baud rate delays (on a real 6551, this means to use an external clock instead of the internal baud rate generator) A busy-wait loop between steps in the simulator control program has also been added. This uses the high-resolution 'System.nanoTime()' call to wait a specific number of nanoseconds before continuing. Symon now waits at least 1uS between clock cycles, trying to approach a real 1MHz 6502 in performance. It is far from perfect, but it's better than it was. Also refactored the status panel to use a BoxLayout, and DRY-up some of the code.
37 lines
1005 B
NASM
37 lines
1005 B
NASM
;;
|
|
;; Read input from the keyboard, and echo to console.
|
|
;;
|
|
|
|
|
|
.alias iobase $c000
|
|
.alias iostatus [iobase + 1]
|
|
.alias iocmd [iobase + 2]
|
|
.alias ioctrl [iobase + 3]
|
|
|
|
.org $0300
|
|
|
|
start: cli
|
|
lda #$09
|
|
sta iocmd ; Set command status
|
|
lda #$1a
|
|
sta ioctrl ; 0 stop bits, 8 bit word, 2400 baud
|
|
|
|
;; Load a character from the keyboard and store it into
|
|
;; the accumulator
|
|
|
|
getkey: lda iostatus ; Read the ACIA status
|
|
and #$08 ; Is the rx register empty?
|
|
beq getkey ; Yes, wait for it to fill
|
|
lda iobase ; Otherwise, read into accumulator
|
|
|
|
;; Write the current char in the accumulator to the console
|
|
|
|
write: pha ; Save accumulator
|
|
lda iostatus ; Read the ACIA status
|
|
and #$10 ; Is the tx register empty?
|
|
beq write ; No, wait for it to empty
|
|
pla ; Otherwise, load saved accumulator
|
|
sta iobase ; and write to output.
|
|
|
|
jmp getkey ; Repeat
|