Big refactoring and first character generator implementation

This commit is contained in:
Daniele Verducci (ZenPenguin) 2021-01-24 11:27:40 +01:00
parent 415300a2db
commit f49818caa1
5 changed files with 666 additions and 591 deletions

View File

@ -4,7 +4,48 @@
; ******************************************* ; *******************************************
; This module generates the character pixels using the font present in rom ; This module generates the character pixels using the font present in rom
; and adds it on the framebuffer in the position indicated by POS_COARSE. ; and adds it on the framebuffer in the position indicated by POS_COARSE (Y).
; Draws character in register A to the screen at current coords .equ LINE_COLUMNS = 52 ; number of columns (characters or chunks) per line
; Draws character in register A to the screen at current coords (Y)
; @param A (r0) ascii code to display
; @modifies r0 (A), r1, r2, r3, r16 (HIGH_ACCUM), Y, Z
draw_char: draw_char:
; Glyph's first byte is at:
; glyph_pointer = font_starting_mem_pos + (ascii_code * number_of_bytes_per_font)
; But all the fonts are 1 byte large, so a glyph is 1*height bytes:
; glyph_pointer = FONT + (ascii_code * FONT_HEIGHT)
; Save current chunk cursor position (Y)
mov r2, YL
mov r3, YH
; Load first glyph position on Z
ldi ZH, high(FONT)
ldi ZL, low(FONT)
; Obtain offset multiplying ascii_code * number_of_bytes_per_fontr1
ldi HIGH_ACCUM, FONT_HEIGHT
mul A, HIGH_ACCUM ; result overwrites r0 and r1!
; 16-bit addition between gliph's first byte position and offset (and store result in Z)
add ZL, A
adc ZH, r1
; 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
; on screen. To do this, we place it LINE_COLUMNS bytes after the previous one.
ldi HIGH_ACCUM, FONT_HEIGHT
draw_char_loop:
; Load glyph line byte from program memory (and point to the next)
lpm r1, Z+
; Write glyph line to framebuffer at chunk cursor position (Y)
st Y, r1
; Increment chunk cursor position (Y) to next line of the same char column
adiw YH:YL,LINE_COLUMNS
; Decrement loop counter and exit if reached 0
dec HIGH_ACCUM
brne draw_char_loop
; Char drawing is complete. Set chunk cursor position to next char first line
mov YL, r2 ; first restore Y
mov YH, r3
adiw YH:YL,1 ; just increment pre-char-drawing-saved chunk cursor position by 1
ret

View File

@ -5,27 +5,25 @@
; This module manages the communication between Pat80 and ; This module manages the communication between Pat80 and
; the video adapter. ; the video adapter.
; The data port is PORTB. The CLK (clock) signal is on PORTD0
; and the RS (register select) on PORTD1
; INTERNAL POINTER: ; INTERNAL POINTER:
; Internally, the last screen position is represented by 24 bits in two registers: ; Internally, the last screen position is represented by 24 bits in two registers:
; POS_COARSE: Register Z (16-bit, r31 and r30): Coarse position. Points to one of the chunks ; POS_COARSE: Register Y (16-bit, r31 and r30): Coarse position. Points to one of the chunks
; (character columns). 52 chunks per row, 304 rows. Used for character position, as ; (character columns). 52 chunks per row, 304 rows. Used for character position, as
; 1 chunk = 1 byte = 1 character. ; 1 chunk = 1 byte = 1 character.
; POS_FINE: Register r24: Fine position. Represents the bit inside the chunk selected by POS_COARSE. ; POS_FINE: Register r24: Fine position. Represents the bit inside the chunk selected by POS_COARSE.
; Ignored in character mode (the character is always aligned to column.) ; Ignored in character mode (the character is always aligned to column). Used in graphic mode.
; Initializes and waits for a byte on PORTB ; Initializes and waits for a byte on PORTB
comm_init: comm_init:
call cursor_pos_home ; Set cursor to 0,0 call cursor_pos_home ; Set cursor to 0,0
comm_wait_byte: comm_wait_byte:
in r24, PINB ; read PORTB in A, DATA_PORT_IN ; read PORTB
; Check continuously CLK until a LOW is found ; Check continuously CLK until a LOW is found
sbic PORTD, CLK_PIN sbic PORTD, CLK_PIN
jmp comm_wait_byte jmp comm_wait_byte
; CLK triggered: Copy PORTB to the next framebuffer byte ; CLK triggered: Copy PORTB to the next framebuffer byte
st Z+, r24 st Y+, A
; if reached the last framebuffer byte, exit cycle ; if reached the last framebuffer byte, exit cycle
cpi r31, 0b00111110 cpi r31, 0b00111110
brne comm_wait_byte ; if not 0, repeat h_picture_loop brne comm_wait_byte ; if not 0, repeat h_picture_loop
@ -35,8 +33,8 @@ comm_init:
; Sets the cursor to 0,0 and clears fine position ; Sets the cursor to 0,0 and clears fine position
cursor_pos_home: cursor_pos_home:
; Set Z to framebuffer start ; Set Y to framebuffer start
ldi POS_COARSE_H, high(FRAMEBUFFER<<1) ldi YH, high(FRAMEBUFFER<<1)
ldi POS_COARSE_L, low(FRAMEBUFFER<<1) ldi YL, low(FRAMEBUFFER<<1)
clr POS_FINE clr POS_FINE
ret ret

View File

@ -1,130 +1,131 @@
.equ FONT_HEIGHT = 8
; Temporary dhepper's font8x8 adaptation (https://github.com/dhepper/font8x8) ; Temporary dhepper's font8x8 adaptation (https://github.com/dhepper/font8x8)
FONT: FONT: .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0000 (nul)
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0000 (nul) .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0001
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0001 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0002
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0002 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0003
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0003 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0004
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0004 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0005
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0005 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0006
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0006 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0007
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0007 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0008
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0008 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0009
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0009 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+000A
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+000A .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+000B
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+000B .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+000C
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+000C .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+000D
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+000D .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+000E
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+000E .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+000F
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+000F .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0010
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0010 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0011
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0011 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0012
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0012 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0013
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0013 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0014
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0014 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0015
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0015 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0016
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0016 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0017
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0017 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0018
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0018 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0019
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0019 .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+001A
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+001A .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+001B
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+001B .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+001C
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+001C .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+001D
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+001D .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+001E
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+001E .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+001F
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+001F .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0020 (space)
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0020 (space) .db 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00, ; U+0021 (!)
.db 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00, // U+0021 (!) .db 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0022 (")
.db 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0022 (") .db 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00, ; U+0023 (#)
.db 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00, // U+0023 (#) .db 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00, ; U+0024 ($)
.db 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00, // U+0024 ($) .db 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00, ; U+0025 (%)
.db 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00, // U+0025 (%) .db 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00, ; U+0026 (&)
.db 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00, // U+0026 (&) .db 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0027 (')
.db 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0027 (') .db 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00, ; U+0028 (()
.db 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00, // U+0028 (() .db 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00, ; U+0029 ())
.db 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00, // U+0029 ()) .db 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, ; U+002A (*)
.db 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, // U+002A (*) .db 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00, ; U+002B (+)
.db 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00, // U+002B (+) .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06, ; U+002C (,)
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06, // U+002C (,) .db 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, ; U+002D (-)
.db 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, // U+002D (-) .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, ; U+002E (.)
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, // U+002E (.) .db 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, ; U+002F (/)
.db 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, // U+002F (/) .db 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00, ; U+0030 (0)
.db 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00, // U+0030 (0) .db 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00, ; U+0031 (1)
.db 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00, // U+0031 (1) .db 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00, ; U+0032 (2)
.db 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00, // U+0032 (2) .db 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00, ; U+0033 (3)
.db 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00, // U+0033 (3) .db 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00, ; U+0034 (4)
.db 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00, // U+0034 (4) .db 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00, ; U+0035 (5)
.db 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00, // U+0035 (5) .db 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00, ; U+0036 (6)
.db 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00, // U+0036 (6) .db 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00, ; U+0037 (7)
.db 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00, // U+0037 (7) .db 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00, ; U+0038 (8)
.db 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00, // U+0038 (8) .db 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00, ; U+0039 (9)
.db 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00, // U+0039 (9) .db 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00, ; U+003A (:)
.db 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00, // U+003A (:) .db 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06, ; U+003B (;)
.db 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06, // U+003B (;) .db 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00, ; U+003C (<)
.db 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00, // U+003C (<) .db 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00, ; U+003D (=)
.db 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00, // U+003D (=) .db 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00, ; U+003E (>)
.db 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00, // U+003E (>) .db 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00, ; U+003F (?)
.db 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00, // U+003F (?) .db 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00, ; U+0040 (@)
.db 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00, // U+0040 (@) .db 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00, ; U+0041 (A)
.db 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00, // U+0041 (A) .db 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00, ; U+0042 (B)
.db 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00, // U+0042 (B) .db 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00, ; U+0043 (C)
.db 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00, // U+0043 (C) .db 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00, ; U+0044 (D)
.db 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00, // U+0044 (D) .db 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00, ; U+0045 (E)
.db 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00, // U+0045 (E) .db 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00, ; U+0046 (F)
.db 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00, // U+0046 (F) .db 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00, ; U+0047 (G)
.db 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00, // U+0047 (G) .db 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00, ; U+0048 (H)
.db 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00, // U+0048 (H) .db 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, ; U+0049 (I)
.db 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, // U+0049 (I) .db 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00, ; U+004A (J)
.db 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00, // U+004A (J) .db 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00, ; U+004B (K)
.db 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00, // U+004B (K) .db 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00, ; U+004C (L)
.db 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00, // U+004C (L) .db 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00, ; U+004D (M)
.db 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00, // U+004D (M) .db 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00, ; U+004E (N)
.db 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00, // U+004E (N) .db 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, ; U+004F (O)
.db 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00, // U+004F (O) .db 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00, ; U+0050 (P)
.db 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00, // U+0050 (P) .db 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00, ; U+0051 (Q)
.db 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00, // U+0051 (Q) .db 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00, ; U+0052 (R)
.db 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00, // U+0052 (R) .db 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00, ; U+0053 (S)
.db 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00, // U+0053 (S) .db 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, ; U+0054 (T)
.db 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, // U+0054 (T) .db 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00, ; U+0055 (U)
.db 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00, // U+0055 (U) .db 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00, ; U+0056 (V)
.db 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00, // U+0056 (V) .db 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00, ; U+0057 (W)
.db 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00, // U+0057 (W) .db 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00, ; U+0058 (X)
.db 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00, // U+0058 (X) .db 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00, ; U+0059 (Y)
.db 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00, // U+0059 (Y) .db 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00, ; U+005A (Y)
.db 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00, // U+005A (Z) .db 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00, ; U+005B ([)
.db 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00, // U+005B ([) .db 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00, ; U+005C (\)
.db 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00, // U+005C (\) .db 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00, ; U+005D (])
.db 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00, // U+005D (]) .db 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, ; U+005E (^)
.db 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, // U+005E (^) .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, ; U+005F (_)
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, // U+005F (_) .db 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+0060 (`)
.db 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // U+0060 (`) .db 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00, ; U+0061 (a)
.db 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00, // U+0061 (a) .db 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, ; U+0062 (b)
.db 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00, // U+0062 (b) .db 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00, ; U+0063 (c)
.db 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00, // U+0063 (c) .db 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00, ; U+0064 (d)
.db 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00, // U+0064 (d) .db 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00, ; U+0065 (e)
.db 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00, // U+0065 (e) .db 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00, ; U+0066 (f)
.db 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00, // U+0066 (f) .db 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F, ; U+0067 (g)
.db 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F, // U+0067 (g) .db 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00, ; U+0068 (h)
.db 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00, // U+0068 (h) .db 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, ; U+0069 (i)
.db 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, // U+0069 (i) .db 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, ; U+006A (j)
.db 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, // U+006A (j) .db 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00, ; U+006B (k)
.db 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00, // U+006B (k) .db 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, ; U+006C (l)
.db 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, // U+006C (l) .db 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00, ; U+006D (m)
.db 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00, // U+006D (m) .db 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00, ; U+006E (n)
.db 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00, // U+006E (n) .db 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00, ; U+006F (o)
.db 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00, // U+006F (o) .db 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F, ; U+0070 (p)
.db 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F, // U+0070 (p) .db 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78, ; U+0071 (q)
.db 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78, // U+0071 (q) .db 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00, ; U+0072 (r)
.db 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00, // U+0072 (r) .db 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00, ; U+0073 (s)
.db 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00, // U+0073 (s) .db 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00, ; U+0074 (t)
.db 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00, // U+0074 (t) .db 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00, ; U+0075 (u)
.db 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00, // U+0075 (u) .db 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00, ; U+0076 (v)
.db 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00, // U+0076 (v) .db 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00, ; U+0077 (w)
.db 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00, // U+0077 (w) .db 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00, ; U+0078 (x)
.db 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00, // U+0078 (x) .db 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F, ; U+0079 (y)
.db 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F, // U+0079 (y) .db 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00, ; U+007A (z)
.db 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00, // U+007A (z) .db 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00, ; U+007B ({)
.db 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00, // U+007B ({) .db 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, ; U+007C (|)
.db 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, // U+007C (|) .db 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00, ; U+007D (})
.db 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00, // U+007D (}) .db 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ; U+007E (~)
.db 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // U+007E (~) .db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ; U+007F
.db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // U+007F

View File

@ -8,14 +8,21 @@
; If the busy pin is high, retry reading until goes low. When the busy pin goes low, we have... TODO ; If the busy pin is high, retry reading until goes low. When the busy pin goes low, we have... TODO
; ;
; ELECTRONICALLY: ; ELECTRONICALLY:
; The data port D0 (= PB0) is tied to ground with a 1KOhm resistance. When the MC is busy drawing the screen, the data port is in ; The data port PB0 is tied to ground with a 1KOhm resistance. When the MC is busy drawing the screen, the data port is in
; high impedance state, so that avoids causing bus contention, but when read returns a 0bXXXXXXX0 byte. When the MC starts vsync, ; high impedance state, so that avoids causing bus contention, but when read returns a 0bXXXXXXX0 byte. When the MC starts vsync,
; begins checking the port for data... TODO ; begins checking the port for data... TODO
; ;
; PINS: ; PINS:
; Video pin: PA0 (pin 1) ; Video:
; Video pin: PA0 (pin 1) (but all PORTA is used)
; Sync pin: PC0 (pin 22) ; Sync pin: PC0 (pin 22)
; Debug hsync pin: PC1 (pin 23) ; Communication:
; Data port is PORTB [INPUT]
; CLK (clock) signal is on PORTD0 [INPUT]
; RS (register select) on PORTD1 [INPUT]
; BUSY signal is on PORTD2 [OUTPUT]
; Debug:
; Debug hsync single pulse on pin: PC1 (pin 23) (may be disabled)
; ;
.include "m1284def.inc" ; Atmega 1280 device definition .include "m1284def.inc" ; Atmega 1280 device definition
@ -23,14 +30,21 @@
; reserved registers ; reserved registers
.def A = r0 ; accumulator .def A = r0 ; accumulator
.def STATUS = r25 ; signal status (see STATUS TABLE) .def STATUS = r25 ; signal status (see STATUS TABLE)
.def POS_COARSE = Z ; coarse position (aligned to character column) ;POS_COARSE = Y ; coarse position (aligned to character column)
.def POS_COARSE_H = r31 ;DRAWING_BYTE = X ; coarse position (aligned to character column)
.def POS_COARSE_L = r30
.def POS_FINE = r24 ; fine position (bit inside coarse-position-pointed byte) .def POS_FINE = r24 ; fine position (bit inside coarse-position-pointed byte)
.def LINE_COUNTER = r23 ; fine position (bit inside coarse-position-pointed byte)
.def VG_HIGH_ACCUM = r22 ; an accumulator in high registers to be used only by video_generator in interrupt
.def HIGH_ACCUM = r16 ; an accumulator in high registers to be used outside of interrupts
; define constant ; define constant
.equ VIDEO_PORT_OUT = PORTA ; Used all PORTA, but connected only PA0
.equ SYNC_PIN = PC0 ; Sync pin (pin 22) .equ SYNC_PIN = PC0 ; Sync pin (pin 22)
.equ DEBUG_PIN = PC1 ; DEBUG: Single vertical sync pulse to trigger oscilloscope (pin 23) .equ DEBUG_PIN = PC1 ; DEBUG: Single vertical sync pulse to trigger oscilloscope (pin 23)
.equ CLK_PIN = PD7 .equ DATA_PORT_IN = PINB
.equ CLK_PIN = PD0
.equ RS_PIN = PD1
.equ BUSY_PIN = PD2
; memory ; memory
.equ FRAMEBUFFER = 0x100 .equ FRAMEBUFFER = 0x100
@ -47,25 +61,26 @@ main:
; pins setup ; pins setup
sbi DDRC, SYNC_PIN ; set pin as output sbi DDRC, SYNC_PIN ; set pin as output
sbi DDRC, DEBUG_PIN ; set pin as output sbi DDRC, DEBUG_PIN ; set pin as output
sbi DDRC, BUSY_PIN ; set pin as output
cbi DDRD, CLK_PIN ; set pin as input cbi DDRD, CLK_PIN ; set pin as input
ldi r16, 0xFF ldi HIGH_ACCUM, 0xFF
out DDRA, r16 ; set port as output (contains video pin) out DDRA, HIGH_ACCUM ; set port as output (contains video pin)
ldi r16, 0x00 ldi HIGH_ACCUM, 0x00
out DDRB, r16 ; set port as input (used as data bus) out DDRB, HIGH_ACCUM ; set port as input (used as data bus)
; *** timer setup (use 16-bit counter TC1) *** ; *** timer setup (use 16-bit counter TC1) ***
; The Power Reduction TC1 and TC3 bits in the Power Reduction Registers (PRR0.PRTIM1 and ; The Power Reduction TC1 and TC3 bits in the Power Reduction Registers (PRR0.PRTIM1 and
; PRR1.PRTIM3) must be written to zero to enable the TC1 and TC3 module. ; PRR1.PRTIM3) must be written to zero to enable the TC1 and TC3 module.
ldi r16, 0b00000000 ldi HIGH_ACCUM, 0b00000000
sts PRR0, r16 sts PRR0, HIGH_ACCUM
; Set timer prescaler to 1:1 ; Set timer prescaler to 1:1
LDI r16,0b00000001 LDI HIGH_ACCUM,0b00000001
sts TCCR1B,r16 sts TCCR1B,HIGH_ACCUM
; Enambe timer1 overflow interrupt ; Enambe timer1 overflow interrupt
LDI r16,0b00000001 LDI HIGH_ACCUM,0b00000001
STS TIMSK1,r16 STS TIMSK1,HIGH_ACCUM
; Enable interrupts globally ; Enable interrupts globally
SEI SEI
; Timer setup completed. ; Timer setup completed.
@ -82,3 +97,4 @@ main:
.include "video_generator.asm" ; Asyncronous timer-interrupt-based video generation .include "video_generator.asm" ; Asyncronous timer-interrupt-based video generation
.include "character_generator.asm" ; Character generator .include "character_generator.asm" ; Character generator
.include "communication.asm" ; Communication with Pat80 .include "communication.asm" ; Communication with Pat80
.include "font.asm" ; Font face