Hello, today i decide to make this topic for sharing macro (HLA macro, ...)
This file contains a lot of type of macro:
I/ Factorization CPU instructions (easy to upgrade)
This kind of macro give the possibility to factorize instructions's block.
Algo:
call func_1 ..
call func_2 ....
call func_3 ...... --> call func_1, func_2, func_3, func_4, func_5
call func_4 ....
call func_5 ..
Exemple:
call_ display_screen, display_fps , clear_screen, windows_event
vbroadcastss_ {ymm0, [fsincosps_cos + _1x]}, {ymm1, [fsincosps_cos + _1y]}, {ymm2, [fsincosps_cos + _1z]}
vbroadcastss_ {ymm3, [fsincosps_sin + _1x]}, {ymm4, [fsincosps_sin + _1y]}, {ymm5, [fsincosps_sin + _1z]}
vbroadcastf128_ {ymm6, [r8 + OBJ3D_POSITION]}, {ymm7, [r8 + OBJ3D_REPERE ]}
vbroadcastss_ {ymm0, [temp2 + _1x ]}, {ymm1, [temp2 + _1y ]}, {ymm2, [temp2 + _1z ]}
vbroadcastss_ {ymm3, [temp2 + _1x + _1xmm]}, {ymm4, [temp2 + _1y + _1xmm]}, {ymm5, [temp2 + _1z + _1xmm]}
II/ if elseif else endif | while endwhile (very long macro, cause it doesn't exist concatenation of comparaison (|| && OR AND)
It's just C-like, except of give the possibility to decide or not where branch if the condition is met (label) and the trivial one, write after endwhile, the
modification of operand's value.
Unfortunally, this macro can't get more one elseif.
Exemple:
while rsi ,<, tmp_end_scene_3D
;{
%include "1.ASM\HackEngine\Source\show_world\show_pixel.asm"
;}
endwhile {add rsi, voxel(2)}
;==========================================================================
; void manage_keyboard(UINT message, WPARAM state)
; Purpose : Manage keyboard
; Input : NONE
; Output : NONE
;==========================================================================
manage_keyboard:
;{
if [message] is i32(WM_KEYDOWN)
endif
; ALT + ²
if [message] is i32(260)
;{
if i64 [word_param_msg] is 222, quit_program
endif
;}
endif
if [message] is i32(WM_CLOSE) , quit_program
elseif [message] is i32(WM_DESTROY), quit_program
endif
;}
end_manage_keyboard:
;==========================================================================
; / manage_keyboard
;==========================================================================
quit_program:
; 1x
if xmm0 ,>=, [plimit_x], .end_putpixel
endif
if xmm0 ,<=, [mlimit_x], .end_putpixel
endif
vmovss xmm0, [showpixel_xy + 4]
; 1y
if xmm0 ,>=, [plimit_y], .end_putpixel
endif
if xmm0 ,<=, [mlimit_y], .end_putpixel
endif
vmovss xmm0, [rsi + _1z]
; 1z
if xmm0 ,<=, [_0], .end_putpixel
endif
; ...
.end_putpixel:
III/ Some defines (beta)
Exemple:
while [quit] is false
;{
; ...
;}
endwhile
ret
IV/ Write in single line, multiple instructions
Exemple:
_{vsubps xmm1, xmm0, [prev_coord_mouse]}, {vaddps xmm1, [cam_angle]}
V/ ... (lazy to put a title)
Example:
m2m [rdx + _1color], [rsi + _1color], eax
m2m [rdx + _2color], [rsi + _2color], eax
m2m [rdx + _3color], [rsi + _3color], eax
m2m [rdx + _4color], [rsi + _4color], eax
VI/ ...
Example:
. [instance] is rcx
. [previous_instance] is rdx
. [cmd_line] is r8
. [cmd_show] is r9d
VII/ WinAPI macro
Example:
printf_ "FPS = %d", [fps_data]
LoadImageA_ 0, "data\Hackengine_logo.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE
VIII/ ASM data types
Example:
int32 nbr1
int64 nbr2
float32 nbr3
float64 nbr4
vector2D point2D
vector3D point3D
_int32 nbr1, 32
_int64 nbr2, 64
_float32 nbr3, 32.0
_float64 nbr4, 64.0
_vector2D point2D, 10, 20
_vector3D point3D, 10, 20, 30, 0
char str0 is "Hello"
; tab_f32/i32 for create 16 * 32 bit variables
ftab pi_180 is 0.01745329
ftab pi is 3.14159265
ftab ps_inv_sign is -1.0 ; MUL
ftab ps_pos_sign is 0x7FFFFFFF ; AND
ftab ps_neg_sign is 0x80000000 ; OR
ftab _100.0 is 100.0
ftab _32.0 is 32.0
ftab _20.0 is 20.0
ftab _8.0 is 8.0
ftab _5.0 is 5.0
ftab _2.0 is 2.0
ftab _1.0 is 1.0
ftab _0.01 is 0.01
itab _0 is 0
itab _32 is 32
Enjoy