Refinements

This commit is contained in:
Daniele Verducci su MatissePenguin 2021-02-20 11:21:15 +01:00
parent cc9805f044
commit 97adb88023
3 changed files with 16 additions and 14 deletions

View File

@ -56,19 +56,19 @@ draw_char:
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
draw_char_eol: draw_char_eol:
; Check if end of screen
cpi YH, high(FRAMEBUFFER_END)
brne draw_char_end
cpi YL, low(FRAMEBUFFER_END)
brne draw_char_end
; End of screen reached! Scroll framebuffer by 1 line
call scroll_screen
ret
draw_char_end:
; end of line ; end of line
clr POS_COLUMN ; reset column to 0
adiw YH:YL,1 ; increment chunk cursor position by 1 (begin of next line on screen) adiw YH:YL,1 ; increment chunk cursor position by 1 (begin of next line on screen)
clr POS_COLUMN ; reset column to 0
; check if reached end of screen
cpi POS_ROWP, SCREEN_HEIGHT-FONT_HEIGHT
breq draw_char_eos
; if not end of screen, increment row
ldi HIGH_ACCUM, FONT_HEIGHT
add POS_ROWP, HIGH_ACCUM
ret
draw_char_eos:
; end of screen: scroll screen but leave line pointer to last line
call scroll_screen
ret ret
; Sets the cursor to 0,0 and clears fine position ; Sets the cursor to 0,0 and clears fine position
@ -122,14 +122,15 @@ draw_carriage_return:
; Scrolls the screen by one line (=LINE_COLUMNS*FONT_HEIGHT bytes) ; Scrolls the screen by one line (=LINE_COLUMNS*FONT_HEIGHT bytes)
; and clears the last line (FRAMEBUFFER_END - LINE_COLUMNS*FONT_HEIGHT bytes) ; and clears the last line (FRAMEBUFFER_END - LINE_COLUMNS*FONT_HEIGHT bytes)
; @uses A, Z
scroll_screen: scroll_screen:
clr POS_COLUMN ; cursor to first column clr POS_COLUMN ; cursor to first column
; "Read" Pointer to first char of second line ; "Read" Pointer to first char of second line
ldi YH, high(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) ldi YH, high(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT)
ldi YL, low(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) ldi YL, low(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT)
; "Write" Pointer to first char of first line ; "Write" Pointer to first char of first line
ldi XH, high(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) ldi XH, high(FRAMEBUFFER)
ldi XL, low(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) ldi XL, low(FRAMEBUFFER)
; Copy data ; Copy data
scroll_screen_copy_loop: scroll_screen_copy_loop:
ld A, Y+ ld A, Y+

View File

@ -53,6 +53,7 @@
; memory ; memory
.equ FRAMEBUFFER = 0x0100 .equ FRAMEBUFFER = 0x0100
.equ FRAMEBUFFER_END = 0x2AB0 .equ FRAMEBUFFER_END = 0x2AB0
.equ SCREEN_HEIGHT = 256
; start vector ; start vector
.org 0x0000 .org 0x0000

View File

@ -158,7 +158,7 @@ draw_picture:
ldi r26, low(FRAMEBUFFER) ldi r26, low(FRAMEBUFFER)
; start 304 picture lines ; start 304 picture lines
ldi LINE_COUNTER, 255 ; line counter ldi LINE_COUNTER, SCREEN_HEIGHT-1 ; line counter
h_picture_loop: h_picture_loop:
; **** start line sync: 4uS, 96 cycles @ 24Mhz ; **** start line sync: 4uS, 96 cycles @ 24Mhz
; video pin goes low before sync ; video pin goes low before sync