From 97adb88023516f5eb8968f40d7b087a209f90aba Mon Sep 17 00:00:00 2001 From: Daniele Verducci su MatissePenguin Date: Sat, 20 Feb 2021 11:21:15 +0100 Subject: [PATCH] Refinements --- .../avr-assembly/character_generator.asm | 27 ++++++++++--------- .../software/avr-assembly/main.asm | 1 + .../software/avr-assembly/video_generator.asm | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/pat80-io-devices/composite-pal-adapter/software/avr-assembly/character_generator.asm b/pat80-io-devices/composite-pal-adapter/software/avr-assembly/character_generator.asm index 828be1f..d8cfb1b 100644 --- a/pat80-io-devices/composite-pal-adapter/software/avr-assembly/character_generator.asm +++ b/pat80-io-devices/composite-pal-adapter/software/avr-assembly/character_generator.asm @@ -56,19 +56,19 @@ draw_char: adiw YH:YL,1 ; just increment pre-char-drawing-saved chunk cursor position by 1 ret 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 - clr POS_COLUMN ; reset column to 0 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 ; 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) ; and clears the last line (FRAMEBUFFER_END - LINE_COLUMNS*FONT_HEIGHT bytes) +; @uses A, Z scroll_screen: clr POS_COLUMN ; cursor to first column ; "Read" Pointer to first char of second line ldi YH, high(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) ldi YL, low(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) ; "Write" Pointer to first char of first line - ldi XH, high(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) - ldi XL, low(FRAMEBUFFER+LINE_COLUMNS*FONT_HEIGHT) + ldi XH, high(FRAMEBUFFER) + ldi XL, low(FRAMEBUFFER) ; Copy data scroll_screen_copy_loop: ld A, Y+ diff --git a/pat80-io-devices/composite-pal-adapter/software/avr-assembly/main.asm b/pat80-io-devices/composite-pal-adapter/software/avr-assembly/main.asm index fe8a610..0fdc72a 100644 --- a/pat80-io-devices/composite-pal-adapter/software/avr-assembly/main.asm +++ b/pat80-io-devices/composite-pal-adapter/software/avr-assembly/main.asm @@ -53,6 +53,7 @@ ; memory .equ FRAMEBUFFER = 0x0100 .equ FRAMEBUFFER_END = 0x2AB0 +.equ SCREEN_HEIGHT = 256 ; start vector .org 0x0000 diff --git a/pat80-io-devices/composite-pal-adapter/software/avr-assembly/video_generator.asm b/pat80-io-devices/composite-pal-adapter/software/avr-assembly/video_generator.asm index e76cf4a..fe5c5f5 100644 --- a/pat80-io-devices/composite-pal-adapter/software/avr-assembly/video_generator.asm +++ b/pat80-io-devices/composite-pal-adapter/software/avr-assembly/video_generator.asm @@ -158,7 +158,7 @@ draw_picture: ldi r26, low(FRAMEBUFFER) ; start 304 picture lines - ldi LINE_COUNTER, 255 ; line counter + ldi LINE_COUNTER, SCREEN_HEIGHT-1 ; line counter h_picture_loop: ; **** start line sync: 4uS, 96 cycles @ 24Mhz ; video pin goes low before sync