Skip to content

Commit 79c76b6

Browse files
committed
Finish box-drawing
1 parent fe699c1 commit 79c76b6

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

examples/box.asm

+32-10
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ draw_top:
5252

5353
draw_bottom:
5454
mv A, 1 ; A contains the X coordinate
55-
push A, (1 + BOX_HEIGHT), BL_CORNER ; x, y, character
55+
push A, BOX_HEIGHT, BL_CORNER ; x, y, character
5656
call [draw_character]
5757
mv B, (BOX_WIDTH - 2)
5858
.loop:
5959
inc A
6060
push A, B
6161

62-
push A, (1+BOX_HEIGHT), DASH
62+
push A, BOX_HEIGHT, DASH
6363
call [draw_character]
6464

6565
pop B, A
@@ -68,15 +68,44 @@ draw_bottom:
6868
jnz B, [.loop]
6969

7070
inc A
71-
push A, (1+BOX_HEIGHT), BR_CORNER
71+
push A, BOX_HEIGHT, BR_CORNER
7272
call [draw_character]
7373

7474
ret
7575

7676
draw_left:
77+
inc A
78+
mv A, 1 ; A contains the Y coordinate
79+
mv B, (BOX_HEIGHT - 2)
80+
.loop:
81+
inc A
82+
push A, B
83+
84+
push 1, A, WALL
85+
call [draw_character]
86+
87+
pop B, A
88+
89+
dec B
90+
jnz B, [.loop]
91+
7792
ret
7893

7994
draw_right:
95+
mv A, 1 ; A contains the Y coordinate
96+
mv B, (BOX_HEIGHT - 2)
97+
.loop:
98+
inc A
99+
push A, B
100+
101+
push BOX_WIDTH, A, WALL
102+
call [draw_character]
103+
104+
pop B, A
105+
106+
dec B
107+
jnz B, [.loop]
108+
80109
ret
81110

82111
draw_hello:
@@ -106,7 +135,6 @@ draw_character:
106135
pop C, B, A ; character, Y, X
107136
push L, H ; store return address
108137
push A, C; save X coordinate and character
109-
jeq B, (1+BOX_HEIGHT), [dbg]
110138

111139
push B, 0, SCREEN_WIDTH, 0
112140
call [mul16] ; get Y offset
@@ -121,11 +149,5 @@ draw_character:
121149

122150
ret
123151

124-
dbg:
125-
push B, 0, SCREEN_WIDTH, 0
126-
call [mul16] ; get Y offset
127-
pop H, L ; get value
128-
halt
129-
130152
hello_str:
131153
@str "Hello world!"

src/emulator/display.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ unsafe impl Send for BufferPtr {}
2323

2424
impl TextBuffer {
2525
pub fn spawn() -> TextBuffer {
26-
let mut data = Box::pin([0; 1 << 12]);
27-
data[0] = 0x12;
26+
let data = Box::pin([0; 1 << 12]);
2827

2928
let handle = async_std::task::spawn(run_handle(BufferPtr(&*data)));
3029

0 commit comments

Comments
 (0)