Skip to content

Commit 014ab0c

Browse files
committed
Clear each new line, wrap when reaching bottom of screen
1 parent db3658a commit 014ab0c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/peripherals/display.mlog

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ reset_loop:
3232
# 498 = 70 characters
3333
set WRAP_X 505
3434

35+
# TODO: test this
36+
set WRAP_Y 8
37+
3538
set cur_x BASE_X
3639
set next_x BASE_X
3740

@@ -60,20 +63,36 @@ loop__newline:
6063
set next_x BASE_X
6164
op sub next_y next_y CHAR_HEIGHT
6265

66+
jump loop__no_overflow_y greaterThanEq next_y WRAP_Y
67+
set next_y BASE_Y
68+
loop__no_overflow_y:
69+
6370
loop__print_now:
6471
draw print cur_x cur_y topLeft
6572
set cur_x next_x
6673
set cur_y next_y
6774

75+
jump loop__no_print notEqual cur_x BASE_X # space in middle of line
76+
77+
# if we reach this point, we're at the start of a new line, so clear it
78+
draw color 0 0 0 255
79+
op sub y cur_y CHAR_HEIGHT
80+
op sub y y 3
81+
draw rect 6 y 500 CHAR_HEIGHT
82+
draw color 255 255 255 255
83+
84+
drawflush display1
85+
86+
jump loop__no_print equal char 32 # space at start of line
6887
jump loop__no_print equal char 10 # lf
69-
jump loop__no_print equal char 32 # space
7088

71-
op add next_x next_x CHAR_WIDTH # hack
89+
# if we reach this point, we're printing a character after moving to a new line, so shift next_x again
90+
op add next_x next_x CHAR_WIDTH
7291

7392
loop__same_line:
7493
printchar char
75-
loop__no_print:
7694

95+
loop__no_print:
7796
op add rptr rptr 1
7897
op mod rptr rptr UART_FIFO_MODULO
7998
write rptr UART 510

0 commit comments

Comments
 (0)