From b65a0249a5e10e7b9b73ef1aaa5fa91a2f88e779 Mon Sep 17 00:00:00 2001 From: "matthias@arch" Date: Sun, 31 Dec 2023 01:56:42 +0100 Subject: [PATCH] use masked writes for RA --- system/lcd.s65 | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/system/lcd.s65 b/system/lcd.s65 index 6912da7..b5222f5 100644 --- a/system/lcd.s65 +++ b/system/lcd.s65 @@ -22,9 +22,9 @@ charcount: .res 1 lda #$ff ; RB 0-7 output sta lcd::LCD_IO+IO::DDRB - MaskedWrite lcd::LCD_IO+IO::DDRA, #(lcd::RS | lcd::RW | lcd::E), #lcd::RA_MASK - ; lda #(lcd::RS | lcd::RW | lcd::E) ; RA 5-7 output - ; sta lcd::LCD_IO+IO::DDRA + lda lcd::LCD_IO+IO::DDRA + ora #(lcd::RS | lcd::RW | lcd::E) + sta lcd::LCD_IO+IO::DDRA ; init lcd lda #lcd::CMD_FUNCTION_SET @@ -176,26 +176,31 @@ charcount: .res 1 .proc _wait_nbusy pha stz lcd::LCD_IO + IO::DDRB ; set IO1-IO + IO::RB to input -@lcd_wait_nbusy_loop: ; read the busy flag - ; TODO use update_with_mask - lda #lcd::RW + lda lcd::LCD_IO + IO::RA + and #<~lcd::RA_MASK + ora #lcd::RW sta lcd::LCD_IO + IO::RA - lda #(lcd::RW | lcd::E) + +@lcd_wait_nbusy_loop: ; read the busy flag + ; set E low, then high + lda lcd::LCD_IO + IO::RA + and #<~lcd::E + sta lcd::LCD_IO + IO::RA + ora #lcd::E sta lcd::LCD_IO + IO::RA lda lcd::LCD_IO + IO::RB bmi @lcd_wait_nbusy_loop ; msb set - ; and #%10000000 ; and updates zero flag, if not set retry - ; bne @lcd_wait_nbusy_loop - lda #%00000000 ; TODO dont overwrite 0-4 + lda lcd::LCD_IO + IO::RA + and #<~lcd::RA_MASK sta lcd::LCD_IO + IO::RA lda #%11111111 ; set IO1-IO + IO::RB to output sta lcd::LCD_IO + IO::DDRB pla rts .endproc - + ;;******************************************************************************** ;; @function Send a command to the lcd