libdgl/DGLUTIL.H
Gered 62af8575c6 various updates i've left uncommitted for many months
- rename standard integer types to a more familiar (u)int(8/16/32)
- many function/struct renames. i don't _really_ know if what i've done
  for this is better, but it "feels" better to me. many draw/blit
  function names are shorter which is nice, at least. kinda important
  to me because i develop this on a real DOS machine in 80x50 text mode.
- add 'extern "C"' blocks to headers for C++ compiler usage
- draw/pixel color value arguments for functions should all have been
  changed to be uint8 instead of a full 32-bit int. feels right, but
  maybe should've left alone...
- small fix to keyboard handler. noticed a problem on one thinkpad
  laptop. was a result of what i think was a typo in a constant value
  used during the part of the interrupt handler that tells the keyboard
  controller the key event was processed
- fix uncommon potential crash function return in draw_filled_rect
- renamed low-level "direct" assembly functions to "lowlevel_xxx" to
  be a little bit more explicit about what they are
- add some convenience event helper functions for determining event
  types
- add fixed point atan2
- fixed some tabs/spaces inconsistences (should all be spaces now?)
- maybe some other minor things i've forgotten
2020-07-19 19:24:48 -04:00

108 lines
2.7 KiB
C
Executable file

#ifndef LIBDGL_DGLUTIL_H
#define LIBDGL_DGLUTIL_H
#include "dglcmn.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SWAP(type, a, b) \
do { \
type __tmp = a; \
a = b; \
b = __tmp; \
} while (0)
#define SIGN(x) (((x) < 0) ? -1 : (((x) > 0) ? 1 : 0))
uint32 sys_clock();
float clock_ticks_to_seconds(uint32 clocks);
int rnd_int(int low, int high);
float rnd_float(float low, float high);
void int_enable(void);
#pragma aux int_enable = "sti"
void int_disable(void);
#pragma aux int_disable = "cli"
int32 fill32(uint8 value);
#pragma aux fill32 = \
"mov ah, al" \
"shl eax, 8" \
"mov al, ah" \
"shl eax, 8" \
"mov al, ah" \
parm [al] \
value [eax];
void REP_MOVSD(const void *src, void *dest, uint32 num_dwords);
#pragma aux REP_MOVSD = \
"cld" \
"rep movsd" \
parm [esi] [edi] [ecx];
void REP_MOVSB(const void *src, void *dest, uint32 num_bytes);
#pragma aux REP_MOVSB = \
"cld" \
"rep movsb" \
parm [esi] [edi] [ecx];
void REP_STOSD(uint32 value, void *dest, uint32 num_dwords);
#pragma aux REP_STOSD = \
"cld" \
"rep stosd" \
parm [eax] [edi] [ecx];
void REP_STOSB(uint32 value, void *dest, uint32 num_bytes);
#pragma aux REP_STOSB = \
"cld" \
"rep stosb" \
parm [eax] [edi] [ecx];
void mem_fill(void *dest, uint8 value, uint32 num_bytes);
#pragma aux mem_fill = \
"mov ah, al" \
"mov bx, ax" \
"shl eax, 16" \
"mov ax, bx" \
"mov ebx, ecx" \
"shr ecx, 2" \
"and ebx, 3" \
"rep stosd" \
"mov ecx, ebx" \
"rep stosb" \
parm [edi] [al] [ecx] \
modify [eax ebx ecx edi];
void mem_fill32(void *dest, uint32 value, uint32 num_bytes);
#pragma aux mem_fill32 = \
"mov ebx, ecx" \
"shr ecx, 2" \
"and ebx, 3" \
"rep stosd" \
"mov ecx, ebx" \
"rep stosb" \
parm [edi] [eax] [ecx] \
modify [eax ebx ecx edi];
void mem_copy(void *dest, const void *src, uint32 num_bytes);
#pragma aux mem_copy = \
"mov ebx, ecx" \
"shr ecx, 2" \
"and ebx, 3" \
"rep movsd" \
"mov ecx, ebx" \
"rep movsb" \
parm [edi] [esi] [ecx] \
modify [eax ebx ecx];
#ifdef __cplusplus
}
#endif
#endif