Vfx.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  2. //ÛÛ ÛÛ
  3. //ÛÛ VFX.H: C type definitions & API function prototypes ÛÛ
  4. //ÛÛ ÛÛ
  5. //ÛÛ Source compatible with 32-bit 80386 C/C++ ÛÛ
  6. //ÛÛ ÛÛ
  7. //ÛÛ V0.10 of 10-Dec-92: Initial version ÛÛ
  8. //ÛÛ V1.01 of 12-May-93: Added VFX_shape_lookaside(), new polygon calls ÛÛ
  9. //ÛÛ PCX_draw() returns void ÛÛ
  10. //ÛÛ V1.02 of 18-Jun-93: Added rotation/scaling calls ÛÛ
  11. //ÛÛ intervals parameter added to window_fade() ÛÛ
  12. //ÛÛ Added VFX_RECT structure ÛÛ
  13. //ÛÛ V1.03 of 28-Jul-93: VERTEX2D structure changed to SCRNVERTEX ÛÛ
  14. //ÛÛ Fixed-VFX_POINT data types renamed ÛÛ
  15. //ÛÛ Added VFX_bank_reset() call ÛÛ
  16. //ÛÛ V1.04 of 4-Sep-93: Indirect function prototypes changed for C++ use ÛÛ
  17. //ÛÛ V1.05 of 26-Sep-93: Added FLOAT typedef ÛÛ
  18. //ÛÛ VFX_RGB BYTE members changed to UBYTEs ÛÛ
  19. //ÛÛ V1.06 of 13-Oct-93: Added VFX_pane_refresh(), other new calls ÛÛ
  20. //ÛÛ V1.07 of 17-Nov-93: Added MetaWare High C support ÛÛ
  21. //ÛÛ V1.10 of 3-Dec-93: Modified VFX_pane_refresh(), WINDOW structure ÛÛ
  22. //ÛÛ V1.15 of 13-Mar-94: Added new VFX.C function prototypes ÛÛ
  23. //ÛÛ Added new WINDOW members, PANE_LIST structure ÛÛ
  24. //ÛÛ ÛÛ
  25. //ÛÛ Project: 386FX Sound & Light(TM) ÛÛ
  26. //ÛÛ Author: Ken Arnold, John Miles, John Lemberger ÛÛ
  27. //ÛÛ ÛÛ
  28. //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  29. //ÛÛ ÛÛ
  30. //ÛÛ Copyright (C) 1992-1994 Non-Linear Arts, Inc. ÛÛ
  31. //ÛÛ ÛÛ
  32. //ÛÛ Non-Linear Arts, Inc. ÛÛ
  33. //ÛÛ 3415 Greystone #200 ÛÛ
  34. //ÛÛ Austin, TX 78731 ÛÛ
  35. //ÛÛ ÛÛ
  36. //ÛÛ (512) 346-9595 / FAX (512) 346-9596 / BBS (512) 454-9990 ÛÛ
  37. //ÛÛ ÛÛ
  38. //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
  39. #ifndef VFX_H
  40. #define VFX_H
  41. #ifndef TRUE
  42. #define TRUE -1
  43. #endif
  44. #ifndef FALSE
  45. #define FALSE 0
  46. #endif
  47. #define SHAPE_FILE_VERSION '01.1' // 1.10 backwards for big-endian compare
  48. //
  49. // MetaWare support
  50. //
  51. #ifdef __HIGHC__
  52. #define _CC(_REVERSE_PARMS | _NEAR_CALL)
  53. #pragma Global_aliasing_convention("_%r");
  54. #pragma Align_members(1)
  55. #endif
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. #ifdef WIN32
  60. #pragma pack(1)
  61. #endif
  62. #ifndef TYPEDEFS1
  63. #define TYPEDEFS1
  64. typedef unsigned char UBYTE;
  65. typedef unsigned short UWORD;
  66. typedef unsigned long ULONG;
  67. typedef unsigned char BYTE;
  68. #ifndef WIN32
  69. typedef unsigned WORD;
  70. #endif
  71. typedef signed long LONG;
  72. typedef float FLOAT;
  73. typedef signed long FIXED16; // 16:16 fixed-VFX_POINT type [-32K,+32K]
  74. typedef signed long FIXED30; // 2:30 fixed-VFX_POINT type [-1.999,+1.999]
  75. #endif
  76. #define GIF_SCRATCH_SIZE 20526L // Temp memory req'd for GIF decompression
  77. #define S_BLACK 264
  78. //
  79. // VFX_map_polygon() flags
  80. //
  81. #define MP_XLAT 0x0001 // Use lookaside table (speed loss = ~9%)
  82. #define MP_XP 0x0002 // Enable transparency (speed loss = ~6%)
  83. //
  84. // VFX_shape_transform() flags
  85. //
  86. #define ST_XLAT 0x0001 // Use shape_lookaside() table
  87. #define ST_REUSE 0x0002 // Use buffer contents from prior call
  88. //
  89. // VFX_line_draw() modes
  90. //
  91. #define LD_DRAW 0
  92. #define LD_TRANSLATE 1
  93. #define LD_EXECUTE 2
  94. //
  95. // VFX_pane_scroll() modes
  96. //
  97. #define PS_NOWRAP 0
  98. #define PS_WRAP 1
  99. #define NO_COLOR -1
  100. //
  101. // VFX_shape_visible_rectangle() mirror values
  102. //
  103. #define VR_NO_MIRROR 0
  104. #define VR_X_MIRROR 1
  105. #define VR_Y_MIRROR 2
  106. #define VR_XY_MIRROR 3
  107. //
  108. // PANE_LIST.flags values
  109. //
  110. #define PL_FREE 0 // Free and available for assignment
  111. #define PL_VALID 1 // Assigned; to be refreshed
  112. #define PL_CONTAINED 2 // Contained within another pane; don't refresh
  113. //
  114. // VFX data structures
  115. //
  116. typedef unsigned char STENCIL;
  117. typedef struct _window
  118. {
  119. UBYTE *buffer;
  120. LONG x_max;
  121. LONG y_max;
  122. STENCIL *stencil;
  123. UBYTE *shadow;
  124. }
  125. WINDOW;
  126. typedef struct _pane
  127. {
  128. WINDOW *window;
  129. LONG x0;
  130. LONG y0;
  131. LONG x1;
  132. LONG y1;
  133. }
  134. PANE;
  135. typedef struct _pane_list
  136. {
  137. PANE *array;
  138. ULONG *flags;
  139. LONG size;
  140. }
  141. PANE_LIST;
  142. typedef union
  143. {
  144. void *v;
  145. UBYTE *b;
  146. UWORD *w;
  147. ULONG *d;
  148. }
  149. FLEX_PTR;
  150. typedef struct
  151. {
  152. LONG scrn_width;
  153. LONG scrn_height;
  154. LONG bytes_per_pixel;
  155. LONG ncolors;
  156. LONG npages;
  157. ULONG flags;
  158. }
  159. VFX_DESC;
  160. typedef struct
  161. {
  162. UBYTE r;
  163. UBYTE g;
  164. UBYTE b;
  165. }
  166. VFX_RGB;
  167. typedef struct
  168. {
  169. UBYTE color;
  170. VFX_RGB VFX_RGB;
  171. }
  172. VFX_CRGB;
  173. typedef struct
  174. {
  175. LONG x;
  176. LONG y;
  177. }
  178. VFX_POINT;
  179. typedef struct
  180. {
  181. LONG version;
  182. LONG char_count;
  183. LONG char_height;
  184. LONG font_background;
  185. }
  186. FONT;
  187. typedef struct // Vertex structure used by polygon primitives
  188. {
  189. LONG x; // Screen X
  190. LONG y; // Screen Y
  191. FIXED16 c; // Color/addition value used by some primitives
  192. FIXED16 u; // Texture source X
  193. FIXED16 v; // Texture source Y
  194. FIXED30 w; // Homogeneous perspective divisor (unused by VFX3D)
  195. }
  196. SCRNVERTEX;
  197. typedef struct
  198. {
  199. LONG x0;
  200. LONG y0;
  201. LONG x1;
  202. LONG y1;
  203. }
  204. VFX_RECT;
  205. #define INT_TO_FIXED16(x) (((long)(int)(x)) << 16)
  206. #define DOUBLE_TO_FIXED16(x) ((long) ((x) * 65536.0 + 0.5))
  207. #define FIXED16_TO_DOUBLE(x) (((double)(x)) / 65536.0)
  208. #define FIXED16_TO_INT(x) ((int) ((x)<0 ? -(-(x) >> 16) : (x) >> 16))
  209. #define ROUND_FIXED16_TO_INT(x) ((int) ((x)<0 ? -((32768-(x)) >> 16) : ((x)+32768) >> 16))
  210. #define FIXED16_TO_FIXED30(x) ((x) << 14)
  211. #define FIXED30_TO_FIXED16(x) ((x) >> 14)
  212. #define FIXED30_TO_DOUBLE(x) (((double)x) / 1073741824.0)
  213. #define DOUBLE_TO_FIXED30(x) ((long) (x * 1073741824.0 + 0.5))
  214. #define PIXELS_IN_PANE(pane) (((pane).x1-(pane).x0+1)*((pane).y1-(pane).y0+1))
  215. #define PIXELS_IN_PANEP(pane) (((pane)->x1-(pane)->x0+1)*((pane)->y1-(pane)0>y0+1))
  216. //
  217. // Hardware-specific VFX DLL functions
  218. //
  219. /*
  220. extern VFX_DESC * (*VFX_describe_driver)(void);
  221. extern void (*VFX_init_driver)(void);
  222. extern void (*VFX_shutdown_driver)(void);
  223. extern void (*VFX_wait_vblank)(void);
  224. extern void (*VFX_wait_vblank_leading)(void);
  225. extern void (*VFX_area_wipe)(LONG x0, LONG y0, LONG x1, LONG y1,
  226. LONG color);
  227. extern void (*VFX_window_refresh)(WINDOW *target, LONG x0, LONG y0,
  228. LONG x1, LONG y1);
  229. extern void (*VFX_window_read)(WINDOW *destination, LONG x0, LONG y0,
  230. LONG x1, LONG y1);
  231. extern void (*VFX_pane_refresh)(PANE *target, LONG x0, LONG y0,
  232. LONG x1, LONG y1);
  233. extern void (*VFX_DAC_read)(LONG color_number, VFX_RGB *triplet);
  234. extern void (*VFX_DAC_write)(LONG color_number, VFX_RGB *triplet);
  235. extern void (*VFX_bank_reset)(void);
  236. extern void (*VFX_line_address)(LONG x, LONG y, UBYTE **addr, ULONG *nbytes);
  237. */
  238. //
  239. // Device-independent VFX API functions (VFXC.C)
  240. //
  241. extern ULONG VFX_stencil_size(WINDOW *source, ULONG transparent_color);
  242. extern STENCIL *VFX_stencil_construct(WINDOW *source, void *dest, ULONG transparent_color);
  243. extern void VFX_stencil_destroy(STENCIL *stencil);
  244. extern WINDOW *VFX_window_construct(LONG width, LONG height);
  245. extern void VFX_window_destroy(WINDOW *window);
  246. extern PANE *VFX_pane_construct(WINDOW *window, LONG x0, LONG y0, LONG x1, LONG y1);
  247. extern void VFX_pane_destroy(PANE *pane);
  248. extern PANE_LIST *VFX_pane_list_construct(LONG n_entries);
  249. extern void VFX_pane_list_destroy(PANE_LIST *list);
  250. extern void VFX_pane_list_clear(PANE_LIST *list);
  251. extern LONG VFX_pane_list_add(PANE_LIST *list, PANE *target);
  252. extern LONG VFX_pane_list_add_area(PANE_LIST *list, WINDOW *window, LONG x0, LONG y0,
  253. LONG x1, LONG y1);
  254. extern void VFX_pane_list_delete_entry(PANE_LIST *list, LONG entry_num);
  255. extern void VFX_pane_list_refresh(PANE_LIST *list);
  256. //
  257. // Device-independent VFX API functions (VFXA.ASM)
  258. //
  259. extern BYTE * VFX_driver_name(void *VFXScanDLL);
  260. extern LONG VFX_register_driver(void *DLLbase);
  261. extern LONG VFX_line_draw (PANE *pane, LONG x0, LONG y0,
  262. LONG x1, LONG y1, LONG mode, LONG parm);
  263. extern long VFX_shape_draw (PANE *pane, void *shape_table,
  264. LONG shape_number, LONG hotX, LONG hotY);
  265. extern long VFX_nTile_draw (PANE* pane, void *tile, LONG hotX, LONG hotY, unsigned char *fadeTable = 0);
  266. extern long VFX_newShape_count (void *shape);
  267. extern void VFX_shape_lookaside (UBYTE *table);
  268. extern long VFX_shape_translate_draw (PANE *pane, void *shape_table,
  269. LONG shape_number,
  270. LONG hotX, LONG hotY);
  271. extern void VFX_shape_remap_colors(void *shape_table,
  272. ULONG shape_number);
  273. void VFX_shape_visible_rectangle(void *shape_table,
  274. LONG shape_number, LONG hotX, LONG hotY,
  275. LONG mirror, LONG *rectangle);
  276. extern LONG VFX_shape_scan (PANE *pane, ULONG transparentColor,
  277. LONG hotX, LONG hotY, void *buffer);
  278. extern long VFX_newShape_scan (PANE *shapePane, UBYTE xparentColor, UBYTE Hsx, UBYTE Hsy, unsigned char* *shapeBuffer);
  279. extern long VFX_deltaShape_scan (PANE *shapePane, UBYTE xparentColor, UBYTE Hsx, UBYTE Hsy, unsigned char* *shapeBuffer);
  280. extern long VFX_tile_scan (PANE *shapePane, UBYTE xparentColor, UBYTE Hsx, UBYTE Hsy, unsigned char* *shapeBuffer);
  281. extern LONG VFX_shape_bounds(void *shape_table, LONG shape_num);
  282. extern LONG VFX_shape_origin(void *shape_table, LONG shape_num);
  283. extern LONG VFX_shape_resolution(void *shape_table, LONG shape_num);
  284. extern LONG VFX_shape_minxy(void *shape_table, LONG shape_num);
  285. extern void VFX_shape_palette(void *shape_table, LONG shape_num,
  286. VFX_RGB *palette);
  287. extern LONG VFX_shape_colors(void *shape_table, LONG shape_num,
  288. VFX_CRGB *colors);
  289. extern LONG VFX_shape_set_colors(void *shape_table, LONG shape_number,
  290. VFX_CRGB *colors);
  291. extern LONG VFX_shape_count(void *shape_table);
  292. extern LONG VFX_shape_list(void *shape_table, ULONG *index_list);
  293. extern LONG VFX_shape_palette_list(void *shape_table, ULONG *index_list);
  294. extern LONG VFX_pixel_write (PANE *pane, LONG x, LONG y, ULONG color);
  295. extern LONG VFX_pixel_read (PANE *pane, LONG x, LONG y);
  296. extern LONG VFX_rectangle_hash (PANE *pane, LONG x0, LONG y0,
  297. LONG x1, LONG y1, ULONG color);
  298. extern LONG VFX_pane_wipe (PANE *pane, LONG color);
  299. extern LONG VFX_pane_copy (PANE *source, LONG sx, LONG sy,
  300. PANE *target, LONG tx, LONG ty, LONG fill);
  301. extern LONG VFX_pane_scroll (PANE *pane, LONG dx, LONG dy,
  302. LONG mode, LONG parm);
  303. extern void VFX_ellipse_draw(PANE *pane, LONG xc, LONG yc,
  304. LONG width, LONG height, LONG color);
  305. extern void VFX_ellipse_fill(PANE *pane, LONG xc, LONG yc,
  306. LONG width, LONG height, LONG color);
  307. extern void VFX_point_transform(VFX_POINT *in, VFX_POINT *out, VFX_POINT *origin,
  308. LONG rot, LONG x_scale, LONG y_scale);
  309. extern void VFX_Cos_Sin(LONG Angle, FIXED16 *Cos, FIXED16 *Sin);
  310. extern void VFX_fixed_mul(FIXED16 M1, FIXED16 M2,
  311. FIXED16 *result);
  312. extern LONG VFX_font_height(void *font);
  313. extern LONG VFX_character_width(void *font, LONG character);
  314. extern LONG VFX_character_draw(PANE *pane, LONG x, LONG y, void *font,
  315. LONG character, UBYTE *color_translate);
  316. extern void VFX_string_draw(PANE *pane, LONG x, LONG y, void *font,
  317. char *string, UBYTE *color_translate);
  318. extern LONG VFX_ILBM_draw(PANE *pane, UBYTE *ILBM_buffer);
  319. extern void VFX_ILBM_palette(UBYTE *ILBM_buffer, VFX_RGB *palette);
  320. extern LONG VFX_ILBM_resolution(UBYTE *ILBM_buffer);
  321. extern void VFX_PCX_draw(PANE *pane, UBYTE *PCX_buffer);
  322. extern void VFX_PCX_palette(UBYTE *PCX_buffer, LONG PCX_file_size,
  323. VFX_RGB *palette);
  324. extern LONG VFX_PCX_resolution(UBYTE *PCX_buffer);
  325. extern LONG VFX_GIF_draw(PANE *pane, UBYTE *GIF_buffer,
  326. void *GIF_scratch);
  327. extern void VFX_GIF_palette(UBYTE *GIF_buffer, VFX_RGB *palette);
  328. extern LONG VFX_GIF_resolution(UBYTE *GIF_buffer);
  329. extern LONG VFX_pixel_fade(PANE *source, PANE *destination,
  330. LONG intervals, LONG rnd);
  331. extern void VFX_window_fade(WINDOW *buffer, VFX_RGB *palette, LONG intervals);
  332. extern LONG VFX_color_scan(PANE *pane, ULONG *colors);
  333. extern void VFX_shape_transform(PANE *pane,
  334. void *shape_table, LONG shape_number, LONG hotX, LONG hotY,
  335. void *buffer, LONG rot, LONG x_scale, LONG y_scale, LONG flags);
  336. //
  337. // VFX 3D polygon functions
  338. //
  339. extern void VFX_flat_polygon(PANE *pane, LONG vcnt, SCRNVERTEX *vlist);
  340. extern void VFX_Gouraud_polygon(PANE *pane, LONG vcnt,
  341. SCRNVERTEX *vlist);
  342. extern void VFX_dithered_Gouraud_polygon(PANE *pane, FIXED16
  343. dither_amount, LONG vcnt, SCRNVERTEX *vlist);
  344. extern void VFX_map_lookaside(UBYTE *table);
  345. extern void VFX_map_polygon(PANE *pane, LONG vcnt, SCRNVERTEX *vlist,
  346. WINDOW *texture, ULONG flags);
  347. extern void VFX_translate_polygon(PANE *pane, LONG vcnt, SCRNVERTEX *vlist,
  348. void *lookaside);
  349. extern void VFX_illuminate_polygon(PANE *pane, FIXED16 dither_amount,
  350. LONG vcnt, SCRNVERTEX *vlist);
  351. #ifdef __cplusplus
  352. }
  353. #endif
  354. //
  355. // MetaWare support
  356. //
  357. #ifdef __HIGHC__
  358. #pragma Global_aliasing_convention();
  359. #pragma Align_members(4)
  360. #endif
  361. #ifdef WIN32
  362. #pragma pack()
  363. #endif
  364. #endif