Bugfix, refactoring
This commit is contained in:
parent
0697bc3753
commit
1d4c4f8d3f
@ -9,9 +9,15 @@
|
|||||||
.equ LINE_COLUMNS = 46 ; number of columns (characters or chunks) per line
|
.equ LINE_COLUMNS = 46 ; 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 r16 (HIGH_ACCUM) ascii code to display
|
; @param (HIGH_ACCUM) ascii code to display
|
||||||
; @modifies r0 (A), r1, r2, r3, r16 (HIGH_ACCUM), r17, Y, Z
|
; @modifies r0 (A), r1, r2, r3, r17, HIGH_ACCUM, Y, Z
|
||||||
draw_char:
|
draw_char:
|
||||||
|
; Check char is valid
|
||||||
|
cpi HIGH_ACCUM, 0x7f
|
||||||
|
brlo draw_char_valid
|
||||||
|
ret
|
||||||
|
|
||||||
|
draw_char_valid:
|
||||||
; 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)
|
||||||
; But all the fonts are 1 byte large, so a glyph is 1*height bytes:
|
; But all the fonts are 1 byte large, so a glyph is 1*height bytes:
|
||||||
@ -130,7 +136,7 @@ update_mem_pointer:
|
|||||||
; ...+POS_COLUMN
|
; ...+POS_COLUMN
|
||||||
add r0, POS_COLUMN
|
add r0, POS_COLUMN
|
||||||
clr HIGH_ACCUM
|
clr HIGH_ACCUM
|
||||||
adc r0, HIGH_ACCUM
|
adc r1, HIGH_ACCUM
|
||||||
; Set pointer to start of framebuffer
|
; Set pointer to start of framebuffer
|
||||||
ldi YL, low(FRAMEBUFFER)
|
ldi YL, low(FRAMEBUFFER)
|
||||||
ldi YH, high(FRAMEBUFFER)
|
ldi YH, high(FRAMEBUFFER)
|
||||||
@ -138,3 +144,17 @@ update_mem_pointer:
|
|||||||
add YL, r0
|
add YL, r0
|
||||||
adc YH, r1
|
adc YH, r1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
clear_screen:
|
||||||
|
ldi YH, high(FRAMEBUFFER)
|
||||||
|
ldi YL, low(FRAMEBUFFER)
|
||||||
|
load_mem_loop:
|
||||||
|
clr HIGH_ACCUM
|
||||||
|
;ser HIGH_ACCUM
|
||||||
|
st Y+, HIGH_ACCUM
|
||||||
|
; if reached the last framebuffer byte, exit cycle
|
||||||
|
cpi YH, high(FRAMEBUFFER_END)
|
||||||
|
brne load_mem_loop ; if not 0, repeat h_picture_loop
|
||||||
|
cpi YL, low(FRAMEBUFFER_END)
|
||||||
|
brne load_mem_loop ; if not 0, repeat h_picture_loop
|
||||||
|
ret
|
@ -6,13 +6,13 @@ draw_cat:
|
|||||||
ldi ZH, high(CAT_IMAGE)
|
ldi ZH, high(CAT_IMAGE)
|
||||||
ldi ZL, low(CAT_IMAGE)
|
ldi ZL, low(CAT_IMAGE)
|
||||||
load_cat_loop:
|
load_cat_loop:
|
||||||
lpm r17, Z+
|
lpm HIGH_ACCUM, Z+
|
||||||
st Y+, r17
|
st Y+, HIGH_ACCUM
|
||||||
; wait
|
; wait
|
||||||
ser r19
|
; ser r19
|
||||||
cat_wait_loop_1:
|
; cat_wait_loop_1:
|
||||||
dec r19
|
; dec r19
|
||||||
brne cat_wait_loop_1
|
; brne cat_wait_loop_1
|
||||||
; if reached the last framebuffer byte, exit cycle
|
; if reached the last framebuffer byte, exit cycle
|
||||||
cpi YH, high(FRAMEBUFFER_END)
|
cpi YH, high(FRAMEBUFFER_END)
|
||||||
brne load_cat_loop ; if not 0, repeat h_picture_loop
|
brne load_cat_loop ; if not 0, repeat h_picture_loop
|
||||||
|
@ -25,32 +25,30 @@
|
|||||||
.include "m1284def.inc" ; Atmega 1280 device definition
|
.include "m1284def.inc" ; Atmega 1280 device definition
|
||||||
|
|
||||||
; *** reserved registers ***
|
; *** reserved registers ***
|
||||||
; Cursor Position
|
; Video generator registers:
|
||||||
; POS_COLUMN (0-46) represents the character/chunk column
|
; X(R27, R26)
|
||||||
; POS_ROWP (0-255) represent the chunk row. The caracter row is POS_ROWP/FONT_HEIGHT
|
|
||||||
.def POS_COLUMN = r21
|
|
||||||
.def POS_ROWP = r20
|
|
||||||
; Internal registers
|
|
||||||
.def A = r0 ; accumulator
|
|
||||||
.def STATUS = r25 ; signal status (see STATUS TABLE)
|
.def STATUS = r25 ; signal status (see STATUS TABLE)
|
||||||
;POS_COARSE = Y ; coarse position (aligned to character column)
|
.def VG_HIGH_ACCUM = r24 ; an accumulator in high registers to be used only by video_generator in interrupt
|
||||||
;DRAWING_BYTE = X ; current position in framebuffer
|
|
||||||
.def LINE_COUNTER = r23
|
.def LINE_COUNTER = r23
|
||||||
.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
|
; Character generator registers:
|
||||||
|
.def POS_COLUMN = r22 ; POS_COLUMN (0-46) represents the character/chunk column
|
||||||
|
.def POS_ROWP = r21 ; POS_ROWP (0-255) represent the chunk row. The caracter row is POS_ROWP/FONT_HEIGHT
|
||||||
|
.def HIGH_ACCUM = r20 ; an accumulator in high registers to be used outside of interrupts
|
||||||
|
.def A = r0 ; general purpose accumulator to be used outside of interrupts
|
||||||
|
|
||||||
|
; Hardware pins and ports
|
||||||
.equ VIDEO_PORT_OUT = PORTA ; Used all PORTA, but connected only PA0
|
.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 DATA_PORT_IN = PINB
|
.equ DATA_PORT_IN = PIND
|
||||||
.equ CLK_PIN = PD0
|
.equ CLK_PIN = PC2
|
||||||
.equ RS_PIN = PD1
|
.equ RS_PIN = PC3
|
||||||
.equ BUSY_PIN = PD2
|
.equ BUSY_PIN = PC4
|
||||||
|
|
||||||
; memory
|
; Memory map
|
||||||
.equ FRAMEBUFFER = 0x0100
|
.equ FRAMEBUFFER = 0x0F70
|
||||||
.equ FRAMEBUFFER_END = 0x2F00
|
.equ FRAMEBUFFER_END = 0x3C00
|
||||||
.equ SCREEN_HEIGHT = 248
|
.equ SCREEN_HEIGHT = 248
|
||||||
|
|
||||||
; start vector
|
; start vector
|
||||||
@ -77,19 +75,7 @@ main:
|
|||||||
|
|
||||||
; **** MEMORY SETUP ****
|
; **** MEMORY SETUP ****
|
||||||
|
|
||||||
; clear ram
|
call clear_screen
|
||||||
;*** Load data into ram ***
|
|
||||||
Set X to 0x0100
|
|
||||||
ldi XH, high(FRAMEBUFFER)
|
|
||||||
ldi XL, low(FRAMEBUFFER)
|
|
||||||
load_mem_loop:
|
|
||||||
clr r17
|
|
||||||
st X+, r17
|
|
||||||
; if reached the last framebuffer byte, exit cycle
|
|
||||||
cpi XH, 0b00111110
|
|
||||||
brne load_mem_loop ; if not 0, repeat h_picture_loop
|
|
||||||
cpi XL, 0b11000000
|
|
||||||
brne load_mem_loop ; if not 0, repeat h_picture_loop
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +104,7 @@ main:
|
|||||||
; **** MAIN ROUTINE ****
|
; **** MAIN ROUTINE ****
|
||||||
|
|
||||||
; Wait for data (it never exits)
|
; Wait for data (it never exits)
|
||||||
; jmp comm_init
|
;jmp comm_init
|
||||||
|
|
||||||
|
|
||||||
; draw example image
|
; draw example image
|
||||||
@ -144,7 +130,7 @@ main:
|
|||||||
inc r18
|
inc r18
|
||||||
cpi r18, 0x5B
|
cpi r18, 0x5B
|
||||||
brne draw_chars
|
brne draw_chars
|
||||||
call draw_carriage_return
|
; call draw_carriage_return
|
||||||
jmp dctest
|
jmp dctest
|
||||||
|
|
||||||
|
|
||||||
@ -160,4 +146,4 @@ main:
|
|||||||
.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
|
.include "font.asm" ; Font face
|
||||||
.include "example_data/cat.asm" ; Cat image
|
;.include "example_data/cat.asm" ; Cat image
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user