-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathborder.asm
84 lines (63 loc) · 1.96 KB
/
border.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
section .data
NW: db "╔", 0
NE: db "╗", 0
SE: db "╝", 0
SW: db "╚", 0
HORI: db "═", 0
VERT: db "║", 0
section .text
global draw_border
; Draw the border around the screen
; Prototype: long draw_border( struct LB* game, short width, short height );
draw_border:
push rbp
mov rbp, rsp
mov r8w, word [rdi - 14] ; max x
mov r9w, word [rdi - 16] ; max y
inc rsi ; x
inc rdx ; y
xor rax, rax
cmp si, 1
jle draw_border.if_west ; It's the left
cmp si, r8w
jge draw_border.if_east ; It's the right
cmp dx, 1
jle draw_border.hori ; It's the top
cmp dx, r9w
jge draw_border.hori ; It's the bottom
jmp draw_border.if_end ; Return with 0
draw_border.if_west:
cmp dx, 1
jle draw_border.if_west_north
cmp dx, r9w
jge draw_border.if_west_south
jmp draw_border.vert
draw_border.if_east:
cmp dx, 1
jle draw_border.if_east_north
cmp dx, r9w
jge draw_border.if_east_south
jmp draw_border.vert
draw_border.if_west_north:
mov eax, dword [NW]
jmp draw_border.if_end
draw_border.if_west_south:
mov eax, dword [SW]
jmp draw_border.if_end
draw_border.if_east_north:
mov eax, dword [NE]
jmp draw_border.if_end
draw_border.if_east_south:
mov eax, dword [SE]
jmp draw_border.if_end
draw_border.hori:
mov eax, dword [HORI]
jmp draw_border.if_end
draw_border.vert:
mov eax, dword [VERT]
draw_border.if_end:
mov r10, 0x3937
shl r10, 32
or rax, r10
pop rbp
ret