diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index 0c44c977bac..c7896fdb86d 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -53,16 +53,18 @@ ) (defenum language-enum - :type int64 + :type uint8 (english 0) (french 1) (german 2) (spanish 3) (italian 4) + (commentary 5) (japanese 6) (korean 7) (russian 8) (portuguese 9) + (dutch 10) (uk-english 11) ) @@ -3373,16 +3375,650 @@ ;; +++vu1-user-h:tpage-category (defenum tpage-category :type int8 + (tpage-cat0 0) + (tpage-cat1 1) + (tpage-cat2 2) + (tpage-cat3 3) + (tpage-cat4 4) + (tpage-cat5 5) + (tpage-cat6 6) + (tpage-cat7 7) + (tpage-cat8 8) + (sky 9) + (tpage-cat10 10) ) ;; ---vu1-user-h:tpage-category +;; +++vu1-user-h:tpage-category-u32 +(defenum tpage-category-u32 + :type uint32 + :copy-entries tpage-category + ) +;; ---vu1-user-h:tpage-category-u32 + ;; +++vu1-user-h:bucket-id (defenum bucket-id :type int32 + (bucket0 0) + (bucket1 1) + (bucket2 2) + (bucket3 3) + (tex-lcom-sky-pre 4) + (bucket5 5) + (bucket6 6) + (bucket7 7) + (bucket8 8) + (bucket9 9) + (bucket10 10) + (bucket11 11) + (bucket12 12) + (bucket13 13) + (bucket14 14) + (bucket15 15) + (bucket16 16) + (bucket17 17) + (bucket18 18) + (bucket19 19) + (bucket20 20) + (bucket21 21) + (bucket22 22) + (bucket23 23) + (bucket24 24) + (bucket25 25) + (bucket26 26) + (bucket27 27) + (bucket28 28) + (bucket29 29) + (bucket30 30) + (bucket31 31) + (bucket32 32) + (bucket33 33) + (bucket34 34) + (bucket35 35) + (bucket36 36) + (bucket37 37) + (bucket38 38) + (bucket39 39) + (bucket40 40) + (bucket41 41) + (bucket42 42) + (bucket43 43) + (bucket44 44) + (bucket45 45) + (bucket46 46) + (bucket47 47) + (bucket48 48) + (bucket49 49) + (bucket50 50) + (bucket51 51) + (bucket52 52) + (bucket53 53) + (bucket54 54) + (bucket55 55) + (bucket56 56) + (bucket57 57) + (bucket58 58) + (bucket59 59) + (bucket60 60) + (bucket61 61) + (bucket62 62) + (bucket63 63) + (bucket64 64) + (bucket65 65) + (bucket66 66) + (bucket67 67) + (bucket68 68) + (bucket69 69) + (bucket70 70) + (bucket71 71) + (bucket72 72) + (bucket73 73) + (bucket74 74) + (bucket75 75) + (bucket76 76) + (bucket77 77) + (bucket78 78) + (bucket79 79) + (bucket80 80) + (bucket81 81) + (bucket82 82) + (bucket83 83) + (bucket84 84) + (bucket85 85) + (bucket86 86) + (bucket87 87) + (bucket88 88) + (bucket89 89) + (bucket90 90) + (bucket91 91) + (bucket92 92) + (bucket93 93) + (bucket94 94) + (bucket95 95) + (bucket96 96) + (bucket97 97) + (bucket98 98) + (bucket99 99) + (bucket100 100) + (bucket101 101) + (bucket102 102) + (bucket103 103) + (bucket104 104) + (bucket105 105) + (bucket106 106) + (bucket107 107) + (bucket108 108) + (bucket109 109) + (bucket110 110) + (bucket111 111) + (bucket112 112) + (bucket113 113) + (bucket114 114) + (bucket115 115) + (bucket116 116) + (bucket117 117) + (bucket118 118) + (bucket119 119) + (bucket120 120) + (bucket121 121) + (bucket122 122) + (bucket123 123) + (bucket124 124) + (bucket125 125) + (bucket126 126) + (bucket127 127) + (bucket128 128) + (bucket129 129) + (bucket130 130) + (bucket131 131) + (bucket132 132) + (bucket133 133) + (bucket134 134) + (bucket135 135) + (bucket136 136) + (bucket137 137) + (bucket138 138) + (bucket139 139) + (bucket140 140) + (bucket141 141) + (bucket142 142) + (bucket143 143) + (bucket144 144) + (bucket145 145) + (bucket146 146) + (bucket147 147) + (bucket148 148) + (bucket149 149) + (bucket150 150) + (bucket151 151) + (bucket152 152) + (bucket153 153) + (bucket154 154) + (bucket155 155) + (bucket156 156) + (bucket157 157) + (bucket158 158) + (bucket159 159) + (bucket160 160) + (bucket161 161) + (bucket162 162) + (bucket163 163) + (bucket164 164) + (bucket165 165) + (bucket166 166) + (bucket167 167) + (bucket168 168) + (bucket169 169) + (bucket170 170) + (bucket171 171) + (bucket172 172) + (bucket173 173) + (bucket174 174) + (bucket175 175) + (bucket176 176) + (bucket177 177) + (bucket178 178) + (bucket179 179) + (bucket180 180) + (bucket181 181) + (bucket182 182) + (bucket183 183) + (bucket184 184) + (bucket185 185) + (bucket186 186) + (bucket187 187) + (bucket188 188) + (bucket189 189) + (bucket190 190) + (bucket191 191) + (bucket192 192) + (bucket193 193) + (bucket194 194) + (bucket195 195) + (bucket196 196) + (bucket197 197) + (bucket198 198) + (bucket199 199) + (bucket200 200) + (bucket201 201) + (bucket202 202) + (bucket203 203) + (bucket204 204) + (bucket205 205) + (bucket206 206) + (bucket207 207) + (bucket208 208) + (bucket209 209) + (bucket210 210) + (bucket211 211) + (bucket212 212) + (bucket213 213) + (bucket214 214) + (bucket215 215) + (bucket216 216) + (bucket217 217) + (bucket218 218) + (bucket219 219) + (bucket220 220) + (bucket221 221) + (bucket222 222) + (bucket223 223) + (bucket224 224) + (bucket225 225) + (bucket226 226) + (bucket227 227) + (bucket228 228) + (bucket229 229) + (bucket230 230) + (bucket231 231) + (bucket232 232) + (bucket233 233) + (bucket234 234) + (bucket235 235) + (bucket236 236) + (bucket237 237) + (bucket238 238) + (bucket239 239) + (bucket240 240) + (bucket241 241) + (bucket242 242) + (bucket243 243) + (bucket244 244) + (bucket245 245) + (bucket246 246) + (bucket247 247) + (bucket248 248) + (bucket249 249) + (bucket250 250) + (bucket251 251) + (bucket252 252) + (bucket253 253) + (bucket254 254) + (bucket255 255) + (bucket256 256) + (bucket257 257) + (bucket258 258) + (bucket259 259) + (bucket260 260) + (bucket261 261) + (bucket262 262) + (bucket263 263) + (bucket264 264) + (bucket265 265) + (bucket266 266) + (bucket267 267) + (bucket268 268) + (bucket269 269) + (bucket270 270) + (bucket271 271) + (bucket272 272) + (bucket273 273) + (bucket274 274) + (bucket275 275) + (bucket276 276) + (bucket277 277) + (bucket278 278) + (bucket279 279) + (bucket280 280) + (bucket281 281) + (bucket282 282) + (bucket283 283) + (bucket284 284) + (bucket285 285) + (bucket286 286) + (bucket287 287) + (bucket288 288) + (bucket289 289) + (bucket290 290) + (bucket291 291) + (bucket292 292) + (bucket293 293) + (bucket294 294) + (bucket295 295) + (bucket296 296) + (bucket297 297) + (bucket298 298) + (bucket299 299) + (bucket300 300) + (bucket301 301) + (bucket302 302) + (bucket303 303) + (bucket304 304) + (bucket305 305) + (bucket306 306) + (bucket307 307) + (bucket308 308) + (bucket309 309) + (bucket310 310) + (bucket311 311) + (bucket312 312) + (bucket313 313) + (bucket314 314) + (bucket315 315) + (bucket316 316) + (bucket317 317) + (bucket318 318) + (bucket319 319) + (bucket320 320) + (bucket321 321) + (bucket322 322) + (bucket323 323) + (bucket324 324) + (bucket325 325) + (bucket326 326) + (bucket327 327) + (bucket328 328) + (bucket329 329) + (bucket330 330) + (bucket331 331) + (bucket332 332) + (bucket333 333) + (bucket334 334) + (bucket335 335) + (bucket336 336) + (bucket337 337) + (bucket338 338) + (bucket339 339) + (bucket340 340) + (bucket341 341) + (bucket342 342) + (bucket343 343) + (bucket344 344) + (bucket345 345) + (bucket346 346) + (bucket347 347) + (bucket348 348) + (bucket349 349) + (bucket350 350) + (bucket351 351) + (bucket352 352) + (bucket353 353) + (bucket354 354) + (bucket355 355) + (bucket356 356) + (bucket357 357) + (bucket358 358) + (bucket359 359) + (bucket360 360) + (bucket361 361) + (bucket362 362) + (bucket363 363) + (bucket364 364) + (bucket365 365) + (bucket366 366) + (bucket367 367) + (bucket368 368) + (bucket369 369) + (bucket370 370) + (bucket371 371) + (bucket372 372) + (bucket373 373) + (bucket374 374) + (bucket375 375) + (bucket376 376) + (bucket377 377) + (bucket378 378) + (bucket379 379) + (bucket380 380) + (bucket381 381) + (bucket382 382) + (bucket383 383) + (bucket384 384) + (bucket385 385) + (bucket386 386) + (bucket387 387) + (bucket388 388) + (bucket389 389) + (bucket390 390) + (bucket391 391) + (bucket392 392) + (bucket393 393) + (bucket394 394) + (bucket395 395) + (bucket396 396) + (bucket397 397) + (bucket398 398) + (bucket399 399) + (bucket400 400) + (bucket401 401) + (bucket402 402) + (bucket403 403) + (bucket404 404) + (bucket405 405) + (bucket406 406) + (bucket407 407) + (bucket408 408) + (bucket409 409) + (bucket410 410) + (bucket411 411) + (bucket412 412) + (bucket413 413) + (bucket414 414) + (bucket415 415) + (bucket416 416) + (bucket417 417) + (bucket418 418) + (bucket419 419) + (bucket420 420) + (bucket421 421) + (bucket422 422) + (bucket423 423) + (bucket424 424) + (bucket425 425) + (bucket426 426) + (bucket427 427) + (bucket428 428) + (bucket429 429) + (bucket430 430) + (bucket431 431) + (bucket432 432) + (bucket433 433) + (bucket434 434) + (bucket435 435) + (bucket436 436) + (bucket437 437) + (bucket438 438) + (bucket439 439) + (bucket440 440) + (bucket441 441) + (bucket442 442) + (bucket443 443) + (bucket444 444) + (bucket445 445) + (bucket446 446) + (bucket447 447) + (bucket448 448) + (bucket449 449) + (bucket450 450) + (bucket451 451) + (bucket452 452) + (bucket453 453) + (bucket454 454) + (bucket455 455) + (bucket456 456) + (bucket457 457) + (bucket458 458) + (bucket459 459) + (bucket460 460) + (bucket461 461) + (bucket462 462) + (bucket463 463) + (bucket464 464) + (bucket465 465) + (bucket466 466) + (bucket467 467) + (bucket468 468) + (bucket469 469) + (bucket470 470) + (bucket471 471) + (bucket472 472) + (bucket473 473) + (bucket474 474) + (bucket475 475) + (bucket476 476) + (bucket477 477) + (bucket478 478) + (bucket479 479) + (bucket480 480) + (bucket481 481) + (bucket482 482) + (bucket483 483) + (bucket484 484) + (bucket485 485) + (bucket486 486) + (bucket487 487) + (bucket488 488) + (bucket489 489) + (bucket490 490) + (bucket491 491) + (bucket492 492) + (bucket493 493) + (bucket494 494) + (bucket495 495) + (bucket496 496) + (bucket497 497) + (bucket498 498) + (bucket499 499) + (bucket500 500) + (bucket501 501) + (bucket502 502) + (bucket503 503) + (bucket504 504) + (bucket505 505) + (bucket506 506) + (bucket507 507) + (bucket508 508) + (bucket509 509) + (bucket510 510) + (bucket511 511) + (bucket512 512) + (bucket513 513) + (bucket514 514) + (bucket515 515) + (bucket516 516) + (bucket517 517) + (bucket518 518) + (bucket519 519) + (bucket520 520) + (bucket521 521) + (bucket522 522) + (bucket523 523) + (bucket524 524) + (bucket525 525) + (bucket526 526) + (bucket527 527) + (bucket528 528) + (bucket529 529) + (bucket530 530) + (bucket531 531) + (bucket532 532) + (bucket533 533) + (bucket534 534) + (bucket535 535) + (bucket536 536) + (bucket537 537) + (bucket538 538) + (bucket539 539) + (bucket540 540) + (bucket541 541) + (bucket542 542) + (bucket543 543) + (bucket544 544) + (bucket545 545) + (bucket546 546) + (bucket547 547) + (bucket548 548) + (bucket549 549) + (bucket550 550) + (bucket551 551) + (bucket552 552) + (bucket553 553) + (bucket554 554) + (bucket555 555) + (bucket556 556) + (bucket557 557) + (bucket558 558) + (bucket559 559) + (bucket560 560) + (bucket561 561) + (bucket562 562) + (bucket563 563) + (bucket564 564) + (bucket565 565) + (bucket566 566) + (bucket567 567) + (bucket568 568) + (bucket569 569) + (bucket570 570) + (bucket571 571) + (bucket572 572) + (bucket573 573) + (bucket574 574) + (bucket575 575) + (bucket576 576) + (bucket577 577) + (bucket578 578) + (bucket579 579) + (bucket580 580) + (bucket581 581) + (bucket582 582) + (bucket583 583) (debug-no-zbuf2 584) ) ;; ---vu1-user-h:bucket-id +;; +++vu1-user-h:texture-enable-mask +(defenum texture-enable-mask + :type uint64 + :bitfield #t + (tex0 0) + (tex1 1) + (tex2 2) + (tex3 3) + (tex4 4) + (tex5 5) + (tex6 6) + (tex7 7) + (sky 8) + (tex9 9) + (tex10 10) + (tex11 11) + (tex12 12) + (tex13 13) + (tex14 14) + (tex15 15) + (tex16 16) + ) +;; ---vu1-user-h:texture-enable-mask + +;; +++vu1-user-h:texture-enable-mask-u32 +(defenum texture-enable-mask-u32 + :type uint32 + :bitfield #t + :copy-entries texture-enable-mask + ) +;; ---vu1-user-h:texture-enable-mask-u32 + ;; +++vu1-user-h:vu1-renderer-mask ;; TODO stolen from Jak 2 (defenum vu1-renderer-mask @@ -3601,20 +4237,17 @@ ;; dma-buffer ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype dma-packet (structure) - ((dma uint64 :offset-assert 0) ;; dma-tag + ((dma dma-tag :offset-assert 0) ;; dma-tag (vif0 vif-tag :offset-assert 8) ;; guessed by decompiler (vif1 vif-tag :offset-assert 12) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype dma-packet-array (inline-array-class) ((data dma-packet :dynamic :offset-assert 16) ;; guessed by decompiler ) @@ -3622,30 +4255,25 @@ :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype dma-gif (structure) ((gif uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype dma-gif-packet (structure) ((dma-vif dma-packet :inline :offset-assert 0) (gif uint64 2 :offset-assert 16) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (quad uint128 2 :offset 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ) -|# (deftype dma-buffer (basic) ((allocated-length int32 :offset-assert 4) @@ -3910,448 +4538,853 @@ ;; gs ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype gs-pmode (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-psm +(defenum gs-psm + :bitfield #f + :type uint8 + (ct32 0) + (ct24 1) + (ct16 2) + (ct16s 10) + (mt8 19) + (mt4 20) + (mt8h 27) + (mt4hl 36) + (mt4hh 44) + (mz32 48) + (mz24 49) + (mz16 50) + (mz16s 58) + ) +;; ---gs:gs-psm + +;; +++gs:gs-reg +(defenum gs-reg + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (tex1-1 20) + (tex1-2 21) + (tex2-1 22) + (tex2-2 23) + (xyoffset-1 24) + (xyoffset-2 25) + (prmodecont 26) + (prmode 27) + (texclut 28) + (scanmsk 34) + (miptbp1-1 52) + (miptbp1-2 53) + (miptbp2-1 54) + (miptbp2-2 55) + (texa 59) + (fogcol 61) + (texflush 63) + (scissor-1 64) + (scissor-2 65) + (alpha-1 66) + (alpha-2 67) + (dimx 68) + (dthe 69) + (colclamp 70) + (test-1 71) + (test-2 72) + (pabe 73) + (fba-1 74) + (fba-2 75) + (frame-1 76) + (frame-2 77) + (zbuf-1 78) + (zbuf-2 79) + (bitbltbuf 80) + (trxpos 81) + (trxreg 82) + (trxdir 83) + (hwreg 84) + (signal 96) + (finish 97) + (label 98) + (hack 127) + ) +;; ---gs:gs-reg + +;; +++gs:gs-reg64 +(defenum gs-reg64 + :type uint64 + :copy-entries gs-reg + ) +;; ---gs:gs-reg64 -;; (deftype gs-smode2 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-reg32 +(defenum gs-reg32 + :type uint32 + :copy-entries gs-reg + ) +;; ---gs:gs-reg32 -;; (deftype gs-display-fb (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-prim-type +(defenum gs-prim-type + :type uint8 + (point 0) + (line 1) + (line-strip 2) + (tri 3) + (tri-strip 4) + (tri-fan 5) + (sprite 6) + ) +;; ---gs:gs-prim-type + +(deftype gs-pmode (uint64) + ((en1 uint8 :offset 0 :size 1) + (en2 uint8 :offset 1 :size 1) + (crtmd uint8 :offset 2 :size 3) + (mmod uint8 :offset 5 :size 1) + (amod uint8 :offset 6 :size 1) + (slbg uint8 :offset 7 :size 1) + (alp uint8 :offset 8 :size 8) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-display (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-smode2 (uint64) + ((int uint8 :offset 0 :size 1) + (ffmd uint8 :offset 1 :size 1) + (dpms uint8 :offset 2 :size 2) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-bgcolor (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-display-fb (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 9 :size 6) + (psm gs-psm :offset 15 :size 5) + (dbx uint16 :offset 32 :size 11) + (dby uint16 :offset 43 :size 11) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-csr (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-display (uint64) + "the GS's DISPLAY registers make settings for the display position on the screen regarding + information on Rectangular Area Read Output Circuit n for the PCRTC. + write-only" + ((dx uint16 :offset 0 :size 12) + (dy uint16 :offset 12 :size 11) + (magh uint8 :offset 23 :size 4) + (magv uint8 :offset 27 :size 2) + (dw uint16 :offset 32 :size 12) + (dh uint16 :offset 44 :size 11) + ) + :flag-assert #x900000008 + ) + +(deftype gs-bgcolor (uint64) + "The GS's BGCOLOR register sets the background color of the PCRTC with RGB value. + write-only" + ((r uint8 :offset 0) + (g uint8 :offset 8) + (b uint8 :offset 16) + ) + :flag-assert #x900000008 + ) + +(deftype gs-csr (uint64) + "The GS's CSR register sets and obtains various GS statuses. + read-write. The fields have different effects depending on whether they're being read from + or written to. + + Bits 5 and 6 (0x20 and 0x40) should be zero." + ((signal uint8 :offset 0 :size 1) + (finish uint8 :offset 1 :size 1) + (hsint uint8 :offset 2 :size 1) + (vsint uint8 :offset 3 :size 1) + (edwint uint8 :offset 4 :size 1) + (flush uint8 :offset 8 :size 1) + (reset uint8 :offset 9 :size 1) + (nfield uint8 :offset 12 :size 1) + (field uint8 :offset 13 :size 1) + (fifo uint8 :offset 14 :size 2) + (rev uint8 :offset 16 :size 8) + (id uint8 :offset 24 :size 8) + ) + :flag-assert #x900000008 + ) -#| (deftype gs-bank (structure) - ((pmode uint64 :offset-assert 0) ;; gs-pmode - (smode2 uint64 :offset-assert 32) ;; gs-smode2 - (dspfb1 uint64 :offset-assert 112) ;; gs-display-fb - (display1 uint64 :offset-assert 128) ;; gs-display - (dspfb2 uint64 :offset-assert 144) ;; gs-display-fb - (display2 uint64 :offset-assert 160) ;; gs-display - (extbuf uint64 :offset-assert 176) - (extdata uint64 :offset-assert 192) - (extwrite uint64 :offset-assert 208) - (bgcolor uint64 :offset-assert 224) ;; gs-bgcolor - (csr uint64 :offset-assert 4096) ;; gs-csr - (imr uint64 :offset-assert 4112) - (busdir uint64 :offset-assert 4160) + "Memory layout of the GS's privileged registers (mapped to EE memory). + It is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)" + ((pmode gs-pmode :offset-assert 0) + (smode2 gs-smode2 :offset 32) + (dspfb1 gs-display-fb :offset 112) + (display1 gs-display :offset 128) + (dspfb2 gs-display-fb :offset 144) + (display2 gs-display :offset 160) + (extbuf uint64 :offset 176) + (extdata uint64 :offset 192) + (extwrite uint64 :offset 208) + (bgcolor gs-bgcolor :offset 224) + (csr gs-csr :offset 4096) + (imr uint64 :offset 4112) + (busdir uint64 :offset 4160) ) :method-count-assert 9 :size-assert #x1048 :flag-assert #x900001048 ) -|# -;; (deftype gs-frame (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-frame (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 16 :size 6) + (psm gs-psm :offset 24 :size 6) + (fbmsk uint32 :offset 32 :size 32) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-zbuf (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-zbuf (uint64) + "The GS's ZBUF registers make various settings regarding Z buffer." + ((zbp uint16 :offset 0 :size 9) + (psm gs-psm :offset 24 :size 4) + (zmsk uint8 :offset 32 :size 1) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-xy-offset (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-xy-offset (uint64) + "The GS's XYOFFSET registers set the offset value for converting from the primitive coordinate + system to the window coordinate system." + ((ofx uint16 :offset 0 :size 16) + (ofy uint16 :offset 32 :size 16) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-scissor (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-scissor (uint64) + "The GS's SCISSOR registers specify the scissoring area. The coordinate values for + the upper-left/lower-right points of the enabled drawing area are specified by the window + coordinate system." + ((scax0 uint16 :offset 0 :size 11) + (scax1 uint16 :offset 16 :size 11) + (scay0 uint16 :offset 32 :size 11) + (scay1 uint16 :offset 48 :size 11) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-prmode-cont (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-prmode-cont (uint64) + "The GS's PRMODECONT register sets whether to use primitive attributes (IIP, TME, FGE, ABE, + AA1, FST, CTXT, FIX) specified by the PRMODE register or the PRIM register." + ((ac uint8 :offset 0 :size 1) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-color-clamp (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-color-clamp (uint64) + "The GS's COLCLAMP register stores settings as to whether clamping for the RGB value of the + pixel is performed." + ((clamp uint8 :offset 0 :size 1) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-dthe (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-dthe (uint64) + "The GS's DTHE register stores settings for dithering (performed/not performed)." + ((dthe uint8 :offset 0 :size 1)) + :flag-assert #x900000008 + ) -;; (deftype gs-test (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-atest +(defenum gs-atest + :type uint8 + (never 0) + (always 1) + (less 2) + (less-equal 3) + (equal 4) + (greater-equal 5) + (greater 6) + (not-equal 7) + ) +;; ---gs:gs-atest + +;; +++gs:gs-ztest +(defenum gs-ztest + :type uint8 + (never 0) + (always 1) + (greater-equal 2) + (greater 3) + ) +;; ---gs:gs-ztest + +(deftype gs-test (uint64) + "The GS's TEST register performs settings related to the pixel test." + ((ate uint8 :offset 0 :size 1) ;; alpha test enable + (atst gs-atest :offset 1 :size 3) ;; alpha test method + (aref uint8 :offset 4 :size 8) ;; alpha val reference + (afail uint8 :offset 12 :size 2) ;; processing method on alpha test fail + (date uint8 :offset 14 :size 1) ;; dest alpha test enable + (datm uint8 :offset 15 :size 1) ;; dest alpha test mode + (zte uint8 :offset 16 :size 1) ;; depth test enable + (ztst gs-ztest :offset 17 :size 2) ;; depth test method + ) + :flag-assert #x900000008 + ) -;; (deftype gs-prim (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-rgbaq (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-rgbaq (uint64) + "The GS's RGBAQ register sets the RGBA value of the vertex and the Q value of the normalized + texture coordinates." + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + (a uint8 :offset 24 :size 8) ;; 0x80 --> 1.0 + (q float :offset 32 :size 32) ;; affects some LOD behavior apparently? + ) + :flag-assert #x900000008 + ) -;; (deftype gs-xyz (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-xyz (uint64) + ((x uint16 :offset 0 :size 16) ;; Q4 fixed point + (y uint16 :offset 16 :size 16) ;; Q4 fixed point + (z uint32 :offset 32 :size 32) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-uv (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-uv (uint64) + "The GS's UV register specifies the texel coordinate (UV) values of the vertex." + ((u uint16 :offset 0 :size 16) ;; Q4 fixed point + (v uint16 :offset 16 :size 16) ;; Q4 fixed point + ) + :flag-assert #x900000008 + ) -;; (deftype gs-st (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-uv2 (uint64) + "Hack - added for warp." + ((u int16 :offset 0 :size 16) ;; Q4 fixed point + (v int16 :offset 16 :size 16) ;; Q4 fixed point + ) + :flag-assert #x900000008 + ) -;; (deftype gs-xyzf (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-st (uint64) + "The GS's ST register sets the S and T values of the vertex texture coordinates. + The value Q is specified by the RGBAQ register." + ((s float :offset 0 :size 32) + (t float :offset 32 :size 32) + ) + :flag-assert #x900000008 + ) + +(deftype gs-xyzf (uint64) + ((x uint16 :offset 0 :size 16) ;; Q4 fixed point + (y uint16 :offset 16 :size 16) ;; Q4 fixed point + (z uint32 :offset 32 :size 24) + (f uint8 :offset 56 :size 8) ;; fog coeff + ) + :flag-assert #x900000008 + ) -#| (deftype gs-adcmd (structure) - ((word uint32 4 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) - (data uint64 :offset-assert 0) - (cmds uint64 :offset-assert 8) ;; gs-reg64 - (cmd uint8 :offset-assert 8) - (x uint32 :offset-assert 0) - (y uint32 :offset-assert 4) - (z uint32 :offset-assert 8) - (w uint32 :offset-assert 12) + ((word uint32 4 :offset-assert 0 :score -10) + (quad uint128 :offset 0 :score -10) + (data uint64 :offset 0 :score -10) + (cmds gs-reg64 :offset 8 :score 10) + (cmd uint8 :offset 8) + (x uint32 :offset 0) + (y uint32 :offset 4) + (z uint32 :offset 8) + (w uint32 :offset 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (deftype gs-trxpos (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-trxpos (uint64) + "The GS's TRXPOS register specifies the position and + scanning direction of the rectangular area + in each buffer where buffer transmission is performed." + ((ssax uint16 :offset 0 :size 11) + (ssay uint16 :offset 16 :size 11) + (dsax uint16 :offset 32 :size 11) + (dsay uint16 :offset 48 :size 11) + (dir uint8 :offset 59 :size 2) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-trxreg (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-trxreg (uint64) + "The GS's TRXREG register specifies the size of the rectangular area, where the transmission + between buffers is implemented, in units of pixels. + The pixel mode must be the one set by the BITBLTBUF register." + ((rrw uint16 :offset 0 :size 12) + (rrh uint16 :offset 32 :size 12) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-trxdir (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-trxdir (uint64) + "The GS's TRXDIR register specifies the transmission direction in the transmission between + buffers, and activates transmission. + Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating + the transmission." + ((xdir uint8 :offset 0 :size 2) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-bitbltbuf (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-bitbltbuf (uint64) + "The GS's BITBLTBUF register stores buffer-related settings for transmission source and + destination during transmission between buffers." + ((sbp uint16 :offset 0 :size 14) + (sbw uint8 :offset 16 :size 6) + (spsm uint8 :offset 24 :size 6) + (dbp uint16 :offset 32 :size 14) + (dbw uint8 :offset 48 :size 6) + (dpsm gs-psm :offset 56 :size 6) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-tex0 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-tex0 (uint64) + "The GS's TEX0 registers set various kinds of information regarding the textures to be used." + ((tbp0 uint16 :offset 0 :size 14) + (tbw uint8 :offset 14 :size 6) + (psm uint8 :offset 20 :size 6) + (tw uint8 :offset 26 :size 4) + (th uint8 :offset 30 :size 4) + (tcc uint8 :offset 34 :size 1) + (tfx uint8 :offset 35 :size 2) + (cbp uint16 :offset 37 :size 14) + (cpsm uint8 :offset 51 :size 4) + (csm uint8 :offset 55 :size 1) + (csa uint8 :offset 56 :size 5) + (cld uint8 :offset 61 :size 3) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-tex1 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-tex1 (uint64) + "The GS's TEX1 registers set information on the sampling method of the textures." + ((lcm uint8 :offset 0 :size 1) + (mxl uint8 :offset 2 :size 3) + (mmag uint8 :offset 5 :size 1) + (mmin uint8 :offset 6 :size 3) + (mtba uint8 :offset 9 :size 1) + (l uint8 :offset 19 :size 2) + (k int16 :offset 32 :size 12) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-texa (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-texa (uint64) + "The GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the + texture is not an 8-bit value." + ((ta0 uint8 :offset 0 :size 8) + (aem uint8 :offset 15 :size 1) + (ta1 uint8 :offset 32 :size 8) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-texclut (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-texclut (uint64) + "The GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode + is CSM=1 (CSM2 mode)." + ((cbw uint8 :offset 0 :size 6) + (cou uint8 :offset 6 :size 6) + (cov uint16 :offset 12 :size 10) + ) + :flag-assert #x900000008 + ) -;; (deftype gs-miptbp (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +(deftype gs-miptbp (uint64) + "the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing + MIPMAP. MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6." + ((tbp1 uint16 :offset 0 :size 14) + (tbw1 uint8 :offset 14 :size 6) + (tbp2 uint16 :offset 20 :size 14) + (tbw2 uint8 :offset 34 :size 6) + (tbp3 uint16 :offset 40 :size 14) + (tbw3 uint8 :offset 54 :size 6) + ) + :flag-assert #x900000008 + ) -#| (deftype gs-alpha (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((a uint8 :offset 0 :size 2) + (b uint8 :offset 2 :size 2) + (c uint8 :offset 4 :size 2) + (d uint8 :offset 6 :size 2) + (fix uint8 :offset 32 :size 8) ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 + :flag-assert #x900000008 ) -|# -;; (deftype gs-clamp (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gs-tex-wrap-mode +(defenum gs-tex-wrap-mode + :type uint8 + (repeat 0) + (clamp 1) + (region-clamp 2) + (region-repeat 3) + ) +;; ---gs:gs-tex-wrap-mode + +(deftype gs-clamp (uint64) + ((wms gs-tex-wrap-mode :offset 0 :size 2) + (wmt gs-tex-wrap-mode :offset 2 :size 2) + (minu uint16 :offset 4 :size 10) + (maxu uint16 :offset 14 :size 10) + (minv uint16 :offset 24 :size 10) + (maxv uint16 :offset 34 :size 10) + ) + :flag-assert #x900000008 + ) -#| (deftype gs-fog (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((f uint8 :offset 56 :size 8) ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 + :flag-assert #x900000008 ) -|# -#| (deftype gs-fogcol (uint64) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((fcr uint8 :offset 0 :size 8) + (fcg uint8 :offset 8 :size 8) + (fcb uint8 :offset 16 :size 8) ) - :method-count-assert 9 - :size-assert #x8 - :flag-assert #x900000008 + :flag-assert #x900000008 ) -|# -;; (deftype gif-ctrl (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-ctrl (uint32) + ((rst uint8 :offset 0 :size 1) + (pse uint8 :offset 3 :size 1) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-mode (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-mode (uint32) + ((m3r uint8 :offset 0 :size 1) + (imt uint8 :offset 2 :size 1) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-stat (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-stat (uint32) + ((m3r uint8 :offset 0 :size 1) + (m3p uint8 :offset 1 :size 1) + (imt uint8 :offset 2 :size 1) + (pse uint8 :offset 3 :size 1) + (ip3 uint8 :offset 5 :size 1) + (p3q uint8 :offset 6 :size 1) + (p2q uint8 :offset 7 :size 1) + (p1q uint8 :offset 8 :size 1) + (oph uint8 :offset 9 :size 1) + (apath uint8 :offset 10 :size 2) + (dir uint8 :offset 12 :size 1) + (fqc uint8 :offset 24 :size 5) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-cnt (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-cnt (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (regcnt uint8 :offset 16 :size 4) + (vuaddr uint16 :offset 20 :size 10) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-p3cnt (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-p3cnt (uint32) + ((p3cnt uint16 :offset 0 :size 15) + ) + :flag-assert #x900000004 + ) -;; (deftype gif-p3tag (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(deftype gif-p3tag (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + :flag-assert #x900000004 + ) -#| (deftype gif-bank (structure) - ((ctrl gif-ctrl :offset-assert 0) ;; guessed by decompiler - (mode gif-mode :offset-assert 16) ;; guessed by decompiler - (stat gif-stat :offset-assert 32) ;; guessed by decompiler - (tag0 uint32 :offset-assert 64) - (tag1 uint32 :offset-assert 80) - (tag2 uint32 :offset-assert 96) - (tag3 uint32 :offset-assert 112) - (cnt gif-cnt :offset-assert 128) ;; guessed by decompiler - (p3cnt gif-p3cnt :offset-assert 144) ;; guessed by decompiler - (p3tag gif-p3tag :offset-assert 160) ;; guessed by decompiler + ((ctrl gif-ctrl :offset 0) + (mode gif-mode :offset 16) + (stat gif-stat :offset 32) + (tag0 uint32 :offset 64) + (tag1 uint32 :offset 80) + (tag2 uint32 :offset 96) + (tag3 uint32 :offset 112) + (cnt gif-cnt :offset 128) + (p3cnt gif-p3cnt :offset 144) + (p3tag gif-p3tag :offset 160) ) :method-count-assert 9 :size-assert #xa4 :flag-assert #x9000000a4 ) -|# - -;; (deftype gif-tag-prim (uint32) -;; () -;; :flag-assert #x900000004 -;; ) - -;; (deftype gif-tag-count (uint32) -;; () -;; :flag-assert #x900000004 -;; ) -;; (deftype gif-tag64 (uint64) -;; () -;; :flag-assert #x900000008 -;; ) +;; +++gs:gif-flag +(defenum gif-flag + :type uint8 + (packed 0) + (reg-list 1) + (image 2) + (disable 3) + ) +;; ---gs:gif-flag -#| -(deftype gif-tag (uint128) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. +(deftype gif-tag-prim (uint32) + ((id uint16 :offset 0 :size 14) + (pre uint8 :offset 14 :size 1) + (prim gs-prim :offset 15 :size 11) + (flg gif-flag :offset 26 :size 2) + (nreg uint8 :offset 28 :size 4) + ) + :flag-assert #x900000004 + ) + +(deftype gif-tag-count (uint32) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + :flag-assert #x900000004 + ) + +;; +++gs:gif-reg-id +(defenum gif-reg-id + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (a+d 14) + (nop 15) + ) +;; ---gs:gif-reg-id + +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + ) + :flag-assert #x900000008 + ) + +(deftype gif-tag (uint128) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim uint16 :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + (regs0 gif-reg-id :offset 64 :size 4) + (regs1 gif-reg-id :offset 68 :size 4) + (regs2 gif-reg-id :offset 72 :size 4) + (regs3 gif-reg-id :offset 76 :size 4) + (regs4 gif-reg-id :offset 80 :size 4) + (regs5 gif-reg-id :offset 84 :size 4) + (regs6 gif-reg-id :offset 88 :size 4) + (regs7 gif-reg-id :offset 92 :size 4) + (regs8 gif-reg-id :offset 96 :size 4) + (regs9 gif-reg-id :offset 100 :size 4) + (regs10 gif-reg-id :offset 104 :size 4) + (regs11 gif-reg-id :offset 108 :size 4) + (regs12 gif-reg-id :offset 112 :size 4) + (regs13 gif-reg-id :offset 116 :size 4) + (regs14 gif-reg-id :offset 120 :size 4) + (regs15 gif-reg-id :offset 124 :size 4) + ) + :flag-assert #x900000010 + ) + +(deftype gif-tag-regs (uint64) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) + ) + ) + +(deftype gif-tag-regs-32 (uint32) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) ) - :method-count-assert 9 - :size-assert #x10 - :flag-assert #x900000010 ) -|# -#| (deftype gs-gif-tag (structure) - ((qword qword :inline :offset-assert 0) ;; uint128 - (dword uint64 2 :offset-assert 0) ;; guessed by decompiler - (word uint32 4 :offset-assert 0) ;; guessed by decompiler - (tag uint64 :offset-assert 0) ;; gif-tag64 - (regs uint64 :offset-assert 8) ;; gif-tag-regs + ((qword uint128 :offset-assert 0 :score -1) ;; is "qword" and inline? in game + + (tag gif-tag64 :offset 0) + (regs gif-tag-regs :offset 8) + + (dword uint64 2 :offset 0) + (word uint32 4 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gif-packet (basic) + "Unused type for building a dynamically sized gif packet." ((reg-count int32 :offset-assert 4) - (gif-tag0 uint128 :offset-assert 16) - (args uint64 1 :offset-assert 32) ;; guessed by decompiler + + (gif-tag gs-gif-tag :inline :offset-assert 16) ;; added + (gif-tag0 uint128 :offset 16) + (args uint64 1 :offset-assert 32) ) + (:methods + (new (symbol type int) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 ) -|# -#| (deftype draw-context (basic) - ((orgx int32 :offset-assert 4) - (orgy int32 :offset-assert 8) - (orgz int32 :offset-assert 12) - (width int32 :offset-assert 16) - (height int32 :offset-assert 20) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + ((orgx int32 :offset-assert 4) + (orgy int32 :offset-assert 8) + (orgz int32 :offset-assert 12) + (width int32 :offset-assert 16) + (height int32 :offset-assert 20) + (color rgba 4 :offset-assert 24) ) + (:methods + (new (symbol type int int int int rgba) _type_) ;; 0 + ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 + ;; Failed to read some fields. ) -|# -#| (deftype gs-packed-rgba (vector4w) - ((r int32 :offset-assert 0) - (g int32 :offset-assert 4) - (b int32 :offset-assert 8) - (a int32 :offset-assert 12) + ((r int32 :offset 0) + (g int32 :offset 4) + (b int32 :offset 8) + (a int32 :offset 12) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-xyzw (vector) - ((ix int32 :offset-assert 0) - (iy int32 :offset-assert 4) - (iz int32 :offset-assert 8) - (iw int32 :offset-assert 12) + ((ix int32 :offset 0 :score 10) + (iy int32 :offset 4 :score 10) + (iz int32 :offset 8 :score 10) + (iw int32 :offset 12 :score 10) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-stq (vector) - ((tex-s float :offset-assert 0) - (tex-t float :offset-assert 4) - (tex-q float :offset-assert 8) + ((tex-s float :offset 0) + (tex-t float :offset 4) + (tex-q float :offset 8) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-uv (vector) - ((u int16 :offset-assert 0) - (v int16 :offset-assert 4) + ((u int16 :offset 0) + (v int16 :offset 4) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype gs-packed-gt (structure) - ((stq gs-packed-stq :inline :offset-assert 0) - (rgba gs-packed-rgba :inline :offset-assert 16) - (xyzw gs-packed-xyzw :inline :offset-assert 32) + ((stq gs-packed-stq :inline :offset 0) + (rgba gs-packed-rgba :inline :offset 16) + (xyzw gs-packed-xyzw :inline :offset 32) ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype gs-packed-gt4 (structure) - ((data gs-packed-gt 4 :offset-assert 0) ;; guessed by decompiler + ((data gs-packed-gt 4 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #xc0 :flag-assert #x9000000c0 ) -|# -;; (define-extern psm-size function) ;; (function gs-psm int) -;; (define-extern psm-page-height function) ;; (function gs-psm int) -;; (define-extern psm->string function) ;; (function gs-psm string) -;; (define-extern *fog-color* object) ;; rgba -;; (define-extern open-gif-packet function) ;; (function gif-packet gif-packet) -;; (define-extern add-reg-gif-packet function) ;; (function gif-packet int int none) -;; (define-extern close-gif-packet function) ;; (function gif-packet int gif-packet) -;; (define-extern draw-context-set-xy function) ;; (function draw-context int int none) +(define-extern psm-size "Convert texture format to some type of size." (function gs-psm int)) +(define-extern psm-page-height "Convert texture format to some type of page height." (function gs-psm int)) +(define-extern psm->string "Get the name of a texture format." (function gs-psm string)) +(define-extern *fog-color* rgba) +(define-extern open-gif-packet "Initialize an existing gif-packet for 0 registers." (function gif-packet gif-packet)) +(define-extern add-reg-gif-packet "Add a register + value to the packet." (function gif-packet int int none)) +(define-extern close-gif-packet "Finish adding registers." (function gif-packet int gif-packet)) +(define-extern draw-context-set-xy "Set the origin of the draw context." (function draw-context int int none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; display-h ;; @@ -4963,18 +5996,39 @@ ;; loader-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (deftype load-dir (basic) -;; () -;; :flag-assert #xb00000010 -;; ) +(declare-type art basic) +(declare-type art-group art) +(define-extern art-group type) -;; (deftype load-dir-art-group (load-dir) -;; () -;; :flag-assert #xb00000010 -;; ) +(deftype load-dir (basic) + "`load-dir` is an array of references to loaded things. + It's used to handle art groups that are loaded as part of a level load." + ((lev level :offset-assert 4) + (string-array (array string) :offset-assert 8) ;; these are the names + (data-array (array basic) :score -50 :offset-assert 12) ;; this is the file data. + ) + :method-count-assert 11 + :size-assert #x10 + :flag-assert #xb00000010 + (:methods + (new (symbol type int level) _type_) ;; 0 + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) ;; 9 + (set-loaded-art (_type_ art-group) art-group) ;; 10 + ) + ) + +(deftype load-dir-art-group (load-dir) + "Specialization of load-dir for `art-group`s." + ((art-group-array (array art-group) :offset 12) + ) + :flag-assert #xb00000010 + (:methods + (new (symbol type int level) _type_) ;; 0 + ) + ) -#| (deftype external-art-buffer (basic) + "An `external-art-buffer` is a buffer that streamed files use." ((index int32 :offset-assert 4) (other external-art-buffer :offset-assert 8) ;; guessed by decompiler (status symbol :offset-assert 12) ;; guessed by decompiler @@ -4985,54 +6039,54 @@ (heap kheap :inline :offset-assert 32) (pending-load-file string :offset-assert 48) ;; guessed by decompiler (pending-load-file-part int32 :offset-assert 52) - (pending-load-file-owner uint64 :offset-assert 56) ;; handle + (pending-load-file-owner handle :offset-assert 56) ;; handle (pending-load-file-priority float :offset-assert 64) (load-file string :offset-assert 68) ;; guessed by decompiler (load-file-part int32 :offset-assert 72) - (load-file-owner uint64 :offset-assert 80) ;; handle + (load-file-owner handle :offset-assert 80) ;; handle (load-file-priority float :offset-assert 88) (buf pointer :offset-assert 92) ;; guessed by decompiler (len int32 :offset-assert 96) (art-group art-group :offset-assert 100) ;; guessed by decompiler - (art-data uint32 :offset-assert 100) + (art-data uint32 :offset 100) ) :method-count-assert 16 :size-assert #x68 :flag-assert #x1000000068 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type int function symbol) _type_) - (external-art-buffer-method-9 () none) ;; 9 ;; (set-pending-file (_type_ string int handle float) int) - (external-art-buffer-method-10 () none) ;; 10 ;; (update (_type_) int) - (external-art-buffer-method-11 () none) ;; 11 ;; (inactive? (_type_) symbol) - (external-art-buffer-method-12 () none) ;; 12 ;; (file-status (_type_ string int) symbol) - (external-art-buffer-method-13 () none) ;; 13 ;; (link-file (_type_ art-group) art-group) - (external-art-buffer-method-14 () none) ;; 14 ;; (unlink-file (_type_ art-group) int) - (external-art-buffer-method-15 () none) ;; 15 ;; (unlock! (_type_) int) + (new (symbol type int function symbol) _type_) ;; 0 + (set-pending-file (_type_ string int handle float) int) ;; 9 + (update (_type_) int) ;; 10 + (inactive? (_type_) symbol) ;; 11 + (file-status (_type_ string int) symbol) ;; 12 + (link-file (_type_ art-group) art-group) ;; 13 + (unlink-file (_type_ art-group) int) ;; 14 + (unlock! (_type_) int) ;; 15 ) ) -|# -#| (deftype spool-anim (basic) - ((name string :offset-assert 16) ;; guessed by decompiler - (anim-name basic :offset-assert 20) + "A `spool-anim` is metadata for an animation that will be loaded in chunks + to a pair of external-art-buffers." + ((name string :offset 16) ;; guessed by decompiler + (anim-name string :offset-assert 20) + (buffer external-art-buffer :offset 20 :score -1) ;; added (parts int32 :offset-assert 24) - (hint-id int32 :offset-assert 24) + (hint-id int32 :offset 24) (priority float :offset-assert 28) - (owner uint64 :offset-assert 32) ;; handle + (owner handle :offset-assert 32) ;; handle (command-list pair :offset-assert 40) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x2c :flag-assert #x90000002c ) -|# -#| (deftype external-art-control (basic) + "The `external-art-control` manages loading chunks from `spool-anim`s to `external-art-buffer`." ((buffer external-art-buffer 2 :offset-assert 4) ;; guessed by decompiler - (rec spool-anim 3 :offset-assert 20) ;; guessed by decompiler - (spool-lock uint64 :offset-assert 160) ;; handle + (rec spool-anim 3 :inline :offset-assert 16) ;; guessed by decompiler + (spool-lock handle :offset-assert 160) ;; handle (reserve-buffer external-art-buffer :offset-assert 168) ;; guessed by decompiler (reserve-buffer-count int16 :offset-assert 172) (dma-reserve-buffer-count int16 :offset-assert 174) @@ -5045,80 +6099,77 @@ :size-assert #xd0 :flag-assert #x10000000d0 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) - (external-art-control-method-9 () none) ;; 9 ;; (update (_type_ symbol) int) - (external-art-control-method-10 () none) ;; 10 ;; (clear-rec (_type_) int) - (external-art-control-method-11 () none) ;; 11 ;; (spool-push (_type_ string int process float) int) - (external-art-control-method-12 () none) ;; 12 ;; (file-status (_type_ string int) symbol) - (external-art-control-method-13 () none) ;; 13 ;; (reserve-alloc (_type_) kheap) - (external-art-control-method-14 () none) ;; 14 ;; (reserve-free (_type_ kheap) int) - (external-art-control-method-15 () none) ;; 15 ;; (none-reserved? (_type_) symbol) + (new (symbol type) _type_) ;; 0 + (update (_type_ symbol) int) ;; 9 + (clear-rec (_type_) int) ;; 10 + (spool-push (_type_ string int process float) int) ;; 11 + (file-status (_type_ string int) symbol) ;; 12 + (reserve-alloc (_type_) kheap) ;; 13 + (reserve-free (_type_ kheap) int) ;; 14 + (none-reserved? (_type_) symbol) ;; 15 ) ) -|# -#| (deftype subtitle-range (basic) ((start-frame float :offset-assert 4) (end-frame float :offset-assert 8) (message basic 12 :offset-assert 12) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. ) :method-count-assert 9 :size-assert #x3c :flag-assert #x90000003c ) -|# -#| (deftype subtitle-image (basic) ((width uint16 :offset-assert 4) (height uint16 :offset-assert 6) - (palette rgba 16 :offset-assert 16) ;; guessed by decompiler + (palette rgba 16 :offset 16) ;; guessed by decompiler (data uint8 :dynamic :offset-assert 80) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; texture-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type texture-page basic) + (deftype texture-id (uint32) - ((UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + "Unique identifier for a texture + as the tpage number and index of the texture within the tpage." + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype texture-pool-segment (structure) + "A chunk of VRAM." ((dest uint32 :offset-assert 0) (size uint32 :offset-assert 4) ) + :allow-misaligned + :pack-me :method-count-assert 9 :size-assert #x8 :flag-assert #x900000008 ) -|# -#| (deftype texture-pool (basic) + "The manager for the VRAM." ((top int32 :offset-assert 4) (cur int32 :offset-assert 8) (allocate-func (function texture-pool texture-page kheap int texture-page) :offset-assert 12) ;; guessed by decompiler (font-palette int32 :offset-assert 16) - (segment texture-pool-segment 4 :offset-assert 20) ;; guessed by decompiler - (segment-near texture-pool-segment :inline :offset-assert 20) - (segment-common texture-pool-segment :inline :offset-assert 28) + (segment texture-pool-segment 4 :inline :offset-assert 20) ;; guessed by decompiler + (segment-near texture-pool-segment :inline :offset 20) + (segment-common texture-pool-segment :inline :offset 28) (common-page texture-page 32 :offset-assert 52) ;; guessed by decompiler (common-page-mask int32 :offset-assert 180) (update-sprites-flag symbol :offset-assert 184) ;; guessed by decompiler @@ -5131,63 +6182,62 @@ :size-assert #x2d0 :flag-assert #x1a000002d0 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type) _type_) - (texture-pool-method-9 () none) ;; 9 ;; (initialize! (_type_) _type_) - (texture-pool-method-10 () none) ;; 10 ;; (print-usage (_type_) _type_) - (texture-pool-method-11 () none) ;; 11 ;; (setup-font-texture (_type_) none) - (texture-pool-method-12 () none) ;; 12 ;; (allocate-defaults (_type_) none) - (texture-pool-method-13 () none) ;; 13 ;; (login-level-textures (_type_ level int (pointer texture-id)) none) - (texture-pool-method-14 () none) ;; 14 ;; (add-level-tpage-dma (_type_ level tpage-category bucket-id) none) - (texture-pool-method-15 () none) ;; 15 ;; (allocate-vram-words! (_type_ int) int) - (texture-pool-method-16 () none) ;; 16 ;; (allocate-segment (_type_ texture-pool-segment int) texture-pool-segment) - (texture-pool-method-17 () none) ;; 17 ;; (unload-page (_type_ texture-page) none) - (texture-pool-method-18 () none) ;; 18 ;; (get-common-page-slot-by-id (_type_ int) int) - (texture-pool-method-19 () none) ;; 19 ;; (update-warp-and-hud (_type_) none) - (texture-pool-method-20 () none) ;; 20 ;; (update-sprites (_type_) none) - (texture-pool-method-21 () none) ;; 21 ;; (mark-hud-warp-sprite-dirty (_type_) none) - (texture-pool-method-22 () none) ;; 22 ;; (lay-out-sprite-tex (_type_) none) - (texture-pool-method-23 () none) ;; 23 ;; (lay-out-hud-tex (_type_) none) - (texture-pool-method-24 () none) ;; 24 ;; (lay-out-warp-tex (_type_) none) - (texture-pool-method-25 () none) ;; 25 ;; (clear-ids (_type_) none) + (new (symbol type) _type_) ;; 0 + (initialize! (_type_) _type_) ;; 9 + (print-usage (_type_) _type_) ;; 10 + (setup-font-texture (_type_) none) ;; 11 + (allocate-defaults (_type_) none) ;; 12 + (login-level-textures (_type_ level int (pointer texture-id)) none) ;; 13 + (add-level-tpage-dma (_type_ level tpage-category bucket-id) none) ;; 14 + (allocate-vram-words! (_type_ int) int) ;; 15 + (allocate-segment (_type_ texture-pool-segment int) texture-pool-segment) ;; 16 + (unload-page (_type_ texture-page) none) ;; 17 + (get-common-page-slot-by-id (_type_ int) int) ;; 18 + (update-warp-and-hud (_type_) none) ;; 19 + (update-sprites (_type_) none) ;; 20 + (mark-hud-warp-sprite-dirty (_type_) none) ;; 21 + (lay-out-sprite-tex (_type_) none) ;; 22 + (lay-out-hud-tex (_type_) none) ;; 23 + (lay-out-warp-tex (_type_) none) ;; 24 + (clear-ids (_type_) none) ;; 25 ) ) -|# -#| (deftype texture-mask (structure) + "Mask where each bit indicates if some part of a tpage is used, by a texture. + Additionally, the w component holds a minimum distance. The texture is only needed + if the distance to the object is smaller than this." ((mask vector4w :inline :offset-assert 0) - (dist float :offset-assert 12) - (long uint64 2 :offset-assert 0) ;; guessed by decompiler - (quad uint128 :offset-assert 0) + (dist float :offset 12 :score 1) + (long uint64 2 :offset 0) ;; guessed by decompiler + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype texture-masks (structure) - ((data texture-mask 3 :offset-assert 0) ;; guessed by decompiler + "Grouping of three masks, corresponding to the 3 segments of the texture. + So mask 0 is needed if segment 0 of the texture is needed, etc..." + ((data texture-mask 3 :inline :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x30 :flag-assert #x900000030 ) -|# -#| (deftype texture-masks-array (inline-array-class) + "Group of all texture-masks for a given tpage." ((data texture-masks :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype texture (basic) + "Metadata for a texture." ((w int16 :offset-assert 4) (h int16 :offset-assert 6) (num-mips uint8 :offset-assert 8) @@ -5208,29 +6258,44 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype texture-page-segment (structure) + "Metadata for a 'segment' of a texture page. + Each texture page has 3 segments - smaller number segments have higher detail mips." ((block-data pointer :offset-assert 0) ;; guessed by decompiler (size uint32 :offset-assert 4) (dest uint32 :offset-assert 8) ) + :allow-misaligned + :pack-me :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -#| +;; +++texture-h:tex-upload-mode +(defenum tex-upload-mode + (none -3) + (seg0-1 -2) + (seg0-1-2 -1) + (seg0 0) + (seg2 2) + ) +;; ---texture-h:tex-upload-mode + (deftype texture-page (basic) + "A collection of textures. There is a tpage per category per level. + These tpages are loaded from the DVD. + e.g.: prison tfrag is its own tpage. + The tpage has multiple textures, and 3 segments. + Lower number segments are larger and have hi-res versions of textures." ((info file-info :offset-assert 4) ;; guessed by decompiler (name string :offset-assert 8) ;; guessed by decompiler (id uint32 :offset-assert 12) (length int32 :offset-assert 16) (mip0-size uint32 :offset-assert 20) (size uint32 :offset-assert 24) - (segment texture-page-segment 3 :offset-assert 28) ;; guessed by decompiler + (segment texture-page-segment 3 :inline :offset-assert 28) ;; guessed by decompiler (dram-size uint32 :offset-assert 64) (vram-size uint32 :offset-assert 68) (pad uint32 14 :offset-assert 72) ;; guessed by decompiler @@ -5240,50 +6305,70 @@ :size-assert #x80 :flag-assert #xe00000080 (:methods - (texture-page-method-9 () none) ;; 9 ;; (remove-data-from-heap (_type_ kheap) _type_) - (texture-page-method-10 () none) ;; 10 ;; (get-leftover-block-count (_type_ int int) int) - (texture-page-method-11 () none) ;; 11 ;; (relocate-dests! (_type_ int int) none) - (texture-page-method-12 () none) ;; 12 ;; (add-to-dma-buffer (_type_ dma-buffer tex-upload-mode) int) - (texture-page-method-13 () none) ;; 13 ;; (upload-now! (_type_ tex-upload-mode) none) + (relocate (_type_ kheap (pointer uint8)) texture-page :replace) ;; 7 + (remove-data-from-heap (_type_ kheap) _type_) ;; 9 + (get-leftover-block-count (_type_ int int) int) ;; 10 + (relocate-dests! (_type_ int int) none) ;; 11 + (add-to-dma-buffer (_type_ dma-buffer tex-upload-mode) int) ;; 12 + (upload-now! (_type_ tex-upload-mode) none) ;; 13 ) ) -|# -;; (deftype shader-ptr (uint32) -;; () -;; :flag-assert #x900000004 -;; ) +(declare-type adgif-shader structure) +(deftype shader-ptr (uint32) + "A pointer to an adgif-shader, stored in bits 8-32. This allows them to fit into + an adgif shader easily." + ((first-8 uint8 :offset 0 :size 8) ;; added + (shader uint32 :offset 8 :size 24) + ) + :method-count-assert 9 + :size-assert #x4 + :flag-assert #x900000004 + ) -#| (deftype texture-link (structure) - ((next shader-ptr :offset-assert 0) ;; guessed by decompiler + "An overlay structure containing a shader-ptr that points to the next adgif-shader + in a linked list." + ((next shader-ptr 1 :offset-assert 0) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x4 :flag-assert #x900000004 ) -|# -#| (deftype texture-page-dir-entry (structure) + "An entry for a texture in the texture-page-dir. + The texture-page-dir contains an entry for each tpage. + Each entry contains a reference to the tpage, and a linked list of shaders + using it." ((length int16 :offset-assert 0) (status uint16 :offset-assert 2) (page texture-page :offset-assert 4) ;; guessed by decompiler (link texture-link :offset-assert 8) ;; guessed by decompiler ) + :pack-me + :allow-misaligned :method-count-assert 9 :size-assert #xc :flag-assert #x90000000c ) -|# -;; (deftype texture-page-dir (basic) -;; () -;; :flag-assert #xa00000014 -;; ) +(deftype texture-page-dir (basic) + "The list of all texture pages. + This is static data loaded from the DVD at boot." + ((length int32) + (entries texture-page-dir-entry 1 :inline) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) ;; 7 + (unlink-shaders-in-heap (_type_ kheap) int) ;; 9 + ) + :flag-assert #xa00000014 + ) -#| (deftype texture-relocate-later (basic) + "Unused in Jak 2, but metadata for postponing tpage copies until a second frame, + to have a smaller impact on frame times when loading." ((memcpy symbol :offset-assert 4) ;; guessed by decompiler (dest uint32 :offset-assert 8) (source uint32 :offset-assert 12) @@ -5295,45 +6380,55 @@ :size-assert #x1c :flag-assert #x90000001c ) -|# -#| +;; +++texture-h:link-test-flags +(defenum link-test-flags + :type uint32 + :bitfield #t + (needs-log-in 8) + (bit-9 9) + (backup-sprite-tex 10) ;; set when particle-setup-adgif fails texture lookup. + ) +;; ---texture-h:link-test-flags + (deftype adgif-shader (structure) - ((quad qword 5 :offset-assert 0) ;; guessed by decompiler - (prims gs-reg64 10 :offset-assert 0) ;; guessed by decompiler - (reg-0 uint8 :offset-assert 8) - (reg-1 uint8 :offset-assert 24) - (reg-2 uint8 :offset-assert 40) - (reg-3 uint8 :offset-assert 56) - (reg-4 uint8 :offset-assert 72) - (tex0 uint64 :offset-assert 0) ;; gs-tex0 - (tex1 uint64 :offset-assert 16) ;; gs-tex1 - (miptbp1 uint64 :offset-assert 32) ;; gs-miptbp - (clamp uint64 :offset-assert 48) ;; gs-clamp - (clamp-reg uint64 :offset-assert 56) ;; gs-reg64 - (alpha uint64 :offset-assert 64) ;; gs-alpha - (link-test link-test-flags :offset-assert 8) ;; guessed by decompiler - (texture-id texture-id :offset-assert 24) ;; guessed by decompiler - (next shader-ptr :offset-assert 40) ;; guessed by decompiler + "GS texturing/blending settings, called adgif-shader. + These are used by many different renderers and partially managed by the texture system. + For example, the texture system will automatically update tbp to point to the location + of the texture." + ((quad qword 5 :inline :offset-assert 0 :score -100) ;; guessed by decompiler + (prims gs-reg64 10 :offset 0 :score -100) ;; guessed by decompiler + (reg-0 uint8 :offset 8) + (reg-1 uint8 :offset 24) + (reg-2 uint8 :offset 40) + (reg-3 uint8 :offset 56) + (reg-4 uint8 :offset 72) + (tex0 uint64 :offset 0) ;; gs-tex0 + (tex1 uint64 :offset 16) ;; gs-tex1 + (miptbp1 uint64 :offset 32) ;; gs-miptbp + (clamp uint64 :offset 48) ;; gs-clamp + (clamp-reg uint64 :offset 56) ;; gs-reg64 + (alpha uint64 :offset 64) ;; gs-alpha + (link-test link-test-flags :offset 8) ;; guessed by decompiler + (texture-id texture-id :offset 24) ;; guessed by decompiler + (next shader-ptr :offset 40) ;; guessed by decompiler ) :method-count-assert 9 :size-assert #x50 :flag-assert #x900000050 ) -|# -#| (deftype adgif-shader-array (inline-array-class) - ((data adgif-shader :dynamic :offset-assert 16) ;; guessed by decompiler + ((data adgif-shader :inline :dynamic :offset-assert 16) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x10 :flag-assert #xe00000010 ) -|# -#| (deftype texture-base (structure) + "Metadata about an area of VRAM set aside for fancy dynamic texture effects + (sky, eye, etc)." ((vram-page uint32 :offset-assert 0) (vram-block uint32 :offset-assert 4) (vram-word uint32 :offset-assert 8) @@ -5342,11 +6437,9 @@ :size-assert #xc :flag-assert #x90000000c ) -|# -#| (deftype texture-page-translate-item (structure) - ((bucket int32 :offset-assert 0) ;; bucket-id + ((bucket bucket-id :offset-assert 0) ;; bucket-id (level-index uint32 :offset-assert 4) (level-texture-page tpage-category-u32 :offset-assert 8) ;; guessed by decompiler (texture-user texture-enable-mask-u32 :offset-assert 12) ;; guessed by decompiler @@ -5355,28 +6448,31 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *texture-masks* object) ;; texture-masks -;; (define-extern *texture-masks-array* object) ;; texture-masks-array -;; (define-extern texture-mip->segment function) ;; (function int int int) -;; (define-extern *texture-relocate-later* object) ;; texture-relocate-later -;; (define-extern *texture-page-dir* object) ;; texture-page-dir -;; (define-extern ct32-24-block-table array) ;; (array int32) -;; (define-extern mz32-24-block-table array) ;; (array int32) -;; (define-extern ct16-block-table array) ;; (array int32) -;; (define-extern ct16s-block-table array) ;; (array int32) -;; (define-extern mz16-block-table array) ;; (array int32) -;; (define-extern mz16s-block-table array) ;; (array int32) -;; (define-extern mt8-block-table array) ;; (array int32) -;; (define-extern mt4-block-table array) ;; (array int32) -;; (define-extern *texture-page-translate* array) ;; (array texture-page-translate-item) -;; (define-extern *eyes-texture-base* object) ;; texture-base -;; (define-extern *skull-gem-texture-base* object) ;; texture-base -;; (define-extern *ocean-texture-base* object) ;; texture-base -;; (define-extern *ocean-envmap-texture-base* object) ;; texture-base -;; (define-extern *grey-scale-base* object) ;; texture-base -;; (define-extern *map-texture-base* object) ;; texture-base +(define-extern *texture-masks* texture-masks) +(define-extern *texture-masks-array* texture-masks-array) +(define-extern texture-mip->segment + "Figure out which segment of a tpage a given mip level of a texture will be in. + arg0 is the mip level, arg1 is the total number of mips. + Higher mip level is lower detail." + (function int int int)) +(define-extern *texture-relocate-later* texture-relocate-later) +(define-extern *texture-page-dir* texture-page-dir) +(define-extern ct32-24-block-table (array int32)) +(define-extern mz32-24-block-table (array int32)) +(define-extern ct16-block-table (array int32)) +(define-extern ct16s-block-table (array int32)) +(define-extern mz16-block-table (array int32)) +(define-extern mz16s-block-table (array int32)) +(define-extern mt8-block-table (array int32)) +(define-extern mt4-block-table (array int32)) +(define-extern *texture-page-translate* (array texture-page-translate-item)) +(define-extern *eyes-texture-base* texture-base) +(define-extern *skull-gem-texture-base* texture-base) +(define-extern *ocean-texture-base* texture-base) +(define-extern *ocean-envmap-texture-base* texture-base) +(define-extern *grey-scale-base* texture-base) +(define-extern *map-texture-base* texture-base) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; texture-anim-h ;; @@ -5824,20 +6920,18 @@ ) |# -#| (deftype mood-range (structure) ((data float 4 :offset-assert 0) ;; guessed by decompiler - (min-cloud float :offset-assert 0) - (max-cloud float :offset-assert 4) - (min-fog float :offset-assert 8) - (max-fog float :offset-assert 12) - (quad uint128 :offset-assert 0) + (min-cloud float :offset 0) + (max-cloud float :offset 4) + (min-fog float :offset 8) + (max-fog float :offset 12) + (quad uint128 :offset 0) ) :method-count-assert 9 :size-assert #x10 :flag-assert #x900000010 ) -|# #| (deftype mood-filters-table (structure) @@ -6072,7 +7166,47 @@ ;; level-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(declare-type bsp-header basic) + +;; +++level-h:vis-info-flag +(defenum vis-info-flag + :type uint32 + :bitfield #t + (dummy0 0) + (dummy1 1) + (dummy2 2) + (dummy3 3) + (dummy4 4) + (dummy5 5) + (dummy6 6) + (dummy7 7) + (dummy8 8) + (dummy9 9) + (dummy10 10) + (dummy11 11) + (dummy12 12) + (dummy13 13) + (dummy14 14) + (dummy15 15) + (dummy16 16) + (dummy17 17) + (dummy18 18) + (dummy19 19) + (dummy20 20) + (dummy21 21) + (dummy22 22) + (dummy23 23) + (dummy24 24) + (dummy25 25) + (dummy26 26) + (dummy27 27) + (dummy28 28) + (in-iop 29) + (loading 30) + (vis-valid 31) + ) +;; ---level-h:vis-info-flag + (deftype level-vis-info (basic) ((level level :offset-assert 4) ;; guessed by decompiler (from-level symbol :offset-assert 8) ;; guessed by decompiler @@ -6092,31 +7226,89 @@ :size-assert #x34 :flag-assert #x900000034 ) -|# -#| (deftype level-borrow-info (basic) ((alias basic :offset-assert 4) - (borrow-size UNKNOWN 5 :offset-assert 8) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (borrow-info UNKNOWN 5 :offset-assert 20) - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. + (borrow-size uint16 5 :offset-assert 8) + (borrow-info object 5 :offset-assert 20) ) :method-count-assert 9 :size-assert #x28 :flag-assert #x900000028 ) -|# -(declare-type level-load-info basic) -#| +;; +++level-h:load-buffer-mode +(defenum load-buffer-mode + :type uint32 + (small-edge 0) + (small-center 1) + (medium 2) + (large 3) + (borrow 4) + (ten 10) + ) +;; ---level-h:load-buffer-mode + +;; +++level-h:task-mask +(defenum task-mask + :type uint32 + :bitfield #t + (task0 0) + (task1 1) + (task2 2) + (task3 3) + (task4 4) + (task5 5) + (task6 6) + (task7 7) + (done 8) + (dummy0 9) + (dummy1 10) + (vehicle 11) + (special 12) + (primary0 13) + (ctywide 14) + (never 15) + (movie0 16) + (movie1 17) + (movie2 18) + ) +;; ---level-h:task-mask + +;; +++level-h:bigmap-id +(defenum bigmap-id + :type uint32 + (bigmap-id-0 0) + (bigmap-id-1 1) + (bigmap-id-2 2) + (bigmap-id-3 3) + (bigmap-id-4 4) + (bigmap-id-5 5) + (bigmap-id-6 6) + (bigmap-id-7 7) + (bigmap-id-8 8) + (bigmap-id-9 9) + (bigmap-id-10 10) + (bigmap-id-11 11) + (bigmap-id-12 12) + (bigmap-id-13 13) + (bigmap-id-14 14) + (bigmap-id-15 15) + (bigmap-id-16 16) + (bigmap-id-17 17) + (bigmap-id-18 18) + (bigmap-id-19 19) + (bigmap-id-20 20) + ) +;; ---level-h:bigmap-id + (deftype level-load-info (basic) ((name-list symbol 6 :offset-assert 4) ;; guessed by decompiler - (name symbol :offset-assert 4) ;; guessed by decompiler - (visname symbol :offset-assert 8) ;; guessed by decompiler - (nickname symbol :offset-assert 12) ;; guessed by decompiler - (dbname symbol :offset-assert 16) ;; guessed by decompiler - (taskname symbol :offset-assert 20) ;; guessed by decompiler + (name symbol :offset 4) ;; guessed by decompiler + (visname symbol :offset 8) ;; guessed by decompiler + (nickname symbol :offset 12) ;; guessed by decompiler + (dbname symbol :offset 16) ;; guessed by decompiler + (taskname symbol :offset 20) ;; guessed by decompiler (index int16 :offset-assert 28) (task-level uint8 :offset-assert 30) (part-engine-max uint8 :offset-assert 31) ;; int32 @@ -6155,13 +7347,12 @@ :flag-assert #xb000000a0 ;; field extra-sound-bank uses ~A with a signed load. (:methods - (level-load-info-method-9 () none) ;; 9 - (level-load-info-method-10 () none) ;; 10 + (level-load-info-method-9 (_type_) none) ;; 9 + (level-load-info-method-10 (_type_) none) ;; 10 ) ) -|# -#| +(declare-type drawable basic) (deftype login-state (basic) ((state int32 :offset-assert 4) (pos uint32 :offset-assert 8) @@ -6172,7 +7363,6 @@ :size-assert #x50 :flag-assert #x900000050 ) -|# (declare-type level basic) #| @@ -6362,7 +7552,6 @@ ;; capture-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype gs-store-image-packet (structure) ((vifcode vif-tag 4 :offset-assert 0) ;; guessed by decompiler (giftag uint128 :offset-assert 16) ;; gif-tag @@ -6381,9 +7570,7 @@ :size-assert #x70 :flag-assert #x900000070 ) -|# -#| (deftype screen-shot-work (structure) ((count int16 :offset-assert 0) (size int16 :offset-assert 2) @@ -6395,17 +7582,16 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -;; (define-extern *screen-shot-work* object) ;; screen-shot-work -;; (define-extern *image-name* object) ;; string +(define-extern *screen-shot-work* screen-shot-work) +(define-extern *image-name* string) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; math-camera-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype vis-gif-tag (structure) + "Unused." ((fog0 uint32 :offset-assert 0) (strip uint32 :offset-assert 4) (regs uint32 :offset-assert 8) @@ -6415,10 +7601,9 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| (deftype cull-info (structure) + "Also seems unused." ((x-fact float :offset-assert 0) (y-fact float :offset-assert 4) (z-fact float :offset-assert 8) @@ -6436,17 +7621,16 @@ (yz-dir-bz float :offset-assert 56) (yz-cross-ab float :offset-assert 60) ) + :allow-misaligned :method-count-assert 9 :size-assert #x40 :flag-assert #x900000040 ) -|# -#| (deftype math-camera (basic) ((d meters :offset-assert 4) (f meters :offset-assert 8) - (fov deg :offset-assert 12) ;; degrees + (fov degrees :offset-assert 12) ;; degrees (x-ratio float :offset-assert 16) (y-ratio float :offset-assert 20) (x-pix float :offset-assert 24) @@ -6482,15 +7666,15 @@ (hvdf-off vector :inline :offset-assert 816) (guard vector :inline :offset-assert 832) (vis-gifs vis-gif-tag 4 :offset-assert 848) ;; guessed by decompiler - (giftex uint128 :offset-assert 848) - (gifgr uint128 :offset-assert 864) - (giftex-trans uint128 :offset-assert 880) - (gifgr-trans uint128 :offset-assert 896) + (giftex uint128 :offset 848) + (gifgr uint128 :offset 864) + (giftex-trans uint128 :offset 880) + (gifgr-trans uint128 :offset 896) (pfog0 float :offset-assert 912) (pfog1 float :offset-assert 916) (trans vector :inline :offset-assert 928) - (plane plane 4 :offset-assert 944) ;; guessed by decompiler - (guard-plane plane 4 :offset-assert 1008) ;; guessed by decompiler + (plane plane 4 :inline :offset-assert 944) ;; guessed by decompiler + (guard-plane plane 4 :inline :offset-assert 1008) ;; guessed by decompiler (shrub-mat matrix :inline :offset-assert 1072) (quat-other quaternion :inline :offset-assert 1136) (trans-other vector :inline :offset-assert 1152) @@ -6500,8 +7684,8 @@ (camera-rot-other-sky matrix :inline :offset-assert 1360) (camera-rot-other-sprite matrix :inline :offset-assert 1424) (inv-camera-rot-other matrix :inline :offset-assert 1488) - (plane-other plane 4 :offset-assert 1552) ;; guessed by decompiler - (guard-plane-other plane 4 :offset-assert 1616) ;; guessed by decompiler + (plane-other plane 4 :inline :offset-assert 1552) ;; guessed by decompiler + (guard-plane-other plane 4 :inline :offset-assert 1616) ;; guessed by decompiler (mirror-trans vector :inline :offset-assert 1680) (mirror-normal vector :inline :offset-assert 1696) (fov-correction-factor float :offset-assert 1712) @@ -6509,16 +7693,25 @@ :method-count-assert 9 :size-assert #x6b4 :flag-assert #x9000006b4 + (:methods + (new (symbol type) _type_) ;; 0 + ) ) -|# ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; math-camera ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype fog-corrector (structure) + "The math-camera matrices are used to compute fogging values, which are a per-vertex uint8 that + tells the GS how 'foggy' the color should be. This should be proportional to how far away the vertex + is. There is a scaling factor applied so the fog intensity isn't affected by the field of view angle. + + The fog-corrector stores a fog-end fog-start value that is corrected for the field of view. + The actual correction factor is computed in cam-update.gc. + Without this corrector, the fogginess of the world would change as the FOV changes + (for example, when Jak gets on the zoomer, the FOV changes slightly)." ((fog-end float :offset-assert 0) (fog-start float :offset-assert 4) ) @@ -6526,19 +7719,40 @@ :size-assert #x8 :flag-assert #x900000008 ) -|# -;; (define-extern fog-corrector-setup function) ;; (function fog-corrector math-camera none) -;; (define-extern *math-camera-fog-correction* object) ;; fog-corrector -;; (define-extern update-math-camera function) ;; (function math-camera symbol symbol float math-camera) -;; (define-extern *math-camera* object) ;; math-camera -;; (define-extern math-cam-start-smoothing function) ;; (function float float quaternion) -;; (define-extern move-target-from-pad function) ;; (function transform int transform) -;; (define-extern transform-point-vector! function) ;; (function vector vector symbol) -;; (define-extern transform-point-qword! function) ;; (function vector4w vector symbol) -;; (define-extern transform-point-vector-scale! function) ;; (function vector vector float) -;; (define-extern reverse-transform-point! function) ;; (function vector vector vector vector none) -;; (define-extern init-for-transform function) ;; (function matrix none) +(define-extern fog-corrector-setup "Set the fog corrector based on the supplied math-camera." (function fog-corrector math-camera none)) +(define-extern *math-camera-fog-correction* fog-corrector) +(define-extern update-math-camera + "Compute some one-time camera constants. + These should only change when changing aspect ratio." + (function math-camera symbol symbol float math-camera)) +(define-extern *math-camera* math-camera) +(define-extern math-cam-start-smoothing "Unused camera smoothing." (function float float quaternion)) +(define-extern move-target-from-pad + "Unused function to adjust trans based on inputs from the pad. + This function must be extremely old because it takes a non-quaternion transform, + and all [[target]] stuff uses quaternions." + (function transform int transform)) +(define-extern transform-point-vector! + "Apply camera transformation to a point. Return true if it is visible or not. + This returns the point in GS coords, but as float instead of int, so it's + not really useful. See [[transform-point-qword!]] for more details." + (function vector vector symbol)) +(define-extern transform-point-qword! + "Apply camera transformation to point, returning fixed point 28.4 position + that can be given to the GS directly." + (function vector4w vector symbol)) +(define-extern transform-point-vector-scale! + "Similar to transform-point-qword! but returns the scale factor instead." + (function vector vector float)) +(define-extern reverse-transform-point! + "Likely transform arg3 from screen space to world coords, using arg1/arg2 for... something." + (function vector vector vector vector none)) +(define-extern init-for-transform + "Sets up VU0 registers with camera info. + This is probably a very old function and it's only used by camera debug. + It stashes some data in vector float registers that must be there before calling transform-float-point." + (function matrix none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; font-h ;; @@ -6865,8 +8079,19 @@ ;; connect ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| (deftype connectable (structure) + "A connectable is the linked-list node part of a connection. + The connections themselves are owned by the engine. + + The `next0`/`prev0` references are used for how this belongs in the connectable list + belonging to the [[engine]]. These terminate on special nodes stored in the engine: + `alive-list`/`alive-list-end` for the active connections, and `dead-list`/`dead-list-end` + for the inactive. + + The `next1`/`prev1` references are used to build a linked list _per process_. + The head of this list is the inline connectable in process and it ends with `#f`. + This is a bit confusing at first, but these belong to two linked lists... + These terminate on both ends with `#f`." ((next0 connectable :offset-assert 0) (prev0 connectable :offset-assert 4) (next1 connectable :offset-assert 8) @@ -6876,119 +8101,158 @@ :size-assert #x10 :flag-assert #x900000010 ) -|# -#| +(declare-type engine basic) + (deftype connection (connectable) + "This is the actual data for the connection. + It may be used in multiple ways, but the most common is to use `param0` as a function. + It receives `param1`, `param2`, `param3`, and the engine as the arguments. + In some cases, the return value is checked for `'dead`." ((param0 basic :offset-assert 16) (param1 basic :offset-assert 20) (param2 int32 :offset-assert 24) ;; guessed by decompiler (param3 int32 :offset-assert 28) ;; guessed by decompiler - (quad uint128 2 :offset-assert 0) ;; guessed by decompiler + (quad uint128 2 :offset 0) ;; guessed by decompiler ) :method-count-assert 14 :size-assert #x20 :flag-assert #xe00000020 ;; field param1 uses ~A with a signed load. field param2 uses ~A with a signed load. field param3 uses ~A with a signed load. (:methods - (connection-method-9 () none) ;; 9 ;; (get-engine (connection) engine) - (connection-method-10 () none) ;; 10 ;; (get-process (connection) process) - (connection-method-11 () none) ;; 11 ;; (belongs-to-engine? (connection engine) symbol) - (connection-method-12 () none) ;; 12 ;; (belongs-to-process? (connection process) symbol) - (connection-method-13 () none) ;; 13 ;; (move-to-dead (connection) connection) + (get-engine + "Get the engine for this connection. This must be used on a live connection." + (connection) engine) ;; 9 + (get-process "Get the process for this connection." (connection) process) ;; 10 + (belongs-to-engine? + "Check to see if this connection is located in the data section of the engine. + This works on dead or alive connections." + (connection engine) symbol) ;; 11 + (belongs-to-process? "Does this connection belong to the given process?" (connection process) symbol) ;; 12 + (move-to-dead "Move this connection from the alive list to the dead list." (connection) connection) ;; 13 ) ) -|# -#| (deftype engine (basic) + "An engine is a collection of connections. + You can iterate over the connections, or run them. + The engine is dynamically sized based on how many connections it can store. + + New for Jak 2: You can use a child class of [[connection]]." ((name symbol :offset-assert 4) ;; guessed by decompiler - (engine-time uint64 :offset-assert 16) ;; time-frame - (allocated-length int16 :offset-assert 10) - (length int16 :offset-assert 8) - (element-type type :offset-assert 12) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (data connection :dynamic :offset-assert 96) ;; guessed by decompiler + (engine-time time-frame :offset 16) ;; time-frame + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) ;; guessed by decompiler + (alive-list connectable :inline :offset-assert 32) + (alive-list-end connectable :inline :offset-assert 48) + (dead-list connectable :inline :offset-assert 64) + (dead-list-end connectable :inline :offset-assert 80) + (data connection :inline :dynamic :offset-assert 96) ;; guessed by decompiler ) :method-count-assert 26 :size-assert #x60 :flag-assert #x1a00000060 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type symbol int type) _type_) - (engine-method-9 () none) ;; 9 ;; (inspect-all-connections (engine) engine) - (engine-method-10 () none) ;; 10 ;; (apply-to-connections (engine (function connectable none)) int) - (engine-method-11 () none) ;; 11 ;; (apply-to-connections-reverse (engine (function connectable none)) int) - (engine-method-12 () none) ;; 12 ;; (execute-connections (engine object) int) - (engine-method-13 () none) ;; 13 ;; (execute-connections-and-move-to-dead (engine object) int) - (engine-method-14 () none) ;; 14 ;; (execute-connections-if-needed (engine object) int) - (engine-method-15 () none) ;; 15 ;; (add-connection (engine process object object object object) connection) - (engine-method-16 () none) ;; 16 ;; (remove-from-process (engine process) int) - (engine-method-17 () none) ;; 17 ;; (remove-matching (engine (function connection engine symbol)) int) - (engine-method-18 () none) ;; 18 ;; (remove-all (engine) int) - (engine-method-19 () none) ;; 19 ;; (remove-by-param0 (engine object) int) - (engine-method-20 () none) ;; 20 ;; (remove-by-param1 (engine int) int) - (engine-method-21 () none) ;; 21 ;; (remove-by-param2 (engine int) int) - (engine-method-22 () none) ;; 22 ;; (get-first-connectable (engine) connectable) - (engine-method-23 () none) ;; 23 ;; (get-last-connectable (engine) connectable) - (engine-method-24 () none) ;; 24 ;; (get-next-connectable (_type_ connectable) connectable) - (engine-method-25 () none) ;; 25 ;; (get-prev-connectable (_type_ connectable) connectable) + (new (symbol type symbol int type) _type_) ;; 0 + (inspect-all-connections "inspect all of the connections." (engine) engine) ;; 9 + (apply-to-connections + "Apply arg0 to all connections for the engine. + It's okay to have arg0 remove the connection." + (engine (function connectable none)) int) ;; 10 + (apply-to-connections-reverse + "Apply arg0 to all connections, reverse order. + Do not use arg0 to remove yourself from the list." + (engine (function connectable none)) int) ;; 11 + (execute-connections "Run the engine!" (engine object) int) ;; 12 + (execute-connections-and-move-to-dead + "Run the engine! If any objects return `'dead`, remove them." + (engine object) int) ;; 13 + (execute-connections-if-needed + "Execute connections, but only if it hasn't been done on this frame." + (engine object) int) ;; 14 + (add-connection + "Add a connection between this engine and a given process." + (engine process object object object object) connection) ;; 15 + (remove-from-process "Remove all connections from process for this engine." (engine process) int) ;; 16 + (remove-matching + "Call the given function on each connection and the engine. + If it returns truthy, `move-to-dead` that connection." + (engine (function connection engine symbol)) int) ;; 17 + (remove-all "Remove all connections from an engine." (engine) int) ;; 18 + (remove-by-param0 "Remove all connections with param0 matching arg0." (engine object) int) ;; 19 + (remove-by-param1 "Remove all connections with param1 matching arg0." (engine int) int) ;; 20 + (remove-by-param2 "Remove all connections with param2 matching arg0." (engine int) int) ;; 21 + (get-first-connectable (engine) connectable) ;; 22 + (get-last-connectable (engine) connectable) ;; 23 + (get-next-connectable (_type_ connectable) connectable) ;; 24 + (get-prev-connectable (_type_ connectable) connectable) ;; 25 ) ) -|# -#| (deftype connection-pers (structure) + "This is another engine system, very similar to the first, but not specific to a process. + Each connection has a `key`, which is like the process, but unlike normal engine, + the key's don't track which engine-pers they belong to. + + Unlike [[engine]], users can use [[engine-pers]] as a parent class." ((next connection-pers :offset-assert 0) - (key object :offset-assert 4) ;; guessed by decompiler - (update-time uint64 :offset-assert 8) ;; time-frame - (param object 4 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-int32 int32 4 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-int64 int64 2 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-float float 4 :offset-assert 16) ;; guessed by decompiler - (UNKNOWN UNKNOWN :offset-assert -1) ;; field could not be read. - (param-quat uint128 :offset-assert 16) + (key object :offset-assert 4) + (update-time time-frame :offset-assert 8) + (param object 4 :offset-assert 16) + (param-int32 int32 4 :offset 16) + (param-int64 int64 2 :offset 16) + (param-float float 4 :offset 16) + (param-quat uint128 :offset 16) ) :method-count-assert 9 :size-assert #x20 :flag-assert #x900000020 ;; field key uses ~A with a signed load. ) -|# -#| (deftype engine-pers (basic) - ((name symbol :offset-assert 4) ;; guessed by decompiler - (length int16 :offset-assert 8) - (allocated-length int16 :offset-assert 10) - (element-type type :offset-assert 12) ;; guessed by decompiler - (execute-time uint64 :offset-assert 16) ;; time-frame - (alive-list connection-pers :offset-assert 24) - (dead-list connection-pers :offset-assert 28) - (data connection-pers :dynamic :offset-assert 32) ;; guessed by decompiler + ((name symbol :offset-assert 4) ;; guessed by decompiler + (length int16 :offset-assert 8) + (allocated-length int16 :offset-assert 10) + (element-type type :offset-assert 12) ;; guessed by decompiler + (execute-time time-frame :offset-assert 16) ;; time-frame + (alive-list connection-pers :offset-assert 24) + (dead-list connection-pers :offset-assert 28) + (data connection-pers :inline :dynamic :offset-assert 32) ;; guessed by decompiler ) :method-count-assert 15 :size-assert #x20 :flag-assert #xf00000020 (:methods - (new (symbol type) _type_) ;; 0 ;; (new (symbol type symbol int type) _type_) - (engine-pers-method-9 () none) ;; 9 ;; (schedule-callback (_type_ object time-frame) connection-pers) - (engine-pers-method-10 () none) ;; 10 ;; (kill-callback (_type_ connection-pers) none) - (engine-pers-method-11 () none) ;; 11 ;; (kill-by-key (_type_ object) none) - (engine-pers-method-12 () none) ;; 12 ;; (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none) - (engine-pers-method-13 () none) ;; 13 ;; (update-callback (_type_) none) - (engine-pers-method-14 () none) ;; 14 ;; (run-pending-updates! (_type_ time-frame) none) - ) - ) -|# - -;; (define-extern connection-process-apply function) ;; (function process (function object none) symbol) -(define-extern process-disconnect (function process int)) + (new (symbol type symbol int type) _type_) ;; 0 + (schedule-callback + "Get a connection for this key. + If no connection exists, add it. + Schedule an update to happen in arg1 seconds." + (_type_ object time-frame) connection-pers) ;; 9 + (kill-callback "Called when a connection is removed." (_type_ connection-pers) none) ;; 10 + (kill-by-key "Remove connections with this key, calling `kill-callback`." (_type_ object) none) ;; 11 + (kill-matching + "Call the given function on each connection. If it returns truthy, kill that connection." + (_type_ (function engine-pers connection-pers object object symbol) object object) none) ;; 12 + (update-callback + "Called when a connection is run. + Users can override this as needed." + (_type_) none) ;; 13 + (run-pending-updates! + "Run updates if they scheduled. If something is found that has no pending update, kill it. + Note that we won't kill things on this call if they fail to update their `update-time`. + They will survive until the next call to `run-pending-updates`! + (or you can modify their `update-time` before that to prevent them from being killed.)" + (_type_ time-frame) none) ;; 14 + ) + ) + +(define-extern connection-process-apply + "Apply a function to all connectables of a process." + (function process (function object none) symbol)) +(define-extern process-disconnect "Disconnect all connections for the given process." (function process int)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; text-h ;; @@ -8454,19 +9718,29 @@ ;; settings-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -#| +(defenum game-feature + :type uint64 + :bitfield #t + ) + +(defenum game-secrets + :type uint64 + :bitfield #t + ) + (deftype user-setting-data (structure) ((border-mode symbol :offset-assert 0) ;; guessed by decompiler (process-mask process-mask :offset-assert 4) ;; guessed by decompiler - (language uint8 :offset-assert 12) ;; language-enum - (movie (pointer process) :offset-assert 32) ;; guessed by decompiler + (unknown-int32 int32 :offset-assert 8) + (language language-enum :offset-assert 12) ;; language-enum + (movie (pointer process) :offset 32) ;; guessed by decompiler (talking (pointer process) :offset-assert 36) ;; guessed by decompiler (spooling (pointer process) :offset-assert 40) ;; guessed by decompiler (hint (pointer process) :offset-assert 44) ;; guessed by decompiler (ambient (pointer process) :offset-assert 48) ;; guessed by decompiler (video-mode symbol :offset-assert 52) ;; guessed by decompiler (aspect-ratio symbol :offset-assert 56) ;; guessed by decompiler - (auto-save symbol :offset-assert 64) ;; guessed by decompiler + (auto-save symbol :offset 64) ;; guessed by decompiler (bg-r float :offset-assert 68) (bg-g float :offset-assert 72) (bg-b float :offset-assert 76) @@ -8477,10 +9751,10 @@ (blur-a-speed float :offset-assert 96) (allow-progress symbol :offset-assert 100) ;; guessed by decompiler (allow-pause symbol :offset-assert 104) ;; guessed by decompiler - (movie-name symbol :offset-assert 120) ;; guessed by decompiler + (movie-name symbol :offset 120) ;; guessed by decompiler (weather symbol :offset-assert 124) ;; guessed by decompiler - (task-mask task-mask :offset-assert 140) - (duck symbol :offset-assert 148) ;; guessed by decompiler + (task-mask task-mask :offset 140) + (duck symbol :offset 148) ;; guessed by decompiler (attack symbol :offset-assert 152) ;; guessed by decompiler (gun symbol :offset-assert 156) ;; guessed by decompiler (board symbol :offset-assert 160) ;; guessed by decompiler @@ -8511,10 +9785,10 @@ (task-manager (pointer process) :offset-assert 272) ;; guessed by decompiler (task symbol :offset-assert 276) ;; guessed by decompiler (airlock symbol :offset-assert 280) ;; guessed by decompiler - (minimap uint16 :offset-assert 284) ;; guessed by decompiler + (minimap uint32 :offset-assert 284) ;; guessed by decompiler (sound-tune uint32 :offset-assert 288) (allow-continue symbol :offset-assert 292) ;; guessed by decompiler - (subtitle symbol :offset-assert 304) ;; guessed by decompiler + (subtitle symbol :offset 304) ;; guessed by decompiler (doorway symbol :offset-assert 308) ;; guessed by decompiler (gem symbol :offset-assert 312) ;; guessed by decompiler (half-speed symbol :offset-assert 316) ;; guessed by decompiler @@ -8544,7 +9818,7 @@ (allow-error symbol :offset-assert 412) ;; guessed by decompiler (under-water-pitch-mod float :offset-assert 416) (slow-time float :offset-assert 420) - (restart-info basic :offset-assert 428) + (restart-info basic :offset 428) (fail-info basic :offset-assert 432) (death-info basic :offset-assert 436) (quit-info basic :offset-assert 440) @@ -8558,22 +9832,22 @@ (scarf float :offset-assert 496) (goggles float :offset-assert 500) (board-trail basic :offset-assert 504) - (letterbox float :offset-assert 572) + (letterbox float :offset 572) (letterbox-speed float :offset-assert 576) - (borrow-city-count uint32 :offset-assert 620) - (borrow-city UNKNOWN 3 :offset-assert 624) - (audio-language uint8 :offset-assert 748) - (special-volume float :offset-assert 796) + (borrow-city-count uint32 :offset 620) + (borrow-city pair 3 :offset-assert 624) + (audio-language language-enum :offset 748) + (special-volume float :offset 796) + (pad uint8 108 :offset 800) ;; added ) :method-count-assert 11 :size-assert #x38c :flag-assert #xb0000038c (:methods - (user-setting-data-method-9 () none) ;; 9 ;; (user-setting-data-method-9 (_type_ engine engine-pers engine) user-setting-data) - (user-setting-data-method-10 () none) ;; 10 ;; (user-setting-data-method-10 (_type_ object symbol float uint) user-setting-data) + (user-setting-data-method-9 (_type_ engine engine-pers engine) user-setting-data) ;; 9 + (user-setting-data-method-10 (_type_ object symbol float uint) user-setting-data) ;; 10 ) ) -|# #| (deftype cam-setting-data (structure) @@ -11408,32 +12682,6 @@ :flag-assert #x900000010 ) -;; +++task-control-h:task-mask -(defenum task-mask - :type uint32 - :bitfield #t - (task0 0) - (task1 1) - (task2 2) - (task3 3) - (task4 4) - (task5 5) - (task6 6) - (task7 7) - (done 8) - (dummy0 9) - (dummy1 10) - (vehicle 11) - (special 12) - (primary0 13) - (ctywide 14) - (never 15) - (movie0 16) - (movie1 17) - (movie2 18) - ) -;; ---task-control-h:task-mask - (deftype game-task-node-info (basic) ((level symbol :offset-assert 4) ;; guessed by decompiler (task game-task :offset-assert 8) @@ -24752,7 +26000,7 @@ |# ;; (define-extern *sprite-distorter-sine-tables* object) ;; sprite-distorter-sine-tables -;; (define-extern sprite-distorter-generate-tables function) ;; (function none) +(define-extern sprite-distorter-generate-tables (function none)) ;; (define-extern sprite-distort-vu1-block object) ;; vu-function ;; (define-extern sprite-init-distorter function) ;; (function dma-buffer none) ;; (define-extern sprite-draw-distorters function) ;; (function dma-buffer none) @@ -26392,7 +27640,7 @@ ;; (define-extern drawable-load function) ;; (function drawable kheap drawable) ;; (define-extern art-load function) ;; (function string kheap art) ;; (define-extern art-group-load-check function) ;; (function string kheap int art-group) -;; (define-extern external-art-buffer-init function) ;; (function external-art-buffer int) +(define-extern external-art-buffer-init (function external-art-buffer int)) ;; (define-extern *preload-spool-anims* object) ;; symbol ;; (define-extern ja-play-spooled-anim function) ;; (function spool-anim art-joint-anim art-joint-anim (function process-drawable symbol) int :behavior process-drawable) ;; (define-extern ja-abort-spooled-anim function) ;; (function spool-anim art-joint-anim int int :behavior process-drawable) diff --git a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc index 0f5c8c113e3..d1283ad0b70 100644 --- a/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc +++ b/decompiler/config/jak3/ntsc_v1/stack_structures.jsonc @@ -9,5 +9,6 @@ [32, "vector"], [48, "vector"] ], - "rotate-vector-to-vector": [[16, "quaternion"]] + "rotate-vector-to-vector": [[16, "quaternion"]], + "init-for-transform": [[192, "vector"]] } diff --git a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc index 1fa31b2aee5..1a5706bf3cd 100644 --- a/decompiler/config/jak3/ntsc_v1/type_casts.jsonc +++ b/decompiler/config/jak3/ntsc_v1/type_casts.jsonc @@ -122,5 +122,33 @@ [15, "gp", "(inline-array vector4)"] ], "(method 9 clock)": [[47, "v1", "float"]], - "service-cpads": [[[207, 311], "s3", "pad-buttons"]] + "service-cpads": [[[207, 311], "s3", "pad-buttons"]], + "(method 3 connection-pers)": [[97, "f0", "float"]], + "(method 0 engine-pers)": [ + [32, "v1", "pointer"], + [23, "v1", "pointer"], + [26, "v1", "pointer"], + [24, "v1", "(pointer pointer)"] + ], + "(method 0 engine)": [ + [44, "v1", "pointer"], + [47, "v1", "pointer"], + [53, "v1", "connectable"], + [65, "v1", "connectable"] + ], + "(method 21 engine)": [[8, "a0", "connection"]], + "(method 20 engine)": [[8, "a0", "connection"]], + "(method 19 engine)": [[8, "a0", "connection"]], + "(method 15 engine)": [[[0, 36], "v1", "connection"]], + "(method 13 engine)": [ + [[0, 25], "s4", "connection"], + [13, "t9", "(function object object object object object)"] + ], + "(method 12 engine)": [ + [[0, 25], "s4", "connection"], + [13, "t9", "(function object object object object object)"] + ], + "(method 9 connection)": [[8, "a0", "pointer"]], + "(method 10 connection)": [[8, "a0", "pointer"]], + "(method 11 connection)": [[5, "a1", "pointer"]] } diff --git a/goal_src/jak3/engine/engine/connect.gc b/goal_src/jak3/engine/engine/connect.gc index 2bd031caea9..788ee297a1d 100644 --- a/goal_src/jak3/engine/engine/connect.gc +++ b/goal_src/jak3/engine/engine/connect.gc @@ -5,5 +5,717 @@ ;; name in dgo: connect ;; dgos: GAME +#|@file +This extremely confusing "connection system" allows the connection between +"engines" and "processes". Basically, a process can "register" itself with any number of "engines". +The "engines" can then iterate through all the connected processes. If a process is destroyed, it will +be removed from all engines. It is okay to connect a process to multiple engines, or even to the same engine +multiple times. + +Some example uses: +- a "foreground-engine" has connections to all foreground objects that need to be drawn on each frame. +- when a process wants to change a game setting, it opens a connection to the settings engine to request a change. + when the process is killed (or it stops requesting the change), the setting change is reverted. + +A "connection" is really just a function that gets called when the engine runs, or a set of parameters that the engine can iterate through. +|# + +(declare-type engine basic) + ;; DECOMP BEGINS +(deftype connectable (structure) + "A connectable is the linked-list node part of a connection. + The connections themselves are owned by the engine. + + The `next0`/`prev0` references are used for how this belongs in the connectable list + belonging to the [[engine]]. These terminate on special nodes stored in the engine: + `alive-list`/`alive-list-end` for the active connections, and `dead-list`/`dead-list-end` + for the inactive. + + The `next1`/`prev1` references are used to build a linked list _per process_. + The head of this list is the inline connectable in process and it ends with `#f`. + This is a bit confusing at first, but these belong to two linked lists... + These terminate on both ends with `#f`." + ((next0 connectable) + (prev0 connectable) + (next1 connectable) + (prev1 connectable) + ) + ) + + +(deftype connection (connectable) + "This is the actual data for the connection. +It may be used in multiple ways, but the most common is to use `param0` as a function. +It receives `param1`, `param2`, `param3`, and the engine as the arguments. +In some cases, the return value is checked for `'dead`." + ((param0 basic) + (param1 basic) + (param2 int32) + (param3 int32) + (quad uint128 2 :overlay-at next0) + ) + (:methods + (get-engine (connection) engine) + (get-process (connection) process) + (belongs-to-engine? (connection engine) symbol) + (belongs-to-process? (connection process) symbol) + (move-to-dead (connection) connection) + ) + ) + + +(deftype engine (basic) + "An engine is a collection of connections. +You can iterate over the connections, or run them. +The engine is dynamically sized based on how many connections it can store. + +New for Jak 2: You can use a child class of [[connection]]." + ((name symbol) + (engine-time time-frame :offset 16) + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) + (alive-list connectable :inline) + (alive-list-end connectable :inline) + (dead-list connectable :inline) + (dead-list-end connectable :inline) + (data connection :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (inspect-all-connections (engine) engine) + (apply-to-connections (engine (function connectable none)) int) + (apply-to-connections-reverse (engine (function connectable none)) int) + (execute-connections (engine object) int) + (execute-connections-and-move-to-dead (engine object) int) + (execute-connections-if-needed (engine object) int) + (add-connection (engine process object object object object) connection) + (remove-from-process (engine process) int) + (remove-matching (engine (function connection engine symbol)) int) + (remove-all (engine) int) + (remove-by-param0 (engine object) int) + (remove-by-param1 (engine int) int) + (remove-by-param2 (engine int) int) + (get-first-connectable (engine) connectable) + (get-last-connectable (engine) connectable) + (get-next-connectable (_type_ connectable) connectable) + (get-prev-connectable (_type_ connectable) connectable) + ) + ) + +(defmethod belongs-to-process? ((this connection) (arg0 process)) + "Does this connection belong to the given process?" + (= arg0 (get-process this)) + ) + +(defmethod print ((this connection)) + (format + #t + "#" + (-> this param0) + (-> this param1) + (-> this param2) + (-> this param3) + this + ) + this + ) + +;; WARN: Return type mismatch pointer vs engine. +(defmethod get-engine ((this connection)) + "Get the engine for this connection. This must be used on a live connection." + (while (-> (the-as connectable this) prev0) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev0))) + ) + (the-as engine (&+ (the-as pointer this) -28)) + ) + +;; WARN: Return type mismatch pointer vs process. +(defmethod get-process ((this connection)) + "Get the process for this connection." + (while (-> (the-as connectable this) prev1) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev1))) + ) + (the-as process (&+ (the-as pointer this) -108)) + ) + +(defmethod belongs-to-engine? ((this connection) (arg0 engine)) + "Check to see if this connection is located in the data section of the engine. + This works on dead or alive connections." + (and (< (the-as int arg0) (the-as int this)) + (< (the-as int this) (the-as int (&+ + (&+ (the-as pointer arg0) (-> arg0 type size)) + (* (-> arg0 allocated-length) (the-as int (-> arg0 element-type size))) + ) + ) + ) + ) + ) + +(defmethod get-first-connectable ((this engine)) + (-> this alive-list next0) + ) + +(defmethod get-last-connectable ((this engine)) + (-> this alive-list-end) + ) + +(defmethod get-next-connectable ((this engine) (arg0 connectable)) + (-> arg0 next0) + ) + +(defmethod get-prev-connectable ((this engine) (arg0 connectable)) + (-> arg0 prev0) + ) + +(defmethod new engine ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 + (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list next0) (-> v0-0 alive-list-end)) + (set! (-> v0-0 alive-list prev0) #f) + (set! (-> v0-0 alive-list next1) #f) + (set! (-> v0-0 alive-list prev1) #f) + (set! (-> v0-0 alive-list-end next0) #f) + (set! (-> v0-0 alive-list-end prev0) (-> v0-0 alive-list)) + (set! (-> v0-0 alive-list-end next1) #f) + (set! (-> v0-0 alive-list-end prev1) #f) + (set! (-> v0-0 dead-list next0) (the-as connectable (-> v0-0 data))) + (set! (-> v0-0 dead-list prev0) #f) + (set! (-> v0-0 dead-list next1) #f) + (set! (-> v0-0 dead-list prev1) #f) + (set! (-> v0-0 dead-list-end next0) #f) + (set! (-> v0-0 dead-list-end prev0) + (the-as connectable (+ (+ (* (the-as uint (+ arg1 -1)) (-> arg2 size)) 92) (the-as uint v0-0))) + ) + (set! (-> v0-0 dead-list-end next1) #f) + (set! (-> v0-0 dead-list-end prev1) #f) + (let ((v1-9 (the-as object (-> v0-0 data)))) + (set! (-> v0-0 data 0 prev0) (-> v0-0 dead-list)) + (set! (-> v0-0 data 0 next0) (the-as connectable (&+ (the-as pointer v1-9) (-> arg2 size)))) + (let ((v1-10 (the-as object (&+ (the-as pointer v1-9) (-> arg2 size))))) + (let ((a0-6 1) + (a1-3 (+ arg1 -2)) + ) + (while (>= a1-3 a0-6) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + ;; og:preserve-this cast changed to (pointer pointer) + (set! (-> (the-as (pointer pointer) v1-10)) (&+ (the-as pointer v1-10) (-> arg2 size))) + (set! v1-10 (&+ (the-as pointer v1-10) (-> arg2 size))) + (+! a0-6 1) + ) + ) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + ;; og:preserve-this cast changed to (pointer collectable) + (set! (-> (the-as (pointer connectable) v1-10)) (-> v0-0 dead-list-end)) + ) + ) + v0-0 + ) + ) + +(defmethod print ((this engine)) + (format #t "#<~A ~A @ #x~X>" (-> this type) (-> this name) this) + this + ) + + +(defmethod length ((this engine)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +(defmethod apply-to-connections ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections for the engine. + It's okay to have arg0 remove the connection." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (arg0 a0-1) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(defmethod apply-to-connections-reverse ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections, reverse order. + Do not use arg0 to remove yourself from the list." + (let ((s4-0 (-> this alive-list-end prev0))) + (while (!= s4-0 (-> this alive-list)) + (arg0 s4-0) + (set! s4-0 (-> s4-0 prev0)) + ) + ) + 0 + ) + +(defmethod execute-connections ((this engine) (arg0 object)) + "Run the engine!" + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + ) + ) + 0 + ) + +(defmethod execute-connections-and-move-to-dead ((this engine) (arg0 object)) + "Run the engine! If any objects return `'dead`, remove them." + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + (let ((v1-3 ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + ) + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + (if (= v1-3 'dead) + ((method-of-type connection move-to-dead) (the-as connection (-> s4-0 next0))) + ) + ) + ) + ) + 0 + ) + +(defmethod execute-connections-if-needed ((this engine) (arg0 object)) + "Execute connections, but only if it hasn't been done on this frame." + (if (!= (-> *display* real-clock frame-counter) (-> this engine-time)) + (execute-connections this arg0) + ) + 0 + ) + +(defun connection-process-apply ((arg0 process) (arg1 (function object none))) + "Apply a function to all connectables of a process." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (arg1 s5-0) + (set! s5-0 (-> s5-0 next1)) + ) + ) + #f + ) + ) + +(defmethod inspect-all-connections ((this engine)) + "inspect all of the connections." + (let ((gp-0 *kernel-symbol-warnings*)) + (set! *kernel-symbol-warnings* #f) + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (format + #t + "from process ~A:~%~`connection`I" + ((method-of-type connection get-process) (the-as connection s4-0)) + s4-0 + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + (set! *kernel-symbol-warnings* gp-0) + ) + this + ) + + +(defmethod add-connection ((this engine) (arg0 process) (arg1 object) (arg2 object) (arg3 object) (arg4 object)) + "Add a connection between this engine and a given process." + (let ((v1-0 (the-as connection (-> this dead-list next0)))) + (when (not (or (not arg0) (= v1-0 (-> this dead-list-end)))) + (set! (-> v1-0 param0) (the-as basic arg1)) + (set! (-> v1-0 param1) (the-as basic arg2)) + (set! (-> v1-0 param2) (the-as int arg3)) + (set! (-> v1-0 param3) (the-as int arg4)) + (set! (-> this dead-list next0) (-> v1-0 next0)) + (set! (-> v1-0 next0 prev0) (-> this dead-list)) + (set! (-> v1-0 next0) (-> this alive-list next0)) + (set! (-> v1-0 next0 prev0) v1-0) + (set! (-> v1-0 prev0) (-> this alive-list)) + (set! (-> this alive-list next0) v1-0) + (set! (-> v1-0 next1) (-> arg0 connection-list next1)) + (if (-> v1-0 next1) + (set! (-> v1-0 next1 prev1) v1-0) + ) + (set! (-> v1-0 prev1) (-> arg0 connection-list)) + (set! (-> arg0 connection-list next1) v1-0) + (+! (-> this length) 1) + v1-0 + ) + ) + ) + +(defmethod move-to-dead ((this connection)) + "Move this connection from the alive list to the dead list." + (let ((v1-1 (get-engine this))) + (set! (-> this prev0 next0) (-> this next0)) + (set! (-> this next0 prev0) (-> this prev0)) + (set! (-> this prev1 next1) (-> this next1)) + (if (-> this next1) + (set! (-> this next1 prev1) (-> this prev1)) + ) + (set! (-> this next0) (-> v1-1 dead-list next0)) + (set! (-> this next0 prev0) this) + (set! (-> this prev0) (-> v1-1 dead-list)) + (set! (-> v1-1 dead-list next0) this) + (+! (-> v1-1 length) -1) + ) + this + ) + +(defun process-disconnect ((arg0 process)) + "Disconnect all connections for the given process." + (when arg0 + (let ((gp-0 (-> arg0 connection-list next1))) + (while gp-0 + ((method-of-type connection move-to-dead) (the-as connection gp-0)) + (set! gp-0 (-> gp-0 next1)) + ) + ) + ) + 0 + ) + +(defmethod remove-from-process ((this engine) (arg0 process)) + "Remove all connections from process for this engine." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (if ((method-of-type connection belongs-to-engine?) (the-as connection s5-0) this) + ((method-of-type connection move-to-dead) (the-as connection s5-0)) + ) + (set! s5-0 (-> s5-0 next1)) + ) + ) + ) + 0 + ) + +(defmethod remove-matching ((this engine) (arg0 (function connection engine symbol))) + "Call the given function on each connection and the engine. + If it returns truthy, `move-to-dead` that connection." + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (if (arg0 (the-as connection s4-0) this) + ((method-of-type connection move-to-dead) (the-as connection s4-0)) + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-all ((this engine)) + "Remove all connections from an engine." + (let* ((a0-1 (-> this alive-list next0)) + (s5-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + (set! a0-1 s5-0) + (set! s5-0 (-> s5-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-by-param0 ((this engine) (arg0 object)) + "Remove all connections with param0 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param0) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-by-param1 ((this engine) (arg0 int)) + "Remove all connections with param1 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param1) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(defmethod remove-by-param2 ((this engine) (arg0 int)) + "Remove all connections with param2 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param2) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +(deftype connection-pers (structure) + "This is another engine system, very similar to the first, but not specific to a process. +Each connection has a `key`, which is like the process, but unlike normal engine, +the key's don't track which engine-pers they belong to. + +Unlike [[engine]], users can use [[engine-pers]] as a parent class." + ((next connection-pers) + (key object) + (update-time time-frame) + (param object 4) + (param-int32 int32 4 :overlay-at (-> param 0)) + (param-int64 int64 2 :overlay-at (-> param 0)) + (param-float float 4 :overlay-at (-> param 0)) + (param-quat uint128 :overlay-at (-> param 0)) + ) + ) + + +(deftype engine-pers (basic) + ((name symbol) + (length int16) + (allocated-length int16) + (element-type type) + (execute-time time-frame) + (alive-list connection-pers) + (dead-list connection-pers) + (data connection-pers :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (schedule-callback (_type_ object time-frame) connection-pers) + (kill-callback (_type_ connection-pers) none) + (kill-by-key (_type_ object) none) + (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none) + (update-callback (_type_) none) + (run-pending-updates! (_type_ time-frame) none) + ) + ) + + +(defmethod new engine-pers ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list) #f) + (set! (-> v0-0 dead-list) (the-as connection-pers (-> v0-0 data))) + (let ((v1-3 (the-as object (-> v0-0 data)))) + (dotimes (a0-1 arg1) + (set! (-> (the-as (pointer uint32) v1-3) 0) (the-as uint (&+ (the-as pointer v1-3) (-> arg2 size)))) + (set! v1-3 (&+ (the-as pointer v1-3) (-> arg2 size))) + ) + (set! (-> (the-as (pointer symbol) (&- (the-as pointer v1-3) (the-as uint (-> arg2 size))))) #f) + ) + v0-0 + ) + ) + +(defmethod length ((this engine-pers)) + (-> this length) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine-pers)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +(defmethod schedule-callback ((this engine-pers) (arg0 object) (arg1 time-frame)) + "Get a connection for this key. + If no connection exists, add it. + Schedule an update to happen in arg1 seconds." + (local-vars (v0-0 connection-pers)) + (let ((v1-0 (-> this alive-list))) + (while v1-0 + (when (= arg0 (-> v1-0 key)) + (set! v0-0 v1-0) + (goto cfg-8) + ) + (set! v1-0 (-> v1-0 next)) + ) + ) + (set! v0-0 (-> this dead-list)) + (when v0-0 + (set! (-> this dead-list) (-> v0-0 next)) + (set! (-> v0-0 next) (-> this alive-list)) + (set! (-> this alive-list) v0-0) + (+! (-> this length) 1) + (set! (-> v0-0 key) arg0) + (set! (-> v0-0 param-quat) (the-as uint128 0)) + 0 + ) + (label cfg-8) + (if v0-0 + (set! (-> v0-0 update-time) (+ (-> this execute-time) arg1)) + ) + v0-0 + ) + +(defmethod kill-callback ((this engine-pers) (arg0 connection-pers)) + "Called when a connection is removed." + 0 + (none) + ) + +(defmethod update-callback ((this engine-pers)) + "Called when a connection is run. + Users can override this as needed." + 0 + (none) + ) + +(defmethod kill-by-key ((this engine-pers) (arg0 object)) + "Remove connections with this key, calling `kill-callback`." + (let ((s4-0 (&-> this alive-list)) + (s2-0 (-> this alive-list)) + ) + (while s2-0 + (let ((s3-0 (-> s2-0 next))) + (cond + ((!= arg0 (-> s2-0 key)) + (set! s4-0 (&-> s2-0 next)) + ) + (else + (kill-callback this s2-0) + (set! (-> s4-0 0) (-> s2-0 next)) + (set! (-> s2-0 next) (-> this dead-list)) + (set! (-> this dead-list) s2-0) + (+! (-> this length) -1) + ) + ) + (set! s2-0 s3-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod kill-matching ((this engine-pers) + (arg0 (function engine-pers connection-pers object object symbol)) + (arg1 object) + (arg2 object) + ) + "Call the given function on each connection. If it returns truthy, kill that connection." + (let ((s2-0 (&-> this alive-list)) + (s0-0 (-> this alive-list)) + ) + (while s0-0 + (let ((s1-0 (-> s0-0 next))) + (cond + ((not (arg0 this s0-0 arg1 arg2)) + (set! s2-0 (&-> s0-0 next)) + ) + (else + (kill-callback this s0-0) + (set! (-> s2-0 0) (-> s0-0 next)) + (set! (-> s0-0 next) (-> this dead-list)) + (set! (-> this dead-list) s0-0) + (+! (-> this length) -1) + ) + ) + (set! s0-0 s1-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod run-pending-updates! ((this engine-pers) (arg0 time-frame)) + "Run updates if they scheduled. If something is found that has no pending update, kill it. + Note that we won't kill things on this call if they fail to update their `update-time`. + They will survive until the next call to `run-pending-updates`! + (or you can modify their `update-time` before that to prevent them from being killed.)" + (let ((s4-0 (-> this execute-time)) + (s2-0 (&-> this alive-list)) + (s1-0 (-> this alive-list)) + ) + (while s1-0 + (let ((s3-0 (-> s1-0 next))) + (cond + ((>= (-> s1-0 update-time) s4-0) + (update-callback this) + (set! s2-0 (&-> s1-0 next)) + ) + (else + (kill-callback this s1-0) + (set! (-> s2-0 0) (-> s1-0 next)) + (set! (-> s1-0 next) (-> this dead-list)) + (set! (-> this dead-list) s1-0) + (+! (-> this length) -1) + ) + ) + (set! s1-0 s3-0) + ) + ) + ) + (set! (-> this execute-time) arg0) + 0 + (none) + ) diff --git a/goal_src/jak3/engine/game/task/task-control-h.gc b/goal_src/jak3/engine/game/task/task-control-h.gc index c4cddd495e2..ce730eef260 100644 --- a/goal_src/jak3/engine/game/task/task-control-h.gc +++ b/goal_src/jak3/engine/game/task/task-control-h.gc @@ -43,34 +43,6 @@ ) ;; ---task-manager-mask - -;; +++task-mask -(defenum task-mask - :type uint32 - :bitfield #t - (task0 0) - (task1 1) - (task2 2) - (task3 3) - (task4 4) - (task5 5) - (task6 6) - (task7 7) - (done 8) - (dummy0 9) - (dummy1 10) - (vehicle 11) - (special 12) - (primary0 13) - (ctywide 14) - (never 15) - (movie0 16) - (movie1 17) - (movie2 18) - ) -;; ---task-mask - - ;; DECOMP BEGINS (defun-debug game-task->string ((task game-task)) diff --git a/goal_src/jak3/engine/gfx/hw/gs.gc b/goal_src/jak3/engine/gfx/hw/gs.gc index 36efe4eb1c1..92434ea2206 100644 --- a/goal_src/jak3/engine/gfx/hw/gs.gc +++ b/goal_src/jak3/engine/gfx/hw/gs.gc @@ -5,5 +5,978 @@ ;; name in dgo: gs ;; dgos: GAME +;; +++gs-psm +(defenum gs-psm + :bitfield #f + :type uint8 + (ct32 0) + (ct24 1) + (ct16 2) + (ct16s 10) + (mt8 19) + (mt4 20) + (mt8h 27) + (mt4hl 36) + (mt4hh 44) + (mz32 48) + (mz24 49) + (mz16 50) + (mz16s 58) + ) +;; ---gs-psm + + +;; +++gs-reg +(defenum gs-reg + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (tex1-1 20) + (tex1-2 21) + (tex2-1 22) + (tex2-2 23) + (xyoffset-1 24) + (xyoffset-2 25) + (prmodecont 26) + (prmode 27) + (texclut 28) + (scanmsk 34) + (miptbp1-1 52) + (miptbp1-2 53) + (miptbp2-1 54) + (miptbp2-2 55) + (texa 59) + (fogcol 61) + (texflush 63) + (scissor-1 64) + (scissor-2 65) + (alpha-1 66) + (alpha-2 67) + (dimx 68) + (dthe 69) + (colclamp 70) + (test-1 71) + (test-2 72) + (pabe 73) + (fba-1 74) + (fba-2 75) + (frame-1 76) + (frame-2 77) + (zbuf-1 78) + (zbuf-2 79) + (bitbltbuf 80) + (trxpos 81) + (trxreg 82) + (trxdir 83) + (hwreg 84) + (signal 96) + (finish 97) + (label 98) + (hack 127) + ) +;; ---gs-reg + + +;; +++gs-reg64 +(defenum gs-reg64 + :type uint64 + :copy-entries gs-reg + ) +;; ---gs-reg64 + + +;; +++gs-reg32 +(defenum gs-reg32 + :type uint32 + :copy-entries gs-reg + ) +;; ---gs-reg32 + + +;; +++gs-prim-type +(defenum gs-prim-type + :type uint8 + (point 0) + (line 1) + (line-strip 2) + (tri 3) + (tri-strip 4) + (tri-fan 5) + (sprite 6) + ) +;; ---gs-prim-type + + +;; +++gs-atest +(defenum gs-atest + :type uint8 + (never 0) + (always 1) + (less 2) + (less-equal 3) + (equal 4) + (greater-equal 5) + (greater 6) + (not-equal 7) + ) +;; ---gs-atest + + +;; +++gs-ztest +(defenum gs-ztest + :type uint8 + (never 0) + (always 1) + (greater-equal 2) + (greater 3) + ) +;; ---gs-ztest + + +;; +++gs-tex-wrap-mode +(defenum gs-tex-wrap-mode + :type uint8 + (repeat 0) + (clamp 1) + (region-clamp 2) + (region-repeat 3) + ) +;; ---gs-tex-wrap-mode + + +;; +++gif-flag +(defenum gif-flag + :type uint8 + (packed 0) + (reg-list 1) + (image 2) + (disable 3) + ) +;; ---gif-flag + + +;; +++gif-reg-id +(defenum gif-reg-id + :type uint8 + (prim 0) + (rgbaq 1) + (st 2) + (uv 3) + (xyzf2 4) + (xyz2 5) + (tex0-1 6) + (tex0-2 7) + (clamp-1 8) + (clamp-2 9) + (fog 10) + (xyzf3 12) + (xyz3 13) + (a+d 14) + (nop 15) + ) +;; ---gif-reg-id + +(defconstant GIF_REGS_ALL_AD + (new 'static 'gif-tag-regs + :regs0 (gif-reg-id a+d) + :regs1 (gif-reg-id a+d) + :regs2 (gif-reg-id a+d) + :regs3 (gif-reg-id a+d) + :regs4 (gif-reg-id a+d) + :regs5 (gif-reg-id a+d) + :regs6 (gif-reg-id a+d) + :regs7 (gif-reg-id a+d) + :regs8 (gif-reg-id a+d) + :regs9 (gif-reg-id a+d) + :regs10 (gif-reg-id a+d) + :regs11 (gif-reg-id a+d) + :regs12 (gif-reg-id a+d) + :regs13 (gif-reg-id a+d) + :regs14 (gif-reg-id a+d) + :regs15 (gif-reg-id a+d) + ) + ) + ;; DECOMP BEGINS +(deftype gs-pmode (uint64) + ((en1 uint8 :offset 0 :size 1) + (en2 uint8 :offset 1 :size 1) + (crtmd uint8 :offset 2 :size 3) + (mmod uint8 :offset 5 :size 1) + (amod uint8 :offset 6 :size 1) + (slbg uint8 :offset 7 :size 1) + (alp uint8 :offset 8 :size 8) + ) + ) + +(deftype gs-smode2 (uint64) + ((int uint8 :offset 0 :size 1) + (ffmd uint8 :offset 1 :size 1) + (dpms uint8 :offset 2 :size 2) + ) + ) + +(defun psm-size ((arg0 gs-psm)) + "Convert texture format to some type of size." + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 32 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 128 + ) + (else + 256 + ) + ) + ) + +(defun psm-page-height ((arg0 gs-psm)) + "Convert texture format to some type of page height." + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 128 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 64 + ) + (else + 32 + ) + ) + ) + +(defun psm->string ((arg0 gs-psm)) + "Get the name of a texture format." + (case arg0 + (((gs-psm ct24)) + "ct24" + ) + (((gs-psm mt4)) + "mt4" + ) + (((gs-psm ct32)) + "ct32" + ) + (((gs-psm mz16s)) + "mz16s" + ) + (((gs-psm ct16s)) + "ct16s" + ) + (((gs-psm mt8)) + "mt8" + ) + (((gs-psm mt8h)) + "mt8h" + ) + (((gs-psm mz16)) + "mz16" + ) + (((gs-psm mz24)) + "mz24" + ) + (((gs-psm mt4hh)) + "mt4hh" + ) + (((gs-psm ct16)) + "ct16" + ) + (((gs-psm mt4hl)) + "mt4hl" + ) + (((gs-psm mz32)) + "mz32" + ) + (else + "*unknown*" + ) + ) + ) + +(deftype gs-display-fb (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 9 :size 6) + (psm gs-psm :offset 15 :size 5) + (dbx uint16 :offset 32 :size 11) + (dby uint16 :offset 43 :size 11) + ) + ) + +(deftype gs-display (uint64) + "the GS's DISPLAY registers make settings for the display position on the screen regarding +information on Rectangular Area Read Output Circuit n for the PCRTC. +write-only" + ((dx uint16 :offset 0 :size 12) + (dy uint16 :offset 12 :size 11) + (magh uint8 :offset 23 :size 4) + (magv uint8 :offset 27 :size 2) + (dw uint16 :offset 32 :size 12) + (dh uint16 :offset 44 :size 11) + ) + ) + +(deftype gs-bgcolor (uint64) + "The GS's BGCOLOR register sets the background color of the PCRTC with RGB value. +write-only" + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + ) + ) + +(deftype gs-csr (uint64) + "The GS's CSR register sets and obtains various GS statuses. +read-write. The fields have different effects depending on whether they're being read from +or written to. + +Bits 5 and 6 (0x20 and 0x40) should be zero." + ((signal uint8 :offset 0 :size 1) + (finish uint8 :offset 1 :size 1) + (hsint uint8 :offset 2 :size 1) + (vsint uint8 :offset 3 :size 1) + (edwint uint8 :offset 4 :size 1) + (flush uint8 :offset 8 :size 1) + (reset uint8 :offset 9 :size 1) + (nfield uint8 :offset 12 :size 1) + (field uint8 :offset 13 :size 1) + (fifo uint8 :offset 14 :size 2) + (rev uint8 :offset 16 :size 8) + (id uint8 :offset 24 :size 8) + ) + ) + +(deftype gs-bank (structure) + "Memory layout of the GS's privileged registers (mapped to EE memory). +It is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)" + ((pmode gs-pmode) + (smode2 gs-smode2 :offset 32) + (dspfb1 gs-display-fb :offset 112) + (display1 gs-display :offset 128) + (dspfb2 gs-display-fb :offset 144) + (display2 gs-display :offset 160) + (extbuf uint64 :offset 176) + (extdata uint64 :offset 192) + (extwrite uint64 :offset 208) + (bgcolor gs-bgcolor :offset 224) + (csr gs-csr :offset 4096) + (imr uint64 :offset 4112) + (busdir uint64 :offset 4160) + ) + ) + + +(deftype gs-frame (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 16 :size 6) + (psm gs-psm :offset 24 :size 6) + (fbmsk uint32 :offset 32 :size 32) + ) + ) + +(deftype gs-zbuf (uint64) + "The GS's ZBUF registers make various settings regarding Z buffer." + ((zbp uint16 :offset 0 :size 9) + (psm gs-psm :offset 24 :size 4) + (zmsk uint8 :offset 32 :size 1) + ) + ) + +(deftype gs-xy-offset (uint64) + "The GS's XYOFFSET registers set the offset value for converting from the primitive coordinate +system to the window coordinate system." + ((ofx uint16 :offset 0 :size 16) + (ofy uint16 :offset 32 :size 16) + ) + ) + +(deftype gs-scissor (uint64) + "The GS's SCISSOR registers specify the scissoring area. The coordinate values for +the upper-left/lower-right points of the enabled drawing area are specified by the window +coordinate system." + ((scax0 uint16 :offset 0 :size 11) + (scax1 uint16 :offset 16 :size 11) + (scay0 uint16 :offset 32 :size 11) + (scay1 uint16 :offset 48 :size 11) + ) + ) + +(deftype gs-prmode-cont (uint64) + "The GS's PRMODECONT register sets whether to use primitive attributes (IIP, TME, FGE, ABE, +AA1, FST, CTXT, FIX) specified by the PRMODE register or the PRIM register." + ((ac uint8 :offset 0 :size 1) + ) + ) + +(deftype gs-color-clamp (uint64) + "The GS's COLCLAMP register stores settings as to whether clamping for the RGB value of the +pixel is performed." + ((clamp uint8 :offset 0 :size 1) + ) + ) + +(deftype gs-dthe (uint64) + "The GS's DTHE register stores settings for dithering (performed/not performed)." + ((dthe uint8 :offset 0 :size 1) + ) + ) + +(deftype gs-test (uint64) + "The GS's TEST register performs settings related to the pixel test." + ((ate uint8 :offset 0 :size 1) + (atst gs-atest :offset 1 :size 3) + (aref uint8 :offset 4 :size 8) + (afail uint8 :offset 12 :size 2) + (date uint8 :offset 14 :size 1) + (datm uint8 :offset 15 :size 1) + (zte uint8 :offset 16 :size 1) + (ztst gs-ztest :offset 17 :size 2) + ) + ) + +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + ) + +(deftype gs-rgbaq (uint64) + "The GS's RGBAQ register sets the RGBA value of the vertex and the Q value of the normalized +texture coordinates." + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + (a uint8 :offset 24 :size 8) + (q float :offset 32 :size 32) + ) + ) + +(deftype gs-xyz (uint64) + ((x uint16 :offset 0 :size 16) + (y uint16 :offset 16 :size 16) + (z uint32 :offset 32 :size 32) + ) + ) + +(deftype gs-uv (uint64) + "The GS's UV register specifies the texel coordinate (UV) values of the vertex." + ((u uint16 :offset 0 :size 16) + (v uint16 :offset 16 :size 16) + ) + ) + +(deftype gs-st (uint64) + "The GS's ST register sets the S and T values of the vertex texture coordinates. +The value Q is specified by the RGBAQ register." + ((s float :offset 0 :size 32) + (t float :offset 32 :size 32) + ) + ) + +(deftype gs-xyzf (uint64) + ((x uint16 :offset 0 :size 16) + (y uint16 :offset 16 :size 16) + (z uint32 :offset 32 :size 24) + (f uint8 :offset 56 :size 8) + ) + ) + +(deftype gs-adcmd (structure) + ((word uint32 4) + (quad uint128 :overlay-at (-> word 0)) + (data uint64 :overlay-at (-> word 0)) + (cmds gs-reg64 :overlay-at (-> word 2)) + (cmd uint8 :overlay-at (-> word 2)) + (x uint32 :overlay-at (-> word 0)) + (y uint32 :overlay-at (-> word 1)) + (z uint32 :overlay-at (-> word 2)) + (w uint32 :overlay-at (-> word 3)) + ) + ) + + +(deftype gs-trxpos (uint64) + "The GS's TRXPOS register specifies the position and +scanning direction of the rectangular area +in each buffer where buffer transmission is performed." + ((ssax uint16 :offset 0 :size 11) + (ssay uint16 :offset 16 :size 11) + (dsax uint16 :offset 32 :size 11) + (dsay uint16 :offset 48 :size 11) + (dir uint8 :offset 59 :size 2) + ) + ) + +(deftype gs-trxreg (uint64) + "The GS's TRXREG register specifies the size of the rectangular area, where the transmission +between buffers is implemented, in units of pixels. +The pixel mode must be the one set by the BITBLTBUF register." + ((rrw uint16 :offset 0 :size 12) + (rrh uint16 :offset 32 :size 12) + ) + ) + +(deftype gs-trxdir (uint64) + "The GS's TRXDIR register specifies the transmission direction in the transmission between +buffers, and activates transmission. +Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating +the transmission." + ((xdir uint8 :offset 0 :size 2) + ) + ) + +(deftype gs-bitbltbuf (uint64) + "The GS's BITBLTBUF register stores buffer-related settings for transmission source and +destination during transmission between buffers." + ((sbp uint16 :offset 0 :size 14) + (sbw uint8 :offset 16 :size 6) + (spsm uint8 :offset 24 :size 6) + (dbp uint16 :offset 32 :size 14) + (dbw uint8 :offset 48 :size 6) + (dpsm gs-psm :offset 56 :size 6) + ) + ) + +(deftype gs-tex0 (uint64) + "The GS's TEX0 registers set various kinds of information regarding the textures to be used." + ((tbp0 uint16 :offset 0 :size 14) + (tbw uint8 :offset 14 :size 6) + (psm uint8 :offset 20 :size 6) + (tw uint8 :offset 26 :size 4) + (th uint8 :offset 30 :size 4) + (tcc uint8 :offset 34 :size 1) + (tfx uint8 :offset 35 :size 2) + (cbp uint16 :offset 37 :size 14) + (cpsm uint8 :offset 51 :size 4) + (csm uint8 :offset 55 :size 1) + (csa uint8 :offset 56 :size 5) + (cld uint8 :offset 61 :size 3) + ) + ) + +(deftype gs-tex1 (uint64) + "The GS's TEX1 registers set information on the sampling method of the textures." + ((lcm uint8 :offset 0 :size 1) + (mxl uint8 :offset 2 :size 3) + (mmag uint8 :offset 5 :size 1) + (mmin uint8 :offset 6 :size 3) + (mtba uint8 :offset 9 :size 1) + (l uint8 :offset 19 :size 2) + (k int16 :offset 32 :size 12) + ) + ) + +(deftype gs-texa (uint64) + "The GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the +texture is not an 8-bit value." + ((ta0 uint8 :offset 0 :size 8) + (aem uint8 :offset 15 :size 1) + (ta1 uint8 :offset 32 :size 8) + ) + ) + +(deftype gs-texclut (uint64) + "The GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode +is CSM=1 (CSM2 mode)." + ((cbw uint8 :offset 0 :size 6) + (cou uint8 :offset 6 :size 6) + (cov uint16 :offset 12 :size 10) + ) + ) + +(deftype gs-miptbp (uint64) + "the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing +MIPMAP. MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6." + ((tbp1 uint16 :offset 0 :size 14) + (tbw1 uint8 :offset 14 :size 6) + (tbp2 uint16 :offset 20 :size 14) + (tbw2 uint8 :offset 34 :size 6) + (tbp3 uint16 :offset 40 :size 14) + (tbw3 uint8 :offset 54 :size 6) + ) + ) + +(deftype gs-alpha (uint64) + ((a uint8 :offset 0 :size 2) + (b uint8 :offset 2 :size 2) + (c uint8 :offset 4 :size 2) + (d uint8 :offset 6 :size 2) + (fix uint8 :offset 32 :size 8) + ) + ) + + +(deftype gs-clamp (uint64) + ((wms gs-tex-wrap-mode :offset 0 :size 2) + (wmt gs-tex-wrap-mode :offset 2 :size 2) + (minu uint16 :offset 4 :size 10) + (maxu uint16 :offset 14 :size 10) + (minv uint16 :offset 24 :size 10) + (maxv uint16 :offset 34 :size 10) + ) + ) + +(deftype gs-fog (uint64) + ((f uint8 :offset 56 :size 8) + ) + ) + + +(deftype gs-fogcol (uint64) + ((fcr uint8 :offset 0 :size 8) + (fcg uint8 :offset 8 :size 8) + (fcb uint8 :offset 16 :size 8) + ) + ) + + +(deftype gif-ctrl (uint32) + ((rst uint8 :offset 0 :size 1) + (pse uint8 :offset 3 :size 1) + ) + ) + +(deftype gif-mode (uint32) + ((m3r uint8 :offset 0 :size 1) + (imt uint8 :offset 2 :size 1) + ) + ) + +(deftype gif-stat (uint32) + ((m3r uint8 :offset 0 :size 1) + (m3p uint8 :offset 1 :size 1) + (imt uint8 :offset 2 :size 1) + (pse uint8 :offset 3 :size 1) + (ip3 uint8 :offset 5 :size 1) + (p3q uint8 :offset 6 :size 1) + (p2q uint8 :offset 7 :size 1) + (p1q uint8 :offset 8 :size 1) + (oph uint8 :offset 9 :size 1) + (apath uint8 :offset 10 :size 2) + (dir uint8 :offset 12 :size 1) + (fqc uint8 :offset 24 :size 5) + ) + ) + +(deftype gif-cnt (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (regcnt uint8 :offset 16 :size 4) + (vuaddr uint16 :offset 20 :size 10) + ) + ) + +(deftype gif-p3cnt (uint32) + ((p3cnt uint16 :offset 0 :size 15) + ) + ) + +(deftype gif-p3tag (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +(deftype gif-bank (structure) + ((ctrl gif-ctrl :offset 0) + (mode gif-mode :offset 16) + (stat gif-stat :offset 32) + (tag0 uint32 :offset 64) + (tag1 uint32 :offset 80) + (tag2 uint32 :offset 96) + (tag3 uint32 :offset 112) + (cnt gif-cnt :offset 128) + (p3cnt gif-p3cnt :offset 144) + (p3tag gif-p3tag :offset 160) + ) + ) + + +(deftype gif-tag-prim (uint32) + ((id uint16 :offset 0 :size 14) + (pre uint8 :offset 14 :size 1) + (prim gs-prim :offset 15 :size 11) + (flg gif-flag :offset 26 :size 2) + (nreg uint8 :offset 28 :size 4) + ) + ) + +(deftype gif-tag-count (uint32) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + ) + ) + +(deftype gif-tag (uint128) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim uint16 :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + (regs0 gif-reg-id :offset 64 :size 4) + (regs1 gif-reg-id :offset 68 :size 4) + (regs2 gif-reg-id :offset 72 :size 4) + (regs3 gif-reg-id :offset 76 :size 4) + (regs4 gif-reg-id :offset 80 :size 4) + (regs5 gif-reg-id :offset 84 :size 4) + (regs6 gif-reg-id :offset 88 :size 4) + (regs7 gif-reg-id :offset 92 :size 4) + (regs8 gif-reg-id :offset 96 :size 4) + (regs9 gif-reg-id :offset 100 :size 4) + (regs10 gif-reg-id :offset 104 :size 4) + (regs11 gif-reg-id :offset 108 :size 4) + (regs12 gif-reg-id :offset 112 :size 4) + (regs13 gif-reg-id :offset 116 :size 4) + (regs14 gif-reg-id :offset 120 :size 4) + (regs15 gif-reg-id :offset 124 :size 4) + ) + ) + +(deftype gif-tag-regs (uint64) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4) + (regs8 gif-reg-id :offset 32 :size 4) + (regs9 gif-reg-id :offset 36 :size 4) + (regs10 gif-reg-id :offset 40 :size 4) + (regs11 gif-reg-id :offset 44 :size 4) + (regs12 gif-reg-id :offset 48 :size 4) + (regs13 gif-reg-id :offset 52 :size 4) + (regs14 gif-reg-id :offset 56 :size 4) + (regs15 gif-reg-id :offset 60 :size 4) + ) + ) + +(deftype gif-tag-regs-32 (uint32) + ((regs0 gif-reg-id :offset 0 :size 4) + (regs1 gif-reg-id :offset 4 :size 4) + (regs2 gif-reg-id :offset 8 :size 4) + (regs3 gif-reg-id :offset 12 :size 4) + (regs4 gif-reg-id :offset 16 :size 4) + (regs5 gif-reg-id :offset 20 :size 4) + (regs6 gif-reg-id :offset 24 :size 4) + (regs7 gif-reg-id :offset 28 :size 4)) + ) + +;; we unfortunately kind of need this +(defmacro gif-tag->static-array (tag regs) + "Allocates a new static array of two uint64's making up the gif-tag and the tag registers" + + `(new 'static 'array uint64 2 ,tag ,regs) + ) + +(defmacro gif-prim (prim-type) + `(new 'static 'gs-prim :prim (gs-prim-type ,prim-type) :iip 1 :abe 1) + ) + +(defmacro gs-reg-list (&rest reg-ids) + "Generate a giftag register descriptor list from reg-ids." + + (let ((reg-count (length reg-ids))) + (when (> (length reg-ids) 16) + (ferror "too many regs passed to gs-reg-list") + ) + (let ((list-to-splice '()) + (cur-lst reg-ids) + (i -1)) + + ;; this is questionable. + (while (and (not (null? cur-lst)) (< i 15)) + (push! list-to-splice (cons 'gif-reg-id (cons (car cur-lst) '()))) + (push! list-to-splice (string->symbol-format ":regs{}" (inc! i))) + (pop! cur-lst) + ) + + `(new 'static 'gif-tag-regs + ,@list-to-splice + ) + ) + #| ;; the opengoal compiler does not have enough constant propagation for this for now + (let ((i -1)) + + `(the-as gif-tag-regs (logior ,@(apply (lambda (x) + `(shl (the-as uint (gif-reg-id ,x)) ,(* 4 (inc! i))) + ) reg-ids) + )) + + )|# + ) + ) + +(deftype gs-gif-tag (structure) + ((qword uint128) + (tag gif-tag64 :overlay-at qword) + (regs gif-tag-regs :offset 8) + (dword uint64 2 :overlay-at qword) + (word uint32 4 :overlay-at qword) + ) + ) + + +;; WARN: Return type mismatch object vs gif-tag. + +(define *fog-color* (new 'static 'rgba :r #x80)) + +(deftype gif-packet (basic) + "Unused type for building a dynamically sized gif packet." + ((reg-count int32) + (gif-tag gs-gif-tag :inline) + (gif-tag0 uint128 :overlay-at (-> gif-tag qword)) + (args uint64 1) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + + +(defmethod new gif-packet ((allocation symbol) (type-to-make type) (arg0 int)) + (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 8)))) + ) + +(defun open-gif-packet ((arg0 gif-packet)) + "Initialize an existing gif-packet for 0 registers." + (set! (-> arg0 reg-count) 0) + (set! (-> arg0 gif-tag regs) (new 'static 'gif-tag-regs)) + arg0 + ) + +;; WARN: Return type mismatch gif-packet vs none. +(defun add-reg-gif-packet ((arg0 gif-packet) (arg1 int) (arg2 int)) + "Add a register + value to the packet." + (let ((v1-0 (-> arg0 gif-tag))) + (logior! (-> v1-0 regs) (ash arg1 (* (-> arg0 reg-count) 4))) + ) + (set! (-> (&-> arg0 args (-> arg0 reg-count)) 0) (the-as uint arg2)) + (+! (-> arg0 reg-count) 1) + (none) + ) + +(defun close-gif-packet ((arg0 gif-packet) (arg1 int)) + "Finish adding registers." + (set! (-> arg0 gif-tag tag) + (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :eop arg1 :nreg (-> arg0 reg-count)) + ) + arg0 + ) + +(deftype draw-context (basic) + ((orgx int32) + (orgy int32) + (orgz int32) + (width int32) + (height int32) + (color rgba 4) + ) + (:methods + (new (symbol type int int int int rgba) _type_) + ) + ) + + +(defmethod new draw-context ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 rgba)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 orgx) arg0) + (set! (-> v0-0 orgy) arg1) + (set! (-> v0-0 orgz) #xffffff) + (set! (-> v0-0 width) arg2) + (set! (-> v0-0 height) arg3) + (set! (-> v0-0 color 0) arg4) + v0-0 + ) + ) + +(defun draw-context-set-xy ((arg0 draw-context) (arg1 int) (arg2 int)) + "Set the origin of the draw context." + (set! (-> arg0 orgx) arg1) + (set! (-> arg0 orgy) arg2) + (none) + ) + +(deftype gs-packed-rgba (vector4w) + ((r int32 :overlay-at (-> data 0)) + (g int32 :overlay-at (-> data 1)) + (b int32 :overlay-at (-> data 2)) + (a int32 :overlay-at (-> data 3)) + ) + ) + + +(deftype gs-packed-xyzw (vector) + ((ix int32 :overlay-at (-> data 0)) + (iy int32 :overlay-at (-> data 1)) + (iz int32 :overlay-at (-> data 2)) + (iw int32 :overlay-at (-> data 3)) + ) + ) + + +(deftype gs-packed-stq (vector) + ((tex-s float :overlay-at (-> data 0)) + (tex-t float :overlay-at (-> data 1)) + (tex-q float :overlay-at (-> data 2)) + ) + ) + + +(deftype gs-packed-uv (vector) + ((u int16 :overlay-at (-> data 0)) + (v int16 :overlay-at (-> data 1)) + ) + ) + + +(deftype gs-packed-gt (structure) + ((stq gs-packed-stq :inline :offset 0) + (rgba gs-packed-rgba :inline :offset 16) + (xyzw gs-packed-xyzw :inline :offset 32) + ) + ) + + +(deftype gs-packed-gt4 (structure) + ((data gs-packed-gt 4 :inline) + ) + ) diff --git a/goal_src/jak3/engine/gfx/math-camera-h.gc b/goal_src/jak3/engine/gfx/math-camera-h.gc index 79665276ecc..2703efc0c5d 100644 --- a/goal_src/jak3/engine/gfx/math-camera-h.gc +++ b/goal_src/jak3/engine/gfx/math-camera-h.gc @@ -5,5 +5,115 @@ ;; name in dgo: math-camera-h ;; dgos: GAME +#|@file +The "math-camera" is responsible for computing the projection matrix used in the renderer +from the position of the in-game camera. It also computes some other common camera info. +See cam-update.gc for how the game camera updates the math-camera. + +It also contains some GIF stuff, but these seem to be wrong/unused. +Some of the code here may be extremely old and unused, but this does compute the camera projection +matrix used almost everywhere. +|# + ;; DECOMP BEGINS +(deftype vis-gif-tag (structure) + "Unused." + ((fog0 uint32) + (strip uint32) + (regs uint32) + (fan uint32) + ) + ) + + +(deftype cull-info (structure) + "Also seems unused." + ((x-fact float) + (y-fact float) + (z-fact float) + (cam-radius float) + (cam-x float) + (cam-y float) + (xz-dir-ax float) + (xz-dir-az float) + (xz-dir-bx float) + (xz-dir-bz float) + (xz-cross-ab float) + (yz-dir-ay float) + (yz-dir-az float) + (yz-dir-by float) + (yz-dir-bz float) + (yz-cross-ab float) + ) + :allow-misaligned + ) + + +(deftype math-camera (basic) + ((d meters) + (f meters) + (fov degrees) + (x-ratio float) + (y-ratio float) + (x-pix float) + (x-clip float) + (x-clip-ratio-in float) + (x-clip-ratio-over float) + (y-pix float) + (y-clip float) + (y-clip-ratio-in float) + (y-clip-ratio-over float) + (cull-info cull-info :inline) + (fog-start meters) + (fog-end meters) + (fog-max float) + (fog-min float) + (reset int32) + (smooth-step float) + (smooth-t float) + (perspective matrix :inline) + (isometric matrix :inline) + (sprite-2d matrix :inline) + (sprite-2d-hvdf vector :inline) + (camera-rot matrix :inline) + (inv-camera-rot matrix :inline) + (inv-camera-rot-smooth matrix :inline) + (inv-camera-rot-smooth-from quaternion :inline) + (camera-temp matrix :inline) + (prev-camera-temp matrix :inline) + (prev-inv-camera-rot matrix :inline) + (prev-trans vector :inline) + (hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-off vector :inline) + (guard vector :inline) + (vis-gifs vis-gif-tag 4) + (giftex uint128 :overlay-at (-> vis-gifs 0)) + (gifgr uint128 :offset 864) + (giftex-trans uint128 :offset 880) + (gifgr-trans uint128 :offset 896) + (pfog0 float) + (pfog1 float) + (trans vector :inline) + (plane plane 4 :inline) + (guard-plane plane 4 :inline) + (shrub-mat matrix :inline) + (quat-other quaternion :inline) + (trans-other vector :inline) + (shrub-mat-other matrix :inline) + (camera-temp-other matrix :inline) + (camera-rot-other matrix :inline) + (camera-rot-other-sky matrix :inline) + (camera-rot-other-sprite matrix :inline) + (inv-camera-rot-other matrix :inline) + (plane-other plane 4 :inline) + (guard-plane-other plane 4 :inline) + (mirror-trans vector :inline) + (mirror-normal vector :inline) + (fov-correction-factor float) + ) + (:methods + (new (symbol type) _type_) + ) + ) diff --git a/goal_src/jak3/engine/gfx/math-camera.gc b/goal_src/jak3/engine/gfx/math-camera.gc index 5aa2ad1ef7e..9bb9d2f2c7e 100644 --- a/goal_src/jak3/engine/gfx/math-camera.gc +++ b/goal_src/jak3/engine/gfx/math-camera.gc @@ -5,5 +5,687 @@ ;; name in dgo: math-camera ;; dgos: GAME +#|@file +;;;;;;;;;;;;;;;;;;;; +math camera basics +;;;;;;;;;;;;;;;;;;;; + +the math camera computes the perspective matrix, hvdf offset, and hmge scale. + +multiplying a point by the perspective matrix, doing the persepctive divide, then adding hvdf offset gives you: +H : horizontal position (in GS coordinates) +V : vertical position (in GS coordinates) +D : depth (as a 24-bit integer for the z buffer) +F : fog + +Multiplying by hmge then checking the clipping flags can be used to see if a point is outside the view frustum. + +The "camera-temp" matrix is the perspective matrix multplied by the camera tranformation and is used +renderers that want a single matrix. +|# + +(define-extern sprite-distorter-generate-tables (function none)) + ;; DECOMP BEGINS +(deftype fog-corrector (structure) + "The math-camera matrices are used to compute fogging values, which are a per-vertex uint8 that +tells the GS how 'foggy' the color should be. This should be proportional to how far away the vertex +is. There is a scaling factor applied so the fog intensity isn't affected by the field of view angle. + +The fog-corrector stores a fog-end fog-start value that is corrected for the field of view. +The actual correction factor is computed in cam-update.gc. +Without this corrector, the fogginess of the world would change as the FOV changes +(for example, when Jak gets on the zoomer, the FOV changes slightly)." + ((fog-end float) + (fog-start float) + ) + ) + + +;; WARN: Return type mismatch float vs none. +(defun fog-corrector-setup ((arg0 fog-corrector) (arg1 math-camera)) + "Set the fog corrector based on the supplied math-camera." + (set! (-> arg0 fog-end) (* (-> arg1 fog-end) (-> arg1 fov-correction-factor))) + (set! (-> arg0 fog-start) (* (-> arg1 fog-start) (-> arg1 fov-correction-factor))) + (none) + ) + +(define *math-camera-fog-correction* (new 'global 'fog-corrector)) + +;; ERROR: Failed store: (s.w! a0-43 v1-54) at op 457 +;; ERROR: Failed store: (s.w! (+ a0-43 4) a1-9) at op 461 +;; ERROR: Failed store: (s.w! (+ a0-43 8) a1-10) at op 463 +;; ERROR: Failed store: (s.w! (+ a0-43 12) a1-11) at op 465 +(defun update-math-camera ((arg0 math-camera) (arg1 symbol) (arg2 symbol) (arg3 float)) + "Compute some one-time camera constants. + These should only change when changing aspect ratio." + (local-vars (sv-16 float)) + (set! (-> arg0 x-ratio) (tan (* 0.5 arg3))) + (if (= arg2 'aspect4x3) + (set! (-> arg0 y-ratio) (* 0.75 (-> arg0 x-ratio))) + (set! (-> arg0 y-ratio) (* 0.5625 (-> arg0 x-ratio))) + ) + ;; TODO pckernel + ;; og:preserve-this + ;; (with-pc + ;; (cond + ;; ((-> *pc-settings* use-vis?) + ;; ;; using game vis, cannot allow seeing more of the view + ;; ;; crops excess aspect ratio at the top and bottom + ;; ;(set! (-> arg0 y-ratio) (* (1/ (-> *pc-settings* aspect-ratio)) (-> arg0 x-ratio))) + ;; ) + ;; ((real-movie?) + ;; ;; this mess is just so that we can force the original 16x9 cropping during cutscenes. + ;; (if (<= (-> *pc-settings* aspect-ratio) ASPECT_16X9) + ;; (set! (-> arg0 y-ratio) (* (1/ (-> *pc-settings* aspect-ratio)) (-> arg0 x-ratio))) + ;; (begin + ;; (set! (-> arg0 y-ratio) (* (1/ ASPECT_16X9) (-> arg0 x-ratio))) + ;; (*! (-> arg0 x-ratio) (/ (-> *pc-settings* aspect-ratio) ASPECT_16X9)) + ;; ) + ;; ) + ;; ) + ;; (else + ;; ;; not using game vis, allow *extended* aspect ratios + ;; ;; there is no vertical cropping, and you can see more of the sides + ;; (set! (-> arg0 y-ratio) (* (1/ ASPECT_4X3) (-> arg0 x-ratio))) ;; same cropping as 4x3 + ;; (*! (-> arg0 x-ratio) (/ (-> *pc-settings* aspect-ratio) ASPECT_4X3)) ;; extend fov! shows more on the sides. + ;; ) + ;; ) + ;; ) + (let ((f1-3 (-> arg0 x-ratio)) + (f0-7 (-> arg0 y-ratio)) + (v1-6 (-> arg0 cull-info)) + ) + (/ (+ 1.0 (* 4.0 f1-3 f1-3)) (+ 1.0 (* f1-3 f1-3))) + (let ((f2-5 (/ (+ 1.0 (* 4.0 f0-7 f0-7)) (+ 1.0 (* f0-7 f0-7))))) + (set! (-> v1-6 x-fact) (/ (+ 1.0 (* 4.0 f1-3 f1-3)) (* f1-3 (sqrtf (+ 1.0 (* 16.0 f1-3 f1-3)))))) + (set! (-> v1-6 y-fact) (/ (+ 1.0 (* 4.0 f0-7 f0-7)) (* f0-7 (sqrtf (+ 1.0 (* 16.0 f0-7 f0-7)))))) + (set! (-> v1-6 z-fact) (sqrtf (+ (* (+ -4.0 f2-5) (+ -4.0 f2-5) f0-7 f0-7) (* (+ -1.0 f2-5) (+ -1.0 f2-5))))) + ) + (let* ((f2-11 (* f1-3 (-> arg0 d))) + (f1-5 (* f0-7 (-> arg0 d))) + (f0-10 (+ (* f2-11 f2-11) (* f1-5 f1-5))) + (f1-8 (-> arg0 d)) + ) + (set! (-> v1-6 cam-radius) (sqrtf (+ f0-10 (* f1-8 f1-8)))) + ) + (let* ((f1-12 (* (-> arg0 d) (-> arg0 x-ratio))) + (f0-14 (-> arg0 d)) + (f2-13 (* 4.0 f1-12)) + (f3-21 (-> arg0 d)) + ) + (let ((f4-21 (/ 1.0 (sqrtf (+ (* f1-12 f1-12) (* f0-14 f0-14))))) + (f5-11 (/ 1.0 (sqrtf (+ (* f2-13 f2-13) (* f3-21 f3-21))))) + ) + (set! (-> v1-6 xz-dir-ax) (* f1-12 f4-21)) + (set! (-> v1-6 xz-dir-az) (* f0-14 f4-21)) + (set! (-> v1-6 xz-dir-bx) (* f2-13 f5-11)) + (set! (-> v1-6 xz-dir-bz) (* f3-21 f5-11)) + ) + (set! (-> v1-6 xz-cross-ab) (- (* f1-12 f3-21) (* f0-14 f2-13))) + ) + (let* ((f1-15 (* (-> arg0 d) (-> arg0 y-ratio))) + (f0-18 (-> arg0 d)) + (f2-15 (* 4.0 f1-15)) + (f3-22 (-> arg0 d)) + ) + (let ((f4-26 (/ 1.0 (sqrtf (+ (* f1-15 f1-15) (* f0-18 f0-18))))) + (f5-16 (/ 1.0 (sqrtf (+ (* f2-15 f2-15) (* f3-22 f3-22))))) + ) + (set! (-> v1-6 yz-dir-ay) (* f1-15 f4-26)) + (set! (-> v1-6 yz-dir-az) (* f0-18 f4-26)) + (set! (-> v1-6 yz-dir-by) (* f2-15 f5-16)) + (set! (-> v1-6 yz-dir-bz) (* f3-22 f5-16)) + ) + (set! (-> v1-6 yz-cross-ab) (- (* f1-15 f3-22) (* f0-18 f2-15))) + ) + ) + (fog-corrector-setup *math-camera-fog-correction* arg0) + (matrix-identity! (-> arg0 camera-rot)) + (let ((f0-21 100.0) + (f2-16 16760631.0) + ) + 16777115.0 + (let ((f30-0 (/ (* (-> arg0 d) (- (-> arg0 fog-min) (-> arg0 fog-max))) + (- (-> *math-camera-fog-correction* fog-end) (-> *math-camera-fog-correction* fog-start)) + ) + ) + (f1-21 (* -0.5 (- f2-16 f0-21))) + ) + (let ((f4-34 (/ f1-21 (* (-> arg0 d) (- (-> arg0 f) (-> arg0 d))))) + (f3-30 (-> arg0 fov-correction-factor)) + ) + (set! (-> arg0 perspective rvec x) (* f3-30 (- (/ (-> arg0 x-pix) (* (-> arg0 x-ratio) (-> arg0 d)))))) + (set! (-> arg0 perspective uvec y) (* f3-30 (- (/ (-> arg0 y-pix) (* (-> arg0 y-ratio) (-> arg0 d)))))) + (set! (-> arg0 perspective fvec z) (* f3-30 (+ (-> arg0 f) (-> arg0 d)) f4-34)) + (set! (-> arg0 perspective fvec w) (* (/ f3-30 (-> arg0 d)) f30-0)) + (set! (-> arg0 perspective trans z) (* -2.0 f4-34 (-> arg0 f) (-> arg0 d) f3-30)) + ) + (let ((f24-0 2048.0) + (f26-0 2048.0) + (f28-0 (/ (- (* (-> *math-camera-fog-correction* fog-end) (-> arg0 fog-max)) + (* (-> *math-camera-fog-correction* fog-start) (-> arg0 fog-min)) + ) + (- (-> *math-camera-fog-correction* fog-end) (-> *math-camera-fog-correction* fog-start)) + ) + ) + ) + (let ((f22-0 (* 0.5 (+ f2-16 f0-21)))) + (set! (-> arg0 hmge-scale x) (/ 1.0 (-> arg0 x-clip))) + (set! (-> arg0 hmge-scale y) (/ 1.0 (-> arg0 y-clip))) + (set! (-> arg0 hmge-scale z) (/ 1.0 f1-21)) + (set! (-> arg0 hmge-scale w) (/ 1.0 f30-0)) + (set! (-> arg0 inv-hmge-scale x) (-> arg0 x-clip)) + (set! (-> arg0 inv-hmge-scale y) (-> arg0 y-clip)) + (set! (-> arg0 inv-hmge-scale z) f1-21) + (set! (-> arg0 inv-hmge-scale w) f30-0) + (cond + ((or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + (set! (-> arg0 hvdf-off x) f24-0) + (set! (-> arg0 hvdf-off y) f26-0) + ) + (else + (let* ((v1-32 (-> *screen-shot-work* count)) + (a0-36 (-> *screen-shot-work* size)) + (f0-34 (the float a0-36)) + (f20-0 (/ (the float (mod v1-32 a0-36)) f0-34)) + ) + (set! sv-16 (/ (the float (/ v1-32 a0-36)) f0-34)) + (format 0 "~f ~f~%" f20-0 sv-16) + (set! (-> arg0 hvdf-off x) (- f24-0 f20-0)) + ) + (set! (-> arg0 hvdf-off y) (- f26-0 sv-16)) + ) + ) + (set! (-> arg0 hvdf-off z) f22-0) + (set! (-> arg0 hvdf-off w) f28-0) + (set! (-> arg0 guard x) (/ (-> arg0 x-clip) (-> arg0 x-pix))) + (set! (-> arg0 guard y) (/ (-> arg0 y-clip) (-> arg0 y-pix))) + (set! (-> arg0 guard z) 1.0) + (set! (-> arg0 guard w) 1.0) + (set! (-> arg0 isometric trans z) (- 16777215.0 f22-0)) + ;; og:preserve-this PC HACK! + ;; for whatever reason, the font render ends up computing a depth #x1000000 instead of + ;; #xffffffff, which overflows the 24-bit z buffer. + ;; cheating this by 1 bit seems to fix it. + (#when PC_PORT + ;; #x4b002032 -> #x4b002031 + (set! (-> arg0 isometric vector 3 z) (the-as float (- (the-as int (-> arg0 isometric vector 3 z)) 1))) + ) + ) + (set! (-> arg0 isometric trans w) f30-0) + (let ((f1-28 (-> arg0 perspective rvec x)) + (f2-19 (-> arg0 perspective uvec y)) + (f0-48 (* -1.9996 (-> arg0 perspective rvec x))) + ) + (let ((v1-39 (-> arg0 sprite-2d))) + (set! (-> v1-39 rvec x) f0-48) + (set! (-> v1-39 rvec y) 0.0) + (set! (-> v1-39 rvec z) 0.0) + (set! (-> v1-39 rvec w) 0.0) + ) + (set-vector! (-> arg0 sprite-2d uvec) 0.0 (- (* (/ f2-19 f1-28) f0-48)) 0.0 0.0) + (set-vector! (-> arg0 sprite-2d fvec) 0.0 0.0 (- f0-48) 0.0) + (set-vector! (-> arg0 sprite-2d trans) 0.0 0.0 (* 500000000.0 f0-48) (* 60.0 f0-48 (-> arg0 pfog0))) + ) + (set! (-> arg0 sprite-2d-hvdf quad) (-> arg0 hvdf-off quad)) + (set! (-> arg0 sprite-2d-hvdf x) 2048.0) + (set! (-> arg0 sprite-2d-hvdf y) 2048.0) + (set! (-> arg0 sprite-2d-hvdf z) (-> arg0 hvdf-off z)) + (set! (-> arg0 pfog0) f30-0) + (set! (-> arg0 pfog1) f28-0) + ) + ) + ) + 0 + ;; garbage giftags + (make-u128 0 (shl #x301ec000 32)) + (make-u128 0 (shl #x303ec000 32)) + (let ((v1-54 (-> arg0 pfog0))) + (let ((a0-42 (-> arg0 vis-gifs))) + (set! (-> a0-42 0) (the-as vis-gif-tag v1-54)) + (set! (-> a0-42 1) (the-as vis-gif-tag #x301e4000)) + (set! (-> a0-42 2) (the-as vis-gif-tag 1042)) + (set! (-> a0-42 3) (the-as vis-gif-tag #x301ec000)) + ) + ;; og:preserve-this + #| + (let ((a0-43 (&-> arg0 gifgr))) + (s.w! a0-43 v1-54) + (let ((a1-9 (make-u128 0 (shl #x20164000 32)))) + (s.w! (+ a0-43 4) a1-9) + ) + (let ((a1-10 65)) + (s.w! (+ a0-43 8) a1-10) + ) + (let ((a1-11 #x301ec000)) + (s.w! (+ a0-43 12) a1-11) + ) + ) + |# + (let ((a0-44 (-> arg0 vis-gifs))) + (set! (-> a0-44 0) (the-as vis-gif-tag v1-54)) + (set! (-> a0-44 1) (the-as vis-gif-tag #x303e4000)) + (set! (-> a0-44 2) (the-as vis-gif-tag 1042)) + (set! (-> a0-44 3) (the-as vis-gif-tag #x303ec000)) + ) + (let ((a0-45 (-> arg0 vis-gifs))) + (set! (-> a0-45 0) (the-as vis-gif-tag v1-54)) + (set! (-> a0-45 1) (the-as vis-gif-tag #x303e4000)) + (set! (-> a0-45 2) (the-as vis-gif-tag 1042)) + (set! (-> a0-45 3) (the-as vis-gif-tag #x303ec000)) + ) + ) + (if (nonzero? sprite-distorter-generate-tables) + (sprite-distorter-generate-tables) + ) + arg0 + ) + +(defmethod new math-camera ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 d) 1024.0) + (set! (-> gp-0 f) 40960000.0) + (set! (-> gp-0 fov) 11650.845) + (set! (-> gp-0 x-pix) 256.0) + (set! (-> gp-0 x-clip) 512.0) + (set! (-> gp-0 y-pix) 208.0) + (set! (-> gp-0 y-clip) 416.0) + (set! (-> gp-0 fog-start) 40960.0) + (set! (-> gp-0 fog-end) 819200.0) + (set! (-> gp-0 fog-max) 255.0) + (set! (-> gp-0 fog-min) 150.0) + (matrix-identity! (-> gp-0 inv-camera-rot)) + (matrix-identity! (-> gp-0 camera-rot)) + (vector-reset! (-> gp-0 trans)) + (quaternion-identity! (-> gp-0 quat-other)) + (set-vector! (-> gp-0 trans-other) 0.0 0.0 0.0 1.0) + (matrix-identity! (-> gp-0 inv-camera-rot-other)) + (matrix-identity! (-> gp-0 camera-rot-other)) + (matrix-identity! (-> gp-0 camera-temp-other)) + (set! (-> gp-0 isometric rvec x) 1.0) + (set! (-> gp-0 isometric uvec y) 0.5) + (set! (-> gp-0 isometric fvec z) -1.0) + (set! (-> gp-0 reset) 1) + (set! (-> gp-0 smooth-step) 0.0) + (set! (-> gp-0 smooth-t) 0.0) + (update-math-camera gp-0 'ntsc 'aspect4x3 (-> gp-0 fov)) + ) + ) + +(define *math-camera* (new 'global 'math-camera)) + +(defun math-cam-start-smoothing ((arg0 float) (arg1 float)) + "Unused camera smoothing." + (set! (-> *math-camera* smooth-step) (/ 1.0 arg0)) + (set! (-> *math-camera* smooth-t) arg1) + (matrix->quaternion (-> *math-camera* inv-camera-rot-smooth-from) (-> *math-camera* inv-camera-rot-smooth)) + ) + +(defun move-target-from-pad ((arg0 transform) (arg1 int)) + "Unused function to adjust trans based on inputs from the pad. + This function must be extremely old because it takes a non-quaternion transform, + and all [[target]] stuff uses quaternions." + (let ((s4-0 (new-stack-vector0))) + (set! (-> s4-0 x) (cond + ((cpad-hold? arg1 circle) + -80.0 + ) + ((cpad-hold? arg1 square) + 80.0 + ) + (else + 0.0 + ) + ) + ) + (set! (-> s4-0 y) 0.0) + (set! (-> s4-0 z) (cond + ((cpad-hold? arg1 down) + -80.0 + ) + ((cpad-hold? arg1 up) + 80.0 + ) + (else + 0.0 + ) + ) + ) + (set! (-> s4-0 w) 1.0) + (let ((a0-5 (new-stack-vector0)) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s3-0 rvec quad) (the-as uint128 0)) + (set! (-> s3-0 uvec quad) (the-as uint128 0)) + (set! (-> s3-0 fvec quad) (the-as uint128 0)) + (set! (-> s3-0 trans quad) (the-as uint128 0)) + (vector-negate! a0-5 (-> arg0 rot)) + (matrix-rotate-zyx! s3-0 (-> arg0 rot)) + (vector-matrix*! s4-0 s4-0 s3-0) + ) + (vector+! (-> arg0 trans) (-> arg0 trans) s4-0) + ) + (set! (-> arg0 trans w) 1.0) + (if (cpad-hold? arg1 r1) + (+! (-> arg0 trans y) 80.0) + ) + (if (cpad-hold? arg1 r2) + (+! (-> arg0 trans y) -80.0) + ) + (if (cpad-hold? arg1 x) + (+! (-> arg0 rot x) 546.13336) + ) + (if (cpad-hold? arg1 triangle) + (+! (-> arg0 rot x) -546.13336) + ) + (if (cpad-hold? arg1 left) + (+! (-> arg0 rot y) 546.13336) + ) + (if (cpad-hold? arg1 right) + (+! (-> arg0 rot y) -546.13336) + ) + arg0 + ) + +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +(defun transform-point-vector! ((arg0 vector) (arg1 vector)) + "Apply camera transformation to a point. Return true if it is visible or not. + This returns the point in GS coords, but as float instead of int, so it's + not really useful. See [[transform-point-qword!]] for more details." + (local-vars (v1-2 int)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + 0 + (let ((v1-1 *math-camera*)) + (.lvf vf24 (&-> v1-1 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-1 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-1 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-1 camera-temp trans quad)) + (.lvf vf29 (&-> v1-1 hmge-scale quad)) + (.lvf vf30 (&-> v1-1 hvdf-off quad)) + ) + (.lvf vf28 (&-> arg1 quad)) + (.mul.x.vf acc vf24 vf28) + (.add.mul.y.vf acc vf25 vf28 acc) + (.add.mul.z.vf acc vf26 vf28 acc) + (.add.mul.w.vf vf28 vf27 vf0 acc) + (.add.w.vf vf23 vf0 vf0) + (.mul.vf vf31 vf28 vf29) + ;; og:preserve-this + ;;(TODO.VCLIP vf31 vf31) + (let ((clip (vu-clip vf31 0))) + (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) + (.wait.vf) + ;;(.cfc2.i v1-7 Clipping) + (.mul.vf vf28 vf28 Q :mask #b111) + (.mul.vf vf23 vf23 Q) + (.add.vf vf28 vf28 vf30) + (.max.x.vf vf28 vf28 vf0 :mask #b1000) + (.svf (&-> arg0 quad) vf28) + (not (logtest? clip 63)) + ) + ) + ) + +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +(defun transform-point-qword! ((arg0 vector4w) (arg1 vector)) + "Apply camera transformation to point, returning fixed point 28.4 position + that can be given to the GS directly." + (local-vars (v1-2 int)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + 0 + (let ((v1-1 *math-camera*)) + (.lvf vf24 (&-> v1-1 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-1 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-1 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-1 camera-temp trans quad)) + (.lvf vf29 (&-> v1-1 hmge-scale quad)) + (.lvf vf30 (&-> v1-1 hvdf-off quad)) + ) + (.lvf vf28 (&-> arg1 quad)) + (.mul.x.vf acc vf24 vf28) + (.add.mul.y.vf acc vf25 vf28 acc) + (.add.mul.z.vf acc vf26 vf28 acc) + (.add.mul.w.vf vf28 vf27 vf0 acc) + (.add.w.vf vf23 vf0 vf0) + (.mul.vf vf31 vf28 vf29) + ;; og:preserve-this + ;; (TODO.VCLIP vf31 vf31) + (let ((clip (vu-clip vf31 0))) + (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) + (.wait.vf) + ;; (.cfc2.i v1-2 Clipping) + (.mul.vf vf28 vf28 Q :mask #b111) + (.mul.vf vf23 vf23 Q) + (.add.vf vf28 vf28 vf30) + (.max.x.vf vf28 vf28 vf0 :mask #b1000) + (vftoi4.xyzw vf28 vf28) + (.svf (&-> arg0 quad) vf28) + (not (logtest? clip 63)) + ) + ) + ) + +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +(defun transform-point-vector-scale! ((arg0 vector) (arg1 vector)) + "Similar to transform-point-qword! but returns the scale factor instead." + (local-vars (v0-0 float) (v1-2 int)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + 0 + (let ((v1-1 *math-camera*)) + (.lvf vf24 (&-> v1-1 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-1 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-1 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-1 camera-temp trans quad)) + (.lvf vf29 (&-> v1-1 hmge-scale quad)) + (.lvf vf30 (&-> v1-1 hvdf-off quad)) + ) + (.lvf vf28 (&-> arg1 quad)) + (.mul.x.vf acc vf24 vf28) + (.add.mul.y.vf acc vf25 vf28 acc) + (.add.mul.z.vf acc vf26 vf28 acc) + (.add.mul.w.vf vf28 vf27 vf0 acc) + (.add.w.vf vf23 vf0 vf0) + (.mul.vf vf31 vf28 vf29) + ;; og:preserve-this + ;; (TODO.VCLIP vf31 vf31) + (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) + (.wait.vf) + ;; (.cfc2.i v1-2 Clipping) + (.mul.vf vf28 vf28 Q :mask #b111) + (.mul.vf vf23 vf23 Q) + (.add.vf vf28 vf28 vf30) + (.max.x.vf vf28 vf28 vf0 :mask #b1000) + (.svf (&-> arg0 quad) vf28) + ;; (not (logtest? v1-2 63)) + (.mov v0-0 vf23) + v0-0 + ) + ) + +;; WARN: Return type mismatch vector vs none. +(defun reverse-transform-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Likely transform arg3 from screen space to world coords, using arg1/arg2 for... something." + (let* ((v1-1 (-> *math-camera* perspective)) + (s2-0 (-> *math-camera* camera-rot)) + (f30-0 (* (/ (-> v1-1 fvec w) (-> v1-1 rvec x)) (-> *math-camera* hmge-scale w))) + (f28-0 (* (/ (-> v1-1 fvec w) (-> v1-1 uvec y)) (-> *math-camera* hmge-scale w))) + (s4-0 (vector-rotate*! (new 'stack-no-clear 'vector) arg2 s2-0)) + (v1-3 (vector-matrix*! (new 'stack-no-clear 'vector) arg1 s2-0)) + (f0-8 (/ (+ (* (-> s4-0 x) (-> v1-3 x)) (* (-> s4-0 y) (-> v1-3 y)) (* (-> s4-0 z) (-> v1-3 z))) + (+ (* (-> s4-0 x) (-> arg3 x) f30-0) (* (-> s4-0 y) (-> arg3 y) f28-0) (-> s4-0 z)) + ) + ) + (f1-16 (* (-> arg3 x) f0-8 f30-0)) + (f2-9 (* (-> arg3 y) f0-8 f28-0)) + (t9-2 vector-matrix*!) + (a0-5 arg0) + (a1-3 (new 'stack-no-clear 'vector)) + ) + (set! (-> a1-3 x) f1-16) + (set! (-> a1-3 y) f2-9) + (set! (-> a1-3 z) f0-8) + (set! (-> a1-3 w) 1.0) + (t9-2 a0-5 a1-3 (-> *math-camera* inv-camera-rot)) + ) + (none) + ) + +(defun init-for-transform ((arg0 matrix)) + "Sets up VU0 registers with camera info. + This is probably a very old function and it's only used by camera debug. + It stashes some data in vector float registers that must be there before calling transform-float-point." + (local-vars (v1-14 float)) + (rlet ((vf1 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf2 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (let ((gp-0 (new-stack-matrix0)) + (s5-0 (new-stack-matrix0)) + (s4-0 (new 'stack 'vector4s-3)) + (s3-0 (new-stack-vector0)) + (s2-0 (new 'stack 'vector4s-3)) + ) + (matrix*! s5-0 arg0 (-> *math-camera* camera-temp)) + (matrix-3x3-inverse-transpose! gp-0 arg0) + (set-vector! s3-0 0.4 0.4 0.4 1.0) + (let ((v1-4 (-> s4-0 data))) + (set! (-> v1-4 0) 1.0) + (set! (-> v1-4 1) 1.0) + (set! (-> v1-4 2) 1.0) + (set! (-> v1-4 3) 1.0) + ) + (let ((v1-5 (&-> s4-0 data 4))) + (set! (-> v1-5 0) 0.0) + (set! (-> v1-5 1) 0.0) + (set! (-> v1-5 2) 0.0) + (set! (-> v1-5 3) 1.0) + ) + (let ((v1-6 (&-> s4-0 data 8))) + (set! (-> v1-6 0) 0.0) + (set! (-> v1-6 1) 0.0) + (set! (-> v1-6 2) 0.0) + (set! (-> v1-6 3) 1.0) + ) + (let ((v1-7 (-> s2-0 data))) + (set! (-> v1-7 0) 1.0) + (set! (-> v1-7 1) 0.0) + (set! (-> v1-7 2) 0.0) + (set! (-> v1-7 3) 1.0) + ) + (let ((v1-8 (&-> s2-0 data 4))) + (set! (-> v1-8 0) 0.0) + (set! (-> v1-8 1) 1.0) + (set! (-> v1-8 2) 0.0) + (set! (-> v1-8 3) 1.0) + ) + (let ((v1-9 (&-> s2-0 data 8))) + (set! (-> v1-9 0) 0.0) + (set! (-> v1-9 1) 0.0) + (set! (-> v1-9 2) 1.0) + (set! (-> v1-9 3) 1.0) + ) + (.lvf vf7 (&-> *math-camera* hmge-scale quad)) + (.lvf vf8 (&-> *math-camera* hvdf-off quad)) + (.lvf vf9 (&-> *math-camera* giftex)) + (let ((v1-13 255)) + (.mov vf6 v1-13) + ) + ;; og:preserve-this + ;; (.mov v1-14 vf6) + (.itof.vf vf6 vf6) + (.svf (&-> *transform-regs* vf7) vf7) + (.svf (&-> *transform-regs* vf8) vf8) + (.svf (&-> *transform-regs* vf9) vf9) + (.svf (&-> *transform-regs* vf6) vf6) + (set! (-> *transform-regs* vf1) (-> s5-0 rvec quad)) + (set! (-> *transform-regs* vf2) (-> s5-0 uvec quad)) + (set! (-> *transform-regs* vf3) (-> s5-0 fvec quad)) + (set! (-> *transform-regs* vf4) (-> s5-0 trans quad)) + (set! (-> *transform-regs* vf17) (-> gp-0 rvec quad)) + (set! (-> *transform-regs* vf18) (-> gp-0 uvec quad)) + (set! (-> *transform-regs* vf19) (-> gp-0 fvec quad)) + (set! (-> *transform-regs* vf23) (-> s2-0 quad 0)) + (set! (-> *transform-regs* vf24) (-> s2-0 quad 1)) + (set! (-> *transform-regs* vf25) (-> s2-0 quad 2)) + + (set! (-> *transform-regs* vf27) (-> s4-0 quad 0)) + (set! (-> *transform-regs* vf28) (-> s4-0 quad 1)) + (set! (-> *transform-regs* vf29) (-> s4-0 quad 2)) + (set! (-> *transform-regs* vf26) (-> s3-0 quad)) + ;; (.lvf vf1 (&-> s5-0 rvec quad)) + ;; (.lvf vf2 (&-> s5-0 uvec quad)) + ;; (.lvf vf3 (&-> s5-0 fvec quad)) + ;; (.lvf vf4 (&-> s5-0 trans quad)) + ;; (.lvf vf17 (&-> gp-0 rvec quad)) + ;; (.lvf vf18 (&-> gp-0 uvec quad)) + ;; (.lvf vf19 (&-> gp-0 fvec quad)) + ;; (.lvf vf23 (&-> s2-0 quad 0)) + ;; (.lvf vf24 (&-> s2-0 quad 1)) + ;; (.lvf vf25 (&-> s2-0 quad 2)) + ;; (.lvf vf27 (&-> s4-0 quad 0)) + ;; (.lvf vf28 (&-> s4-0 quad 1)) + ;; (.lvf vf29 (&-> s4-0 quad 2)) + ;; (.lvf vf26 (&-> s3-0 quad)) + ) + (none) + ) + ) diff --git a/goal_src/jak3/engine/gfx/texture/texture-h.gc b/goal_src/jak3/engine/gfx/texture/texture-h.gc index 1494cce084a..a0f6f0f0fc7 100644 --- a/goal_src/jak3/engine/gfx/texture/texture-h.gc +++ b/goal_src/jak3/engine/gfx/texture/texture-h.gc @@ -5,5 +5,1281 @@ ;; name in dgo: texture-h ;; dgos: GAME +(declare-type texture-page basic) +(declare-type texture-pool basic) +(declare-type fog-texture-work structure) +(declare-type adgif-shader structure) +(declare-type texture basic) +(declare-type texture-id uint32) +(declare-type texture-anim-array array) +(declare-type texture-anim structure) +(define-extern adgif-shader<-texture-simple! (function adgif-shader texture adgif-shader)) +(define-extern lookup-texture-by-id-fast (function texture-id texture)) +(define-extern *edit-shader* texture-id) +(define-extern adgif-shader-update! (function adgif-shader texture none)) +(declare-type texture-page-dir basic) +(define-extern texture-page-dir-inspect (function texture-page-dir symbol none)) +(define-extern *texture-pool* texture-pool) +(define-extern *fog-texture-work* fog-texture-work) +(define-extern *skull-gem-texture-anim-array* (texture-anim-array texture-anim)) + +;; +++tex-upload-mode +(defenum tex-upload-mode + (none -3) + (seg0-1 -2) + (seg0-1-2 -1) + (seg0 0) + (seg2 2) + ) +;; ---tex-upload-mode + + +;; +++link-test-flags +(defenum link-test-flags + :type uint32 + :bitfield #t + (needs-log-in 8) + (bit-9 9) + (backup-sprite-tex 10) ;; set when particle-setup-adgif fails texture lookup. + ) +;; ---link-test-flags + + ;; DECOMP BEGINS +(deftype texture-id (uint32) + "Unique identifier for a texture +as the tpage number and index of the texture within the tpage." + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) + ) + ) + + +(deftype texture-pool-segment (structure) + "A chunk of VRAM." + ((dest uint32) + (size uint32) + ) + :pack-me + :allow-misaligned + ) + + +(deftype texture-pool (basic) + "The manager for the VRAM." + ((top int32) + (cur int32) + (allocate-func (function texture-pool texture-page kheap int texture-page)) + (font-palette int32) + (segment texture-pool-segment 4 :inline) + (segment-near texture-pool-segment :inline :overlay-at (-> segment 0)) + (segment-common texture-pool-segment :inline :overlay-at (-> segment 1)) + (common-page texture-page 32) + (common-page-mask int32) + (update-sprites-flag symbol) + (update-flag symbol) + (texture-enable-user uint64) + (texture-enable-user-menu uint64) + (ids uint32 128) + ) + (:methods + (new (symbol type) _type_) + (initialize! (_type_) _type_) + (print-usage (_type_) _type_) + (setup-font-texture (_type_) none) + (allocate-defaults (_type_) none) + (login-level-textures (_type_ level int (pointer texture-id)) none) + (add-level-tpage-dma (_type_ level tpage-category bucket-id) none) + (allocate-vram-words! (_type_ int) int) + (allocate-segment (_type_ texture-pool-segment int) texture-pool-segment) + (unload-page (_type_ texture-page) none) + (get-common-page-slot-by-id (_type_ int) int) + (update-warp-and-hud (_type_) none) + (update-sprites (_type_) none) + (mark-hud-warp-sprite-dirty (_type_) none) + (lay-out-sprite-tex (_type_) none) + (lay-out-hud-tex (_type_) none) + (lay-out-warp-tex (_type_) none) + (clear-ids (_type_) none) + ) + ) + + +(deftype texture-mask (structure) + "Mask where each bit indicates if some part of a tpage is used, by a texture. +Additionally, the w component holds a minimum distance. The texture is only needed +if the distance to the object is smaller than this." + ((mask vector4w :inline) + (dist float :overlay-at (-> mask data 3)) + (long uint64 2 :overlay-at (-> mask data 0)) + (quad uint128 :overlay-at (-> mask data 0)) + ) + ) + + +(deftype texture-masks (structure) + "Grouping of three masks, corresponding to the 3 segments of the texture. +So mask 0 is needed if segment 0 of the texture is needed, etc..." + ((data texture-mask 3 :inline) + ) + ) + + +(deftype texture-masks-array (inline-array-class) + "Group of all texture-masks for a given tpage." + ((data texture-masks :dynamic) + ) + ) + + +(set! (-> texture-masks-array heap-base) (the-as uint 48)) + +(define *texture-masks* (the-as texture-masks #f)) + +(define *texture-masks-array* (the-as texture-masks-array #f)) + +(deftype texture (basic) + "Metadata for a texture." + ((w int16) + (h int16) + (num-mips uint8) + (tex1-control uint8) + (psm uint8) + (mip-shift uint8) + (clutpsm uint16) + (dest uint16 7) + (clutdest uint16) + (width uint8 7) + (name string) + (size uint32) + (uv-dist float) + (pad uint32 3) + (masks texture-masks :inline) + ) + ) + + +(deftype texture-page-segment (structure) + "Metadata for a 'segment' of a texture page. +Each texture page has 3 segments - smaller number segments have higher detail mips." + ((block-data pointer) + (size uint32) + (dest uint32) + ) + :pack-me + :allow-misaligned + ) + + +(defun texture-mip->segment ((arg0 int) (arg1 int)) + "Figure out which segment of a tpage a given mip level of a texture will be in. + arg0 is the mip level, arg1 is the total number of mips. + Higher mip level is lower detail." + (if (>= 2 arg1) + (+ (- -1 arg0) arg1) + (max 0 (- 2 arg0)) + ) + ) + +(deftype texture-page (basic) + "A collection of textures. There is a tpage per category per level. +These tpages are loaded from the DVD. +e.g.: prison tfrag is its own tpage. +The tpage has multiple textures, and 3 segments. +Lower number segments are larger and have hi-res versions of textures." + ((info file-info) + (name string) + (id uint32) + (length int32) + (mip0-size uint32) + (size uint32) + (segment texture-page-segment 3 :inline) + (dram-size uint32) + (vram-size uint32) + (pad uint32 14) + (data texture :dynamic) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) texture-page :replace) + (remove-data-from-heap (_type_ kheap) _type_) + (get-leftover-block-count (_type_ int int) int) + (relocate-dests! (_type_ int int) none) + (add-to-dma-buffer (_type_ dma-buffer tex-upload-mode) int) + (upload-now! (_type_ tex-upload-mode) none) + ) + ) + + +(deftype shader-ptr (uint32) + "A pointer to an adgif-shader, stored in bits 8-32. This allows them to fit into +an adgif shader easily." + ((first-8 uint8 :offset 0 :size 8) + (shader uint32 :offset 8 :size 24) + ) + ) + +(deftype texture-link (structure) + "An overlay structure containing a shader-ptr that points to the next adgif-shader +in a linked list." + ((next shader-ptr 1) + ) + ) + + +(deftype texture-page-dir-entry (structure) + "An entry for a texture in the texture-page-dir. +The texture-page-dir contains an entry for each tpage. +Each entry contains a reference to the tpage, and a linked list of shaders +using it." + ((length int16) + (status uint16) + (page texture-page) + (link texture-link) + ) + :pack-me + :allow-misaligned + ) + + +(deftype texture-page-dir (basic) + "The list of all texture pages. +This is static data loaded from the DVD at boot." + ((length int32) + (entries texture-page-dir-entry 1 :inline) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) + (unlink-shaders-in-heap (_type_ kheap) int) + ) + ) + +(deftype texture-relocate-later (basic) + "Unused in Jak 2, but metadata for postponing tpage copies until a second frame, +to have a smaller impact on frame times when loading." + ((memcpy symbol) + (dest uint32) + (source uint32) + (move uint32) + (entry texture-page-dir-entry) + (page texture-page) + ) + ) + + +(define *texture-relocate-later* (new 'global 'texture-relocate-later)) + +(set! (-> *texture-relocate-later* memcpy) #f) + +(define *texture-page-dir* (the-as texture-page-dir #f)) + +(deftype adgif-shader (structure) + "GS texturing/blending settings, called adgif-shader. +These are used by many different renderers and partially managed by the texture system. +For example, the texture system will automatically update tbp to point to the location +of the texture." + ((quad qword 5 :inline) + (prims gs-reg64 10 :overlay-at quad) + (reg-0 uint8 :overlay-at (-> quad 0 data 2)) + (reg-1 uint8 :overlay-at (-> prims 3)) + (reg-2 uint8 :overlay-at (-> prims 5)) + (reg-3 uint8 :overlay-at (-> prims 7)) + (reg-4 uint8 :overlay-at (-> prims 9)) + (tex0 uint64 :overlay-at (-> quad 0 data 0)) + (tex1 uint64 :overlay-at (-> prims 2)) + (miptbp1 uint64 :overlay-at (-> prims 4)) + (clamp uint64 :overlay-at (-> prims 6)) + (clamp-reg uint64 :overlay-at reg-3) + (alpha uint64 :overlay-at (-> prims 8)) + (link-test link-test-flags :overlay-at (-> quad 0 data 2)) + (texture-id texture-id :overlay-at reg-1) + (next shader-ptr :overlay-at reg-2) + ) + ) + + +(deftype adgif-shader-array (inline-array-class) + ((data adgif-shader :inline :dynamic) + ) + ) + + +(set! (-> adgif-shader-array heap-base) (the-as uint 80)) + +(deftype texture-base (structure) + "Metadata about an area of VRAM set aside for fancy dynamic texture effects +(sky, eye, etc)." + ((vram-page uint32) + (vram-block uint32) + (vram-word uint32) + ) + ) + + +(define ct32-24-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +(define mz32-24-block-table (new 'static 'boxed-array :type int32 + 16 + 17 + 20 + 21 + 0 + 1 + 4 + 5 + 18 + 19 + 22 + 23 + 2 + 3 + 6 + 7 + 24 + 25 + 28 + 29 + 8 + 9 + 12 + 13 + 26 + 27 + 30 + 31 + 10 + 11 + 14 + 15 + ) + ) + +(define ct16-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +(define ct16s-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 16 + 18 + 1 + 3 + 17 + 19 + 8 + 10 + 24 + 26 + 9 + 11 + 25 + 27 + 4 + 6 + 20 + 22 + 5 + 7 + 21 + 23 + 12 + 14 + 28 + 30 + 13 + 15 + 29 + 31 + ) + ) + +(define mz16-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + ) + ) + +(define mz16s-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 0 + 2 + 17 + 19 + 1 + 3 + 24 + 26 + 8 + 10 + 25 + 27 + 9 + 11 + 20 + 22 + 4 + 6 + 21 + 23 + 5 + 7 + 28 + 30 + 12 + 14 + 29 + 31 + 13 + 15 + ) + ) + +(define mt8-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +(define mt4-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +(deftype texture-page-translate-item (structure) + ((bucket bucket-id) + (level-index uint32) + (level-texture-page tpage-category-u32) + (texture-user texture-enable-mask-u32) + ) + ) + + +(define *texture-page-translate* (new 'static 'boxed-array :type texture-page-translate-item + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-lcom-sky-pre) + :level-index #xa + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket10) + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket22) + :level-index #x1 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket34) + :level-index #x2 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket46) + :level-index #x3 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket58) + :level-index #x4 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket70) + :level-index #x5 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket82) + :level-index #x6 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket94) + :level-index #x7 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket106) + :level-index #x8 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket118) + :level-index #x9 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket130) + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket140) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket150) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket160) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket170) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket180) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket190) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket200) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket210) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket220) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket230) + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket241) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket252) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket263) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket274) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket285) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket296) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket307) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket318) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket329) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket340) + :level-index #xa + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket345) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket351) + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket356) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket361) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket366) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket371) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket376) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket381) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket386) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket391) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket396) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket401) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket406) + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket411) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket416) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket421) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket426) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket431) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket436) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket441) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket446) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket451) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket456) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket461) + :level-index #xa + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket463) + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket473) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket483) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket493) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket503) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket513) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket523) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket533) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket543) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket553) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket563) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket580) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex7) + ) + ) + ) + +(define *eyes-texture-base* (new 'static 'texture-base)) + +(define *skull-gem-texture-base* (new 'static 'texture-base)) + +(define *ocean-texture-base* (new 'static 'texture-base)) + +(define *ocean-envmap-texture-base* (new 'static 'texture-base)) + +(define *grey-scale-base* (new 'static 'texture-base)) + +(define *map-texture-base* (new 'static 'texture-base)) + +(define-extern texture-page-default-allocate (function texture-pool texture-page kheap int texture-page)) +(define-extern texture-page-login (function texture-id (function texture-pool texture-page kheap int texture-page) kheap texture-page-dir-entry)) +(define-extern lookup-texture-by-id (function texture-id texture)) diff --git a/goal_src/jak3/engine/gfx/vu1-user-h.gc b/goal_src/jak3/engine/gfx/vu1-user-h.gc index 1d296a11ec6..911715df993 100644 --- a/goal_src/jak3/engine/gfx/vu1-user-h.gc +++ b/goal_src/jak3/engine/gfx/vu1-user-h.gc @@ -8,12 +8,607 @@ ;; +++tpage-category (defenum tpage-category :type int8 + (tpage-cat0 0) + (tpage-cat1 1) + (tpage-cat2 2) + (tpage-cat3 3) + (tpage-cat4 4) + (tpage-cat5 5) + (tpage-cat6 6) + (tpage-cat7 7) + (tpage-cat8 8) + (sky 9) + (tpage-cat10 10) ) ;; ---tpage-category ;; +++bucket-id (defenum bucket-id :type int32 + (bucket0 0) + (bucket1 1) + (bucket2 2) + (bucket3 3) + (tex-lcom-sky-pre 4) + (bucket5 5) + (bucket6 6) + (bucket7 7) + (bucket8 8) + (bucket9 9) + (bucket10 10) + (bucket11 11) + (bucket12 12) + (bucket13 13) + (bucket14 14) + (bucket15 15) + (bucket16 16) + (bucket17 17) + (bucket18 18) + (bucket19 19) + (bucket20 20) + (bucket21 21) + (bucket22 22) + (bucket23 23) + (bucket24 24) + (bucket25 25) + (bucket26 26) + (bucket27 27) + (bucket28 28) + (bucket29 29) + (bucket30 30) + (bucket31 31) + (bucket32 32) + (bucket33 33) + (bucket34 34) + (bucket35 35) + (bucket36 36) + (bucket37 37) + (bucket38 38) + (bucket39 39) + (bucket40 40) + (bucket41 41) + (bucket42 42) + (bucket43 43) + (bucket44 44) + (bucket45 45) + (bucket46 46) + (bucket47 47) + (bucket48 48) + (bucket49 49) + (bucket50 50) + (bucket51 51) + (bucket52 52) + (bucket53 53) + (bucket54 54) + (bucket55 55) + (bucket56 56) + (bucket57 57) + (bucket58 58) + (bucket59 59) + (bucket60 60) + (bucket61 61) + (bucket62 62) + (bucket63 63) + (bucket64 64) + (bucket65 65) + (bucket66 66) + (bucket67 67) + (bucket68 68) + (bucket69 69) + (bucket70 70) + (bucket71 71) + (bucket72 72) + (bucket73 73) + (bucket74 74) + (bucket75 75) + (bucket76 76) + (bucket77 77) + (bucket78 78) + (bucket79 79) + (bucket80 80) + (bucket81 81) + (bucket82 82) + (bucket83 83) + (bucket84 84) + (bucket85 85) + (bucket86 86) + (bucket87 87) + (bucket88 88) + (bucket89 89) + (bucket90 90) + (bucket91 91) + (bucket92 92) + (bucket93 93) + (bucket94 94) + (bucket95 95) + (bucket96 96) + (bucket97 97) + (bucket98 98) + (bucket99 99) + (bucket100 100) + (bucket101 101) + (bucket102 102) + (bucket103 103) + (bucket104 104) + (bucket105 105) + (bucket106 106) + (bucket107 107) + (bucket108 108) + (bucket109 109) + (bucket110 110) + (bucket111 111) + (bucket112 112) + (bucket113 113) + (bucket114 114) + (bucket115 115) + (bucket116 116) + (bucket117 117) + (bucket118 118) + (bucket119 119) + (bucket120 120) + (bucket121 121) + (bucket122 122) + (bucket123 123) + (bucket124 124) + (bucket125 125) + (bucket126 126) + (bucket127 127) + (bucket128 128) + (bucket129 129) + (bucket130 130) + (bucket131 131) + (bucket132 132) + (bucket133 133) + (bucket134 134) + (bucket135 135) + (bucket136 136) + (bucket137 137) + (bucket138 138) + (bucket139 139) + (bucket140 140) + (bucket141 141) + (bucket142 142) + (bucket143 143) + (bucket144 144) + (bucket145 145) + (bucket146 146) + (bucket147 147) + (bucket148 148) + (bucket149 149) + (bucket150 150) + (bucket151 151) + (bucket152 152) + (bucket153 153) + (bucket154 154) + (bucket155 155) + (bucket156 156) + (bucket157 157) + (bucket158 158) + (bucket159 159) + (bucket160 160) + (bucket161 161) + (bucket162 162) + (bucket163 163) + (bucket164 164) + (bucket165 165) + (bucket166 166) + (bucket167 167) + (bucket168 168) + (bucket169 169) + (bucket170 170) + (bucket171 171) + (bucket172 172) + (bucket173 173) + (bucket174 174) + (bucket175 175) + (bucket176 176) + (bucket177 177) + (bucket178 178) + (bucket179 179) + (bucket180 180) + (bucket181 181) + (bucket182 182) + (bucket183 183) + (bucket184 184) + (bucket185 185) + (bucket186 186) + (bucket187 187) + (bucket188 188) + (bucket189 189) + (bucket190 190) + (bucket191 191) + (bucket192 192) + (bucket193 193) + (bucket194 194) + (bucket195 195) + (bucket196 196) + (bucket197 197) + (bucket198 198) + (bucket199 199) + (bucket200 200) + (bucket201 201) + (bucket202 202) + (bucket203 203) + (bucket204 204) + (bucket205 205) + (bucket206 206) + (bucket207 207) + (bucket208 208) + (bucket209 209) + (bucket210 210) + (bucket211 211) + (bucket212 212) + (bucket213 213) + (bucket214 214) + (bucket215 215) + (bucket216 216) + (bucket217 217) + (bucket218 218) + (bucket219 219) + (bucket220 220) + (bucket221 221) + (bucket222 222) + (bucket223 223) + (bucket224 224) + (bucket225 225) + (bucket226 226) + (bucket227 227) + (bucket228 228) + (bucket229 229) + (bucket230 230) + (bucket231 231) + (bucket232 232) + (bucket233 233) + (bucket234 234) + (bucket235 235) + (bucket236 236) + (bucket237 237) + (bucket238 238) + (bucket239 239) + (bucket240 240) + (bucket241 241) + (bucket242 242) + (bucket243 243) + (bucket244 244) + (bucket245 245) + (bucket246 246) + (bucket247 247) + (bucket248 248) + (bucket249 249) + (bucket250 250) + (bucket251 251) + (bucket252 252) + (bucket253 253) + (bucket254 254) + (bucket255 255) + (bucket256 256) + (bucket257 257) + (bucket258 258) + (bucket259 259) + (bucket260 260) + (bucket261 261) + (bucket262 262) + (bucket263 263) + (bucket264 264) + (bucket265 265) + (bucket266 266) + (bucket267 267) + (bucket268 268) + (bucket269 269) + (bucket270 270) + (bucket271 271) + (bucket272 272) + (bucket273 273) + (bucket274 274) + (bucket275 275) + (bucket276 276) + (bucket277 277) + (bucket278 278) + (bucket279 279) + (bucket280 280) + (bucket281 281) + (bucket282 282) + (bucket283 283) + (bucket284 284) + (bucket285 285) + (bucket286 286) + (bucket287 287) + (bucket288 288) + (bucket289 289) + (bucket290 290) + (bucket291 291) + (bucket292 292) + (bucket293 293) + (bucket294 294) + (bucket295 295) + (bucket296 296) + (bucket297 297) + (bucket298 298) + (bucket299 299) + (bucket300 300) + (bucket301 301) + (bucket302 302) + (bucket303 303) + (bucket304 304) + (bucket305 305) + (bucket306 306) + (bucket307 307) + (bucket308 308) + (bucket309 309) + (bucket310 310) + (bucket311 311) + (bucket312 312) + (bucket313 313) + (bucket314 314) + (bucket315 315) + (bucket316 316) + (bucket317 317) + (bucket318 318) + (bucket319 319) + (bucket320 320) + (bucket321 321) + (bucket322 322) + (bucket323 323) + (bucket324 324) + (bucket325 325) + (bucket326 326) + (bucket327 327) + (bucket328 328) + (bucket329 329) + (bucket330 330) + (bucket331 331) + (bucket332 332) + (bucket333 333) + (bucket334 334) + (bucket335 335) + (bucket336 336) + (bucket337 337) + (bucket338 338) + (bucket339 339) + (bucket340 340) + (bucket341 341) + (bucket342 342) + (bucket343 343) + (bucket344 344) + (bucket345 345) + (bucket346 346) + (bucket347 347) + (bucket348 348) + (bucket349 349) + (bucket350 350) + (bucket351 351) + (bucket352 352) + (bucket353 353) + (bucket354 354) + (bucket355 355) + (bucket356 356) + (bucket357 357) + (bucket358 358) + (bucket359 359) + (bucket360 360) + (bucket361 361) + (bucket362 362) + (bucket363 363) + (bucket364 364) + (bucket365 365) + (bucket366 366) + (bucket367 367) + (bucket368 368) + (bucket369 369) + (bucket370 370) + (bucket371 371) + (bucket372 372) + (bucket373 373) + (bucket374 374) + (bucket375 375) + (bucket376 376) + (bucket377 377) + (bucket378 378) + (bucket379 379) + (bucket380 380) + (bucket381 381) + (bucket382 382) + (bucket383 383) + (bucket384 384) + (bucket385 385) + (bucket386 386) + (bucket387 387) + (bucket388 388) + (bucket389 389) + (bucket390 390) + (bucket391 391) + (bucket392 392) + (bucket393 393) + (bucket394 394) + (bucket395 395) + (bucket396 396) + (bucket397 397) + (bucket398 398) + (bucket399 399) + (bucket400 400) + (bucket401 401) + (bucket402 402) + (bucket403 403) + (bucket404 404) + (bucket405 405) + (bucket406 406) + (bucket407 407) + (bucket408 408) + (bucket409 409) + (bucket410 410) + (bucket411 411) + (bucket412 412) + (bucket413 413) + (bucket414 414) + (bucket415 415) + (bucket416 416) + (bucket417 417) + (bucket418 418) + (bucket419 419) + (bucket420 420) + (bucket421 421) + (bucket422 422) + (bucket423 423) + (bucket424 424) + (bucket425 425) + (bucket426 426) + (bucket427 427) + (bucket428 428) + (bucket429 429) + (bucket430 430) + (bucket431 431) + (bucket432 432) + (bucket433 433) + (bucket434 434) + (bucket435 435) + (bucket436 436) + (bucket437 437) + (bucket438 438) + (bucket439 439) + (bucket440 440) + (bucket441 441) + (bucket442 442) + (bucket443 443) + (bucket444 444) + (bucket445 445) + (bucket446 446) + (bucket447 447) + (bucket448 448) + (bucket449 449) + (bucket450 450) + (bucket451 451) + (bucket452 452) + (bucket453 453) + (bucket454 454) + (bucket455 455) + (bucket456 456) + (bucket457 457) + (bucket458 458) + (bucket459 459) + (bucket460 460) + (bucket461 461) + (bucket462 462) + (bucket463 463) + (bucket464 464) + (bucket465 465) + (bucket466 466) + (bucket467 467) + (bucket468 468) + (bucket469 469) + (bucket470 470) + (bucket471 471) + (bucket472 472) + (bucket473 473) + (bucket474 474) + (bucket475 475) + (bucket476 476) + (bucket477 477) + (bucket478 478) + (bucket479 479) + (bucket480 480) + (bucket481 481) + (bucket482 482) + (bucket483 483) + (bucket484 484) + (bucket485 485) + (bucket486 486) + (bucket487 487) + (bucket488 488) + (bucket489 489) + (bucket490 490) + (bucket491 491) + (bucket492 492) + (bucket493 493) + (bucket494 494) + (bucket495 495) + (bucket496 496) + (bucket497 497) + (bucket498 498) + (bucket499 499) + (bucket500 500) + (bucket501 501) + (bucket502 502) + (bucket503 503) + (bucket504 504) + (bucket505 505) + (bucket506 506) + (bucket507 507) + (bucket508 508) + (bucket509 509) + (bucket510 510) + (bucket511 511) + (bucket512 512) + (bucket513 513) + (bucket514 514) + (bucket515 515) + (bucket516 516) + (bucket517 517) + (bucket518 518) + (bucket519 519) + (bucket520 520) + (bucket521 521) + (bucket522 522) + (bucket523 523) + (bucket524 524) + (bucket525 525) + (bucket526 526) + (bucket527 527) + (bucket528 528) + (bucket529 529) + (bucket530 530) + (bucket531 531) + (bucket532 532) + (bucket533 533) + (bucket534 534) + (bucket535 535) + (bucket536 536) + (bucket537 537) + (bucket538 538) + (bucket539 539) + (bucket540 540) + (bucket541 541) + (bucket542 542) + (bucket543 543) + (bucket544 544) + (bucket545 545) + (bucket546 546) + (bucket547 547) + (bucket548 548) + (bucket549 549) + (bucket550 550) + (bucket551 551) + (bucket552 552) + (bucket553 553) + (bucket554 554) + (bucket555 555) + (bucket556 556) + (bucket557 557) + (bucket558 558) + (bucket559 559) + (bucket560 560) + (bucket561 561) + (bucket562 562) + (bucket563 563) + (bucket564 564) + (bucket565 565) + (bucket566 566) + (bucket567 567) + (bucket568 568) + (bucket569 569) + (bucket570 570) + (bucket571 571) + (bucket572 572) + (bucket573 573) + (bucket574 574) + (bucket575 575) + (bucket576 576) + (bucket577 577) + (bucket578 578) + (bucket579 579) + (bucket580 580) + (bucket581 581) + (bucket582 582) + (bucket583 583) (debug-no-zbuf2 584) ) ;; ---bucket-id @@ -64,6 +659,48 @@ ) ;; ---vu1-renderer-mask +;; +++tpage-category-u32 +(defenum tpage-category-u32 + :type uint32 + :copy-entries tpage-category + ) +;; ---tpage-category-u32 + + +;; +++texture-enable-mask +(defenum texture-enable-mask + :type uint64 + :bitfield #t + (tex0 0) + (tex1 1) + (tex2 2) + (tex3 3) + (tex4 4) + (tex5 5) + (tex6 6) + (tex7 7) + (sky 8) + (tex9 9) + (tex10 10) + (tex11 11) + (tex12 12) + (tex13 13) + (tex14 14) + (tex15 15) + (tex16 16) + ) +;; ---texture-enable-mask + + +;; +++texture-enable-mask-u32 +(defenum texture-enable-mask-u32 + :type uint32 + :bitfield #t + :copy-entries texture-enable-mask + ) +;; ---texture-enable-mask-u32 + + ;; DECOMP BEGINS (deftype dma-foreground-sink (basic) diff --git a/goal_src/jak3/engine/level/level-h.gc b/goal_src/jak3/engine/level/level-h.gc index 0bee782f4c4..df52937289c 100644 --- a/goal_src/jak3/engine/level/level-h.gc +++ b/goal_src/jak3/engine/level/level-h.gc @@ -5,5 +5,113 @@ ;; name in dgo: level-h ;; dgos: GAME +;; +++vis-info-flag +(defenum vis-info-flag + :type uint32 + :bitfield #t + (dummy0 0) + (dummy1 1) + (dummy2 2) + (dummy3 3) + (dummy4 4) + (dummy5 5) + (dummy6 6) + (dummy7 7) + (dummy8 8) + (dummy9 9) + (dummy10 10) + (dummy11 11) + (dummy12 12) + (dummy13 13) + (dummy14 14) + (dummy15 15) + (dummy16 16) + (dummy17 17) + (dummy18 18) + (dummy19 19) + (dummy20 20) + (dummy21 21) + (dummy22 22) + (dummy23 23) + (dummy24 24) + (dummy25 25) + (dummy26 26) + (dummy27 27) + (dummy28 28) + (in-iop 29) + (loading 30) + (vis-valid 31) + ) +;; ---vis-info-flag + + +;; +++load-buffer-mode +(defenum load-buffer-mode + :type uint32 + (small-edge 0) + (small-center 1) + (medium 2) + (large 3) + (borrow 4) + (ten 10) + ) +;; ---load-buffer-mode + + +;; +++task-mask +(defenum task-mask + :type uint32 + :bitfield #t + (task0 0) + (task1 1) + (task2 2) + (task3 3) + (task4 4) + (task5 5) + (task6 6) + (task7 7) + (done 8) + (dummy0 9) + (dummy1 10) + (vehicle 11) + (special 12) + (primary0 13) + (ctywide 14) + (never 15) + (movie0 16) + (movie1 17) + (movie2 18) + ) +;; ---task-mask + + +;; +++bigmap-id +(defenum bigmap-id + :type uint32 + (bigmap-id-0 0) + (bigmap-id-1 1) + (bigmap-id-2 2) + (bigmap-id-3 3) + (bigmap-id-4 4) + (bigmap-id-5 5) + (bigmap-id-6 6) + (bigmap-id-7 7) + (bigmap-id-8 8) + (bigmap-id-9 9) + (bigmap-id-10 10) + (bigmap-id-11 11) + (bigmap-id-12 12) + (bigmap-id-13 13) + (bigmap-id-14 14) + (bigmap-id-15 15) + (bigmap-id-16 16) + (bigmap-id-17 17) + (bigmap-id-18 18) + (bigmap-id-19 19) + (bigmap-id-20 20) + ) +;; ---bigmap-id + + ;; DECOMP BEGINS diff --git a/goal_src/jak3/engine/load/loader-h.gc b/goal_src/jak3/engine/load/loader-h.gc index 85a5fd3894d..ef2ac73ed85 100644 --- a/goal_src/jak3/engine/load/loader-h.gc +++ b/goal_src/jak3/engine/load/loader-h.gc @@ -5,5 +5,200 @@ ;; name in dgo: loader-h ;; dgos: GAME +(declare-type spool-anim basic) +(declare-type art-joint-anim art-element) +(declare-type external-art-buffer basic) +(declare-type process-drawable process) +(define-extern external-art-buffer-init (function external-art-buffer int)) +(define-extern ja-abort-spooled-anim (function spool-anim art-joint-anim int int :behavior process-drawable)) +(declare-type art basic) +(declare-type art-group art) +(define-extern *stack-top* pointer) + ;; DECOMP BEGINS +(deftype load-dir (basic) + "`load-dir` is an array of references to loaded things. +It's used to handle art groups that are loaded as part of a level load." + ((lev level) + (string-array (array string)) + (data-array (array basic)) + ) + (:methods + (new (symbol type int level) _type_) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) + (set-loaded-art (_type_ art-group) art-group) + ) + ) + +(deftype load-dir-art-group (load-dir) + "Specialization of load-dir for `art-group`s." + ((art-group-array (array art-group) :overlay-at data-array) + ) + (:methods + (new (symbol type int level) _type_) + ) + ) + +(defmethod new load-dir ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((s4-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s4-0 lev) arg1) + (set! (-> s4-0 string-array) + (the-as (array string) ((method-of-type array new) allocation array string arg0)) + ) + (set! (-> s4-0 string-array length) 0) + (set! (-> s4-0 data-array) (the-as (array basic) ((method-of-type array new) allocation array basic arg0))) + (set! (-> s4-0 data-array length) 0) + s4-0 + ) + ) + +;; WARN: Return type mismatch load-dir vs load-dir-art-group. +(defmethod new load-dir-art-group ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((v0-0 ((method-of-type load-dir new) allocation type-to-make arg0 arg1))) + (set! (-> v0-0 data-array content-type) art-group) + (the-as load-dir-art-group v0-0) + ) + ) + +(deftype external-art-buffer (basic) + "An `external-art-buffer` is a buffer that streamed files use." + ((index int32) + (other external-art-buffer) + (status symbol) + (locked? symbol) + (login? symbol) + (frame-lock symbol) + (init-heap (function external-art-buffer object)) + (heap kheap :inline) + (pending-load-file string) + (pending-load-file-part int32) + (pending-load-file-owner handle) + (pending-load-file-priority float) + (load-file string) + (load-file-part int32) + (load-file-owner handle) + (load-file-priority float) + (buf pointer) + (len int32) + (art-group art-group) + (art-data uint32 :overlay-at art-group) + ) + (:methods + (new (symbol type int function symbol) _type_) + (set-pending-file (_type_ string int handle float) int) + (update (_type_) int) + (inactive? (_type_) symbol) + (file-status (_type_ string int) symbol) + (link-file (_type_ art-group) art-group) + (unlink-file (_type_ art-group) int) + (unlock! (_type_) int) + ) + ) + + +(defmethod new external-art-buffer ((allocation symbol) (type-to-make type) (arg0 int) (arg1 function) (arg2 symbol)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 index) arg0) + (set! (-> v0-0 init-heap) (the-as (function external-art-buffer object) arg1)) + (set! (-> v0-0 login?) arg2) + (set! (-> v0-0 load-file) #f) + (set! (-> v0-0 load-file-part) -1) + (set! (-> v0-0 load-file-owner) (the-as handle #f)) + (set! (-> v0-0 load-file-priority) 100000000.0) + (set! (-> v0-0 pending-load-file) #f) + (set! (-> v0-0 pending-load-file-part) -1) + (set! (-> v0-0 pending-load-file-owner) (the-as handle #f)) + (set! (-> v0-0 pending-load-file-priority) 100000000.0) + (set! (-> v0-0 art-group) #f) + (set! (-> v0-0 status) 'initialize) + (set! (-> v0-0 locked?) #f) + (set! (-> v0-0 other) #f) + v0-0 + ) + ) + +(deftype spool-anim (basic) + "A `spool-anim` is metadata for an animation that will be loaded in chunks +to a pair of external-art-buffers." + ((name string :offset 16) + (anim-name string) + (buffer external-art-buffer :overlay-at anim-name) + (parts int32) + (hint-id int32 :overlay-at parts) + (priority float) + (owner handle) + (command-list pair) + ) + ) + + +(deftype external-art-control (basic) + "The `external-art-control` manages loading chunks from `spool-anim`s to `external-art-buffer`." + ((buffer external-art-buffer 2) + (rec spool-anim 3 :inline) + (spool-lock handle) + (reserve-buffer external-art-buffer) + (reserve-buffer-count int16) + (dma-reserve-buffer-count int16) + (active-stream string) + (queue-stream (array spool-anim)) + (frame-mask uint32) + (dma-reserve-heap kheap :inline) + ) + (:methods + (new (symbol type) _type_) + (update (_type_ symbol) int) + (clear-rec (_type_) int) + (spool-push (_type_ string int process float) int) + (file-status (_type_ string int) symbol) + (reserve-alloc (_type_) kheap) + (reserve-free (_type_ kheap) int) + (none-reserved? (_type_) symbol) + ) + ) + + +(defmethod new external-art-control ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (dotimes (s4-0 2) + (set! (-> gp-0 buffer s4-0) + ((method-of-type external-art-buffer new) allocation external-art-buffer s4-0 external-art-buffer-init #t) + ) + ) + (set! (-> gp-0 buffer 0 other) (-> gp-0 buffer 1)) + (set! (-> gp-0 buffer 1 other) (-> gp-0 buffer 0)) + (dotimes (v1-9 3) + (set! (-> gp-0 rec v1-9 name) #f) + (set! (-> gp-0 rec v1-9 priority) 100000000.0) + (set! (-> gp-0 rec v1-9 owner) (the-as handle #f)) + ) + (set! (-> gp-0 spool-lock) (the-as handle #f)) + (set! (-> gp-0 reserve-buffer) #f) + (set! (-> gp-0 active-stream) #f) + (set! (-> gp-0 queue-stream) (new 'global 'boxed-array spool-anim 4)) + (dotimes (s5-1 (-> gp-0 queue-stream allocated-length)) + (set! (-> gp-0 queue-stream s5-1) (new 'global 'spool-anim)) + ) + (set! (-> gp-0 queue-stream length) 0) + gp-0 + ) + ) + +(deftype subtitle-range (basic) + ((start-frame float) + (end-frame float) + (message basic 12) + ) + ) + + +(deftype subtitle-image (basic) + ((width uint16) + (height uint16) + (palette rgba 16 :offset 16) + (data uint8 :dynamic) + ) + ) + +(define-extern *art-control* external-art-control) \ No newline at end of file diff --git a/goal_src/jak3/engine/util/capture-h.gc b/goal_src/jak3/engine/util/capture-h.gc index 41aadb43014..5baeeb635e1 100644 --- a/goal_src/jak3/engine/util/capture-h.gc +++ b/goal_src/jak3/engine/util/capture-h.gc @@ -7,3 +7,44 @@ ;; DECOMP BEGINS +;; this file is debug only +(declare-file (debug)) + +(deftype gs-store-image-packet (structure) + ((vifcode vif-tag 4) + (giftag uint128) + (bitbltbuf uint64) + (bitbltbuf-addr uint64) + (trxpos uint64) + (trxpos-addr uint64) + (trxreg uint64) + (trxreg-addr uint64) + (finish uint64) + (finish-addr uint64) + (trxdir uint64) + (trxdir-addr uint64) + ) + ) + + +(deftype screen-shot-work (structure) + ((count int16) + (size int16) + (name string) + (highres-enable symbol) + (hud-enable symbol) + ) + ) + + +(define *screen-shot-work* (new 'global 'screen-shot-work)) + +(set! (-> *screen-shot-work* count) -1) + +(set! (-> *screen-shot-work* size) -1) + +(set! (-> *screen-shot-work* highres-enable) #f) + +(set! (-> *screen-shot-work* hud-enable) #f) + +(define *image-name* (new 'global 'string 32 (the-as string #f))) diff --git a/goal_src/jak3/kernel-defs.gc b/goal_src/jak3/kernel-defs.gc index cba19ccf546..4c909711e88 100644 --- a/goal_src/jak3/kernel-defs.gc +++ b/goal_src/jak3/kernel-defs.gc @@ -27,16 +27,18 @@ (defenum language-enum - :type int64 + :type uint8 (english 0) (french 1) (german 2) (spanish 3) (italian 4) + (commentary 5) (japanese 6) (korean 7) (russian 8) (portuguese 9) + (dutch 10) (uk-english 11) ) diff --git a/test/decompiler/reference/jak3/engine/engine/connect_REF.gc b/test/decompiler/reference/jak3/engine/engine/connect_REF.gc new file mode 100644 index 00000000000..a4a5c3ec050 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/engine/connect_REF.gc @@ -0,0 +1,856 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type connectable +(deftype connectable (structure) + ((next0 connectable) + (prev0 connectable) + (next1 connectable) + (prev1 connectable) + ) + ) + +;; definition for method 3 of type connectable +(defmethod inspect ((this connectable)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'connectable) + (format #t "~1Tnext0: ~`connectable`P~%" (-> this next0)) + (format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0)) + (format #t "~1Tnext1: ~`connectable`P~%" (-> this next1)) + (format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1)) + (label cfg-4) + this + ) + +;; definition of type connection +(deftype connection (connectable) + "This is the actual data for the connection. +It may be used in multiple ways, but the most common is to use `param0` as a function. +It receives `param1`, `param2`, `param3`, and the engine as the arguments. +In some cases, the return value is checked for `'dead`." + ((param0 basic) + (param1 basic) + (param2 int32) + (param3 int32) + (quad uint128 2 :overlay-at next0) + ) + (:methods + (get-engine (connection) engine) + (get-process (connection) process) + (belongs-to-engine? (connection engine) symbol) + (belongs-to-process? (connection process) symbol) + (move-to-dead (connection) connection) + ) + ) + +;; definition for method 3 of type connection +(defmethod inspect ((this connection)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'connection) + (format #t "~1Tnext0: ~`connectable`P~%" (-> this next0)) + (format #t "~1Tprev0: ~`connectable`P~%" (-> this prev0)) + (format #t "~1Tnext1: ~`connectable`P~%" (-> this next1)) + (format #t "~1Tprev1: ~`connectable`P~%" (-> this prev1)) + (format #t "~1Tparam0: ~A~%" (-> this param0)) + (format #t "~1Tparam1: ~A~%" (-> this param1)) + (format #t "~1Tparam2: ~A~%" (-> this param2)) + (format #t "~1Tparam3: ~A~%" (-> this param3)) + (format #t "~1Tquad[2] @ #x~X~%" (&-> this next0)) + (label cfg-4) + this + ) + +;; definition of type engine +(deftype engine (basic) + "An engine is a collection of connections. +You can iterate over the connections, or run them. +The engine is dynamically sized based on how many connections it can store. + +New for Jak 2: You can use a child class of [[connection]]." + ((name symbol) + (engine-time time-frame :offset 16) + (allocated-length int16 :offset 10) + (length int16 :offset 8) + (element-type type :offset 12) + (alive-list connectable :inline) + (alive-list-end connectable :inline) + (dead-list connectable :inline) + (dead-list-end connectable :inline) + (data connection :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (inspect-all-connections (engine) engine) + (apply-to-connections (engine (function connectable none)) int) + (apply-to-connections-reverse (engine (function connectable none)) int) + (execute-connections (engine object) int) + (execute-connections-and-move-to-dead (engine object) int) + (execute-connections-if-needed (engine object) int) + (add-connection (engine process object object object object) connection) + (remove-from-process (engine process) int) + (remove-matching (engine (function connection engine symbol)) int) + (remove-all (engine) int) + (remove-by-param0 (engine object) int) + (remove-by-param1 (engine int) int) + (remove-by-param2 (engine int) int) + (get-first-connectable (engine) connectable) + (get-last-connectable (engine) connectable) + (get-next-connectable (_type_ connectable) connectable) + (get-prev-connectable (_type_ connectable) connectable) + ) + ) + +;; definition for method 12 of type connection +(defmethod belongs-to-process? ((this connection) (arg0 process)) + "Does this connection belong to the given process?" + (= arg0 (get-process this)) + ) + +;; definition for method 2 of type connection +(defmethod print ((this connection)) + (format + #t + "#" + (-> this param0) + (-> this param1) + (-> this param2) + (-> this param3) + this + ) + this + ) + +;; definition for method 9 of type connection +;; WARN: Return type mismatch pointer vs engine. +(defmethod get-engine ((this connection)) + "Get the engine for this connection. This must be used on a live connection." + (while (-> (the-as connectable this) prev0) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev0))) + ) + (the-as engine (&+ (the-as pointer this) -28)) + ) + +;; definition for method 10 of type connection +;; WARN: Return type mismatch pointer vs process. +(defmethod get-process ((this connection)) + "Get the process for this connection." + (while (-> (the-as connectable this) prev1) + (nop!) + (nop!) + (set! this (the-as connection (-> (the-as connectable this) prev1))) + ) + (the-as process (&+ (the-as pointer this) -108)) + ) + +;; definition for method 11 of type connection +(defmethod belongs-to-engine? ((this connection) (arg0 engine)) + "Check to see if this connection is located in the data section of the engine. + This works on dead or alive connections." + (and (< (the-as int arg0) (the-as int this)) + (< (the-as int this) (the-as int (&+ + (&+ (the-as pointer arg0) (-> arg0 type size)) + (* (-> arg0 allocated-length) (the-as int (-> arg0 element-type size))) + ) + ) + ) + ) + ) + +;; definition for method 22 of type engine +(defmethod get-first-connectable ((this engine)) + (-> this alive-list next0) + ) + +;; definition for method 23 of type engine +(defmethod get-last-connectable ((this engine)) + (-> this alive-list-end) + ) + +;; definition for method 24 of type engine +(defmethod get-next-connectable ((this engine) (arg0 connectable)) + (-> arg0 next0) + ) + +;; definition for method 25 of type engine +(defmethod get-prev-connectable ((this engine) (arg0 connectable)) + (-> arg0 prev0) + ) + +;; definition for method 0 of type engine +(defmethod new engine ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 + (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list next0) (-> v0-0 alive-list-end)) + (set! (-> v0-0 alive-list prev0) #f) + (set! (-> v0-0 alive-list next1) #f) + (set! (-> v0-0 alive-list prev1) #f) + (set! (-> v0-0 alive-list-end next0) #f) + (set! (-> v0-0 alive-list-end prev0) (-> v0-0 alive-list)) + (set! (-> v0-0 alive-list-end next1) #f) + (set! (-> v0-0 alive-list-end prev1) #f) + (set! (-> v0-0 dead-list next0) (the-as connectable (-> v0-0 data))) + (set! (-> v0-0 dead-list prev0) #f) + (set! (-> v0-0 dead-list next1) #f) + (set! (-> v0-0 dead-list prev1) #f) + (set! (-> v0-0 dead-list-end next0) #f) + (set! (-> v0-0 dead-list-end prev0) + (the-as connectable (+ (+ (* (the-as uint (+ arg1 -1)) (-> arg2 size)) 92) (the-as uint v0-0))) + ) + (set! (-> v0-0 dead-list-end next1) #f) + (set! (-> v0-0 dead-list-end prev1) #f) + (let ((v1-9 (the-as object (-> v0-0 data)))) + (set! (-> v0-0 data 0 prev0) (-> v0-0 dead-list)) + (set! (-> v0-0 data 0 next0) (the-as connectable (&+ (the-as pointer v1-9) (-> arg2 size)))) + (let ((v1-10 (the-as object (&+ (the-as pointer v1-9) (-> arg2 size))))) + (let ((a0-6 1) + (a1-3 (+ arg1 -2)) + ) + (while (>= a1-3 a0-6) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + (set! (-> (the-as (pointer int32) v1-10)) (&+ (the-as pointer v1-10) (-> arg2 size))) + (set! v1-10 (&+ (the-as pointer v1-10) (-> arg2 size))) + (+! a0-6 1) + ) + ) + (set! (-> (the-as connectable v1-10) prev0) + (the-as connectable (&- (the-as pointer v1-10) (the-as uint (-> arg2 size)))) + ) + (set! (-> (the-as (pointer int32) v1-10)) (-> v0-0 dead-list-end)) + ) + ) + v0-0 + ) + ) + +;; definition for method 2 of type engine +(defmethod print ((this engine)) + (format #t "#<~A ~A @ #x~X>" (-> this type) (-> this name) this) + this + ) + +;; definition for method 3 of type engine +(defmethod inspect ((this engine)) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~Tname: ~A~%" (-> this name)) + (format #t "~Tengine-time: ~D~%" (-> this engine-time)) + (format #t "~Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~Tlength: ~D~%" (-> this length)) + (format #t "~Telement-type: ~A~%" (-> this element-type)) + (format #t "~Talive-list:~%") + (let ((s5-0 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this alive-list)) + (set! *print-column* s5-0) + ) + (format #t "~Talive-list-end:~%") + (let ((s5-1 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this alive-list-end)) + (set! *print-column* s5-1) + ) + (format #t "~Tdead-list:~%") + (let ((s5-2 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this dead-list)) + (set! *print-column* s5-2) + ) + (format #t "~Tdead-list-end:~%") + (let ((s5-3 *print-column*)) + (set! *print-column* (+ *print-column* 64)) + (inspect (-> this dead-list-end)) + (set! *print-column* s5-3) + ) + (format #t "~Tdata[~D]: @ #x~X~%" (-> this allocated-length) (-> this data)) + this + ) + +;; definition for method 4 of type engine +(defmethod length ((this engine)) + (-> this length) + ) + +;; definition for method 5 of type engine +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +;; definition for method 10 of type engine +(defmethod apply-to-connections ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections for the engine. + It's okay to have arg0 remove the connection." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (arg0 a0-1) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition for method 11 of type engine +(defmethod apply-to-connections-reverse ((this engine) (arg0 (function connectable none))) + "Apply arg0 to all connections, reverse order. + Do not use arg0 to remove yourself from the list." + (let ((s4-0 (-> this alive-list-end prev0))) + (while (!= s4-0 (-> this alive-list)) + (arg0 s4-0) + (set! s4-0 (-> s4-0 prev0)) + ) + ) + 0 + ) + +;; definition for method 12 of type engine +(defmethod execute-connections ((this engine) (arg0 object)) + "Run the engine!" + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + ) + ) + 0 + ) + +;; definition for method 13 of type engine +(defmethod execute-connections-and-move-to-dead ((this engine) (arg0 object)) + "Run the engine! If any objects return `'dead`, remove them." + (set! (-> this engine-time) (-> *display* real-clock frame-counter)) + (let ((s4-0 (the-as connection (-> this alive-list-end prev0)))) + (while (!= s4-0 (-> this alive-list)) + (let ((v1-3 ((the-as (function object object object object object) (-> s4-0 param0)) + (-> s4-0 param1) + (-> s4-0 param2) + (-> s4-0 param3) + arg0 + ) + ) + ) + (set! s4-0 (the-as connection (-> s4-0 prev0))) + (if (= v1-3 'dead) + ((method-of-type connection move-to-dead) (the-as connection (-> s4-0 next0))) + ) + ) + ) + ) + 0 + ) + +;; definition for method 14 of type engine +(defmethod execute-connections-if-needed ((this engine) (arg0 object)) + "Execute connections, but only if it hasn't been done on this frame." + (if (!= (-> *display* real-clock frame-counter) (-> this engine-time)) + (execute-connections this arg0) + ) + 0 + ) + +;; definition for function connection-process-apply +(defun connection-process-apply ((arg0 process) (arg1 (function object none))) + "Apply a function to all connectables of a process." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (arg1 s5-0) + (set! s5-0 (-> s5-0 next1)) + ) + ) + #f + ) + ) + +;; definition for method 9 of type engine +(defmethod inspect-all-connections ((this engine)) + "inspect all of the connections." + (let ((gp-0 *kernel-symbol-warnings*)) + (set! *kernel-symbol-warnings* #f) + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (format + #t + "from process ~A:~%~`connection`I" + ((method-of-type connection get-process) (the-as connection s4-0)) + s4-0 + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + (set! *kernel-symbol-warnings* gp-0) + ) + this + ) + +;; definition for method 15 of type engine +(defmethod add-connection ((this engine) (arg0 process) (arg1 object) (arg2 object) (arg3 object) (arg4 object)) + "Add a connection between this engine and a given process." + (let ((v1-0 (the-as connection (-> this dead-list next0)))) + (when (not (or (not arg0) (= v1-0 (-> this dead-list-end)))) + (set! (-> v1-0 param0) (the-as basic arg1)) + (set! (-> v1-0 param1) (the-as basic arg2)) + (set! (-> v1-0 param2) (the-as int arg3)) + (set! (-> v1-0 param3) (the-as int arg4)) + (set! (-> this dead-list next0) (-> v1-0 next0)) + (set! (-> v1-0 next0 prev0) (-> this dead-list)) + (set! (-> v1-0 next0) (-> this alive-list next0)) + (set! (-> v1-0 next0 prev0) v1-0) + (set! (-> v1-0 prev0) (-> this alive-list)) + (set! (-> this alive-list next0) v1-0) + (set! (-> v1-0 next1) (-> arg0 connection-list next1)) + (if (-> v1-0 next1) + (set! (-> v1-0 next1 prev1) v1-0) + ) + (set! (-> v1-0 prev1) (-> arg0 connection-list)) + (set! (-> arg0 connection-list next1) v1-0) + (+! (-> this length) 1) + v1-0 + ) + ) + ) + +;; definition for method 13 of type connection +(defmethod move-to-dead ((this connection)) + "Move this connection from the alive list to the dead list." + (let ((v1-1 (get-engine this))) + (set! (-> this prev0 next0) (-> this next0)) + (set! (-> this next0 prev0) (-> this prev0)) + (set! (-> this prev1 next1) (-> this next1)) + (if (-> this next1) + (set! (-> this next1 prev1) (-> this prev1)) + ) + (set! (-> this next0) (-> v1-1 dead-list next0)) + (set! (-> this next0 prev0) this) + (set! (-> this prev0) (-> v1-1 dead-list)) + (set! (-> v1-1 dead-list next0) this) + (+! (-> v1-1 length) -1) + ) + this + ) + +;; definition for function process-disconnect +(defun process-disconnect ((arg0 process)) + "Disconnect all connections for the given process." + (when arg0 + (let ((gp-0 (-> arg0 connection-list next1))) + (while gp-0 + ((method-of-type connection move-to-dead) (the-as connection gp-0)) + (set! gp-0 (-> gp-0 next1)) + ) + ) + ) + 0 + ) + +;; definition for method 16 of type engine +(defmethod remove-from-process ((this engine) (arg0 process)) + "Remove all connections from process for this engine." + (when arg0 + (let ((s5-0 (-> arg0 connection-list next1))) + (while s5-0 + (if ((method-of-type connection belongs-to-engine?) (the-as connection s5-0) this) + ((method-of-type connection move-to-dead) (the-as connection s5-0)) + ) + (set! s5-0 (-> s5-0 next1)) + ) + ) + ) + 0 + ) + +;; definition for method 17 of type engine +(defmethod remove-matching ((this engine) (arg0 (function connection engine symbol))) + "Call the given function on each connection and the engine. + If it returns truthy, `move-to-dead` that connection." + (let* ((s4-0 (-> this alive-list next0)) + (s3-0 (-> s4-0 next0)) + ) + (while (!= s4-0 (-> this alive-list-end)) + (if (arg0 (the-as connection s4-0) this) + ((method-of-type connection move-to-dead) (the-as connection s4-0)) + ) + (set! s4-0 s3-0) + (set! s3-0 (-> s3-0 next0)) + ) + ) + 0 + ) + +;; definition for method 18 of type engine +(defmethod remove-all ((this engine)) + "Remove all connections from an engine." + (let* ((a0-1 (-> this alive-list next0)) + (s5-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + (set! a0-1 s5-0) + (set! s5-0 (-> s5-0 next0)) + ) + ) + 0 + ) + +;; definition for method 19 of type engine +(defmethod remove-by-param0 ((this engine) (arg0 object)) + "Remove all connections with param0 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param0) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition for method 20 of type engine +(defmethod remove-by-param1 ((this engine) (arg0 int)) + "Remove all connections with param1 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param1) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition for method 21 of type engine +(defmethod remove-by-param2 ((this engine) (arg0 int)) + "Remove all connections with param2 matching arg0." + (let* ((a0-1 (-> this alive-list next0)) + (s4-0 (-> a0-1 next0)) + ) + (while (!= a0-1 (-> this alive-list-end)) + (if (= (-> (the-as connection a0-1) param2) arg0) + ((method-of-type connection move-to-dead) (the-as connection a0-1)) + ) + (set! a0-1 s4-0) + (set! s4-0 (-> s4-0 next0)) + ) + ) + 0 + ) + +;; definition of type connection-pers +(deftype connection-pers (structure) + "This is another engine system, very similar to the first, but not specific to a process. +Each connection has a `key`, which is like the process, but unlike normal engine, +the key's don't track which engine-pers they belong to. + +Unlike [[engine]], users can use [[engine-pers]] as a parent class." + ((next connection-pers) + (key object) + (update-time time-frame) + (param object 4) + (param-int32 int32 4 :overlay-at (-> param 0)) + (param-int64 int64 2 :overlay-at (-> param 0)) + (param-float float 4 :overlay-at (-> param 0)) + (param-quat uint128 :overlay-at (-> param 0)) + ) + ) + +;; definition for method 3 of type connection-pers +;; INFO: Used lq/sq +(defmethod inspect ((this connection-pers)) + (when (not this) + (set! this this) + (goto cfg-16) + ) + (format #t "[~8x] ~A~%" this 'connection-pers) + (format #t "~1Tnext: #~%" (-> this next)) + (format #t "~1Tkey: ~A~%" (-> this key)) + (format #t "~1Tupdate-time: ~D~%" (-> this update-time)) + (format #t "~1Tparam[4] @ #x~X~%" (-> this param)) + (dotimes (s5-0 4) + (format #t "~T [~D]~1Tparam: ~A~%" s5-0 (-> this param s5-0)) + ) + (format #t "~1Tparam-int32[4] @ #x~X~%" (-> this param)) + (dotimes (s5-1 4) + (format #t "~T [~D]~1Tparam-int32: ~D~%" s5-1 (-> this param s5-1)) + ) + (format #t "~1Tparam-int64[2] @ #x~X~%" (-> this param)) + (dotimes (s5-2 2) + (format #t "~T [~D]~1Tparam-int64: ~D~%" s5-2 (-> this param-int64 s5-2)) + ) + (format #t "~1Tparam-float[4] @ #x~X~%" (-> this param)) + (dotimes (s5-3 4) + (format #t "~T [~D]~1Tparam-float: ~f~%" s5-3 (the-as float (-> this param s5-3))) + ) + (format #t "~1Tparam-quat: #x~X~%" (-> this param-quat)) + (label cfg-16) + this + ) + +;; definition of type engine-pers +(deftype engine-pers (basic) + ((name symbol) + (length int16) + (allocated-length int16) + (element-type type) + (execute-time time-frame) + (alive-list connection-pers) + (dead-list connection-pers) + (data connection-pers :inline :dynamic) + ) + (:methods + (new (symbol type symbol int type) _type_) + (schedule-callback (_type_ object time-frame) connection-pers) + (kill-callback (_type_ connection-pers) none) + (kill-by-key (_type_ object) none) + (kill-matching (_type_ (function engine-pers connection-pers object object symbol) object object) none) + (update-callback (_type_) none) + (run-pending-updates! (_type_ time-frame) none) + ) + ) + +;; definition for method 3 of type engine-pers +(defmethod inspect ((this engine-pers)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Telement-type: ~A~%" (-> this element-type)) + (format #t "~1Texecute-time: ~D~%" (-> this execute-time)) + (format #t "~1Talive-list: #~%" (-> this alive-list)) + (format #t "~1Tdead-list: #~%" (-> this dead-list)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition for method 0 of type engine-pers +(defmethod new engine-pers ((allocation symbol) (type-to-make type) (arg0 symbol) (arg1 int) (arg2 type)) + (let ((v0-0 (object-new + allocation + type-to-make + (the-as int (+ (-> type-to-make size) (* (the-as uint arg1) (-> arg2 size)))) + ) + ) + ) + (set! (-> v0-0 allocated-length) arg1) + (set! (-> v0-0 length) 0) + (set! (-> v0-0 name) arg0) + (set! (-> v0-0 element-type) arg2) + (set! (-> v0-0 alive-list) #f) + (set! (-> v0-0 dead-list) (the-as connection-pers (-> v0-0 data))) + (let ((v1-3 (the-as object (-> v0-0 data)))) + (dotimes (a0-1 arg1) + (set! (-> (the-as (pointer pointer) v1-3) 0) (&+ (the-as pointer v1-3) (-> arg2 size))) + (set! v1-3 (&+ (the-as pointer v1-3) (-> arg2 size))) + ) + (set! (-> (the-as (pointer int32) (&- (the-as pointer v1-3) (the-as uint (-> arg2 size))))) #f) + ) + v0-0 + ) + ) + +;; definition for method 4 of type engine-pers +(defmethod length ((this engine-pers)) + (-> this length) + ) + +;; definition for method 5 of type engine-pers +;; WARN: Return type mismatch uint vs int. +(defmethod asize-of ((this engine-pers)) + (the-as int (+ (-> this type size) (* (-> this allocated-length) (the-as int (-> this element-type size))))) + ) + +;; definition for method 9 of type engine-pers +;; INFO: Used lq/sq +(defmethod schedule-callback ((this engine-pers) (arg0 object) (arg1 time-frame)) + "Get a connection for this key. + If no connection exists, add it. + Schedule an update to happen in arg1 seconds." + (local-vars (v0-0 connection-pers)) + (let ((v1-0 (-> this alive-list))) + (while v1-0 + (when (= arg0 (-> v1-0 key)) + (set! v0-0 v1-0) + (goto cfg-8) + ) + (set! v1-0 (-> v1-0 next)) + ) + ) + (set! v0-0 (-> this dead-list)) + (when v0-0 + (set! (-> this dead-list) (-> v0-0 next)) + (set! (-> v0-0 next) (-> this alive-list)) + (set! (-> this alive-list) v0-0) + (+! (-> this length) 1) + (set! (-> v0-0 key) arg0) + (set! (-> v0-0 param-quat) (the-as uint128 0)) + 0 + ) + (label cfg-8) + (if v0-0 + (set! (-> v0-0 update-time) (+ (-> this execute-time) arg1)) + ) + v0-0 + ) + +;; definition for method 10 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-callback ((this engine-pers) (arg0 connection-pers)) + "Called when a connection is removed." + 0 + (none) + ) + +;; definition for method 13 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod update-callback ((this engine-pers)) + "Called when a connection is run. + Users can override this as needed." + 0 + (none) + ) + +;; definition for method 11 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-by-key ((this engine-pers) (arg0 object)) + "Remove connections with this key, calling `kill-callback`." + (let ((s4-0 (&-> this alive-list)) + (s2-0 (-> this alive-list)) + ) + (while s2-0 + (let ((s3-0 (-> s2-0 next))) + (cond + ((!= arg0 (-> s2-0 key)) + (set! s4-0 (&-> s2-0 next)) + ) + (else + (kill-callback this s2-0) + (set! (-> s4-0 0) (-> s2-0 next)) + (set! (-> s2-0 next) (-> this dead-list)) + (set! (-> this dead-list) s2-0) + (+! (-> this length) -1) + ) + ) + (set! s2-0 s3-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod kill-matching ((this engine-pers) + (arg0 (function engine-pers connection-pers object object symbol)) + (arg1 object) + (arg2 object) + ) + "Call the given function on each connection. If it returns truthy, kill that connection." + (let ((s2-0 (&-> this alive-list)) + (s0-0 (-> this alive-list)) + ) + (while s0-0 + (let ((s1-0 (-> s0-0 next))) + (cond + ((not (arg0 this s0-0 arg1 arg2)) + (set! s2-0 (&-> s0-0 next)) + ) + (else + (kill-callback this s0-0) + (set! (-> s2-0 0) (-> s0-0 next)) + (set! (-> s0-0 next) (-> this dead-list)) + (set! (-> this dead-list) s0-0) + (+! (-> this length) -1) + ) + ) + (set! s0-0 s1-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type engine-pers +;; WARN: Return type mismatch int vs none. +(defmethod run-pending-updates! ((this engine-pers) (arg0 time-frame)) + "Run updates if they scheduled. If something is found that has no pending update, kill it. + Note that we won't kill things on this call if they fail to update their `update-time`. + They will survive until the next call to `run-pending-updates`! + (or you can modify their `update-time` before that to prevent them from being killed.)" + (let ((s4-0 (-> this execute-time)) + (s2-0 (&-> this alive-list)) + (s1-0 (-> this alive-list)) + ) + (while s1-0 + (let ((s3-0 (-> s1-0 next))) + (cond + ((>= (-> s1-0 update-time) s4-0) + (update-callback this) + (set! s2-0 (&-> s1-0 next)) + ) + (else + (kill-callback this s1-0) + (set! (-> s2-0 0) (-> s1-0 next)) + (set! (-> s1-0 next) (-> this dead-list)) + (set! (-> this dead-list) s1-0) + (+! (-> this length) -1) + ) + ) + (set! s1-0 s3-0) + ) + ) + ) + (set! (-> this execute-time) arg0) + 0 + (none) + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/hw/gs_REF.gc b/test/decompiler/reference/jak3/engine/gfx/hw/gs_REF.gc new file mode 100644 index 00000000000..5d9000be875 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/hw/gs_REF.gc @@ -0,0 +1,1053 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type gs-pmode +(deftype gs-pmode (uint64) + ((en1 uint8 :offset 0 :size 1) + (en2 uint8 :offset 1 :size 1) + (crtmd uint8 :offset 2 :size 3) + (mmod uint8 :offset 5 :size 1) + (amod uint8 :offset 6 :size 1) + (slbg uint8 :offset 7 :size 1) + (alp uint8 :offset 8 :size 8) + ) + ) + +;; definition of type gs-smode2 +(deftype gs-smode2 (uint64) + ((int uint8 :offset 0 :size 1) + (ffmd uint8 :offset 1 :size 1) + (dpms uint8 :offset 2 :size 2) + ) + ) + +;; definition for function psm-size +(defun psm-size ((arg0 gs-psm)) + "Convert texture format to some type of size." + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 32 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 128 + ) + (else + 256 + ) + ) + ) + +;; definition for function psm-page-height +(defun psm-page-height ((arg0 gs-psm)) + "Convert texture format to some type of page height." + (cond + ((= arg0 (gs-psm mt8)) + 64 + ) + ((= arg0 (gs-psm mt4)) + 128 + ) + ((or (= arg0 (gs-psm ct16)) (= arg0 (gs-psm ct16s)) (= arg0 (gs-psm mz16)) (= arg0 (gs-psm mz16s))) + 64 + ) + (else + 32 + ) + ) + ) + +;; definition for function psm->string +(defun psm->string ((arg0 gs-psm)) + "Get the name of a texture format." + (case arg0 + (((gs-psm ct24)) + "ct24" + ) + (((gs-psm mt4)) + "mt4" + ) + (((gs-psm ct32)) + "ct32" + ) + (((gs-psm mz16s)) + "mz16s" + ) + (((gs-psm ct16s)) + "ct16s" + ) + (((gs-psm mt8)) + "mt8" + ) + (((gs-psm mt8h)) + "mt8h" + ) + (((gs-psm mz16)) + "mz16" + ) + (((gs-psm mz24)) + "mz24" + ) + (((gs-psm mt4hh)) + "mt4hh" + ) + (((gs-psm ct16)) + "ct16" + ) + (((gs-psm mt4hl)) + "mt4hl" + ) + (((gs-psm mz32)) + "mz32" + ) + (else + "*unknown*" + ) + ) + ) + +;; definition of type gs-display-fb +(deftype gs-display-fb (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 9 :size 6) + (psm gs-psm :offset 15 :size 5) + (dbx uint16 :offset 32 :size 11) + (dby uint16 :offset 43 :size 11) + ) + ) + +;; definition of type gs-display +(deftype gs-display (uint64) + "the GS's DISPLAY registers make settings for the display position on the screen regarding +information on Rectangular Area Read Output Circuit n for the PCRTC. +write-only" + ((dx uint16 :offset 0 :size 12) + (dy uint16 :offset 12 :size 11) + (magh uint8 :offset 23 :size 4) + (magv uint8 :offset 27 :size 2) + (dw uint16 :offset 32 :size 12) + (dh uint16 :offset 44 :size 11) + ) + ) + +;; definition of type gs-bgcolor +(deftype gs-bgcolor (uint64) + "The GS's BGCOLOR register sets the background color of the PCRTC with RGB value. +write-only" + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + ) + ) + +;; definition of type gs-csr +(deftype gs-csr (uint64) + "The GS's CSR register sets and obtains various GS statuses. +read-write. The fields have different effects depending on whether they're being read from +or written to. + +Bits 5 and 6 (0x20 and 0x40) should be zero." + ((signal uint8 :offset 0 :size 1) + (finish uint8 :offset 1 :size 1) + (hsint uint8 :offset 2 :size 1) + (vsint uint8 :offset 3 :size 1) + (edwint uint8 :offset 4 :size 1) + (flush uint8 :offset 8 :size 1) + (reset uint8 :offset 9 :size 1) + (nfield uint8 :offset 12 :size 1) + (field uint8 :offset 13 :size 1) + (fifo uint8 :offset 14 :size 2) + (rev uint8 :offset 16 :size 8) + (id uint8 :offset 24 :size 8) + ) + ) + +;; definition of type gs-bank +(deftype gs-bank (structure) + "Memory layout of the GS's privileged registers (mapped to EE memory). +It is missing the SIGLBLID/LABELID register at 4224 (useless anyway?)" + ((pmode gs-pmode) + (smode2 gs-smode2 :offset 32) + (dspfb1 gs-display-fb :offset 112) + (display1 gs-display :offset 128) + (dspfb2 gs-display-fb :offset 144) + (display2 gs-display :offset 160) + (extbuf uint64 :offset 176) + (extdata uint64 :offset 192) + (extwrite uint64 :offset 208) + (bgcolor gs-bgcolor :offset 224) + (csr gs-csr :offset 4096) + (imr uint64 :offset 4112) + (busdir uint64 :offset 4160) + ) + ) + +;; definition for method 3 of type gs-bank +(defmethod inspect ((this gs-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-bank) + (format #t "~1Tpmode: #x~X~%" (-> this pmode)) + (format #t "~1Tsmode2: #x~X~%" (-> this smode2)) + (format #t "~1Tdspfb1: #x~X~%" (-> this dspfb1)) + (format #t "~1Tdisplay1: #x~X~%" (-> this display1)) + (format #t "~1Tdspfb2: #x~X~%" (-> this dspfb2)) + (format #t "~1Tdisplay2: #x~X~%" (-> this display2)) + (format #t "~1Textbuf: #x~X~%" (-> this extbuf)) + (format #t "~1Textdata: #x~X~%" (-> this extdata)) + (format #t "~1Textwrite: #x~X~%" (-> this extwrite)) + (format #t "~1Tbgcolor: #x~X~%" (-> this bgcolor)) + (format #t "~1Tcsr: #x~X~%" (-> this csr)) + (format #t "~1Timr: #x~X~%" (-> this imr)) + (format #t "~1Tbusdir: #x~X~%" (-> this busdir)) + (label cfg-4) + this + ) + +;; definition of type gs-frame +(deftype gs-frame (uint64) + ((fbp uint16 :offset 0 :size 9) + (fbw uint8 :offset 16 :size 6) + (psm gs-psm :offset 24 :size 6) + (fbmsk uint32 :offset 32 :size 32) + ) + ) + +;; definition of type gs-zbuf +(deftype gs-zbuf (uint64) + "The GS's ZBUF registers make various settings regarding Z buffer." + ((zbp uint16 :offset 0 :size 9) + (psm gs-psm :offset 24 :size 4) + (zmsk uint8 :offset 32 :size 1) + ) + ) + +;; definition of type gs-xy-offset +(deftype gs-xy-offset (uint64) + "The GS's XYOFFSET registers set the offset value for converting from the primitive coordinate +system to the window coordinate system." + ((ofx uint16 :offset 0 :size 16) + (ofy uint16 :offset 32 :size 16) + ) + ) + +;; definition of type gs-scissor +(deftype gs-scissor (uint64) + "The GS's SCISSOR registers specify the scissoring area. The coordinate values for +the upper-left/lower-right points of the enabled drawing area are specified by the window +coordinate system." + ((scax0 uint16 :offset 0 :size 11) + (scax1 uint16 :offset 16 :size 11) + (scay0 uint16 :offset 32 :size 11) + (scay1 uint16 :offset 48 :size 11) + ) + ) + +;; definition of type gs-prmode-cont +(deftype gs-prmode-cont (uint64) + "The GS's PRMODECONT register sets whether to use primitive attributes (IIP, TME, FGE, ABE, +AA1, FST, CTXT, FIX) specified by the PRMODE register or the PRIM register." + ((ac uint8 :offset 0 :size 1) + ) + ) + +;; definition of type gs-color-clamp +(deftype gs-color-clamp (uint64) + "The GS's COLCLAMP register stores settings as to whether clamping for the RGB value of the +pixel is performed." + ((clamp uint8 :offset 0 :size 1) + ) + ) + +;; definition of type gs-dthe +(deftype gs-dthe (uint64) + "The GS's DTHE register stores settings for dithering (performed/not performed)." + ((dthe uint8 :offset 0 :size 1) + ) + ) + +;; definition of type gs-test +(deftype gs-test (uint64) + "The GS's TEST register performs settings related to the pixel test." + ((ate uint8 :offset 0 :size 1) + (atst gs-atest :offset 1 :size 3) + (aref uint8 :offset 4 :size 8) + (afail uint8 :offset 12 :size 2) + (date uint8 :offset 14 :size 1) + (datm uint8 :offset 15 :size 1) + (zte uint8 :offset 16 :size 1) + (ztst gs-ztest :offset 17 :size 2) + ) + ) + +;; definition of type gs-prim +(deftype gs-prim (uint64) + ((prim gs-prim-type :offset 0 :size 3) + (iip uint8 :offset 3 :size 1) + (tme uint8 :offset 4 :size 1) + (fge uint8 :offset 5 :size 1) + (abe uint8 :offset 6 :size 1) + (aa1 uint8 :offset 7 :size 1) + (fst uint8 :offset 8 :size 1) + (ctxt uint8 :offset 9 :size 1) + (fix uint8 :offset 10 :size 1) + ) + ) + +;; definition of type gs-rgbaq +(deftype gs-rgbaq (uint64) + "The GS's RGBAQ register sets the RGBA value of the vertex and the Q value of the normalized +texture coordinates." + ((r uint8 :offset 0 :size 8) + (g uint8 :offset 8 :size 8) + (b uint8 :offset 16 :size 8) + (a uint8 :offset 24 :size 8) + (q float :offset 32 :size 32) + ) + ) + +;; definition of type gs-xyz +(deftype gs-xyz (uint64) + ((x uint16 :offset 0 :size 16) + (y uint16 :offset 16 :size 16) + (z uint32 :offset 32 :size 32) + ) + ) + +;; definition of type gs-uv +(deftype gs-uv (uint64) + "The GS's UV register specifies the texel coordinate (UV) values of the vertex." + ((u uint16 :offset 0 :size 16) + (v uint16 :offset 16 :size 16) + ) + ) + +;; definition of type gs-st +(deftype gs-st (uint64) + "The GS's ST register sets the S and T values of the vertex texture coordinates. +The value Q is specified by the RGBAQ register." + ((s float :offset 0 :size 32) + (t float :offset 32 :size 32) + ) + ) + +;; definition of type gs-xyzf +(deftype gs-xyzf (uint64) + ((x uint16 :offset 0 :size 16) + (y uint16 :offset 16 :size 16) + (z uint32 :offset 32 :size 24) + (f uint8 :offset 56 :size 8) + ) + ) + +;; definition of type gs-adcmd +(deftype gs-adcmd (structure) + ((word uint32 4) + (quad uint128 :overlay-at (-> word 0)) + (data uint64 :overlay-at (-> word 0)) + (cmds gs-reg64 :overlay-at (-> word 2)) + (cmd uint8 :overlay-at (-> word 2)) + (x uint32 :overlay-at (-> word 0)) + (y uint32 :overlay-at (-> word 1)) + (z uint32 :overlay-at (-> word 2)) + (w uint32 :overlay-at (-> word 3)) + ) + ) + +;; definition for method 3 of type gs-adcmd +;; INFO: Used lq/sq +(defmethod inspect ((this gs-adcmd)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-adcmd) + (format #t "~1Tword[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tdata: ~D~%" (-> this data)) + (format #t "~1Tcmds: ~D~%" (-> this cmds)) + (format #t "~1Tcmd: ~D~%" (-> this cmd)) + (format #t "~1Tx: ~D~%" (-> this x)) + (format #t "~1Ty: ~D~%" (-> this y)) + (format #t "~1Tz: ~D~%" (-> this z)) + (format #t "~1Tw: ~D~%" (-> this w)) + (label cfg-4) + this + ) + +;; definition of type gs-trxpos +(deftype gs-trxpos (uint64) + "The GS's TRXPOS register specifies the position and +scanning direction of the rectangular area +in each buffer where buffer transmission is performed." + ((ssax uint16 :offset 0 :size 11) + (ssay uint16 :offset 16 :size 11) + (dsax uint16 :offset 32 :size 11) + (dsay uint16 :offset 48 :size 11) + (dir uint8 :offset 59 :size 2) + ) + ) + +;; definition of type gs-trxreg +(deftype gs-trxreg (uint64) + "The GS's TRXREG register specifies the size of the rectangular area, where the transmission +between buffers is implemented, in units of pixels. +The pixel mode must be the one set by the BITBLTBUF register." + ((rrw uint16 :offset 0 :size 12) + (rrh uint16 :offset 32 :size 12) + ) + ) + +;; definition of type gs-trxdir +(deftype gs-trxdir (uint64) + "The GS's TRXDIR register specifies the transmission direction in the transmission between +buffers, and activates transmission. +Appropriate settings must be made by the BITBLTBUF/TRXPOS/TRXREG before activating +the transmission." + ((xdir uint8 :offset 0 :size 2) + ) + ) + +;; definition of type gs-bitbltbuf +(deftype gs-bitbltbuf (uint64) + "The GS's BITBLTBUF register stores buffer-related settings for transmission source and +destination during transmission between buffers." + ((sbp uint16 :offset 0 :size 14) + (sbw uint8 :offset 16 :size 6) + (spsm uint8 :offset 24 :size 6) + (dbp uint16 :offset 32 :size 14) + (dbw uint8 :offset 48 :size 6) + (dpsm gs-psm :offset 56 :size 6) + ) + ) + +;; definition of type gs-tex0 +(deftype gs-tex0 (uint64) + "The GS's TEX0 registers set various kinds of information regarding the textures to be used." + ((tbp0 uint16 :offset 0 :size 14) + (tbw uint8 :offset 14 :size 6) + (psm uint8 :offset 20 :size 6) + (tw uint8 :offset 26 :size 4) + (th uint8 :offset 30 :size 4) + (tcc uint8 :offset 34 :size 1) + (tfx uint8 :offset 35 :size 2) + (cbp uint16 :offset 37 :size 14) + (cpsm uint8 :offset 51 :size 4) + (csm uint8 :offset 55 :size 1) + (csa uint8 :offset 56 :size 5) + (cld uint8 :offset 61 :size 3) + ) + ) + +;; definition of type gs-tex1 +(deftype gs-tex1 (uint64) + "The GS's TEX1 registers set information on the sampling method of the textures." + ((lcm uint8 :offset 0 :size 1) + (mxl uint8 :offset 2 :size 3) + (mmag uint8 :offset 5 :size 1) + (mmin uint8 :offset 6 :size 3) + (mtba uint8 :offset 9 :size 1) + (l uint8 :offset 19 :size 2) + (k int16 :offset 32 :size 12) + ) + ) + +;; definition of type gs-texa +(deftype gs-texa (uint64) + "The GS's TEXA register sets the Alpha value to be referred to when the Alpha value of the +texture is not an 8-bit value." + ((ta0 uint8 :offset 0 :size 8) + (aem uint8 :offset 15 :size 1) + (ta1 uint8 :offset 32 :size 8) + ) + ) + +;; definition of type gs-texclut +(deftype gs-texclut (uint64) + "The GS's TEXCLUT register specifies the CLUT position in the buffer when the CLUT storage mode +is CSM=1 (CSM2 mode)." + ((cbw uint8 :offset 0 :size 6) + (cou uint8 :offset 6 :size 6) + (cov uint16 :offset 12 :size 10) + ) + ) + +;; definition of type gs-miptbp +(deftype gs-miptbp (uint64) + "the GS's MIPTBP registers set the buffer pointer and buffer width of textures when performing +MIPMAP. MIPTBP1 sets levels 1 to 3, MIPTBP2 sets levels 4 to 6." + ((tbp1 uint16 :offset 0 :size 14) + (tbw1 uint8 :offset 14 :size 6) + (tbp2 uint16 :offset 20 :size 14) + (tbw2 uint8 :offset 34 :size 6) + (tbp3 uint16 :offset 40 :size 14) + (tbw3 uint8 :offset 54 :size 6) + ) + ) + +;; definition of type gs-alpha +(deftype gs-alpha (uint64) + ((a uint8 :offset 0 :size 2) + (b uint8 :offset 2 :size 2) + (c uint8 :offset 4 :size 2) + (d uint8 :offset 6 :size 2) + (fix uint8 :offset 32 :size 8) + ) + ) + +;; definition for method 3 of type gs-alpha +(defmethod inspect ((this gs-alpha)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-alpha) + (format #t "~1Ta: ~D~%" (-> this a)) + (format #t "~1Tb: ~D~%" (-> this b)) + (format #t "~1Tc: ~D~%" (-> this c)) + (format #t "~1Td: ~D~%" (-> this d)) + (format #t "~1Tfix: ~D~%" (-> this fix)) + (label cfg-4) + this + ) + +;; definition of type gs-clamp +(deftype gs-clamp (uint64) + ((wms gs-tex-wrap-mode :offset 0 :size 2) + (wmt gs-tex-wrap-mode :offset 2 :size 2) + (minu uint16 :offset 4 :size 10) + (maxu uint16 :offset 14 :size 10) + (minv uint16 :offset 24 :size 10) + (maxv uint16 :offset 34 :size 10) + ) + ) + +;; definition of type gs-fog +(deftype gs-fog (uint64) + ((f uint8 :offset 56 :size 8) + ) + ) + +;; definition for method 3 of type gs-fog +(defmethod inspect ((this gs-fog)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-fog) + (format #t "~1Tf: ~D~%" (-> this f)) + (label cfg-4) + this + ) + +;; definition of type gs-fogcol +(deftype gs-fogcol (uint64) + ((fcr uint8 :offset 0 :size 8) + (fcg uint8 :offset 8 :size 8) + (fcb uint8 :offset 16 :size 8) + ) + ) + +;; definition for method 3 of type gs-fogcol +(defmethod inspect ((this gs-fogcol)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-fogcol) + (format #t "~1Tr: ~D~%" (-> this fcr)) + (format #t "~1Tg: ~D~%" (-> this fcg)) + (format #t "~1Tb: ~D~%" (-> this fcb)) + (label cfg-4) + this + ) + +;; definition of type gif-ctrl +(deftype gif-ctrl (uint32) + ((rst uint8 :offset 0 :size 1) + (pse uint8 :offset 3 :size 1) + ) + ) + +;; definition of type gif-mode +(deftype gif-mode (uint32) + ((m3r uint8 :offset 0 :size 1) + (imt uint8 :offset 2 :size 1) + ) + ) + +;; definition of type gif-stat +(deftype gif-stat (uint32) + ((m3r uint8 :offset 0 :size 1) + (m3p uint8 :offset 1 :size 1) + (imt uint8 :offset 2 :size 1) + (pse uint8 :offset 3 :size 1) + (ip3 uint8 :offset 5 :size 1) + (p3q uint8 :offset 6 :size 1) + (p2q uint8 :offset 7 :size 1) + (p1q uint8 :offset 8 :size 1) + (oph uint8 :offset 9 :size 1) + (apath uint8 :offset 10 :size 2) + (dir uint8 :offset 12 :size 1) + (fqc uint8 :offset 24 :size 5) + ) + ) + +;; definition of type gif-cnt +(deftype gif-cnt (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (regcnt uint8 :offset 16 :size 4) + (vuaddr uint16 :offset 20 :size 10) + ) + ) + +;; definition of type gif-p3cnt +(deftype gif-p3cnt (uint32) + ((p3cnt uint16 :offset 0 :size 15) + ) + ) + +;; definition of type gif-p3tag +(deftype gif-p3tag (uint32) + ((loopcnt uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +;; definition of type gif-bank +(deftype gif-bank (structure) + ((ctrl gif-ctrl :offset 0) + (mode gif-mode :offset 16) + (stat gif-stat :offset 32) + (tag0 uint32 :offset 64) + (tag1 uint32 :offset 80) + (tag2 uint32 :offset 96) + (tag3 uint32 :offset 112) + (cnt gif-cnt :offset 128) + (p3cnt gif-p3cnt :offset 144) + (p3tag gif-p3tag :offset 160) + ) + ) + +;; definition for method 3 of type gif-bank +(defmethod inspect ((this gif-bank)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gif-bank) + (format #t "~1Tctrl: #x~X~%" (-> this ctrl)) + (format #t "~1Tmode: #x~X~%" (-> this mode)) + (format #t "~1Tstat: #x~X~%" (-> this stat)) + (format #t "~1Ttag0: #x~X~%" (-> this tag0)) + (format #t "~1Ttag1: #x~X~%" (-> this tag1)) + (format #t "~1Ttag2: #x~X~%" (-> this tag2)) + (format #t "~1Ttag3: #x~X~%" (-> this tag3)) + (format #t "~1Tcnt: #x~X~%" (-> this cnt)) + (format #t "~1Tp3cnt: #x~X~%" (-> this p3cnt)) + (format #t "~1Tp3tag: #x~X~%" (-> this p3tag)) + (label cfg-4) + this + ) + +;; definition of type gif-tag-prim +(deftype gif-tag-prim (uint32) + ((id uint16 :offset 0 :size 14) + (pre uint8 :offset 14 :size 1) + (prim gs-prim :offset 15 :size 11) + (flg gif-flag :offset 26 :size 2) + (nreg uint8 :offset 28 :size 4) + ) + ) + +;; definition of type gif-tag-count +(deftype gif-tag-count (uint32) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + ) + ) + +;; definition of type gif-tag64 +(deftype gif-tag64 (uint64) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim gs-prim :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + ) + ) + +;; definition of type gif-tag +(deftype gif-tag (uint128) + ((nloop uint16 :offset 0 :size 15) + (eop uint8 :offset 15 :size 1) + (id uint16 :offset 32 :size 14) + (pre uint8 :offset 46 :size 1) + (prim uint16 :offset 47 :size 11) + (flg gif-flag :offset 58 :size 2) + (nreg uint8 :offset 60 :size 4) + (regs0 gif-reg-id :offset 64 :size 4) + (regs1 gif-reg-id :offset 68 :size 4) + (regs2 gif-reg-id :offset 72 :size 4) + (regs3 gif-reg-id :offset 76 :size 4) + (regs4 gif-reg-id :offset 80 :size 4) + (regs5 gif-reg-id :offset 84 :size 4) + (regs6 gif-reg-id :offset 88 :size 4) + (regs7 gif-reg-id :offset 92 :size 4) + (regs8 gif-reg-id :offset 96 :size 4) + (regs9 gif-reg-id :offset 100 :size 4) + (regs10 gif-reg-id :offset 104 :size 4) + (regs11 gif-reg-id :offset 108 :size 4) + (regs12 gif-reg-id :offset 112 :size 4) + (regs13 gif-reg-id :offset 116 :size 4) + (regs14 gif-reg-id :offset 120 :size 4) + (regs15 gif-reg-id :offset 124 :size 4) + ) + ) + +;; definition of type gs-gif-tag +(deftype gs-gif-tag (structure) + ((qword uint128) + (tag gif-tag64 :overlay-at qword) + (regs gif-tag-regs :offset 8) + (dword uint64 2 :overlay-at qword) + (word uint32 4 :overlay-at qword) + ) + ) + +;; definition for method 3 of type gs-gif-tag +(defmethod inspect ((this gs-gif-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-gif-tag) + (format #t "~1Tqword: #~%" (&-> this tag)) + (format #t "~1Tdword[2] @ #x~X~%" (&-> this tag)) + (format #t "~1Tword[4] @ #x~X~%" (&-> this tag)) + (format #t "~1Ttag: ~D~%" (-> this tag)) + (format #t "~1Tregs: ~D~%" (-> this regs)) + (label cfg-4) + this + ) + +;; definition for method 3 of type gif-tag +;; WARN: Return type mismatch object vs gif-tag. +(defmethod inspect ((this gif-tag)) + (format #t "[~8x] gif-tag~%" this) + (format #t "~Tnloop: ~4d~%" (-> this nloop)) + (format #t "~Teop : ~4d~%" (-> this eop)) + (format #t "~Tid : ~4d~%" (-> this id)) + (format #t "~Tpre : ~4d~%" (-> this pre)) + (format #t "~Tprim : ~4d~%" (-> this prim)) + (format #t "~Tflg : ~4d~%" (-> this flg)) + (format #t "~Tnreg : ~4d~%" (-> this nreg)) + (format #t "~Tregs0 : ~4d~%" (-> this regs0)) + (format #t "~Tregs1 : ~4d~%" (-> this regs1)) + (format #t "~Tregs2 : ~4d~%" (-> this regs2)) + (format #t "~Tregs3 : ~4d~%" (-> this regs3)) + (format #t "~Tregs4 : ~4d~%" (-> this regs4)) + (format #t "~Tregs5 : ~4d~%" (-> this regs5)) + (format #t "~Tregs6 : ~4d~%" (-> this regs6)) + (format #t "~Tregs7 : ~4d~%" (-> this regs7)) + (format #t "~Tregs8 : ~4d~%" (-> this regs8)) + (format #t "~Tregs9 : ~4d~%" (-> this regs9)) + (format #t "~Tregs10: ~4d~%" (-> this regs10)) + (format #t "~Tregs11: ~4d~%" (-> this regs11)) + (format #t "~Tregs12: ~4d~%" (-> this regs12)) + (format #t "~Tregs13: ~4d~%" (-> this regs13)) + (format #t "~Tregs14: ~4d~%" (-> this regs14)) + (the-as gif-tag (format #t "~Tregs15: ~4d~%" (-> this regs15))) + ) + +;; definition for symbol *fog-color*, type rgba +(define *fog-color* (new 'static 'rgba :r #x80)) + +;; definition of type gif-packet +(deftype gif-packet (basic) + "Unused type for building a dynamically sized gif packet." + ((reg-count int32) + (gif-tag gs-gif-tag :inline) + (gif-tag0 uint128 :overlay-at (-> gif-tag qword)) + (args uint64 1) + ) + (:methods + (new (symbol type int) _type_) + ) + ) + +;; definition for method 3 of type gif-packet +;; INFO: Used lq/sq +(defmethod inspect ((this gif-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Treg-count: ~D~%" (-> this reg-count)) + (format #t "~1Tgif-tag0: #x~X~%" (-> this gif-tag0)) + (format #t "~1Targs[1] @ #x~X~%" (-> this args)) + (label cfg-4) + this + ) + +;; definition for method 0 of type gif-packet +(defmethod new gif-packet ((allocation symbol) (type-to-make type) (arg0 int)) + (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* (+ arg0 -1) 8)))) + ) + +;; definition for function open-gif-packet +(defun open-gif-packet ((arg0 gif-packet)) + "Initialize an existing gif-packet for 0 registers." + (set! (-> arg0 reg-count) 0) + (set! (-> arg0 gif-tag regs) (new 'static 'gif-tag-regs)) + arg0 + ) + +;; definition for function add-reg-gif-packet +;; WARN: Return type mismatch gif-packet vs none. +(defun add-reg-gif-packet ((arg0 gif-packet) (arg1 int) (arg2 int)) + "Add a register + value to the packet." + (let ((v1-0 (-> arg0 gif-tag))) + (logior! (-> v1-0 regs) (ash arg1 (* (-> arg0 reg-count) 4))) + ) + (set! (-> (&-> arg0 args (-> arg0 reg-count)) 0) (the-as uint arg2)) + (+! (-> arg0 reg-count) 1) + (none) + ) + +;; definition for function close-gif-packet +(defun close-gif-packet ((arg0 gif-packet) (arg1 int)) + "Finish adding registers." + (set! (-> arg0 gif-tag tag) + (new 'static 'gif-tag64 :nloop #x1 :flg (gif-flag reg-list) :eop arg1 :nreg (-> arg0 reg-count)) + ) + arg0 + ) + +;; definition of type draw-context +(deftype draw-context (basic) + ((orgx int32) + (orgy int32) + (orgz int32) + (width int32) + (height int32) + (color rgba 4) + ) + (:methods + (new (symbol type int int int int rgba) _type_) + ) + ) + +;; definition for method 3 of type draw-context +(defmethod inspect ((this draw-context)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Torgx: ~D~%" (-> this orgx)) + (format #t "~1Torgy: ~D~%" (-> this orgy)) + (format #t "~1Torgz: ~D~%" (-> this orgz)) + (format #t "~1Twidth: ~D~%" (-> this width)) + (format #t "~1Theight: ~D~%" (-> this height)) + (format #t "~1Tcolor: #x~X~%" (-> this color)) + (label cfg-4) + this + ) + +;; definition for method 0 of type draw-context +(defmethod new draw-context ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 rgba)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 orgx) arg0) + (set! (-> v0-0 orgy) arg1) + (set! (-> v0-0 orgz) #xffffff) + (set! (-> v0-0 width) arg2) + (set! (-> v0-0 height) arg3) + (set! (-> v0-0 color 0) arg4) + v0-0 + ) + ) + +;; definition for function draw-context-set-xy +;; WARN: Return type mismatch int vs none. +(defun draw-context-set-xy ((arg0 draw-context) (arg1 int) (arg2 int)) + "Set the origin of the draw context." + (set! (-> arg0 orgx) arg1) + (set! (-> arg0 orgy) arg2) + (none) + ) + +;; definition of type gs-packed-rgba +(deftype gs-packed-rgba (vector4w) + ((r int32 :overlay-at (-> data 0)) + (g int32 :overlay-at (-> data 1)) + (b int32 :overlay-at (-> data 2)) + (a int32 :overlay-at (-> data 3)) + ) + ) + +;; definition for method 3 of type gs-packed-rgba +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-rgba)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-rgba) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tx: ~D~%" (-> this x)) + (format #t "~1Ty: ~D~%" (-> this y)) + (format #t "~1Tz: ~D~%" (-> this z)) + (format #t "~1Tw: ~D~%" (-> this w)) + (format #t "~1Tdword[2] @ #x~X~%" (&-> this x)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tr: ~D~%" (-> this x)) + (format #t "~1Tg: ~D~%" (-> this y)) + (format #t "~1Tb: ~D~%" (-> this z)) + (format #t "~1Ta: ~D~%" (-> this w)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-xyzw +(deftype gs-packed-xyzw (vector) + ((ix int32 :overlay-at (-> data 0)) + (iy int32 :overlay-at (-> data 1)) + (iz int32 :overlay-at (-> data 2)) + (iw int32 :overlay-at (-> data 3)) + ) + ) + +;; definition for method 3 of type gs-packed-xyzw +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-xyzw)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-xyzw) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this ix)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tix: ~D~%" (-> this ix)) + (format #t "~1Tiy: ~D~%" (-> this iy)) + (format #t "~1Tiz: ~D~%" (-> this iz)) + (format #t "~1Tiw: ~D~%" (-> this iw)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-stq +(deftype gs-packed-stq (vector) + ((tex-s float :overlay-at (-> data 0)) + (tex-t float :overlay-at (-> data 1)) + (tex-q float :overlay-at (-> data 2)) + ) + ) + +;; definition for method 3 of type gs-packed-stq +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-stq)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-stq) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Ttex-s: ~f~%" (-> this x)) + (format #t "~1Ttex-t: ~f~%" (-> this y)) + (format #t "~1Ttex-q: ~f~%" (-> this z)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-uv +(deftype gs-packed-uv (vector) + ((u int16 :overlay-at (-> data 0)) + (v int16 :overlay-at (-> data 1)) + ) + ) + +;; definition for method 3 of type gs-packed-uv +;; INFO: Used lq/sq +(defmethod inspect ((this gs-packed-uv)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-uv) + (format #t "~1Tdata[4] @ #x~X~%" (&-> this x)) + (format #t "~1Tx: ~f~%" (-> this x)) + (format #t "~1Ty: ~f~%" (-> this y)) + (format #t "~1Tz: ~f~%" (-> this z)) + (format #t "~1Tw: ~f~%" (-> this w)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (format #t "~1Tu: ~D~%" (-> this u)) + (format #t "~1Tv: ~D~%" (-> this v)) + (format #t "~1Tquad: ~D~%" (-> this quad)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-gt +(deftype gs-packed-gt (structure) + ((stq gs-packed-stq :inline :offset 0) + (rgba gs-packed-rgba :inline :offset 16) + (xyzw gs-packed-xyzw :inline :offset 32) + ) + ) + +;; definition for method 3 of type gs-packed-gt +(defmethod inspect ((this gs-packed-gt)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-gt) + (format #t "~1Tstq: #~%" (-> this stq)) + (format #t "~1Trgba: #~%" (-> this rgba)) + (format #t "~1Txyzw: #~%" (-> this xyzw)) + (label cfg-4) + this + ) + +;; definition of type gs-packed-gt4 +(deftype gs-packed-gt4 (structure) + ((data gs-packed-gt 4 :inline) + ) + ) + +;; definition for method 3 of type gs-packed-gt4 +(defmethod inspect ((this gs-packed-gt4)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-packed-gt4) + (format #t "~1Tdata[4] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/math-camera-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/math-camera-h_REF.gc new file mode 100644 index 00000000000..6d6189cc108 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/math-camera-h_REF.gc @@ -0,0 +1,226 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type vis-gif-tag +(deftype vis-gif-tag (structure) + "Unused." + ((fog0 uint32) + (strip uint32) + (regs uint32) + (fan uint32) + ) + ) + +;; definition for method 3 of type vis-gif-tag +(defmethod inspect ((this vis-gif-tag)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'vis-gif-tag) + (format #t "~1Tfog0: ~D~%" (-> this fog0)) + (format #t "~1Tstrip: ~D~%" (-> this strip)) + (format #t "~1Tregs: ~D~%" (-> this regs)) + (format #t "~1Tfan: ~D~%" (-> this fan)) + (label cfg-4) + this + ) + +;; definition of type cull-info +(deftype cull-info (structure) + "Also seems unused." + ((x-fact float) + (y-fact float) + (z-fact float) + (cam-radius float) + (cam-x float) + (cam-y float) + (xz-dir-ax float) + (xz-dir-az float) + (xz-dir-bx float) + (xz-dir-bz float) + (xz-cross-ab float) + (yz-dir-ay float) + (yz-dir-az float) + (yz-dir-by float) + (yz-dir-bz float) + (yz-cross-ab float) + ) + :allow-misaligned + ) + +;; definition for method 3 of type cull-info +(defmethod inspect ((this cull-info)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'cull-info) + (format #t "~1Tx-fact: ~f~%" (-> this x-fact)) + (format #t "~1Ty-fact: ~f~%" (-> this y-fact)) + (format #t "~1Tz-fact: ~f~%" (-> this z-fact)) + (format #t "~1Tcam-radius: ~f~%" (-> this cam-radius)) + (format #t "~1Tcam-x: ~f~%" (-> this cam-x)) + (format #t "~1Tcam-y: ~f~%" (-> this cam-y)) + (format #t "~1Txz-dir-ax: ~f~%" (-> this xz-dir-ax)) + (format #t "~1Txz-dir-az: ~f~%" (-> this xz-dir-az)) + (format #t "~1Txz-dir-bx: ~f~%" (-> this xz-dir-bx)) + (format #t "~1Txz-dir-bz: ~f~%" (-> this xz-dir-bz)) + (format #t "~1Txz-cross-ab: ~f~%" (-> this xz-cross-ab)) + (format #t "~1Tyz-dir-ay: ~f~%" (-> this yz-dir-ay)) + (format #t "~1Tyz-dir-az: ~f~%" (-> this yz-dir-az)) + (format #t "~1Tyz-dir-by: ~f~%" (-> this yz-dir-by)) + (format #t "~1Tyz-dir-bz: ~f~%" (-> this yz-dir-bz)) + (format #t "~1Tyz-cross-ab: ~f~%" (-> this yz-cross-ab)) + (label cfg-4) + this + ) + +;; definition of type math-camera +(deftype math-camera (basic) + ((d meters) + (f meters) + (fov degrees) + (x-ratio float) + (y-ratio float) + (x-pix float) + (x-clip float) + (x-clip-ratio-in float) + (x-clip-ratio-over float) + (y-pix float) + (y-clip float) + (y-clip-ratio-in float) + (y-clip-ratio-over float) + (cull-info cull-info :inline) + (fog-start meters) + (fog-end meters) + (fog-max float) + (fog-min float) + (reset int32) + (smooth-step float) + (smooth-t float) + (perspective matrix :inline) + (isometric matrix :inline) + (sprite-2d matrix :inline) + (sprite-2d-hvdf vector :inline) + (camera-rot matrix :inline) + (inv-camera-rot matrix :inline) + (inv-camera-rot-smooth matrix :inline) + (inv-camera-rot-smooth-from quaternion :inline) + (camera-temp matrix :inline) + (prev-camera-temp matrix :inline) + (prev-inv-camera-rot matrix :inline) + (prev-trans vector :inline) + (hmge-scale vector :inline) + (inv-hmge-scale vector :inline) + (hvdf-off vector :inline) + (guard vector :inline) + (vis-gifs vis-gif-tag 4) + (giftex uint128 :overlay-at (-> vis-gifs 0)) + (gifgr uint128 :offset 864) + (giftex-trans uint128 :offset 880) + (gifgr-trans uint128 :offset 896) + (pfog0 float) + (pfog1 float) + (trans vector :inline) + (plane plane 4 :inline) + (guard-plane plane 4 :inline) + (shrub-mat matrix :inline) + (quat-other quaternion :inline) + (trans-other vector :inline) + (shrub-mat-other matrix :inline) + (camera-temp-other matrix :inline) + (camera-rot-other matrix :inline) + (camera-rot-other-sky matrix :inline) + (camera-rot-other-sprite matrix :inline) + (inv-camera-rot-other matrix :inline) + (plane-other plane 4 :inline) + (guard-plane-other plane 4 :inline) + (mirror-trans vector :inline) + (mirror-normal vector :inline) + (fov-correction-factor float) + ) + (:methods + (new (symbol type) _type_) + ) + ) + +;; definition for method 3 of type math-camera +;; INFO: Used lq/sq +(defmethod inspect ((this math-camera)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Td: (meters ~m)~%" (-> this d)) + (format #t "~1Tf: (meters ~m)~%" (-> this f)) + (format #t "~1Tfov: (deg ~r)~%" (-> this fov)) + (format #t "~1Tx-ratio: ~f~%" (-> this x-ratio)) + (format #t "~1Ty-ratio: ~f~%" (-> this y-ratio)) + (format #t "~1Tx-pix: ~f~%" (-> this x-pix)) + (format #t "~1Tx-clip: ~f~%" (-> this x-clip)) + (format #t "~1Tx-clip-ratio-in: ~f~%" (-> this x-clip-ratio-in)) + (format #t "~1Tx-clip-ratio-over: ~f~%" (-> this x-clip-ratio-over)) + (format #t "~1Ty-pix: ~f~%" (-> this y-pix)) + (format #t "~1Ty-clip: ~f~%" (-> this y-clip)) + (format #t "~1Ty-clip-ratio-in: ~f~%" (-> this y-clip-ratio-in)) + (format #t "~1Ty-clip-ratio-over: ~f~%" (-> this y-clip-ratio-over)) + (format #t "~1Tcull-info: #~%" (-> this cull-info)) + (format #t "~1Tfog-start: (meters ~m)~%" (-> this fog-start)) + (format #t "~1Tfog-end: (meters ~m)~%" (-> this fog-end)) + (format #t "~1Tfog-max: ~f~%" (-> this fog-max)) + (format #t "~1Tfog-min: ~f~%" (-> this fog-min)) + (format #t "~1Treset: ~D~%" (-> this reset)) + (format #t "~1Tsmooth-step: ~f~%" (-> this smooth-step)) + (format #t "~1Tsmooth-t: ~f~%" (-> this smooth-t)) + (format #t "~1Tperspective: #~%" (-> this perspective)) + (format #t "~1Tisometric: #~%" (-> this isometric)) + (format #t "~1Tsprite-2d: #~%" (-> this sprite-2d)) + (format #t "~1Tsprite-2d-hvdf: #~%" (-> this sprite-2d-hvdf)) + (format #t "~1Tcamera-rot: #~%" (-> this camera-rot)) + (format #t "~1Tinv-camera-rot: #~%" (-> this inv-camera-rot)) + (format #t "~1Tinv-camera-rot-smooth: #~%" (-> this inv-camera-rot-smooth)) + (format #t "~1Tinv-camera-rot-smooth-from: #~%" (-> this inv-camera-rot-smooth-from)) + (format #t "~1Tcamera-temp: #~%" (-> this camera-temp)) + (format #t "~1Tprev-camera-temp: #~%" (-> this prev-camera-temp)) + (format #t "~1Tprev-inv-camera-rot: #~%" (-> this prev-inv-camera-rot)) + (format #t "~1Tprev-trans: ~`vector`P~%" (-> this prev-trans)) + (format #t "~1Thmge-scale: #~%" (-> this hmge-scale)) + (format #t "~1Tinv-hmge-scale: #~%" (-> this inv-hmge-scale)) + (format #t "~1Thvdf-off: #~%" (-> this hvdf-off)) + (format #t "~1Tguard: #~%" (-> this guard)) + (format #t "~1Tvis-gifs[4] @ #x~X~%" (-> this vis-gifs)) + (format #t "~1Tgiftex: ~D~%" (-> this giftex)) + (format #t "~1Tgifgr: ~D~%" (-> this gifgr)) + (format #t "~1Tgiftex-trans: ~D~%" (-> this giftex-trans)) + (format #t "~1Tgifgr-trans: ~D~%" (-> this gifgr-trans)) + (format #t "~1Tpfog0: ~f~%" (-> this pfog0)) + (format #t "~1Tpfog1: ~f~%" (-> this pfog1)) + (format #t "~1Ttrans: ~`vector`P~%" (-> this trans)) + (format #t "~1Tplane[4] @ #x~X~%" (-> this plane)) + (format #t "~1Tguard-plane[4] @ #x~X~%" (-> this guard-plane)) + (format #t "~1Tshrub-mat: #~%" (-> this shrub-mat)) + (format #t "~1Tquat-other: #~%" (-> this quat-other)) + (format #t "~1Ttrans-other: #~%" (-> this trans-other)) + (format #t "~1Tshrub-mat-other: #~%" (-> this shrub-mat-other)) + (format #t "~1Tcamera-temp-other: #~%" (-> this camera-temp-other)) + (format #t "~1Tcamera-rot-other: #~%" (-> this camera-rot-other)) + (format #t "~1Tcamera-rot-other-sky: #~%" (-> this camera-rot-other-sky)) + (format #t "~1Tcamera-rot-other-sprite: #~%" (-> this camera-rot-other-sprite)) + (format #t "~1Tinv-camera-rot-other: #~%" (-> this inv-camera-rot-other)) + (format #t "~1Tplane-other[4] @ #x~X~%" (-> this plane-other)) + (format #t "~1Tguard-plane-other[4] @ #x~X~%" (-> this guard-plane-other)) + (format #t "~1Tmirror-trans: #~%" (-> this mirror-trans)) + (format #t "~1Tmirror-normal: #~%" (-> this mirror-normal)) + (format #t "~1Tfov-correction-factor: ~f~%" (-> this fov-correction-factor)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/math-camera_REF.gc b/test/decompiler/reference/jak3/engine/gfx/math-camera_REF.gc new file mode 100644 index 00000000000..5f4379ae526 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/math-camera_REF.gc @@ -0,0 +1,646 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type fog-corrector +(deftype fog-corrector (structure) + "The math-camera matrices are used to compute fogging values, which are a per-vertex uint8 that +tells the GS how 'foggy' the color should be. This should be proportional to how far away the vertex +is. There is a scaling factor applied so the fog intensity isn't affected by the field of view angle. + +The fog-corrector stores a fog-end fog-start value that is corrected for the field of view. +The actual correction factor is computed in cam-update.gc. +Without this corrector, the fogginess of the world would change as the FOV changes +(for example, when Jak gets on the zoomer, the FOV changes slightly)." + ((fog-end float) + (fog-start float) + ) + ) + +;; definition for method 3 of type fog-corrector +(defmethod inspect ((this fog-corrector)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'fog-corrector) + (format #t "~1Tfog-end: ~f~%" (-> this fog-end)) + (format #t "~1Tfog-start: ~f~%" (-> this fog-start)) + (label cfg-4) + this + ) + +;; definition for function fog-corrector-setup +;; WARN: Return type mismatch float vs none. +(defun fog-corrector-setup ((arg0 fog-corrector) (arg1 math-camera)) + "Set the fog corrector based on the supplied math-camera." + (set! (-> arg0 fog-end) (* (-> arg1 fog-end) (-> arg1 fov-correction-factor))) + (set! (-> arg0 fog-start) (* (-> arg1 fog-start) (-> arg1 fov-correction-factor))) + (none) + ) + +;; definition for symbol *math-camera-fog-correction*, type fog-corrector +(define *math-camera-fog-correction* (new 'global 'fog-corrector)) + +;; definition for function update-math-camera +;; INFO: Used lq/sq +;; WARN: Stack slot offset 16 signed mismatch +;; WARN: Stack slot offset 16 signed mismatch +;; WARN: Stack slot offset 16 signed mismatch +;; WARN: Stack slot offset 16 signed mismatch +;; ERROR: Failed store: (s.w! a0-43 v1-54) at op 457 +;; ERROR: Failed store: (s.w! (+ a0-43 4) a1-9) at op 461 +;; ERROR: Failed store: (s.w! (+ a0-43 8) a1-10) at op 463 +;; ERROR: Failed store: (s.w! (+ a0-43 12) a1-11) at op 465 +(defun update-math-camera ((arg0 math-camera) (arg1 symbol) (arg2 symbol) (arg3 float)) + "Compute some one-time camera constants. + These should only change when changing aspect ratio." + (local-vars (sv-16 float)) + (set! (-> arg0 x-ratio) (tan (* 0.5 arg3))) + (if (= arg2 'aspect4x3) + (set! (-> arg0 y-ratio) (* 0.75 (-> arg0 x-ratio))) + (set! (-> arg0 y-ratio) (* 0.5625 (-> arg0 x-ratio))) + ) + (let ((f1-3 (-> arg0 x-ratio)) + (f0-7 (-> arg0 y-ratio)) + (v1-6 (-> arg0 cull-info)) + ) + (/ (+ 1.0 (* 4.0 f1-3 f1-3)) (+ 1.0 (* f1-3 f1-3))) + (let ((f2-5 (/ (+ 1.0 (* 4.0 f0-7 f0-7)) (+ 1.0 (* f0-7 f0-7))))) + (set! (-> v1-6 x-fact) (/ (+ 1.0 (* 4.0 f1-3 f1-3)) (* f1-3 (sqrtf (+ 1.0 (* 16.0 f1-3 f1-3)))))) + (set! (-> v1-6 y-fact) (/ (+ 1.0 (* 4.0 f0-7 f0-7)) (* f0-7 (sqrtf (+ 1.0 (* 16.0 f0-7 f0-7)))))) + (set! (-> v1-6 z-fact) (sqrtf (+ (* (+ -4.0 f2-5) (+ -4.0 f2-5) f0-7 f0-7) (* (+ -1.0 f2-5) (+ -1.0 f2-5))))) + ) + (let* ((f2-11 (* f1-3 (-> arg0 d))) + (f1-5 (* f0-7 (-> arg0 d))) + (f0-10 (+ (* f2-11 f2-11) (* f1-5 f1-5))) + (f1-8 (-> arg0 d)) + ) + (set! (-> v1-6 cam-radius) (sqrtf (+ f0-10 (* f1-8 f1-8)))) + ) + (let* ((f1-12 (* (-> arg0 d) (-> arg0 x-ratio))) + (f0-14 (-> arg0 d)) + (f2-13 (* 4.0 f1-12)) + (f3-21 (-> arg0 d)) + ) + (let ((f4-21 (/ 1.0 (sqrtf (+ (* f1-12 f1-12) (* f0-14 f0-14))))) + (f5-11 (/ 1.0 (sqrtf (+ (* f2-13 f2-13) (* f3-21 f3-21))))) + ) + (set! (-> v1-6 xz-dir-ax) (* f1-12 f4-21)) + (set! (-> v1-6 xz-dir-az) (* f0-14 f4-21)) + (set! (-> v1-6 xz-dir-bx) (* f2-13 f5-11)) + (set! (-> v1-6 xz-dir-bz) (* f3-21 f5-11)) + ) + (set! (-> v1-6 xz-cross-ab) (- (* f1-12 f3-21) (* f0-14 f2-13))) + ) + (let* ((f1-15 (* (-> arg0 d) (-> arg0 y-ratio))) + (f0-18 (-> arg0 d)) + (f2-15 (* 4.0 f1-15)) + (f3-22 (-> arg0 d)) + ) + (let ((f4-26 (/ 1.0 (sqrtf (+ (* f1-15 f1-15) (* f0-18 f0-18))))) + (f5-16 (/ 1.0 (sqrtf (+ (* f2-15 f2-15) (* f3-22 f3-22))))) + ) + (set! (-> v1-6 yz-dir-ay) (* f1-15 f4-26)) + (set! (-> v1-6 yz-dir-az) (* f0-18 f4-26)) + (set! (-> v1-6 yz-dir-by) (* f2-15 f5-16)) + (set! (-> v1-6 yz-dir-bz) (* f3-22 f5-16)) + ) + (set! (-> v1-6 yz-cross-ab) (- (* f1-15 f3-22) (* f0-18 f2-15))) + ) + ) + (fog-corrector-setup *math-camera-fog-correction* arg0) + (matrix-identity! (-> arg0 camera-rot)) + (let ((f0-21 100.0) + (f2-16 16760631.0) + ) + 16777115.0 + (let ((f30-0 (/ (* (-> arg0 d) (- (-> arg0 fog-min) (-> arg0 fog-max))) + (- (-> *math-camera-fog-correction* fog-end) (-> *math-camera-fog-correction* fog-start)) + ) + ) + (f1-21 (* -0.5 (- f2-16 f0-21))) + ) + (let ((f4-34 (/ f1-21 (* (-> arg0 d) (- (-> arg0 f) (-> arg0 d))))) + (f3-30 (-> arg0 fov-correction-factor)) + ) + (set! (-> arg0 perspective rvec x) (* f3-30 (- (/ (-> arg0 x-pix) (* (-> arg0 x-ratio) (-> arg0 d)))))) + (set! (-> arg0 perspective uvec y) (* f3-30 (- (/ (-> arg0 y-pix) (* (-> arg0 y-ratio) (-> arg0 d)))))) + (set! (-> arg0 perspective fvec z) (* f3-30 (+ (-> arg0 f) (-> arg0 d)) f4-34)) + (set! (-> arg0 perspective fvec w) (* (/ f3-30 (-> arg0 d)) f30-0)) + (set! (-> arg0 perspective trans z) (* -2.0 f4-34 (-> arg0 f) (-> arg0 d) f3-30)) + ) + (let ((f24-0 2048.0) + (f26-0 2048.0) + (f28-0 (/ (- (* (-> *math-camera-fog-correction* fog-end) (-> arg0 fog-max)) + (* (-> *math-camera-fog-correction* fog-start) (-> arg0 fog-min)) + ) + (- (-> *math-camera-fog-correction* fog-end) (-> *math-camera-fog-correction* fog-start)) + ) + ) + ) + (let ((f22-0 (* 0.5 (+ f2-16 f0-21)))) + (set! (-> arg0 hmge-scale x) (/ 1.0 (-> arg0 x-clip))) + (set! (-> arg0 hmge-scale y) (/ 1.0 (-> arg0 y-clip))) + (set! (-> arg0 hmge-scale z) (/ 1.0 f1-21)) + (set! (-> arg0 hmge-scale w) (/ 1.0 f30-0)) + (set! (-> arg0 inv-hmge-scale x) (-> arg0 x-clip)) + (set! (-> arg0 inv-hmge-scale y) (-> arg0 y-clip)) + (set! (-> arg0 inv-hmge-scale z) f1-21) + (set! (-> arg0 inv-hmge-scale w) f30-0) + (cond + ((or (zero? *screen-shot-work*) (= (-> *screen-shot-work* count) -1)) + (set! (-> arg0 hvdf-off x) f24-0) + (set! (-> arg0 hvdf-off y) f26-0) + ) + (else + (let* ((v1-32 (-> *screen-shot-work* count)) + (a0-36 (-> *screen-shot-work* size)) + (f0-34 (the float a0-36)) + (f20-0 (/ (the float (mod v1-32 a0-36)) f0-34)) + ) + (set! sv-16 (/ (the float (/ v1-32 a0-36)) f0-34)) + (format 0 "~f ~f~%" f20-0 sv-16) + (set! (-> arg0 hvdf-off x) (- f24-0 f20-0)) + ) + (set! (-> arg0 hvdf-off y) (- f26-0 sv-16)) + ) + ) + (set! (-> arg0 hvdf-off z) f22-0) + (set! (-> arg0 hvdf-off w) f28-0) + (set! (-> arg0 guard x) (/ (-> arg0 x-clip) (-> arg0 x-pix))) + (set! (-> arg0 guard y) (/ (-> arg0 y-clip) (-> arg0 y-pix))) + (set! (-> arg0 guard z) 1.0) + (set! (-> arg0 guard w) 1.0) + (set! (-> arg0 isometric trans z) (- 16777215.0 f22-0)) + ) + (set! (-> arg0 isometric trans w) f30-0) + (let ((f1-28 (-> arg0 perspective rvec x)) + (f2-19 (-> arg0 perspective uvec y)) + (f0-48 (* -1.9996 (-> arg0 perspective rvec x))) + ) + (let ((v1-39 (-> arg0 sprite-2d))) + (set! (-> v1-39 rvec x) f0-48) + (set! (-> v1-39 rvec y) 0.0) + (set! (-> v1-39 rvec z) 0.0) + (set! (-> v1-39 rvec w) 0.0) + ) + (set-vector! (-> arg0 sprite-2d uvec) 0.0 (- (* (/ f2-19 f1-28) f0-48)) 0.0 0.0) + (set-vector! (-> arg0 sprite-2d fvec) 0.0 0.0 (- f0-48) 0.0) + (set-vector! (-> arg0 sprite-2d trans) 0.0 0.0 (* 500000000.0 f0-48) (* 60.0 f0-48 (-> arg0 pfog0))) + ) + (set! (-> arg0 sprite-2d-hvdf quad) (-> arg0 hvdf-off quad)) + (set! (-> arg0 sprite-2d-hvdf x) 2048.0) + (set! (-> arg0 sprite-2d-hvdf y) 2048.0) + (set! (-> arg0 sprite-2d-hvdf z) (-> arg0 hvdf-off z)) + (set! (-> arg0 pfog0) f30-0) + (set! (-> arg0 pfog1) f28-0) + ) + ) + ) + 0 + (make-u128 0 (shl #x301ec000 32)) + (make-u128 0 (shl #x303ec000 32)) + (let ((v1-54 (-> arg0 pfog0))) + (let ((a0-42 (-> arg0 vis-gifs))) + (set! (-> a0-42 0) (the-as vis-gif-tag v1-54)) + (set! (-> a0-42 1) (the-as vis-gif-tag #x301e4000)) + (set! (-> a0-42 2) (the-as vis-gif-tag 1042)) + (set! (-> a0-42 3) (the-as vis-gif-tag #x301ec000)) + ) + (let ((a0-43 (&-> arg0 gifgr))) + (s.w! a0-43 v1-54) + (let ((a1-9 (make-u128 0 (shl #x20164000 32)))) + (s.w! (+ a0-43 4) a1-9) + ) + (let ((a1-10 65)) + (s.w! (+ a0-43 8) a1-10) + ) + (let ((a1-11 #x301ec000)) + (s.w! (+ a0-43 12) a1-11) + ) + ) + (let ((a0-44 (-> arg0 vis-gifs))) + (set! (-> a0-44 0) (the-as vis-gif-tag v1-54)) + (set! (-> a0-44 1) (the-as vis-gif-tag #x303e4000)) + (set! (-> a0-44 2) (the-as vis-gif-tag 1042)) + (set! (-> a0-44 3) (the-as vis-gif-tag #x303ec000)) + ) + (let ((a0-45 (-> arg0 vis-gifs))) + (set! (-> a0-45 0) (the-as vis-gif-tag v1-54)) + (set! (-> a0-45 1) (the-as vis-gif-tag #x303e4000)) + (set! (-> a0-45 2) (the-as vis-gif-tag 1042)) + (set! (-> a0-45 3) (the-as vis-gif-tag #x303ec000)) + ) + ) + (if (nonzero? sprite-distorter-generate-tables) + (sprite-distorter-generate-tables) + ) + arg0 + ) + +;; definition for method 0 of type math-camera +(defmethod new math-camera ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> gp-0 d) 1024.0) + (set! (-> gp-0 f) 40960000.0) + (set! (-> gp-0 fov) 11650.845) + (set! (-> gp-0 x-pix) 256.0) + (set! (-> gp-0 x-clip) 512.0) + (set! (-> gp-0 y-pix) 208.0) + (set! (-> gp-0 y-clip) 416.0) + (set! (-> gp-0 fog-start) 40960.0) + (set! (-> gp-0 fog-end) 819200.0) + (set! (-> gp-0 fog-max) 255.0) + (set! (-> gp-0 fog-min) 150.0) + (matrix-identity! (-> gp-0 inv-camera-rot)) + (matrix-identity! (-> gp-0 camera-rot)) + (vector-reset! (-> gp-0 trans)) + (quaternion-identity! (-> gp-0 quat-other)) + (set-vector! (-> gp-0 trans-other) 0.0 0.0 0.0 1.0) + (matrix-identity! (-> gp-0 inv-camera-rot-other)) + (matrix-identity! (-> gp-0 camera-rot-other)) + (matrix-identity! (-> gp-0 camera-temp-other)) + (set! (-> gp-0 isometric rvec x) 1.0) + (set! (-> gp-0 isometric uvec y) 0.5) + (set! (-> gp-0 isometric fvec z) -1.0) + (set! (-> gp-0 reset) 1) + (set! (-> gp-0 smooth-step) 0.0) + (set! (-> gp-0 smooth-t) 0.0) + (update-math-camera gp-0 'ntsc 'aspect4x3 (-> gp-0 fov)) + ) + ) + +;; definition for symbol *math-camera*, type math-camera +(define *math-camera* (new 'global 'math-camera)) + +;; definition for function math-cam-start-smoothing +(defun math-cam-start-smoothing ((arg0 float) (arg1 float)) + "Unused camera smoothing." + (set! (-> *math-camera* smooth-step) (/ 1.0 arg0)) + (set! (-> *math-camera* smooth-t) arg1) + (matrix->quaternion (-> *math-camera* inv-camera-rot-smooth-from) (-> *math-camera* inv-camera-rot-smooth)) + ) + +;; definition for function move-target-from-pad +;; INFO: Used lq/sq +(defun move-target-from-pad ((arg0 transform) (arg1 int)) + "Unused function to adjust trans based on inputs from the pad. + This function must be extremely old because it takes a non-quaternion transform, + and all [[target]] stuff uses quaternions." + (let ((s4-0 (new-stack-vector0))) + (set! (-> s4-0 x) (cond + ((cpad-hold? arg1 circle) + -80.0 + ) + ((cpad-hold? arg1 square) + 80.0 + ) + (else + 0.0 + ) + ) + ) + (set! (-> s4-0 y) 0.0) + (set! (-> s4-0 z) (cond + ((cpad-hold? arg1 down) + -80.0 + ) + ((cpad-hold? arg1 up) + 80.0 + ) + (else + 0.0 + ) + ) + ) + (set! (-> s4-0 w) 1.0) + (let ((a0-5 (new-stack-vector0)) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (set! (-> s3-0 rvec quad) (the-as uint128 0)) + (set! (-> s3-0 uvec quad) (the-as uint128 0)) + (set! (-> s3-0 fvec quad) (the-as uint128 0)) + (set! (-> s3-0 trans quad) (the-as uint128 0)) + (vector-negate! a0-5 (-> arg0 rot)) + (matrix-rotate-zyx! s3-0 (-> arg0 rot)) + (vector-matrix*! s4-0 s4-0 s3-0) + ) + (vector+! (-> arg0 trans) (-> arg0 trans) s4-0) + ) + (set! (-> arg0 trans w) 1.0) + (if (cpad-hold? arg1 r1) + (+! (-> arg0 trans y) 80.0) + ) + (if (cpad-hold? arg1 r2) + (+! (-> arg0 trans y) -80.0) + ) + (if (cpad-hold? arg1 x) + (+! (-> arg0 rot x) 546.13336) + ) + (if (cpad-hold? arg1 triangle) + (+! (-> arg0 rot x) -546.13336) + ) + (if (cpad-hold? arg1 left) + (+! (-> arg0 rot y) 546.13336) + ) + (if (cpad-hold? arg1 right) + (+! (-> arg0 rot y) -546.13336) + ) + arg0 + ) + +;; definition for function transform-point-vector! +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +(defun transform-point-vector! ((arg0 vector) (arg1 vector)) + "Apply camera transformation to a point. Return true if it is visible or not. + This returns the point in GS coords, but as float instead of int, so it's + not really useful. See [[transform-point-qword!]] for more details." + (local-vars (v1-2 int)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + 0 + (let ((v1-1 *math-camera*)) + (.lvf vf24 (&-> v1-1 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-1 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-1 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-1 camera-temp trans quad)) + (.lvf vf29 (&-> v1-1 hmge-scale quad)) + (.lvf vf30 (&-> v1-1 hvdf-off quad)) + ) + (.lvf vf28 (&-> arg1 quad)) + (.mul.x.vf acc vf24 vf28) + (.add.mul.y.vf acc vf25 vf28 acc) + (.add.mul.z.vf acc vf26 vf28 acc) + (.add.mul.w.vf vf28 vf27 vf0 acc) + (.add.w.vf vf23 vf0 vf0) + (.mul.vf vf31 vf28 vf29) + (TODO.VCLIP vf31 vf31) + (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) + (.wait.vf) + (.cfc2.i v1-2 Clipping) + (.mul.vf vf28 vf28 Q :mask #b111) + (.mul.vf vf23 vf23 Q) + (.add.vf vf28 vf28 vf30) + (.max.x.vf vf28 vf28 vf0 :mask #b1000) + (.svf (&-> arg0 quad) vf28) + (not (logtest? v1-2 63)) + ) + ) + +;; definition for function transform-point-qword! +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +(defun transform-point-qword! ((arg0 vector4w) (arg1 vector)) + "Apply camera transformation to point, returning fixed point 28.4 position + that can be given to the GS directly." + (local-vars (v1-2 int)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + 0 + (let ((v1-1 *math-camera*)) + (.lvf vf24 (&-> v1-1 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-1 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-1 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-1 camera-temp trans quad)) + (.lvf vf29 (&-> v1-1 hmge-scale quad)) + (.lvf vf30 (&-> v1-1 hvdf-off quad)) + ) + (.lvf vf28 (&-> arg1 quad)) + (.mul.x.vf acc vf24 vf28) + (.add.mul.y.vf acc vf25 vf28 acc) + (.add.mul.z.vf acc vf26 vf28 acc) + (.add.mul.w.vf vf28 vf27 vf0 acc) + (.add.w.vf vf23 vf0 vf0) + (.mul.vf vf31 vf28 vf29) + (TODO.VCLIP vf31 vf31) + (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) + (.wait.vf) + (.cfc2.i v1-2 Clipping) + (.mul.vf vf28 vf28 Q :mask #b111) + (.mul.vf vf23 vf23 Q) + (.add.vf vf28 vf28 vf30) + (.max.x.vf vf28 vf28 vf0 :mask #b1000) + (vftoi4.xyzw vf28 vf28) + (.svf (&-> arg0 quad) vf28) + (not (logtest? v1-2 63)) + ) + ) + +;; definition for function transform-point-vector-scale! +;; ERROR: Inline assembly instruction marked with TODO - [TODO.VCLIP] +;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v1, Clipping] +(defun transform-point-vector-scale! ((arg0 vector) (arg1 vector)) + "Similar to transform-point-qword! but returns the scale factor instead." + (local-vars (v0-0 float) (v1-2 int)) + (rlet ((acc :class vf) + (Q :class vf) + (vf0 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf30 :class vf) + (vf31 :class vf) + ) + (init-vf0-vector) + 0 + (let ((v1-1 *math-camera*)) + (.lvf vf24 (&-> v1-1 camera-temp rvec quad)) + (.lvf vf25 (&-> v1-1 camera-temp uvec quad)) + (.lvf vf26 (&-> v1-1 camera-temp fvec quad)) + (.lvf vf27 (&-> v1-1 camera-temp trans quad)) + (.lvf vf29 (&-> v1-1 hmge-scale quad)) + (.lvf vf30 (&-> v1-1 hvdf-off quad)) + ) + (.lvf vf28 (&-> arg1 quad)) + (.mul.x.vf acc vf24 vf28) + (.add.mul.y.vf acc vf25 vf28 acc) + (.add.mul.z.vf acc vf26 vf28 acc) + (.add.mul.w.vf vf28 vf27 vf0 acc) + (.add.w.vf vf23 vf0 vf0) + (.mul.vf vf31 vf28 vf29) + (TODO.VCLIP vf31 vf31) + (.div.vf Q vf0 vf31 :fsf #b11 :ftf #b11) + (.wait.vf) + (.cfc2.i v1-2 Clipping) + (.mul.vf vf28 vf28 Q :mask #b111) + (.mul.vf vf23 vf23 Q) + (.add.vf vf28 vf28 vf30) + (.max.x.vf vf28 vf28 vf0 :mask #b1000) + (.svf (&-> arg0 quad) vf28) + (not (logtest? v1-2 63)) + (.mov v0-0 vf23) + v0-0 + ) + ) + +;; definition for function reverse-transform-point! +;; WARN: Return type mismatch vector vs none. +(defun reverse-transform-point! ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 vector)) + "Likely transform arg3 from screen space to world coords, using arg1/arg2 for... something." + (let* ((v1-1 (-> *math-camera* perspective)) + (s2-0 (-> *math-camera* camera-rot)) + (f30-0 (* (/ (-> v1-1 fvec w) (-> v1-1 rvec x)) (-> *math-camera* hmge-scale w))) + (f28-0 (* (/ (-> v1-1 fvec w) (-> v1-1 uvec y)) (-> *math-camera* hmge-scale w))) + (s4-0 (vector-rotate*! (new 'stack-no-clear 'vector) arg2 s2-0)) + (v1-3 (vector-matrix*! (new 'stack-no-clear 'vector) arg1 s2-0)) + (f0-8 (/ (+ (* (-> s4-0 x) (-> v1-3 x)) (* (-> s4-0 y) (-> v1-3 y)) (* (-> s4-0 z) (-> v1-3 z))) + (+ (* (-> s4-0 x) (-> arg3 x) f30-0) (* (-> s4-0 y) (-> arg3 y) f28-0) (-> s4-0 z)) + ) + ) + (f1-16 (* (-> arg3 x) f0-8 f30-0)) + (f2-9 (* (-> arg3 y) f0-8 f28-0)) + (t9-2 vector-matrix*!) + (a0-5 arg0) + (a1-3 (new 'stack-no-clear 'vector)) + ) + (set! (-> a1-3 x) f1-16) + (set! (-> a1-3 y) f2-9) + (set! (-> a1-3 z) f0-8) + (set! (-> a1-3 w) 1.0) + (t9-2 a0-5 a1-3 (-> *math-camera* inv-camera-rot)) + ) + (none) + ) + +;; definition for function init-for-transform +;; INFO: Used lq/sq +;; WARN: Return type mismatch symbol vs none. +(defun init-for-transform ((arg0 matrix)) + "Sets up VU0 registers with camera info. + This is probably a very old function and it's only used by camera debug. + It stashes some data in vector float registers that must be there before calling transform-float-point." + (local-vars (v1-14 float)) + (rlet ((vf1 :class vf) + (vf17 :class vf) + (vf18 :class vf) + (vf19 :class vf) + (vf2 :class vf) + (vf23 :class vf) + (vf24 :class vf) + (vf25 :class vf) + (vf26 :class vf) + (vf27 :class vf) + (vf28 :class vf) + (vf29 :class vf) + (vf3 :class vf) + (vf4 :class vf) + (vf6 :class vf) + (vf7 :class vf) + (vf8 :class vf) + (vf9 :class vf) + ) + (let ((gp-0 (new 'stack-no-clear 'matrix))) + (set! (-> gp-0 rvec quad) (the-as uint128 0)) + (set! (-> gp-0 uvec quad) (the-as uint128 0)) + (set! (-> gp-0 fvec quad) (the-as uint128 0)) + (set! (-> gp-0 trans quad) (the-as uint128 0)) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (set! (-> s5-0 rvec quad) (the-as uint128 0)) + (set! (-> s5-0 uvec quad) (the-as uint128 0)) + (set! (-> s5-0 fvec quad) (the-as uint128 0)) + (set! (-> s5-0 trans quad) (the-as uint128 0)) + (let ((s4-0 (new 'stack 'vector4s-3)) + (s3-0 (new-stack-vector0)) + ) + (let ((s2-0 (new 'stack 'vector4s-3))) + (matrix*! s5-0 arg0 (-> *math-camera* camera-temp)) + (matrix-3x3-inverse-transpose! gp-0 arg0) + (set-vector! s3-0 0.4 0.4 0.4 1.0) + (let ((v1-4 (-> s4-0 data))) + (set! (-> v1-4 0) 1.0) + (set! (-> v1-4 1) 1.0) + (set! (-> v1-4 2) 1.0) + (set! (-> v1-4 3) 1.0) + ) + (let ((v1-5 (&-> s4-0 data 4))) + (set! (-> v1-5 0) 0.0) + (set! (-> v1-5 1) 0.0) + (set! (-> v1-5 2) 0.0) + (set! (-> v1-5 3) 1.0) + ) + (let ((v1-6 (&-> s4-0 data 8))) + (set! (-> v1-6 0) 0.0) + (set! (-> v1-6 1) 0.0) + (set! (-> v1-6 2) 0.0) + (set! (-> v1-6 3) 1.0) + ) + (let ((v1-7 (-> s2-0 data))) + (set! (-> v1-7 0) 1.0) + (set! (-> v1-7 1) 0.0) + (set! (-> v1-7 2) 0.0) + (set! (-> v1-7 3) 1.0) + ) + (let ((v1-8 (&-> s2-0 data 4))) + (set! (-> v1-8 0) 0.0) + (set! (-> v1-8 1) 1.0) + (set! (-> v1-8 2) 0.0) + (set! (-> v1-8 3) 1.0) + ) + (let ((v1-9 (&-> s2-0 data 8))) + (set! (-> v1-9 0) 0.0) + (set! (-> v1-9 1) 0.0) + (set! (-> v1-9 2) 1.0) + (set! (-> v1-9 3) 1.0) + ) + (.lvf vf7 (&-> *math-camera* hmge-scale quad)) + (.lvf vf8 (&-> *math-camera* hvdf-off quad)) + (.lvf vf9 (&-> *math-camera* giftex)) + (let ((v1-13 255)) + (.mov vf6 v1-13) + ) + (.mov v1-14 vf6) + (.itof.vf vf6 vf6) + (.lvf vf1 (&-> s5-0 rvec quad)) + (.lvf vf2 (&-> s5-0 uvec quad)) + (.lvf vf3 (&-> s5-0 fvec quad)) + (.lvf vf4 (&-> s5-0 trans quad)) + (.lvf vf17 (&-> gp-0 rvec quad)) + (.lvf vf18 (&-> gp-0 uvec quad)) + (.lvf vf19 (&-> gp-0 fvec quad)) + (.lvf vf23 (&-> s2-0 quad 0)) + (.lvf vf24 (&-> s2-0 quad 1)) + (.lvf vf25 (&-> s2-0 quad 2)) + ) + (.lvf vf27 (&-> s4-0 quad 0)) + (.lvf vf28 (&-> s4-0 quad 1)) + (.lvf vf29 (&-> s4-0 quad 2)) + (.lvf vf26 (&-> s3-0 quad)) + ) + ) + ) + (none) + ) + ) + + + + diff --git a/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc b/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc new file mode 100644 index 00000000000..f46a9c688eb --- /dev/null +++ b/test/decompiler/reference/jak3/engine/gfx/texture/texture-h_REF.gc @@ -0,0 +1,1536 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type texture-id +(deftype texture-id (uint32) + "Unique identifier for a texture +as the tpage number and index of the texture within the tpage." + ((index uint16 :offset 8 :size 12) + (page uint16 :offset 20 :size 12) + ) + ) + +;; definition for method 3 of type texture-id +(defmethod inspect ((this texture-id)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-id) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tpage: ~D~%" (-> this page)) + (label cfg-4) + this + ) + +;; definition of type texture-pool-segment +(deftype texture-pool-segment (structure) + "A chunk of VRAM." + ((dest uint32) + (size uint32) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type texture-pool-segment +(defmethod inspect ((this texture-pool-segment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-pool-segment) + (format #t "~1Tdest: #x~X~%" (-> this dest)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (label cfg-4) + this + ) + +;; definition of type texture-pool +(deftype texture-pool (basic) + "The manager for the VRAM." + ((top int32) + (cur int32) + (allocate-func (function texture-pool texture-page kheap int texture-page)) + (font-palette int32) + (segment texture-pool-segment 4 :inline) + (segment-near texture-pool-segment :inline :overlay-at (-> segment 0)) + (segment-common texture-pool-segment :inline :overlay-at (-> segment 1)) + (common-page texture-page 32) + (common-page-mask int32) + (update-sprites-flag symbol) + (update-flag symbol) + (texture-enable-user uint64) + (texture-enable-user-menu uint64) + (ids uint32 128) + ) + (:methods + (new (symbol type) _type_) + (initialize! (_type_) _type_) + (print-usage (_type_) _type_) + (setup-font-texture (_type_) none) + (allocate-defaults (_type_) none) + (login-level-textures (_type_ level int (pointer texture-id)) none) + (add-level-tpage-dma (_type_ level tpage-category bucket-id) none) + (allocate-vram-words! (_type_ int) int) + (allocate-segment (_type_ texture-pool-segment int) texture-pool-segment) + (unload-page (_type_ texture-page) none) + (get-common-page-slot-by-id (_type_ int) int) + (update-warp-and-hud (_type_) none) + (update-sprites (_type_) none) + (mark-hud-warp-sprite-dirty (_type_) none) + (lay-out-sprite-tex (_type_) none) + (lay-out-hud-tex (_type_) none) + (lay-out-warp-tex (_type_) none) + (clear-ids (_type_) none) + ) + ) + +;; definition for method 3 of type texture-pool +(defmethod inspect ((this texture-pool)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Ttop: #x~X~%" (-> this top)) + (format #t "~1Tcur: #x~X~%" (-> this cur)) + (format #t "~1Tallocate-func: ~A~%" (-> this allocate-func)) + (format #t "~1Tfont-palette: ~D~%" (-> this font-palette)) + (format #t "~1Tsegment[4] @ #x~X~%" (-> this segment)) + (format #t "~1Tsegment-near: #~%" (-> this segment)) + (format #t "~1Tsegment-common: #~%" (-> this segment-common)) + (format #t "~1Tcommon-page[32] @ #x~X~%" (-> this common-page)) + (format #t "~1Tcommon-page-mask: ~D~%" (-> this common-page-mask)) + (format #t "~1Tupdate-sprites-flag: ~A~%" (-> this update-sprites-flag)) + (format #t "~1Tupdate-flag: ~A~%" (-> this update-flag)) + (format #t "~1Ttexture-enable-user: ~D~%" (-> this texture-enable-user)) + (format #t "~1Ttexture-enable-user-menu: ~D~%" (-> this texture-enable-user-menu)) + (format #t "~1Tids[128] @ #x~X~%" (-> this ids)) + (label cfg-4) + this + ) + +;; definition of type texture-mask +(deftype texture-mask (structure) + "Mask where each bit indicates if some part of a tpage is used, by a texture. +Additionally, the w component holds a minimum distance. The texture is only needed +if the distance to the object is smaller than this." + ((mask vector4w :inline) + (dist float :overlay-at (-> mask data 3)) + (long uint64 2 :overlay-at (-> mask data 0)) + (quad uint128 :overlay-at (-> mask data 0)) + ) + ) + +;; definition for method 3 of type texture-mask +;; INFO: Used lq/sq +(defmethod inspect ((this texture-mask)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-mask) + (format #t "~1Tmask: #~%" (-> this mask)) + (format #t "~1Tdist: ~f~%" (-> this dist)) + (format #t "~1Tlong[2] @ #x~X~%" (-> this mask)) + (format #t "~1Tquad: ~D~%" (-> this mask quad)) + (label cfg-4) + this + ) + +;; definition of type texture-masks +(deftype texture-masks (structure) + "Grouping of three masks, corresponding to the 3 segments of the texture. +So mask 0 is needed if segment 0 of the texture is needed, etc..." + ((data texture-mask 3 :inline) + ) + ) + +;; definition for method 3 of type texture-masks +(defmethod inspect ((this texture-masks)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-masks) + (format #t "~1Tdata[3] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type texture-masks-array +(deftype texture-masks-array (inline-array-class) + "Group of all texture-masks for a given tpage." + ((data texture-masks :dynamic) + ) + ) + +;; definition for method 3 of type texture-masks-array +(defmethod inspect ((this texture-masks-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> texture-masks-array heap-base) (the-as uint 48)) + +;; definition for symbol *texture-masks*, type texture-masks +(define *texture-masks* (the-as texture-masks #f)) + +;; definition for symbol *texture-masks-array*, type texture-masks-array +(define *texture-masks-array* (the-as texture-masks-array #f)) + +;; definition of type texture +(deftype texture (basic) + "Metadata for a texture." + ((w int16) + (h int16) + (num-mips uint8) + (tex1-control uint8) + (psm uint8) + (mip-shift uint8) + (clutpsm uint16) + (dest uint16 7) + (clutdest uint16) + (width uint8 7) + (name string) + (size uint32) + (uv-dist float) + (pad uint32 3) + (masks texture-masks :inline) + ) + ) + +;; definition for method 3 of type texture +(defmethod inspect ((this texture)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tw: ~D~%" (-> this w)) + (format #t "~1Th: ~D~%" (-> this h)) + (format #t "~1Tnum-mips: ~D~%" (-> this num-mips)) + (format #t "~1Ttex1-control: ~D~%" (-> this tex1-control)) + (format #t "~1Tpsm: ~D~%" (-> this psm)) + (format #t "~1Tmip-shift: ~D~%" (-> this mip-shift)) + (format #t "~1Tclutpsm: ~D~%" (-> this clutpsm)) + (format #t "~1Tdest[7] @ #x~X~%" (-> this dest)) + (format #t "~1Tclutdest: ~D~%" (-> this clutdest)) + (format #t "~1Twidth[7] @ #x~X~%" (-> this width)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (format #t "~1Tuv-dist: ~f~%" (-> this uv-dist)) + (format #t "~1Tpad[3] @ #x~X~%" (-> this pad)) + (format #t "~1Tmasks: #~%" (-> this masks)) + (label cfg-4) + this + ) + +;; definition of type texture-page-segment +(deftype texture-page-segment (structure) + "Metadata for a 'segment' of a texture page. +Each texture page has 3 segments - smaller number segments have higher detail mips." + ((block-data pointer) + (size uint32) + (dest uint32) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type texture-page-segment +(defmethod inspect ((this texture-page-segment)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-page-segment) + (format #t "~1Tblock-data: #x~X~%" (-> this block-data)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (format #t "~1Tdest: #x~X~%" (-> this dest)) + (label cfg-4) + this + ) + +;; definition for function texture-mip->segment +(defun texture-mip->segment ((arg0 int) (arg1 int)) + "Figure out which segment of a tpage a given mip level of a texture will be in. + arg0 is the mip level, arg1 is the total number of mips. + Higher mip level is lower detail." + (if (>= 2 arg1) + (+ (- -1 arg0) arg1) + (max 0 (- 2 arg0)) + ) + ) + +;; definition of type texture-page +(deftype texture-page (basic) + "A collection of textures. There is a tpage per category per level. +These tpages are loaded from the DVD. +e.g.: prison tfrag is its own tpage. +The tpage has multiple textures, and 3 segments. +Lower number segments are larger and have hi-res versions of textures." + ((info file-info) + (name string) + (id uint32) + (length int32) + (mip0-size uint32) + (size uint32) + (segment texture-page-segment 3 :inline) + (dram-size uint32) + (vram-size uint32) + (pad uint32 14) + (data texture :dynamic) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) texture-page :replace) + (remove-data-from-heap (_type_ kheap) _type_) + (get-leftover-block-count (_type_ int int) int) + (relocate-dests! (_type_ int int) none) + (add-to-dma-buffer (_type_ dma-buffer tex-upload-mode) int) + (upload-now! (_type_ tex-upload-mode) none) + ) + ) + +;; definition for method 3 of type texture-page +(defmethod inspect ((this texture-page)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tinfo: ~A~%" (-> this info)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tid: ~D~%" (-> this id)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tmip0-size: ~D~%" (-> this mip0-size)) + (format #t "~1Tsize: #x~X~%" (-> this size)) + (format #t "~1Tsegment[3] @ #x~X~%" (-> this segment)) + (format #t "~1Tdram-size: ~D~%" (-> this dram-size)) + (format #t "~1Tvram-size: ~D~%" (-> this vram-size)) + (format #t "~1Tpad[14] @ #x~X~%" (-> this pad)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; definition of type shader-ptr +(deftype shader-ptr (uint32) + "A pointer to an adgif-shader, stored in bits 8-32. This allows them to fit into +an adgif shader easily." + ((first-8 uint8 :offset 0 :size 8) + (shader uint32 :offset 8 :size 24) + ) + ) + +;; definition of type texture-link +(deftype texture-link (structure) + "An overlay structure containing a shader-ptr that points to the next adgif-shader +in a linked list." + ((next shader-ptr 1) + ) + ) + +;; definition for method 3 of type texture-link +(defmethod inspect ((this texture-link)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-link) + (format #t "~1Tnext: #x~X~%" (-> this next 0)) + (label cfg-4) + this + ) + +;; definition of type texture-page-dir-entry +(deftype texture-page-dir-entry (structure) + "An entry for a texture in the texture-page-dir. +The texture-page-dir contains an entry for each tpage. +Each entry contains a reference to the tpage, and a linked list of shaders +using it." + ((length int16) + (status uint16) + (page texture-page) + (link texture-link) + ) + :pack-me + :allow-misaligned + ) + +;; definition for method 3 of type texture-page-dir-entry +(defmethod inspect ((this texture-page-dir-entry)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-page-dir-entry) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tstatus: ~D~%" (-> this status)) + (format #t "~1Tpage: ~A~%" (-> this page)) + (format #t "~1Tlink: #x~X~%" (-> this link)) + (label cfg-4) + this + ) + +;; definition of type texture-page-dir +(deftype texture-page-dir (basic) + "The list of all texture pages. +This is static data loaded from the DVD at boot." + ((length int32) + (entries texture-page-dir-entry 1 :inline) + ) + (:methods + (relocate (_type_ kheap (pointer uint8)) none :replace) + (unlink-shaders-in-heap (_type_ kheap) int) + ) + ) + +;; definition of type texture-relocate-later +(deftype texture-relocate-later (basic) + "Unused in Jak 2, but metadata for postponing tpage copies until a second frame, +to have a smaller impact on frame times when loading." + ((memcpy symbol) + (dest uint32) + (source uint32) + (move uint32) + (entry texture-page-dir-entry) + (page texture-page) + ) + ) + +;; definition for method 3 of type texture-relocate-later +(defmethod inspect ((this texture-relocate-later)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tmemcpy: ~A~%" (-> this memcpy)) + (format #t "~1Tdest: ~D~%" (-> this dest)) + (format #t "~1Tsource: ~D~%" (-> this source)) + (format #t "~1Tmove: ~D~%" (-> this move)) + (format #t "~1Tentry: #~%" (-> this entry)) + (format #t "~1Tpage: ~A~%" (-> this page)) + (label cfg-4) + this + ) + +;; definition for symbol *texture-relocate-later*, type texture-relocate-later +(define *texture-relocate-later* (new 'global 'texture-relocate-later)) + +;; failed to figure out what this is: +(set! (-> *texture-relocate-later* memcpy) #f) + +;; definition for symbol *texture-page-dir*, type texture-page-dir +(define *texture-page-dir* (the-as texture-page-dir #f)) + +;; definition of type adgif-shader +(deftype adgif-shader (structure) + "GS texturing/blending settings, called adgif-shader. +These are used by many different renderers and partially managed by the texture system. +For example, the texture system will automatically update tbp to point to the location +of the texture." + ((quad qword 5 :inline) + (prims gs-reg64 10 :overlay-at quad) + (reg-0 uint8 :overlay-at (-> quad 0 data 2)) + (reg-1 uint8 :overlay-at (-> prims 3)) + (reg-2 uint8 :overlay-at (-> prims 5)) + (reg-3 uint8 :overlay-at (-> prims 7)) + (reg-4 uint8 :overlay-at (-> prims 9)) + (tex0 uint64 :overlay-at (-> quad 0 data 0)) + (tex1 uint64 :overlay-at (-> prims 2)) + (miptbp1 uint64 :overlay-at (-> prims 4)) + (clamp uint64 :overlay-at (-> prims 6)) + (clamp-reg uint64 :overlay-at reg-3) + (alpha uint64 :overlay-at (-> prims 8)) + (link-test link-test-flags :overlay-at (-> quad 0 data 2)) + (texture-id texture-id :overlay-at reg-1) + (next shader-ptr :overlay-at reg-2) + ) + ) + +;; definition for method 3 of type adgif-shader +(defmethod inspect ((this adgif-shader)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'adgif-shader) + (format #t "~1Tquad[5] @ #x~X~%" (&-> this tex0)) + (format #t "~1Tprims[10] @ #x~X~%" (&-> this tex0)) + (format #t "~1Treg-0: ~D~%" (-> this reg-0)) + (format #t "~1Treg-1: ~D~%" (-> this reg-1)) + (format #t "~1Treg-2: ~D~%" (-> this reg-2)) + (format #t "~1Treg-3: ~D~%" (-> this reg-3)) + (format #t "~1Treg-4: ~D~%" (-> this reg-4)) + (format #t "~1Ttex0: #x~X~%" (-> this tex0)) + (format #t "~1Ttex1: #x~X~%" (-> this tex1)) + (format #t "~1Tmiptbp1: #x~X~%" (-> this miptbp1)) + (format #t "~1Tclamp: #x~X~%" (-> this clamp)) + (format #t "~1Tclamp-reg: ~D~%" (-> this clamp-reg)) + (format #t "~1Talpha: #x~X~%" (-> this alpha)) + (format #t "~1Tlink-test: ~D~%" (-> this link-test)) + (format #t "~1Ttexture-id: ~D~%" (-> this texture-id)) + (format #t "~1Tnext: #x~X~%" (-> this next)) + (label cfg-4) + this + ) + +;; definition of type adgif-shader-array +(deftype adgif-shader-array (inline-array-class) + ((data adgif-shader :inline :dynamic) + ) + ) + +;; definition for method 3 of type adgif-shader-array +(defmethod inspect ((this adgif-shader-array)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tlength: ~D~%" (-> this length)) + (format #t "~1Tallocated-length: ~D~%" (-> this allocated-length)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +(set! (-> adgif-shader-array heap-base) (the-as uint 80)) + +;; definition of type texture-base +(deftype texture-base (structure) + "Metadata about an area of VRAM set aside for fancy dynamic texture effects +(sky, eye, etc)." + ((vram-page uint32) + (vram-block uint32) + (vram-word uint32) + ) + ) + +;; definition for method 3 of type texture-base +(defmethod inspect ((this texture-base)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-base) + (format #t "~1Tvram-page: ~D~%" (-> this vram-page)) + (format #t "~1Tvram-block: ~D~%" (-> this vram-block)) + (format #t "~1Tvram-word: ~D~%" (-> this vram-word)) + (label cfg-4) + this + ) + +;; definition for symbol ct32-24-block-table, type (array int32) +(define ct32-24-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +;; definition for symbol mz32-24-block-table, type (array int32) +(define mz32-24-block-table (new 'static 'boxed-array :type int32 + 16 + 17 + 20 + 21 + 0 + 1 + 4 + 5 + 18 + 19 + 22 + 23 + 2 + 3 + 6 + 7 + 24 + 25 + 28 + 29 + 8 + 9 + 12 + 13 + 26 + 27 + 30 + 31 + 10 + 11 + 14 + 15 + ) + ) + +;; definition for symbol ct16-block-table, type (array int32) +(define ct16-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +;; definition for symbol ct16s-block-table, type (array int32) +(define ct16s-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 16 + 18 + 1 + 3 + 17 + 19 + 8 + 10 + 24 + 26 + 9 + 11 + 25 + 27 + 4 + 6 + 20 + 22 + 5 + 7 + 21 + 23 + 12 + 14 + 28 + 30 + 13 + 15 + 29 + 31 + ) + ) + +;; definition for symbol mz16-block-table, type (array int32) +(define mz16-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + ) + ) + +;; definition for symbol mz16s-block-table, type (array int32) +(define mz16s-block-table (new 'static 'boxed-array :type int32 + 16 + 18 + 0 + 2 + 17 + 19 + 1 + 3 + 24 + 26 + 8 + 10 + 25 + 27 + 9 + 11 + 20 + 22 + 4 + 6 + 21 + 23 + 5 + 7 + 28 + 30 + 12 + 14 + 29 + 31 + 13 + 15 + ) + ) + +;; definition for symbol mt8-block-table, type (array int32) +(define mt8-block-table (new 'static 'boxed-array :type int32 + 0 + 1 + 4 + 5 + 16 + 17 + 20 + 21 + 2 + 3 + 6 + 7 + 18 + 19 + 22 + 23 + 8 + 9 + 12 + 13 + 24 + 25 + 28 + 29 + 10 + 11 + 14 + 15 + 26 + 27 + 30 + 31 + ) + ) + +;; definition for symbol mt4-block-table, type (array int32) +(define mt4-block-table (new 'static 'boxed-array :type int32 + 0 + 2 + 8 + 10 + 1 + 3 + 9 + 11 + 4 + 6 + 12 + 14 + 5 + 7 + 13 + 15 + 16 + 18 + 24 + 26 + 17 + 19 + 25 + 27 + 20 + 22 + 28 + 30 + 21 + 23 + 29 + 31 + ) + ) + +;; definition of type texture-page-translate-item +(deftype texture-page-translate-item (structure) + ((bucket bucket-id) + (level-index uint32) + (level-texture-page tpage-category-u32) + (texture-user texture-enable-mask-u32) + ) + ) + +;; definition for method 3 of type texture-page-translate-item +(defmethod inspect ((this texture-page-translate-item)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'texture-page-translate-item) + (format #t "~1Tbucket: ~D~%" (-> this bucket)) + (format #t "~1Tlevel-index: ~D~%" (-> this level-index)) + (format #t "~1Tlevel-texture-page: ~D~%" (-> this level-texture-page)) + (format #t "~1Ttexture-user: ~D~%" (-> this texture-user)) + (label cfg-4) + this + ) + +;; definition for symbol *texture-page-translate*, type (array texture-page-translate-item) +(define *texture-page-translate* (new 'static 'boxed-array :type texture-page-translate-item + (new 'static 'texture-page-translate-item + :bucket (bucket-id tex-lcom-sky-pre) + :level-index #xa + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket7) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat10) + :texture-user (texture-enable-mask-u32 tex9) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket10) + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket22) + :level-index #x1 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket34) + :level-index #x2 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket46) + :level-index #x3 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket58) + :level-index #x4 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket70) + :level-index #x5 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket82) + :level-index #x6 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket94) + :level-index #x7 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket106) + :level-index #x8 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket118) + :level-index #x9 + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket130) + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket140) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket150) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket160) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket170) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket180) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket190) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket200) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket210) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket220) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket230) + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket241) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket252) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket263) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket274) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket285) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket296) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket307) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket318) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket329) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex3) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket340) + :level-index #xa + :texture-user (texture-enable-mask-u32 tex0) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket345) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat2) + :texture-user (texture-enable-mask-u32 tex2) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket351) + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket356) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket361) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket366) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket371) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket376) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket381) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket386) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket391) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket396) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket401) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat1) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket406) + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket411) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket416) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket421) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket426) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket431) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket436) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket441) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket446) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket451) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket456) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex1) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket461) + :level-index #xa + :level-texture-page (tpage-category-u32 sky) + :texture-user (texture-enable-mask-u32 sky) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket463) + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket473) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket483) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket493) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket503) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket513) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket523) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket533) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket543) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket553) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket563) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat4) + :texture-user (texture-enable-mask-u32 tex4) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket568) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat7) + :texture-user (texture-enable-mask-u32 tex6) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket575) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat5) + :texture-user (texture-enable-mask-u32 tex5) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x1 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x2 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x3 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x4 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x5 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x6 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x7 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x8 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #x9 + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat8) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket578) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat3) + :texture-user (texture-enable-mask-u32 tex7) + ) + (new 'static 'texture-page-translate-item + :bucket (bucket-id bucket580) + :level-index #xa + :level-texture-page (tpage-category-u32 tpage-cat6) + :texture-user (texture-enable-mask-u32 tex7) + ) + ) + ) + +;; definition for symbol *eyes-texture-base*, type texture-base +(define *eyes-texture-base* (new 'static 'texture-base)) + +;; definition for symbol *skull-gem-texture-base*, type texture-base +(define *skull-gem-texture-base* (new 'static 'texture-base)) + +;; definition for symbol *ocean-texture-base*, type texture-base +(define *ocean-texture-base* (new 'static 'texture-base)) + +;; definition for symbol *ocean-envmap-texture-base*, type texture-base +(define *ocean-envmap-texture-base* (new 'static 'texture-base)) + +;; definition for symbol *grey-scale-base*, type texture-base +(define *grey-scale-base* (new 'static 'texture-base)) + +;; definition for symbol *map-texture-base*, type texture-base +(define *map-texture-base* (new 'static 'texture-base)) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak3/engine/load/loader-h_REF.gc b/test/decompiler/reference/jak3/engine/load/loader-h_REF.gc new file mode 100644 index 00000000000..823e9cdbb34 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/load/loader-h_REF.gc @@ -0,0 +1,302 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type load-dir +(deftype load-dir (basic) + "`load-dir` is an array of references to loaded things. +It's used to handle art groups that are loaded as part of a level load." + ((lev level) + (string-array (array string)) + (data-array (array basic)) + ) + (:methods + (new (symbol type int level) _type_) + (load-to-heap-by-name (_type_ string symbol kheap int) art-group) + (set-loaded-art (_type_ art-group) art-group) + ) + ) + +;; definition of type load-dir-art-group +(deftype load-dir-art-group (load-dir) + "Specialization of load-dir for `art-group`s." + ((art-group-array (array art-group) :overlay-at data-array) + ) + (:methods + (new (symbol type int level) _type_) + ) + ) + +;; definition for method 0 of type load-dir +(defmethod new load-dir ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((s4-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s4-0 lev) arg1) + (set! (-> s4-0 string-array) + (the-as (array string) ((method-of-type array new) allocation array string arg0)) + ) + (set! (-> s4-0 string-array length) 0) + (set! (-> s4-0 data-array) (the-as (array basic) ((method-of-type array new) allocation array basic arg0))) + (set! (-> s4-0 data-array length) 0) + s4-0 + ) + ) + +;; definition for method 0 of type load-dir-art-group +;; WARN: Return type mismatch load-dir vs load-dir-art-group. +(defmethod new load-dir-art-group ((allocation symbol) (type-to-make type) (arg0 int) (arg1 level)) + (let ((v0-0 ((method-of-type load-dir new) allocation type-to-make arg0 arg1))) + (set! (-> v0-0 data-array content-type) art-group) + (the-as load-dir-art-group v0-0) + ) + ) + +;; definition of type external-art-buffer +(deftype external-art-buffer (basic) + "An `external-art-buffer` is a buffer that streamed files use." + ((index int32) + (other external-art-buffer) + (status symbol) + (locked? symbol) + (login? symbol) + (frame-lock symbol) + (init-heap (function external-art-buffer object)) + (heap kheap :inline) + (pending-load-file string) + (pending-load-file-part int32) + (pending-load-file-owner handle) + (pending-load-file-priority float) + (load-file string) + (load-file-part int32) + (load-file-owner handle) + (load-file-priority float) + (buf pointer) + (len int32) + (art-group art-group) + (art-data uint32 :overlay-at art-group) + ) + (:methods + (new (symbol type int function symbol) _type_) + (set-pending-file (_type_ string int handle float) int) + (update (_type_) int) + (inactive? (_type_) symbol) + (file-status (_type_ string int) symbol) + (link-file (_type_ art-group) art-group) + (unlink-file (_type_ art-group) int) + (unlock! (_type_) int) + ) + ) + +;; definition for method 3 of type external-art-buffer +(defmethod inspect ((this external-art-buffer)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tindex: ~D~%" (-> this index)) + (format #t "~1Tother: ~A~%" (-> this other)) + (format #t "~1Tstatus: ~A~%" (-> this status)) + (format #t "~1Tlocked?: ~A~%" (-> this locked?)) + (format #t "~1Tlogin?: ~A~%" (-> this login?)) + (format #t "~1Tframe-lock: ~A~%" (-> this frame-lock)) + (format #t "~1Tinit-heap: ~A~%" (-> this init-heap)) + (format #t "~1Theap: #~%" (-> this heap)) + (format #t "~1Tpending-load-file: ~A~%" (-> this pending-load-file)) + (format #t "~1Tpending-load-file-part: ~D~%" (-> this pending-load-file-part)) + (format #t "~1Tpending-load-file-owner: ~D~%" (-> this pending-load-file-owner)) + (format #t "~1Tpending-load-file-priority: ~f~%" (-> this pending-load-file-priority)) + (format #t "~1Tload-file: ~A~%" (-> this load-file)) + (format #t "~1Tload-file-part: ~D~%" (-> this load-file-part)) + (format #t "~1Tload-file-owner: ~D~%" (-> this load-file-owner)) + (format #t "~1Tload-file-priority: ~f~%" (-> this load-file-priority)) + (format #t "~1Tbuf: #x~X~%" (-> this buf)) + (format #t "~1Tlen: ~D~%" (-> this len)) + (format #t "~1Tart-group: ~A~%" (-> this art-group)) + (format #t "~1Tart-data: #x~X~%" (-> this art-group)) + (label cfg-4) + this + ) + +;; definition for method 0 of type external-art-buffer +(defmethod new external-art-buffer ((allocation symbol) (type-to-make type) (arg0 int) (arg1 function) (arg2 symbol)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 index) arg0) + (set! (-> v0-0 init-heap) (the-as (function external-art-buffer object) arg1)) + (set! (-> v0-0 login?) arg2) + (set! (-> v0-0 load-file) #f) + (set! (-> v0-0 load-file-part) -1) + (set! (-> v0-0 load-file-owner) (the-as handle #f)) + (set! (-> v0-0 load-file-priority) 100000000.0) + (set! (-> v0-0 pending-load-file) #f) + (set! (-> v0-0 pending-load-file-part) -1) + (set! (-> v0-0 pending-load-file-owner) (the-as handle #f)) + (set! (-> v0-0 pending-load-file-priority) 100000000.0) + (set! (-> v0-0 art-group) #f) + (set! (-> v0-0 status) 'initialize) + (set! (-> v0-0 locked?) #f) + (set! (-> v0-0 other) #f) + v0-0 + ) + ) + +;; definition of type spool-anim +(deftype spool-anim (basic) + "A `spool-anim` is metadata for an animation that will be loaded in chunks +to a pair of external-art-buffers." + ((name string :offset 16) + (anim-name string) + (buffer external-art-buffer :overlay-at anim-name) + (parts int32) + (hint-id int32 :overlay-at parts) + (priority float) + (owner handle) + (command-list pair) + ) + ) + +;; definition for method 3 of type spool-anim +(defmethod inspect ((this spool-anim)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Tanim-name: ~A~%" (-> this anim-name)) + (format #t "~1Tparts: ~D~%" (-> this parts)) + (format #t "~1Thint-id: ~D~%" (-> this parts)) + (format #t "~1Tpriority: ~f~%" (-> this priority)) + (format #t "~1Towner: ~D~%" (-> this owner)) + (format #t "~1Tcommand-list: ~A~%" (-> this command-list)) + (label cfg-4) + this + ) + +;; definition of type external-art-control +(deftype external-art-control (basic) + "The `external-art-control` manages loading chunks from `spool-anim`s to `external-art-buffer`." + ((buffer external-art-buffer 2) + (rec spool-anim 3 :inline) + (spool-lock handle) + (reserve-buffer external-art-buffer) + (reserve-buffer-count int16) + (dma-reserve-buffer-count int16) + (active-stream string) + (queue-stream (array spool-anim)) + (frame-mask uint32) + (dma-reserve-heap kheap :inline) + ) + (:methods + (new (symbol type) _type_) + (update (_type_ symbol) int) + (clear-rec (_type_) int) + (spool-push (_type_ string int process float) int) + (file-status (_type_ string int) symbol) + (reserve-alloc (_type_) kheap) + (reserve-free (_type_ kheap) int) + (none-reserved? (_type_) symbol) + ) + ) + +;; definition for method 3 of type external-art-control +(defmethod inspect ((this external-art-control)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tbuffer[2] @ #x~X~%" (-> this buffer)) + (format #t "~1Trec[3] @ #x~X~%" (-> this rec)) + (format #t "~1Tspool-lock: ~D~%" (-> this spool-lock)) + (format #t "~1Treserve-buffer: ~A~%" (-> this reserve-buffer)) + (format #t "~1Treserve-buffer-count: ~D~%" (-> this reserve-buffer-count)) + (format #t "~1Tdma-reserve-buffer-count: ~D~%" (-> this dma-reserve-buffer-count)) + (format #t "~1Tactive-stream: ~A~%" (-> this active-stream)) + (format #t "~1Tqueue-stream: ~A~%" (-> this queue-stream)) + (format #t "~1Tframe-mask: ~D~%" (-> this frame-mask)) + (format #t "~1Tdma-reserve-heap: #~%" (-> this dma-reserve-heap)) + (label cfg-4) + this + ) + +;; definition for method 0 of type external-art-control +(defmethod new external-art-control ((allocation symbol) (type-to-make type)) + (let ((gp-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (dotimes (s4-0 2) + (set! (-> gp-0 buffer s4-0) + ((method-of-type external-art-buffer new) allocation external-art-buffer s4-0 external-art-buffer-init #t) + ) + ) + (set! (-> gp-0 buffer 0 other) (-> gp-0 buffer 1)) + (set! (-> gp-0 buffer 1 other) (-> gp-0 buffer 0)) + (dotimes (v1-9 3) + (set! (-> gp-0 rec v1-9 name) #f) + (set! (-> gp-0 rec v1-9 priority) 100000000.0) + (set! (-> gp-0 rec v1-9 owner) (the-as handle #f)) + ) + (set! (-> gp-0 spool-lock) (the-as handle #f)) + (set! (-> gp-0 reserve-buffer) #f) + (set! (-> gp-0 active-stream) #f) + (set! (-> gp-0 queue-stream) (new 'global 'boxed-array spool-anim 4)) + (dotimes (s5-1 (-> gp-0 queue-stream allocated-length)) + (set! (-> gp-0 queue-stream s5-1) (new 'global 'spool-anim)) + ) + (set! (-> gp-0 queue-stream length) 0) + gp-0 + ) + ) + +;; definition of type subtitle-range +(deftype subtitle-range (basic) + ((start-frame float) + (end-frame float) + (message basic 12) + ) + ) + +;; definition for method 3 of type subtitle-range +(defmethod inspect ((this subtitle-range)) + (when (not this) + (set! this this) + (goto cfg-7) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Tstart-frame: ~f~%" (-> this start-frame)) + (format #t "~1Tend-frame: ~f~%" (-> this end-frame)) + (format #t "~1Tmessage[12] @ #x~X~%" (-> this message)) + (dotimes (s5-0 12) + (format #t "~T [~D]~1Tmessage: ~`object`P~%" s5-0 (-> this message s5-0)) + ) + (label cfg-7) + this + ) + +;; definition of type subtitle-image +(deftype subtitle-image (basic) + ((width uint16) + (height uint16) + (palette rgba 16 :offset 16) + (data uint8 :dynamic) + ) + ) + +;; definition for method 3 of type subtitle-image +(defmethod inspect ((this subtitle-image)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this (-> this type)) + (format #t "~1Twidth: ~D~%" (-> this width)) + (format #t "~1Theight: ~D~%" (-> this height)) + (format #t "~1Tpalette[16] @ #x~X~%" (-> this palette)) + (format #t "~1Tdata[0] @ #x~X~%" (-> this data)) + (label cfg-4) + this + ) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/decompiler/reference/jak3/engine/util/capture-h_REF.gc b/test/decompiler/reference/jak3/engine/util/capture-h_REF.gc new file mode 100644 index 00000000000..ea9da098b06 --- /dev/null +++ b/test/decompiler/reference/jak3/engine/util/capture-h_REF.gc @@ -0,0 +1,97 @@ +;;-*-Lisp-*- +(in-package goal) + +;; this file is debug only +(declare-file (debug)) + +;; definition of type gs-store-image-packet +(deftype gs-store-image-packet (structure) + ((vifcode vif-tag 4) + (giftag uint128) + (bitbltbuf uint64) + (bitbltbuf-addr uint64) + (trxpos uint64) + (trxpos-addr uint64) + (trxreg uint64) + (trxreg-addr uint64) + (finish uint64) + (finish-addr uint64) + (trxdir uint64) + (trxdir-addr uint64) + ) + ) + +;; definition for method 3 of type gs-store-image-packet +;; INFO: Used lq/sq +(defmethod inspect ((this gs-store-image-packet)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'gs-store-image-packet) + (format #t "~1Tvifcode[4] @ #x~X~%" (-> this vifcode)) + (format #t "~1Tgiftag: ~D~%" (-> this giftag)) + (format #t "~1Tbitbltbuf: ~D~%" (-> this bitbltbuf)) + (format #t "~1Tbitbltbuf-addr: ~D~%" (-> this bitbltbuf-addr)) + (format #t "~1Ttrxpos: ~D~%" (-> this trxpos)) + (format #t "~1Ttrxpos-addr: ~D~%" (-> this trxpos-addr)) + (format #t "~1Ttrxreg: ~D~%" (-> this trxreg)) + (format #t "~1Ttrxreg-addr: ~D~%" (-> this trxreg-addr)) + (format #t "~1Tfinish: ~D~%" (-> this finish)) + (format #t "~1Tfinish-addr: ~D~%" (-> this finish-addr)) + (format #t "~1Ttrxdir: ~D~%" (-> this trxdir)) + (format #t "~1Ttrxdir-addr: ~D~%" (-> this trxdir-addr)) + (label cfg-4) + this + ) + +;; definition of type screen-shot-work +(deftype screen-shot-work (structure) + ((count int16) + (size int16) + (name string) + (highres-enable symbol) + (hud-enable symbol) + ) + ) + +;; definition for method 3 of type screen-shot-work +(defmethod inspect ((this screen-shot-work)) + (when (not this) + (set! this this) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" this 'screen-shot-work) + (format #t "~1Tcount: ~D~%" (-> this count)) + (format #t "~1Tsize: ~D~%" (-> this size)) + (format #t "~1Tname: ~A~%" (-> this name)) + (format #t "~1Thighres-enable: ~A~%" (-> this highres-enable)) + (format #t "~1Thud-enable: ~A~%" (-> this hud-enable)) + (label cfg-4) + this + ) + +;; definition for symbol *screen-shot-work*, type screen-shot-work +(define *screen-shot-work* (new 'global 'screen-shot-work)) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* count) -1) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* size) -1) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* highres-enable) #f) + +;; failed to figure out what this is: +(set! (-> *screen-shot-work* hud-enable) #f) + +;; definition for symbol *image-name*, type string +(define *image-name* (new 'global 'string 32 (the-as string #f))) + +;; failed to figure out what this is: +0 + + + + diff --git a/test/offline/config/jak3/config.jsonc b/test/offline/config/jak3/config.jsonc index e92c013e015..3a3d2cb53c4 100644 --- a/test/offline/config/jak3/config.jsonc +++ b/test/offline/config/jak3/config.jsonc @@ -41,7 +41,15 @@ // timer "(method 9 clock)", // pad - "service-cpads" + "service-cpads", + // connect + "(method 0 engine)", + "(method 0 engine-pers)", + // math-camera + "update-math-camera", + "transform-point-vector!", + "transform-point-qword!", + "transform-point-vector-scale!" ], "skip_compile_states": {}