dxl_main.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. #ifndef _dxl_main_h
  12. #define _dxl_main_h
  13. #if defined(__cplusplus)
  14. extern "C" {
  15. #endif
  16. struct vScreen;
  17. struct tXImage;
  18. struct tAudioBuff;
  19. struct tXAudioSource;
  20. #if defined(__cplusplus)
  21. }
  22. #endif
  23. #if defined(_WIN32_WCE)
  24. #ifndef NULL
  25. #define NULL 0
  26. #endif
  27. #endif
  28. #include "dkpltfrm.h"
  29. //#include "duktypes.h"
  30. #include "duck_dxl.h"
  31. #if defined(__cplusplus)
  32. extern "C" {
  33. #endif
  34. #define TMRTType 5
  35. #define validate(x) {if (!x) return (int ) DXL_NULLSOURCE; if (!x->dkFlags.inUse) return (int ) DXL_NOTINUSE ;}
  36. typedef void *blitFunc;
  37. /*typedef void (*blitFunc2)(DXL_XIMAGE_HANDLE,DXL_VSCREEN_HANDLE); */
  38. typedef int DXL_BLIT_FORMAT;
  39. enum DKOBJECTTYPE {
  40. DXUNUSED = 0,
  41. DXXIMAGE = 1,
  42. DXVSCREEN = 2
  43. };
  44. enum COLORDEPTH {
  45. PALETTE8 = 0,
  46. RGB555 = 1,
  47. RGB555A = 2,
  48. RGB888 = 3,
  49. RGBA8888 = 4
  50. };
  51. typedef struct tagflgs {
  52. unsigned inUse : 1;
  53. unsigned DXed : 1;
  54. unsigned clutOwner: 1;
  55. unsigned doCompleteBlit : 1;
  56. unsigned keyFrame : 1;
  57. unsigned nullFrame : 1;
  58. unsigned interframe : 1;
  59. unsigned logo : 1;
  60. unsigned allocated : 1;
  61. } dkInfoFlags;
  62. typedef struct vflgs {
  63. unsigned clipped : 1;
  64. unsigned showInfoDots : 1;
  65. } vFlags;
  66. typedef struct frameheader {
  67. unsigned char hdrSize;
  68. unsigned char Type;
  69. unsigned char DeltaSet;
  70. unsigned char Table;
  71. unsigned short Ysize;
  72. unsigned short Xsize;
  73. unsigned short CheckSum;
  74. unsigned char CVersion;
  75. unsigned char metaType;
  76. unsigned char Frameinfo;
  77. unsigned char Control;
  78. unsigned short xoff,yoff,width,height;
  79. } FRAMEHEADER;
  80. typedef struct DXINFOSTRUCT{
  81. int imwidth;
  82. int imheight;
  83. int blockpower;
  84. int lpbmione;
  85. int block2x;
  86. unsigned char *vectbl;
  87. int hinterp;
  88. int interframe;
  89. int iskeyframe;
  90. int sprite;
  91. int bitcnt;
  92. int hdrSize;
  93. int drawing;
  94. int fmt;
  95. FRAMEHEADER f;
  96. int algorithm;
  97. } dxInfoStruct;
  98. /*
  99. base "class" for xImage(s):
  100. enum DKOBJECTTYPE dkObjectType; // type of object
  101. dkInfoFlags dkFlags; // universal flags
  102. enum COLORDEPTH cDepth; // colorDepth
  103. short imWidth,imHeight; // internal width & height
  104. short x,y,w,h; // location and dx'd dimensions
  105. unsigned char *addr; // pointer to compressed data
  106. DXL_VSCREEN_HANDLE lVScreen; // last know destination
  107. DXL_XIMAGE_HANDLE (*create)(void); // creator (constructor)
  108. DXL_XIMAGE_HANDLE (*recreate)(void); // recreate base w/h/type/etc.
  109. int (*destroy)(void); // destroyer (destructor)
  110. int (*seedData)(void); // reseed with new compressed data
  111. int (*dx)(void); // decompress (to vScreen)
  112. int (*blit)(void); // blit from internal state
  113. */
  114. /*
  115. char *(*perfStats)(DXL_XIMAGE_HANDLE, char *storage); \
  116. */
  117. typedef struct profilePack_t
  118. {
  119. UINT64 dxClocks;
  120. UINT64 profileStart;
  121. UINT64 profileEnd;
  122. int frameCount;
  123. } DXL_PROFILEPACK;
  124. #define xImageBaseStruct \
  125. enum DKOBJECTTYPE dkObjectType; \
  126. dkInfoFlags dkFlags; \
  127. enum COLORDEPTH colorDepth; \
  128. short imWidth,imHeight; \
  129. short x,y,w,h; \
  130. unsigned char *addr; \
  131. DXL_VSCREEN_HANDLE lVScreen; \
  132. enum BITDEPTH *bdPrefs; \
  133. DXL_XIMAGE_HANDLE (*create)(void *); \
  134. DXL_XIMAGE_HANDLE (*recreate)(DXL_XIMAGE_HANDLE,void *,int,int,int,int); \
  135. int (*destroy)(DXL_XIMAGE_HANDLE); \
  136. int (*seedData)(DXL_XIMAGE_HANDLE); \
  137. int (*dx)(DXL_XIMAGE_HANDLE, DXL_VSCREEN_HANDLE); \
  138. int (*blit)(DXL_XIMAGE_HANDLE, DXL_VSCREEN_HANDLE); \
  139. int (*internalFormat)(DXL_XIMAGE_HANDLE, DXL_VSCREEN_HANDLE); \
  140. int (*verify)(DXL_XIMAGE_HANDLE, DXL_VSCREEN_HANDLE); \
  141. int fSize; \
  142. long (*GetXImageCSize)(DXL_XIMAGE_HANDLE); \
  143. void *(*getFrameBuffer)(DXL_XIMAGE_HANDLE); \
  144. void (*setParameter)(DXL_XIMAGE_HANDLE, int , unsigned long );\
  145. DXL_PROFILEPACK prof
  146. typedef struct tXImage{
  147. xImageBaseStruct;
  148. } DXL_XIMAGE;
  149. typedef struct tXImage1{
  150. xImageBaseStruct;
  151. /********** TM1 specific follows **********/
  152. enum IMAGETYPE imType;
  153. unsigned char *lineBuffer;
  154. int lineBufferSize;
  155. unsigned long *chromaBuffer;
  156. int chromaBufferSize;
  157. short dxCount; /* number of lines left to decompress */
  158. short lw,lh;
  159. enum BGMODE sprMode;
  160. short sprColor; /* sprite mode and color for blending */
  161. dxInfoStruct dxInfo;
  162. } DXL_XIMAGE_1,*DXL_XIMAGE_1HANDLE;
  163. typedef struct vScreen{
  164. enum DKOBJECTTYPE dkObjectType;
  165. unsigned char *addr,*laddr; /* address of destination and what it was the last time */
  166. unsigned char *bAddr,*bOffsetAddr; /* address of sprite background */
  167. enum BITDEPTH bd; /* format of destination */
  168. enum BLITQUALITY bq; /* blit translation mode */
  169. short pitch,height; /* pitch and height of dest */
  170. short bx,by,bPitch; /* x,y, and pitch of background */
  171. short viewX,viewY; /* offset/clipping viewport within destination */
  172. short viewW,viewH;
  173. short clipX,clipY; /* clipping rectangle within viewport */
  174. short clipW,clipH;
  175. dkInfoFlags dkFlags;
  176. DXL_XIMAGE_HANDLE lXImage; /* last XImage decompressed here, useful for smart blitting */
  177. unsigned char *clut1,*clut2;
  178. DXL_BLIT_FORMAT blitFormat;
  179. void *blitSetup;
  180. void *blitter;
  181. void *blitExit;
  182. int vesaMode;
  183. unsigned char *drawAddr;
  184. short drawW,drawH;
  185. vFlags flags;
  186. } DXL_VSCREEN;
  187. /* private functions */
  188. int decodeHeader(void *data,register dxInfoStruct *dxInfo);
  189. #define MAX_CDEPTHS DXMAX
  190. #define MAX_BQUALITIES DXBLITMAX
  191. typedef enum tDXL_INTERNAL_FORMAT {
  192. DXL_NULL_IFORMAT = -1,
  193. DXL_LINE16 = 0,
  194. DXL_LINE16i = 1,
  195. DXL_LINE16hi = 2,
  196. DXL_LINE16spr = 3,
  197. DXL_LINE8 = 4,
  198. TM2_BLOCK24 = 5,
  199. TM1_24 = 6,
  200. TORQ_YUY2 = 7,
  201. TORQ_YUY2hi = 8,
  202. YV12 = 9,
  203. SWET_YUV = 10,
  204. DXL_MAX_IFORMATS
  205. } DXL_INTERNAL_FORMAT;
  206. DXL_BLIT_FORMAT DXL_ReserveBlitter(void);
  207. DXL_BLIT_FORMAT DXL_OverrideBlitter(enum BLITQUALITY bq,enum BITDEPTH bd);
  208. int DXL_RegisterBlitter(DXL_BLIT_FORMAT dFormat, DXL_INTERNAL_FORMAT ,
  209. blitFunc blit, blitFunc setup, blitFunc exit);
  210. blitFunc DXL_GetBlitFunc(DXL_XIMAGE_HANDLE ,DXL_VSCREEN_HANDLE );
  211. blitFunc DXL_GetBlitSetupFunc(DXL_XIMAGE_HANDLE ,DXL_VSCREEN_HANDLE );
  212. blitFunc DXL_GetBlitExitFunc(DXL_XIMAGE_HANDLE ,DXL_VSCREEN_HANDLE );
  213. blitFunc DXL_GetVBlitFunc(DXL_VSCREEN_HANDLE ,DXL_VSCREEN_HANDLE );
  214. blitFunc DXL_GetVBlitSetupFunc(DXL_VSCREEN_HANDLE ,DXL_VSCREEN_HANDLE );
  215. blitFunc DXL_GetVBlitExitFunc(DXL_VSCREEN_HANDLE ,DXL_VSCREEN_HANDLE );
  216. DXL_BLIT_FORMAT DXL_GetVScreenBlitFormat(DXL_VSCREEN_HANDLE );
  217. DXL_INTERNAL_FORMAT DXL_GetXImageInternalFormat(DXL_XIMAGE_HANDLE ,DXL_VSCREEN_HANDLE );
  218. DXL_INTERNAL_FORMAT DXL_GetVScreenInternalFormat(DXL_VSCREEN_HANDLE vScreen);
  219. int dxl_GetAlgHandle(unsigned long fourcc);
  220. int dxl_RegisterInternalFormat(int xHandle, DXL_INTERNAL_FORMAT xFormat);
  221. int DXL_VScreenInfoDots(DXL_XIMAGE_HANDLE src, DXL_VSCREEN_HANDLE dst);
  222. int DXL_GetVScreenSizeOfPixel(DXL_VSCREEN_HANDLE );
  223. unsigned char *DXL_GetDestAddress(DXL_XIMAGE_HANDLE src, DXL_VSCREEN_HANDLE dst);
  224. int DXL_GetXImageOffset(DXL_XIMAGE_HANDLE,int *,int *);
  225. typedef DXL_XIMAGE_HANDLE (*createFunc)(unsigned char *data);
  226. int DXL_RegisterXImage(createFunc creator,unsigned long fourcc,DXL_INTERNAL_FORMAT iForm);
  227. void registerDuckBlitters(void);
  228. void resetBlitters(void);
  229. void dxv_logo( unsigned char *dst, int width, int height, int pitch,
  230. enum BITDEPTH format, int dci, enum BLITQUALITY bq);
  231. void dxl_24c(void *compaddr, void *scrnaddr,
  232. int dstPitch,int iskeyframe,
  233. int hinterp,int doublesize,
  234. int scrnwidth,int scrnheight,
  235. int blockpower, int block2x,
  236. int forceheight, char *lastdecomp,
  237. char *lastcdecomp);
  238. #define DXL_MKFOURCC( ch0, ch1, ch2, ch3 ) \
  239. ( (unsigned long)(unsigned char)(ch0) | ( (unsigned long)(unsigned char)(ch1) << 8 ) | \
  240. ( (unsigned long)(unsigned char)(ch2) << 16 ) | ( (unsigned long)(unsigned char)(ch3) << 24 ) )
  241. #if defined(__cplusplus)
  242. }
  243. #endif
  244. #endif