mirror of
https://github.com/open-goal/jak-project
synced 2026-08-02 08:42:11 -04:00
[jak3] A few early files (#3330)
types-h, vu1-macros, gsound-h, dma-h, video-h, vu1-user-h, profile-h The `gsound-h` is very simple, but the rest have decent docs and all the macros we had from jak 2. So far, barely any differences! (there's a few in gsound-h)
This commit is contained in:
@@ -5,5 +5,242 @@
|
||||
;; name in dgo: dma-h
|
||||
;; dgos: GAME
|
||||
|
||||
(defenum dma-tag-id
|
||||
:bitfield #f
|
||||
:type uint8
|
||||
(refe 0) ;; addr=ADDR, ends after this transfer
|
||||
(cnt 1) ;; addr=after tag, next-tag=after data
|
||||
(next 2) ;; addr=after tag, next-tag=ADDR
|
||||
(ref 3) ;; addr=ADDR, next-tag=after tag
|
||||
(refs 4) ;; ref, but stall controled
|
||||
(call 5) ;;
|
||||
(ret 6) ;;
|
||||
(end 7) ;; next, but ends.
|
||||
)
|
||||
|
||||
;; all these have mask (only applies to unpacks) and interrupt not set.
|
||||
(defenum vif-cmd
|
||||
:bitfield #f
|
||||
:type uint8
|
||||
(nop 0) ;; no-op, can still have irq set.
|
||||
(stcycl 1) ;; set write recycle register
|
||||
(offset 2) ;; set offset register
|
||||
(base 3) ;; set base register
|
||||
(itop 4) ;; set data pointer register (itops)
|
||||
(stmod 5) ;; set mode register
|
||||
(mskpath3 6) ;; set path 3 mask
|
||||
(mark 7) ;; set mark register
|
||||
(pc-port 8) ;; special tag for PC Port data.
|
||||
(flushe 16) ;; wait for end of microprogram
|
||||
(flush 17) ;; wait for end of microprogram and transfer (path1/path2)
|
||||
(flusha 19) ;; wait for end of microprogram and transfer (path1/path2/path3)
|
||||
(mscal 20) ;; activate microprogram (call)
|
||||
(mscalf 21) ;; flushe and activate (call)
|
||||
(mscnt 23) ;; activate microprogram (continue)
|
||||
(stmask 32) ;; set MASK register.
|
||||
(strow 48) ;; set filling data
|
||||
(stcol 49) ;; set filling data
|
||||
(mpg 74) ;; transfer microprogram
|
||||
(direct 80) ;; straight to GIF.
|
||||
(directhl 81)
|
||||
(unpack-s-32 96)
|
||||
(unpack-s-16 97)
|
||||
(unpack-s-8 98)
|
||||
;; 99 is invllid
|
||||
(unpack-v2-32 100)
|
||||
(unpack-v2-16 101)
|
||||
(unpack-v2-8 102)
|
||||
;; 103 is invalid
|
||||
(unpack-v3-32 104)
|
||||
(unpack-v3-16 105)
|
||||
(unpack-v3-8 106)
|
||||
;; 107 is invalid
|
||||
(unpack-v4-32 108)
|
||||
(unpack-v4-16 109)
|
||||
(unpack-v4-8 110)
|
||||
(unpack-v4-5 111)
|
||||
(cmd-mask 239) ;; not sure what this is.
|
||||
)
|
||||
|
||||
;; this makes a copy of the above type, but uses a uint32.
|
||||
(defenum vif-cmd-32
|
||||
:bitfield #f
|
||||
:type uint32
|
||||
:copy-entries vif-cmd
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype dma-chcr (uint32)
|
||||
"Memory mapped DMA channel control register. Typically used to start and check on DMA transfer."
|
||||
((dir uint8 :offset 0 :size 1)
|
||||
(mod uint8 :offset 2 :size 2)
|
||||
(asp uint8 :offset 4 :size 2)
|
||||
(tte uint8 :offset 6 :size 1)
|
||||
(tie uint8 :offset 7 :size 1)
|
||||
(str uint8 :offset 8 :size 1)
|
||||
(tag uint16 :offset 16 :size 16)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype dma-bank (structure)
|
||||
"Bank of memory mapped DMA registers for a single channel. Used to control DMA."
|
||||
((chcr dma-chcr :offset 0)
|
||||
(madr uint32 :offset 16)
|
||||
(qwc uint32 :offset 32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype dma-bank-source (dma-bank)
|
||||
"DMA channel registers for a DMA channel supporting source-chain."
|
||||
((tadr uint32 :offset 48)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype dma-bank-vif (dma-bank-source)
|
||||
"DMA channel registers for a DMA channel with call/ret stack."
|
||||
((as0 uint32 :offset 64)
|
||||
(as1 uint32 :offset 80)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype dma-bank-spr (dma-bank-source)
|
||||
"DMA channel registers for a DMA channel supporting scratchpad transfer."
|
||||
((sadr uint32 :offset 128)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype dma-ctrl (uint32)
|
||||
"Main DMA control register, shared for all channels."
|
||||
((dmae uint8 :offset 0 :size 1)
|
||||
(rele uint8 :offset 1 :size 1)
|
||||
(mfd uint8 :offset 2 :size 2)
|
||||
(sts uint8 :offset 4 :size 2)
|
||||
(std uint8 :offset 6 :size 2)
|
||||
(rcyc uint8 :offset 8 :size 3)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype dma-enable (uint32)
|
||||
((cpnd uint8 :offset 16 :size 1)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype dma-sqwc (uint32)
|
||||
((sqwc uint8 :offset 0 :size 8)
|
||||
(tqwc uint8 :offset 16 :size 8)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype dma-bank-control (structure)
|
||||
"Memory mapping for shared DMA registers."
|
||||
((ctrl dma-ctrl :offset 0)
|
||||
(stat uint32 :offset 16)
|
||||
(pcr uint32 :offset 32)
|
||||
(sqwc dma-sqwc :offset 48)
|
||||
(rbsr uint32 :offset 64)
|
||||
(rbor uint32 :offset 80)
|
||||
(stadr uint32 :offset 96)
|
||||
(enabler uint32 :offset 5408)
|
||||
(enablew uint32 :offset 5520)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vu-code-block (basic)
|
||||
"Unused type for some VU code. vu-function is used instead."
|
||||
((name basic)
|
||||
(code uint32)
|
||||
(size int32)
|
||||
(dest-address uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vu-stat (uint64)
|
||||
()
|
||||
)
|
||||
|
||||
(deftype dma-tag (uint64)
|
||||
"The 64-bit tag used by the DMA system."
|
||||
((qwc uint16 :offset 0 :size 16)
|
||||
(pce uint8 :offset 26 :size 2)
|
||||
(id dma-tag-id :offset 28 :size 3)
|
||||
(irq uint8 :offset 31 :size 1)
|
||||
(addr uint32 :offset 32 :size 31)
|
||||
(spr uint8 :offset 63 :size 1)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype dma-bucket (structure)
|
||||
"A linked list of DMA data, typically all in the same category. Used to organize the full DMA chain."
|
||||
((tag dma-tag)
|
||||
(last (pointer dma-tag))
|
||||
(dummy uint32)
|
||||
(next uint32 :offset 4)
|
||||
(clear uint64 :overlay-at last)
|
||||
(vif0 uint32 :overlay-at last)
|
||||
(vif1 uint32 :overlay-at dummy)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vif-mask (uint32)
|
||||
((m0 uint8 :offset 0 :size 2)
|
||||
(m1 uint8 :offset 2 :size 2)
|
||||
(m2 uint8 :offset 4 :size 2)
|
||||
(m3 uint8 :offset 6 :size 2)
|
||||
(m4 uint8 :offset 8 :size 2)
|
||||
(m5 uint8 :offset 10 :size 2)
|
||||
(m6 uint8 :offset 12 :size 2)
|
||||
(m7 uint8 :offset 14 :size 2)
|
||||
(m8 uint8 :offset 16 :size 2)
|
||||
(m9 uint8 :offset 18 :size 2)
|
||||
(m10 uint8 :offset 20 :size 2)
|
||||
(m11 uint8 :offset 22 :size 2)
|
||||
(m12 uint8 :offset 24 :size 2)
|
||||
(m13 uint8 :offset 26 :size 2)
|
||||
(m14 uint8 :offset 28 :size 2)
|
||||
(m15 uint8 :offset 30 :size 2)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype vif-stcycl-imm (uint16)
|
||||
"The imm field of a VIF code using STCYCL, which adjusts the pattern for storing data."
|
||||
((cl uint8 :offset 0 :size 8)
|
||||
(wl uint8 :offset 8 :size 8)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype vif-unpack-imm (uint16)
|
||||
"The imm field of a VIF code using UNPACK, which transfers data to VU memory."
|
||||
((addr uint16 :offset 0 :size 10)
|
||||
(usn uint8 :offset 14 :size 1)
|
||||
(flg uint8 :offset 15 :size 1)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype vif-tag (uint32)
|
||||
"A tag consumed by the VIF, which accepts DMA data."
|
||||
((imm uint16 :offset 0 :size 16)
|
||||
(num uint8 :offset 16 :size 8)
|
||||
(cmd vif-cmd :offset 24 :size 7)
|
||||
(irq uint8 :offset 31 :size 1)
|
||||
(msk uint8 :offset 28 :size 1)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
@@ -7,3 +7,30 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype video-params (structure)
|
||||
"Parameters for the framebuffer."
|
||||
((set-video-mode symbol)
|
||||
(reset-video-mode symbol)
|
||||
(display-fbp int32)
|
||||
(relative-x-scale float :offset 16)
|
||||
(display-dx int32)
|
||||
(display-dy int32)
|
||||
(display-sy int32)
|
||||
(relative-x-scale-reciprical float)
|
||||
(screen-pages-high int32)
|
||||
(smode2 uint64)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define *video-params* (new 'static 'video-params
|
||||
:set-video-mode #f
|
||||
:reset-video-mode #f
|
||||
:display-fbp #xa4
|
||||
:relative-x-scale 1.0
|
||||
:display-dy 8
|
||||
:display-sy #xe0
|
||||
:relative-x-scale-reciprical 1.0
|
||||
:screen-pages-high 13
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5,5 +5,40 @@
|
||||
;; name in dgo: vu1-user-h
|
||||
;; dgos: GAME
|
||||
|
||||
(defenum tpage-category
|
||||
:type int8
|
||||
)
|
||||
|
||||
(defenum bucket-id
|
||||
:type int32
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype dma-foreground-sink (basic)
|
||||
"A specification for where a foreground renderer should output its DMA data."
|
||||
((bucket bucket-id)
|
||||
(foreground-texture-page tpage-category)
|
||||
(foreground-texture-level int8)
|
||||
(foreground-output-bucket int8)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype generic-bucket-state (structure)
|
||||
"The state of buffers for the generic renderer.
|
||||
When generating generic DMA data, you must know the previous state
|
||||
of the VU's memory to properly double-buffer the input and output data."
|
||||
((gifbuf-adr uint32)
|
||||
(inbuf-adr uint32)
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype generic-dma-foreground-sink (dma-foreground-sink)
|
||||
"A specification for where a foreground generic renderer should output DMA data,
|
||||
and the state of the VU memory buffers at the end of the bucket."
|
||||
((state generic-bucket-state :inline)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5,5 +5,249 @@
|
||||
;; name in dgo: vu1-macros
|
||||
;; dgos: GAME
|
||||
|
||||
#|@file
|
||||
this file has no code, just macros for vector-unit stuff.
|
||||
|
||||
in OpenGOAL we're also using this for VU0 macros to help with VU0 operations that are not
|
||||
directly implemented by the OpenGOAL compiler
|
||||
|#
|
||||
|
||||
(defmacro vu-clip (vfr cf)
|
||||
"Returns the result of VCLIP.
|
||||
NOTE: this implementation is pretty inefficient.
|
||||
If this ends up used a lot, it's probably worth rewriting.
|
||||
"
|
||||
`(let ((vec (new 'stack 'vector))
|
||||
(flag ,cf)
|
||||
)
|
||||
(.svf vec ,vfr)
|
||||
(let* ((w-plus (fabs (-> vec w)))
|
||||
(w-minus (- 0.0 w-plus))
|
||||
)
|
||||
;; CF = CF << 6
|
||||
(set! flag (logand #xffffff (shl flag 6)))
|
||||
|
||||
(when (> (-> vec x) w-plus)
|
||||
(logior! flag 1)
|
||||
)
|
||||
(when (< (-> vec x) w-minus)
|
||||
(logior! flag 2)
|
||||
)
|
||||
(when (> (-> vec y) w-plus)
|
||||
(logior! flag 4)
|
||||
)
|
||||
(when (< (-> vec y) w-minus)
|
||||
(logior! flag 8)
|
||||
)
|
||||
(when (> (-> vec z) w-plus)
|
||||
(logior! flag 16)
|
||||
)
|
||||
(when (< (-> vec z) w-minus)
|
||||
(logior! flag 32)
|
||||
)
|
||||
)
|
||||
flag
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defmacro vftoi4.xyzw (dst src)
|
||||
"convert to 28.4 integer. This does the multiply while the number is still
|
||||
a float. This will have issues for very large floats, but it seems like this
|
||||
is how PCSX2 does it as well, so maybe it's right?
|
||||
NOTE: this is the only version of the instruction used in Jak 1, so we
|
||||
don't need to worry about masks."
|
||||
|
||||
`(begin
|
||||
(rlet ((temp :class vf))
|
||||
(set! temp 16.0)
|
||||
(.mul.x.vf temp ,src temp)
|
||||
(.ftoi.vf ,dst temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro vftoi12.xyzw (dst src)
|
||||
"convert to 20.12 integer. This does the multiply while the number is still
|
||||
a float. This will have issues for very large floats, but it seems like this
|
||||
is how PCSX2 does it as well, so maybe it's right?
|
||||
NOTE: this is the only version of the instruction used in Jak 1, so we
|
||||
don't need to worry about masks."
|
||||
|
||||
`(begin
|
||||
(rlet ((temp :class vf))
|
||||
(set! temp 4096.0)
|
||||
(.mul.x.vf temp ,src temp)
|
||||
(.ftoi.vf ,dst temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro vftoi15.xyzw (dst src)
|
||||
"convert to 17.15 integer. This does the multiply while the number is still
|
||||
a float. This will have issues for very large floats, but it seems like this
|
||||
is how PCSX2 does it as well, so maybe it's right?
|
||||
NOTE: this is the only version of the instruction used in Jak 1, so we
|
||||
don't need to worry about masks."
|
||||
|
||||
`(begin
|
||||
(rlet ((temp :class vf))
|
||||
(set! temp 32768.0)
|
||||
(.mul.x.vf temp ,src temp)
|
||||
(.ftoi.vf ,dst temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro vitof4.xyzw (dst src)
|
||||
"convert from a 28.4 integer. This does the multiply while the number is still
|
||||
a float. This will have issues for very large floats, but it seems like this
|
||||
is how PCSX2 does it as well, so maybe it's right?
|
||||
NOTE: this is the only version of the instruction used in Jak 1, so we
|
||||
don't need to worry about masks."
|
||||
|
||||
`(begin
|
||||
(rlet ((temp :class vf))
|
||||
(.itof.vf ,dst ,src)
|
||||
(set! temp 0.0625)
|
||||
(.mul.x.vf ,dst ,dst temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro vitof12.xyzw (dst src)
|
||||
"convert from a 20.12 integer. This does the multiply while the number is still
|
||||
a float. This will have issues for very large floats, but it seems like this
|
||||
is how PCSX2 does it as well, so maybe it's right?
|
||||
NOTE: this is the only version of the instruction used in Jak 1, so we
|
||||
don't need to worry about masks."
|
||||
|
||||
`(begin
|
||||
(rlet ((temp :class vf))
|
||||
(.itof.vf ,dst ,src)
|
||||
(set! temp 0.000244140625)
|
||||
(.mul.x.vf ,dst ,dst temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro vitof15.xyzw (dst src)
|
||||
"convert from a 17.15 integer. This does the multiply while the number is still
|
||||
a float. This will have issues for very large floats, but it seems like this
|
||||
is how PCSX2 does it as well, so maybe it's right?
|
||||
NOTE: this is the only version of the instruction used in Jak 1, so we
|
||||
don't need to worry about masks."
|
||||
|
||||
`(begin
|
||||
(rlet ((temp :class vf))
|
||||
(.itof.vf ,dst ,src)
|
||||
(set! temp 0.000030517578125)
|
||||
(.mul.x.vf ,dst ,dst temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; In the original game, they sometimes stashed some values in vf registers across function calls.
|
||||
;; In OpenGOAL, we don't have a one-to-one mapping of vf's to x86 hardware registers, so we need
|
||||
;; to manually backup and restore these.
|
||||
|
||||
;; it's used in a few places:
|
||||
;; - init-for-transforms sets up register for doing world -> screen transformations. only used for debug cam drawing
|
||||
;; - set-background-regs! sets up registers for background drawing and runs a VU0 program to premultiply some stuff
|
||||
;; - bsp also does a similar thing, but doesn't run the VU0 program
|
||||
|
||||
(deftype transform-regs (structure)
|
||||
;; Eventually we might want to actually name some of these fields to be more comprehensible?
|
||||
(;; vf0 not included!
|
||||
(vf1 uint128)
|
||||
(vf2 uint128)
|
||||
(vf3 uint128)
|
||||
(vf4 uint128)
|
||||
(vf5 uint128)
|
||||
(vf6 uint128)
|
||||
(vf7 uint128)
|
||||
(vf8 uint128)
|
||||
(vf9 uint128)
|
||||
(vf10 uint128)
|
||||
(vf11 uint128)
|
||||
(vf12 uint128)
|
||||
(vf13 uint128)
|
||||
(vf14 uint128)
|
||||
(vf15 uint128)
|
||||
(vf16 uint128)
|
||||
(vf17 uint128)
|
||||
(vf18 uint128)
|
||||
(vf19 uint128)
|
||||
(vf20 uint128)
|
||||
(vf21 uint128)
|
||||
(vf22 uint128)
|
||||
(vf23 uint128)
|
||||
(vf24 uint128)
|
||||
(vf25 uint128)
|
||||
(vf26 uint128)
|
||||
(vf27 uint128)
|
||||
(vf28 uint128)
|
||||
(vf29 uint128)
|
||||
(vf30 uint128)
|
||||
(vf31 uint128)
|
||||
)
|
||||
)
|
||||
|
||||
(define *transform-regs* (new 'static 'transform-regs))
|
||||
|
||||
|
||||
(defmacro with-vf0 (&rest body)
|
||||
"Macro for using the ps2-style vf0 register."
|
||||
|
||||
`(rlet ((vf0 :class vf))
|
||||
(init-vf0-vector)
|
||||
,@body
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro load-vf (reg)
|
||||
"Load a vf from the preserved vf registers"
|
||||
`(.lvf ,reg (&-> *transform-regs* ,reg))
|
||||
)
|
||||
|
||||
(defmacro save-vf (reg)
|
||||
"Save a vf to the preserved vf registers"
|
||||
`(.svf (&-> *transform-regs* ,reg) ,reg)
|
||||
)
|
||||
|
||||
(defmacro with-vf (regs &key (rw 'read) &rest body)
|
||||
"Macro for using the specified ps2-style vf registers. These are preserved in *transform-regs*
|
||||
Each register name in regs must be a valid vf register name. vf0 CANNOT be used! Use with-vf0 for that instead.
|
||||
rw specifies the read/write mode:
|
||||
'read means the registers will be read from the preserved registers. This is the default
|
||||
'write means the registers will be written to the preserved registers at the end
|
||||
'readwrite (or 'rw) means both
|
||||
#f means neither, turning this into a fancy macro around rlet."
|
||||
|
||||
`(rlet (,@(apply (lambda (x) `(,x :class vf)) regs))
|
||||
|
||||
,@(if (or (eq? rw ''read) (eq? rw ''readwrite) (eq? rw ''rw))
|
||||
(apply (lambda (y)
|
||||
`(load-vf ,y)
|
||||
) regs)
|
||||
'()
|
||||
)
|
||||
|
||||
,@body
|
||||
|
||||
;; this will mess up the return value!
|
||||
,@(if (or (eq? rw ''write) (eq? rw ''readwrite) (eq? rw ''rw))
|
||||
(apply (lambda (y)
|
||||
`(save-vf ,y)
|
||||
) regs)
|
||||
'()
|
||||
)
|
||||
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
|
||||
@@ -5,5 +5,333 @@
|
||||
;; name in dgo: gsound-h
|
||||
;; dgos: GAME
|
||||
|
||||
(defenum sound-command
|
||||
:type uint16
|
||||
)
|
||||
|
||||
(defenum sound-group
|
||||
:bitfield #t
|
||||
:type uint8
|
||||
)
|
||||
|
||||
(defenum sound-mask
|
||||
:bitfield #t
|
||||
:type uint16
|
||||
)
|
||||
|
||||
(defenum stream-status
|
||||
:type uint32
|
||||
:bitfield #t
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype sound-stream-name (structure)
|
||||
((name uint8 48)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-id (uint32)
|
||||
()
|
||||
(:methods
|
||||
(unknown () none)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype sound-bank-id (uint32)
|
||||
()
|
||||
)
|
||||
|
||||
(deftype sound-name (uint128)
|
||||
()
|
||||
)
|
||||
|
||||
(deftype sound-rpc-cmd (structure)
|
||||
((rsvd1 uint16)
|
||||
(command uint16)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-play-params (structure)
|
||||
((mask uint16)
|
||||
(pitch-mod int16)
|
||||
(bend int16)
|
||||
(fo-min int16)
|
||||
(fo-max int16)
|
||||
(fo-curve int8)
|
||||
(priority int8)
|
||||
(volume int32)
|
||||
(trans int32 3)
|
||||
(group uint8)
|
||||
(reg uint8 3)
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-bank-cmd (sound-rpc-cmd)
|
||||
((bank-name sound-name)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-test-cmd (sound-rpc-cmd)
|
||||
((ee-addr pointer)
|
||||
(param0 uint16)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-sound-cmd (sound-rpc-cmd)
|
||||
((id sound-id)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-group-cmd (sound-rpc-cmd)
|
||||
((group uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-load-bank (sound-rpc-bank-cmd)
|
||||
((ee-addr pointer)
|
||||
(mode uint32)
|
||||
(priority uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-load-music (sound-rpc-bank-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-unload-bank (sound-rpc-bank-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-play (sound-rpc-sound-cmd)
|
||||
((name sound-name)
|
||||
(params sound-play-params :inline)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-pause-sound (sound-rpc-sound-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-stop-sound (sound-rpc-sound-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-continue-sound (sound-rpc-sound-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-param (sound-rpc-sound-cmd)
|
||||
((params sound-play-params :inline)
|
||||
(auto-time int32)
|
||||
(auto-from int32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-master-volume (sound-rpc-group-cmd)
|
||||
((volume int32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-pause-group (sound-rpc-group-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-stop-group (sound-rpc-group-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-continue-group (sound-rpc-group-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-cancel-dgo (sound-rpc-group-cmd)
|
||||
((id uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-get-irx-version (sound-rpc-cmd)
|
||||
((major uint32)
|
||||
(minor uint32)
|
||||
(ee-addr pointer)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-language (sound-rpc-cmd)
|
||||
((lang uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-stereo-mode (sound-rpc-cmd)
|
||||
((mode int32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-reverb (sound-rpc-cmd)
|
||||
((core uint8)
|
||||
(reverb int32)
|
||||
(left uint32)
|
||||
(right uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-ear-trans (sound-rpc-cmd)
|
||||
((ear-trans1 int32 3)
|
||||
(ear-trans0 int32 3)
|
||||
(cam-trans int32 3)
|
||||
(cam-forward int32 3)
|
||||
(cam-left int32 3)
|
||||
(cam-scale int32)
|
||||
(cam-inverted int32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-flava (sound-rpc-cmd)
|
||||
((flava uint8)
|
||||
(excitement uint8)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-midi-reg (sound-rpc-cmd)
|
||||
((reg int32)
|
||||
(value int16)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-shutdown (sound-rpc-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-set-fps (sound-rpc-cmd)
|
||||
((fps uint8)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-list-sounds (sound-rpc-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-unload-music (sound-rpc-cmd)
|
||||
()
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-rpc-union (structure)
|
||||
((data uint32 20)
|
||||
(load-bank sound-rpc-load-bank :overlay-at (-> data 0))
|
||||
(unload-bank sound-rpc-unload-bank :overlay-at (-> data 0))
|
||||
(play sound-rpc-play :overlay-at (-> data 0))
|
||||
(pause-sound sound-rpc-pause-sound :overlay-at (-> data 0))
|
||||
(stop-sound sound-rpc-stop-sound :overlay-at (-> data 0))
|
||||
(continue-sound sound-rpc-continue-sound :overlay-at (-> data 0))
|
||||
(set-param sound-rpc-set-param :overlay-at (-> data 0))
|
||||
(set-master-volume sound-rpc-set-master-volume :overlay-at (-> data 0))
|
||||
(pause-group sound-rpc-pause-group :overlay-at (-> data 0))
|
||||
(stop-group sound-rpc-stop-group :overlay-at (-> data 0))
|
||||
(continue-group sound-rpc-continue-group :overlay-at (-> data 0))
|
||||
(get-irx-version sound-rpc-get-irx-version :overlay-at (-> data 0))
|
||||
(set-language sound-rpc-set-language :overlay-at (-> data 0))
|
||||
(set-reverb sound-rpc-set-reverb :overlay-at (-> data 0))
|
||||
(set-ear-trans sound-rpc-set-ear-trans :overlay-at (-> data 0))
|
||||
(set-flava sound-rpc-set-flava :overlay-at (-> data 0))
|
||||
(set-midi-reg sound-rpc-set-midi-reg :overlay-at (-> data 0))
|
||||
(set-fps sound-rpc-set-fps :overlay-at (-> data 0))
|
||||
(shutdown sound-rpc-shutdown :overlay-at (-> data 0))
|
||||
(list-sounds sound-rpc-list-sounds :overlay-at (-> data 0))
|
||||
(unload-music sound-rpc-unload-music :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-spec (basic)
|
||||
((mask sound-mask)
|
||||
(num float)
|
||||
(group sound-group)
|
||||
(reg uint8 3)
|
||||
(sound-name-char uint8 16)
|
||||
(sound-name sound-name :overlay-at (-> sound-name-char 0))
|
||||
(trans int32 4)
|
||||
(volume int32)
|
||||
(pitch-mod int32)
|
||||
(bend int32)
|
||||
(fo-min int16)
|
||||
(fo-max int16)
|
||||
(fo-curve int8)
|
||||
(priority int8)
|
||||
(auto-time int32)
|
||||
(auto-from int32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sound-bank-state (structure)
|
||||
((name basic)
|
||||
(mode uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define *current-sound-id* (the-as sound-id #x10000))
|
||||
|
||||
(deftype ambient-sound (basic)
|
||||
((spec sound-spec)
|
||||
(playing-id sound-id)
|
||||
(trans vector :inline)
|
||||
(name uint128)
|
||||
(play-time uint64)
|
||||
(time-base uint64)
|
||||
(time-random uint64)
|
||||
(volume int32)
|
||||
(pitch int32)
|
||||
(falloff-near int32)
|
||||
(falloff-far int32)
|
||||
(falloff-mode int32)
|
||||
(params (pointer float))
|
||||
(param-count int32)
|
||||
(entity entity)
|
||||
(sound-count int32)
|
||||
(sound-state int32)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_)
|
||||
(ambient-sound-method-9 () none)
|
||||
(ambient-sound-method-10 () none)
|
||||
(ambient-sound-method-11 () none)
|
||||
(ambient-sound-method-12 () none)
|
||||
(ambient-sound-method-13 () none)
|
||||
(ambient-sound-method-14 () none)
|
||||
(ambient-sound-method-15 () none)
|
||||
(ambient-sound-method-16 () none)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5,5 +5,138 @@
|
||||
;; name in dgo: profile-h
|
||||
;; dgos: GAME
|
||||
|
||||
(declare-type dma-buffer structure)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype profile-segment (structure)
|
||||
"Confusingly, this has two uses. Either a single event, or a summary of all events within a category."
|
||||
((name symbol)
|
||||
(start-time int16)
|
||||
(end-time int16)
|
||||
(count uint8)
|
||||
(vu-count uint8)
|
||||
(depth uint16)
|
||||
(color rgba)
|
||||
(code-time uint16 :overlay-at start-time)
|
||||
(vu-time uint16 :overlay-at end-time)
|
||||
)
|
||||
:allow-misaligned
|
||||
)
|
||||
|
||||
|
||||
(deftype profile-collapse (structure)
|
||||
"An array of 'summaries'. Each entry in data is a summary of all events within a category."
|
||||
((count int32)
|
||||
(data profile-segment 48 :inline)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype profile-segment-array (basic)
|
||||
"All profiling data for a frame, stored as a tree of events. There is one for the VU, and one for the EE."
|
||||
((count int16)
|
||||
(depth int8)
|
||||
(max-depth int8)
|
||||
(base-time int16)
|
||||
(segment profile-segment 9)
|
||||
(data profile-segment 1024 :inline)
|
||||
)
|
||||
(:methods
|
||||
(get-total-time (_type_) int)
|
||||
(start-frame! (_type_) none)
|
||||
(start-segment! (_type_ symbol rgba) none)
|
||||
(end-segment! (_type_) none)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype profile-array (structure)
|
||||
"The EE and VU profilers, and the drawing code."
|
||||
((data profile-segment-array 2)
|
||||
)
|
||||
(:methods
|
||||
(postprocess-data! (_type_) none)
|
||||
(draw-bars! (_type_ dma-buffer int) none)
|
||||
(draw-text! (_type_) none)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defmethod get-total-time ((this profile-segment-array))
|
||||
"Get the duration of the top-level event (typically, the whole frame)"
|
||||
(- (-> this data 0 end-time) (-> this data 0 start-time))
|
||||
)
|
||||
|
||||
(deftype profile-spec (structure)
|
||||
"Specification for a profile category."
|
||||
((name basic)
|
||||
(color rgba)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define *profile-gap-color* (new 'static 'rgba :r #x30 :g #x30 :b #x30 :a #x80))
|
||||
|
||||
(define *profile-all-color* (new 'static 'rgba :r #x55 :g #x55 :b #x55 :a #x80))
|
||||
|
||||
(define *profile-blit-color* (new 'static 'rgba :r #x20 :g #x20 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-sky-color* (new 'static 'rgba :r #x20 :g #x80 :b #x20 :a #x80))
|
||||
|
||||
(define *profile-ocean-color* (new 'static 'rgba :r #x20 :g #x80 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-hfrag-color* (new 'static 'rgba :r #x80 :g #x20 :b #x20 :a #x80))
|
||||
|
||||
(define *profile-tfrag-color* (new 'static 'rgba :r #x80 :g #x20 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-texture-color* (new 'static 'rgba :r #x80 :g #x80 :b #x20 :a #x80))
|
||||
|
||||
(define *profile-tie-color* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-generic-color* (new 'static 'rgba :r #x70 :g #x70 :a #x80))
|
||||
|
||||
(define *profile-merc-color* (new 'static 'rgba :r #x70 :b #x70 :a #x80))
|
||||
|
||||
(define *profile-shrubbery-color* (new 'static 'rgba :r #x70 :a #x80))
|
||||
|
||||
(define *profile-particle-color* (new 'static 'rgba :g #x70 :b #x70 :a #x80))
|
||||
|
||||
(define *profile-debug-color* (new 'static 'rgba :g #x70 :a #x80))
|
||||
|
||||
(define *profile-other-color* (new 'static 'rgba :g #x70 :b #x70 :a #x80))
|
||||
|
||||
(define *profile-joints-color* (new 'static 'rgba :r #x70 :g #x70 :b #x20 :a #x80))
|
||||
|
||||
(define *profile-draw-hook-color* (new 'static 'rgba :r #x20 :g #x70 :b #x70 :a #x80))
|
||||
|
||||
(define *profile-background-color* (new 'static 'rgba :r #x60 :g #x60 :b #x40 :a #x80))
|
||||
|
||||
(define *profile-foreground-color* (new 'static 'rgba :r #x40 :g #x60 :b #x60 :a #x80))
|
||||
|
||||
(define *profile-bones-color* (new 'static 'rgba :r #x20 :g #x80 :b #x60 :a #x80))
|
||||
|
||||
(define *profile-actors-color* (new 'static 'rgba :r #x80 :g #x10 :b #x70 :a #x80))
|
||||
|
||||
(define *profile-collide-color* (new 'static 'rgba :r #x80 :g #x40 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-nav-color* (new 'static 'rgba :r #x38 :g #x48 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-camera-color* (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80))
|
||||
|
||||
(define *profile-gs-sync-color* (new 'static 'rgba :r #x70 :g #x70 :b #x70 :a #x80))
|
||||
|
||||
(when *debug-segment*
|
||||
(define *profile-array* (new 'debug 'profile-array))
|
||||
|
||||
(set! (-> *profile-array* data 0) (new 'debug 'profile-segment-array))
|
||||
|
||||
(set! (-> *profile-array* data 1) (new 'debug 'profile-segment-array))
|
||||
|
||||
(define *profile-collapse* (new 'debug 'profile-collapse))
|
||||
|
||||
(define *profile-interrupt-segment* (-> *profile-array* data 1))
|
||||
|
||||
(define *profile-interrupt-start* #f)
|
||||
|
||||
)
|
||||
|
||||
@@ -5,5 +5,128 @@
|
||||
;; name in dgo: types-h
|
||||
;; dgos: GAME
|
||||
|
||||
(defmacro s.w! (location value)
|
||||
"Utility macro to store a 32-bit value at a given address. Performs _no_ type checking."
|
||||
`(set! (-> (the-as (pointer uint32) ,location) 0) (the-as uint32 ,value))
|
||||
)
|
||||
|
||||
(defmacro l.wu (location)
|
||||
"Load an unsigned 32-bit value from a given address. Performs _no_ type checking."
|
||||
`(-> (the-as (pointer uint32) ,location) 0)
|
||||
)
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Common Units
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; in-game durations, distances, and rotations are stored in special formats.
|
||||
;; these macros/constants convert from literals to the correct format.
|
||||
;; for example, (meters 4.0) will give you a distance representing 4 in-game meters.
|
||||
|
||||
;; meters are stored as (usually) a float, scaled by 4096.
|
||||
;; this gives you reasonable accuracy as an integer.
|
||||
(defglobalconstant METER_LENGTH 4096.0)
|
||||
|
||||
(defmacro meters (x)
|
||||
"Convert number to meters.
|
||||
If the input is a constant float or integer, the result will be a
|
||||
compile time constant float. Otherwise, it will not be constant.
|
||||
Returns float."
|
||||
|
||||
;; we don't have enough constant propagation for the compiler to figure this out.
|
||||
(cond
|
||||
((float? x)
|
||||
(* METER_LENGTH x)
|
||||
)
|
||||
((integer? x)
|
||||
(* METER_LENGTH x)
|
||||
)
|
||||
(#t
|
||||
`(* METER_LENGTH ,x)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; rotations are stored in 65,536ths of a full rotation.
|
||||
;; like with meters, you get a reasonable accuracy as an integer.
|
||||
;; additionally, it is a power-of-two, so wrapping rotations can be done
|
||||
;; quickly by converting to an int, masking, and back to float
|
||||
(defglobalconstant DEGREES_PER_ROT 65536.0)
|
||||
|
||||
;; this was deg in GOAL
|
||||
(defmacro degrees (x)
|
||||
"Convert number to degrees unit.
|
||||
Will keep a constant float/int constant."
|
||||
(cond
|
||||
((or (float? x) (integer? x))
|
||||
(* DEGREES_PER_ROT (/ (+ 0.0 x) 360.0))
|
||||
)
|
||||
(#t
|
||||
`(* (/ (the float ,x) 360.0)
|
||||
DEGREES_PER_ROT
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro fsec (x)
|
||||
"Convert number to seconds unit.
|
||||
Returns float."
|
||||
(cond
|
||||
((or (integer? x) (float? x))
|
||||
(* 1.0 TICKS_PER_SECOND x)
|
||||
)
|
||||
(#t
|
||||
`(* 1.0 TICKS_PER_SECOND ,x)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype basic-reserved (basic)
|
||||
()
|
||||
(:methods
|
||||
(basic-reserved-method-9 () none)
|
||||
(basic-reserved-method-10 () none)
|
||||
(basic-reserved-method-11 () none)
|
||||
(basic-reserved-method-12 () none)
|
||||
(basic-reserved-method-13 () none)
|
||||
(basic-reserved-method-14 () none)
|
||||
(basic-reserved-method-15 () none)
|
||||
(basic-reserved-method-16 () none)
|
||||
(basic-reserved-method-17 () none)
|
||||
(basic-reserved-method-18 () none)
|
||||
(basic-reserved-method-19 () none)
|
||||
(basic-reserved-method-20 () none)
|
||||
(basic-reserved-method-21 () none)
|
||||
(basic-reserved-method-22 () none)
|
||||
(basic-reserved-method-23 () none)
|
||||
(basic-reserved-method-24 () none)
|
||||
(basic-reserved-method-25 () none)
|
||||
(basic-reserved-method-26 () none)
|
||||
(basic-reserved-method-27 () none)
|
||||
(basic-reserved-method-28 () none)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype part-id (uint32)
|
||||
()
|
||||
)
|
||||
|
||||
;; og:preserve-this
|
||||
;; unused, and not supported in the compiler, since the linker would need to link to the type object, which
|
||||
;; means the type needs to be allocated, and we'd need to know the number of methods.
|
||||
;; technically, the compiler does support this through the `(type-ref sage-finalboss :method-count 53)` feature,
|
||||
;; but it seems like too much work to support this in the decompiler for an array that's not even used...
|
||||
; (new 'static 'boxed-array :type type
|
||||
; pilot-info
|
||||
; flut-info
|
||||
; mech-info
|
||||
; turret-info
|
||||
; indax-info
|
||||
; tube-info
|
||||
; race-mesh
|
||||
; )
|
||||
Reference in New Issue
Block a user