Replace magic nums to constants

This commit is contained in:
Gleb Zaharov 2023-06-19 23:32:18 +03:00
parent b7031863c2
commit 91d8b54a56
3 changed files with 22 additions and 9 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
**/*.rs.bk
/Cargo.lock
/rust_dos.com
rust.kex

10
src/func_constants.inc Normal file
View File

@ -0,0 +1,10 @@
SF_TERMINATE_PROCESS = -1
SF_CREATE_WINDOW = 0
SF_PUT_PIXEL = 1
SF_GET_KEY = 2
SF_GET_SYS_TIME = 3
SF_DRAW_TEXT = 4
SF_WAIT_EVENT = 10
SF_REDRAW = 12
SSF_BEGIN_DRAW = 1
SSF_END_DRAW = 2

View File

@ -1,5 +1,7 @@
format ELF
include "src/func_constants.inc"
section '.text'
public _exit
public _start_window_draw
@ -10,25 +12,25 @@ section '.text'
public _pressed_key
_exit:
mov eax, -1
mov eax, SF_TERMINATE_PROCESS
int 0x40
_start_window_draw:
mov eax, 0xc
mov ebx, 1
mov eax, SF_REDRAW
mov ebx, SSF_BEGIN_DRAW
int 0x40
ret
_end_window_draw:
mov eax, 0xc
mov ebx, 2
mov eax, SF_REDRAW
mov ebx, SSF_END_DRAW
int 0x40
ret
_define_window:
push edi
push esi
xor eax, eax
mov eax, SF_CREATE_WINDOW
mov ebx, dword [esp + 0x0c]
mov ecx, dword [esp + 0x10]
mov edx, dword [esp + 0x14]
@ -42,7 +44,7 @@ _define_window:
_display_message:
push edi
push esi
mov eax, 4
mov eax, SF_DRAW_TEXT
mov ebx, dword [esp + 0x0c]
mov ecx, dword [esp + 0x10]
mov edx, dword [esp + 0x14]
@ -54,11 +56,11 @@ _display_message:
ret
_wait_event:
mov eax, 0xa
mov eax, SF_WAIT_EVENT
int 0x40
ret
_pressed_key:
mov eax, 2
mov eax, SF_GET_KEY
int 0x40
ret