-
Notifications
You must be signed in to change notification settings - Fork 0
/
color.inc
91 lines (85 loc) · 3.36 KB
/
color.inc
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
85
86
87
88
89
90
91
struct _color_field _string*, _length*, _escape*, _categorie*, _payload*
.string: dd (_string)
.length: dd (_length)
.escape: db (_escape)
.categorie: db (_categorie)
.payload: dw (_payload)
ends
irp _kind*, fg,bg
{
_user_code _#_kind
xor eax, eax
mov al, _SYSCALL_ARGCPY
int 030H
mov edx, dword [_USER_SHELL_ARGUMENT_VIRTUAL]
test edx, edx
jnz _#_kind#_start
_#_kind#_error:
xor eax, eax
mov al, _SYSCALL_WRITE
mov ebx, _TELETYPE_CURRENT
mov ecx, _#_kind#_invalid
mov edx, _#_kind#_invalid.sizeof
int 030H
mov ebx, (not 0H)
jmp _#_kind#_exit
_#_kind#_start:
mov ebp, ((_#_kind#_color_table_end - _#_kind#_color_table) / _color_field.sizeof)
mov ebx, _#_kind#_color_table
_#_kind#_loop:
mov edi, (_USER_SHELL_ARGUMENT_VIRTUAL + 4H)
mov esi, dword [ebx+_color_field.string]
mov ecx, dword [ebx+_color_field.length]
jecxz _#_kind#_loop_update
cmp ecx, edx
ja _#_kind#_loop_update
rep cmpsb
jz _#_kind#_loop_continue
_#_kind#_loop_update:
add ebx, _color_field.sizeof
dec ebp
jnz _#_kind#_loop
jmp _#_kind#_error
_#_kind#_loop_continue:
sub edx, dword [ebx+_color_field.length]
jz _#_kind#_loop_display
mov ecx, edx
mov al, 020H
repz scasb
jnz _#_kind#_error
_#_kind#_loop_display:
xor eax, eax
mov al, _SYSCALL_WRITE
lea ecx, [ebx+_color_field.escape]
xor edx, edx
mov dl, 4H
mov ebx, _TELETYPE_CURRENT
int 030H
xor ebx, ebx
_#_kind#_exit:
xor eax, eax
mov al, _SYSCALL_EXIT
int 030H
_#_kind#_color_string_0 string "black"
_#_kind#_color_string_1 string "blue"
_#_kind#_color_string_2 string "green"
_#_kind#_color_string_3 string "cyan"
_#_kind#_color_string_4 string "red"
_#_kind#_color_string_5 string "magenta"
_#_kind#_color_string_6 string "brown"
_#_kind#_color_string_7 string "light"
match =fg, _kind \{ define _categorie _ESCAPE_CHANGE_FOREGROUND \}
match =bg, _kind \{ define _categorie _ESCAPE_CHANGE_BACKGROUND \}
_#_kind#_color_table:
_#_kind#_color_0 _color_field _#_kind#_color_string_0, _#_kind#_color_string_0.sizeof, _ESCAPE, _categorie, "00"
_#_kind#_color_1 _color_field _#_kind#_color_string_1, _#_kind#_color_string_1.sizeof, _ESCAPE, _categorie, "01"
_#_kind#_color_2 _color_field _#_kind#_color_string_2, _#_kind#_color_string_2.sizeof, _ESCAPE, _categorie, "02"
_#_kind#_color_3 _color_field _#_kind#_color_string_3, _#_kind#_color_string_3.sizeof, _ESCAPE, _categorie, "03"
_#_kind#_color_4 _color_field _#_kind#_color_string_4, _#_kind#_color_string_4.sizeof, _ESCAPE, _categorie, "04"
_#_kind#_color_5 _color_field _#_kind#_color_string_5, _#_kind#_color_string_5.sizeof, _ESCAPE, _categorie, "05"
_#_kind#_color_6 _color_field _#_kind#_color_string_6, _#_kind#_color_string_6.sizeof, _ESCAPE, _categorie, "06"
_#_kind#_color_7 _color_field _#_kind#_color_string_7, _#_kind#_color_string_7.sizeof, _ESCAPE, _categorie, "07"
_#_kind#_color_table_end:
_#_kind#_invalid string `_kind, " invalid usage", 00AH
end _user_code
}