Compare commits
No commits in common. "5ee9610616f37210e63235e0f9558a41a98136ee" and "eb2fb061a0bba85686a38f1626a98828fdcaa909" have entirely different histories.
5ee9610616
...
eb2fb061a0
@ -1,47 +0,0 @@
|
|||||||
.include "lcd.h65"
|
|
||||||
.include "ps2_keyboard_text_handler.h65"
|
|
||||||
|
|
||||||
.import home:absolute
|
|
||||||
|
|
||||||
.zeropage
|
|
||||||
ptr: .res 2
|
|
||||||
.bss
|
|
||||||
buffer: .res 256
|
|
||||||
|
|
||||||
.code
|
|
||||||
.proc init
|
|
||||||
stz ptr
|
|
||||||
stz ptr+1
|
|
||||||
stz buffer
|
|
||||||
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
.proc insert_mode
|
|
||||||
jsr lcd::clear
|
|
||||||
jsr kb::init
|
|
||||||
loop:
|
|
||||||
lda kb::char
|
|
||||||
beq @no_char
|
|
||||||
stz kb::char
|
|
||||||
jsr lcd::print_char
|
|
||||||
bra loop
|
|
||||||
@no_char:
|
|
||||||
lda kb::keycode
|
|
||||||
beq loop
|
|
||||||
|
|
||||||
cmp #kb::K::ESCAPE
|
|
||||||
beq k_esacpe
|
|
||||||
cmp #kb::K::PRINT
|
|
||||||
beq clear_display
|
|
||||||
cmp #kb::K::BACKSPACE
|
|
||||||
beq k_backspace
|
|
||||||
bra loop
|
|
||||||
k_esacpe:
|
|
||||||
jmp home
|
|
||||||
clear_display:
|
|
||||||
jsr lcd::clear
|
|
||||||
bra loop
|
|
||||||
k_backspace:
|
|
||||||
; go back
|
|
||||||
lda ' '
|
|
||||||
.endproc
|
|
@ -20,32 +20,7 @@ INCLUDE_LCD = 1
|
|||||||
.scope lcd
|
.scope lcd
|
||||||
LCD_IO = IO1
|
LCD_IO = IO1
|
||||||
Import lcd,init,clear,print,print_char,set_position,set_custom_char
|
Import lcd,init,clear,print,print_char,set_position,set_custom_char
|
||||||
Import lcd,_cmd,_wait_nbusy,_write_ram,_read_ram,_charcount
|
Import lcd,_cmd,_wait_nbusy,_write_ram,_read_ram
|
||||||
; PIN MASKS
|
|
||||||
E = %10000000
|
|
||||||
RW = %01000000
|
|
||||||
RS = %00100000
|
|
||||||
|
|
||||||
RA_MASK = %11100000
|
|
||||||
|
|
||||||
; LCD Instructions (see datasheet for more)
|
|
||||||
CMD_CLEAR = %00000001 ; clear display
|
|
||||||
CMD_ENTRY_MODE = %00000110 ; auto-shift cursor
|
|
||||||
CMD_DISPLAY_ON = %00001111 ; everything on, with blinking cursor
|
|
||||||
CMD_SHIFT_CUR_LEFT = %00101000 ; shift the display to the left
|
|
||||||
CMD_SHIFT_DIS_LEFT = %00111000 ; shift the display to the left
|
|
||||||
CMD_SHIFT_DIS_RIGHT = %00110000 ; shift the display to the right
|
|
||||||
CMD_SHIFT_CUR_RIGHT = %00100000 ; shift the display to the right
|
|
||||||
CMD_FUNCTION_SET = %00111000 ; 8-bit, 4 lines, 5x7 font
|
|
||||||
CMD_SET_CG_ADDRESS = %01000000 ; or with the address
|
|
||||||
CMD_SET_ADDRESS = %10000000 ; or with the address
|
|
||||||
; LCD Constants
|
|
||||||
LINE1 = $00
|
|
||||||
LINE2 = $40
|
|
||||||
LINE3 = $10
|
|
||||||
LINE4 = $50
|
|
||||||
|
|
||||||
.endscope
|
|
||||||
|
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
;; @macro Clear the screen and print a null-terminated string
|
;; @macro Clear the screen and print a null-terminated string
|
||||||
@ -98,38 +73,29 @@ LINE4 = $50
|
|||||||
jsr lcd::print
|
jsr lcd::print
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
; PIN MASKS
|
||||||
|
E = %10000000
|
||||||
|
RW = %01000000
|
||||||
|
RS = %00100000
|
||||||
|
|
||||||
;;********************************************************************************
|
RA_MASK = %11100000
|
||||||
;; @macro Print a null-terminated string
|
|
||||||
;; @param message: Address of the message or string literal
|
|
||||||
;;********************************************************************************
|
|
||||||
.macro lcd_SetCursor pos
|
|
||||||
.if .match (pos, a)
|
|
||||||
.elseif .match (pos, x)
|
|
||||||
txa
|
|
||||||
.elseif .match (pos, y)
|
|
||||||
tya
|
|
||||||
.else
|
|
||||||
lda #pos
|
|
||||||
.endif
|
|
||||||
sta lcd::_charcount
|
|
||||||
jsr lcd::_set_dd_ram_addr_from__charcount
|
|
||||||
.endmacro
|
|
||||||
|
|
||||||
;;********************************************************************************
|
|
||||||
;; @macro Print a null-terminated string
|
|
||||||
;; @param message: Address of the message or string literal
|
|
||||||
;;********************************************************************************
|
|
||||||
.macro lcd_AdvanceCursor n
|
|
||||||
.ifblank n
|
|
||||||
inc lcd::_charcount
|
|
||||||
.else
|
|
||||||
lda lcd::_charcount
|
|
||||||
add n
|
|
||||||
sta lcd::_charcount
|
|
||||||
.endif
|
|
||||||
jsr lcd::_set_dd_ram_addr_from__charcount
|
|
||||||
.endmacro
|
|
||||||
|
|
||||||
|
; LCD Instructions (see datasheet for more)
|
||||||
|
CMD_CLEAR = %00000001 ; clear display
|
||||||
|
CMD_ENTRY_MODE = %00000110 ; auto-shift cursor
|
||||||
|
CMD_DISPLAY_ON = %00001111 ; everything on, with blinking cursor
|
||||||
|
CMD_SHIFT_CUR_LEFT = %00101000 ; shift the display to the left
|
||||||
|
CMD_SHIFT_DIS_LEFT = %00111000 ; shift the display to the left
|
||||||
|
CMD_SHIFT_DIS_RIGHT = %00110000 ; shift the display to the right
|
||||||
|
CMD_SHIFT_CUR_RIGHT = %00100000 ; shift the display to the right
|
||||||
|
CMD_FUNCTION_SET = %00111000 ; 8-bit, 4 lines, 5x7 font
|
||||||
|
CMD_SET_CG_ADDRESS = %01000000 ; or with the address
|
||||||
|
CMD_SET_ADDRESS = %10000000 ; or with the address
|
||||||
|
; LCD Constants
|
||||||
|
LINE1 = $00
|
||||||
|
LINE2 = $40
|
||||||
|
LINE3 = $10
|
||||||
|
LINE4 = $50
|
||||||
|
|
||||||
|
.endscope
|
||||||
.endif ; guard
|
.endif ; guard
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
Export lcd,init,clear,print,print_char,set_position,set_custom_char
|
Export lcd,init,clear,print,print_char,set_position,set_custom_char
|
||||||
Export lcd,_cmd,_wait_nbusy,_write_ram,_read_ram,_charcount
|
Export lcd,_cmd,_wait_nbusy,_write_ram,_read_ram
|
||||||
; RAM VARIABLES
|
; RAM VARIABLES
|
||||||
.bss
|
.bss
|
||||||
_charcount: .res 1
|
charcount: .res 1
|
||||||
|
|
||||||
; TODO when clockspeeds are more than 1MHz, _cmd, _write_ram and _read_ram might need to be adjusted
|
; TODO when clockspeeds are more than 1MHz, _cmd, _write_ram and _read_ram might need to be adjusted
|
||||||
.code
|
.code
|
||||||
@ -36,7 +36,7 @@ _charcount: .res 1
|
|||||||
lda #lcd::CMD_ENTRY_MODE
|
lda #lcd::CMD_ENTRY_MODE
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
|
|
||||||
stz _charcount
|
stz charcount
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
@ -61,17 +61,17 @@ _charcount: .res 1
|
|||||||
cmp #$10
|
cmp #$10
|
||||||
bge @line3
|
bge @line3
|
||||||
bra @set
|
bra @set
|
||||||
; @line1: ; starts at $00, _charcount at $00
|
; @line1: ; starts at $00, charcount at $00
|
||||||
@line2: ; starts at $40, _charcount at $10
|
@line2: ; starts at $40, charcount at $10
|
||||||
sbc #$30 ; carry is already set
|
sbc #$30 ; carry is already set
|
||||||
bra @set
|
bra @set
|
||||||
@line3: ; starts at $10, _charcount at $20
|
@line3: ; starts at $10, charcount at $20
|
||||||
add #$10
|
add #$10
|
||||||
bra @set
|
bra @set
|
||||||
@line4: ; starts at $50, _charcount at $30
|
@line4: ; starts at $50, charcount at $30
|
||||||
sbc #$20
|
sbc #$20
|
||||||
@set:
|
@set:
|
||||||
sta _charcount
|
sta charcount
|
||||||
pla
|
pla
|
||||||
pha
|
pha
|
||||||
ora #lcd::CMD_SET_ADDRESS
|
ora #lcd::CMD_SET_ADDRESS
|
||||||
@ -82,7 +82,7 @@ _charcount: .res 1
|
|||||||
@invalid:
|
@invalid:
|
||||||
pla ; otherwise stack corruption
|
pla ; otherwise stack corruption
|
||||||
lda #$13
|
lda #$13
|
||||||
sta _charcount
|
sta charcount
|
||||||
lda #(lcd::CMD_SET_ADDRESS | (lcd::LINE2 + 3))
|
lda #(lcd::CMD_SET_ADDRESS | (lcd::LINE2 + 3))
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
lda #(lcd::LINE2 + 3)
|
lda #(lcd::LINE2 + 3)
|
||||||
@ -99,7 +99,7 @@ _charcount: .res 1
|
|||||||
;; @modifies A
|
;; @modifies A
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
.proc clear
|
.proc clear
|
||||||
stz _charcount
|
stz charcount
|
||||||
lda #lcd::CMD_CLEAR
|
lda #lcd::CMD_CLEAR
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
rts
|
rts
|
||||||
@ -131,7 +131,7 @@ _charcount: .res 1
|
|||||||
.proc print_char
|
.proc print_char
|
||||||
pha
|
pha
|
||||||
jsr _write_ram
|
jsr _write_ram
|
||||||
inc _charcount
|
inc charcount
|
||||||
jsr _break_line
|
jsr _break_line
|
||||||
pla ; put char back in a
|
pla ; put char back in a
|
||||||
.endproc
|
.endproc
|
||||||
@ -286,53 +286,11 @@ _charcount: .res 1
|
|||||||
|
|
||||||
|
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
;; @function Set the LCD DD-RAM Address from the character count
|
;; @function Set the LCD DD-RAM Address so that text linebreaks after 16 chars
|
||||||
;; @details
|
|
||||||
;; Sets the DD-RAM Address so that a line break occurs after 16 characters
|
|
||||||
;; If _charcount is more than $40, the position will be set to line 1.
|
|
||||||
;;********************************************************************************
|
|
||||||
.proc _set_dd_ram_addr_from__charcount
|
|
||||||
cmp #$40 ; set to line1 when full
|
|
||||||
bcs @wrap_to_line1
|
|
||||||
cmp #$10
|
|
||||||
bcc @line1
|
|
||||||
cmp #$20
|
|
||||||
bcc @line3
|
|
||||||
; bra @line4
|
|
||||||
@line4:
|
|
||||||
clc
|
|
||||||
adc #$20 ; _charcount $30-$3f -> $50 - $5f
|
|
||||||
bra @set_address
|
|
||||||
@wrap_to_line1:
|
|
||||||
sbc #$40
|
|
||||||
and #%00001111
|
|
||||||
; now every _charcount is mapped between 0 and $3f
|
|
||||||
bra @set_address
|
|
||||||
@line2:
|
|
||||||
adc #$30 ; _charcount $10-$1f -> $40 - $4f
|
|
||||||
bra @set_address
|
|
||||||
@line3:
|
|
||||||
sec
|
|
||||||
sbc #$10 ; _charcount $20-$2f -> $10 - $1f
|
|
||||||
bra @set_address
|
|
||||||
@line1: ; _charcount $00-$1f -> $00 - $0f - nothing to do
|
|
||||||
@set_address:
|
|
||||||
ora #lcd::CMD_SET_ADDRESS
|
|
||||||
jsr _cmd
|
|
||||||
rts
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
;;********************************************************************************
|
|
||||||
;; @function Set the LCD DD-RAM Address to te next line if the end of the line was reached
|
|
||||||
;; @details
|
|
||||||
;; If the cursor is past the end of a line, the DD-RAM Address is set to the next line.
|
|
||||||
;; If _charcount is more than $40, the position will be set to line 1.
|
|
||||||
;; This function is intended to be used with to set the correct address when
|
|
||||||
;; auto-shift is enabled
|
|
||||||
;;********************************************************************************
|
;;********************************************************************************
|
||||||
.proc _break_line
|
.proc _break_line
|
||||||
; check if checks are necessary
|
; check if checks are necessary
|
||||||
lda _charcount
|
lda charcount
|
||||||
beq @line1
|
beq @line1
|
||||||
bit #%10001111 ; ($10 | $20 | $30 | $40) = %01110000
|
bit #%10001111 ; ($10 | $20 | $30 | $40) = %01110000
|
||||||
beq @check
|
beq @check
|
||||||
@ -349,7 +307,7 @@ _charcount: .res 1
|
|||||||
bge @line1
|
bge @line1
|
||||||
rts
|
rts
|
||||||
@line1:
|
@line1:
|
||||||
stz _charcount
|
stz charcount
|
||||||
lda #(lcd::CMD_SET_ADDRESS | lcd::LINE1)
|
lda #(lcd::CMD_SET_ADDRESS | lcd::LINE1)
|
||||||
jsr _cmd
|
jsr _cmd
|
||||||
rts
|
rts
|
||||||
|
Loading…
Reference in New Issue
Block a user