Code Search for Developers
 
 
  

al386wat.h from Allegro game programming library at Krugle


Show al386wat.h syntax highlighted

/*         ______   ___    ___
 *        /\  _  \ /\_ \  /\_ \
 *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
 *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
 *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
 *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
 *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
 *                                           /\____/
 *                                           \_/__/
 *
 *      Inline functions (Watcom style 386 asm).
 *
 *      By Shawn Hargreaves.
 *
 *      See readme.txt for copyright information.
 */


#if (!defined ALLEGRO_WATCOM) || (!defined ALLEGRO_I386)
   #error bad include
#endif


#ifdef ALLEGRO_IMPORT_GFX_ASM

/* _default_ds:
 *  Return a copy of the current %ds selector.
 */
int _default_ds(void);

#pragma aux _default_ds =     \
   " mov eax, 0 "             \
   " mov ax, ds "             \
			      \
   value [eax];



/* _my_cs:
 *  Return a copy of the current %cs selector.
 */
int _my_cs(void);

#pragma aux _my_cs =          \
   " mov eax, 0 "             \
   " mov ax, cs "             \
			      \
   value [eax];



/* bmp_write_line/bmp_read_line:
 *  Bank switch functions.
 */
unsigned long _bmp_bank_switcher(AL_BITMAP *bmp, int al_draw_line, void *bank_switch);

#pragma aux _bmp_bank_switcher =    \
   " call ecx "                     \
				    \
   parm [edx] [eax] [ecx]           \
   value [eax];

#define bmp_write_line(bmp, al_draw_line)   _bmp_bank_switcher(bmp, al_draw_line, (void *)bmp->write_bank)
#define bmp_read_line(bmp, al_draw_line)    _bmp_bank_switcher(bmp, al_draw_line, (void *)bmp->read_bank)



/* bmp_unwrite_line:
 *  Terminate bank switch function.
 */
void _bmp_unbank_switcher(AL_BITMAP *bmp, void *bank_unswitcher);

#pragma aux _bmp_unbank_switcher =  \
   " call ecx "                     \
				    \
   parm [edx] [ecx];

#define bmp_unwrite_line(bmp)       _bmp_unbank_switcher(bmp, (void *)bmp->vtable->unwrite_bank)

#endif /* ALLEGRO_IMPORT_GFX_ASM */


#ifdef ALLEGRO_IMPORT_MATH_ASM

/* _set_errno_erange:
 *  Watcom's asm syntax doesn't provide any nice way to do this inline...
 */
AL_INLINE(void, _set_errno_erange, (void),
{
   *allegro_errno = ERANGE;
})



/* al_fix_add:
 *  Fixed point (16.16) addition.
 */
fixed al_fix_add(fixed x, fixed y);

#pragma aux al_fix_add =             \
   "  add eax, edx "             \
   "  jno Out1 "                 \
   "  call _set_errno_erange "   \
   "  mov eax, 0x7FFFFFFF "      \
   "  cmp edx, 0 "               \
   "  jg Out1 "                  \
   "  neg eax "                  \
   " Out1: "                     \
				 \
   parm [eax] [edx]              \
   value [eax];



/* al_fix_sub:
 *  Fixed point (16.16) subtraction.
 */
fixed al_fix_sub(fixed x, fixed y);

#pragma aux al_fix_sub =             \
   "  sub eax, edx "             \
   "  jno Out1 "                 \
   "  call _set_errno_erange "   \
   "  mov eax, 0x7FFFFFFF "      \
   "  cmp edx, 0 "               \
   "  jl Out1 "                  \
   "  neg eax "                  \
   " Out1: "                     \
				 \
   parm [eax] [edx]              \
   value [eax];



/* al_fix_mul:
 *  Fixed point (16.16) multiplication.
 */
fixed al_fix_mul(fixed x, fixed y);

#pragma aux al_fix_mul =             \
   "  mov eax, ebx "             \
   "  imul ecx "                 \
   "  shrd eax, edx, 16 "        \
   "  sar edx, 15 "              \
   "  jz Out2 "                  \
   "  cmp edx, -1 "              \
   "  jz Out2 "                  \
   "  call _set_errno_erange "   \
   "  mov eax, 0x7FFFFFFF "      \
   "  cmp ebx, 0 "               \
   "  jge Out1 "                 \
   "  neg eax "                  \
   " Out1: "                     \
   "  cmp ecx, 0 "               \
   "  jge Out2 "                 \
   "  neg eax "                  \
   " Out2: "                     \
				 \
   parm [ebx] [ecx]              \
   modify [edx]                  \
   value [eax];



/* al_fix_div:
 *  Fixed point (16.16) division.
 */
fixed al_fix_div(fixed x, fixed y);

#pragma aux al_fix_div =             \
   "  xor ebx, ebx "             \
   "  or eax, eax "              \
   "  jns Out1 "                 \
   "  neg eax "                  \
   "  inc ebx "                  \
   " Out1: "                     \
   "  or ecx, ecx "              \
   "  jns Out2 "                 \
   "  neg ecx "                  \
   "  inc ebx "                  \
   " Out2: "                     \
   "  mov edx, eax "             \
   "  shr edx, 0x10 "            \
   "  shl eax, 0x10 "            \
   "  cmp edx, ecx "             \
   "  jae Out3 "                 \
   "  div ecx "                  \
   "  or eax, eax "              \
   "  jns Out4 "                 \
   " Out3: "                     \
   "  call _set_errno_erange "   \
   "  mov eax, 0x7FFFFFFF "      \
   " Out4: "                     \
   "  test ebx, 1 "              \
   "  je Out5 "                  \
   "  neg eax "                  \
   " Out5: "                     \
				 \
   parm [eax] [ecx]              \
   modify [ebx edx]              \
   value [eax];



/* al_fix_floor :
 * Fixed point version of floor().
 * Note that it returns an integer result (not a fixed one)
 */
int al_fix_floor(fixed x);

#pragma aux al_fix_floor =           \
   "  sar eax, 0x10 "		 \
				 \
   parm [eax]			 \
   value [eax];



/* al_fix_ceil :
 * Fixed point version of ceil().
 * Note that it returns an integer result (not a fixed one)
 */
int al_fix_ceil(fixed x);

#pragma aux al_fix_ceil =            \
   "  add eax, 0xFFFF "		 \
   "  jns Out1 "		 \
   "  jo  Out2 "		 \
   " Out1: "			 \
   "  sar eax, 0x10 "		 \
   "  jmp Out3 "		 \
   " Out2: "			 \
   "  call _set_errno_erange "	 \
   "  mov eax, 0x7FFF "		 \
   " Out3: "			 \
				 \
   parm [eax]			 \
   value [eax];

#endif /* ALLEGRO_IMPORT_MATH_ASM */





See more files for this project here

Allegro game programming library

Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming.

Project homepage: http://sourceforge.net/projects/alleg
Programming language(s): Assembly,C,Shell Script
License: other

  aintbeos.h
  aintdos.h
  aintlnx.h
  aintmac.h
  aintqnx.h
  aintunix.h
  aintwin.h
  al386gcc.h
  al386vc.h
  al386wat.h
  albcc32.h
  albecfg.h
  albeos.h
  aldjgpp.h
  aldos.h
  almac.h
  almaccfg.h
  almngw32.h
  almsvc.h
  alqnx.h
  alqnxcfg.h
  alucfg.h
  alunix.h
  alwatcom.h
  alwin.h
  macdef.h