diff --git a/system/lcd.s65 b/system/lcd.s65 index b6a63b5..90015df 100644 --- a/system/lcd.s65 +++ b/system/lcd.s65 @@ -152,14 +152,33 @@ charcount: .res 1 ;; @returns A: the cursor position ;;******************************************************************************** .proc set_position - cmp #$40 - bge @invalid - sta charcount pha + cmp #$60 + bge @invalid + cmp #$50 + bge @line4 + cmp #$40 + bge @line2 + cmp #$20 + bge @invalid + cmp #$10 + bge @line3 + bra @set +; @line1: ; starts at $00, charcount at $00 +@line2: ; starts at $40, charcount at $10 + sbc #$30 ; carry is already set + bra @set +@line3: ; starts at $10, charcount at $20 + add #$10 + bra @set +@line4: ; starts at $50, charcount at $30 + sbc #$20 +@set: + sta charcount + pla ora #lcd::CMD_SET_ADDRESS jsr _cmd - pla -@rts: + and #(<~lcd::CMD_SET_ADDRESS) ; return original argument rts @invalid: lda $14 @@ -167,7 +186,7 @@ charcount: .res 1 lda #(lcd::CMD_SET_ADDRESS | (lcd::LINE2 + 4)) jsr _cmd lda #(lcd::LINE2 + 4) - bra @rts + rts .endproc