; ; Raw Game Engine ; Copyright (C) 2023 Ernest Deak ; ; This program is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program. If not, see . ; ; This is the main include file for external programs %ifndef RAW_GAME_ENGINE_INC %define RAW_GAME_ENGINE_INC %include "inc/generic.inc" %include "inc/sdl2.inc" ;; Rendering optimization flag that updates objects ;; right before rendering them %ifndef RGE_OPTIM_UPDATE_DURING_RENDER %define RGE_OPTIM_UPDATE_DURING_RENDER 0 %endif ; Main include file for outside projects. ; Located here are all the RGE specific structures ; and macros used with the engine section .bss struc AnimSprite .img resq 1 ; pointer to SDL_Texture .width resd 1 ; total width .height resd 1 ; total height .visible resq 1 ; if not 0 the image is drawn, else its hidden .tile_start resq 1 .tile_end resq 1 .startframe resq 1 .frame resq 1 .endframe resq 1 .speed resq 1 ; animation speed in milliseconds. if 0, wont animate .dt_accum resq 1 ; delta time storage for speed calc .srcrect resb SDL_rect_size .dstrect resb SDL_frect_size ; full struct of an sdl rect or sdl frect .flip resd 1 endstruc defstruct_shortcuts AnimSprite ; Game related macros, simplifications, convenience and ease of use ;; Multiply delta time(ms) and desired value(ms) ;; and then divides by 1000 to get pixel movement per second ;; @param 1 - desired value in miliseconds (minimal value is 59 or 60) ;; @param 2 - register holding dt ;; @param 3 - temp. register to use for division ;; @param 4 (optional) - 'save' keyword. if supplied, temp. reg. will be preserved ;; @return rax - result movement in pixels per second %macro mul_dt 2-4 %ifidni %4, save push %3 %endif %if %1 < 60 %warning A value less than 60 will result in no movement! %endif ; 1 - value in ms mov rax, %1 mov %3, 1000 ; 2 - dt reg imul %2 ; rax = value * dt idiv %3 ; rax = final result %ifidni %4, save pop %3 %endif %endmacro ;; Multiply delta time with immediate operand ;; @param 1 - destination xmm register ;; @param 2 - value to multiply ;; @param 3 - xmm register holding dt ;; @return XMM - multiplited single prec. value in destination register %macro mulss_dt 3 mov eax, %2 cvtsi2ss %1, eax mulss %1, %3 %endmacro %macro RG_PRINTF 2 string2reg areg1, %1 %ifstr %2 string2reg areg2, %2 %else mov areg2, %2 %endif exmcall RG_Printf %endmacro %endif .