libgpu.pas 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742
  1. // (C) Copyright 1993-1995 Sony Corporation,Tokyo,Japan. All Rights Reserved
  2. // libgpu.h: Graphic Primitive Structures Database
  3. {
  4. *
  5. * Primitive list:
  6. *
  7. * Name |Size*1|Shade |Vertex |Texture| Function
  8. * ---------+------+-------+-------+-------+------------------------
  9. * POLY_F3 | 5 |Flat | 3 |OFF | Flat Triangle
  10. * POLY_FT3 | 8 |Flat | 3 |ON | Flat Textured Triangle
  11. * POLY_G3 | 7 |Gouraud| 3 |OFF | Gouraud Triangle
  12. * POLY_GT3 |10 |Gouraud| 3 |ON | Gouraud Textured Triangle
  13. * POLY_F4 | 6 |Flat | 4 |OFF | Flat Quadrangle
  14. * POLY_FT4 |10 |Flat | 4 |ON | Flat Textured Quadrangle
  15. * POLY_G4 | 9 |Gouraud| 4 |OFF | Gouraud Quadrangle
  16. * POLY_GT4 |13 |Gouraud| 4 |ON | Gouraud Textured Quadrangle
  17. * ---------+------+-------+-------+-------+------------------------
  18. * LINE_F2 | 4 |Flat | 2 | - | unconnected Flat Line
  19. * LINE_G2 | 5 |Gouraud| 2 | - | unconnected Gouraud Line
  20. * LINE_F3 | 6 |Flat | 3 | - | 3-connected Flat Line
  21. * LINE_G3 | 8 |Gouraud| 3 | - | 3-connected Gouraud Line
  22. * LINE_F4 | 7 |Flat | 4 | - | 4-connected Flat Line
  23. * LINE_G4 |10 |Gouraud| 4 | - | 4-connected Gouraud Line
  24. * ---------+------+-------+-------+-------+------------------------
  25. * SPRT | 5 |Flat | 1 |ON | free size Sprite
  26. * SPRT_16 | 4 |Flat | 1 |ON | 16x16 Sprite
  27. * SPRT_8 | 4 |Flat | 1 |ON | 8x8 Sprite
  28. * ---------+------+-------+-------+-------+------------------------
  29. * TILE | 4 |Flat | 1 |OFF | free size Sprite
  30. * TILE_16 | 3 |Flat | 1 |OFF | 16x16 Sprite
  31. * TILE_8 | 3 |Flat | 1 |OFF | 8x8 Sprite
  32. * TILE_1 | 3 |Flat | 1 |OFF | 1x1 Sprite
  33. * ---------+------+-------+-------+-------+------------------------
  34. * DR_TWIN | 3 | - | - | - | Texture Window
  35. * DR_AREA | 3 | - | - | - | Drawing Area
  36. * DR_OFFSET| 3 | - | - | - | Drawing Offset
  37. * DR_MODE | 3 | - | - | - | Drawing Mode
  38. * DR_ENV |16 | - | - | - | Drawing Environment
  39. * DR_MOVE | 6 | - | - | - | MoveImage
  40. * DR_LOAD |17 | - | - | - | LoadImage
  41. * DR_TPAGE | 2 | - | - | - | Drawing TPage
  42. * DR_STP | 3 | - | - | - | Drawing STP
  43. *
  44. * *1: in long-word
  45. *
  46. * Texture Attributes:
  47. * abr: ambient rate
  48. * abr 0 1 2 3
  49. * -------------------------------------
  50. * Front 0.5 1.0 0.5 -1.0
  51. * Back 0.5 1.0 1.0 1.0
  52. *
  53. * tp: texture mode
  54. * tp 0 1 2
  55. * -----------------------------
  56. * depth 4bit 8bit 16bit
  57. * color CLUT CLUT DIRECT
  58. }
  59. unit libgpu;
  60. interface
  61. uses libgte;
  62. function GPU_printf(fmt: pchar): longint; varargs; stdcall; external; // printf() object
  63. // Time-out Cycle
  64. const
  65. WAIT_TIME = $800000;
  66. // General
  67. procedure limitRange(var x: integer; l, h: integer); inline;
  68. // Rectangle:
  69. type
  70. RECT = packed record
  71. x, y : smallint; // offset point on VRAM
  72. w, h : smallint; // width and height
  73. end;
  74. PRECT = ^RECT;
  75. RECT32 = packed record
  76. x, y : longint; // offset point on VRAM
  77. w, h : longint; // width and height
  78. end;
  79. // Environment
  80. DR_ENV = packed record // Packed Drawing Environment
  81. tag : dword;
  82. code : array [0..14] of dword;
  83. end;
  84. PDR_ENV = ^DR_ENV;
  85. DRAWENV = packed record
  86. clip : RECT; // clip area
  87. ofs : array [0..1] of smallint; // drawing offset
  88. tw : RECT; // texture window
  89. tpage : word; // texture page
  90. dtd : byte; // dither flag (0:off, 1:on)
  91. dfe : byte; // flag to draw on display area (0:off 1:on)
  92. isbg : byte; // enable to auto-clear
  93. r0, g0, b0 : byte; // initital background color
  94. _dr_env : DR_ENV; // reserved
  95. end;
  96. PDRAWENV = ^DRAWENV;
  97. DISPENV = packed record
  98. disp : RECT; // display area
  99. screen : RECT; // display start point
  100. isinter : byte; // interlace 0: off 1: on
  101. isrgb24 : byte; // RGB24 bit mode
  102. pad0, pad1 : byte; // reserved
  103. end;
  104. PDISPENV = ^DISPENV;
  105. // Polygon Primitive Definitions
  106. P_TAG = bitpacked record
  107. addr: 0..16777215; // 24-bit address (24 bits can represent numbers from 0 to 16777215)
  108. len: 0..255; // 8-bit length (8 bits can represent numbers from 0 to 255)
  109. r0, g0, b0, code: Byte;
  110. end;
  111. P_CODE = packed record
  112. r0, g0, b0, code : byte;
  113. end;
  114. POLY_F3 = packed record // Flat Triangle
  115. tag : dword;
  116. r0, g0, b0, code : byte;
  117. x0, y0 : smallint;
  118. x1, y1 : smallint;
  119. x2, y2 : smallint;
  120. end;
  121. PPOLY_F3 = ^POLY_F3;
  122. POLY_F4 = packed record // Flat Quadrangle
  123. tag : dword;
  124. r0, g0, b0, code : byte;
  125. x0, y0 : smallint;
  126. x1, y1 : smallint;
  127. x2, y2 : smallint;
  128. x3, y3 : smallint;
  129. end;
  130. PPOLY_F4 = ^POLY_F4;
  131. POLY_FT3 = packed record // Flat Textured Triangle
  132. tag : dword;
  133. r0, g0, b0, code : byte;
  134. x0, y0 : smallint;
  135. u0, v0 : byte;
  136. clut : word;
  137. x1, y1 : smallint;
  138. u1, v1 : byte;
  139. tpage : word;
  140. x2, y2 : smallint;
  141. u2, v2 : byte;
  142. pad1 : word;
  143. end;
  144. PPOLY_FT3 = ^POLY_FT3;
  145. POLY_FT4 = packed record // Flat Textured Quadrangle
  146. tag : dword;
  147. r0, g0, b0, code : byte;
  148. x0, y0 : smallint;
  149. u0, v0 : byte;
  150. clut : word;
  151. x1, y1 : smallint;
  152. u1, v1 : byte;
  153. tpage : word;
  154. x2, y2 : smallint;
  155. u2, v2 : byte;
  156. pad1 : word;
  157. x3, y3 : smallint;
  158. u3, v3 : byte;
  159. pad2 : word;
  160. end;
  161. PPOLY_FT4 = ^POLY_FT4;
  162. POLY_G3 = packed record // Gouraud Triangle
  163. tag : dword;
  164. r0, g0, b0, code : byte;
  165. x0, y0 : smallint;
  166. r1, g1, b1, pad1 : byte;
  167. x1, y1 : smallint;
  168. r2, g2, b2, pad2 : byte;
  169. x2, y2 : smallint;
  170. end;
  171. PPOLY_G3 = ^POLY_G3;
  172. POLY_G4 = packed record // Gouraud Quadrangle
  173. tag : dword;
  174. r0, g0, b0, code : byte;
  175. x0, y0 : smallint;
  176. r1, g1, b1, pad1 : byte;
  177. x1, y1 : smallint;
  178. r2, g2, b2, pad2 : byte;
  179. x2, y2 : smallint;
  180. r3, g3, b3, pad3 : byte;
  181. x3, y3 : smallint;
  182. end;
  183. PPOLY_G4 = ^POLY_G4;
  184. POLY_GT3 = packed record // Gouraud Textured Triangle
  185. tag : dword;
  186. r0, g0, b0, code : byte;
  187. x0, y0 : smallint;
  188. u0, v0 : byte;
  189. clut : word;
  190. r1, g1, b1, p1 : byte;
  191. x1, y1 : smallint;
  192. u1, v1 : byte;
  193. tpage : word;
  194. r2, g2, b2, p2 : byte;
  195. x2, y2 : smallint;
  196. u2, v2 : byte;
  197. pad2 : word;
  198. end;
  199. PPOLY_GT3 = ^POLY_GT3;
  200. POLY_GT4 = packed record // Gouraud Textured Quadrangle
  201. tag : dword;
  202. r0, g0, b0, code : byte;
  203. x0, y0 : smallint;
  204. u0, v0 : byte;
  205. clut : word;
  206. r1, g1, b1, p1 : byte;
  207. x1, y1 : smallint;
  208. u1, v1 : byte;
  209. tpage : word;
  210. r2, g2, b2, p2 : byte;
  211. x2, y2 : smallint;
  212. u2, v2 : byte;
  213. pad2 : word;
  214. r3, g3, b3, p3 : byte;
  215. x3, y3 : smallint;
  216. u3, v3 : byte;
  217. pad3 : word;
  218. end;
  219. PPOLY_GT4 = ^POLY_GT4;
  220. // Line Primitive Definitions
  221. LINE_F2 = packed record // Unconnected Flat Line
  222. tag : dword;
  223. r0, g0, b0, code : byte;
  224. x0, y0 : smallint;
  225. x1, y1 : smallint;
  226. end;
  227. PLINE_F2 = ^LINE_F2;
  228. LINE_G2 = packed record // Unconnected Gouraud Line
  229. tag : dword;
  230. r0, g0, b0, code : byte;
  231. x0, y0 : smallint;
  232. r1, g1, b1, p1 : byte;
  233. x1, y1 : smallint;
  234. end;
  235. PLINE_G2 = ^LINE_G2;
  236. LINE_F3 = packed record // 2 connected Flat Line
  237. tag : dword;
  238. r0, g0, b0, code : byte;
  239. x0, y0 : smallint;
  240. x1, y1 : smallint;
  241. x2, y2 : smallint;
  242. pad : dword;
  243. end;
  244. PLINE_F3 = ^LINE_F3;
  245. LINE_G3 = packed record // 2 connected Gouraud Line
  246. tag : dword;
  247. r0, g0, b0, code : byte;
  248. x0, y0 : smallint;
  249. r1, g1, b1, p1 : byte;
  250. x1, y1 : smallint;
  251. r2, g2, b2, p2 : byte;
  252. x2, y2 : smallint;
  253. pad : dword;
  254. end;
  255. PLINE_G3 = ^LINE_G3;
  256. LINE_F4 = packed record // 3 connected Flat Line Quadrangle
  257. tag : dword;
  258. r0, g0, b0, code : byte;
  259. x0, y0 : smallint;
  260. x1, y1 : smallint;
  261. x2, y2 : smallint;
  262. x3, y3 : smallint;
  263. pad : dword;
  264. end;
  265. PLINE_F4 = ^LINE_F4;
  266. LINE_G4 = packed record // 3 connected Gouraud Line
  267. tag : dword;
  268. r0, g0, b0, code : byte;
  269. x0, y0 : smallint;
  270. r1, g1, b1, p1 : byte;
  271. x1, y1 : smallint;
  272. r2, g2, b2, p2 : byte;
  273. x2, y2 : smallint;
  274. r3, g3, b3, p3 : byte;
  275. x3, y3 : smallint;
  276. pad : dword;
  277. end;
  278. PLINE_G4 = ^LINE_G4;
  279. // Sprite Primitive Definitions
  280. SPRT = packed record // free size Sprite
  281. tag : dword;
  282. r0, g0, b0, code : byte;
  283. x0, y0 : smallint;
  284. u0, v0 : byte;
  285. clut : word;
  286. w, h : smallint;
  287. end;
  288. PSPRT = ^SPRT;
  289. SPRT_16 = packed record // 16x16 Sprite
  290. tag : dword;
  291. r0, g0, b0, code : byte;
  292. x0, y0 : smallint;
  293. u0, v0 : byte;
  294. clut : word;
  295. end;
  296. PSPRT_16 = ^SPRT_16;
  297. SPRT_8 = packed record // 8x8 Sprite
  298. tag : dword;
  299. r0, g0, b0, code : byte;
  300. x0, y0 : smallint;
  301. u0, v0 : byte;
  302. clut : word;
  303. end;
  304. PSPRT_8 = ^SPRT_8;
  305. // Tile Primitive Definitions
  306. TILE = packed record // free size Tile
  307. tag : dword;
  308. r0, g0, b0, code : byte;
  309. x0, y0 : smallint;
  310. w, h : smallint;
  311. end;
  312. PTILE = ^TILE;
  313. TILE_16 = packed record // 16x16 Tile
  314. tag : dword;
  315. r0, g0, b0, code : byte;
  316. x0, y0 : smallint;
  317. end;
  318. PTILE_16 = ^TILE_16;
  319. TILE_8 = packed record // 8x8 Tile
  320. tag : dword;
  321. r0, g0, b0, code : byte;
  322. x0, y0 : smallint;
  323. end;
  324. PTILE_8 = ^TILE_8;
  325. TILE_1 = packed record // 1x1 Tile
  326. tag : dword;
  327. r0, g0, b0, code : byte;
  328. x0, y0 : smallint;
  329. end;
  330. PTILE_1 = TILE_1;
  331. // Special Primitive Definitions
  332. DR_MODE = packed record // Drawing Mode
  333. tag : dword;
  334. code : array [0..1] of dword;
  335. end;
  336. PDR_MODE = ^DR_MODE;
  337. DR_TWIN = packed record // Texture Window
  338. tag : dword;
  339. code : array [0..1] of dword;
  340. end;
  341. PDR_TWIN =^DR_TWIN;
  342. DR_AREA = packed record // Drawing Area
  343. tag : dword;
  344. code : array [0..1] of dword;
  345. end;
  346. PDR_AREA = ^DR_AREA;
  347. DR_OFFSET = packed record // Drawing Offset
  348. tag : dword;
  349. code : array [0..1] of dword;
  350. end;
  351. PDR_OFFSET = ^DR_OFFSET;
  352. DR_MOVE = packed record // MoveImage
  353. tag : dword;
  354. code : array [0..4] of dword;
  355. end;
  356. PDR_MOVE = ^DR_MOVE;
  357. DR_LOAD = packed record // LoadImage
  358. tag : dword;
  359. code : array [0..2] of dword;
  360. p : array [0..12] of dword;
  361. end;
  362. PDR_LOAD = ^DR_LOAD;
  363. DR_TPAGE = packed record // Drawing TPage
  364. tag : dword;
  365. code : array [0..0] of dword;
  366. end;
  367. PDR_TPAGE = DR_TPAGE;
  368. DR_STP = packed record // Drawing STP
  369. tag : dword;
  370. code : array [0..1] of dword;
  371. end;
  372. PDR_STP = DR_STP;
  373. // Font Stream Parameters
  374. const
  375. FNT_MAX_ID = 8; // max number of stream ID
  376. FNT_MAX_SPRT = 1024; // max number of sprites in all streams
  377. // Multi-purpose Sony-TMD primitive
  378. type
  379. TMD_PRIM = packed record
  380. id : dword;
  381. r0, g0, b0, p0 : byte; // Color of vertex 0
  382. r1, g1, b1, p1 : byte; // Color of vertex 1
  383. r2, g2, b2, p2 : byte; // Color of vertex 2
  384. r3, g3, b3, p3 : byte; // Color of vertex 3
  385. tpage, clut : word; // texture page ID, clut ID
  386. u0, v0, u1, v1 : byte; // texture corner point
  387. u2, v2, u3, v3 : byte;
  388. // independent vertex model
  389. x0, x1, x2, x3 : SVECTOR; // 3D corner point
  390. n0, n1, n2, n3 : SVECTOR; // 3D corner normal vector
  391. // Common vertex model
  392. v_ofs : PSVECTOR; // offset to vertex database
  393. n_ofs : PSVECTOR; // offset to normal database
  394. vert0, vert1 : word; // index of vertex
  395. vert2, vert3 : word;
  396. norm0, norm1 : word; // index of normal
  397. norm2, norm3 : word;
  398. end;
  399. PTMD_PRIM = ^TMD_PRIM;
  400. // Multi-purpose TIM image
  401. TIM_IMAGE = packed record
  402. mode : dword; // pixel mode
  403. crect : PRECT; // CLUT rectangle on frame buffer
  404. caddr : pdword; // CLUT address on main memory
  405. prect : PRECT; // texture image rectangle on frame buffer
  406. paddr : pdword; // texture image address on main memory
  407. end;
  408. PTIM_IMAGE = ^TIM_IMAGE;
  409. function FntPrint(Args: pchar): longint; varargs; stdcall; external;
  410. function KanjiFntPrint(Args: pchar): longint; varargs; stdcall; external;
  411. function FntPrint: longint; stdcall; external;
  412. function KanjiFntPrint: longint; stdcall; external;
  413. function GetDispEnv(env: PDISPENV): PDISPENV; stdcall; external;
  414. function PutDispEnv(env: PDISPENV): PDISPENV; stdcall; external;
  415. function SetDefDispEnv(env: PDISPENV; x, y, w, h: longint): PDISPENV; stdcall; external;
  416. function GetDrawEnv(env: PDRAWENV): PDRAWENV; stdcall; external;
  417. function PutDrawEnv(env: PDRAWENV): PDRAWENV; stdcall; external;
  418. function SetDefDrawEnv(env: PDRAWENV; x, y, w, h: longint): PDRAWENV; stdcall; external;
  419. function ReadTIM(timimg: PTIM_IMAGE): PTIM_IMAGE; stdcall; external;
  420. function ReadTMD(tmdprim: PTMD_PRIM): PTMD_PRIM; stdcall; external;
  421. function CheckPrim(s: pchar; p: pdword): longint; stdcall; external;
  422. function ClearImage(rect: PRECT; r, g, b: byte): longint; stdcall; external;
  423. function ClearImage2(rect: PRECT; r, g, b: byte): longint; stdcall; external;
  424. function DrawSync(mode: longint): longint; stdcall; external;
  425. function FntOpen(x, y, w, h: longint; isbg, n: longint): longint; stdcall; external;
  426. function GetGraphDebug: longint; stdcall; external;
  427. function GetTimSize(sjis: pbyte): longint; stdcall; external;
  428. function IsEndPrim(p: pointer): longint; stdcall; external;
  429. function KanjiFntOpen(x, y, w, h: longint; dx, dy, cx, cy: longint; isbg, n: longint): longint; stdcall; external;
  430. procedure KanjiFntClose; stdcall; external;
  431. function Krom2Tim(sjis: pbyte; taddr:pdword; dx, dy, cdx, cdy: longint; fg, bg: dword): longint; stdcall; external;
  432. function LoadImage(rect: PRECT; p: pointer): longint; stdcall; external;
  433. function MargePrim(p0, p1: pointer): longint; stdcall; external;
  434. function MoveImage(rect: PRECT; x, y: longint): longint; stdcall; external;
  435. function OpenTIM(addr: pointer): longint; stdcall; external;
  436. function OpenTMD(tmd: pdword; obj_no: longint): longint; stdcall; external;
  437. function ResetGraph(mode: longint): longint; stdcall; external;
  438. function SetGraphDebug(level: longint): longint; stdcall; external;
  439. function StoreImage(rect: PRECT; p: pointer): longint; stdcall; external;
  440. function ClearOTag(ot: pointer; n: longint): pdword; stdcall; external;
  441. function ClearOTagR(ot: pointer; n: longint): pdword; stdcall; external;
  442. function FntFlush(id: longint): pdword; stdcall; external;
  443. function KanjiFntFlush(id: longint): pdword; stdcall; external;
  444. function DrawSyncCallback(func: pointer): longint; stdcall; external;
  445. function GetClut(x, y: longint): word; stdcall; external;
  446. function GetTPage(tp, abr: longint; x, y: longint): word; stdcall; external;
  447. function LoadClut(clut: pointer; x, y: longint): word; stdcall; external;
  448. function LoadClut2(clut: pointer; x, y: longint): word; stdcall; external;
  449. function LoadTPage(pix: pointer; tp, abr: longint; x, y, w, h: longint): word; stdcall; external;
  450. function NextPrim(p: pointer): pointer; stdcall; external;
  451. procedure AddPrim(ot: pointer; p: pointer); stdcall; external;
  452. procedure AddPrims(ot: pointer; p0, p1: pointer); stdcall; external;
  453. procedure CatPrim(p0, p1: pointer); stdcall; external;
  454. procedure DrawOTag(p: pointer); stdcall; external;
  455. procedure DrawOTagIO(p: pointer); stdcall; external;
  456. procedure DrawOTagEnv(p: pointer; env: PDRAWENV); stdcall; external;
  457. procedure DrawPrim(p: pointer); stdcall; external;
  458. procedure DumpClut(clut: word); stdcall; external;
  459. procedure DumpDispEnv(env: PDISPENV); stdcall; external;
  460. procedure DumpDrawEnv(env: PDRAWENV); stdcall; external;
  461. procedure DumpOTag(p: pointer); stdcall; external;
  462. procedure DumpTPage(tpage: word); stdcall; external;
  463. procedure FntLoad(tx, ty: longint); stdcall; external;
  464. procedure SetDispMask(mask: longint); stdcall; external;
  465. procedure SetDrawArea(p: PDR_AREA; r: PRECT); stdcall; external;
  466. procedure SetDrawEnv(dr_env: PDR_ENV; env: PDRAWENV); stdcall; external;
  467. procedure SetDrawLoad(p: PDR_LOAD; rect: PRECT); stdcall; external;
  468. procedure SetDrawMode(p: PDR_MODE; dfe, dtd: longint; tpage: longint; tw: PRECT); stdcall; external;
  469. procedure SetDrawTPage(p: PDR_TPAGE; dfe, dtd: longint; tpage: longint); stdcall; external;
  470. procedure SetDrawMove(p: PDR_MOVE; r: PRECT; x, y: longint); stdcall; external;
  471. procedure SetDrawOffset(p: PDR_OFFSET; ofs: pword); stdcall; external;
  472. procedure SetDrawStp(p: PDR_STP; pbw: longint); stdcall; external;
  473. procedure SetDumpFnt(id: longint); stdcall; external;
  474. procedure SetLineF2(p: PLINE_F2); stdcall; external;
  475. procedure SetLineF3(p: PLINE_F3); stdcall; external;
  476. procedure SetLineF4(p: PLINE_F4); stdcall; external;
  477. procedure SetLineG2(p: PLINE_G2); stdcall; external;
  478. procedure SetLineG3(p: PLINE_G3); stdcall; external;
  479. procedure SetLineG4(p: PLINE_G4); stdcall; external;
  480. procedure SetPolyF3(p: PPOLY_F3); stdcall; external;
  481. procedure SetPolyF4(p: PPOLY_F4); stdcall; external;
  482. procedure SetPolyFT3(p: PPOLY_FT3); stdcall; external;
  483. procedure SetPolyFT4(p: PPOLY_FT4); stdcall; external;
  484. procedure SetPolyG3(p: PPOLY_G3); stdcall; external;
  485. procedure SetPolyG4(p: PPOLY_G4); stdcall; external;
  486. procedure SetPolyGT3(p: PPOLY_GT3); stdcall; external;
  487. procedure SetPolyGT4(p: PPOLY_GT4); stdcall; external;
  488. procedure SetSemiTrans(p: pointer; abe: longint); stdcall; external;
  489. procedure SetShadeTex(p: pointer; tge: longint); stdcall; external;
  490. procedure SetSprt(p: PSPRT); stdcall; external;
  491. procedure SetSprt16(p: PSPRT_16); stdcall; external;
  492. procedure SetSprt8(p: PSPRT_8); stdcall; external;
  493. procedure SetTexWindow(p: PDR_TWIN; tw: PRECT); stdcall; external;
  494. procedure SetTile(p: PTILE); stdcall; external;
  495. procedure SetTile1(p: PTILE_1); stdcall; external;
  496. procedure SetTile16(p: PTILE_16); stdcall; external;
  497. procedure SetTile8(p: PTILE_8); stdcall; external;
  498. procedure TermPrim(p: pointer); stdcall; external;
  499. function BreakDraw: pdword; stdcall; external;
  500. procedure ContinueDraw(insaddr: pdword; contaddr: pdword); stdcall; external;
  501. function IsIdleGPU(max_count: longint): longint; stdcall; external;
  502. function GetODE: longint; stdcall; external;
  503. function LoadImage2(_rect: PRECT; p: pointer): longint; stdcall; external;
  504. function StoreImage2(_rect: PRECT; p: pointer): longint; stdcall; external;
  505. function MoveImage2(_rect: PRECT; x, y: longint): longint; stdcall; external;
  506. function DrawOTag2(p: pointer): longint; stdcall; external;
  507. procedure GetDrawMode(p: PDR_MODE); stdcall; external;
  508. procedure GetTexWindow(p: PDR_TWIN); stdcall; external;
  509. procedure GetDrawArea(p: PDR_AREA); stdcall; external;
  510. procedure GetDrawOffset(p: PDR_OFFSET); stdcall; external;
  511. procedure GetDrawEnv2(p: PDR_ENV); stdcall; external;
  512. // Set/Add Vector/Rectangle Attributes
  513. procedure setVector(var v: VECTOR; const x, y, z: longint);
  514. procedure setVector(var v: SVECTOR; const x, y, z: smallint);
  515. procedure setVector(var v: DVECTOR; const x, y, z: smallint);
  516. {
  517. #define applyVector(v, _x, _y, _z, op) \
  518. (v)->vx op _x, (v)->vy op _y, (v)->vz op _z
  519. }
  520. procedure copyVector(var v0: VECTOR; const v1: VECTOR);
  521. procedure copyVector(var v0: SVECTOR; const v1: SVECTOR);
  522. procedure copyVector(var v0: DVECTOR; const v1: DVECTOR);
  523. procedure addVector(var v0: VECTOR; const v1: VECTOR);
  524. procedure addVector(var v0: SVECTOR; const v1: SVECTOR);
  525. procedure addVector(var v0: DVECTOR; const v1: DVECTOR);
  526. procedure dumpVector(str: pchar; const v: VECTOR);
  527. procedure dumpVector(str: pchar; const v: SVECTOR);
  528. procedure dumpVector(str: pchar; const v: DVECTOR);
  529. procedure dumpMatrix(const x: MATRIX);
  530. procedure setRECT(var r: RECT; const x, y, w, h: longint);
  531. (*
  532. * Set Primitive Attributes
  533. */
  534. #define setTPage(p,tp,abr,x,y) \
  535. ((p)->tpage = getTPage(tp,abr,x,y))
  536. #define setClut(p,x,y) \
  537. ((p)->clut = getClut(x,y))
  538. *)
  539. // Set Primitive Colors
  540. procedure setRGB0(var p: POLY_F3; const r, g, b: byte);
  541. procedure setRGB0(var p: POLY_F4; const r, g, b: byte);
  542. procedure setRGB0(var p: POLY_FT3; const r, g, b: byte);
  543. procedure setRGB0(var p: POLY_FT4; const r, g, b: byte);
  544. procedure setRGB0(var p: POLY_G3; const r, g, b: byte);
  545. procedure setRGB0(var p: POLY_G4; const r, g, b: byte);
  546. procedure setRGB0(var p: POLY_GT3; const r, g, b: byte);
  547. procedure setRGB0(var p: POLY_GT4; const r, g, b: byte);
  548. procedure setRGB0(var c: DRAWENV; r, g, b: byte);
  549. procedure setRGB1(var p: POLY_G3; const r, g, b: byte);
  550. procedure setRGB1(var p: POLY_G4; const r, g, b: byte);
  551. procedure setRGB1(var p: POLY_GT3; const r, g, b: byte);
  552. procedure setRGB1(var p: POLY_GT4; const r, g, b: byte);
  553. procedure setRGB2(var p: POLY_G3; const r, g, b: byte);
  554. procedure setRGB2(var p: POLY_G4; const r, g, b: byte);
  555. procedure setRGB2(var p: POLY_GT3; const r, g, b: byte);
  556. procedure setRGB2(var p: POLY_GT4; const r, g, b: byte);
  557. procedure setRGB3(var p: POLY_G4; const r, g, b: byte);
  558. procedure setRGB3(var p: POLY_GT4; const r, g, b: byte);
  559. // Set Primitive Screen Points
  560. procedure setXY0(var p: POLY_F3; const x, y: smallint);
  561. procedure setXY0(var p: POLY_F4; const x, y: smallint);
  562. procedure setXY0(var p: POLY_FT3; const x, y: smallint);
  563. procedure setXY0(var p: POLY_FT4; const x, y: smallint);
  564. procedure setXY0(var p: POLY_G3; const x, y: smallint);
  565. procedure setXY0(var p: POLY_G4; const x, y: smallint);
  566. procedure setXY0(var p: POLY_GT3; const x, y: smallint);
  567. procedure setXY0(var p: POLY_GT4; const x, y: smallint);
  568. (*
  569. #define setXY2(p,_x0,_y0,_x1,_y1) \
  570. (p)->x0 = (_x0), (p)->y0 = (_y0), \
  571. (p)->x1 = (_x1), (p)->y1 = (_y1)
  572. #define setXY3(p,_x0,_y0,_x1,_y1,_x2,_y2) \
  573. (p)->x0 = (_x0), (p)->y0 = (_y0), \
  574. (p)->x1 = (_x1), (p)->y1 = (_y1), \
  575. (p)->x2 = (_x2), (p)->y2 = (_y2)
  576. #define setXY4(p,_x0,_y0,_x1,_y1,_x2,_y2,_x3,_y3) \
  577. (p)->x0 = (_x0), (p)->y0 = (_y0), \
  578. (p)->x1 = (_x1), (p)->y1 = (_y1), \
  579. (p)->x2 = (_x2), (p)->y2 = (_y2), \
  580. (p)->x3 = (_x3), (p)->y3 = (_y3)
  581. #define setXYWH(p,_x0,_y0,_w,_h) \
  582. (p)->x0 = (_x0), (p)->y0 = (_y0), \
  583. (p)->x1 = (_x0)+(_w), (p)->y1 = (_y0), \
  584. (p)->x2 = (_x0), (p)->y2 = (_y0)+(_h), \
  585. (p)->x3 = (_x0)+(_w), (p)->y3 = (_y0)+(_h)
  586. /*
  587. * Set Primitive Width/Height
  588. */
  589. #define setWH(p,_w,_h) (p)->w = _w, (p)->h = _h
  590. /*
  591. * Set Primitive Texture Points
  592. */
  593. #define setUV0(p,_u0,_v0) \
  594. (p)->u0 = (_u0), (p)->v0 = (_v0) \
  595. #define setUV3(p,_u0,_v0,_u1,_v1,_u2,_v2) \
  596. (p)->u0 = (_u0), (p)->v0 = (_v0), \
  597. (p)->u1 = (_u1), (p)->v1 = (_v1), \
  598. (p)->u2 = (_u2), (p)->v2 = (_v2)
  599. #define setUV4(p,_u0,_v0,_u1,_v1,_u2,_v2,_u3,_v3) \
  600. (p)->u0 = (_u0), (p)->v0 = (_v0), \
  601. (p)->u1 = (_u1), (p)->v1 = (_v1), \
  602. (p)->u2 = (_u2), (p)->v2 = (_v2), \
  603. (p)->u3 = (_u3), (p)->v3 = (_v3)
  604. #define setUVWH(p,_u0,_v0,_w,_h) \
  605. (p)->u0 = (_u0), (p)->v0 = (_v0), \
  606. (p)->u1 = (_u0)+(_w), (p)->v1 = (_v0), \
  607. (p)->u2 = (_u0), (p)->v2 = (_v0)+(_h), \
  608. (p)->u3 = (_u0)+(_w), (p)->v3 = (_v0)+(_h)
  609. *)
  610. // Dump Primivie Parameters
  611. procedure dumpRECT(r: RECT);
  612. (*
  613. procedure dumpWH(p) GPU_printf("(%d,%d)\n", (p)->w, (p)->h )
  614. #define dumpXY0(p) GPU_printf("(%d,%d)\n", (p)->x0, (p)->y0)
  615. #define dumpUV0(p) GPU_printf("(%d,%d)\n", (p)->u0, (p)->v0)
  616. #define dumpXY2(p) \
  617. GPU_printf("(%d,%d)-(%d,%d)\n", \
  618. (p)->x0, (p)->y0, (p)->x1, (p)->y1)
  619. #define dumpXY3(p) \
  620. GPU_printf("(%d,%d)-(%d,%d)-(%d,%d)\n", \
  621. (p)->x0, (p)->y0, (p)->x1, (p)->y1, \
  622. (p)->x2, (p)->y2)
  623. #define dumpUV3(p) \
  624. GPU_printf("(%d,%d)-(%d,%d)-(%d,%d)\n", \
  625. (p)->u0, (p)->v0, (p)->u1, (p)->v1, \
  626. (p)->u2, (p)->v2)
  627. #define dumpXY4(p) \
  628. GPU_printf("(%d,%d)-(%d,%d)-(%d,%d)-(%d,%d)\n", \
  629. (p)->x0, (p)->y0, (p)->x1, (p)->y1, \
  630. (p)->x2, (p)->y2, (p)->x3, (p)->y3)
  631. #define dumpUV4(p) \
  632. GPU_printf("(%d,%d)-(%d,%d)-(%d,%d)-(%d,%d)\n", \
  633. (p)->u0, (p)->v0, (p)->u1, (p)->v1, \
  634. (p)->u2, (p)->v2, (p)->u3, (p)->v3)
  635. #define dumpRGB0(p) \
  636. GPU_printf("(%3d,%3d,%3d)\n", (p)->r0, (p)->g0, (p)->b0)
  637. #define dumpRGB1(p) \
  638. GPU_printf("(%3d,%3d,%3d)\n", (p)->r1, (p)->g1, (p)->b1)
  639. #define dumpRGB2(p) \
  640. GPU_printf("(%3d,%3d,%3d)\n", (p)->r2, (p)->g2, (p)->b2)
  641. #define dumpRGB3(p) \
  642. GPU_printf("(%3d,%3d,%3d)\n", (p)->r3, (p)->g3, (p)->b3)
  643. *)
  644. // Primitive Handling Macros
  645. procedure setlen(var p: P_TAG; const len: byte);
  646. procedure setlen(var p: POLY_F3; const len: byte);
  647. procedure setlen(var p: POLY_FT3; const len: byte);
  648. procedure setlen(var p: POLY_G3; const len: byte);
  649. procedure setlen(var p: POLY_GT3; const len: byte);
  650. procedure setlen(var p: POLY_F4; const len: byte);
  651. procedure setlen(var p: POLY_FT4; const len: byte);
  652. procedure setlen(var p: POLY_G4; const len: byte);
  653. procedure setlen(var p: POLY_GT4; const len: byte);
  654. procedure setlen(var p: SPRT_8; const len: byte);
  655. procedure setlen(var p: SPRT_16; const len: byte);
  656. procedure setlen(var p: SPRT; const len: byte);
  657. procedure setlen(var p: TILE_1; const len: byte);
  658. procedure setlen(var p: TILE_8; const len: byte);
  659. procedure setlen(var p: TILE_16; const len: byte);
  660. procedure setlen(var p: TILE; const len: byte);
  661. procedure setlen(var p: LINE_F2; const len: byte);
  662. procedure setlen(var p: LINE_G2; const len: byte);
  663. procedure setlen(var p: LINE_F3; const len: byte);
  664. procedure setlen(var p: LINE_G3; const len: byte);
  665. procedure setlen(var p: LINE_F4; const len: byte);
  666. procedure setlen(var p: LINE_G4; const len: byte);
  667. procedure setaddr(var p: P_TAG; const addr: dword);
  668. procedure setcode(var p: P_TAG; const code: byte);
  669. procedure setcode(var p: POLY_F3; const code: byte);
  670. procedure setcode(var p: POLY_FT3; const code: byte);
  671. procedure setcode(var p: POLY_G3; const code: byte);
  672. procedure setcode(var p: POLY_GT3; const code: byte);
  673. procedure setcode(var p: POLY_F4; const code: byte);
  674. procedure setcode(var p: POLY_FT4; const code: byte);
  675. procedure setcode(var p: POLY_G4; const code: byte);
  676. procedure setcode(var p: POLY_GT4; const code: byte);
  677. procedure setcode(var p: SPRT_8; const code: byte);
  678. procedure setcode(var p: SPRT_16; const code: byte);
  679. procedure setcode(var p: SPRT; const code: byte);
  680. procedure setcode(var p: TILE_1; const code: byte);
  681. procedure setcode(var p: TILE_8; const code: byte);
  682. procedure setcode(var p: TILE_16; const code: byte);
  683. procedure setcode(var p: TILE; const code: byte);
  684. procedure setcode(var p: LINE_F2; const code: byte);
  685. procedure setcode(var p: LINE_G2; const code: byte);
  686. procedure setcode(var p: LINE_F3; const code: byte);
  687. procedure setcode(var p: LINE_G3; const code: byte);
  688. procedure setcode(var p: LINE_F4; const code: byte);
  689. procedure setcode(var p: LINE_G4; const code: byte);
  690. function getlen(p: P_TAG): byte;
  691. function getcode(p: P_TAG): byte;
  692. function getaddr(p: P_TAG): dword;
  693. {
  694. #define nextPrim(p) (void *)((((P_TAG *)(p))->addr)|0x80000000)
  695. #define isendprim(p) ((((P_TAG *)(p))->addr)==0xffffff)
  696. #define addPrim(ot, p) setaddr(p, getaddr(ot)), setaddr(ot, p)
  697. #define addPrims(ot, p0, p1) setaddr(p1, getaddr(ot)),setaddr(ot, p0)
  698. #define catPrim(p0, p1) setaddr(p0, p1)
  699. #define termPrim(p) setaddr(p, 0xffffffff)
  700. #define setSemiTrans(p, abe) \
  701. ((abe)?setcode(p, getcode(p)|0x02):setcode(p, getcode(p)&~0x02))
  702. #define setShadeTex(p, tge) \
  703. ((tge)?setcode(p, getcode(p)|0x01):setcode(p, getcode(p)&~0x01))
  704. #define getTPage(tp, abr, x, y) \
  705. ((((tp)&0x3)<<7)|(((abr)&0x3)<<5)|(((y)&0x100)>>4)|(((x)&0x3ff)>>6)| \
  706. (((y)&0x200)<<2))
  707. #define getClut(x, y) \
  708. (((y)<<6)|(((x)>>4)&0x3f))
  709. #define dumpTPage(tpage) \
  710. GPU_printf("tpage: (%d,%d,%d,%d)\n", \
  711. ((tpage)>>7)&0x003,((tpage)>>5)&0x003, \
  712. ((tpage)<<6)&0x7c0, \
  713. (((tpage)<<4)&0x100)+(((tpage)>>2)&0x200))
  714. #define dumpClut(clut) \
  715. GPU_printf("clut: (%d,%d)\n", (clut&0x3f)<<4, (clut>>6))
  716. #define _get_mode(dfe, dtd, tpage) \
  717. ((0xe1000000)|((dtd)?0x0200:0)| \
  718. ((dfe)?0x0400:0)|((tpage)&0x9ff))
  719. #define setDrawTPage(p, dfe, dtd, tpage) \
  720. setlen(p, 1), \
  721. ((u_long *)(p))[1] = _get_mode(dfe, dtd, tpage)
  722. #define _get_tw(tw) \
  723. (tw ? ((0xe2000000)|((((tw)->y&0xff)>>3)<<15)| \
  724. ((((tw)->x&0xff)>>3)<<10)|(((~((tw)->h-1)&0xff)>>3)<<5)| \
  725. (((~((tw)->w-1)&0xff)>>3))) : 0)
  726. #define setTexWindow(p, tw) \
  727. setlen(p, 2), \
  728. ((u_long *)(p))[1] = _get_tw(tw), \
  729. ((u_long *)(p))[2] = 0
  730. #define _get_len(rect) \
  731. (((rect)->w*(rect)->h+1)/2+4)
  732. #define setDrawLoad(pt, rect) \
  733. (_get_len(rect) <= 16) ? ( \
  734. (setlen(pt, _get_len(rect))), \
  735. ((pt)->code[0] = 0xa0000000), \
  736. ((pt)->code[1] = *((u_long *)&(rect)->x)), \
  737. ((pt)->code[2] = *((u_long *)&(rect)->w)), \
  738. ((pt)->p[_get_len(rect)-4] = 0x01000000) \
  739. ) : ( \
  740. (setlen(pt,0)) \
  741. )
  742. #define setDrawStp(p, pbw) \
  743. setlen(p, 2), \
  744. ((u_long *)p)[1] = 0xe6000000|(pbw?0x01:0), \
  745. ((u_long *)p)[2] = 0
  746. #define setDrawMode(p, dfe, dtd, tpage, tw) \
  747. setlen(p, 2), \
  748. ((u_long *)p)[1] = _get_mode(dfe, dtd, tpage), \
  749. ((u_long *)p)[2] = _get_tw((RECT *)tw)
  750. }
  751. // Primitive Lentgh Code
  752. //--------------------------------------------------------------------
  753. //
  754. procedure setPolyF3(var p: POLY_F3);
  755. procedure setPolyFT3(var p: POLY_FT3);
  756. procedure setPolyG3(var p: POLY_G3);
  757. procedure setPolyGT3(var p: POLY_GT3);
  758. procedure setPolyF4(var p: POLY_F4);
  759. procedure setPolyFT4(var p: POLY_FT4);
  760. procedure setPolyG4(var p: POLY_G4);
  761. procedure setPolyGT4(var p: POLY_GT4);
  762. procedure setSprt8(var p: SPRT_8);
  763. procedure setSprt16(var p: SPRT_16);
  764. procedure setSprt(var p: SPRT);
  765. //procedure setTile1(var p: TILE_1);
  766. procedure setTile8(var p: TILE_8);
  767. procedure setTile16(var p: TILE_16);
  768. procedure setTile(var p: TILE);
  769. procedure setLineF2(var p: LINE_F2);
  770. procedure setLineG2(var p: LINE_G2);
  771. procedure setLineF3(var p: LINE_F3);
  772. procedure setLineG3(var p: LINE_G3);
  773. procedure setLineF4(var p: LINE_F4);
  774. procedure setLineG4(var p: LINE_G4);
  775. implementation
  776. procedure limitRange(var x: integer; l, h: integer); inline;
  777. begin
  778. if x < l then x := l else if x > h then x := h;
  779. end;
  780. procedure setVector(var v: VECTOR; const x, y, z: longint);
  781. begin
  782. v.vx:= x;
  783. v.vy:= y;
  784. v.vz:= z;
  785. end;
  786. procedure setVector(var v: SVECTOR; const x, y, z: smallint);
  787. begin
  788. v.vx:= x;
  789. v.vy:= y;
  790. v.vz:= z;
  791. end;
  792. procedure setVector(var v: DVECTOR; const x, y, z: smallint);
  793. begin
  794. v.vx:= x;
  795. v.vy:= y;
  796. end;
  797. procedure copyVector(var v0: VECTOR; const v1: VECTOR);
  798. begin
  799. v0:= v1;
  800. end;
  801. procedure copyVector(var v0: SVECTOR; const v1: SVECTOR);
  802. begin
  803. v0:= v1;
  804. end;
  805. procedure copyVector(var v0: DVECTOR; const v1: DVECTOR);
  806. begin
  807. v0:= v1;
  808. end;
  809. procedure addVector(var v0: VECTOR; const v1: VECTOR);
  810. begin
  811. v0.vx:= v0.vx + v1.vx;
  812. v0.vy:= v0.vy + v1.vy;
  813. v0.vz:= v0.vz + v1.vz;
  814. end;
  815. procedure addVector(var v0: SVECTOR; const v1: SVECTOR);
  816. begin
  817. v0.vx:= v0.vx + v1.vx;
  818. v0.vy:= v0.vy + v1.vy;
  819. v0.vz:= v0.vz + v1.vz;
  820. end;
  821. procedure addVector(var v0: DVECTOR; const v1: DVECTOR);
  822. begin
  823. v0.vx:= v0.vx + v1.vx;
  824. v0.vy:= v0.vy + v1.vy;
  825. end;
  826. procedure setRECT(var r: RECT; const x, y, w, h: longint);
  827. begin
  828. r.x:= x;
  829. r.y:= y;
  830. r.w:= w;
  831. r.h:= h;
  832. end;
  833. procedure dumpMatrix(const x: MATRIX);
  834. begin
  835. GPU_printf('\t%5d,%5d,%5d\n', x.m[0,0], x.m[0,1], x.m[0,2]);
  836. GPU_printf('\t%5d,%5d,%5d\n', x.m[1,0], x.m[1,1], x.m[1,2]);
  837. GPU_printf('\t%5d,%5d,%5d\n', x.m[2,0], x.m[2,1], x.m[2,2]);
  838. end;
  839. procedure dumpVector(str: pchar; const v: VECTOR);
  840. begin
  841. GPU_printf('%s=(%d,%d,%d)\n', str, v.vx, v.vy, v.vz)
  842. end;
  843. procedure dumpVector(str: pchar; const v: SVECTOR);
  844. begin
  845. GPU_printf('%s=(%d,%d,%d)\n', str, v.vx, v.vy, v.vz)
  846. end;
  847. procedure dumpVector(str: pchar; const v: DVECTOR);
  848. begin
  849. GPU_printf('%s=(%d,%d)\n', str, v.vx, v.vy)
  850. end;
  851. procedure setRGB0(var p: POLY_F3; const r, g, b: byte);
  852. begin
  853. p.r0:= r;
  854. p.g0:= g;
  855. p.b0:= b;
  856. end;
  857. procedure setRGB0(var p: POLY_F4; const r, g, b: byte);
  858. begin
  859. p.r0:= r;
  860. p.g0:= g;
  861. p.b0:= b;
  862. end;
  863. procedure setRGB0(var p: POLY_FT3; const r, g, b: byte);
  864. begin
  865. p.r0:= r;
  866. p.g0:= g;
  867. p.b0:= b;
  868. end;
  869. procedure setRGB0(var p: POLY_FT4; const r, g, b: byte);
  870. begin
  871. p.r0:= r;
  872. p.g0:= g;
  873. p.b0:= b;
  874. end;
  875. procedure setRGB0(var p: POLY_G3; const r, g, b: byte);
  876. begin
  877. p.r0:= r;
  878. p.g0:= g;
  879. p.b0:= b;
  880. end;
  881. procedure setRGB0(var p: POLY_G4; const r, g, b: byte);
  882. begin
  883. p.r0:= r;
  884. p.g0:= g;
  885. p.b0:= b;
  886. end;
  887. procedure setRGB0(var p: POLY_GT3; const r, g, b: byte);
  888. begin
  889. p.r0:= r;
  890. p.g0:= g;
  891. p.b0:= b;
  892. end;
  893. procedure setRGB0(var p: POLY_GT4; const r, g, b: byte);
  894. begin
  895. p.r0:= r;
  896. p.g0:= g;
  897. p.b0:= b;
  898. end;
  899. procedure setRGB0(var c: DRAWENV; r, g, b: byte);
  900. begin
  901. c.r0:=r;
  902. c.g0:=g;
  903. c.b0:=b;
  904. end;
  905. procedure setRGB1(var p: POLY_G3; const r, g, b: byte);
  906. begin
  907. p.r1:= r;
  908. p.g1:= g;
  909. p.b1:= b;
  910. end;
  911. procedure setRGB1(var p: POLY_G4; const r, g, b: byte);
  912. begin
  913. p.r1:= r;
  914. p.g1:= g;
  915. p.b1:= b;
  916. end;
  917. procedure setRGB1(var p: POLY_GT3; const r, g, b: byte);
  918. begin
  919. p.r1:= r;
  920. p.g1:= g;
  921. p.b1:= b;
  922. end;
  923. procedure setRGB1(var p: POLY_GT4; const r, g, b: byte);
  924. begin
  925. p.r1:= r;
  926. p.g1:= g;
  927. p.b1:= b;
  928. end;
  929. procedure setRGB2(var p: POLY_G3; const r, g, b: byte);
  930. begin
  931. p.r2:= r;
  932. p.g2:= g;
  933. p.b2:= b;
  934. end;
  935. procedure setRGB2(var p: POLY_G4; const r, g, b: byte);
  936. begin
  937. p.r2:= r;
  938. p.g2:= g;
  939. p.b2:= b;
  940. end;
  941. procedure setRGB2(var p: POLY_GT3; const r, g, b: byte);
  942. begin
  943. p.r2:= r;
  944. p.g2:= g;
  945. p.b2:= b;
  946. end;
  947. procedure setRGB2(var p: POLY_GT4; const r, g, b: byte);
  948. begin
  949. p.r2:= r;
  950. p.g2:= g;
  951. p.b2:= b;
  952. end;
  953. procedure setRGB3(var p: POLY_G4; const r, g, b: byte);
  954. begin
  955. p.r3:= r;
  956. p.g3:= g;
  957. p.b3:= b;
  958. end;
  959. procedure setRGB3(var p: POLY_GT4; const r, g, b: byte);
  960. begin
  961. p.r3:= r;
  962. p.g3:= g;
  963. p.b3:= b;
  964. end;
  965. procedure setXY0(var p: POLY_F3; const x, y: smallint);
  966. begin
  967. p.x0:= x;
  968. p.y0:= y;
  969. end;
  970. procedure setXY0(var p: POLY_F4; const x, y: smallint);
  971. begin
  972. p.x0:= x;
  973. p.y0:= y;
  974. end;
  975. procedure setXY0(var p: POLY_FT3; const x, y: smallint);
  976. begin
  977. p.x0:= x;
  978. p.y0:= y;
  979. end;
  980. procedure setXY0(var p: POLY_FT4; const x, y: smallint);
  981. begin
  982. p.x0:= x;
  983. p.y0:= y;
  984. end;
  985. procedure setXY0(var p: POLY_G3; const x, y: smallint);
  986. begin
  987. p.x0:= x;
  988. p.y0:= y;
  989. end;
  990. procedure setXY0(var p: POLY_G4; const x, y: smallint);
  991. begin
  992. p.x0:= x;
  993. p.y0:= y;
  994. end;
  995. procedure setXY0(var p: POLY_GT3; const x, y: smallint);
  996. begin
  997. p.x0:= x;
  998. p.y0:= y;
  999. end;
  1000. procedure setXY0(var p: POLY_GT4; const x, y: smallint);
  1001. begin
  1002. p.x0:= x;
  1003. p.y0:= y;
  1004. end;
  1005. procedure dumpRECT(r: RECT);
  1006. begin
  1007. GPU_printf('(%d,%d)-(%d,%d)\n', r.x, r.y, r.w, r.h);
  1008. end;
  1009. procedure setlen(var p: P_TAG; const len: byte);
  1010. begin
  1011. p.len:= len;
  1012. end;
  1013. procedure setlen(var p: POLY_F3; const len: byte);
  1014. var x : ^P_TAG;
  1015. begin
  1016. x:= @p;
  1017. x^.len:= len;
  1018. end;
  1019. procedure setlen(var p: POLY_FT3; const len: byte);
  1020. var x : ^P_TAG;
  1021. begin
  1022. x:= @p;
  1023. x^.len:= len;
  1024. end;
  1025. procedure setlen(var p: POLY_G3; const len: byte);
  1026. var x : ^P_TAG;
  1027. begin
  1028. x:= @p;
  1029. x^.len:= len;
  1030. end;
  1031. procedure setlen(var p: POLY_GT3; const len: byte);
  1032. var x : ^P_TAG;
  1033. begin
  1034. x:= @p;
  1035. x^.len:= len;
  1036. end;
  1037. procedure setlen(var p: POLY_F4; const len: byte);
  1038. var x : ^P_TAG;
  1039. begin
  1040. x:= @p;
  1041. x^.len:= len;
  1042. end;
  1043. procedure setlen(var p: POLY_FT4; const len: byte);
  1044. var x : ^P_TAG;
  1045. begin
  1046. x:= @p;
  1047. x^.len:= len;
  1048. end;
  1049. procedure setlen(var p: POLY_G4; const len: byte);
  1050. var x : ^P_TAG;
  1051. begin
  1052. x:= @p;
  1053. x^.len:= len;
  1054. end;
  1055. procedure setlen(var p: POLY_GT4; const len: byte);
  1056. var x : ^P_TAG;
  1057. begin
  1058. x:= @p;
  1059. x^.len:= len;
  1060. end;
  1061. procedure setlen(var p: SPRT_8; const len: byte);
  1062. var x : ^P_TAG;
  1063. begin
  1064. x:= @p;
  1065. x^.len:= len;
  1066. end;
  1067. procedure setlen(var p: SPRT_16; const len: byte);
  1068. var x : ^P_TAG;
  1069. begin
  1070. x:= @p;
  1071. x^.len:= len;
  1072. end;
  1073. procedure setlen(var p: SPRT; const len: byte);
  1074. var x : ^P_TAG;
  1075. begin
  1076. x:= @p;
  1077. x^.len:= len;
  1078. end;
  1079. procedure setlen(var p: TILE_1; const len: byte);
  1080. var x : ^P_TAG;
  1081. begin
  1082. x:= @p;
  1083. x^.len:= len;
  1084. end;
  1085. procedure setlen(var p: TILE_8; const len: byte);
  1086. var x : ^P_TAG;
  1087. begin
  1088. x:= @p;
  1089. x^.len:= len;
  1090. end;
  1091. procedure setlen(var p: TILE_16; const len: byte);
  1092. var x : ^P_TAG;
  1093. begin
  1094. x:= @p;
  1095. x^.len:= len;
  1096. end;
  1097. procedure setlen(var p: TILE; const len: byte);
  1098. var x : ^P_TAG;
  1099. begin
  1100. x:= @p;
  1101. x^.len:= len;
  1102. end;
  1103. procedure setlen(var p: LINE_F2; const len: byte);
  1104. var x : ^P_TAG;
  1105. begin
  1106. x:= @p;
  1107. x^.len:= len;
  1108. end;
  1109. procedure setlen(var p: LINE_G2; const len: byte);
  1110. var x : ^P_TAG;
  1111. begin
  1112. x:= @p;
  1113. x^.len:= len;
  1114. end;
  1115. procedure setlen(var p: LINE_F3; const len: byte);
  1116. var x : ^P_TAG;
  1117. begin
  1118. x:= @p;
  1119. x^.len:= len;
  1120. end;
  1121. procedure setlen(var p: LINE_G3; const len: byte);
  1122. var x : ^P_TAG;
  1123. begin
  1124. x:= @p;
  1125. x^.len:= len;
  1126. end;
  1127. procedure setlen(var p: LINE_F4; const len: byte);
  1128. var x : ^P_TAG;
  1129. begin
  1130. x:= @p;
  1131. x^.len:= len;
  1132. end;
  1133. procedure setlen(var p: LINE_G4; const len: byte);
  1134. var x : ^P_TAG;
  1135. begin
  1136. x:= @p;
  1137. x^.len:= len;
  1138. end;
  1139. procedure setaddr(var p: P_TAG; const addr: dword);
  1140. begin
  1141. p.addr:= addr;
  1142. end;
  1143. procedure setcode(var p: P_TAG; const code: byte);
  1144. begin
  1145. p.code:= code;
  1146. end;
  1147. procedure setcode(var p: POLY_F3; const code: byte);
  1148. var x : ^P_TAG;
  1149. begin
  1150. x:= @p;
  1151. x^.code:= code;
  1152. end;
  1153. procedure setcode(var p: POLY_FT3; const code: byte);
  1154. var x : ^P_TAG;
  1155. begin
  1156. x:= @p;
  1157. x^.code:= code;
  1158. end;
  1159. procedure setcode(var p: POLY_G3; const code: byte);
  1160. var x : ^P_TAG;
  1161. begin
  1162. x:= @p;
  1163. x^.code:= code;
  1164. end;
  1165. procedure setcode(var p: POLY_GT3; const code: byte);
  1166. var x : ^P_TAG;
  1167. begin
  1168. x:= @p;
  1169. x^.code:= code;
  1170. end;
  1171. procedure setcode(var p: POLY_F4; const code: byte);
  1172. var x : ^P_TAG;
  1173. begin
  1174. x:= @p;
  1175. x^.code:= code;
  1176. end;
  1177. procedure setcode(var p: POLY_FT4; const code: byte);
  1178. var x : ^P_TAG;
  1179. begin
  1180. x:= @p;
  1181. x^.code:= code;
  1182. end;
  1183. procedure setcode(var p: POLY_G4; const code: byte);
  1184. var x : ^P_TAG;
  1185. begin
  1186. x:= @p;
  1187. x^.code:= code;
  1188. end;
  1189. procedure setcode(var p: POLY_GT4; const code: byte);
  1190. var x : ^P_TAG;
  1191. begin
  1192. x:= @p;
  1193. x^.code:= code;
  1194. end;
  1195. procedure setcode(var p: SPRT_8; const code: byte);
  1196. var x : ^P_TAG;
  1197. begin
  1198. x:= @p;
  1199. x^.code:= code;
  1200. end;
  1201. procedure setcode(var p: SPRT_16; const code: byte);
  1202. var x : ^P_TAG;
  1203. begin
  1204. x:= @p;
  1205. x^.code:= code;
  1206. end;
  1207. procedure setcode(var p: SPRT; const code: byte);
  1208. var x : ^P_TAG;
  1209. begin
  1210. x:= @p;
  1211. x^.code:= code;
  1212. end;
  1213. procedure setcode(var p: TILE_1; const code: byte);
  1214. var x : ^P_TAG;
  1215. begin
  1216. x:= @p;
  1217. x^.code:= code;
  1218. end;
  1219. procedure setcode(var p: TILE_8; const code: byte);
  1220. var x : ^P_TAG;
  1221. begin
  1222. x:= @p;
  1223. x^.code:= code;
  1224. end;
  1225. procedure setcode(var p: TILE_16; const code: byte);
  1226. var x : ^P_TAG;
  1227. begin
  1228. x:= @p;
  1229. x^.code:= code;
  1230. end;
  1231. procedure setcode(var p: TILE; const code: byte);
  1232. var x : ^P_TAG;
  1233. begin
  1234. x:= @p;
  1235. x^.code:= code;
  1236. end;
  1237. procedure setcode(var p: LINE_F2; const code: byte);
  1238. var x : ^P_TAG;
  1239. begin
  1240. x:= @p;
  1241. x^.code:= code;
  1242. end;
  1243. procedure setcode(var p: LINE_G2; const code: byte);
  1244. var x : ^P_TAG;
  1245. begin
  1246. x:= @p;
  1247. x^.code:= code;
  1248. end;
  1249. procedure setcode(var p: LINE_F3; const code: byte);
  1250. var x : ^P_TAG;
  1251. begin
  1252. x:= @p;
  1253. x^.code:= code;
  1254. end;
  1255. procedure setcode(var p: LINE_G3; const code: byte);
  1256. var x : ^P_TAG;
  1257. begin
  1258. x:= @p;
  1259. x^.code:= code;
  1260. end;
  1261. procedure setcode(var p: LINE_F4; const code: byte);
  1262. var x : ^P_TAG;
  1263. begin
  1264. x:= @p;
  1265. x^.code:= code;
  1266. end;
  1267. procedure setcode(var p: LINE_G4; const code: byte);
  1268. var x : ^P_TAG;
  1269. begin
  1270. x:= @p;
  1271. x^.code:= code;
  1272. end;
  1273. function getlen(p: P_TAG): byte;
  1274. begin
  1275. getlen:= p.len;
  1276. end;
  1277. function getcode(p: P_TAG): byte;
  1278. begin
  1279. getcode:= p.code;
  1280. end;
  1281. function getaddr(p: P_TAG): dword;
  1282. begin
  1283. getaddr:= p.addr;
  1284. end;
  1285. // Primitive Lentgh Code
  1286. //--------------------------------------------------------------------
  1287. //
  1288. //#define setPolyF3(p) setlen(p, 4), setcode(p, 0x20)
  1289. procedure setPolyF3(var p: POLY_F3);
  1290. begin
  1291. setlen(p, 4);
  1292. setcode(p, $20);
  1293. end;
  1294. //#define setPolyFT3(p) setlen(p, 7), setcode(p, 0x24)
  1295. procedure setPolyFT3(var p: POLY_FT3);
  1296. begin
  1297. setlen(p, 7);
  1298. setcode(p, $24);
  1299. end;
  1300. //#define setPolyG3(p) setlen(p, 6), setcode(p, 0x30)
  1301. procedure setPolyG3(var p: POLY_G3);
  1302. begin
  1303. setlen(p, 6);
  1304. setcode(p, $30);
  1305. end;
  1306. //#define setPolyGT3(p) setlen(p, 9), setcode(p, 0x34)
  1307. procedure setPolyGT3(var p: POLY_GT3);
  1308. begin
  1309. setlen(p, 9);
  1310. setcode(p, $34);
  1311. end;
  1312. //#define setPolyF4(p) setlen(p, 5), setcode(p, 0x28)
  1313. procedure setPolyF4(var p: POLY_F4);
  1314. begin
  1315. setlen(p, 5);
  1316. setcode(p, $28);
  1317. end;
  1318. //#define setPolyFT4(p) setlen(p, 9), setcode(p, 0x2c)
  1319. procedure setPolyFT4(var p: POLY_FT4);
  1320. begin
  1321. setlen(p, 9);
  1322. setcode(p, $2c);
  1323. end;
  1324. //#define setPolyG4(p) setlen(p, 8), setcode(p, 0x38)
  1325. procedure setPolyG4(var p: POLY_G4);
  1326. begin
  1327. setlen(p, 8);
  1328. setcode(p, $38);
  1329. end;
  1330. //#define setPolyGT4(p) setlen(p, 12), setcode(p, 0x3c)
  1331. procedure setPolyGT4(var p: POLY_GT4);
  1332. begin
  1333. setlen(p, 12);
  1334. setcode(p, $3c);
  1335. end;
  1336. //#define setSprt8(p) setlen(p, 3), setcode(p, 0x74)
  1337. procedure setSprt8(var p: SPRT_8);
  1338. begin
  1339. setlen(p, 3);
  1340. setcode(p, $74);
  1341. end;
  1342. //#define setSprt16(p) setlen(p, 3), setcode(p, 0x7c)
  1343. procedure setSprt16(var p: SPRT_16);
  1344. begin
  1345. setlen(p, 3);
  1346. setcode(p, $7c);
  1347. end;
  1348. //#define setSprt(p) setlen(p, 4), setcode(p, 0x64)
  1349. procedure setSprt(var p: SPRT);
  1350. begin
  1351. setlen(p, 4);
  1352. setcode(p, $64);
  1353. end;
  1354. //#define setTile1(p) setlen(p, 2), setcode(p, 0x68)
  1355. {
  1356. procedure setTile1(var p: TILE_1);
  1357. begin
  1358. setlen(p, 2);
  1359. setcode(p, $68);
  1360. end;
  1361. }
  1362. //#define setTile8(p) setlen(p, 2), setcode(p, 0x70)
  1363. procedure setTile8(var p: TILE_8);
  1364. begin
  1365. setlen(p, 2);
  1366. setcode(p, $70);
  1367. end;
  1368. //#define setTile16(p) setlen(p, 2), setcode(p, 0x78)
  1369. procedure setTile16(var p: TILE_16);
  1370. begin
  1371. setlen(p, 2);
  1372. setcode(p, $78);
  1373. end;
  1374. //#define setTile(p) setlen(p, 3), setcode(p, 0x60)
  1375. procedure setTile(var p: TILE);
  1376. begin
  1377. setlen(p, 3);
  1378. setcode(p, $60);
  1379. end;
  1380. //#define setLineF2(p) setlen(p, 3), setcode(p, 0x40)
  1381. procedure setLineF2(var p: LINE_F2);
  1382. begin
  1383. setlen(p, 3);
  1384. setcode(p, $40);
  1385. end;
  1386. //#define setLineG2(p) setlen(p, 4), setcode(p, 0x50)
  1387. procedure setLineG2(var p: LINE_G2);
  1388. begin
  1389. setlen(p, 4);
  1390. setcode(p, $50);
  1391. end;
  1392. //#define setLineF3(p) setlen(p, 5), setcode(p, 0x48),(p)->pad = 0x55555555
  1393. procedure setLineF3(var p: LINE_F3);
  1394. begin
  1395. setlen(p, 5);
  1396. setcode(p, $48);
  1397. p.pad:= $55555555;
  1398. end;
  1399. //#define setLineG3(p) setlen(p, 7), setcode(p, 0x58),(p)->pad = 0x55555555, \
  1400. // (p)->p2 = 0
  1401. procedure setLineG3(var p: LINE_G3);
  1402. begin
  1403. setlen(p, 7);
  1404. setcode(p, $58);
  1405. p.pad:= $55555555;
  1406. p.p2:= 0;
  1407. end;
  1408. //#define setLineF4(p) setlen(p, 6), setcode(p, 0x4c),(p)->pad = 0x55555555
  1409. procedure setLineF4(var p: LINE_F4);
  1410. begin
  1411. setlen(p, 6);
  1412. setcode(p, $4c);
  1413. p.pad:= $55555555;
  1414. end;
  1415. //#define setLineG4(p) setlen(p, 9), setcode(p, 0x5c),(p)->pad = 0x55555555, \
  1416. // (p)->p2 = 0, (p)->p3 = 0
  1417. procedure setLineG4(var p: LINE_G4);
  1418. begin
  1419. setlen(p, 9);
  1420. setcode(p, $5c);
  1421. p.pad:= $55555555;
  1422. p.p2:= 0;
  1423. p.p3:= 0;
  1424. end;
  1425. end.