Working character output, non working return to home
This commit is contained in:
parent
9de4753984
commit
154e4dc10c
@ -9,8 +9,8 @@
|
|||||||
.equ LINE_COLUMNS = 52 ; number of columns (characters or chunks) per line
|
.equ LINE_COLUMNS = 52 ; number of columns (characters or chunks) per line
|
||||||
|
|
||||||
; Draws character in register A to the screen at current coords (Y)
|
; Draws character in register A to the screen at current coords (Y)
|
||||||
; @param A (r0) ascii code to display
|
; @param r16 (HIGH_ACCUM) ascii code to display
|
||||||
; @modifies r0 (A), r1, r2, r3, r16 (HIGH_ACCUM), Y, Z
|
; @modifies r0 (A), r1, r2, r3, r16 (HIGH_ACCUM), r17, Y, Z
|
||||||
draw_char:
|
draw_char:
|
||||||
; Glyph's first byte is at:
|
; Glyph's first byte is at:
|
||||||
; glyph_pointer = font_starting_mem_pos + (ascii_code * number_of_bytes_per_font)
|
; glyph_pointer = font_starting_mem_pos + (ascii_code * number_of_bytes_per_font)
|
||||||
@ -22,13 +22,13 @@ draw_char:
|
|||||||
mov r3, YH
|
mov r3, YH
|
||||||
|
|
||||||
; Load first glyph position on Z
|
; Load first glyph position on Z
|
||||||
ldi ZH, high(FONT)
|
ldi ZH, high(FONT<<1)
|
||||||
ldi ZL, low(FONT)
|
ldi ZL, low(FONT<<1)
|
||||||
; Obtain offset multiplying ascii_code * number_of_bytes_per_fontr1
|
; Obtain offset multiplying ascii_code * number_of_bytes_per_font
|
||||||
ldi HIGH_ACCUM, FONT_HEIGHT
|
ldi r17, FONT_HEIGHT
|
||||||
mul A, HIGH_ACCUM ; result overwrites r0 and r1!
|
mul HIGH_ACCUM, r17 ; result overwrites r0 and r1!
|
||||||
; 16-bit addition between gliph's first byte position and offset (and store result in Z)
|
; 16-bit addition between gliph's first byte position and offset (and store result in Z)
|
||||||
add ZL, A
|
add ZL, r0
|
||||||
adc ZH, r1
|
adc ZH, r1
|
||||||
; Z contain our glyph's first byte position: draw it
|
; Z contain our glyph's first byte position: draw it
|
||||||
; The drawing consist of FONT_HEIGHT cycles. Every glyph byte is placed on its own line
|
; The drawing consist of FONT_HEIGHT cycles. Every glyph byte is placed on its own line
|
||||||
@ -49,3 +49,11 @@ draw_char:
|
|||||||
mov YH, r3
|
mov YH, r3
|
||||||
adiw YH:YL,1 ; just increment pre-char-drawing-saved chunk cursor position by 1
|
adiw YH:YL,1 ; just increment pre-char-drawing-saved chunk cursor position by 1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; Sets the cursor to 0,0 and clears fine position
|
||||||
|
cursor_pos_home:
|
||||||
|
; Set Y to framebuffer start
|
||||||
|
ldi YH, high(FRAMEBUFFER)
|
||||||
|
ldi YL, low(FRAMEBUFFER)
|
||||||
|
clr POS_FINE
|
||||||
|
ret
|
@ -31,10 +31,3 @@ comm_init:
|
|||||||
brne comm_wait_byte ; if not 0, repeat h_picture_loop
|
brne comm_wait_byte ; if not 0, repeat h_picture_loop
|
||||||
jmp comm_init ; filled all memory: reset framebuffer position
|
jmp comm_init ; filled all memory: reset framebuffer position
|
||||||
|
|
||||||
; Sets the cursor to 0,0 and clears fine position
|
|
||||||
cursor_pos_home:
|
|
||||||
; Set Y to framebuffer start
|
|
||||||
ldi YH, high(FRAMEBUFFER<<1)
|
|
||||||
ldi YL, low(FRAMEBUFFER<<1)
|
|
||||||
clr POS_FINE
|
|
||||||
ret
|
|
||||||
|
@ -68,29 +68,61 @@ main:
|
|||||||
ldi HIGH_ACCUM, 0x00
|
ldi HIGH_ACCUM, 0x00
|
||||||
out DDRB, HIGH_ACCUM ; set port as input (used as data bus)
|
out DDRB, HIGH_ACCUM ; set port as input (used as data bus)
|
||||||
|
|
||||||
|
; clear ram
|
||||||
|
;*** Load data into ram ***
|
||||||
|
; Set X to 0x0100
|
||||||
|
ldi r27, high(FRAMEBUFFER)
|
||||||
|
ldi r26, low(FRAMEBUFFER)
|
||||||
|
load_mem_loop:
|
||||||
|
clr r17
|
||||||
|
st X+, r17
|
||||||
|
; if reached the last framebuffer byte, exit cycle
|
||||||
|
cpi r27, 0b00111110
|
||||||
|
brne load_mem_loop ; if not 0, repeat h_picture_loop
|
||||||
|
cpi r26, 0b11000000
|
||||||
|
brne load_mem_loop ; if not 0, repeat h_picture_loop
|
||||||
|
|
||||||
; test draw character routine
|
; test draw character routine
|
||||||
ser r17
|
;call cursor_pos_home
|
||||||
test_draw_loop:
|
ldi HIGH_ACCUM, 'P'
|
||||||
ldi r16, 'P'
|
call draw_char
|
||||||
mov A, HIGH_ACCUM
|
ldi HIGH_ACCUM, 'A'
|
||||||
call draw_char
|
call draw_char
|
||||||
ldi HIGH_ACCUM, 'A'
|
ldi HIGH_ACCUM, 'T'
|
||||||
mov A, HIGH_ACCUM
|
call draw_char
|
||||||
call draw_char
|
ldi HIGH_ACCUM, '8'
|
||||||
ldi HIGH_ACCUM, 'T'
|
call draw_char
|
||||||
mov A, HIGH_ACCUM
|
ldi HIGH_ACCUM, '0'
|
||||||
call draw_char
|
call draw_char
|
||||||
ldi HIGH_ACCUM, '8'
|
ldi HIGH_ACCUM, ' '
|
||||||
mov A, HIGH_ACCUM
|
call draw_char
|
||||||
call draw_char
|
ldi HIGH_ACCUM, 'H'
|
||||||
ldi HIGH_ACCUM, '0'
|
call draw_char
|
||||||
mov A, HIGH_ACCUM
|
ldi HIGH_ACCUM, 'o'
|
||||||
call draw_char
|
call draw_char
|
||||||
ldi HIGH_ACCUM, ' '
|
ldi HIGH_ACCUM, 'm'
|
||||||
mov A, HIGH_ACCUM
|
call draw_char
|
||||||
call draw_char
|
ldi HIGH_ACCUM, 'e'
|
||||||
dec r17
|
call draw_char
|
||||||
breq test_draw_loop
|
ldi HIGH_ACCUM, ' '
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'c'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'o'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'm'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'p'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'u'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 't'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'e'
|
||||||
|
call draw_char
|
||||||
|
ldi HIGH_ACCUM, 'r'
|
||||||
|
call draw_char
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; *** timer setup (use 16-bit counter TC1) ***
|
; *** timer setup (use 16-bit counter TC1) ***
|
||||||
@ -109,7 +141,7 @@ main:
|
|||||||
; Timer setup completed.
|
; Timer setup completed.
|
||||||
|
|
||||||
; Wait for data (it never exits)
|
; Wait for data (it never exits)
|
||||||
jmp comm_init
|
;jmp comm_init
|
||||||
|
|
||||||
forever:
|
forever:
|
||||||
jmp forever
|
jmp forever
|
||||||
|
Loading…
Reference in New Issue
Block a user