From ae998ec3dc84d4813b985e1804db12ed8e7ec4ed Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Mon, 18 Jan 2021 16:27:00 +0100 Subject: [PATCH] ROM Monitor clears remaining input buffer and waits for GPU to be ready before starting --- src/rom_monitor.z80 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rom_monitor.z80 b/src/rom_monitor.z80 index 3f8ac2b..c35cb55 100644 --- a/src/rom_monitor.z80 +++ b/src/rom_monitor.z80 @@ -25,11 +25,13 @@ ROM_monitor_stack: equ 0x10ff ;upper TPA in RAM, below RAM monitor ;Needs to be called only once after computer comes out of reset. ;If called while port is active will cause port to fail. ;16x = 9600 baud -initialize_port: ld a,04eh ;1 stop bit, no parity, 8-bit char, 16x baud - out (3),a ;write to control port - ld a,037h ;enable receive and transmit - out (3),a ;write to control port - out (3),a ;write to control port +initialize: in a,(0x1E) ; Clear out input buffer + in a,(0x1F) + and 0x01 + jp nz, initialize +initialize_2: in a,(3) ; Wait for GPU to be ready + and 0x02 + jp nz, initialize_2 ret ; ;Puts a single char (byte value) on serial output @@ -455,7 +457,7 @@ decimal_error_msg: defm 13,10,"Error: invalid decimal number, try again: ",0 ; ;Simple monitor program for CPUville Z80 computer with serial interface. monitor_cold_start: ld sp,ROM_monitor_stack - call initialize_port + call initialize ld hl,monitor_message call write_string monitor_warm_start: call write_newline ;routine program return here to avoid re-initialization of port