use masked writes for RA

This commit is contained in:
matthias@arch 2023-12-31 01:56:42 +01:00
parent de098dd9c6
commit b65a0249a5

View File

@ -22,9 +22,9 @@ charcount: .res 1
lda #$ff ; RB 0-7 output lda #$ff ; RB 0-7 output
sta lcd::LCD_IO+IO::DDRB sta lcd::LCD_IO+IO::DDRB
MaskedWrite lcd::LCD_IO+IO::DDRA, #(lcd::RS | lcd::RW | lcd::E), #lcd::RA_MASK lda lcd::LCD_IO+IO::DDRA
; lda #(lcd::RS | lcd::RW | lcd::E) ; RA 5-7 output ora #(lcd::RS | lcd::RW | lcd::E)
; sta lcd::LCD_IO+IO::DDRA sta lcd::LCD_IO+IO::DDRA
; init lcd ; init lcd
lda #lcd::CMD_FUNCTION_SET lda #lcd::CMD_FUNCTION_SET
@ -176,26 +176,31 @@ charcount: .res 1
.proc _wait_nbusy .proc _wait_nbusy
pha pha
stz lcd::LCD_IO + IO::DDRB ; set IO1-IO + IO::RB to input stz lcd::LCD_IO + IO::DDRB ; set IO1-IO + IO::RB to input
@lcd_wait_nbusy_loop: ; read the busy flag lda lcd::LCD_IO + IO::RA
; TODO use update_with_mask and #<~lcd::RA_MASK
lda #lcd::RW ora #lcd::RW
sta lcd::LCD_IO + IO::RA 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 sta lcd::LCD_IO + IO::RA
lda lcd::LCD_IO + IO::RB lda lcd::LCD_IO + IO::RB
bmi @lcd_wait_nbusy_loop ; msb set 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 sta lcd::LCD_IO + IO::RA
lda #%11111111 ; set IO1-IO + IO::RB to output lda #%11111111 ; set IO1-IO + IO::RB to output
sta lcd::LCD_IO + IO::DDRB sta lcd::LCD_IO + IO::DDRB
pla pla
rts rts
.endproc .endproc
;;******************************************************************************** ;;********************************************************************************
;; @function Send a command to the lcd ;; @function Send a command to the lcd