mirror of
https://github.com/open-goal/jak-project
synced 2026-09-03 10:21:36 -04:00
decomp3: some engine files (#3319)
- `vector-h` - `gravity-h` - `bounding-box-h` - `matrix-h` - `quaternion-h` - `euler-h` - `transform-h` - `geometry-h` - `trigonometry-h` - `transformq-h` - `bounding-box` - `matrix` - `matrix-compose` - `transform` - `quaternion` - `euler` - `trigonometry` Not a whole lot of changes, just a couple of new functions and one new file (`matrix-compose`).
This commit is contained in:
+929
-711
File diff suppressed because it is too large
Load Diff
@@ -11,280 +11,280 @@
|
||||
//"CGO/ART.CGO",
|
||||
"CGO/KERNEL.CGO",
|
||||
// "CGO/ENGINE.CGO",
|
||||
"CGO/GAME.CGO",
|
||||
"CGO/GAME.CGO"
|
||||
// "CGO/COMMON.CGO",
|
||||
"DGO/LJKDMPK.DGO",
|
||||
"DGO/LBBSDRP1.DGO",
|
||||
"DGO/LTNJXHIP.DGO",
|
||||
"DGO/MIC.DGO",
|
||||
"DGO/OASISCST.DGO",
|
||||
"DGO/CTYPEPA.DGO",
|
||||
"DGO/LPRENME.DGO",
|
||||
"DGO/LFREEOUT.DGO",
|
||||
"DGO/LGUNNORM.DGO",
|
||||
"DGO/LTOWA.DGO",
|
||||
"DGO/TEMA.DGO",
|
||||
"DGO/CTA.DGO",
|
||||
"DGO/LPRECC.DGO",
|
||||
"DGO/LJKDXVIN.DGO",
|
||||
"DGO/CTYPEPC.DGO",
|
||||
"DGO/SEA.DGO",
|
||||
"DGO/COMBE.DGO",
|
||||
"DGO/CTYPESA.DGO",
|
||||
"DGO/LBLOWCST.DGO",
|
||||
"DGO/WSD.DGO",
|
||||
"DGO/LBBRING3.DGO",
|
||||
"DGO/LCTYPATK.DGO",
|
||||
"DGO/WCB.DGO",
|
||||
"DGO/DESRESC.DGO",
|
||||
"DGO/LBBRING4.DGO",
|
||||
"DGO/GRIDCST.DGO",
|
||||
"DGO/RAILX.DGO",
|
||||
"DGO/SEJ.DGO",
|
||||
"DGO/LJAKC.DGO",
|
||||
"DGO/CTB.DGO",
|
||||
"DGO/CTYCARC.DGO",
|
||||
"DGO/LMECH.DGO",
|
||||
"DGO/LBBSDRP2.DGO",
|
||||
"DGO/NSA.DGO",
|
||||
"DGO/LBBTCHA3.DGO",
|
||||
"DGO/GUNGAME2.DGO",
|
||||
"DGO/CTC.DGO",
|
||||
"DGO/LVINCST.DGO",
|
||||
"DGO/COMBX.DGO",
|
||||
"DGO/DESH.DGO",
|
||||
"DGO/DESRACE2.DGO",
|
||||
"DGO/RAILD.DGO",
|
||||
"DGO/FACC.DGO",
|
||||
"DGO/CTYPESC.DGO",
|
||||
"DGO/LWASBBV.DGO",
|
||||
"DGO/TOWB.DGO",
|
||||
"DGO/HGA.DGO",
|
||||
"DGO/SEH.DGO",
|
||||
"DGO/MHCTYCST.DGO",
|
||||
"DGO/GUNGAME1.DGO",
|
||||
"DGO/INTROCST.DGO",
|
||||
"DGO/DESJUMP.DGO",
|
||||
"DGO/SEM.DGO",
|
||||
"DGO/SEI.DGO",
|
||||
"DGO/DESG.DGO",
|
||||
"DGO/DESW.DGO",
|
||||
"DGO/LOUTRO3.DGO",
|
||||
"DGO/LDAMKLEV.DGO",
|
||||
"DGO/DESERROL.DGO",
|
||||
"DGO/RAILB2.DGO",
|
||||
"DGO/LERROL.DGO",
|
||||
"DGO/IPF.DGO",
|
||||
"DGO/RAILB.DGO",
|
||||
"DGO/LCTYHIJK.DGO",
|
||||
"DGO/CTYPEPB.DGO",
|
||||
"DGO/PRECB.DGO",
|
||||
"DGO/LFORM.DGO",
|
||||
"DGO/WASLEAPR.DGO",
|
||||
"DGO/LKEIRA.DGO",
|
||||
"DGO/LJAK.DGO",
|
||||
"DGO/SLUMBSET.DGO",
|
||||
"DGO/FACD.DGO",
|
||||
"DGO/LWASSIG.DGO",
|
||||
"DGO/LBIPED.DGO",
|
||||
"DGO/DESD.DGO",
|
||||
"DGO/CFB.DGO",
|
||||
"DGO/FREECAST.DGO",
|
||||
"DGO/SEG.DGO",
|
||||
"DGO/FACTORYA.DGO",
|
||||
"DGO/LPATK.DGO",
|
||||
"DGO/FRSTX.DGO",
|
||||
"DGO/SEB.DGO",
|
||||
"DGO/DESBCST.DGO",
|
||||
"DGO/DESE.DGO",
|
||||
"DGO/DESOASIS.DGO",
|
||||
"DGO/CTYCARA.DGO",
|
||||
"DGO/LSIGKLV.DGO",
|
||||
"DGO/CIB.DGO",
|
||||
"DGO/LBBRING2.DGO",
|
||||
"DGO/LTNFXHIP.DGO",
|
||||
"DGO/MIA.DGO",
|
||||
"DGO/MHCB.DGO",
|
||||
"DGO/LNSTOBC.DGO",
|
||||
"DGO/COMBD.DGO",
|
||||
"DGO/RBCT.DGO",
|
||||
"DGO/LTORNJNX.DGO",
|
||||
"DGO/DESBATTL.DGO",
|
||||
"DGO/SEK.DGO",
|
||||
"DGO/LSNKWHLS.DGO",
|
||||
"DGO/LMHCB.DGO",
|
||||
"DGO/LBOMBBOT.DGO",
|
||||
"DGO/OUTCAST3.DGO",
|
||||
"DGO/LBLOWTMH.DGO",
|
||||
"DGO/TEMD.DGO",
|
||||
"DGO/LTOWCITY.DGO",
|
||||
"DGO/OUTROCST.DGO",
|
||||
"DGO/WASCAST.DGO",
|
||||
"DGO/LFACRM2.DGO",
|
||||
"DGO/WASPGAME.DGO",
|
||||
"DGO/RAILE.DGO",
|
||||
"DGO/CTYPESB.DGO",
|
||||
"DGO/DESBOSS1.DGO",
|
||||
"DGO/FREEHQ.DGO",
|
||||
"DGO/LTORN.DGO",
|
||||
"DGO/TOWERA.DGO",
|
||||
"DGO/LSAMOS.DGO",
|
||||
"DGO/LFORP.DGO",
|
||||
"DGO/CFA.DGO",
|
||||
"DGO/LJINX.DGO",
|
||||
"DGO/SEO.DGO",
|
||||
"DGO/PRECA.DGO",
|
||||
"DGO/TOWERC.DGO",
|
||||
"DGO/WCA.DGO",
|
||||
"DGO/SEC.DGO",
|
||||
"DGO/DESF.DGO",
|
||||
"DGO/SEL.DGO",
|
||||
"DGO/LCTYDEST.DGO",
|
||||
"DGO/LTORNSAM.DGO",
|
||||
"DGO/MUSEUM3B.DGO",
|
||||
"DGO/SEE.DGO",
|
||||
"DGO/DESHUNT.DGO",
|
||||
"DGO/RAILA.DGO",
|
||||
"DGO/TITLE.DGO",
|
||||
"DGO/RUBC.DGO",
|
||||
"DGO/DESB.DGO",
|
||||
"DGO/LFACCAR.DGO",
|
||||
"DGO/LNSTOA.DGO",
|
||||
"DGO/MUSEUM3.DGO",
|
||||
"DGO/ONINTENT.DGO",
|
||||
"DGO/STA.DGO",
|
||||
"DGO/WASSTADA.DGO",
|
||||
"DGO/POWERGD.DGO",
|
||||
"DGO/LKLEEVER.DGO",
|
||||
"DGO/FACB.DGO",
|
||||
"DGO/LCTYASS.DGO",
|
||||
"DGO/MHCA.DGO",
|
||||
"DGO/LTOWB.DGO",
|
||||
"DGO/LNSTCST.DGO",
|
||||
"DGO/DESRESCG.DGO",
|
||||
"DGO/INTPALRF.DGO",
|
||||
"DGO/LMHCA.DGO",
|
||||
"DGO/TOWERCST.DGO",
|
||||
"DGO/RAILF.DGO",
|
||||
"DGO/CIA.DGO",
|
||||
"DGO/CTYCARKG.DGO",
|
||||
"DGO/WASCHASE.DGO",
|
||||
"DGO/LFACO.DGO",
|
||||
"DGO/WIN.DGO",
|
||||
"DGO/TEMPLEE.DGO",
|
||||
"DGO/LBBSPIRT.DGO",
|
||||
"DGO/MUSEUM2.DGO",
|
||||
"DGO/INTTITLE.DGO",
|
||||
"DGO/STAA.DGO",
|
||||
"DGO/MUSEUM4B.DGO",
|
||||
"DGO/PRECD.DGO",
|
||||
"DGO/SEF.DGO",
|
||||
"DGO/CTYCARB.DGO",
|
||||
"DGO/WASDEFEN.DGO",
|
||||
"DGO/LBLOWTKG.DGO",
|
||||
"DGO/DESA.DGO",
|
||||
"DGO/COMBB.DGO",
|
||||
"DGO/WASSTADC.DGO",
|
||||
"DGO/DESC.DGO",
|
||||
"DGO/LDAMPECK.DGO",
|
||||
"DGO/LJAKSIG.DGO",
|
||||
"DGO/HALFPIPE.DGO",
|
||||
"DGO/DESRACE1.DGO",
|
||||
"DGO/SEN.DGO",
|
||||
"DGO/TEMP.DGO",
|
||||
"DGO/SED.DGO",
|
||||
"DGO/LFACB.DGO",
|
||||
"DGO/LCTYSNPR.DGO",
|
||||
"DGO/LBBSPID.DGO",
|
||||
"DGO/FRSTA.DGO",
|
||||
"DGO/LBBRING5.DGO",
|
||||
"DGO/LBBSPRT3.DGO",
|
||||
"DGO/HHG.DGO",
|
||||
"DGO/LBBSPRT2.DGO",
|
||||
"DGO/CGB.DGO",
|
||||
"DGO/LDMPCKGN.DGO",
|
||||
"DGO/LSEEMWCA.DGO",
|
||||
"DGO/HGB.DGO",
|
||||
"DGO/LONINSIM.DGO",
|
||||
"DGO/RUBA.DGO",
|
||||
"DGO/DESRALLY.DGO",
|
||||
"DGO/WWD.DGO",
|
||||
"DGO/STB.DGO",
|
||||
"DGO/MIB.DGO",
|
||||
"DGO/LCTYBLOW.DGO",
|
||||
"DGO/LWSTDPCK.DGO",
|
||||
"DGO/MUSEUM.DGO",
|
||||
"DGO/LJAKCKLV.DGO",
|
||||
"DGO/LBBRING1.DGO",
|
||||
"DGO/MUSEUM4.DGO",
|
||||
"DGO/LFACRM1.DGO",
|
||||
"DGO/LJKCDMKL.DGO",
|
||||
"DGO/LDAMSIG.DGO",
|
||||
"DGO/DESTRACK.DGO",
|
||||
"DGO/GGA.DGO",
|
||||
"DGO/RAILC.DGO",
|
||||
"DGO/LBBTCHA2.DGO",
|
||||
"DGO/DESINTER.DGO",
|
||||
"DGO/NSB.DGO",
|
||||
"DGO/LOUTRO.DGO",
|
||||
"DGO/VIN.DGO",
|
||||
"DGO/LDESGCST.DGO",
|
||||
"DGO/WARPCAST.DGO",
|
||||
"DGO/LBBRING6.DGO",
|
||||
"DGO/FRSTB.DGO",
|
||||
"DGO/TEMC.DGO",
|
||||
"DGO/COMBC.DGO",
|
||||
"DGO/LTRTWHLS.DGO",
|
||||
"DGO/PRECC.DGO",
|
||||
"DGO/DESCHASE.DGO",
|
||||
"DGO/CITYCAST.DGO",
|
||||
"DGO/CPO.DGO",
|
||||
"DGO/LFACCITY.DGO",
|
||||
"DGO/RAILCST.DGO",
|
||||
"DGO/LJNDKLEV.DGO",
|
||||
"DGO/CWI.DGO",
|
||||
"DGO/MINEE.DGO",
|
||||
"DGO/LFORRING.DGO",
|
||||
"DGO/LASHELIN.DGO",
|
||||
"DGO/LJAKKLEV.DGO",
|
||||
"DGO/LCTYPALT.DGO",
|
||||
"DGO/LNSTOBB.DGO",
|
||||
"DGO/LJKFEET.DGO",
|
||||
"DGO/DST.DGO",
|
||||
"DGO/LBBTCHA1.DGO",
|
||||
"DGO/LGUNRNC.DGO",
|
||||
"DGO/COMBN.DGO",
|
||||
"DGO/DESRESCC.DGO",
|
||||
"DGO/LSIGJAKC.DGO",
|
||||
"DGO/DESLIZ.DGO",
|
||||
"DGO/WASPALA.DGO",
|
||||
"DGO/LJAKNDAX.DGO",
|
||||
"DGO/WASSEEM.DGO",
|
||||
"DGO/WASALL.DGO",
|
||||
"DGO/WCASEEM.DGO",
|
||||
"DGO/LSIG.DGO",
|
||||
"DGO/LFACTORY.DGO",
|
||||
"DGO/LWLANDM.DGO",
|
||||
"DGO/LPTRL.DGO",
|
||||
"DGO/MINED.DGO",
|
||||
"DGO/LDAMPKSM.DGO",
|
||||
"DGO/RUBB.DGO",
|
||||
"DGO/LCITYSML.DGO",
|
||||
"DGO/RUBA2.DGO",
|
||||
"DGO/LOUTRO2.DGO",
|
||||
"DGO/VOCX.DGO",
|
||||
"DGO/TEMX.DGO",
|
||||
"DGO/ARENACST.DGO",
|
||||
"DGO/TEMB.DGO",
|
||||
"DGO/COMBA.DGO",
|
||||
"DGO/LBBSDRP3.DGO",
|
||||
"DGO/LPATKCS.DGO",
|
||||
"DGO/VOCA.DGO",
|
||||
"DGO/WASSTADB.DGO",
|
||||
"DGO/LDAX.DGO",
|
||||
"DGO/LCTYPROT.DGO",
|
||||
"DGO/DESHOVER.DGO",
|
||||
"DGO/DESBOSS2.DGO"
|
||||
// "DGO/LJKDMPK.DGO",
|
||||
// "DGO/LBBSDRP1.DGO",
|
||||
// "DGO/LTNJXHIP.DGO",
|
||||
// "DGO/MIC.DGO",
|
||||
// "DGO/OASISCST.DGO",
|
||||
// "DGO/CTYPEPA.DGO",
|
||||
// "DGO/LPRENME.DGO",
|
||||
// "DGO/LFREEOUT.DGO",
|
||||
// "DGO/LGUNNORM.DGO",
|
||||
// "DGO/LTOWA.DGO",
|
||||
// "DGO/TEMA.DGO",
|
||||
// "DGO/CTA.DGO",
|
||||
// "DGO/LPRECC.DGO",
|
||||
// "DGO/LJKDXVIN.DGO",
|
||||
// "DGO/CTYPEPC.DGO",
|
||||
// "DGO/SEA.DGO",
|
||||
// "DGO/COMBE.DGO",
|
||||
// "DGO/CTYPESA.DGO",
|
||||
// "DGO/LBLOWCST.DGO",
|
||||
// "DGO/WSD.DGO",
|
||||
// "DGO/LBBRING3.DGO",
|
||||
// "DGO/LCTYPATK.DGO",
|
||||
// "DGO/WCB.DGO",
|
||||
// "DGO/DESRESC.DGO",
|
||||
// "DGO/LBBRING4.DGO",
|
||||
// "DGO/GRIDCST.DGO",
|
||||
// "DGO/RAILX.DGO",
|
||||
// "DGO/SEJ.DGO",
|
||||
// "DGO/LJAKC.DGO",
|
||||
// "DGO/CTB.DGO",
|
||||
// "DGO/CTYCARC.DGO",
|
||||
// "DGO/LMECH.DGO",
|
||||
// "DGO/LBBSDRP2.DGO",
|
||||
// "DGO/NSA.DGO",
|
||||
// "DGO/LBBTCHA3.DGO",
|
||||
// "DGO/GUNGAME2.DGO",
|
||||
// "DGO/CTC.DGO",
|
||||
// "DGO/LVINCST.DGO",
|
||||
// "DGO/COMBX.DGO",
|
||||
// "DGO/DESH.DGO",
|
||||
// "DGO/DESRACE2.DGO",
|
||||
// "DGO/RAILD.DGO",
|
||||
// "DGO/FACC.DGO",
|
||||
// "DGO/CTYPESC.DGO",
|
||||
// "DGO/LWASBBV.DGO",
|
||||
// "DGO/TOWB.DGO",
|
||||
// "DGO/HGA.DGO",
|
||||
// "DGO/SEH.DGO",
|
||||
// "DGO/MHCTYCST.DGO",
|
||||
// "DGO/GUNGAME1.DGO",
|
||||
// "DGO/INTROCST.DGO",
|
||||
// "DGO/DESJUMP.DGO",
|
||||
// "DGO/SEM.DGO",
|
||||
// "DGO/SEI.DGO",
|
||||
// "DGO/DESG.DGO",
|
||||
// "DGO/DESW.DGO",
|
||||
// "DGO/LOUTRO3.DGO",
|
||||
// "DGO/LDAMKLEV.DGO",
|
||||
// "DGO/DESERROL.DGO",
|
||||
// "DGO/RAILB2.DGO",
|
||||
// "DGO/LERROL.DGO",
|
||||
// "DGO/IPF.DGO",
|
||||
// "DGO/RAILB.DGO",
|
||||
// "DGO/LCTYHIJK.DGO",
|
||||
// "DGO/CTYPEPB.DGO",
|
||||
// "DGO/PRECB.DGO",
|
||||
// "DGO/LFORM.DGO",
|
||||
// "DGO/WASLEAPR.DGO",
|
||||
// "DGO/LKEIRA.DGO",
|
||||
// "DGO/LJAK.DGO",
|
||||
// "DGO/SLUMBSET.DGO",
|
||||
// "DGO/FACD.DGO",
|
||||
// "DGO/LWASSIG.DGO",
|
||||
// "DGO/LBIPED.DGO",
|
||||
// "DGO/DESD.DGO",
|
||||
// "DGO/CFB.DGO",
|
||||
// "DGO/FREECAST.DGO",
|
||||
// "DGO/SEG.DGO",
|
||||
// "DGO/FACTORYA.DGO",
|
||||
// "DGO/LPATK.DGO",
|
||||
// "DGO/FRSTX.DGO",
|
||||
// "DGO/SEB.DGO",
|
||||
// "DGO/DESBCST.DGO",
|
||||
// "DGO/DESE.DGO",
|
||||
// "DGO/DESOASIS.DGO",
|
||||
// "DGO/CTYCARA.DGO",
|
||||
// "DGO/LSIGKLV.DGO",
|
||||
// "DGO/CIB.DGO",
|
||||
// "DGO/LBBRING2.DGO",
|
||||
// "DGO/LTNFXHIP.DGO",
|
||||
// "DGO/MIA.DGO",
|
||||
// "DGO/MHCB.DGO",
|
||||
// "DGO/LNSTOBC.DGO",
|
||||
// "DGO/COMBD.DGO",
|
||||
// "DGO/RBCT.DGO",
|
||||
// "DGO/LTORNJNX.DGO",
|
||||
// "DGO/DESBATTL.DGO",
|
||||
// "DGO/SEK.DGO",
|
||||
// "DGO/LSNKWHLS.DGO",
|
||||
// "DGO/LMHCB.DGO",
|
||||
// "DGO/LBOMBBOT.DGO",
|
||||
// "DGO/OUTCAST3.DGO",
|
||||
// "DGO/LBLOWTMH.DGO",
|
||||
// "DGO/TEMD.DGO",
|
||||
// "DGO/LTOWCITY.DGO",
|
||||
// "DGO/OUTROCST.DGO",
|
||||
// "DGO/WASCAST.DGO",
|
||||
// "DGO/LFACRM2.DGO",
|
||||
// "DGO/WASPGAME.DGO",
|
||||
// "DGO/RAILE.DGO",
|
||||
// "DGO/CTYPESB.DGO",
|
||||
// "DGO/DESBOSS1.DGO",
|
||||
// "DGO/FREEHQ.DGO",
|
||||
// "DGO/LTORN.DGO",
|
||||
// "DGO/TOWERA.DGO",
|
||||
// "DGO/LSAMOS.DGO",
|
||||
// "DGO/LFORP.DGO",
|
||||
// "DGO/CFA.DGO",
|
||||
// "DGO/LJINX.DGO",
|
||||
// "DGO/SEO.DGO",
|
||||
// "DGO/PRECA.DGO",
|
||||
// "DGO/TOWERC.DGO",
|
||||
// "DGO/WCA.DGO",
|
||||
// "DGO/SEC.DGO",
|
||||
// "DGO/DESF.DGO",
|
||||
// "DGO/SEL.DGO",
|
||||
// "DGO/LCTYDEST.DGO",
|
||||
// "DGO/LTORNSAM.DGO",
|
||||
// "DGO/MUSEUM3B.DGO",
|
||||
// "DGO/SEE.DGO",
|
||||
// "DGO/DESHUNT.DGO",
|
||||
// "DGO/RAILA.DGO",
|
||||
// "DGO/TITLE.DGO",
|
||||
// "DGO/RUBC.DGO",
|
||||
// "DGO/DESB.DGO",
|
||||
// "DGO/LFACCAR.DGO",
|
||||
// "DGO/LNSTOA.DGO",
|
||||
// "DGO/MUSEUM3.DGO",
|
||||
// "DGO/ONINTENT.DGO",
|
||||
// "DGO/STA.DGO",
|
||||
// "DGO/WASSTADA.DGO",
|
||||
// "DGO/POWERGD.DGO",
|
||||
// "DGO/LKLEEVER.DGO",
|
||||
// "DGO/FACB.DGO",
|
||||
// "DGO/LCTYASS.DGO",
|
||||
// "DGO/MHCA.DGO",
|
||||
// "DGO/LTOWB.DGO",
|
||||
// "DGO/LNSTCST.DGO",
|
||||
// "DGO/DESRESCG.DGO",
|
||||
// "DGO/INTPALRF.DGO",
|
||||
// "DGO/LMHCA.DGO",
|
||||
// "DGO/TOWERCST.DGO",
|
||||
// "DGO/RAILF.DGO",
|
||||
// "DGO/CIA.DGO",
|
||||
// "DGO/CTYCARKG.DGO",
|
||||
// "DGO/WASCHASE.DGO",
|
||||
// "DGO/LFACO.DGO",
|
||||
// "DGO/WIN.DGO",
|
||||
// "DGO/TEMPLEE.DGO",
|
||||
// "DGO/LBBSPIRT.DGO",
|
||||
// "DGO/MUSEUM2.DGO",
|
||||
// "DGO/INTTITLE.DGO",
|
||||
// "DGO/STAA.DGO",
|
||||
// "DGO/MUSEUM4B.DGO",
|
||||
// "DGO/PRECD.DGO",
|
||||
// "DGO/SEF.DGO",
|
||||
// "DGO/CTYCARB.DGO",
|
||||
// "DGO/WASDEFEN.DGO",
|
||||
// "DGO/LBLOWTKG.DGO",
|
||||
// "DGO/DESA.DGO",
|
||||
// "DGO/COMBB.DGO",
|
||||
// "DGO/WASSTADC.DGO",
|
||||
// "DGO/DESC.DGO",
|
||||
// "DGO/LDAMPECK.DGO",
|
||||
// "DGO/LJAKSIG.DGO",
|
||||
// "DGO/HALFPIPE.DGO",
|
||||
// "DGO/DESRACE1.DGO",
|
||||
// "DGO/SEN.DGO",
|
||||
// "DGO/TEMP.DGO",
|
||||
// "DGO/SED.DGO",
|
||||
// "DGO/LFACB.DGO",
|
||||
// "DGO/LCTYSNPR.DGO",
|
||||
// "DGO/LBBSPID.DGO",
|
||||
// "DGO/FRSTA.DGO",
|
||||
// "DGO/LBBRING5.DGO",
|
||||
// "DGO/LBBSPRT3.DGO",
|
||||
// "DGO/HHG.DGO",
|
||||
// "DGO/LBBSPRT2.DGO",
|
||||
// "DGO/CGB.DGO",
|
||||
// "DGO/LDMPCKGN.DGO",
|
||||
// "DGO/LSEEMWCA.DGO",
|
||||
// "DGO/HGB.DGO",
|
||||
// "DGO/LONINSIM.DGO",
|
||||
// "DGO/RUBA.DGO",
|
||||
// "DGO/DESRALLY.DGO",
|
||||
// "DGO/WWD.DGO",
|
||||
// "DGO/STB.DGO",
|
||||
// "DGO/MIB.DGO",
|
||||
// "DGO/LCTYBLOW.DGO",
|
||||
// "DGO/LWSTDPCK.DGO",
|
||||
// "DGO/MUSEUM.DGO",
|
||||
// "DGO/LJAKCKLV.DGO",
|
||||
// "DGO/LBBRING1.DGO",
|
||||
// "DGO/MUSEUM4.DGO",
|
||||
// "DGO/LFACRM1.DGO",
|
||||
// "DGO/LJKCDMKL.DGO",
|
||||
// "DGO/LDAMSIG.DGO",
|
||||
// "DGO/DESTRACK.DGO",
|
||||
// "DGO/GGA.DGO",
|
||||
// "DGO/RAILC.DGO",
|
||||
// "DGO/LBBTCHA2.DGO",
|
||||
// "DGO/DESINTER.DGO",
|
||||
// "DGO/NSB.DGO",
|
||||
// "DGO/LOUTRO.DGO",
|
||||
// "DGO/VIN.DGO",
|
||||
// "DGO/LDESGCST.DGO",
|
||||
// "DGO/WARPCAST.DGO",
|
||||
// "DGO/LBBRING6.DGO",
|
||||
// "DGO/FRSTB.DGO",
|
||||
// "DGO/TEMC.DGO",
|
||||
// "DGO/COMBC.DGO",
|
||||
// "DGO/LTRTWHLS.DGO",
|
||||
// "DGO/PRECC.DGO",
|
||||
// "DGO/DESCHASE.DGO",
|
||||
// "DGO/CITYCAST.DGO",
|
||||
// "DGO/CPO.DGO",
|
||||
// "DGO/LFACCITY.DGO",
|
||||
// "DGO/RAILCST.DGO",
|
||||
// "DGO/LJNDKLEV.DGO",
|
||||
// "DGO/CWI.DGO",
|
||||
// "DGO/MINEE.DGO",
|
||||
// "DGO/LFORRING.DGO",
|
||||
// "DGO/LASHELIN.DGO",
|
||||
// "DGO/LJAKKLEV.DGO",
|
||||
// "DGO/LCTYPALT.DGO",
|
||||
// "DGO/LNSTOBB.DGO",
|
||||
// "DGO/LJKFEET.DGO",
|
||||
// "DGO/DST.DGO",
|
||||
// "DGO/LBBTCHA1.DGO",
|
||||
// "DGO/LGUNRNC.DGO",
|
||||
// "DGO/COMBN.DGO",
|
||||
// "DGO/DESRESCC.DGO",
|
||||
// "DGO/LSIGJAKC.DGO",
|
||||
// "DGO/DESLIZ.DGO",
|
||||
// "DGO/WASPALA.DGO",
|
||||
// "DGO/LJAKNDAX.DGO",
|
||||
// "DGO/WASSEEM.DGO",
|
||||
// "DGO/WASALL.DGO",
|
||||
// "DGO/WCASEEM.DGO",
|
||||
// "DGO/LSIG.DGO",
|
||||
// "DGO/LFACTORY.DGO",
|
||||
// "DGO/LWLANDM.DGO",
|
||||
// "DGO/LPTRL.DGO",
|
||||
// "DGO/MINED.DGO",
|
||||
// "DGO/LDAMPKSM.DGO",
|
||||
// "DGO/RUBB.DGO",
|
||||
// "DGO/LCITYSML.DGO",
|
||||
// "DGO/RUBA2.DGO",
|
||||
// "DGO/LOUTRO2.DGO",
|
||||
// "DGO/VOCX.DGO",
|
||||
// "DGO/TEMX.DGO",
|
||||
// "DGO/ARENACST.DGO",
|
||||
// "DGO/TEMB.DGO",
|
||||
// "DGO/COMBA.DGO",
|
||||
// "DGO/LBBSDRP3.DGO",
|
||||
// "DGO/LPATKCS.DGO",
|
||||
// "DGO/VOCA.DGO",
|
||||
// "DGO/WASSTADB.DGO",
|
||||
// "DGO/LDAX.DGO",
|
||||
// "DGO/LCTYPROT.DGO",
|
||||
// "DGO/DESHOVER.DGO",
|
||||
// "DGO/DESBOSS2.DGO"
|
||||
],
|
||||
|
||||
// some objects are part of STR files (streaming data).
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
{}
|
||||
{
|
||||
"math": [
|
||||
["L108", "(pointer float)", 32],
|
||||
["L109", "(pointer float)", 32]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
{}
|
||||
{
|
||||
"quaternion-smooth-seek!": [[16, "quaternion"]],
|
||||
"eul->matrix": [[16, "vector"]]
|
||||
}
|
||||
|
||||
@@ -33,5 +33,24 @@
|
||||
"(method 0 process)": [
|
||||
// [11, "a0", "int"],
|
||||
// [[12, 45], "v0", "process"]
|
||||
],
|
||||
"logf": [
|
||||
[12, "f0", "float"],
|
||||
[12, "f1", "float"],
|
||||
[19, "f0", "float"],
|
||||
[19, "f1", "float"]
|
||||
],
|
||||
"log2f": [
|
||||
[12, "f0", "float"],
|
||||
[12, "f1", "float"],
|
||||
[19, "f0", "float"],
|
||||
[19, "f1", "float"]
|
||||
],
|
||||
"cube-root": [
|
||||
[17, "f0", "float"],
|
||||
[17, "f1", "float"],
|
||||
[18, "f0", "float"],
|
||||
[18, "f1", "float"],
|
||||
[[23, 32], "f0", "float"]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1 +1,28 @@
|
||||
{}
|
||||
{
|
||||
"matrix-transpose!": {
|
||||
"args": [
|
||||
"dst",
|
||||
"src"
|
||||
]
|
||||
},
|
||||
"matrix-axis-sin-cos!": {
|
||||
"args": [
|
||||
"dst",
|
||||
"axis",
|
||||
"s",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"vector-rad<-vector-deg/2!": {
|
||||
"args": [
|
||||
"out",
|
||||
"in"
|
||||
]
|
||||
},
|
||||
"vector-rad<-vector-deg!": {
|
||||
"args": [
|
||||
"out",
|
||||
"in"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@
|
||||
["transformq-h", "transformq-h", 5, ["GAME"], "engine/math"],
|
||||
["bounding-box", "bounding-box", 5, ["GAME"], "engine/geometry"],
|
||||
["matrix", "matrix", 5, ["GAME"], "engine/math"],
|
||||
["matrix-compose", "matrix-compose", 5, ["GAME"], "engine/common-obs"],
|
||||
["matrix-compose", "matrix-compose", 5, ["GAME"], "engine/math"],
|
||||
["transform", "transform", 5, ["GAME"], "engine/math"],
|
||||
["quaternion", "quaternion", 5, ["GAME"], "engine/math"],
|
||||
["euler", "euler", 5, ["GAME"], "engine/math"],
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; name: matrix-compose.gc
|
||||
;; name in dgo: matrix-compose
|
||||
;; dgos: GAME
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
@@ -7,3 +7,52 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype bounding-box (structure)
|
||||
((min vector :inline)
|
||||
(max vector :inline)
|
||||
)
|
||||
(:methods
|
||||
(add-spheres! (_type_ (inline-array sphere) int) int)
|
||||
(add-box! (_type_ bounding-box) int)
|
||||
(add-point! (_type_ vector) none)
|
||||
(intersects-line-segment? (_type_ vector vector) symbol)
|
||||
(set-from-point-offset! (_type_ vector vector) none)
|
||||
(set-from-point-offset-pad! (_type_ vector vector float) int)
|
||||
(set-to-point! (_type_ vector) none)
|
||||
(set-from-sphere! (_type_ sphere) none)
|
||||
(set-from-spheres! (_type_ (inline-array sphere) int) int)
|
||||
(get-bounding-sphere (_type_ vector) vector)
|
||||
(inside-xyz? (bounding-box vector) symbol)
|
||||
(inside-xz? (bounding-box vector) symbol)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype bounding-box2 (structure)
|
||||
((min vector2 :inline)
|
||||
(max vector2 :inline)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype bounding-box4w (structure)
|
||||
((min vector4w :inline)
|
||||
(max vector4w :inline)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype bounding-box-both (structure)
|
||||
((box bounding-box :inline)
|
||||
(box4w bounding-box4w :inline)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype bounding-box-array (inline-array-class)
|
||||
((data bounding-box :dynamic)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(set! (-> bounding-box-array heap-base) (the-as uint 32))
|
||||
|
||||
@@ -7,3 +7,314 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(defmethod inside-xyz? ((this bounding-box) (arg0 vector))
|
||||
"Is the point in the box?"
|
||||
(and (< (-> this min x) (-> arg0 x))
|
||||
(< (-> this min y) (-> arg0 y))
|
||||
(< (-> this min z) (-> arg0 z))
|
||||
(< (-> arg0 x) (-> this max x))
|
||||
(< (-> arg0 y) (-> this max y))
|
||||
(< (-> arg0 z) (-> this max z))
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod inside-xz? ((this bounding-box) (arg0 vector))
|
||||
"Is the point in the box? Check xz only."
|
||||
(and (< (-> this min x) (-> arg0 x))
|
||||
(< (-> this min z) (-> arg0 z))
|
||||
(< (-> arg0 x) (-> this max x))
|
||||
(< (-> arg0 z) (-> this max z))
|
||||
)
|
||||
)
|
||||
|
||||
(defun box-vector-enside? ((arg0 bounding-box) (arg1 vector))
|
||||
"Is the point in the box? On the edge doesn't count."
|
||||
(and (< (-> arg0 min x) (-> arg1 x))
|
||||
(< (-> arg0 min y) (-> arg1 y))
|
||||
(< (-> arg0 min z) (-> arg1 z))
|
||||
(< (-> arg1 x) (-> arg0 max x))
|
||||
(< (-> arg1 y) (-> arg0 max y))
|
||||
(< (-> arg1 z) (-> arg0 max z))
|
||||
)
|
||||
)
|
||||
|
||||
(defun box-vector-inside? ((arg0 bounding-box) (arg1 vector))
|
||||
"Is the point in the box? On the edge counts."
|
||||
(and (>= (-> arg1 x) (-> arg0 min x))
|
||||
(>= (-> arg1 y) (-> arg0 min y))
|
||||
(>= (-> arg1 z) (-> arg0 min z))
|
||||
(>= (-> arg0 max x) (-> arg1 x))
|
||||
(>= (-> arg0 max y) (-> arg1 y))
|
||||
(>= (-> arg0 max z) (-> arg1 z))
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod set-from-point-offset! ((this bounding-box) (arg0 vector) (arg1 vector))
|
||||
"Set to the smallest box containing arg0, (arg0 + arg1)"
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf3 (&-> arg1 quad))
|
||||
(.lvf vf4 (&-> arg0 quad))
|
||||
(.add.vf vf5 vf4 vf3)
|
||||
(.min.vf vf1 vf4 vf5)
|
||||
(.max.vf vf2 vf4 vf5)
|
||||
(.mov.vf vf1 vf0 :mask #b1000)
|
||||
(.mov.vf vf2 vf0 :mask #b1000)
|
||||
(.svf (&-> this min quad) vf1)
|
||||
(.svf (&-> this max quad) vf2)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod add-point! ((this bounding-box) (arg0 vector))
|
||||
"Expand the box as needed to contain the given point."
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(.lvf vf1 (&-> this min quad))
|
||||
(.lvf vf2 (&-> this max quad))
|
||||
(.lvf vf3 (&-> arg0 quad))
|
||||
(.min.vf vf1 vf1 vf3)
|
||||
(.max.vf vf2 vf2 vf3)
|
||||
(.svf (&-> this min quad) vf1)
|
||||
(.svf (&-> this max quad) vf2)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod add-box! ((this bounding-box) (arg0 bounding-box))
|
||||
"Expand the box as needed to contain the given box."
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
)
|
||||
(.lvf vf1 (&-> this min quad))
|
||||
(.lvf vf2 (&-> this max quad))
|
||||
(.lvf vf3 (&-> arg0 min quad))
|
||||
(.lvf vf4 (&-> arg0 max quad))
|
||||
(.min.vf vf1 vf1 vf3)
|
||||
(.max.vf vf2 vf2 vf4)
|
||||
(.svf (&-> this min quad) vf1)
|
||||
(.svf (&-> this max quad) vf2)
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod set-to-point! ((this bounding-box) (arg0 vector))
|
||||
"Set the box to be a single point."
|
||||
(set! (-> this min quad) (-> arg0 quad))
|
||||
(set! (-> this max quad) (-> arg0 quad))
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defmethod set-from-point-offset-pad! ((this bounding-box) (arg0 vector) (arg1 vector) (arg2 float))
|
||||
"Set the box to contain arg0, arg0 + offset, with some padding."
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf4 (&-> arg1 quad))
|
||||
(.lvf vf5 (&-> arg0 quad))
|
||||
(.mov vf1 arg2)
|
||||
(.add.vf vf6 vf5 vf4)
|
||||
(.min.vf vf2 vf5 vf6)
|
||||
(.max.vf vf3 vf5 vf6)
|
||||
(.add.x.vf vf3 vf3 vf1 :mask #b111)
|
||||
(.sub.x.vf vf2 vf2 vf1 :mask #b111)
|
||||
(.mov.vf vf2 vf0 :mask #b1000)
|
||||
(.mov.vf vf3 vf0 :mask #b1000)
|
||||
(.svf (&-> this min quad) vf2)
|
||||
(.svf (&-> this max quad) vf3)
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod set-from-sphere! ((this bounding-box) (arg0 sphere))
|
||||
"Set the box to contain a single sphere."
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf1 (&-> arg0 quad))
|
||||
(.sub.w.vf vf2 vf1 vf1 :mask #b111)
|
||||
(.add.w.vf vf3 vf1 vf1 :mask #b111)
|
||||
(.mov.vf vf2 vf0 :mask #b1000)
|
||||
(.mov.vf vf3 vf0 :mask #b1000)
|
||||
(.svf (&-> this min quad) vf2)
|
||||
(.svf (&-> this max quad) vf3)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; multi-sphere methods
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; these are used in the collision system to build bounding boxes around collision geometries, so they are quite optimized.
|
||||
|
||||
(defmethod add-spheres! ((this bounding-box) (spheres (inline-array sphere)) (count int))
|
||||
"Add count spheres."
|
||||
;; the PS2 implementation is very optimized
|
||||
;; It is unrolled and 'software pipelined' to do 4 at a time.
|
||||
;; This is slightly less optimized.
|
||||
(rlet ((current-min :class vf)
|
||||
(current-max :class vf)
|
||||
(sph-min :class vf)
|
||||
(sph-max :class vf)
|
||||
(sph :class vf))
|
||||
|
||||
(when (nonzero? count)
|
||||
;; load these outside the loop
|
||||
(.lvf current-min (-> this min))
|
||||
(.lvf current-max (-> this max))
|
||||
|
||||
(dotimes (i count)
|
||||
(.lvf sph (-> spheres i))
|
||||
(.sub.w.vf sph-min sph sph :mask #b111)
|
||||
(.add.w.vf sph-max sph sph :mask #b111)
|
||||
(.min.vf current-min current-min sph-min :mask #b111)
|
||||
(.max.vf current-max current-max sph-max :mask #b111)
|
||||
)
|
||||
|
||||
(.svf (-> this min) current-min)
|
||||
(.svf (-> this max) current-max)
|
||||
)
|
||||
)
|
||||
0
|
||||
)
|
||||
|
||||
(defmethod set-from-spheres! ((this bounding-box) (spheres (inline-array sphere)) (count int))
|
||||
"Reset box to hold the given spheres. Note: this implementation could be optimized."
|
||||
;; This is also unrolled, but does 7 at a time.
|
||||
(rlet ((vf0 :class vf)
|
||||
(current-min :class vf)
|
||||
(current-max :class vf)
|
||||
(sph-min :class vf)
|
||||
(sph-max :class vf)
|
||||
(sph :class vf))
|
||||
;; init constant
|
||||
(init-vf0-vector)
|
||||
;; init min/max. in the case we don't have any spheres, we should return (0,0,0,1) for min/max.
|
||||
(set! current-min vf0)
|
||||
(set! current-max vf0)
|
||||
|
||||
(dotimes (i count)
|
||||
(.lvf sph (-> spheres i))
|
||||
(.sub.w.vf sph-min sph sph :mask #b111)
|
||||
(.add.w.vf sph-max sph sph :mask #b111)
|
||||
(cond
|
||||
((zero? i)
|
||||
(set! current-min sph-min)
|
||||
(set! current-max sph-max)
|
||||
)
|
||||
(else
|
||||
(.min.vf current-min current-min sph-min :mask #b111)
|
||||
(.max.vf current-max current-max sph-max :mask #b111)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(.svf (-> this min) current-min)
|
||||
(.svf (-> this max) current-max)
|
||||
)
|
||||
0
|
||||
)
|
||||
|
||||
(defmethod get-bounding-sphere ((this bounding-box) (arg0 vector))
|
||||
"Get a bounding sphere for a bounding box."
|
||||
(let* ((a1-2 (vector-! (new 'stack-no-clear 'vector) (-> this max) (-> this min)))
|
||||
(a0-3 (vector-float*! (new 'stack-no-clear 'vector) a1-2 0.5))
|
||||
)
|
||||
(vector+! arg0 (-> this min) a0-3)
|
||||
(set! (-> arg0 w) (vector-length a0-3))
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
(deftype liang-barsky-line-clip-params (structure)
|
||||
((te float)
|
||||
(tl float)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defun liang-barsky-line-clipt ((arg0 liang-barsky-line-clip-params) (arg1 float) (arg2 float))
|
||||
"Clip test in 1 dimension. Is arg1 in arg2?"
|
||||
(cond
|
||||
((< 0.0 arg1)
|
||||
(let ((f0-2 (/ arg2 arg1)))
|
||||
(if (< (-> arg0 tl) f0-2)
|
||||
(return #f)
|
||||
)
|
||||
(if (< (-> arg0 te) f0-2)
|
||||
(set! (-> arg0 te) f0-2)
|
||||
)
|
||||
)
|
||||
)
|
||||
((< arg1 0.0)
|
||||
(let ((f0-5 (/ arg2 arg1)))
|
||||
(if (< f0-5 (-> arg0 te))
|
||||
(return #f)
|
||||
)
|
||||
(if (< f0-5 (-> arg0 tl))
|
||||
(set! (-> arg0 tl) f0-5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(if (< 0.0 arg2)
|
||||
(return #f)
|
||||
)
|
||||
)
|
||||
)
|
||||
#t
|
||||
)
|
||||
|
||||
;; WARN: disable def twice: 23. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
|
||||
(defmethod intersects-line-segment? ((this bounding-box) (arg0 vector) (arg1 vector))
|
||||
"Check intersection in xz plane, using liang-barsky. Not sure if this actually
|
||||
a useful check or not..."
|
||||
(let ((f28-0 (- (-> arg1 x) (-> arg0 x)))
|
||||
(f30-0 (- (-> arg1 z) (-> arg0 z)))
|
||||
)
|
||||
(cond
|
||||
((and (= f28-0 0.0) (= f30-0 0.0))
|
||||
(let ((f1-2 (-> arg0 x))
|
||||
(f0-4 (-> arg0 z))
|
||||
)
|
||||
(and (>= f1-2 (-> this min x)) (>= (-> this max x) f1-2) (>= f0-4 (-> this min z)) (>= (-> this max z) f0-4))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let ((s4-0 (new 'stack-no-clear 'liang-barsky-line-clip-params)))
|
||||
(set! (-> s4-0 te) 0.0)
|
||||
(set! (-> s4-0 tl) 1.0)
|
||||
(and (liang-barsky-line-clipt s4-0 f28-0 (- (-> this min x) (-> arg0 x)))
|
||||
(liang-barsky-line-clipt s4-0 (- f28-0) (- (-> arg0 x) (-> this max x)))
|
||||
(liang-barsky-line-clipt s4-0 f30-0 (- (-> this min z) (-> arg0 z)))
|
||||
(liang-barsky-line-clipt s4-0 (- f30-0) (- (-> arg0 z) (-> this max z)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -5,5 +5,65 @@
|
||||
;; name in dgo: geometry-h
|
||||
;; dgos: GAME
|
||||
|
||||
(define-extern quaternion-from-two-vectors-max-angle! (function quaternion vector vector float quaternion))
|
||||
(define-extern vector-orient-by-quat! (function vector vector quaternion vector))
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype curve (structure)
|
||||
((cverts (inline-array vector))
|
||||
(num-cverts int32)
|
||||
(knots (pointer float))
|
||||
(num-knots int32)
|
||||
(length float)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype line-intersection-val (structure)
|
||||
((tt0 float)
|
||||
(tt1 float)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype border-plane (basic)
|
||||
((name symbol)
|
||||
(action basic)
|
||||
(slot int8)
|
||||
(trans vector :inline)
|
||||
(normal vector :inline)
|
||||
)
|
||||
(:methods
|
||||
(debug-draw (_type_) int)
|
||||
(point-past-plane? (_type_ vector) symbol)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype lissajous (structure)
|
||||
((x-mag float)
|
||||
(y-mag float)
|
||||
(theta float)
|
||||
(wx float)
|
||||
(wy float)
|
||||
(period-shift float)
|
||||
(theta-rate float)
|
||||
)
|
||||
:pack-me
|
||||
(:methods
|
||||
(lissajous-method-9 (_type_ vector) vector)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype lissajous-interp (structure)
|
||||
((current lissajous :inline)
|
||||
(dest lissajous :inline)
|
||||
(rate lissajous :inline)
|
||||
)
|
||||
(:methods
|
||||
(lissajous-interp-method-9 (_type_ vector) vector)
|
||||
(lissajous-interp-method-10 (_type_) float)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -7,3 +7,18 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(define EulSafe
|
||||
"Maybe euler angle storage orders?
|
||||
What is this naming convention?"
|
||||
(new 'static 'boxed-array :type int32 0 1 2 0)
|
||||
)
|
||||
|
||||
(define EulNext (new 'static 'boxed-array :type int32 1 2 0 1))
|
||||
|
||||
(deftype euler-angles (vector)
|
||||
"Just uses the same xyzw and data array as vector.
|
||||
The `w` stores an integer that seems to have
|
||||
bitfields for... something? Like maybe the order?
|
||||
Euler angles are mostly unused, and the code is a bit of disaster."
|
||||
()
|
||||
)
|
||||
|
||||
@@ -7,3 +7,209 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(defun set-eul! ((arg0 euler-angles) (arg1 float) (arg2 float) (arg3 float) (arg4 int))
|
||||
"Set euler angles and the flag bits."
|
||||
(set! (-> arg0 x) arg1)
|
||||
(set! (-> arg0 y) arg2)
|
||||
(set! (-> arg0 z) arg3)
|
||||
(set! (-> arg0 w) (the float arg4))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun eul->matrix ((arg0 matrix) (arg1 euler-angles))
|
||||
"Convert from euler angles to 4x4 matrix."
|
||||
(matrix-identity! arg0)
|
||||
(let ((s5-0 (new 'stack-no-clear 'vector)))
|
||||
(set! (-> s5-0 quad) (-> arg1 quad))
|
||||
(when (= (logand (the int (-> s5-0 w)) 1) 1)
|
||||
(let ((f0-2 (-> s5-0 x)))
|
||||
(set! (-> s5-0 x) (-> s5-0 z))
|
||||
(set! (-> s5-0 z) f0-2)
|
||||
)
|
||||
)
|
||||
(when (= (logand (/ (the int (-> s5-0 w)) 4) 1) 1)
|
||||
(set! (-> s5-0 x) (- (-> s5-0 x)))
|
||||
(set! (-> s5-0 y) (- (-> s5-0 y)))
|
||||
(set! (-> s5-0 z) (- (-> s5-0 z)))
|
||||
)
|
||||
(let* ((f26-0 (cos (-> s5-0 x)))
|
||||
(f30-0 (cos (-> s5-0 y)))
|
||||
(f22-0 (cos (-> s5-0 z)))
|
||||
(f24-0 (sin (-> s5-0 x)))
|
||||
(f28-0 (sin (-> s5-0 y)))
|
||||
(f4-0 (sin (-> s5-0 z)))
|
||||
(f0-17 (* f26-0 f22-0))
|
||||
(f1-1 (* f26-0 f4-0))
|
||||
(f2-0 (* f24-0 f22-0))
|
||||
(f3-0 (* f24-0 f4-0))
|
||||
)
|
||||
0
|
||||
0
|
||||
0
|
||||
(let* ((v1-12 (logand (/ (the int (-> s5-0 w)) 4) 1))
|
||||
(a1-2 (-> EulSafe (logand (/ (the int (-> s5-0 w)) 8) 3)))
|
||||
(a0-21 (-> EulNext (+ a1-2 v1-12)))
|
||||
(v1-17 (-> EulNext (+ (- 1 v1-12) a1-2)))
|
||||
)
|
||||
(cond
|
||||
((= (logand (/ (the int (-> s5-0 w)) 2) 1) 1)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) f30-0)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0)))) (* f28-0 f24-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0)))) (* f28-0 f26-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f28-0 f4-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(- f0-17 (* f30-0 f3-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(- (- f2-0) (* f30-0 f1-1))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- (* f28-0 f22-0)))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(+ f1-1 (* f30-0 f2-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(+ (- f3-0) (* f30-0 f0-17))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f22-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(+ (- f1-1) (* f28-0 f2-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(+ f3-0 (* f28-0 f0-17))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f4-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(+ f0-17 (* f28-0 f3-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(+ (- f2-0) (* f28-0 f1-1))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- f28-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0)))) (* f30-0 f24-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0)))) (* f30-0 f26-0))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix->eul ((arg0 euler-angles) (arg1 matrix) (arg2 int))
|
||||
"Convert matrix to euler angles with given order flag.
|
||||
Not clear how this works if the matrix has more than just a rotation."
|
||||
0
|
||||
0
|
||||
0
|
||||
(let* ((v1-4 (logand (/ arg2 4) 1))
|
||||
(s3-0 (-> EulSafe (logand (/ arg2 8) 3)))
|
||||
(s2-0 (-> EulNext (+ s3-0 v1-4)))
|
||||
(s1-0 (-> EulNext (+ (- 1 v1-4) s3-0)))
|
||||
)
|
||||
(cond
|
||||
((= (logand (/ arg2 2) 1) 1)
|
||||
(let* ((f0-0 (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1)))))
|
||||
(f0-2 (* f0-0 f0-0))
|
||||
(f1-0 (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1)))))
|
||||
(f30-0 (sqrtf (+ f0-2 (* f1-0 f1-0))))
|
||||
)
|
||||
(cond
|
||||
((< 0.00000000001 f30-0)
|
||||
(set! (-> arg0 x) (atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))))
|
||||
(set! (-> arg0 z) (atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
(- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1)))))
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(set! (-> arg0 x) (atan
|
||||
(- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1)))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))))
|
||||
(set! (-> arg0 z) 0.0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let* ((f0-21 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))))
|
||||
(f0-23 (* f0-21 f0-21))
|
||||
(f1-3 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1)))))
|
||||
(f30-1 (sqrtf (+ f0-23 (* f1-3 f1-3))))
|
||||
)
|
||||
(cond
|
||||
((< 0.00000000001 f30-1)
|
||||
(set! (-> arg0 x)
|
||||
(atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s1-0 16)) (the-as int arg1))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s1-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y)
|
||||
(atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1)
|
||||
)
|
||||
(set! (-> arg0 z) (atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(set! (-> arg0 x)
|
||||
(atan
|
||||
(- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1)))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y)
|
||||
(atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1)
|
||||
)
|
||||
(set! (-> arg0 z) 0.0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (= (logand (/ arg2 4) 1) 1)
|
||||
(set! (-> arg0 x) (- (-> arg0 x)))
|
||||
(set! (-> arg0 y) (- (-> arg0 y)))
|
||||
(set! (-> arg0 z) (- (-> arg0 z)))
|
||||
)
|
||||
(when (= (logand arg2 1) 1)
|
||||
(let ((f0-49 (-> arg0 x)))
|
||||
(set! (-> arg0 x) (-> arg0 z))
|
||||
(set! (-> arg0 z) f0-49)
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 w) (the float arg2))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun eul->quat ((arg0 quaternion) (arg1 euler-angles))
|
||||
"Convert euler angles to quaternion, not very efficient."
|
||||
(let ((s5-0 (new 'stack-no-clear 'matrix)))
|
||||
(eul->matrix s5-0 arg1)
|
||||
(matrix->quaternion arg0 s5-0)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun quat->eul ((arg0 euler-angles) (arg1 quaternion) (arg2 int))
|
||||
"Convert quaternion to euler angles with given order, not very efficient."
|
||||
(let ((s5-0 (new 'stack-no-clear 'matrix)))
|
||||
(quaternion->matrix s5-0 arg1)
|
||||
(matrix->eul arg0 s5-0 arg2)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
@@ -5,5 +5,907 @@
|
||||
;; name in dgo: math
|
||||
;; dgos: GAME
|
||||
|
||||
(defmacro init-vf0-vector ()
|
||||
"Initializes the VF0 vector which is a constant vector in the VU set to <0,0,0,1>"
|
||||
`(.lvf vf0 (new 'static 'vector :x 0.0 :y 0.0 :z 0.0 :w 1.0))
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(defun truncate ((arg0 float))
|
||||
"Round (toward zero) to an integer.
|
||||
@param arg0 float to truncate"
|
||||
(the float (the int arg0))
|
||||
)
|
||||
|
||||
(defun round ((arg0 float))
|
||||
"Round to the nearest integer"
|
||||
(the float (the int (+ 0.5 arg0)))
|
||||
)
|
||||
|
||||
(defun floor ((arg0 float))
|
||||
"Round (down) to an integer"
|
||||
(let ((f0-3 (the float (the int arg0))))
|
||||
(if (or (>= arg0 0.0) (= arg0 f0-3))
|
||||
f0-3
|
||||
(+ -1.0 f0-3)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun ceil ((arg0 float))
|
||||
"Round (up) to an integer"
|
||||
(let ((f0-3 (the float (the int arg0))))
|
||||
(if (or (>= 0.0 arg0) (= arg0 f0-3))
|
||||
f0-3
|
||||
(+ 1.0 f0-3)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun integral? ((arg0 float))
|
||||
"Is this number an integer?"
|
||||
(= (the float (the int arg0)) arg0)
|
||||
)
|
||||
|
||||
(defun fractional-part ((arg0 float))
|
||||
"Get the fractional part of a float."
|
||||
(- arg0 (the float (the int arg0)))
|
||||
)
|
||||
|
||||
(defun odd? ((arg0 int))
|
||||
"Is the number odd?"
|
||||
(= (logand arg0 1) 1)
|
||||
)
|
||||
|
||||
(defun even? ((arg0 int))
|
||||
"Is the number even?"
|
||||
(not (odd? arg0))
|
||||
)
|
||||
|
||||
(defun sawtooth-wave ((arg0 float))
|
||||
"Sample a sawtooth with period 1. In range (0, 1)"
|
||||
(let ((f0-2 (- arg0 (the float (the int arg0)))))
|
||||
(if (< f0-2 0.0)
|
||||
(set! f0-2 (+ 1.0 f0-2))
|
||||
)
|
||||
f0-2
|
||||
)
|
||||
)
|
||||
|
||||
(defun triangle-wave ((arg0 float))
|
||||
"Sample a triangle wave. Period is 4, in range (-1, 1) (so slope is 1 or -1)."
|
||||
(let* ((f0-1 (* 0.25 (+ -1.0 arg0)))
|
||||
(f0-3 (- f0-1 (the float (the int f0-1))))
|
||||
)
|
||||
(if (< f0-3 0.0)
|
||||
(set! f0-3 (+ 1.0 f0-3))
|
||||
)
|
||||
(+ -1.0 (fabs (+ -2.0 (* 4.0 f0-3))))
|
||||
)
|
||||
)
|
||||
|
||||
(defun log-x-plus-1-order9 ((arg0 float))
|
||||
"Fast approximation of ln(x + 1). Probably only accurate for x in [0, 1]."
|
||||
(* arg0
|
||||
(+ 1.0
|
||||
(* arg0
|
||||
(+ -0.5
|
||||
(* arg0
|
||||
(+ 0.33333334
|
||||
(* arg0
|
||||
(+ -0.25
|
||||
(* arg0 (+ 0.2 (* arg0 (+ -0.16666666 (* arg0 (+ 0.14285715 (* arg0 (+ -0.125 (* 0.11111111 arg0)))))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun logf ((arg0 float))
|
||||
"Natural log."
|
||||
(let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126)))
|
||||
(a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0)))))
|
||||
)
|
||||
;; og:preserve-this
|
||||
(when (< (the-as float a0-2) 0.70710677)
|
||||
(set! a0-2 (+ (the-as float a0-2) (the-as float a0-2)))
|
||||
(set! v1-1 (the-as int (+ (the-as uint v1-1) -1)))
|
||||
)
|
||||
(let ((f0-5 (+ -1.0 (the-as float a0-2))))
|
||||
(+ (* f0-5
|
||||
(+ 1.0
|
||||
(* f0-5
|
||||
(+ -0.5
|
||||
(* f0-5
|
||||
(+ 0.33333334
|
||||
(* f0-5
|
||||
(+ -0.25
|
||||
(* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (* 0.11111111 f0-5)))))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(* 0.6931472 (the float v1-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun log2f ((arg0 float))
|
||||
"Log base 2."
|
||||
(let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126)))
|
||||
(a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0)))))
|
||||
)
|
||||
;; og:preserve-this
|
||||
(when (< (the-as float a0-2) 0.70710677)
|
||||
(set! a0-2 (+ (the-as float a0-2) (the-as float a0-2)))
|
||||
(set! v1-1 (the-as int (+ (the-as uint v1-1) -1)))
|
||||
)
|
||||
(let* ((f0-5 (+ -1.0 (the-as float a0-2)))
|
||||
(f0-7
|
||||
(* f0-5
|
||||
(+ 1.0
|
||||
(* f0-5
|
||||
(+ -0.5
|
||||
(* f0-5
|
||||
(+ 0.33333334
|
||||
(* f0-5
|
||||
(+ -0.25
|
||||
(* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (* 0.11111111 f0-5)))))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(+ (* 1.442695 f0-7) (the float v1-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(deftype float-type (uint32)
|
||||
()
|
||||
)
|
||||
|
||||
(define exp-slead (new 'static 'array float 32
|
||||
1.0
|
||||
1.0218964
|
||||
1.0442734
|
||||
1.0671387
|
||||
1.0905075
|
||||
1.1143799
|
||||
1.1387863
|
||||
1.1637192
|
||||
1.1892014
|
||||
1.2152405
|
||||
1.2418518
|
||||
1.2690506
|
||||
1.2968369
|
||||
1.3252335
|
||||
1.354248
|
||||
1.3839035
|
||||
1.4142075
|
||||
1.4451752
|
||||
1.4768219
|
||||
1.5091629
|
||||
1.5422058
|
||||
1.5759735
|
||||
1.6104889
|
||||
1.645752
|
||||
1.6817856
|
||||
1.7186127
|
||||
1.7562485
|
||||
1.7947083
|
||||
1.8340073
|
||||
1.8741608
|
||||
1.9151993
|
||||
1.9571381
|
||||
)
|
||||
)
|
||||
|
||||
(define exp-strail (new 'static 'array float 32
|
||||
0.0
|
||||
0.0000007863494
|
||||
0.00000040596257
|
||||
0.0000017288019
|
||||
0.00000022534104
|
||||
0.0000068597833
|
||||
0.0000023188388
|
||||
0.0000056815315
|
||||
0.0000057600223
|
||||
0.0000068814647
|
||||
0.000006005433
|
||||
0.0000003590472
|
||||
0.0000027016238
|
||||
0.000003183687
|
||||
0.000007500062
|
||||
0.000006378546
|
||||
0.000006103877
|
||||
0.0000056360786
|
||||
0.0000042465254
|
||||
0.0000015247614
|
||||
0.000005014861
|
||||
0.000007334366
|
||||
0.0000014403477
|
||||
0.000003525029
|
||||
0.000007247011
|
||||
0.000006627224
|
||||
0.0000036862523
|
||||
0.00000082304996
|
||||
0.0000008232258
|
||||
0.0000068675085
|
||||
0.000007281612
|
||||
0.000006062652
|
||||
)
|
||||
)
|
||||
|
||||
(defun exp ((arg float))
|
||||
"Compute e^x."
|
||||
(local-vars
|
||||
(f0 float)
|
||||
(f1 float)
|
||||
(f2 float)
|
||||
(f3 float)
|
||||
(f4 float)
|
||||
(f5 float)
|
||||
(f6 float)
|
||||
(f7 float)
|
||||
(f8 float)
|
||||
(f10 float)
|
||||
(f11 float)
|
||||
(f12 float)
|
||||
(f13 float)
|
||||
(f14 float)
|
||||
(f15 float)
|
||||
(f16 float)
|
||||
(f17 float)
|
||||
(f18 float)
|
||||
(a2 int)
|
||||
(v0 float)
|
||||
(v1 int)
|
||||
(a1 int)
|
||||
(a3 int)
|
||||
(t0 int)
|
||||
(a0-2 int)
|
||||
)
|
||||
|
||||
(set! f0 arg)
|
||||
(set! f0 (fabs f0))
|
||||
(set! f1 (the-as float #x435c6bba))
|
||||
;;(b! (>=.s f1 f0) L44 (nop!))
|
||||
(when-goto (>= f1 f0) L44)
|
||||
|
||||
(set! f0 0.0)
|
||||
(set! f1 arg)
|
||||
;;(b! (>=.s f0 f1) L42 (nop!))
|
||||
(when-goto (>= f0 f1) L42)
|
||||
|
||||
(set! v0 (the-as float #x7f7fffff))
|
||||
;;(b! #t L43 (nop!))
|
||||
(goto L43)
|
||||
|
||||
(label L42)
|
||||
(set! v0 (the-as float #x0))
|
||||
|
||||
(label L43)
|
||||
;;(b! #t L49 (nop!))
|
||||
(goto L49)
|
||||
|
||||
|
||||
(label L44)
|
||||
(set! f1 (the-as float #x33000000))
|
||||
;;(b! (>=.s f0 f1) L45 (nop!))
|
||||
(when-goto (>= f0 f1) L45)
|
||||
|
||||
(set! f0 (the-as float #x3f800000))
|
||||
(set! f1 arg)
|
||||
(set! f0 (+ f0 f1))
|
||||
(set! v0 f0)
|
||||
;;(b! #t L49 (nop!))
|
||||
(goto L49)
|
||||
|
||||
(label L45)
|
||||
(set! f16 (the-as float #x4238aa3b))
|
||||
(set! f12 (the-as float #x3cb17200))
|
||||
(set! f13 (the-as float #x333fbe8e))
|
||||
(set! f14 (the-as float #x3f000044))
|
||||
(set! f15 (the-as float #x3e2aaaec))
|
||||
(set! f0 arg)
|
||||
(set! f0 (* f0 f16))
|
||||
;;(set! f0 (f2i f0))
|
||||
;;(set! a2 (fpr->gpr f0))
|
||||
(set! a2 (the int f0))
|
||||
(set! v1 (logand a2 31))
|
||||
(set! a1 (- a2 v1))
|
||||
(set! a3 512)
|
||||
(set! t0 a2)
|
||||
;;(bl! (<0.si t0) L46 (no-delay!))
|
||||
;;(set! t0 (- t0))
|
||||
(set! t0 (abs t0))
|
||||
|
||||
;;(label L46)
|
||||
;;(b! (>=.si a3 t0) L47 (nop!))
|
||||
(when-goto (>= a3 t0) L47)
|
||||
;;(set! f17 a1)
|
||||
;;(set! f18 v1)
|
||||
;;(set! f17 (i2f f17))
|
||||
;;(set! f18 (i2f f18))
|
||||
(set! f17 (the float a1))
|
||||
(set! f18 (the float v1))
|
||||
(set! f17 (* f17 f12))
|
||||
(set! f18 (* f18 f12))
|
||||
(set! f0 arg)
|
||||
(set! f17 (- f0 f17))
|
||||
;;(b! #t L48 (set! f2 (-.s f17 f18)))
|
||||
(set! f2 (- f17 f18))
|
||||
(goto L48)
|
||||
|
||||
(label L47)
|
||||
;;(set! f17 (gpr->fpr a2))
|
||||
;;(set! f17 (i2f f17))
|
||||
(set! f17 (the float a2))
|
||||
(set! f17 (* f17 f12))
|
||||
(set! f0 arg)
|
||||
(set! f2 (- f0 f17))
|
||||
|
||||
(label L48)
|
||||
(set! a0-2 (- a2))
|
||||
;;(set! f17 (gpr->fpr a0))
|
||||
;;(set! f17 (i2f f17))
|
||||
(set! f17 (the float a0-2))
|
||||
(set! f3 (* f17 f13))
|
||||
(set! a0-2 (sar a1 5))
|
||||
(set! f4 (+ f2 f3))
|
||||
(set! f6 (* f4 f15))
|
||||
(set! f6 (+ f14 f6))
|
||||
(set! f6 (* f4 f6))
|
||||
(set! f6 (* f4 f6))
|
||||
(set! f5 (+ f3 f6))
|
||||
(set! f5 (+ f2 f5))
|
||||
;;(set! a1 exp-slead)
|
||||
;;(set! a2 (sll v1 2))
|
||||
;;(set! a1 (+ a1 a2))
|
||||
;;(set! f10 (l.f a1))
|
||||
(set! f10 (-> exp-slead v1))
|
||||
;;(set! a1 exp-strail)
|
||||
;;(set! v1 (sll v1 2))
|
||||
;;(set! v1 (+ a1 v1))
|
||||
;;(set! f11 (l.f v1))
|
||||
(set! f11 (-> exp-strail v1))
|
||||
(set! f7 (+ f10 f11))
|
||||
(set! f8 (* f7 f5))
|
||||
(set! f8 (+ f11 f8))
|
||||
(set! f8 (+ f8 f10))
|
||||
(set! v1 (the-as int f8))
|
||||
(set! a0-2 (logand a0-2 511))
|
||||
(set! a0-2 (shl a0-2 23))
|
||||
(set! v0 (the-as float (+ v1 a0-2)))
|
||||
(label L49)
|
||||
v0
|
||||
)
|
||||
|
||||
(defun pow ((arg0 float) (arg1 float))
|
||||
"Compute arg0^arg1"
|
||||
(exp (* arg1 (logf arg0)))
|
||||
)
|
||||
|
||||
(defun print-exp ((arg0 float))
|
||||
"Print in the format AeB where A is in the range (1, 10)"
|
||||
(let* ((f30-1 (floor (/ (logf (fabs arg0)) (logf 10.0))))
|
||||
(f0-4 (pow 10.0 f30-1))
|
||||
)
|
||||
(format #t "~fe~d" (/ arg0 f0-4) (the int f30-1))
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(deftype rgba (uint32)
|
||||
()
|
||||
)
|
||||
|
||||
(defmacro static-rgba (r g b a)
|
||||
"make a new static rgba"
|
||||
`(new 'static 'rgba :r ,r :g ,g :b ,b :a ,a)
|
||||
)
|
||||
|
||||
(defmacro static-rgba-uint (col)
|
||||
"make a new static rgba"
|
||||
`(the-as rgba ,col)
|
||||
)
|
||||
|
||||
(deftype xyzw (uint128)
|
||||
()
|
||||
)
|
||||
|
||||
(deftype xyzwh (uint128)
|
||||
()
|
||||
)
|
||||
|
||||
(defun print-time ((arg0 object) (arg1 time-frame))
|
||||
"Print a [[time-frame]] as h:mm:ss."
|
||||
0
|
||||
0
|
||||
0
|
||||
(let* ((f0-1 (* 0.0033333334 (the float arg1)))
|
||||
(a2-0 (the int (* 0.016666668 f0-1)))
|
||||
(f0-2 (- f0-1 (* 60.0 (the float a2-0))))
|
||||
(a3-0 (the int f0-2))
|
||||
(f0-3 (- f0-2 (the float a3-0)))
|
||||
(t0-0 (the int (* 100.0 f0-3)))
|
||||
)
|
||||
(format arg0 "~d:~2,'0,d:~2,'0,d" a2-0 a3-0 t0-0)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; WARN: Return type mismatch uint vs int.
|
||||
(defun log2 ((arg0 int))
|
||||
"Log base 2."
|
||||
(the-as int (+ (sar (the-as int (the float arg0)) 23) -127))
|
||||
)
|
||||
|
||||
(defun seek ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Move arg0 toward arg1 by at most arg2."
|
||||
(let ((f2-0 (- arg1 arg0)))
|
||||
(cond
|
||||
((>= arg2 (fabs f2-0))
|
||||
arg1
|
||||
)
|
||||
((>= f2-0 0.0)
|
||||
(+ arg0 arg2)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun seek-ease ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Move arg0 toward arg1, and slow down before reaching the end.
|
||||
When farther than arg3 away, move by at most arg2.
|
||||
When closer than arg3, linearly ramp down the movement amount from arg2 to 0 but no lower than arg4."
|
||||
(let ((f2-0 (- arg1 arg0)))
|
||||
(when (>= arg3 (fabs f2-0))
|
||||
(set! arg2 (* arg2 (- 1.0 (/ (- arg3 (fabs f2-0)) arg3))))
|
||||
(if (< arg2 arg4)
|
||||
(set! arg2 arg4)
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((>= arg2 (fabs f2-0))
|
||||
arg1
|
||||
)
|
||||
((>= f2-0 0.0)
|
||||
(+ arg0 arg2)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun seek-ease-in-out ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 float) (arg6 float))
|
||||
"Move arg0 toward arg2, and slow down at the start and end.
|
||||
When within arg4 of arg1 (at the beginning of movement), ramp up speed, with a minimum speed of arg6
|
||||
When within arg5 of arg2 (at the end of movement), ramp down speed, with a minimum speed of arg5
|
||||
Normally, move at most arg3"
|
||||
(let ((f2-0 (- arg2 arg0)))
|
||||
(let ((f4-1 (- arg0 arg1)))
|
||||
(when (>= arg4 (fabs f4-1))
|
||||
(set! arg3 (* arg3 (- 1.0 (/ (- arg4 (fabs f4-1)) arg4))))
|
||||
(if (< arg3 arg6)
|
||||
(set! arg3 arg6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (>= arg5 (fabs f2-0))
|
||||
(set! arg3 (* arg3 (- 1.0 (/ (- arg5 (fabs f2-0)) arg5))))
|
||||
(if (< arg3 arg6)
|
||||
(set! arg3 arg6)
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((>= arg3 (fabs f2-0))
|
||||
arg2
|
||||
)
|
||||
((>= f2-0 0.0)
|
||||
(+ arg0 arg3)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun lerp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Linearly interpolate between arg0 and arg1."
|
||||
(+ arg0 (* arg2 (- arg1 arg0)))
|
||||
)
|
||||
|
||||
(defun-debug lerp-scale-old ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Linearly remap arg2 in [arg3, arg4] to [arg0, arg1].
|
||||
This is the jak 1 implementation, which I claimed was a bad implementation..."
|
||||
(let ((f0-1 (fmax 0.0 (fmin 1.0 (/ (- arg2 arg3) (- arg4 arg3))))))
|
||||
(+ (* (- 1.0 f0-1) arg0) (* f0-1 arg1))
|
||||
)
|
||||
)
|
||||
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f2]
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f1, f3]
|
||||
(defun lerp-scale ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Linearly remap arg2 in [arg3, arg4] to [arg0, arg1].
|
||||
More efficient than the -old version."
|
||||
(local-vars (f0-2 float))
|
||||
(let* ((v1-0 1.0)
|
||||
(f1-0 0.0)
|
||||
(f0-0 v1-0)
|
||||
(f4-0 arg2)
|
||||
(f2-0 arg3)
|
||||
(f3-0 arg4)
|
||||
(f1-2 (fmin (fmax (/ (- f4-0 f2-0) (- f3-0 f2-0)) f1-0) f0-0))
|
||||
(f0-1 (- f0-0 f1-2))
|
||||
(f2-3 arg0)
|
||||
(f3-1 arg1)
|
||||
)
|
||||
;; og:preserve-this
|
||||
; (.mula.s f0-1 f2-3)
|
||||
; (.madd.s f0-2 f1-2 f3-1)
|
||||
(+ (* f0-1 f2-3) (* f1-2 f3-1))
|
||||
)
|
||||
f0-2
|
||||
)
|
||||
|
||||
(defun lerp-scale-clamp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Clamp the input, then linearly remap arg2 in [arg3, arg4] to [arg0, arg1]."
|
||||
(let ((a2-1 (fmax (fmin arg2 arg4) arg3)))
|
||||
(lerp-scale arg0 arg1 a2-1 arg3 arg4)
|
||||
)
|
||||
)
|
||||
|
||||
(defun lerp-clamp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Linearly interpolate between arg0 and arg1. arg2 is clamped to [0, 1]"
|
||||
(cond
|
||||
((>= 0.0 arg2)
|
||||
arg0
|
||||
)
|
||||
((>= arg2 1.0)
|
||||
arg1
|
||||
)
|
||||
(else
|
||||
(+ (* (- 1.0 arg2) arg0) (* arg2 arg1))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; WARN: Return type mismatch int vs rgba.
|
||||
(defun rgba-lerp ((arg0 rgba) (arg1 rgba) (arg2 rgba))
|
||||
(local-vars
|
||||
(v0-0 uint128)
|
||||
(v1-0 uint128)
|
||||
(v1-1 uint128)
|
||||
(a0-1 uint128)
|
||||
(a0-2 uint128)
|
||||
(a1-1 uint128)
|
||||
(a2-1 uint128)
|
||||
)
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.pextlb v1-0 0 arg0)
|
||||
(.pextlb a0-1 0 arg1)
|
||||
(.pextlh v1-1 0 v1-0)
|
||||
(.pextlh a0-2 0 a0-1)
|
||||
(.mov vf1 v1-1)
|
||||
(.mov vf2 a0-2)
|
||||
(.mov vf3 arg2)
|
||||
(.itof.vf vf1 vf1)
|
||||
(.itof.vf vf2 vf2)
|
||||
(.mul.w.vf acc vf1 vf0)
|
||||
(.add.mul.x.vf acc vf2 vf3 acc)
|
||||
(.sub.mul.x.vf vf1 vf1 vf3 acc)
|
||||
(.ftoi.vf vf3 vf1)
|
||||
(.mov a1-1 vf3)
|
||||
(.ppach a2-1 (the-as uint128 0) a1-1)
|
||||
(.ppacb v0-0 (the-as uint128 0) a2-1)
|
||||
(the-as rgba v0-0)
|
||||
)
|
||||
)
|
||||
|
||||
(defun seekl ((arg0 int) (arg1 int) (arg2 int))
|
||||
"Move arg0 toward arg1, by at most arg2."
|
||||
(let* ((v1-0 (- arg1 arg0))
|
||||
(a3-0 (abs v1-0))
|
||||
)
|
||||
(cond
|
||||
((>= arg2 a3-0)
|
||||
arg1
|
||||
)
|
||||
((>= v1-0 0)
|
||||
(+ arg0 arg2)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro seek! (place target rate)
|
||||
"Macro to use seek in-place. place is the base, and where the result is stored."
|
||||
`(set! ,place (seek ,place ,target ,rate))
|
||||
)
|
||||
|
||||
(defmacro seekl! (place target rate)
|
||||
"Macro to use seekl in-place. place is the base, and where the result is stored."
|
||||
`(set! ,place (seekl ,place ,target ,rate))
|
||||
)
|
||||
|
||||
(defmacro seek-ease! (place target rate min-threshold rate-min)
|
||||
"Macro to use seek-ease in-place. place is the base, and where the result is stored."
|
||||
`(set! ,place (seek-ease ,place ,target ,rate ,min-threshold ,rate-min))
|
||||
)
|
||||
|
||||
;; in the PS2 there is a R register for generating random numbers
|
||||
;; it is a "32-bit" register, but the upper bits are fixed so it always
|
||||
;; represents a float in (1, 2).
|
||||
;; we don't have this register on x86, so we add a special global: *_vu-reg-R_*
|
||||
(define *_vu-reg-R_* 0)
|
||||
|
||||
(defun rand-vu-init ((seed float))
|
||||
"Initialize the VU0 random generator."
|
||||
;; (.ctc2.i R arg0)
|
||||
;; (.cfc2.i v0 R)
|
||||
(set! *_vu-reg-R_*
|
||||
(logior #x3F800000 (logand (the-as int seed) #x007FFFFF))
|
||||
)
|
||||
(the-as float *_vu-reg-R_*)
|
||||
)
|
||||
|
||||
(rand-vu-init 1.418091)
|
||||
|
||||
(defun rand-vu ()
|
||||
"Get a random number in [0, 1) and advance the random generator."
|
||||
;; (.vrget.xyzw vf1) - get current random
|
||||
(let ((current-random *_vu-reg-R_*))
|
||||
;; here they update the random generate with some junk
|
||||
;; for now, we don't do this in OpenGOAL.
|
||||
;; (.vsqrty Q vf1)
|
||||
;; (.vaddq.x vf2 vf0 Q) ;; you're not allowed to do this!
|
||||
;; (.vrxorw vf2)
|
||||
|
||||
;; and advance
|
||||
;; (.vrnext.xyzw vf1)
|
||||
(let ((x (logand 1 (shr current-random 4)))
|
||||
(y (logand 1 (shr current-random 22)))
|
||||
)
|
||||
(set! current-random (shl current-random 1))
|
||||
(set! current-random (logxor current-random (logxor x y)))
|
||||
(logxor! current-random (pc-rand))
|
||||
(set! *_vu-reg-R_* (logior #x3f800000 (logand current-random #x7fffff)))
|
||||
)
|
||||
)
|
||||
|
||||
;; (.vsubw.xyzw vf1 vf1 vf0)
|
||||
;; (.qmfc2.i v0 vf1)
|
||||
(- (the-as float *_vu-reg-R_*) 1.0)
|
||||
)
|
||||
|
||||
(defun rand-vu-nostep ()
|
||||
"Get the number currently in the random generator.
|
||||
This will be equal to the last call of (rand-vu)
|
||||
This will not update the random generator"
|
||||
(- (the-as float *_vu-reg-R_*) 1.0)
|
||||
)
|
||||
|
||||
(defun rand-vu-float-range ((arg0 float) (arg1 float))
|
||||
"Get a random float in between arg0 and arg1."
|
||||
(+ arg0 (* (rand-vu) (- arg1 arg0)))
|
||||
)
|
||||
|
||||
(defun rand-vu-percent? ((arg0 float))
|
||||
"Get a boolean that's true with the given probability (in 0, 1)."
|
||||
(>= arg0 (rand-vu))
|
||||
)
|
||||
|
||||
(defun rand-vu-int-range ((arg0 int) (arg1 int))
|
||||
"Get an integer in the given range (inclusive)."
|
||||
(if (< arg0 arg1)
|
||||
(set! arg1 (+ arg1 1))
|
||||
(set! arg0 (+ arg0 1))
|
||||
)
|
||||
(let ((f0-4 (rand-vu-float-range (the float arg0) (the float arg1))))
|
||||
(if (< f0-4 0.0)
|
||||
(set! f0-4 (+ -1.0 f0-4))
|
||||
)
|
||||
(the int f0-4)
|
||||
)
|
||||
)
|
||||
|
||||
(defun rand-vu-int-count ((arg0 int))
|
||||
"Get an integer in the range [0, max)."
|
||||
(the int (* (rand-vu) (the float arg0)))
|
||||
)
|
||||
|
||||
;; WARN: new jak 2 until loop case, check carefully
|
||||
(defun rand-vu-int-count-excluding ((arg0 int) (arg1 int))
|
||||
"Get an integer in the range [0, arg0).
|
||||
If bit n is set in arg1, exclude this value from being returned."
|
||||
(let ((s4-0 0)
|
||||
(s5-0 0)
|
||||
)
|
||||
(let ((v1-0 1))
|
||||
(while (nonzero? arg0)
|
||||
(+! arg0 -1)
|
||||
(if (not (logtest? arg1 v1-0))
|
||||
(+! s4-0 1)
|
||||
)
|
||||
(set! v1-0 (* v1-0 2))
|
||||
)
|
||||
)
|
||||
(when (> s4-0 0)
|
||||
(let ((v1-4 (the int (* (rand-vu) (the float s4-0))))
|
||||
(a0-1 1)
|
||||
)
|
||||
(until #f
|
||||
(while (logtest? arg1 a0-1)
|
||||
(nop!)
|
||||
(nop!)
|
||||
(+! s5-0 1)
|
||||
(set! a0-1 (* a0-1 2))
|
||||
)
|
||||
(if (zero? v1-4)
|
||||
(goto cfg-14)
|
||||
)
|
||||
(+! v1-4 -1)
|
||||
(+! s5-0 1)
|
||||
(set! a0-1 (* a0-1 2))
|
||||
)
|
||||
)
|
||||
#f
|
||||
)
|
||||
(label cfg-14)
|
||||
s5-0
|
||||
)
|
||||
)
|
||||
|
||||
;; WARN: new jak 2 until loop case, check carefully
|
||||
(defun rand-vu-int-range-exclude ((arg0 int) (arg1 int) (arg2 int))
|
||||
"Get an integer in the range [0, arg0), excluding arg2.
|
||||
Note that this doesn't use bits like rand-vu-int-count-excluding."
|
||||
(until #f
|
||||
(let ((v1-0 (rand-vu-int-range arg0 arg1)))
|
||||
(if (!= v1-0 arg2)
|
||||
(return v1-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the-as int #f)
|
||||
)
|
||||
|
||||
(deftype random-generator (basic)
|
||||
((seed uint32)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(define *random-generator* (new 'global 'random-generator))
|
||||
|
||||
(set! (-> *random-generator* seed) (the-as uint #x666edd1e))
|
||||
|
||||
(defmacro sext32-64 (x)
|
||||
"Sign extend a 32-bit value to 64-bits"
|
||||
`(sar (shl ,x 32) 32)
|
||||
)
|
||||
|
||||
(defun rand-uint31-gen ((gen random-generator))
|
||||
"Generate a supposedly random integer.
|
||||
Note, this might not quite be right.
|
||||
But the highest bit is always zero, like it says
|
||||
and it looks kinda random to me."
|
||||
(let* ((sd (-> gen seed))
|
||||
;; addiu v1, r0, 16807
|
||||
;; mult3 v0, v1, a1
|
||||
(prod (imul64 16807 sd))
|
||||
;; mfhi v1
|
||||
(hi (shr prod 32)) ;; sign extend this?
|
||||
(lo (sar (shl prod 32) 32))
|
||||
;; daddu v1, v1, v1
|
||||
(v1 (+ hi hi))
|
||||
;; srl a1, v0, 31
|
||||
(a1 (logand #xffffffff (shr lo 31)))
|
||||
;; or v1, v1, a1
|
||||
;; daddu v0, v0 v1
|
||||
(result (+ lo (logior v1 a1)))
|
||||
)
|
||||
(set! result (shr (logand #xffffffff (shl result 1)) 1))
|
||||
(set! (-> gen seed) result)
|
||||
(the uint result)
|
||||
)
|
||||
)
|
||||
|
||||
(defun cube-root ((arg0 float))
|
||||
"Cube root with cool trick that I don't understand."
|
||||
(cond
|
||||
((!= arg0 0.0)
|
||||
(let* ((v1-0 arg0)
|
||||
(a1-2 (+ (logand (shr (the-as int v1-0) 23) 255) -127))
|
||||
(f0-1 (the-as float
|
||||
(logior (logand (the-as uint #x807fffff) (the-as uint v1-0)) (shl (+ (/ (the-as int a1-2) 3) 127) 23))
|
||||
)
|
||||
)
|
||||
)
|
||||
;; somehow f0-1 is a reasonable approximation of cube-root.
|
||||
;; then we do 6 iterations of newton's method to get a more accurate answer.
|
||||
(dotimes (v1-3 6)
|
||||
(set! f0-1 (- f0-1
|
||||
(/ (- (* (* f0-1 f0-1) f0-1) arg0)
|
||||
(* 3.0 f0-1 f0-1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
f0-1
|
||||
)
|
||||
)
|
||||
(else
|
||||
0.0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun int-noise ((arg0 int))
|
||||
"Generate random-ish floats in range -1, 1."
|
||||
(let ((v1-1 (logxor (shl arg0 13) arg0)))
|
||||
(- 1.0 (* 0.0000000009313226
|
||||
(the float (logand #x7fffffff (+ #x5208dd0d (* v1-1 (+ #xc0ae5 (* (* #x3d73 v1-1) v1-1))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun smooth-step ((arg0 float))
|
||||
"Interpolate between 0, 1 with a cubic polynomial.
|
||||
These are picked so f(0) = 0, f(1) = 1, f'(0) = f'(1) = 0."
|
||||
(cond
|
||||
((>= 0.0 arg0)
|
||||
0.0
|
||||
)
|
||||
((>= arg0 1.0)
|
||||
1.0
|
||||
)
|
||||
(else
|
||||
(* arg0 arg0 (+ 3.0 (* -2.0 arg0)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun smooth-interp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Remap arg2 from (arg3, arg4) to (arg0, arg1), using cubic interpolation.
|
||||
Satisfies:
|
||||
- f(arg3) = arg0
|
||||
- f(arg4) = arg1
|
||||
- f'(arg3) = f'(arg4) = 0"
|
||||
(+ arg0 (* (- arg1 arg0) (smooth-step (/ (- arg2 arg3) (- arg4 arg3)))))
|
||||
)
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; name: matrix-compose.gc
|
||||
;; name in dgo: matrix-compose
|
||||
;; dgos: GAME
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(defun matrix-fur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg3 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg2 quad))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg2 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg2 arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-fr-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(set! (-> arg0 rvec quad) (-> arg2 quad))
|
||||
(vector-cross! (-> arg0 uvec) arg1 arg2)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-ur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg2 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 fvec) arg1 arg2)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 rvec) 1.0)
|
||||
(vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-f-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 uvec) arg1 arg2)
|
||||
(vector-normalize! (-> arg0 uvec) 1.0)
|
||||
(vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-u-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg1 arg2)
|
||||
(vector-normalize! (-> arg0 rvec) 1.0)
|
||||
(vector-cross! (-> arg0 fvec) (-> arg0 rvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-u-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 fvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 fvec) 1.0)
|
||||
(vector-cross! (-> arg0 rvec) arg1 (-> arg0 fvec))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-r-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 uvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 uvec) 1.0)
|
||||
(vector-cross! (-> arg0 fvec) arg1 (-> arg0 uvec))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-r-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 fvec) arg1 arg2)
|
||||
(vector-normalize! (-> arg0 fvec) 1.0)
|
||||
(vector-cross! (-> arg0 uvec) (-> arg0 fvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(matrix-f-u-compose arg0 arg1 a2-1 arg3)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(matrix-u-f-compose arg0 arg1 a2-1 arg3)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg1 quad))
|
||||
(let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(matrix-r-f-compose arg0 arg1 a2-1 arg3)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
@@ -5,5 +5,103 @@
|
||||
;; name in dgo: matrix-h
|
||||
;; dgos: GAME
|
||||
|
||||
(defmacro new-stack-matrix0 ()
|
||||
"Get a new matrix on the stack that's set to zero."
|
||||
`(let ((mat (new 'stack-no-clear 'matrix)))
|
||||
(set! (-> mat quad 0) (the-as uint128 0))
|
||||
(set! (-> mat quad 1) (the-as uint128 0))
|
||||
(set! (-> mat quad 2) (the-as uint128 0))
|
||||
(set! (-> mat quad 3) (the-as uint128 0))
|
||||
mat
|
||||
)
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype matrix (structure)
|
||||
"A 4x4 matrix, stored in row-major order.
|
||||
some, but not all, functions assume that a matrix is an affine transform.
|
||||
others assume that the rotation has no scale or shear (and that its inverse is its transpose)."
|
||||
((data float 16)
|
||||
(vector vector 4 :overlay-at (-> data 0))
|
||||
(quad uint128 4 :overlay-at (-> data 0))
|
||||
(rvec vector :inline :overlay-at (-> data 0))
|
||||
(uvec vector :inline :overlay-at (-> data 4))
|
||||
(fvec vector :inline :overlay-at (-> data 8))
|
||||
(trans vector :inline :overlay-at (-> data 12))
|
||||
)
|
||||
(:methods
|
||||
(transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype matrix3 (structure)
|
||||
"A 3x3 matrix, stored in row-major order.
|
||||
NOTE: the rows each have an extra 4-bytes of padding,
|
||||
so this is really a 3x4 matrix.
|
||||
This type is rarely used."
|
||||
((data float 12)
|
||||
(vector vector 3 :inline :overlay-at (-> data 0))
|
||||
(quad uint128 3 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype matrix4h (structure)
|
||||
"A matrix stored using 16-bit integers.
|
||||
Note that these usually have different scaling for the 4th row which
|
||||
contains the translation in an affine transform.
|
||||
So you generally should not unpack these to floats without knowing where they came from
|
||||
and how they were originally packed (for example, in tie/shrub)."
|
||||
((data int16 16)
|
||||
(vector4h vector4h 4 :overlay-at (-> data 0))
|
||||
(long int64 4 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defun matrix-copy! ((arg0 matrix) (arg1 matrix))
|
||||
"Copy arg1 to arg0"
|
||||
(let ((v1-0 (-> arg1 rvec quad))
|
||||
(a2-0 (-> arg1 uvec quad))
|
||||
(a3-0 (-> arg1 fvec quad))
|
||||
(a1-1 (-> arg1 trans quad))
|
||||
)
|
||||
(set! (-> arg0 rvec quad) v1-0)
|
||||
(set! (-> arg0 uvec quad) a2-0)
|
||||
(set! (-> arg0 fvec quad) a3-0)
|
||||
(set! (-> arg0 trans quad) a1-1)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix<-vector-yz-exact! ((arg0 matrix) (arg1 vector) (arg2 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg2 quad))
|
||||
(vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix<-vector-yz! ((arg0 matrix) (arg1 vector) (arg2 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 rvec) 1.0)
|
||||
(vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec))
|
||||
(set! (-> arg0 rvec w) 1.0)
|
||||
(set! (-> arg0 uvec w) 1.0)
|
||||
(set! (-> arg0 fvec w) 1.0)
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun matrix<-vector-z! ((arg0 matrix) (arg1 vector))
|
||||
(let* ((s3-0 (new 'stack-no-clear 'vector))
|
||||
(v1-0 (vector-get-closest-perpendicular! s3-0 arg1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(s4-1 arg0)
|
||||
)
|
||||
(set! (-> s4-1 fvec quad) (-> arg1 quad))
|
||||
(set! (-> s4-1 uvec quad) (-> v1-0 quad))
|
||||
(vector-cross! (-> s4-1 rvec) (-> s4-1 uvec) arg1)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,5 +5,33 @@
|
||||
;; name in dgo: quaternion-h
|
||||
;; dgos: GAME
|
||||
|
||||
(defmacro new-stack-quaternion0 ()
|
||||
"Get a stack quaternion that's set to 0.
|
||||
This is more efficient than (new 'stack 'quaternion) because
|
||||
this doesn't call the constructor."
|
||||
`(let ((q (new 'stack-no-clear 'quaternion)))
|
||||
(set! (-> q quad) (the-as uint128 0))
|
||||
q
|
||||
)
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype quaternion (structure)
|
||||
"Quaternion. Stored in xyzw order."
|
||||
((data float 4)
|
||||
(x float :overlay-at (-> data 0))
|
||||
(y float :overlay-at (-> data 1))
|
||||
(z float :overlay-at (-> data 2))
|
||||
(w float :overlay-at (-> data 3))
|
||||
(vec vector :inline :overlay-at (-> data 0))
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
(define-extern quaternion-normalize! (function quaternion quaternion))
|
||||
(define-extern vector-y-angle (function vector float))
|
||||
(define-extern matrix->quaternion (function quaternion matrix quaternion))
|
||||
(define-extern quaternion->matrix (function matrix quaternion matrix))
|
||||
|
||||
(define *unity-quaternion* (new 'static 'quaternion :w 1.0))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,3 +7,27 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype transform (structure)
|
||||
"Transformation. w components of vectors should be 1.0
|
||||
This can represent any rotation, translation, and scaling.
|
||||
Note that the scaling is applied before rotation
|
||||
(meaning it scales along the axes of the pre-transformed frame)."
|
||||
((trans vector :inline)
|
||||
(rot vector :inline)
|
||||
(scale vector :inline)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype trs (basic)
|
||||
"Like transform, but it's a basic.
|
||||
Note that the trsq child type overrides this rotation with a quaternion.
|
||||
usage of the plain trs is very limited, at least in Jak 1."
|
||||
((trans vector :inline)
|
||||
(rot vector :inline)
|
||||
(scale vector :inline)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -7,3 +7,62 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(defmethod print ((this transform))
|
||||
(format #t "#<transform @ #x~X~%" this)
|
||||
(format #t "~T~Ttrans:~F ~F ~F ~F ~%" (-> this trans x) (-> this trans y) (-> this trans z) (-> this trans w))
|
||||
(format #t "~T~Trot: ~F ~F ~F ~F ~%" (-> this rot x) (-> this rot y) (-> this rot z) (-> this rot w))
|
||||
(format #t "~T~Tscale:~F ~F ~F ~F>" (-> this scale x) (-> this scale y) (-> this scale z) (-> this scale w))
|
||||
this
|
||||
)
|
||||
|
||||
(defmethod new trs ((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 trans w) 1.0)
|
||||
(set! (-> gp-0 rot w) 1.0)
|
||||
(vector-identity! (-> gp-0 scale))
|
||||
gp-0
|
||||
)
|
||||
)
|
||||
|
||||
(defun transform-matrix-calc! ((arg0 transform) (arg1 matrix))
|
||||
"Convert a transform to matrix. Not efficient, and the output is the second arg."
|
||||
(let ((s4-0 (new-stack-matrix0))
|
||||
(s3-0 (new-stack-matrix0))
|
||||
)
|
||||
(matrix-identity! arg1)
|
||||
(matrix-translate! arg1 (-> arg0 trans))
|
||||
(matrix-rotate-y! s4-0 (-> arg0 rot y))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-rotate-x! s4-0 (-> arg0 rot x))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
(matrix-rotate-z! s4-0 (-> arg0 rot z))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-scale! s4-0 (-> arg0 scale))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
)
|
||||
)
|
||||
|
||||
(defun transform-matrix-parent-calc! ((arg0 transform) (arg1 matrix) (arg2 vector))
|
||||
"Convert a transform to a matrix, applying an inverse scaling."
|
||||
(let ((s4-0 (new-stack-matrix0))
|
||||
(s3-0 (new-stack-matrix0))
|
||||
)
|
||||
(matrix-identity! s3-0)
|
||||
(matrix-translate! s3-0 (-> arg0 trans))
|
||||
(matrix-inv-scale! s4-0 arg2)
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
(matrix-rotate-y! s4-0 (-> arg0 rot y))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-rotate-x! s4-0 (-> arg0 rot x))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
(matrix-rotate-z! s4-0 (-> arg0 rot z))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-scale! s4-0 (-> arg0 scale))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
)
|
||||
)
|
||||
|
||||
(defun trs-matrix-calc! ((arg0 trs) (arg1 matrix))
|
||||
"Convert a trs to a matrix."
|
||||
(transform-matrix-calc! (the-as transform (-> arg0 trans)) arg1)
|
||||
)
|
||||
|
||||
@@ -7,3 +7,69 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype transformq (transform)
|
||||
((quat quaternion :inline :overlay-at (-> rot data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype trsq (trs)
|
||||
((quat quaternion :inline :overlay-at (-> rot data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype trsqv (trsq)
|
||||
"A transform with:
|
||||
- type information (child of [[basic]])
|
||||
- rotation stored as quaternion
|
||||
- velocity information.
|
||||
This is a very commonly used type to represent the position of an in-game object.
|
||||
The `root` of a process-drawable (the parent 'in-game object' type) is a [[trsqv]].
|
||||
Additionally, the collision system uses [[trsqv]] as the parent type for foreground
|
||||
collision objects ([[collide-shape]], [[collide-shape-moving]]).
|
||||
As a result, this type has a lot of weird methods and extra stuff hidden in it."
|
||||
((pause-adjust-distance meters :offset 4)
|
||||
(nav-radius meters :offset 8)
|
||||
(transv vector :inline)
|
||||
(rotv vector :inline)
|
||||
(scalev vector :inline)
|
||||
(dir-targ quaternion :inline)
|
||||
(angle-change-time time-frame)
|
||||
(old-y-angle-diff float)
|
||||
)
|
||||
(:methods
|
||||
(seek-toward-heading-vec! (_type_ vector float time-frame) quaternion)
|
||||
(set-heading-vec! (_type_ vector) quaternion)
|
||||
(seek-to-point-toward-point! (_type_ vector float time-frame) quaternion)
|
||||
(point-toward-point! (_type_ vector) quaternion)
|
||||
(seek-toward-yaw-angle! (_type_ float float time-frame) quaternion)
|
||||
(set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion)
|
||||
(set-roll-to-grav! (_type_ float) quaternion)
|
||||
(set-roll-to-grav-2! (_type_ float) quaternion)
|
||||
(rotate-toward-orientation! (_type_ quaternion float float int int float) quaternion)
|
||||
(set-quaternion! (_type_ quaternion) quaternion)
|
||||
(set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion)
|
||||
(point-toward-point-clear-roll-pitch! (_type_ vector) quaternion)
|
||||
(rot->dir-targ! (_type_) quaternion)
|
||||
(y-angle (_type_) float)
|
||||
(global-y-angle-to-point (_type_ vector) float)
|
||||
(relative-y-angle-to-point (_type_ vector) float)
|
||||
(roll-relative-to-gravity (_type_) float)
|
||||
(set-and-limit-velocity (_type_ int vector float) trsqv)
|
||||
(get-quaternion (_type_) quaternion)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defmethod global-y-angle-to-point ((this trsqv) (arg0 vector))
|
||||
"Get the angle in the xz plane from the position of this trsqv to the point arg0
|
||||
(ignores our current yaw)."
|
||||
(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans)))
|
||||
)
|
||||
|
||||
(defmethod relative-y-angle-to-point ((this trsqv) (arg0 vector))
|
||||
"Get the y angle between the current orientation and arg0
|
||||
(how much we'd have to yaw to point at arg0)."
|
||||
(deg-diff (y-angle this) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans))))
|
||||
)
|
||||
|
||||
@@ -5,5 +5,22 @@
|
||||
;; name in dgo: trigonometry-h
|
||||
;; dgos: GAME
|
||||
|
||||
(define-extern deg-diff (function float float float))
|
||||
(define-extern sin (function float float))
|
||||
(define-extern cos (function float float))
|
||||
(define-extern acos (function float float))
|
||||
(define-extern atan (function float float float))
|
||||
(define-extern sincos! (function vector float int))
|
||||
(define-extern sincos-rad! (function vector float int))
|
||||
(define-extern vector-sin-rad! (function vector vector vector))
|
||||
(define-extern vector-sincos-rad! (function vector vector vector int))
|
||||
(define-extern vector-rad<-vector-deg! (function vector vector none))
|
||||
(define-extern vector-rad<-vector-deg/2! (function vector vector int))
|
||||
(define-extern vector-sincos! (function vector vector vector int))
|
||||
(define-extern acos-rad (function float float))
|
||||
(define-extern atan-series-rad (function float float))
|
||||
(define-extern atan2-rad (function float float float))
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
;; No code!
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,5 +5,620 @@
|
||||
;; name in dgo: vector-h
|
||||
;; dgos: GAME
|
||||
|
||||
(define-extern vector-identity! (function vector vector))
|
||||
(define-extern vector-cross! (function vector vector vector vector))
|
||||
(define-extern vector-float*! (function vector vector float vector))
|
||||
(define-extern vector-normalize! (function vector float vector))
|
||||
(define-extern vector-normalize-copy! (function vector vector float vector))
|
||||
(define-extern vector-xz-normalize! (function vector float vector))
|
||||
(define-extern vector-get-unique! (function vector vector vector))
|
||||
(define-extern vector-get-closest-perpendicular! (function vector vector vector vector))
|
||||
(define-extern vector-length (function vector float))
|
||||
(define-extern vector-length-squared (function vector float))
|
||||
(define-extern vector-xz-length (function vector float))
|
||||
|
||||
(defmacro set-vector! (v xv yv zv wv)
|
||||
"Set all fields in a vector"
|
||||
(with-gensyms (vec)
|
||||
`(let ((,vec ,v))
|
||||
(set! (-> ,vec x) ,xv)
|
||||
(set! (-> ,vec y) ,yv)
|
||||
(set! (-> ,vec z) ,zv)
|
||||
(set! (-> ,vec w) ,wv)
|
||||
,vec
|
||||
))
|
||||
)
|
||||
|
||||
(defmacro set-vector-xyz! (v xv yv zv)
|
||||
"Set xyz fields in a vector"
|
||||
(with-gensyms (vec)
|
||||
`(let ((,vec ,v))
|
||||
(set! (-> ,vec x) ,xv)
|
||||
(set! (-> ,vec y) ,yv)
|
||||
(set! (-> ,vec z) ,zv)
|
||||
,vec
|
||||
))
|
||||
)
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(deftype bit-array (basic)
|
||||
((length int32)
|
||||
(allocated-length int32)
|
||||
(_pad uint8)
|
||||
(bytes uint8 :dynamic :overlay-at _pad)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type int) _type_)
|
||||
(get-bit (_type_ int) symbol)
|
||||
(clear-bit (_type_ int) int)
|
||||
(set-bit (_type_ int) int)
|
||||
(clear-all! (_type_) _type_)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defmethod new bit-array ((allocation symbol) (type-to-make type) (arg0 int))
|
||||
"Allocate a new bit-array with room arg0 bits."
|
||||
(let ((v0-0 (object-new allocation type-to-make (+ (/ (logand -8 (+ arg0 7)) 8) -1 (-> type-to-make size)))))
|
||||
(set! (-> v0-0 length) arg0)
|
||||
(set! (-> v0-0 allocated-length) arg0)
|
||||
v0-0
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod length ((this bit-array))
|
||||
(-> this length)
|
||||
)
|
||||
|
||||
;; WARN: Return type mismatch uint vs int.
|
||||
(defmethod asize-of ((this bit-array))
|
||||
(the-as int (+ (-> this type size) (/ (logand -8 (+ (-> this allocated-length) 7)) 8)))
|
||||
)
|
||||
|
||||
(defmethod get-bit ((this bit-array) (arg0 int))
|
||||
"Get the nth bit as a boolean."
|
||||
(let ((v1-2 (-> this bytes (/ arg0 8))))
|
||||
(logtest? v1-2 (ash 1 (logand arg0 7)))
|
||||
)
|
||||
)
|
||||
|
||||
(defmethod clear-bit ((this bit-array) (arg0 int))
|
||||
"Set the nth bit to 0."
|
||||
(logclear! (-> this bytes (/ arg0 8)) (ash 1 (logand arg0 7)))
|
||||
0
|
||||
)
|
||||
|
||||
(defmethod set-bit ((this bit-array) (arg0 int))
|
||||
"Set the nth bit to 1."
|
||||
(logior! (-> this bytes (/ arg0 8)) (ash 1 (logand arg0 7)))
|
||||
0
|
||||
)
|
||||
|
||||
(defmethod clear-all! ((this bit-array))
|
||||
"Set all bits to 0."
|
||||
(countdown (v1-2 (/ (logand -8 (+ (-> this allocated-length) 7)) 8))
|
||||
(nop!)
|
||||
(nop!)
|
||||
(set! (-> this bytes v1-2) (the-as uint 0))
|
||||
)
|
||||
this
|
||||
)
|
||||
|
||||
(deftype vector16ub (structure)
|
||||
((data uint8 16)
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4ub (structure)
|
||||
((data uint8 4)
|
||||
(x uint8 :overlay-at (-> data 0))
|
||||
(y uint8 :overlay-at (-> data 1))
|
||||
(z uint8 :overlay-at (-> data 2))
|
||||
(w uint8 :overlay-at (-> data 3))
|
||||
(clr uint32 :overlay-at (-> data 0))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4b (structure)
|
||||
((data int8 4)
|
||||
(x int8 :overlay-at (-> data 0))
|
||||
(y int8 :overlay-at (-> data 1))
|
||||
(z int8 :overlay-at (-> data 2))
|
||||
(w int8 :overlay-at (-> data 3))
|
||||
(clr int32 :overlay-at (-> data 0))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype vector2ub (structure)
|
||||
((data uint8 2)
|
||||
(x uint8 :overlay-at (-> data 0))
|
||||
(y uint8 :overlay-at (-> data 1))
|
||||
(clr uint16 :overlay-at (-> data 0))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype vector2b (structure)
|
||||
((data int8 2)
|
||||
(x int8 :overlay-at (-> data 0))
|
||||
(y int8 :overlay-at (-> data 1))
|
||||
(clr int16 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector2h (structure)
|
||||
((data int16 2)
|
||||
(x int16 :overlay-at (-> data 0))
|
||||
(y int16 :overlay-at (-> data 1))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype vector2uh (structure)
|
||||
((data uint16 2)
|
||||
(x uint16 :overlay-at (-> data 0))
|
||||
(y uint16 :overlay-at (-> data 1))
|
||||
(val uint32 :overlay-at (-> data 0))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype vector3h (structure)
|
||||
((data int16 3)
|
||||
(x int16 :overlay-at (-> data 0))
|
||||
(y int16 :overlay-at (-> data 1))
|
||||
(z int16 :overlay-at (-> data 2))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector3uh (structure)
|
||||
((data uint16 3)
|
||||
(x uint16 :overlay-at (-> data 0))
|
||||
(y uint16 :overlay-at (-> data 1))
|
||||
(z uint16 :overlay-at (-> data 2))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector2w (structure)
|
||||
((data int32 2)
|
||||
(x int32 :overlay-at (-> data 0))
|
||||
(y int32 :overlay-at (-> data 1))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector3w (structure)
|
||||
((data int32 3)
|
||||
(x int32 :overlay-at (-> data 0))
|
||||
(y int32 :overlay-at (-> data 1))
|
||||
(z int32 :overlay-at (-> data 2))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4w (structure)
|
||||
((data int32 4)
|
||||
(x int32 :overlay-at (-> data 0))
|
||||
(y int32 :overlay-at (-> data 1))
|
||||
(z int32 :overlay-at (-> data 2))
|
||||
(w int32 :overlay-at (-> data 3))
|
||||
(dword uint64 2 :overlay-at (-> data 0))
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector2 (structure)
|
||||
((data float 2)
|
||||
(x float :overlay-at (-> data 0))
|
||||
(y float :overlay-at (-> data 1))
|
||||
)
|
||||
:allow-misaligned
|
||||
)
|
||||
|
||||
|
||||
(deftype vector3 (structure)
|
||||
((data float 3)
|
||||
(x float :overlay-at (-> data 0))
|
||||
(y float :overlay-at (-> data 1))
|
||||
(z float :overlay-at (-> data 2))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4 (structure)
|
||||
((data float 4)
|
||||
(x float :overlay-at (-> data 0))
|
||||
(y float :overlay-at (-> data 1))
|
||||
(z float :overlay-at (-> data 2))
|
||||
(w float :overlay-at (-> data 3))
|
||||
(dword uint64 2 :overlay-at (-> data 0))
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(defmethod print ((this vector4w))
|
||||
(format #t "#<vector4w ~D ~D ~D ~D @ #x~X>" (-> this x) (-> this y) (-> this z) (-> this w) this)
|
||||
this
|
||||
)
|
||||
|
||||
(deftype vector4w-2 (structure)
|
||||
((data int32 8)
|
||||
(quad uint128 2 :overlay-at (-> data 0))
|
||||
(vector vector4w 2 :inline :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4w-3 (structure)
|
||||
((data int32 12)
|
||||
(quad uint128 3 :overlay-at (-> data 0))
|
||||
(vector vector4w 3 :inline :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4w-4 (structure)
|
||||
((data int32 16)
|
||||
(quad uint128 4 :overlay-at (-> data 0))
|
||||
(vector vector4w 4 :inline :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector4h (structure)
|
||||
((data int16 4)
|
||||
(x int16 :overlay-at (-> data 0))
|
||||
(y int16 :overlay-at (-> data 1))
|
||||
(z int16 :overlay-at (-> data 2))
|
||||
(w int16 :overlay-at (-> data 3))
|
||||
(long uint64 :overlay-at (-> data 0))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
|
||||
(deftype vector8h (structure)
|
||||
((data int16 8)
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector16b (structure)
|
||||
((data int8 16)
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
(defmethod print ((this vector))
|
||||
(format #t "#<vector ~F ~F ~F ~F @ #x~X>" (-> this x) (-> this y) (-> this z) (-> this w) this)
|
||||
this
|
||||
)
|
||||
|
||||
(define *null-vector* (new 'static 'vector :w 1.0))
|
||||
|
||||
(define *identity-vector* (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0))
|
||||
|
||||
(define *x-vector* (new 'static 'vector :x 1.0 :w 1.0))
|
||||
|
||||
(define *y-vector* (new 'static 'vector :y 1.0 :w 1.0))
|
||||
|
||||
(define *z-vector* (new 'static 'vector :z 1.0 :w 1.0))
|
||||
|
||||
(define *up-vector* (new 'static 'vector :y 1.0 :w 1.0))
|
||||
|
||||
(deftype vector4s-3 (structure)
|
||||
((data float 12)
|
||||
(quad uint128 3 :overlay-at (-> data 0))
|
||||
(vector vector 3 :inline :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector-array (inline-array-class)
|
||||
((data vector :inline :dynamic)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(set! (-> vector-array heap-base) (the-as uint 16))
|
||||
|
||||
(deftype rgbaf (vector)
|
||||
((r float :overlay-at (-> data 0))
|
||||
(g float :overlay-at (-> data 1))
|
||||
(b float :overlay-at (-> data 2))
|
||||
(a float :overlay-at (-> data 3))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype plane (vector)
|
||||
((a float :overlay-at (-> data 0))
|
||||
(b float :overlay-at (-> data 1))
|
||||
(c float :overlay-at (-> data 2))
|
||||
(d float :overlay-at (-> data 3))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype sphere (vector)
|
||||
((r float :overlay-at (-> data 3))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype isphere (vec4s)
|
||||
()
|
||||
)
|
||||
|
||||
(defmacro static-vector (x y z w)
|
||||
"Creates a static vector."
|
||||
`(new 'static 'vector :x ,x :y ,y :z ,z :w ,w)
|
||||
)
|
||||
(defmacro static-vectorm (x y z)
|
||||
"Creates a static vector using meters. `w` is set to 1.0"
|
||||
`(new 'static 'vector :x (meters ,x) :y (meters ,y) :z (meters ,z) :w 1.0)
|
||||
)
|
||||
(defmacro static-spherem (x y z r)
|
||||
"Creates a static vector using meters where the w component is used as sphere radius. For a 'real' sphere, use [[static-bspherem]]."
|
||||
`(new 'static 'vector :x (meters ,x) :y (meters ,y) :z (meters ,z) :w (meters ,r))
|
||||
)
|
||||
(defmacro static-bspherem (x y z r)
|
||||
"Creates a static sphere using meters."
|
||||
`(new 'static 'sphere :x (meters ,x) :y (meters ,y) :z (meters ,z) :w (meters ,r))
|
||||
)
|
||||
|
||||
(deftype box8s (structure)
|
||||
((data float 8)
|
||||
(quad uint128 2 :overlay-at (-> data 0))
|
||||
(vector vector 2 :overlay-at (-> data 0))
|
||||
(min vector :inline :overlay-at (-> data 0))
|
||||
(max vector :inline :overlay-at (-> data 4))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype box8s-array (inline-array-class)
|
||||
((data box8s :inline :dynamic)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(set! (-> box8s-array heap-base) (the-as uint 32))
|
||||
|
||||
(deftype vertical-planes (structure)
|
||||
((data uint128 4)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vertical-planes-array (basic)
|
||||
((length uint32)
|
||||
(data vertical-planes :inline :dynamic)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype qword (structure)
|
||||
((data uint32 4)
|
||||
(byte uint8 16 :overlay-at (-> data 0))
|
||||
(hword uint16 8 :overlay-at (-> data 0))
|
||||
(word uint32 4 :overlay-at (-> data 0))
|
||||
(dword uint64 2 :overlay-at (-> data 0))
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
(vector vector :inline :overlay-at (-> data 0))
|
||||
(vector4w vector4w :inline :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
(deftype vector3s (structure)
|
||||
((data float 3)
|
||||
(x float :overlay-at (-> data 0))
|
||||
(y float :overlay-at (-> data 1))
|
||||
(z float :overlay-at (-> data 2))
|
||||
)
|
||||
:pack-me
|
||||
)
|
||||
|
||||
(defun vector-dot ((a vector) (b vector))
|
||||
"Take the dot product of two vectors.
|
||||
Only does the x, y, z compoments.
|
||||
Originally handwritten assembly to space out loads and use FPU accumulator"
|
||||
(declare (inline))
|
||||
(let ((result 0.))
|
||||
(+! result (* (-> a x) (-> b x)))
|
||||
(+! result (* (-> a y) (-> b y)))
|
||||
(+! result (* (-> a z) (-> b z)))
|
||||
result
|
||||
)
|
||||
)
|
||||
|
||||
(defun vector-dot-vu ((arg0 vector) (arg1 vector))
|
||||
"Take the dot product (xyz only). Using VU0."
|
||||
(local-vars (v0-0 float))
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
)
|
||||
(.lvf vf1 (&-> arg0 quad))
|
||||
(.lvf vf2 (&-> arg1 quad))
|
||||
(.mul.vf vf1 vf1 vf2)
|
||||
(.add.y.vf vf1 vf1 vf1 :mask #b1)
|
||||
(.add.z.vf vf1 vf1 vf1 :mask #b1)
|
||||
(.mov v0-0 vf1)
|
||||
v0-0
|
||||
)
|
||||
)
|
||||
|
||||
(defun vector4-dot ((a vector) (b vector))
|
||||
"Take the dot product of two vectors.
|
||||
Does the x, y, z, and w compoments"
|
||||
(declare (inline))
|
||||
(let ((result 0.))
|
||||
(+! result (* (-> a x) (-> b x)))
|
||||
(+! result (* (-> a y) (-> b y)))
|
||||
(+! result (* (-> a z) (-> b z)))
|
||||
(+! result (* (-> a w) (-> b w)))
|
||||
result
|
||||
)
|
||||
)
|
||||
|
||||
(defun vector4-dot-vu ((arg0 vector) (arg1 vector))
|
||||
"Take the dot product (xyzw). Using VU0."
|
||||
(local-vars (v0-0 float))
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf1 (&-> arg0 quad))
|
||||
(.lvf vf2 (&-> arg1 quad))
|
||||
(.mul.vf vf1 vf1 vf2)
|
||||
(.add.w.vf vf3 vf0 vf0 :mask #b1)
|
||||
(.mul.x.vf acc vf3 vf1 :mask #b1)
|
||||
(.add.mul.y.vf acc vf3 vf1 acc :mask #b1)
|
||||
(.add.mul.z.vf acc vf3 vf1 acc :mask #b1)
|
||||
(.add.mul.w.vf vf1 vf3 vf1 acc :mask #b1)
|
||||
(.mov v0-0 vf1)
|
||||
v0-0
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro print-vf (vf &key (name #f))
|
||||
"Print out a vf register as a vector."
|
||||
`(let ((temp (new 'stack 'vector)))
|
||||
(.svf temp ,vf)
|
||||
,(if name
|
||||
`(format #t "~A: ~`vector`P~%" (quote ,name) temp)
|
||||
`(format #t "~`vector`P~%" temp)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro print-vf-hex (vf)
|
||||
"Print out a vf register as 4x 32-bit hexadecimal integers"
|
||||
`(let ((temp (new 'stack 'vector4w)))
|
||||
(.svf temp ,vf)
|
||||
(format #t "~`vector4w`P~%" temp)
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro print-vf-dec (vf)
|
||||
"Print out a vf register as 4x 32-bit base-10 integers"
|
||||
`(let ((temp (new 'stack 'vector4w)))
|
||||
(.svf temp ,vf)
|
||||
(format #t " ~d ~d ~d ~d~%" (-> temp data 0) (-> temp data 1) (-> temp data 2) (-> temp data 3))
|
||||
)
|
||||
)
|
||||
|
||||
(defun vector+! ((dst vector) (a vector) (b vector))
|
||||
"Set dst = a + b. The w component of dst is set to 0."
|
||||
(declare (inline))
|
||||
(rlet ((vf0 :class vf :reset-here #t)
|
||||
(vf1 :class vf :reset-here #t)
|
||||
(vf2 :class vf :reset-here #t)
|
||||
(vf3 :class vf :reset-here #t))
|
||||
;; load vectors
|
||||
(.lvf vf2 a)
|
||||
(.lvf vf3 b)
|
||||
(init-vf0-vector)
|
||||
;; add
|
||||
(.add.vf vf1 vf2 vf3)
|
||||
;; set w = 1
|
||||
(.blend.vf vf1 vf1 vf0 :mask #b1000)
|
||||
;; store
|
||||
(.svf dst vf1)
|
||||
)
|
||||
dst
|
||||
)
|
||||
|
||||
(defun vector-! ((dst vector) (a vector) (b vector))
|
||||
"Set dst = a - b. The w componenent of dst is set to 0."
|
||||
(declare (inline))
|
||||
(rlet ((vf0 :class vf :reset-here #t)
|
||||
(vf1 :class vf :reset-here #t)
|
||||
(vf2 :class vf :reset-here #t)
|
||||
(vf3 :class vf :reset-here #t))
|
||||
;; load vectors
|
||||
(.lvf vf2 a)
|
||||
(.lvf vf3 b)
|
||||
(init-vf0-vector)
|
||||
;; subtract
|
||||
(.sub.vf vf1 vf2 vf3)
|
||||
;; set w = 1
|
||||
(.blend.vf vf1 vf1 vf0 :mask #b1000)
|
||||
;; store
|
||||
(.svf dst vf1)
|
||||
)
|
||||
dst
|
||||
)
|
||||
|
||||
(defun vector-zero! ((dst vector))
|
||||
"Set xyzw to 0."
|
||||
(declare (inline))
|
||||
(rlet ((vf1 :class vf :reset-here #t))
|
||||
;; set vf1 = 0
|
||||
(.xor.vf vf1 vf1 vf1)
|
||||
;; store the 0
|
||||
(.svf dst vf1)
|
||||
)
|
||||
dst
|
||||
)
|
||||
|
||||
(defun vector-reset! ((dst vector))
|
||||
"Set vector to <0,0,0,1>."
|
||||
(declare (inline))
|
||||
(vector-zero! dst)
|
||||
(set! (-> dst w) 1.0)
|
||||
dst
|
||||
)
|
||||
|
||||
(defun vector-copy! ((arg0 vector) (arg1 vector))
|
||||
"Copy arg1 to arg0."
|
||||
(declare (inline))
|
||||
(set! (-> arg0 quad) (-> arg1 quad))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun vector-length< ((arg0 vector) (arg1 float))
|
||||
(let ((f0-0 (vector-length-squared arg0))
|
||||
(f1-0 arg1)
|
||||
)
|
||||
(< f0-0 (* f1-0 f1-0))
|
||||
)
|
||||
)
|
||||
|
||||
(defun vector-length> ((arg0 vector) (arg1 float))
|
||||
(< (* arg1 arg1) (vector-length-squared arg0))
|
||||
)
|
||||
|
||||
(define *zero-vector* (new 'static 'vector))
|
||||
|
||||
(defmacro new-stack-vector0 ()
|
||||
"Get a stack vector that's set to 0.
|
||||
This is more efficient than (new 'stack 'vector) because
|
||||
this doesn't call the constructor."
|
||||
`(let ((vec (new 'stack-no-clear 'vector)))
|
||||
(set! (-> vec quad) (the-as uint128 0))
|
||||
vec
|
||||
)
|
||||
)
|
||||
@@ -7,3 +7,4 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
;; No code!
|
||||
|
||||
+20
-13
@@ -1,10 +1,12 @@
|
||||
import os
|
||||
# change working dir to script location
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
import glob
|
||||
import argparse
|
||||
|
||||
|
||||
### Script to track decompilation progress.
|
||||
### Example usage: python3 scripts/decomp_progress.py ~/jak-project/goal_src/jak2
|
||||
### Example usage: python3 scripts/decomp_progress.py jak2
|
||||
|
||||
def get_goal_files(root_dir, ext = "*.gc"):
|
||||
"""Get all GOAL source files under root_dir."""
|
||||
@@ -19,7 +21,7 @@ def lines_in_file(file_path):
|
||||
return lines
|
||||
|
||||
|
||||
def print_table(stats, total_gc_files):
|
||||
def print_table(game, stats, total_gc_files):
|
||||
total_lines = 0
|
||||
print("| {: <24} | {: <6} |".format("file name", "lines"))
|
||||
print("-------------------------------------")
|
||||
@@ -29,7 +31,11 @@ def print_table(stats, total_gc_files):
|
||||
print("-------------------------------------")
|
||||
print("| {: <24} | {: >6} |".format("TOTAL", total_lines))
|
||||
print("-------------------------------------")
|
||||
estimated_lines = 1000000
|
||||
estimated_lines = 500000
|
||||
if game == "jak2":
|
||||
estimated_lines = 1000000
|
||||
elif game == "jak3":
|
||||
estimated_lines = 1200000
|
||||
print("Progress: {}/{} lines ({:.2f}%)".format(total_lines, estimated_lines, 100. * total_lines / estimated_lines))
|
||||
print("{}/{} files modified from template ({:.2f}%)".format(len(stats), total_gc_files,
|
||||
100. * len(stats) / total_gc_files))
|
||||
@@ -37,19 +43,23 @@ def print_table(stats, total_gc_files):
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(dest='goal_src', help='the goal_src folder')
|
||||
parser.add_argument(dest='game', help='game name')
|
||||
args = parser.parse_args()
|
||||
all_files = get_goal_files(args.goal_src)
|
||||
gsrc_path = "../goal_src/" + args.game
|
||||
all_files = get_goal_files(gsrc_path)
|
||||
|
||||
ref_files = get_goal_files(args.goal_src + "/../../test/decompiler/reference/jak2", "*_REF.gc")
|
||||
ref_files = get_goal_files("../test/decompiler/reference/" + args.game, "*_REF.gc")
|
||||
ref_files_no_ext = [os.path.basename(fn)[:-7] for fn in ref_files]
|
||||
|
||||
|
||||
|
||||
file_stats = []
|
||||
total_gc_files = 0
|
||||
excluded_files = {"game_dgos.gc", "all_files.gc", "goal-lib.gc", "ocean-trans-tables.gc", "ocean-frames.gc",
|
||||
"ocean-tables.gc"}
|
||||
"ocean-tables.gc", "art-elts.gc", "joint-nodes.gc", "compiler-setup.gc", "kernel-defs.gc"}
|
||||
excluded_paths = {"pc", "examples", "old"}
|
||||
for path in excluded_paths:
|
||||
files = get_goal_files(gsrc_path + "/" + path)
|
||||
for fn in files:
|
||||
excluded_files.add(os.path.basename(fn))
|
||||
modified = set()
|
||||
|
||||
for fn in all_files:
|
||||
@@ -76,10 +86,7 @@ def main():
|
||||
print("Missing ref files:")
|
||||
for fn in missing_ref_files:
|
||||
print(" {}".format(fn))
|
||||
|
||||
|
||||
print_table(file_stats, total_gc_files)
|
||||
|
||||
print_table(args.game, file_stats, total_gc_files)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
+13
-7
@@ -3,30 +3,36 @@ import os
|
||||
|
||||
jak1_files = None
|
||||
jak2_files = None
|
||||
jak3_files = None
|
||||
|
||||
with open('./goal_src/jak1/build/all_objs.json', 'r') as f:
|
||||
jak1_files = json.load(f)
|
||||
with open('./goal_src/jak2/build/all_objs.json', 'r') as f:
|
||||
jak2_files = json.load(f)
|
||||
with open('./goal_src/jak3/build/all_objs.json', 'r') as f:
|
||||
jak3_files = json.load(f)
|
||||
|
||||
def get_file_list(game_name):
|
||||
if game_name == "jak1":
|
||||
return jak1_files
|
||||
else:
|
||||
return jak2_files
|
||||
match game_name:
|
||||
case "jak1":
|
||||
return jak1_files
|
||||
case "jak2":
|
||||
return jak2_files
|
||||
case "jak3":
|
||||
return jak3_files
|
||||
|
||||
def get_gsrc_path_from_filename(game_name, file_name):
|
||||
file_list = get_file_list(game_name)
|
||||
src_path = ""
|
||||
for f in file_list:
|
||||
if f[2] != 3:
|
||||
if f[2] != 3 and f[2] != 5:
|
||||
continue
|
||||
if f[0] == file_name:
|
||||
src_path = f[4]
|
||||
break
|
||||
path = "./goal_src/{}/{}/{}.gc".format(game_name, src_path, file_name)
|
||||
if not os.path.exists(path):
|
||||
print("{} couldn't find in /goal_src/{}!".format(file_name, game_name))
|
||||
print("couldn't find {} in /goal_src/{}!".format(file_name, game_name))
|
||||
exit(1)
|
||||
return path
|
||||
|
||||
@@ -37,7 +43,7 @@ def get_ref_path_from_filename(game_name, file_name, ref_folder):
|
||||
file_list = get_file_list(game_name)
|
||||
src_path = ""
|
||||
for f in file_list:
|
||||
if f[2] != 3:
|
||||
if f[2] != 3 and f[2] != 5:
|
||||
continue
|
||||
if f[0] == file_name:
|
||||
src_path = f[4]
|
||||
|
||||
+56
@@ -1 +1,57 @@
|
||||
;; This file should contain an implementation for all macros that the decompiler uses in its output.
|
||||
|
||||
(defmacro init-vf0-vector ()
|
||||
"Initializes the VF0 vector which is a constant vector in the VU set to <0,0,0,1>"
|
||||
`(.lvf vf0 (new 'static 'vector :x 0.0 :y 0.0 :z 0.0 :w 1.0))
|
||||
)
|
||||
|
||||
(defmacro new-stack-vector0 ()
|
||||
"Get a stack vector that's set to 0.
|
||||
This is more efficient than (new 'stack 'vector) because
|
||||
this doesn't call the constructor."
|
||||
`(let ((vec (new 'stack-no-clear 'vector)))
|
||||
(set! (-> vec quad) (the-as uint128 0))
|
||||
vec
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro set-vector! (v xv yv zv wv)
|
||||
"Set all fields in a vector"
|
||||
(with-gensyms (vec)
|
||||
`(let ((,vec ,v))
|
||||
(set! (-> ,vec x) ,xv)
|
||||
(set! (-> ,vec y) ,yv)
|
||||
(set! (-> ,vec z) ,zv)
|
||||
(set! (-> ,vec w) ,wv)
|
||||
,vec
|
||||
))
|
||||
)
|
||||
|
||||
(defmacro new-stack-quaternion0 ()
|
||||
"Get a stack quaternion that's set to 0.
|
||||
This is more efficient than (new 'stack 'quaternion) because
|
||||
this doesn't call the constructor."
|
||||
`(let ((q (new 'stack-no-clear 'quaternion)))
|
||||
(set! (-> q quad) (the-as uint128 0))
|
||||
q
|
||||
)
|
||||
)
|
||||
|
||||
(defmacro with-pp (&rest body)
|
||||
"execute the body with pp bound to the current process register."
|
||||
`(rlet ((pp :reg r13 :reset-here #t :type process))
|
||||
,@body)
|
||||
)
|
||||
|
||||
(defconstant PP (with-pp pp))
|
||||
|
||||
(defmacro make-u128 (upper lower)
|
||||
`(rlet ((result :class i128)
|
||||
(upper-xmm :class i128)
|
||||
(lower-xmm :class i128))
|
||||
(.mov upper-xmm ,upper)
|
||||
(.mov lower-xmm ,lower)
|
||||
(.pcpyld result upper-xmm lower-xmm)
|
||||
(the uint result)
|
||||
)
|
||||
)
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type bounding-box
|
||||
(deftype bounding-box (structure)
|
||||
((min vector :inline)
|
||||
(max vector :inline)
|
||||
)
|
||||
(:methods
|
||||
(add-spheres! (_type_ (inline-array sphere) int) int)
|
||||
(add-box! (_type_ bounding-box) int)
|
||||
(add-point! (_type_ vector) none)
|
||||
(intersects-line-segment? (_type_ vector vector) symbol)
|
||||
(set-from-point-offset! (_type_ vector vector) none)
|
||||
(set-from-point-offset-pad! (_type_ vector vector float) int)
|
||||
(set-to-point! (_type_ vector) none)
|
||||
(set-from-sphere! (_type_ sphere) none)
|
||||
(set-from-spheres! (_type_ (inline-array sphere) int) int)
|
||||
(get-bounding-sphere (_type_ vector) vector)
|
||||
(inside-xyz? (bounding-box vector) symbol)
|
||||
(inside-xz? (bounding-box vector) symbol)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type bounding-box
|
||||
(defmethod inspect ((this bounding-box))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'bounding-box)
|
||||
(format #t "~1Tmin: ~`vector`P~%" (-> this min))
|
||||
(format #t "~1Tmax: ~`vector`P~%" (-> this max))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type bounding-box2
|
||||
(deftype bounding-box2 (structure)
|
||||
((min vector2 :inline)
|
||||
(max vector2 :inline)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type bounding-box2
|
||||
(defmethod inspect ((this bounding-box2))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'bounding-box2)
|
||||
(format #t "~1Tmin: #<vector2 @ #x~X>~%" (-> this min))
|
||||
(format #t "~1Tmax: #<vector2 @ #x~X>~%" (-> this max))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type bounding-box4w
|
||||
(deftype bounding-box4w (structure)
|
||||
((min vector4w :inline)
|
||||
(max vector4w :inline)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type bounding-box4w
|
||||
(defmethod inspect ((this bounding-box4w))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'bounding-box4w)
|
||||
(format #t "~1Tmin: ~`vector4w`P~%" (-> this min))
|
||||
(format #t "~1Tmax: ~`vector4w`P~%" (-> this max))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type bounding-box-both
|
||||
(deftype bounding-box-both (structure)
|
||||
((box bounding-box :inline)
|
||||
(box4w bounding-box4w :inline)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type bounding-box-both
|
||||
(defmethod inspect ((this bounding-box-both))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'bounding-box-both)
|
||||
(format #t "~1Tbox: #<bounding-box @ #x~X>~%" (-> this box))
|
||||
(format #t "~1Tbox4w: #<bounding-box4w @ #x~X>~%" (-> this box4w))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type bounding-box-array
|
||||
(deftype bounding-box-array (inline-array-class)
|
||||
((data bounding-box :dynamic)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type bounding-box-array
|
||||
(defmethod inspect ((this bounding-box-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! (-> bounding-box-array heap-base) (the-as uint 32))
|
||||
|
||||
|
||||
|
||||
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 19 of type bounding-box
|
||||
(defmethod inside-xyz? ((this bounding-box) (arg0 vector))
|
||||
"Is the point in the box?"
|
||||
(and (< (-> this min x) (-> arg0 x))
|
||||
(< (-> this min y) (-> arg0 y))
|
||||
(< (-> this min z) (-> arg0 z))
|
||||
(< (-> arg0 x) (-> this max x))
|
||||
(< (-> arg0 y) (-> this max y))
|
||||
(< (-> arg0 z) (-> this max z))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 20 of type bounding-box
|
||||
(defmethod inside-xz? ((this bounding-box) (arg0 vector))
|
||||
"Is the point in the box? Check xz only."
|
||||
(and (< (-> this min x) (-> arg0 x))
|
||||
(< (-> this min z) (-> arg0 z))
|
||||
(< (-> arg0 x) (-> this max x))
|
||||
(< (-> arg0 z) (-> this max z))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function box-vector-enside?
|
||||
(defun box-vector-enside? ((arg0 bounding-box) (arg1 vector))
|
||||
"Is the point in the box? On the edge doesn't count."
|
||||
(and (< (-> arg0 min x) (-> arg1 x))
|
||||
(< (-> arg0 min y) (-> arg1 y))
|
||||
(< (-> arg0 min z) (-> arg1 z))
|
||||
(< (-> arg1 x) (-> arg0 max x))
|
||||
(< (-> arg1 y) (-> arg0 max y))
|
||||
(< (-> arg1 z) (-> arg0 max z))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function box-vector-inside?
|
||||
(defun box-vector-inside? ((arg0 bounding-box) (arg1 vector))
|
||||
"Is the point in the box? On the edge counts."
|
||||
(and (>= (-> arg1 x) (-> arg0 min x))
|
||||
(>= (-> arg1 y) (-> arg0 min y))
|
||||
(>= (-> arg1 z) (-> arg0 min z))
|
||||
(>= (-> arg0 max x) (-> arg1 x))
|
||||
(>= (-> arg0 max y) (-> arg1 y))
|
||||
(>= (-> arg0 max z) (-> arg1 z))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type bounding-box
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod set-from-point-offset! ((this bounding-box) (arg0 vector) (arg1 vector))
|
||||
"Set to the smallest box containing arg0, (arg0 + arg1)"
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf3 (&-> arg1 quad))
|
||||
(.lvf vf4 (&-> arg0 quad))
|
||||
(.add.vf vf5 vf4 vf3)
|
||||
(.min.vf vf1 vf4 vf5)
|
||||
(.max.vf vf2 vf4 vf5)
|
||||
(.mov.vf vf1 vf0 :mask #b1000)
|
||||
(.mov.vf vf2 vf0 :mask #b1000)
|
||||
(.svf (&-> this min quad) vf1)
|
||||
(.svf (&-> this max quad) vf2)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 11 of type bounding-box
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod add-point! ((this bounding-box) (arg0 vector))
|
||||
"Expand the box as needed to contain the given point."
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(.lvf vf1 (&-> this min quad))
|
||||
(.lvf vf2 (&-> this max quad))
|
||||
(.lvf vf3 (&-> arg0 quad))
|
||||
(.min.vf vf1 vf1 vf3)
|
||||
(.max.vf vf2 vf2 vf3)
|
||||
(.svf (&-> this min quad) vf1)
|
||||
(.svf (&-> this max quad) vf2)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 10 of type bounding-box
|
||||
(defmethod add-box! ((this bounding-box) (arg0 bounding-box))
|
||||
"Expand the box as needed to contain the given box."
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
)
|
||||
(.lvf vf1 (&-> this min quad))
|
||||
(.lvf vf2 (&-> this max quad))
|
||||
(.lvf vf3 (&-> arg0 min quad))
|
||||
(.lvf vf4 (&-> arg0 max quad))
|
||||
(.min.vf vf1 vf1 vf3)
|
||||
(.max.vf vf2 vf2 vf4)
|
||||
(.svf (&-> this min quad) vf1)
|
||||
(.svf (&-> this max quad) vf2)
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 15 of type bounding-box
|
||||
;; INFO: Used lq/sq
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod set-to-point! ((this bounding-box) (arg0 vector))
|
||||
"Set the box to be a single point."
|
||||
(set! (-> this min quad) (-> arg0 quad))
|
||||
(set! (-> this max quad) (-> arg0 quad))
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type bounding-box
|
||||
(defmethod set-from-point-offset-pad! ((this bounding-box) (arg0 vector) (arg1 vector) (arg2 float))
|
||||
"Set the box to contain arg0, arg0 + offset, with some padding."
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf4 (&-> arg1 quad))
|
||||
(.lvf vf5 (&-> arg0 quad))
|
||||
(.mov vf1 arg2)
|
||||
(.add.vf vf6 vf5 vf4)
|
||||
(.min.vf vf2 vf5 vf6)
|
||||
(.max.vf vf3 vf5 vf6)
|
||||
(.add.x.vf vf3 vf3 vf1 :mask #b111)
|
||||
(.sub.x.vf vf2 vf2 vf1 :mask #b111)
|
||||
(.mov.vf vf2 vf0 :mask #b1000)
|
||||
(.mov.vf vf3 vf0 :mask #b1000)
|
||||
(.svf (&-> this min quad) vf2)
|
||||
(.svf (&-> this max quad) vf3)
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 16 of type bounding-box
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod set-from-sphere! ((this bounding-box) (arg0 sphere))
|
||||
"Set the box to contain a single sphere."
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf1 (&-> arg0 quad))
|
||||
(.sub.w.vf vf2 vf1 vf1 :mask #b111)
|
||||
(.add.w.vf vf3 vf1 vf1 :mask #b111)
|
||||
(.mov.vf vf2 vf0 :mask #b1000)
|
||||
(.mov.vf vf3 vf0 :mask #b1000)
|
||||
(.svf (&-> this min quad) vf2)
|
||||
(.svf (&-> this max quad) vf3)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 17 of type bounding-box
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for method 9 of type bounding-box
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for method 18 of type bounding-box
|
||||
(defmethod get-bounding-sphere ((this bounding-box) (arg0 vector))
|
||||
"Get a bounding sphere for a bounding box."
|
||||
(let* ((a1-2 (vector-! (new 'stack-no-clear 'vector) (-> this max) (-> this min)))
|
||||
(a0-3 (vector-float*! (new 'stack-no-clear 'vector) a1-2 0.5))
|
||||
)
|
||||
(vector+! arg0 (-> this min) a0-3)
|
||||
(set! (-> arg0 w) (vector-length a0-3))
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition of type liang-barsky-line-clip-params
|
||||
(deftype liang-barsky-line-clip-params (structure)
|
||||
((te float)
|
||||
(tl float)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type liang-barsky-line-clip-params
|
||||
(defmethod inspect ((this liang-barsky-line-clip-params))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'liang-barsky-line-clip-params)
|
||||
(format #t "~1Tte: ~f~%" (-> this te))
|
||||
(format #t "~1Ttl: ~f~%" (-> this tl))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for function liang-barsky-line-clipt
|
||||
(defun liang-barsky-line-clipt ((arg0 liang-barsky-line-clip-params) (arg1 float) (arg2 float))
|
||||
"Clip test in 1 dimension. Is arg1 in arg2?"
|
||||
(cond
|
||||
((< 0.0 arg1)
|
||||
(let ((f0-2 (/ arg2 arg1)))
|
||||
(if (< (-> arg0 tl) f0-2)
|
||||
(return #f)
|
||||
)
|
||||
(if (< (-> arg0 te) f0-2)
|
||||
(set! (-> arg0 te) f0-2)
|
||||
)
|
||||
)
|
||||
)
|
||||
((< arg1 0.0)
|
||||
(let ((f0-5 (/ arg2 arg1)))
|
||||
(if (< f0-5 (-> arg0 te))
|
||||
(return #f)
|
||||
)
|
||||
(if (< f0-5 (-> arg0 tl))
|
||||
(set! (-> arg0 tl) f0-5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(if (< 0.0 arg2)
|
||||
(return #f)
|
||||
)
|
||||
)
|
||||
)
|
||||
#t
|
||||
)
|
||||
|
||||
;; definition for method 12 of type bounding-box
|
||||
;; WARN: disable def twice: 23. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
|
||||
(defmethod intersects-line-segment? ((this bounding-box) (arg0 vector) (arg1 vector))
|
||||
"Check intersection in xz plane, using liang-barsky. Not sure if this actually
|
||||
a useful check or not..."
|
||||
(let ((f28-0 (- (-> arg1 x) (-> arg0 x)))
|
||||
(f30-0 (- (-> arg1 z) (-> arg0 z)))
|
||||
)
|
||||
(cond
|
||||
((and (= f28-0 0.0) (= f30-0 0.0))
|
||||
(let ((f1-2 (-> arg0 x))
|
||||
(f0-4 (-> arg0 z))
|
||||
)
|
||||
(and (>= f1-2 (-> this min x)) (>= (-> this max x) f1-2) (>= f0-4 (-> this min z)) (>= (-> this max z) f0-4))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let ((s4-0 (new 'stack-no-clear 'liang-barsky-line-clip-params)))
|
||||
(set! (-> s4-0 te) 0.0)
|
||||
(set! (-> s4-0 tl) 1.0)
|
||||
(and (liang-barsky-line-clipt s4-0 f28-0 (- (-> this min x) (-> arg0 x)))
|
||||
(liang-barsky-line-clipt s4-0 (- f28-0) (- (-> arg0 x) (-> this max x)))
|
||||
(liang-barsky-line-clipt s4-0 f30-0 (- (-> this min z) (-> arg0 z)))
|
||||
(liang-barsky-line-clipt s4-0 (- f30-0) (- (-> arg0 z) (-> this max z)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type curve
|
||||
(deftype curve (structure)
|
||||
((cverts (inline-array vector))
|
||||
(num-cverts int32)
|
||||
(knots (pointer float))
|
||||
(num-knots int32)
|
||||
(length float)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type curve
|
||||
(defmethod inspect ((this curve))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'curve)
|
||||
(format #t "~1Tcverts: #x~X~%" (-> this cverts))
|
||||
(format #t "~1Tnum-cverts: ~D~%" (-> this num-cverts))
|
||||
(format #t "~1Tknots: #x~X~%" (-> this knots))
|
||||
(format #t "~1Tnum-knots: ~D~%" (-> this num-knots))
|
||||
(format #t "~1Tlength: ~f~%" (-> this length))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type line-intersection-val
|
||||
(deftype line-intersection-val (structure)
|
||||
((tt0 float)
|
||||
(tt1 float)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type line-intersection-val
|
||||
(defmethod inspect ((this line-intersection-val))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'line-intersection-val)
|
||||
(format #t "~1Ttt0: ~f~%" (-> this tt0))
|
||||
(format #t "~1Ttt1: ~f~%" (-> this tt1))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type border-plane
|
||||
(deftype border-plane (basic)
|
||||
((name symbol)
|
||||
(action basic)
|
||||
(slot int8)
|
||||
(trans vector :inline)
|
||||
(normal vector :inline)
|
||||
)
|
||||
(:methods
|
||||
(debug-draw (_type_) int)
|
||||
(point-past-plane? (_type_ vector) symbol)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type border-plane
|
||||
(defmethod inspect ((this border-plane))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this (-> this type))
|
||||
(format #t "~1Tname: ~A~%" (-> this name))
|
||||
(format #t "~1Taction: ~A~%" (-> this action))
|
||||
(format #t "~1Tslot: ~D~%" (-> this slot))
|
||||
(format #t "~1Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~1Tnormal: ~`vector`P~%" (-> this normal))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type lissajous
|
||||
(deftype lissajous (structure)
|
||||
((x-mag float)
|
||||
(y-mag float)
|
||||
(theta float)
|
||||
(wx float)
|
||||
(wy float)
|
||||
(period-shift float)
|
||||
(theta-rate float)
|
||||
)
|
||||
:pack-me
|
||||
(:methods
|
||||
(lissajous-method-9 (_type_ vector) vector)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type lissajous
|
||||
(defmethod inspect ((this lissajous))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'lissajous)
|
||||
(format #t "~1Tx-mag: ~f~%" (-> this x-mag))
|
||||
(format #t "~1Ty-mag: ~f~%" (-> this y-mag))
|
||||
(format #t "~1Ttheta: ~f~%" (-> this theta))
|
||||
(format #t "~1Twx: ~f~%" (-> this wx))
|
||||
(format #t "~1Twy: ~f~%" (-> this wy))
|
||||
(format #t "~1Tperiod-shift: ~f~%" (-> this period-shift))
|
||||
(format #t "~1Ttheta-rate: ~f~%" (-> this theta-rate))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type lissajous-interp
|
||||
(deftype lissajous-interp (structure)
|
||||
((current lissajous :inline)
|
||||
(dest lissajous :inline)
|
||||
(rate lissajous :inline)
|
||||
)
|
||||
(:methods
|
||||
(lissajous-interp-method-9 (_type_ vector) vector)
|
||||
(lissajous-interp-method-10 (_type_) float)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type lissajous-interp
|
||||
(defmethod inspect ((this lissajous-interp))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'lissajous-interp)
|
||||
(format #t "~1Tcurrent: #<lissajous @ #x~X>~%" (-> this current))
|
||||
(format #t "~1Tdest: #<lissajous @ #x~X>~%" (-> this dest))
|
||||
(format #t "~1Trate: #<lissajous @ #x~X>~%" (-> this rate))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for symbol EulSafe, type (array int32)
|
||||
(define EulSafe
|
||||
"Maybe euler angle storage orders?
|
||||
What is this naming convention?"
|
||||
(new 'static 'boxed-array :type int32 0 1 2 0)
|
||||
)
|
||||
|
||||
;; definition for symbol EulNext, type (array int32)
|
||||
(define EulNext (new 'static 'boxed-array :type int32 1 2 0 1))
|
||||
|
||||
;; definition of type euler-angles
|
||||
(deftype euler-angles (vector)
|
||||
"Just uses the same xyzw and data array as vector.
|
||||
The `w` stores an integer that seems to have
|
||||
bitfields for... something? Like maybe the order?
|
||||
Euler angles are mostly unused, and the code is a bit of disaster."
|
||||
()
|
||||
)
|
||||
|
||||
;; definition for method 3 of type euler-angles
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod inspect ((this euler-angles))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'euler-angles)
|
||||
(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))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+219
@@ -0,0 +1,219 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for function set-eul!
|
||||
(defun set-eul! ((arg0 euler-angles) (arg1 float) (arg2 float) (arg3 float) (arg4 int))
|
||||
"Set euler angles and the flag bits."
|
||||
(set! (-> arg0 x) arg1)
|
||||
(set! (-> arg0 y) arg2)
|
||||
(set! (-> arg0 z) arg3)
|
||||
(set! (-> arg0 w) (the float arg4))
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function eul->matrix
|
||||
;; INFO: Used lq/sq
|
||||
(defun eul->matrix ((arg0 matrix) (arg1 euler-angles))
|
||||
"Convert from euler angles to 4x4 matrix."
|
||||
(matrix-identity! arg0)
|
||||
(let ((s5-0 (new 'stack-no-clear 'vector)))
|
||||
(set! (-> s5-0 quad) (-> arg1 quad))
|
||||
(when (= (logand (the int (-> s5-0 w)) 1) 1)
|
||||
(let ((f0-2 (-> s5-0 x)))
|
||||
(set! (-> s5-0 x) (-> s5-0 z))
|
||||
(set! (-> s5-0 z) f0-2)
|
||||
)
|
||||
)
|
||||
(when (= (logand (/ (the int (-> s5-0 w)) 4) 1) 1)
|
||||
(set! (-> s5-0 x) (- (-> s5-0 x)))
|
||||
(set! (-> s5-0 y) (- (-> s5-0 y)))
|
||||
(set! (-> s5-0 z) (- (-> s5-0 z)))
|
||||
)
|
||||
(let* ((f26-0 (cos (-> s5-0 x)))
|
||||
(f30-0 (cos (-> s5-0 y)))
|
||||
(f22-0 (cos (-> s5-0 z)))
|
||||
(f24-0 (sin (-> s5-0 x)))
|
||||
(f28-0 (sin (-> s5-0 y)))
|
||||
(f4-0 (sin (-> s5-0 z)))
|
||||
(f0-17 (* f26-0 f22-0))
|
||||
(f1-1 (* f26-0 f4-0))
|
||||
(f2-0 (* f24-0 f22-0))
|
||||
(f3-0 (* f24-0 f4-0))
|
||||
)
|
||||
0
|
||||
0
|
||||
0
|
||||
(let* ((v1-12 (logand (/ (the int (-> s5-0 w)) 4) 1))
|
||||
(a1-2 (-> EulSafe (logand (/ (the int (-> s5-0 w)) 8) 3)))
|
||||
(a0-21 (-> EulNext (+ a1-2 v1-12)))
|
||||
(v1-17 (-> EulNext (+ (- 1 v1-12) a1-2)))
|
||||
)
|
||||
(cond
|
||||
((= (logand (/ (the int (-> s5-0 w)) 2) 1) 1)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) f30-0)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0)))) (* f28-0 f24-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0)))) (* f28-0 f26-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f28-0 f4-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(- f0-17 (* f30-0 f3-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(- (- f2-0) (* f30-0 f1-1))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- (* f28-0 f22-0)))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(+ f1-1 (* f30-0 f2-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(+ (- f3-0) (* f30-0 f0-17))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f22-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(+ (- f1-1) (* f28-0 f2-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a1-2 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(+ f3-0 (* f28-0 f0-17))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a1-2 4)) (the-as int arg0)))) (* f30-0 f4-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* a0-21 4)) (the-as int arg0))))
|
||||
(+ f0-17 (* f28-0 f3-0))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* a0-21 16) (* v1-17 4)) (the-as int arg0))))
|
||||
(+ (- f2-0) (* f28-0 f1-1))
|
||||
)
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a1-2 4)) (the-as int arg0)))) (- f28-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* a0-21 4)) (the-as int arg0)))) (* f30-0 f24-0))
|
||||
(set! (-> (the-as (pointer float) (+ (+ (* v1-17 16) (* v1-17 4)) (the-as int arg0)))) (* f30-0 f26-0))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix->eul
|
||||
(defun matrix->eul ((arg0 euler-angles) (arg1 matrix) (arg2 int))
|
||||
"Convert matrix to euler angles with given order flag.
|
||||
Not clear how this works if the matrix has more than just a rotation."
|
||||
0
|
||||
0
|
||||
0
|
||||
(let* ((v1-4 (logand (/ arg2 4) 1))
|
||||
(s3-0 (-> EulSafe (logand (/ arg2 8) 3)))
|
||||
(s2-0 (-> EulNext (+ s3-0 v1-4)))
|
||||
(s1-0 (-> EulNext (+ (- 1 v1-4) s3-0)))
|
||||
)
|
||||
(cond
|
||||
((= (logand (/ arg2 2) 1) 1)
|
||||
(let* ((f0-0 (-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1)))))
|
||||
(f0-2 (* f0-0 f0-0))
|
||||
(f1-0 (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1)))))
|
||||
(f30-0 (sqrtf (+ f0-2 (* f1-0 f1-0))))
|
||||
)
|
||||
(cond
|
||||
((< 0.00000000001 f30-0)
|
||||
(set! (-> arg0 x) (atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s3-0 16)) (the-as int arg1))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s3-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))))
|
||||
(set! (-> arg0 z) (atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
(- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1)))))
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(set! (-> arg0 x) (atan
|
||||
(- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1)))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y) (atan f30-0 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))))
|
||||
(set! (-> arg0 z) 0.0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let* ((f0-21 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1)))))
|
||||
(f0-23 (* f0-21 f0-21))
|
||||
(f1-3 (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1)))))
|
||||
(f30-1 (sqrtf (+ f0-23 (* f1-3 f1-3))))
|
||||
)
|
||||
(cond
|
||||
((< 0.00000000001 f30-1)
|
||||
(set! (-> arg0 x)
|
||||
(atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s1-0 16)) (the-as int arg1))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s1-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y)
|
||||
(atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1)
|
||||
)
|
||||
(set! (-> arg0 z) (atan
|
||||
(-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s3-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(set! (-> arg0 x)
|
||||
(atan
|
||||
(- (-> (the-as (pointer float) (+ (+ (* s1-0 4) (* s2-0 16)) (the-as int arg1)))))
|
||||
(-> (the-as (pointer float) (+ (+ (* s2-0 4) (* s2-0 16)) (the-as int arg1))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 y)
|
||||
(atan (- (-> (the-as (pointer float) (+ (+ (* s3-0 4) (* s1-0 16)) (the-as int arg1))))) f30-1)
|
||||
)
|
||||
(set! (-> arg0 z) 0.0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (= (logand (/ arg2 4) 1) 1)
|
||||
(set! (-> arg0 x) (- (-> arg0 x)))
|
||||
(set! (-> arg0 y) (- (-> arg0 y)))
|
||||
(set! (-> arg0 z) (- (-> arg0 z)))
|
||||
)
|
||||
(when (= (logand arg2 1) 1)
|
||||
(let ((f0-49 (-> arg0 x)))
|
||||
(set! (-> arg0 x) (-> arg0 z))
|
||||
(set! (-> arg0 z) f0-49)
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 w) (the float arg2))
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function eul->quat
|
||||
(defun eul->quat ((arg0 quaternion) (arg1 euler-angles))
|
||||
"Convert euler angles to quaternion, not very efficient."
|
||||
(let ((s5-0 (new 'stack-no-clear 'matrix)))
|
||||
(eul->matrix s5-0 arg1)
|
||||
(matrix->quaternion arg0 s5-0)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function quat->eul
|
||||
(defun quat->eul ((arg0 euler-angles) (arg1 quaternion) (arg2 int))
|
||||
"Convert quaternion to euler angles with given order, not very efficient."
|
||||
(let ((s5-0 (new 'stack-no-clear 'matrix)))
|
||||
(quaternion->matrix s5-0 arg1)
|
||||
(matrix->eul arg0 s5-0 arg2)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+771
@@ -0,0 +1,771 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for function truncate
|
||||
(defun truncate ((arg0 float))
|
||||
"Round (toward zero) to an integer.
|
||||
@param arg0 float to truncate"
|
||||
(the float (the int arg0))
|
||||
)
|
||||
|
||||
;; definition for function round
|
||||
(defun round ((arg0 float))
|
||||
"Round to the nearest integer"
|
||||
(the float (the int (+ 0.5 arg0)))
|
||||
)
|
||||
|
||||
;; definition for function floor
|
||||
(defun floor ((arg0 float))
|
||||
"Round (down) to an integer"
|
||||
(let ((f0-3 (the float (the int arg0))))
|
||||
(if (or (>= arg0 0.0) (= arg0 f0-3))
|
||||
f0-3
|
||||
(+ -1.0 f0-3)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function ceil
|
||||
(defun ceil ((arg0 float))
|
||||
"Round (up) to an integer"
|
||||
(let ((f0-3 (the float (the int arg0))))
|
||||
(if (or (>= 0.0 arg0) (= arg0 f0-3))
|
||||
f0-3
|
||||
(+ 1.0 f0-3)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function integral?
|
||||
(defun integral? ((arg0 float))
|
||||
"Is this number an integer?"
|
||||
(= (the float (the int arg0)) arg0)
|
||||
)
|
||||
|
||||
;; definition for function fractional-part
|
||||
(defun fractional-part ((arg0 float))
|
||||
"Get the fractional part of a float."
|
||||
(- arg0 (the float (the int arg0)))
|
||||
)
|
||||
|
||||
;; definition for function odd?
|
||||
(defun odd? ((arg0 int))
|
||||
"Is the number odd?"
|
||||
(= (logand arg0 1) 1)
|
||||
)
|
||||
|
||||
;; definition for function even?
|
||||
(defun even? ((arg0 int))
|
||||
"Is the number even?"
|
||||
(not (odd? arg0))
|
||||
)
|
||||
|
||||
;; definition for function sawtooth-wave
|
||||
(defun sawtooth-wave ((arg0 float))
|
||||
"Sample a sawtooth with period 1. In range (0, 1)"
|
||||
(let ((f0-2 (- arg0 (the float (the int arg0)))))
|
||||
(if (< f0-2 0.0)
|
||||
(set! f0-2 (+ 1.0 f0-2))
|
||||
)
|
||||
f0-2
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function triangle-wave
|
||||
(defun triangle-wave ((arg0 float))
|
||||
"Sample a triangle wave. Period is 4, in range (-1, 1) (so slope is 1 or -1)."
|
||||
(let* ((f0-1 (* 0.25 (+ -1.0 arg0)))
|
||||
(f0-3 (- f0-1 (the float (the int f0-1))))
|
||||
)
|
||||
(if (< f0-3 0.0)
|
||||
(set! f0-3 (+ 1.0 f0-3))
|
||||
)
|
||||
(+ -1.0 (fabs (+ -2.0 (* 4.0 f0-3))))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function log-x-plus-1-order9
|
||||
(defun log-x-plus-1-order9 ((arg0 float))
|
||||
"Fast approximation of ln(x + 1). Probably only accurate for x in [0, 1]."
|
||||
(* arg0
|
||||
(+ 1.0
|
||||
(* arg0
|
||||
(+ -0.5
|
||||
(* arg0
|
||||
(+ 0.33333334
|
||||
(* arg0
|
||||
(+ -0.25
|
||||
(* arg0 (+ 0.2 (* arg0 (+ -0.16666666 (* arg0 (+ 0.14285715 (* arg0 (+ -0.125 (* 0.11111111 arg0)))))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function logf
|
||||
(defun logf ((arg0 float))
|
||||
"Natural log."
|
||||
(let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126)))
|
||||
(a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0)))))
|
||||
)
|
||||
(when (< (the-as float (gpr->fpr (the-as int a0-2))) 0.70710677)
|
||||
(set! a0-2 (+ (the-as float (gpr->fpr (the-as int a0-2))) (the-as float (gpr->fpr (the-as int a0-2)))))
|
||||
(set! v1-1 (the-as int (+ (the-as uint v1-1) -1)))
|
||||
)
|
||||
(let ((f0-5 (+ -1.0 (the-as float (gpr->fpr a0-2)))))
|
||||
(+ (* f0-5
|
||||
(+ 1.0
|
||||
(* f0-5
|
||||
(+ -0.5
|
||||
(* f0-5
|
||||
(+ 0.33333334
|
||||
(* f0-5
|
||||
(+ -0.25
|
||||
(* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (* 0.11111111 f0-5)))))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(* 0.6931472 (the float v1-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function log2f
|
||||
(defun log2f ((arg0 float))
|
||||
"Log base 2."
|
||||
(let ((v1-1 (the-as int (+ (shr (the-as int arg0) 23) -126)))
|
||||
(a0-2 (the-as number (logior #x3f000000 (logand (the-as uint #x807fffff) (the-as uint arg0)))))
|
||||
)
|
||||
(when (< (the-as float (gpr->fpr (the-as int a0-2))) 0.70710677)
|
||||
(set! a0-2 (+ (the-as float (gpr->fpr (the-as int a0-2))) (the-as float (gpr->fpr (the-as int a0-2)))))
|
||||
(set! v1-1 (the-as int (+ (the-as uint v1-1) -1)))
|
||||
)
|
||||
(let* ((f0-5 (+ -1.0 (the-as float (gpr->fpr a0-2))))
|
||||
(f0-7
|
||||
(* f0-5
|
||||
(+ 1.0
|
||||
(* f0-5
|
||||
(+ -0.5
|
||||
(* f0-5
|
||||
(+ 0.33333334
|
||||
(* f0-5
|
||||
(+ -0.25
|
||||
(* f0-5 (+ 0.2 (* f0-5 (+ -0.16666666 (* f0-5 (+ 0.14285715 (* f0-5 (+ -0.125 (* 0.11111111 f0-5)))))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(+ (* 1.442695 f0-7) (the float v1-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition of type float-type
|
||||
(deftype float-type (uint32)
|
||||
()
|
||||
)
|
||||
|
||||
;; definition for symbol exp-slead, type (pointer float)
|
||||
(define exp-slead (new 'static 'array float 32
|
||||
1.0
|
||||
1.0218964
|
||||
1.0442734
|
||||
1.0671387
|
||||
1.0905075
|
||||
1.1143799
|
||||
1.1387863
|
||||
1.1637192
|
||||
1.1892014
|
||||
1.2152405
|
||||
1.2418518
|
||||
1.2690506
|
||||
1.2968369
|
||||
1.3252335
|
||||
1.354248
|
||||
1.3839035
|
||||
1.4142075
|
||||
1.4451752
|
||||
1.4768219
|
||||
1.5091629
|
||||
1.5422058
|
||||
1.5759735
|
||||
1.6104889
|
||||
1.645752
|
||||
1.6817856
|
||||
1.7186127
|
||||
1.7562485
|
||||
1.7947083
|
||||
1.8340073
|
||||
1.8741608
|
||||
1.9151993
|
||||
1.9571381
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for symbol exp-strail, type (pointer float)
|
||||
(define exp-strail (new 'static 'array float 32
|
||||
0.0
|
||||
0.0000007863494
|
||||
0.00000040596257
|
||||
0.0000017288019
|
||||
0.00000022534104
|
||||
0.0000068597833
|
||||
0.0000023188388
|
||||
0.0000056815315
|
||||
0.0000057600223
|
||||
0.0000068814647
|
||||
0.000006005433
|
||||
0.0000003590472
|
||||
0.0000027016238
|
||||
0.000003183687
|
||||
0.000007500062
|
||||
0.000006378546
|
||||
0.000006103877
|
||||
0.0000056360786
|
||||
0.0000042465254
|
||||
0.0000015247614
|
||||
0.000005014861
|
||||
0.000007334366
|
||||
0.0000014403477
|
||||
0.000003525029
|
||||
0.000007247011
|
||||
0.000006627224
|
||||
0.0000036862523
|
||||
0.00000082304996
|
||||
0.0000008232258
|
||||
0.0000068675085
|
||||
0.000007281612
|
||||
0.000006062652
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function exp
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function pow
|
||||
(defun pow ((arg0 float) (arg1 float))
|
||||
"Compute arg0^arg1"
|
||||
(exp (* arg1 (logf arg0)))
|
||||
)
|
||||
|
||||
;; definition for function print-exp
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defun print-exp ((arg0 float))
|
||||
"Print in the format AeB where A is in the range (1, 10)"
|
||||
(let* ((f30-1 (floor (/ (logf (fabs arg0)) (logf 10.0))))
|
||||
(f0-4 (pow 10.0 f30-1))
|
||||
)
|
||||
(format #t "~fe~d" (/ arg0 f0-4) (the int f30-1))
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition of type rgba
|
||||
(deftype rgba (uint32)
|
||||
()
|
||||
)
|
||||
|
||||
;; definition of type xyzw
|
||||
(deftype xyzw (uint128)
|
||||
()
|
||||
)
|
||||
|
||||
;; definition of type xyzwh
|
||||
(deftype xyzwh (uint128)
|
||||
()
|
||||
)
|
||||
|
||||
;; definition for function print-time
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defun print-time ((arg0 object) (arg1 time-frame))
|
||||
"Print a [[time-frame]] as h:mm:ss."
|
||||
0
|
||||
0
|
||||
0
|
||||
(let* ((f0-1 (* 0.0033333334 (the float arg1)))
|
||||
(a2-0 (the int (* 0.016666668 f0-1)))
|
||||
(f0-2 (- f0-1 (* 60.0 (the float a2-0))))
|
||||
(a3-0 (the int f0-2))
|
||||
(f0-3 (- f0-2 (the float a3-0)))
|
||||
(t0-0 (the int (* 100.0 f0-3)))
|
||||
)
|
||||
(format arg0 "~d:~2,'0,d:~2,'0,d" a2-0 a3-0 t0-0)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for function log2
|
||||
;; WARN: Return type mismatch uint vs int.
|
||||
(defun log2 ((arg0 int))
|
||||
"Log base 2."
|
||||
(the-as int (+ (sar (the-as int (the float arg0)) 23) -127))
|
||||
)
|
||||
|
||||
;; definition for function seek
|
||||
(defun seek ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Move arg0 toward arg1 by at most arg2."
|
||||
(let ((f2-0 (- arg1 arg0)))
|
||||
(cond
|
||||
((>= arg2 (fabs f2-0))
|
||||
arg1
|
||||
)
|
||||
((>= f2-0 0.0)
|
||||
(+ arg0 arg2)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function seek-ease
|
||||
(defun seek-ease ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Move arg0 toward arg1, and slow down before reaching the end.
|
||||
When farther than arg3 away, move by at most arg2.
|
||||
When closer than arg3, linearly ramp down the movement amount from arg2 to 0 but no lower than arg4."
|
||||
(let ((f2-0 (- arg1 arg0)))
|
||||
(when (>= arg3 (fabs f2-0))
|
||||
(set! arg2 (* arg2 (- 1.0 (/ (- arg3 (fabs f2-0)) arg3))))
|
||||
(if (< arg2 arg4)
|
||||
(set! arg2 arg4)
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((>= arg2 (fabs f2-0))
|
||||
arg1
|
||||
)
|
||||
((>= f2-0 0.0)
|
||||
(+ arg0 arg2)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function seek-ease-in-out
|
||||
(defun seek-ease-in-out ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float) (arg5 float) (arg6 float))
|
||||
"Move arg0 toward arg2, and slow down at the start and end.
|
||||
When within arg4 of arg1 (at the beginning of movement), ramp up speed, with a minimum speed of arg6
|
||||
When within arg5 of arg2 (at the end of movement), ramp down speed, with a minimum speed of arg5
|
||||
Normally, move at most arg3"
|
||||
(let ((f2-0 (- arg2 arg0)))
|
||||
(let ((f4-1 (- arg0 arg1)))
|
||||
(when (>= arg4 (fabs f4-1))
|
||||
(set! arg3 (* arg3 (- 1.0 (/ (- arg4 (fabs f4-1)) arg4))))
|
||||
(if (< arg3 arg6)
|
||||
(set! arg3 arg6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (>= arg5 (fabs f2-0))
|
||||
(set! arg3 (* arg3 (- 1.0 (/ (- arg5 (fabs f2-0)) arg5))))
|
||||
(if (< arg3 arg6)
|
||||
(set! arg3 arg6)
|
||||
)
|
||||
)
|
||||
(cond
|
||||
((>= arg3 (fabs f2-0))
|
||||
arg2
|
||||
)
|
||||
((>= f2-0 0.0)
|
||||
(+ arg0 arg3)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function lerp
|
||||
(defun lerp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Linearly interpolate between arg0 and arg1."
|
||||
(+ arg0 (* arg2 (- arg1 arg0)))
|
||||
)
|
||||
|
||||
;; definition (debug) for function lerp-scale-old
|
||||
(defun-debug lerp-scale-old ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Linearly remap arg2 in [arg3, arg4] to [arg0, arg1].
|
||||
This is the jak 1 implementation, which I claimed was a bad implementation..."
|
||||
(let ((f0-1 (fmax 0.0 (fmin 1.0 (/ (- arg2 arg3) (- arg4 arg3))))))
|
||||
(+ (* (- 1.0 f0-1) arg0) (* f0-1 arg1))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function lerp-scale
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [mula.s f0, f2]
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [madd.s f0, f1, f3]
|
||||
(defun lerp-scale ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Linearly remap arg2 in [arg3, arg4] to [arg0, arg1].
|
||||
More efficient than the -old version."
|
||||
(local-vars (f0-2 float))
|
||||
(let* ((v1-0 1.0)
|
||||
(f1-0 0.0)
|
||||
(f0-0 v1-0)
|
||||
(f4-0 arg2)
|
||||
(f2-0 arg3)
|
||||
(f3-0 arg4)
|
||||
(f1-2 (fmin (fmax (/ (- f4-0 f2-0) (- f3-0 f2-0)) f1-0) f0-0))
|
||||
(f0-1 (- f0-0 f1-2))
|
||||
(f2-3 arg0)
|
||||
(f3-1 arg1)
|
||||
)
|
||||
(.mula.s f0-1 f2-3)
|
||||
(.madd.s f0-2 f1-2 f3-1)
|
||||
)
|
||||
f0-2
|
||||
)
|
||||
|
||||
;; definition for function lerp-scale-clamp
|
||||
(defun lerp-scale-clamp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Clamp the input, then linearly remap arg2 in [arg3, arg4] to [arg0, arg1]."
|
||||
(let ((a2-1 (fmax (fmin arg2 arg4) arg3)))
|
||||
(lerp-scale arg0 arg1 a2-1 arg3 arg4)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function lerp-clamp
|
||||
(defun lerp-clamp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Linearly interpolate between arg0 and arg1. arg2 is clamped to [0, 1]"
|
||||
(cond
|
||||
((>= 0.0 arg2)
|
||||
arg0
|
||||
)
|
||||
((>= arg2 1.0)
|
||||
arg1
|
||||
)
|
||||
(else
|
||||
(+ (* (- 1.0 arg2) arg0) (* arg2 arg1))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function rgba-lerp
|
||||
;; WARN: Return type mismatch int vs rgba.
|
||||
(defun rgba-lerp ((arg0 rgba) (arg1 rgba) (arg2 rgba))
|
||||
(local-vars
|
||||
(v0-0 uint128)
|
||||
(v1-0 uint128)
|
||||
(v1-1 uint128)
|
||||
(a0-1 uint128)
|
||||
(a0-2 uint128)
|
||||
(a1-1 uint128)
|
||||
(a2-1 uint128)
|
||||
)
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.pextlb v1-0 0 arg0)
|
||||
(.pextlb a0-1 0 arg1)
|
||||
(.pextlh v1-1 0 v1-0)
|
||||
(.pextlh a0-2 0 a0-1)
|
||||
(.mov vf1 v1-1)
|
||||
(.mov vf2 a0-2)
|
||||
(.mov vf3 arg2)
|
||||
(.itof.vf vf1 vf1)
|
||||
(.itof.vf vf2 vf2)
|
||||
(.mul.w.vf acc vf1 vf0)
|
||||
(.add.mul.x.vf acc vf2 vf3 acc)
|
||||
(.sub.mul.x.vf vf1 vf1 vf3 acc)
|
||||
(.ftoi.vf vf3 vf1)
|
||||
(.mov a1-1 vf3)
|
||||
(.ppach a2-1 (the-as uint128 0) a1-1)
|
||||
(.ppacb v0-0 (the-as uint128 0) a2-1)
|
||||
(the-as rgba v0-0)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function seekl
|
||||
(defun seekl ((arg0 int) (arg1 int) (arg2 int))
|
||||
"Move arg0 toward arg1, by at most arg2."
|
||||
(let* ((v1-0 (- arg1 arg0))
|
||||
(a3-0 (abs v1-0))
|
||||
)
|
||||
(cond
|
||||
((>= arg2 a3-0)
|
||||
arg1
|
||||
)
|
||||
((>= v1-0 0)
|
||||
(+ arg0 arg2)
|
||||
)
|
||||
(else
|
||||
(- arg0 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-init
|
||||
;; WARN: Return type mismatch int vs float.
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [ctc2.i vi_R, a0]
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v0, vi_R]
|
||||
(defun rand-vu-init ((arg0 float))
|
||||
"Initialize the VU0 random generator."
|
||||
(local-vars (v0-0 int))
|
||||
(.ctc2.i vi_R arg0)
|
||||
(.cfc2.i v0-0 vi_R)
|
||||
(the-as float v0-0)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(rand-vu-init 1.418091)
|
||||
|
||||
;; definition for function rand-vu
|
||||
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRGET]
|
||||
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRXOR]
|
||||
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRNEXT]
|
||||
(defun rand-vu ()
|
||||
"Get a random number in [0, 1) and advance the random generator."
|
||||
(local-vars (v0-0 float))
|
||||
(rlet ((Q :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(TODO.VRGET vf1)
|
||||
(.sqrt.vf Q vf1 :ftf #b0)
|
||||
(.add.vf vf2 vf0 Q :mask #b1)
|
||||
(TODO.VRXOR vf2)
|
||||
(TODO.VRNEXT vf1)
|
||||
(.sub.w.vf vf1 vf1 vf0)
|
||||
(.mov v0-0 vf1)
|
||||
v0-0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-nostep
|
||||
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRGET]
|
||||
(defun rand-vu-nostep ()
|
||||
"Get the number currently in the random generator.
|
||||
This will be equal to the last call of (rand-vu).
|
||||
This will not update the random generator."
|
||||
(local-vars (v0-0 float))
|
||||
(rlet ((vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(TODO.VRGET vf1)
|
||||
(.sub.w.vf vf1 vf1 vf0)
|
||||
(.mov v0-0 vf1)
|
||||
v0-0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-float-range
|
||||
(defun rand-vu-float-range ((arg0 float) (arg1 float))
|
||||
"Get a random float in between arg0 and arg1."
|
||||
(+ arg0 (* (rand-vu) (- arg1 arg0)))
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-percent?
|
||||
(defun rand-vu-percent? ((arg0 float))
|
||||
"Get a boolean that's true with the given probability (in 0, 1)."
|
||||
(>= arg0 (rand-vu))
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-int-range
|
||||
(defun rand-vu-int-range ((arg0 int) (arg1 int))
|
||||
"Get an integer in the given range (inclusive)."
|
||||
(if (< arg0 arg1)
|
||||
(set! arg1 (+ arg1 1))
|
||||
(set! arg0 (+ arg0 1))
|
||||
)
|
||||
(let ((f0-4 (rand-vu-float-range (the float arg0) (the float arg1))))
|
||||
(if (< f0-4 0.0)
|
||||
(set! f0-4 (+ -1.0 f0-4))
|
||||
)
|
||||
(the int f0-4)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-int-count
|
||||
(defun rand-vu-int-count ((arg0 int))
|
||||
"Get an integer in the range [0, max)."
|
||||
(the int (* (rand-vu) (the float arg0)))
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-int-count-excluding
|
||||
;; WARN: new jak 2 until loop case, check carefully
|
||||
(defun rand-vu-int-count-excluding ((arg0 int) (arg1 int))
|
||||
"Get an integer in the range [0, arg0).
|
||||
If bit n is set in arg1, exclude this value from being returned."
|
||||
(let ((s4-0 0)
|
||||
(s5-0 0)
|
||||
)
|
||||
(let ((v1-0 1))
|
||||
(while (nonzero? arg0)
|
||||
(+! arg0 -1)
|
||||
(if (not (logtest? arg1 v1-0))
|
||||
(+! s4-0 1)
|
||||
)
|
||||
(set! v1-0 (* v1-0 2))
|
||||
)
|
||||
)
|
||||
(when (> s4-0 0)
|
||||
(let ((v1-4 (the int (* (rand-vu) (the float s4-0))))
|
||||
(a0-1 1)
|
||||
)
|
||||
(until #f
|
||||
(while (logtest? arg1 a0-1)
|
||||
(nop!)
|
||||
(nop!)
|
||||
(+! s5-0 1)
|
||||
(set! a0-1 (* a0-1 2))
|
||||
)
|
||||
(if (zero? v1-4)
|
||||
(goto cfg-14)
|
||||
)
|
||||
(+! v1-4 -1)
|
||||
(+! s5-0 1)
|
||||
(set! a0-1 (* a0-1 2))
|
||||
)
|
||||
)
|
||||
#f
|
||||
)
|
||||
(label cfg-14)
|
||||
s5-0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function rand-vu-int-range-exclude
|
||||
;; WARN: new jak 2 until loop case, check carefully
|
||||
(defun rand-vu-int-range-exclude ((arg0 int) (arg1 int) (arg2 int))
|
||||
"Get an integer in the range [0, arg0), excluding arg2.
|
||||
Note that this doesn't use bits like rand-vu-int-count-excluding."
|
||||
(until #f
|
||||
(let ((v1-0 (rand-vu-int-range arg0 arg1)))
|
||||
(if (!= v1-0 arg2)
|
||||
(return v1-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the-as int #f)
|
||||
)
|
||||
|
||||
;; definition of type random-generator
|
||||
(deftype random-generator (basic)
|
||||
((seed uint32)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type random-generator
|
||||
(defmethod inspect ((this random-generator))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this (-> this type))
|
||||
(format #t "~1Tseed: ~D~%" (-> this seed))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for symbol *random-generator*, type random-generator
|
||||
(define *random-generator* (new 'global 'random-generator))
|
||||
|
||||
;; failed to figure out what this is:
|
||||
(set! (-> *random-generator* seed) (the-as uint #x666edd1e))
|
||||
|
||||
;; definition for function rand-uint31-gen
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function cube-root
|
||||
(defun cube-root ((arg0 float))
|
||||
"Cube root with cool trick that I don't understand."
|
||||
(cond
|
||||
((!= arg0 0.0)
|
||||
(let* ((v1-0 arg0)
|
||||
(a1-2 (+ (logand (shr (the-as int v1-0) 23) 255) -127))
|
||||
(f0-1
|
||||
(the-as
|
||||
number
|
||||
(gpr->fpr
|
||||
(logior (logand (the-as uint #x807fffff) (the-as uint v1-0)) (shl (+ (/ (the-as int a1-2) 3) 127) 23))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(dotimes (v1-3 6)
|
||||
(set! f0-1 (- (the-as float f0-1)
|
||||
(/ (- (* (the-as float (* (the-as float f0-1) (the-as float f0-1))) (the-as float f0-1)) arg0)
|
||||
(* 3.0 (the-as float f0-1) (the-as float f0-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the-as float f0-1)
|
||||
)
|
||||
)
|
||||
(else
|
||||
0.0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function int-noise
|
||||
(defun int-noise ((arg0 int))
|
||||
"Generate random-ish floats in range -1, 1."
|
||||
(let ((v1-1 (logxor (shl arg0 13) arg0)))
|
||||
(- 1.0 (* 0.0000000009313226
|
||||
(the float (logand #x7fffffff (+ #x5208dd0d (* v1-1 (+ #xc0ae5 (* (* #x3d73 v1-1) v1-1))))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function smooth-step
|
||||
(defun smooth-step ((arg0 float))
|
||||
"Interpolate between 0, 1 with a cubic polynomial.
|
||||
These are picked so f(0) = 0, f(1) = 1, f'(0) = f'(1) = 0."
|
||||
(cond
|
||||
((>= 0.0 arg0)
|
||||
0.0
|
||||
)
|
||||
((>= arg0 1.0)
|
||||
1.0
|
||||
)
|
||||
(else
|
||||
(* arg0 arg0 (+ 3.0 (* -2.0 arg0)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function smooth-interp
|
||||
(defun smooth-interp ((arg0 float) (arg1 float) (arg2 float) (arg3 float) (arg4 float))
|
||||
"Remap arg2 from (arg3, arg4) to (arg0, arg1), using cubic interpolation.
|
||||
Satisfies:
|
||||
- f(arg3) = arg0
|
||||
- f(arg4) = arg1
|
||||
- f'(arg3) = f'(arg4) = 0"
|
||||
(+ arg0 (* (- arg1 arg0) (smooth-step (/ (- arg2 arg3) (- arg4 arg3)))))
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for function matrix-fur-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-fur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg3 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg2 quad))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-fu-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-fu-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg2 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg2 arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-fr-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-fr-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(set! (-> arg0 rvec quad) (-> arg2 quad))
|
||||
(vector-cross! (-> arg0 uvec) arg1 arg2)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-ur-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-ur-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg2 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 fvec) arg1 arg2)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-f-u-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-f-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 rvec) 1.0)
|
||||
(vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec))
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-f-r-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-f-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 uvec) arg1 arg2)
|
||||
(vector-normalize! (-> arg0 uvec) 1.0)
|
||||
(vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-u-f-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-u-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg1 arg2)
|
||||
(vector-normalize! (-> arg0 rvec) 1.0)
|
||||
(vector-cross! (-> arg0 fvec) (-> arg0 rvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-u-r-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-u-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 fvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 fvec) 1.0)
|
||||
(vector-cross! (-> arg0 rvec) arg1 (-> arg0 fvec))
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-r-f-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-r-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 uvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 uvec) 1.0)
|
||||
(vector-cross! (-> arg0 fvec) arg1 (-> arg0 uvec))
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-r-u-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-r-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 fvec) arg1 arg2)
|
||||
(vector-normalize! (-> arg0 fvec) 1.0)
|
||||
(vector-cross! (-> arg0 uvec) (-> arg0 fvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-f-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-f-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(matrix-f-u-compose arg0 arg1 a2-1 arg3)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-u-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-u-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 uvec quad) (-> arg1 quad))
|
||||
(let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(matrix-u-f-compose arg0 arg1 a2-1 arg3)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix-r-compose
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-r-compose ((arg0 matrix) (arg1 vector) (arg2 vector) (arg3 vector))
|
||||
(set! (-> arg0 rvec quad) (-> arg1 quad))
|
||||
(let ((a2-1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(matrix-r-f-compose arg0 arg1 a2-1 arg3)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type matrix
|
||||
(deftype matrix (structure)
|
||||
"A 4x4 matrix, stored in row-major order.
|
||||
some, but not all, functions assume that a matrix is an affine transform.
|
||||
others assume that the rotation has no scale or shear (and that its inverse is its transpose)."
|
||||
((data float 16)
|
||||
(vector vector 4 :overlay-at (-> data 0))
|
||||
(quad uint128 4 :overlay-at (-> data 0))
|
||||
(rvec vector :inline :overlay-at (-> data 0))
|
||||
(uvec vector :inline :overlay-at (-> data 4))
|
||||
(fvec vector :inline :overlay-at (-> data 8))
|
||||
(trans vector :inline :overlay-at (-> data 12))
|
||||
)
|
||||
(:methods
|
||||
(transform-vectors! (_type_ (inline-array vector) (inline-array vector) int) none)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type matrix
|
||||
(defmethod inspect ((this matrix))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'matrix)
|
||||
(format #t "~1Tdata[16] @ #x~X~%" (-> this rvec))
|
||||
(format #t "~1Tvector[4] @ #x~X~%" (-> this rvec))
|
||||
(format #t "~1Tquad[4] @ #x~X~%" (-> this rvec))
|
||||
(format #t "~1Trvec: #<vector @ #x~X>~%" (-> this rvec))
|
||||
(format #t "~1Tuvec: #<vector @ #x~X>~%" (-> this uvec))
|
||||
(format #t "~1Tfvec: #<vector @ #x~X>~%" (-> this fvec))
|
||||
(format #t "~1Ttrans: #<vector @ #x~X>~%" (-> this trans))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type matrix3
|
||||
(deftype matrix3 (structure)
|
||||
"A 3x3 matrix, stored in row-major order.
|
||||
NOTE: the rows each have an extra 4-bytes of padding,
|
||||
so this is really a 3x4 matrix.
|
||||
This type is rarely used."
|
||||
((data float 12)
|
||||
(vector vector 3 :inline :overlay-at (-> data 0))
|
||||
(quad uint128 3 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type matrix3
|
||||
(defmethod inspect ((this matrix3))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'matrix3)
|
||||
(format #t "~1Tdata[12] @ #x~X~%" (-> this vector))
|
||||
(format #t "~1Tvector[3] @ #x~X~%" (-> this vector))
|
||||
(format #t "~1Tquad[3] @ #x~X~%" (-> this vector))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type matrix4h
|
||||
(deftype matrix4h (structure)
|
||||
"A matrix stored using 16-bit integers.
|
||||
Note that these usually have different scaling for the 4th row which
|
||||
contains the translation in an affine transform.
|
||||
So you generally should not unpack these to floats without knowing where they came from
|
||||
and how they were originally packed (for example, in tie/shrub)."
|
||||
((data int16 16)
|
||||
(vector4h vector4h 4 :overlay-at (-> data 0))
|
||||
(long int64 4 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type matrix4h
|
||||
(defmethod inspect ((this matrix4h))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'matrix4h)
|
||||
(format #t "~1Tdata[16] @ #x~X~%" (-> this vector4h))
|
||||
(format #t "~1Tvector4h[4] @ #x~X~%" (-> this vector4h))
|
||||
(format #t "~1Tlong[4] @ #x~X~%" (-> this vector4h))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for function matrix-copy!
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix-copy! ((arg0 matrix) (arg1 matrix))
|
||||
"Copy arg1 to arg0"
|
||||
(let ((v1-0 (-> arg1 rvec quad))
|
||||
(a2-0 (-> arg1 uvec quad))
|
||||
(a3-0 (-> arg1 fvec quad))
|
||||
(a1-1 (-> arg1 trans quad))
|
||||
)
|
||||
(set! (-> arg0 rvec quad) v1-0)
|
||||
(set! (-> arg0 uvec quad) a2-0)
|
||||
(set! (-> arg0 fvec quad) a3-0)
|
||||
(set! (-> arg0 trans quad) a1-1)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix<-vector-yz-exact!
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix<-vector-yz-exact! ((arg0 matrix) (arg1 vector) (arg2 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(set! (-> arg0 uvec quad) (-> arg2 quad))
|
||||
(vector-cross! (-> arg0 rvec) (-> arg0 uvec) arg1)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix<-vector-yz!
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix<-vector-yz! ((arg0 matrix) (arg1 vector) (arg2 vector))
|
||||
(set! (-> arg0 fvec quad) (-> arg1 quad))
|
||||
(vector-cross! (-> arg0 rvec) arg2 arg1)
|
||||
(vector-normalize! (-> arg0 rvec) 1.0)
|
||||
(vector-cross! (-> arg0 uvec) arg1 (-> arg0 rvec))
|
||||
(set! (-> arg0 rvec w) 1.0)
|
||||
(set! (-> arg0 uvec w) 1.0)
|
||||
(set! (-> arg0 fvec w) 1.0)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for function matrix<-vector-z!
|
||||
;; INFO: Used lq/sq
|
||||
(defun matrix<-vector-z! ((arg0 matrix) (arg1 vector))
|
||||
(let* ((s3-0 (new 'stack-no-clear 'vector))
|
||||
(v1-0 (vector-get-closest-perpendicular! s3-0 arg1 (vector-get-unique! (new 'stack-no-clear 'vector) arg1)))
|
||||
(s4-1 arg0)
|
||||
)
|
||||
(set! (-> s4-1 fvec quad) (-> arg1 quad))
|
||||
(set! (-> s4-1 uvec quad) (-> v1-0 quad))
|
||||
(vector-cross! (-> s4-1 rvec) (-> s4-1 uvec) arg1)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+1907
File diff suppressed because it is too large
Load Diff
+44
@@ -0,0 +1,44 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type quaternion
|
||||
(deftype quaternion (structure)
|
||||
"Quaternion. Stored in xyzw order."
|
||||
((data float 4)
|
||||
(x float :overlay-at (-> data 0))
|
||||
(y float :overlay-at (-> data 1))
|
||||
(z float :overlay-at (-> data 2))
|
||||
(w float :overlay-at (-> data 3))
|
||||
(vec vector :inline :overlay-at (-> data 0))
|
||||
(quad uint128 :overlay-at (-> data 0))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type quaternion
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod inspect ((this quaternion))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'quaternion)
|
||||
(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 "~1Tvec: #<vector @ #x~X>~%" (&-> this x))
|
||||
(format #t "~1Tquad: ~D~%" (-> this quad))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for symbol *unity-quaternion*, type quaternion
|
||||
(define *unity-quaternion* (new 'static 'quaternion :w 1.0))
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+1092
File diff suppressed because it is too large
Load Diff
+63
@@ -0,0 +1,63 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type transform
|
||||
(deftype transform (structure)
|
||||
"Transformation. w components of vectors should be 1.0
|
||||
This can represent any rotation, translation, and scaling.
|
||||
Note that the scaling is applied before rotation
|
||||
(meaning it scales along the axes of the pre-transformed frame)."
|
||||
((trans vector :inline)
|
||||
(rot vector :inline)
|
||||
(scale vector :inline)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type transform
|
||||
(defmethod inspect ((this transform))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'transform)
|
||||
(format #t "~1Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~1Trot: ~`vector`P~%" (-> this rot))
|
||||
(format #t "~1Tscale: ~`vector`P~%" (-> this scale))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type trs
|
||||
(deftype trs (basic)
|
||||
"Like transform, but it's a basic.
|
||||
Note that the trsq child type overrides this rotation with a quaternion.
|
||||
usage of the plain trs is very limited, at least in Jak 1."
|
||||
((trans vector :inline)
|
||||
(rot vector :inline)
|
||||
(scale vector :inline)
|
||||
)
|
||||
(:methods
|
||||
(new (symbol type) _type_)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type trs
|
||||
(defmethod inspect ((this trs))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this (-> this type))
|
||||
(format #t "~1Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~1Trot: ~`vector`P~%" (-> this rot))
|
||||
(format #t "~1Tscale: ~`vector`P~%" (-> this scale))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 2 of type transform
|
||||
(defmethod print ((this transform))
|
||||
(format #t "#<transform @ #x~X~%" this)
|
||||
(format #t "~T~Ttrans:~F ~F ~F ~F ~%" (-> this trans x) (-> this trans y) (-> this trans z) (-> this trans w))
|
||||
(format #t "~T~Trot: ~F ~F ~F ~F ~%" (-> this rot x) (-> this rot y) (-> this rot z) (-> this rot w))
|
||||
(format #t "~T~Tscale:~F ~F ~F ~F>" (-> this scale x) (-> this scale y) (-> this scale z) (-> this scale w))
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 0 of type trs
|
||||
(defmethod new trs ((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 trans w) 1.0)
|
||||
(set! (-> gp-0 rot w) 1.0)
|
||||
(vector-identity! (-> gp-0 scale))
|
||||
gp-0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function transform-matrix-calc!
|
||||
;; INFO: Used lq/sq
|
||||
(defun transform-matrix-calc! ((arg0 transform) (arg1 matrix))
|
||||
"Convert a transform to matrix. Not efficient, and the output is the second arg."
|
||||
(let ((s4-0 (new 'stack-no-clear 'matrix)))
|
||||
(set! (-> s4-0 rvec quad) (the-as uint128 0))
|
||||
(set! (-> s4-0 uvec quad) (the-as uint128 0))
|
||||
(set! (-> s4-0 fvec quad) (the-as uint128 0))
|
||||
(set! (-> s4-0 trans quad) (the-as uint128 0))
|
||||
(let ((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))
|
||||
(matrix-identity! arg1)
|
||||
(matrix-translate! arg1 (-> arg0 trans))
|
||||
(matrix-rotate-y! s4-0 (-> arg0 rot y))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-rotate-x! s4-0 (-> arg0 rot x))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
(matrix-rotate-z! s4-0 (-> arg0 rot z))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-scale! s4-0 (-> arg0 scale))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function transform-matrix-parent-calc!
|
||||
;; INFO: Used lq/sq
|
||||
(defun transform-matrix-parent-calc! ((arg0 transform) (arg1 matrix) (arg2 vector))
|
||||
"Convert a transform to a matrix, applying an inverse scaling."
|
||||
(let ((s4-0 (new 'stack-no-clear 'matrix)))
|
||||
(set! (-> s4-0 rvec quad) (the-as uint128 0))
|
||||
(set! (-> s4-0 uvec quad) (the-as uint128 0))
|
||||
(set! (-> s4-0 fvec quad) (the-as uint128 0))
|
||||
(set! (-> s4-0 trans quad) (the-as uint128 0))
|
||||
(let ((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))
|
||||
(matrix-identity! s3-0)
|
||||
(matrix-translate! s3-0 (-> arg0 trans))
|
||||
(matrix-inv-scale! s4-0 arg2)
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
(matrix-rotate-y! s4-0 (-> arg0 rot y))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-rotate-x! s4-0 (-> arg0 rot x))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
(matrix-rotate-z! s4-0 (-> arg0 rot z))
|
||||
(matrix*! s3-0 s4-0 arg1)
|
||||
(matrix-scale! s4-0 (-> arg0 scale))
|
||||
(matrix*! arg1 s4-0 s3-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function trs-matrix-calc!
|
||||
(defun trs-matrix-calc! ((arg0 trs) (arg1 matrix))
|
||||
"Convert a trs to a matrix."
|
||||
(transform-matrix-calc! (the-as transform (-> arg0 trans)) arg1)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type transformq
|
||||
(deftype transformq (transform)
|
||||
((quat quaternion :inline :overlay-at (-> rot data 0))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type transformq
|
||||
(defmethod inspect ((this transformq))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this 'transformq)
|
||||
(format #t "~1Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~1Trot: ~`vector`P~%" (-> this rot))
|
||||
(format #t "~1Tscale: ~`vector`P~%" (-> this scale))
|
||||
(format #t "~1Tquat: #<quaternion @ #x~X>~%" (-> this rot))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type trsq
|
||||
(deftype trsq (trs)
|
||||
((quat quaternion :inline :overlay-at (-> rot data 0))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type trsq
|
||||
(defmethod inspect ((this trsq))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this (-> this type))
|
||||
(format #t "~1Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~1Trot: ~`vector`P~%" (-> this rot))
|
||||
(format #t "~1Tscale: ~`vector`P~%" (-> this scale))
|
||||
(format #t "~1Tquat: #<quaternion @ #x~X>~%" (-> this rot))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition of type trsqv
|
||||
(deftype trsqv (trsq)
|
||||
"A transform with:
|
||||
- type information (child of [[basic]])
|
||||
- rotation stored as quaternion
|
||||
- velocity information.
|
||||
This is a very commonly used type to represent the position of an in-game object.
|
||||
The `root` of a process-drawable (the parent 'in-game object' type) is a [[trsqv]].
|
||||
Additionally, the collision system uses [[trsqv]] as the parent type for foreground
|
||||
collision objects ([[collide-shape]], [[collide-shape-moving]]).
|
||||
As a result, this type has a lot of weird methods and extra stuff hidden in it."
|
||||
((pause-adjust-distance meters :offset 4)
|
||||
(nav-radius meters :offset 8)
|
||||
(transv vector :inline)
|
||||
(rotv vector :inline)
|
||||
(scalev vector :inline)
|
||||
(dir-targ quaternion :inline)
|
||||
(angle-change-time time-frame)
|
||||
(old-y-angle-diff float)
|
||||
)
|
||||
(:methods
|
||||
(seek-toward-heading-vec! (_type_ vector float time-frame) quaternion)
|
||||
(set-heading-vec! (_type_ vector) quaternion)
|
||||
(seek-to-point-toward-point! (_type_ vector float time-frame) quaternion)
|
||||
(point-toward-point! (_type_ vector) quaternion)
|
||||
(seek-toward-yaw-angle! (_type_ float float time-frame) quaternion)
|
||||
(set-yaw-angle-clear-roll-pitch! (_type_ float) quaternion)
|
||||
(set-roll-to-grav! (_type_ float) quaternion)
|
||||
(set-roll-to-grav-2! (_type_ float) quaternion)
|
||||
(rotate-toward-orientation! (_type_ quaternion float float int int float) quaternion)
|
||||
(set-quaternion! (_type_ quaternion) quaternion)
|
||||
(set-heading-vec-clear-roll-pitch! (_type_ vector) quaternion)
|
||||
(point-toward-point-clear-roll-pitch! (_type_ vector) quaternion)
|
||||
(rot->dir-targ! (_type_) quaternion)
|
||||
(y-angle (_type_) float)
|
||||
(global-y-angle-to-point (_type_ vector) float)
|
||||
(relative-y-angle-to-point (_type_ vector) float)
|
||||
(roll-relative-to-gravity (_type_) float)
|
||||
(set-and-limit-velocity (_type_ int vector float) trsqv)
|
||||
(get-quaternion (_type_) quaternion)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type trsqv
|
||||
(defmethod inspect ((this trsqv))
|
||||
(when (not this)
|
||||
(set! this this)
|
||||
(goto cfg-4)
|
||||
)
|
||||
(format #t "[~8x] ~A~%" this (-> this type))
|
||||
(format #t "~1Ttrans: ~`vector`P~%" (-> this trans))
|
||||
(format #t "~1Trot: ~`vector`P~%" (-> this rot))
|
||||
(format #t "~1Tscale: ~`vector`P~%" (-> this scale))
|
||||
(format #t "~1Tquat: #<quaternion @ #x~X>~%" (-> this rot))
|
||||
(format #t "~1Tpause-adjust-distance: (meters ~m)~%" (-> this pause-adjust-distance))
|
||||
(format #t "~1Tnav-radius: (meters ~m)~%" (-> this nav-radius))
|
||||
(format #t "~1Ttransv: ~`vector`P~%" (-> this transv))
|
||||
(format #t "~1Trotv: ~`vector`P~%" (-> this rotv))
|
||||
(format #t "~1Tscalev: ~`vector`P~%" (-> this scalev))
|
||||
(format #t "~1Tdir-targ: #<quaternion @ #x~X>~%" (-> this dir-targ))
|
||||
(format #t "~1Tangle-change-time: ~D~%" (-> this angle-change-time))
|
||||
(format #t "~1Told-y-angle-diff: ~f~%" (-> this old-y-angle-diff))
|
||||
(label cfg-4)
|
||||
this
|
||||
)
|
||||
|
||||
;; definition for method 23 of type trsqv
|
||||
(defmethod global-y-angle-to-point ((this trsqv) (arg0 vector))
|
||||
"Get the angle in the xz plane from the position of this trsqv to the point arg0
|
||||
(ignores our current yaw)."
|
||||
(vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans)))
|
||||
)
|
||||
|
||||
;; definition for method 24 of type trsqv
|
||||
(defmethod relative-y-angle-to-point ((this trsqv) (arg0 vector))
|
||||
"Get the y angle between the current orientation and arg0
|
||||
(how much we'd have to yaw to point at arg0)."
|
||||
(deg-diff (y-angle this) (vector-y-angle (vector-! (new 'stack-no-clear 'vector) arg0 (-> this trans))))
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
+664
@@ -0,0 +1,664 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for function radmod
|
||||
(defun radmod ((arg0 float))
|
||||
"Wrap arg0 to be within (-pi, pi)."
|
||||
(let ((f0-1 (+ 3.1415925 arg0)))
|
||||
(if (< 0.0 f0-1)
|
||||
(+ -3.1415925 (- f0-1 (* (the float (the int (/ f0-1 6.283185))) 6.283185)))
|
||||
(+ 3.1415925 (- f0-1 (* (the float (the int (/ f0-1 6.283185))) 6.283185)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function deg-
|
||||
(defun deg- ((arg0 float) (arg1 float))
|
||||
"Compute arg0-arg1, unwrapped, using rotation units.
|
||||
Result should be in the range (-180, 180)"
|
||||
(the float (sar (- (shl (the int arg0) 48) (shl (the int arg1) 48)) 48))
|
||||
)
|
||||
|
||||
;; definition for function deg-diff
|
||||
(defun deg-diff ((arg0 float) (arg1 float))
|
||||
"Very similar to the function above, but computes arg1 - arg0 instead."
|
||||
(the float (sar (- (shl (the int arg1) 48) (shl (the int arg0) 48)) 48))
|
||||
)
|
||||
|
||||
;; definition for function deg-seek
|
||||
(defun deg-seek ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Move in toward target by at most max-diff, using rotation units"
|
||||
(let ((v1-1 (shl (the int arg0) 48))
|
||||
(a0-2 (shl (the int arg1) 48))
|
||||
)
|
||||
(let* ((a1-2 (shl (the int arg2) 48))
|
||||
(a2-1 (- a0-2 v1-1))
|
||||
(a3-0 (abs a2-1))
|
||||
)
|
||||
(set! a0-2 (cond
|
||||
((< a3-0 0)
|
||||
(+ v1-1 a1-2)
|
||||
)
|
||||
((>= a1-2 a3-0)
|
||||
(empty)
|
||||
a0-2
|
||||
)
|
||||
((>= a2-1 0)
|
||||
(+ v1-1 a1-2)
|
||||
)
|
||||
(else
|
||||
(- v1-1 a1-2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the float (sar a0-2 48))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function deg-seek-smooth
|
||||
(defun deg-seek-smooth ((arg0 float) (arg1 float) (arg2 float) (arg3 float))
|
||||
"Step amount of the way from in to target, by at most max-diff, using rotation units"
|
||||
(let ((f0-1 (* (deg- arg1 arg0) arg3)))
|
||||
(if (< arg2 (fabs f0-1))
|
||||
(set! f0-1 (if (>= f0-1 0.0)
|
||||
arg2
|
||||
(- arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(+ arg0 f0-1)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function deg-lerp-clamp
|
||||
(defun deg-lerp-clamp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Map [0, 1] to min-val, max-val, handling wrapping and saturating, using rotation units."
|
||||
(cond
|
||||
((>= 0.0 arg2)
|
||||
arg0
|
||||
)
|
||||
((>= arg2 1.0)
|
||||
arg1
|
||||
)
|
||||
(else
|
||||
(the float (sar (shl (the int (+ arg0 (* arg2 (deg-diff arg0 arg1)))) 48) 48))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for symbol binary-table, type (array float)
|
||||
(define binary-table (new 'static 'boxed-array :type float
|
||||
1.0
|
||||
0.5
|
||||
0.25
|
||||
0.125
|
||||
0.0625
|
||||
0.03125
|
||||
0.015625
|
||||
0.0078125
|
||||
0.00390625
|
||||
0.001953125
|
||||
0.0009765625
|
||||
0.00048828125
|
||||
0.00024414062
|
||||
0.00012207031
|
||||
0.000061035156
|
||||
0.000030517578
|
||||
0.000015258789
|
||||
0.0000076293945
|
||||
0.0000038146973
|
||||
0.0000019073486
|
||||
0.0000009536743
|
||||
0.00000047683716
|
||||
0.00000023841858
|
||||
0.00000011920929
|
||||
0.000000059604645
|
||||
0.000000029802322
|
||||
0.000000014901161
|
||||
0.000000007450581
|
||||
0.0000000037252903
|
||||
0.0000000018626451
|
||||
0.0000000009313226
|
||||
0.0000000004656613
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for symbol sincos-table, type (array float)
|
||||
(define sincos-table (new 'static 'boxed-array :type float
|
||||
0.7853982
|
||||
0.4636476
|
||||
0.24497867
|
||||
0.124354996
|
||||
0.06241881
|
||||
0.031239834
|
||||
0.015623729
|
||||
0.007812341
|
||||
0.0039062302
|
||||
0.0019531226
|
||||
0.0009765622
|
||||
0.0004882812
|
||||
0.00024414062
|
||||
0.00012207031
|
||||
0.000061035156
|
||||
0.000030517578
|
||||
0.000015258789
|
||||
0.0000076293945
|
||||
0.0000038146973
|
||||
0.0000019073486
|
||||
0.0000009536743
|
||||
0.00000047683716
|
||||
0.00000023841858
|
||||
0.00000011920929
|
||||
0.000000059604645
|
||||
0.000000029802322
|
||||
0.000000014901161
|
||||
0.000000007450581
|
||||
0.0000000037252903
|
||||
0.0000000018626451
|
||||
0.0000000009313226
|
||||
0.0000000004656613
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function sin
|
||||
(defun sin ((arg0 float))
|
||||
"Compute the sine of an angle in rotation units. Unwraps it."
|
||||
(let ((f2-0 (* 0.000095873795 (the float (sar (shl (the int arg0) 48) 48)))))
|
||||
f2-0
|
||||
(let* ((f1-4 (* 0.999998 f2-0))
|
||||
(f0-3 (* f2-0 f2-0))
|
||||
(f2-1 (* f2-0 f0-3))
|
||||
(f1-5 (+ f1-4 (* -0.16666014 f2-1)))
|
||||
(f2-2 (* f2-1 f0-3))
|
||||
(f1-6 (+ f1-5 (* 0.008326521 f2-2)))
|
||||
(f2-3 (* f2-2 f0-3))
|
||||
(f1-7 (+ f1-6 (* -0.0001956241 f2-3)))
|
||||
(f0-4 (* f2-3 f0-3))
|
||||
)
|
||||
(+ f1-7 (* 0.0000023042373 f0-4))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function sin-rad
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for symbol *sin-poly-vec*, type vector
|
||||
(define *sin-poly-vec*
|
||||
(new 'static 'vector :x -0.16666014 :y 0.008326521 :z -0.0001956241 :w 0.0000023042373)
|
||||
)
|
||||
|
||||
;; definition for symbol *sin-poly-vec2*, type vector
|
||||
(define *sin-poly-vec2* (new 'static 'vector :x 0.999998))
|
||||
|
||||
;; definition for function vector-sin-rad!
|
||||
(defun vector-sin-rad! ((arg0 vector) (arg1 vector))
|
||||
"Taylor series approximation of sine on all 4 elements in a vector.
|
||||
Inputs should be in radians, in -pi to pi.
|
||||
Somehow their coefficients are a little bit off.
|
||||
Like the first coefficient, which should obviously be 1, is not quite 1."
|
||||
(rlet ((acc :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf10 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
(vf7 :class vf)
|
||||
(vf8 :class vf)
|
||||
(vf9 :class vf)
|
||||
)
|
||||
(.lvf vf1 (&-> arg1 quad))
|
||||
(.mul.vf vf3 vf1 vf1)
|
||||
(.lvf vf10 (&-> *sin-poly-vec2* quad))
|
||||
(.lvf vf9 (&-> *sin-poly-vec* quad))
|
||||
(.mul.vf vf4 vf3 vf1)
|
||||
(.mul.vf vf5 vf3 vf3)
|
||||
(.mul.x.vf acc vf1 vf10)
|
||||
(.mul.vf vf6 vf4 vf3)
|
||||
(.mul.vf vf7 vf5 vf4)
|
||||
(.add.mul.x.vf acc vf4 vf9 acc)
|
||||
(.mul.vf vf8 vf6 vf5)
|
||||
(.add.mul.y.vf acc vf6 vf9 acc)
|
||||
(.add.mul.z.vf acc vf7 vf9 acc)
|
||||
(.add.mul.w.vf vf2 vf8 vf9 acc)
|
||||
(.svf (&-> arg0 quad) vf2)
|
||||
arg0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function cos-rad
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for symbol *cos-poly-vec*, type vector
|
||||
(define *cos-poly-vec* (new 'static 'vector :x -0.49998003 :y 0.041620404 :z -0.0013636408 :w 0.000020170546))
|
||||
|
||||
;; definition for function vector-cos-rad!
|
||||
;; ERROR: Bad vector register dependency: vf2
|
||||
(defun vector-cos-rad! ((arg0 vector) (arg1 vector))
|
||||
"Compute the cosine of all 4 vector elements.
|
||||
Radians, with no wrapping. Uses taylor series with 4 coefficients."
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
(vf9 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf1 (&-> arg1 quad))
|
||||
(.sub.vf vf2 vf2 vf2)
|
||||
(.lvf vf9 (&-> *cos-poly-vec* quad))
|
||||
(.mul.vf vf3 vf1 vf1)
|
||||
(.add.w.vf acc vf2 vf0)
|
||||
(.mul.vf vf4 vf3 vf3)
|
||||
(.add.mul.x.vf acc vf3 vf9 acc)
|
||||
(.mul.vf vf5 vf4 vf3)
|
||||
(.add.mul.y.vf acc vf4 vf9 acc)
|
||||
(.mul.vf vf6 vf4 vf4)
|
||||
(.add.mul.z.vf acc vf5 vf9 acc)
|
||||
(.add.mul.w.vf vf2 vf6 vf9 acc)
|
||||
(.svf (&-> arg0 quad) vf2)
|
||||
arg0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function vector-sincos-rad!
|
||||
;; ERROR: Bad vector register dependency: vf14
|
||||
(defun vector-sincos-rad! ((arg0 vector) (arg1 vector) (arg2 vector))
|
||||
"Compute the sine and cosine of each element of src, storing it in dst-sin and dst-cos.
|
||||
This is more efficient than separate calls to sin and cos.
|
||||
Inputs should be radians in -pi to pi."
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf10 :class vf)
|
||||
(vf11 :class vf)
|
||||
(vf12 :class vf)
|
||||
(vf13 :class vf)
|
||||
(vf14 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
(vf5 :class vf)
|
||||
(vf6 :class vf)
|
||||
(vf7 :class vf)
|
||||
(vf8 :class vf)
|
||||
(vf9 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf1 (&-> arg2 quad))
|
||||
(.sub.vf vf14 vf14 vf14)
|
||||
(.lvf vf11 (&-> *sin-poly-vec2* quad))
|
||||
(.mul.vf vf2 vf1 vf1)
|
||||
(.lvf vf10 (&-> *sin-poly-vec* quad))
|
||||
(.lvf vf13 (&-> *cos-poly-vec* quad))
|
||||
(.mul.x.vf acc vf1 vf11)
|
||||
(.mul.vf vf3 vf2 vf1)
|
||||
(.mul.vf vf4 vf2 vf2)
|
||||
(.mul.vf vf5 vf3 vf2)
|
||||
(.mul.vf vf6 vf3 vf3)
|
||||
(.mul.vf vf7 vf4 vf3)
|
||||
(.mul.vf vf8 vf4 vf4)
|
||||
(.mul.vf vf9 vf5 vf4)
|
||||
(.add.mul.x.vf acc vf3 vf10 acc)
|
||||
(.add.mul.y.vf acc vf5 vf10 acc)
|
||||
(.add.mul.z.vf acc vf7 vf10 acc)
|
||||
(.add.mul.w.vf vf12 vf9 vf10 acc)
|
||||
(.add.w.vf acc vf14 vf0)
|
||||
(.add.mul.x.vf acc vf2 vf13 acc)
|
||||
(.add.mul.y.vf acc vf4 vf13 acc)
|
||||
(.add.mul.z.vf acc vf6 vf13 acc)
|
||||
(.add.mul.w.vf vf14 vf8 vf13 acc)
|
||||
(.svf (&-> arg0 quad) vf12)
|
||||
(.svf (&-> arg1 quad) vf14)
|
||||
0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function sincos-rad!
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function sincos!
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function vector-rad<-vector-deg!
|
||||
;; WARN: Return type mismatch float vs none.
|
||||
(defun vector-rad<-vector-deg! ((out vector) (in vector))
|
||||
"Convert a vector in rotation units to radians, and unwrap.
|
||||
Input can be anything, output will be -2pi to pi."
|
||||
(local-vars (v0-0 float) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128))
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
)
|
||||
(let ((v1-0 #x38c90fda))
|
||||
(.lvf vf1 (&-> in quad))
|
||||
(.ftoi.vf vf1 vf1)
|
||||
(.mov vf2 v1-0)
|
||||
)
|
||||
(.mov v1-1 vf1)
|
||||
(.pw.sll v1-2 v1-1 16)
|
||||
(.pw.sra v1-3 v1-2 16)
|
||||
(.mov vf1 v1-3)
|
||||
(.itof.vf vf1 vf1)
|
||||
(.mul.x.vf vf1 vf1 vf2)
|
||||
(.svf (&-> out quad) vf1)
|
||||
(.mov v0-0 vf1)
|
||||
(none)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function vector-rad<-vector-deg/2!
|
||||
;; WARN: Return type mismatch float vs int.
|
||||
(defun vector-rad<-vector-deg/2! ((out vector) (in vector))
|
||||
"Divide the input by two, and then convert from rotation units to radians, unwrapping.
|
||||
Not sure why this really needs to be separate the from previous function..."
|
||||
(local-vars (v0-0 float) (v1-1 uint128) (v1-2 uint128) (v1-3 uint128))
|
||||
(rlet ((vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
)
|
||||
(let ((v1-0 #x38c90fda))
|
||||
(let ((a2-0 #x3f000000))
|
||||
(.lvf vf1 (&-> in quad))
|
||||
(.mov vf2 a2-0)
|
||||
)
|
||||
(.mul.x.vf vf1 vf1 vf2)
|
||||
(.ftoi.vf vf1 vf1)
|
||||
(.mov vf2 v1-0)
|
||||
)
|
||||
(.mov v1-1 vf1)
|
||||
(.pw.sll v1-2 v1-1 16)
|
||||
(.pw.sra v1-3 v1-2 16)
|
||||
(.mov vf1 v1-3)
|
||||
(.itof.vf vf1 vf1)
|
||||
(.mul.x.vf vf1 vf1 vf2)
|
||||
(.svf (&-> out quad) vf1)
|
||||
(.mov v0-0 vf1)
|
||||
(the-as int v0-0)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function vector-sincos!
|
||||
(defun vector-sincos! ((arg0 vector) (arg1 vector) (arg2 vector))
|
||||
"Compute sine and cosine of each element in a vector, in rotation units"
|
||||
(let ((s4-0 (new 'stack-no-clear 'vector)))
|
||||
(vector-rad<-vector-deg! s4-0 arg2)
|
||||
(vector-sincos-rad! arg0 arg1 s4-0)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function tan-rad
|
||||
(defun tan-rad ((arg0 float))
|
||||
"This function appears to be named wrong and actually operates on rotation units."
|
||||
(/ (sin arg0) (cos arg0))
|
||||
)
|
||||
|
||||
;; definition for function cos
|
||||
(defun cos ((arg0 float))
|
||||
"Cosine of rotation units."
|
||||
(sin (+ 16384.0 arg0))
|
||||
)
|
||||
|
||||
;; definition for function tan
|
||||
(defun tan ((arg0 float))
|
||||
"Correctly named tangent of rotation units."
|
||||
(/ (sin arg0) (cos arg0))
|
||||
)
|
||||
|
||||
;; definition for function atan0
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function atan-series-rad
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function atan-rad
|
||||
(defun atan-rad ((arg0 float))
|
||||
"Inverse tangent in radians."
|
||||
(atan-series-rad (/ (+ -1.0 arg0) (+ 1.0 arg0)))
|
||||
)
|
||||
|
||||
;; definition for function sign-bit
|
||||
(defun sign-bit ((arg0 int))
|
||||
"Return 1 if bit 31 is set, otherwise 0."
|
||||
(local-vars (v1-1 int))
|
||||
(let ((v1-0 arg0))
|
||||
(shift-arith-right-32 v1-1 v1-0 31)
|
||||
)
|
||||
(logand v1-1 1)
|
||||
)
|
||||
|
||||
;; definition for function sign-float
|
||||
;; ERROR: function was not converted to expressions. Cannot decompile.
|
||||
|
||||
;; definition for function sign
|
||||
(defun sign ((arg0 float))
|
||||
"Similar to above, but returns 0 if input is 0.
|
||||
But is more complicated."
|
||||
(cond
|
||||
((< 0.0 arg0)
|
||||
1.0
|
||||
)
|
||||
((< arg0 0.0)
|
||||
-1.0
|
||||
)
|
||||
(else
|
||||
0.0
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function atan2-rad
|
||||
(defun atan2-rad ((arg0 float) (arg1 float))
|
||||
"Atan for radians."
|
||||
(cond
|
||||
((= arg1 0.0)
|
||||
(* 1.5707963 (sign arg0))
|
||||
)
|
||||
((and (< arg0 0.0) (< arg1 0.0))
|
||||
(let ((f30-1 -3.1415925)
|
||||
(f0-6 (/ arg0 arg1))
|
||||
)
|
||||
(+ f30-1 (atan-series-rad (/ (+ -1.0 f0-6) (+ 1.0 f0-6))))
|
||||
)
|
||||
)
|
||||
((< arg0 0.0)
|
||||
(let ((f0-14 (- (/ arg0 arg1))))
|
||||
(- (atan-series-rad (/ (+ -1.0 f0-14) (+ 1.0 f0-14))))
|
||||
)
|
||||
)
|
||||
((< arg1 0.0)
|
||||
(let ((f30-2 3.1415925)
|
||||
(f0-22 (- (/ arg0 arg1)))
|
||||
)
|
||||
(- f30-2 (atan-series-rad (/ (+ -1.0 f0-22) (+ 1.0 f0-22))))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let ((f0-28 (/ arg0 arg1)))
|
||||
(atan-series-rad (/ (+ -1.0 f0-28) (+ 1.0 f0-28)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function atan
|
||||
(defun atan ((arg0 float) (arg1 float))
|
||||
"Atan for rotation units. Signs behave like atan.."
|
||||
(cond
|
||||
((and (= arg1 0.0) (= arg0 0.0))
|
||||
0.0
|
||||
)
|
||||
((and (< arg1 0.0) (< arg0 0.0))
|
||||
(+ -32768.0 (atan0 (- arg0) (- arg1)))
|
||||
)
|
||||
((< arg0 0.0)
|
||||
(- (atan0 (- arg0) arg1))
|
||||
)
|
||||
((< arg1 0.0)
|
||||
(- 32768.0 (atan0 arg0 (- arg1)))
|
||||
)
|
||||
(else
|
||||
(atan0 arg0 arg1)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function asin
|
||||
(defun asin ((arg0 float))
|
||||
"Inverse sine, rotation units."
|
||||
(let ((gp-0 #f))
|
||||
0.0
|
||||
(when (< arg0 0.0)
|
||||
(set! arg0 (- arg0))
|
||||
(set! gp-0 #t)
|
||||
)
|
||||
(let ((f0-5 (cond
|
||||
((< 1.0 arg0)
|
||||
16383.996
|
||||
)
|
||||
(else
|
||||
(let* ((f0-6 1.0)
|
||||
(f1-2 arg0)
|
||||
(f0-8 (sqrtf (- f0-6 (* f1-2 f1-2))))
|
||||
)
|
||||
(atan0 arg0 f0-8)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if gp-0
|
||||
(- f0-5)
|
||||
f0-5
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function acos
|
||||
(defun acos ((arg0 float))
|
||||
"Inverse cosine. Returns rotation units."
|
||||
(- 16384.0 (asin arg0))
|
||||
)
|
||||
|
||||
;; definition for function acos-rad
|
||||
(defun acos-rad ((arg0 float))
|
||||
"Inverse cosine, radians."
|
||||
(cond
|
||||
((>= arg0 0.0)
|
||||
(let* ((f0-1 1.0)
|
||||
(f1-1 arg0)
|
||||
(f0-3 (sqrtf (- f0-1 (* f1-1 f1-1))))
|
||||
(f0-5 (/ (- f0-3 arg0) (+ f0-3 arg0)))
|
||||
)
|
||||
(atan-series-rad f0-5)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let* ((f0-6 1.0)
|
||||
(f1-6 arg0)
|
||||
(f0-8 (sqrtf (- f0-6 (* f1-6 f1-6))))
|
||||
(f0-10 (/ (+ f0-8 arg0) (- f0-8 arg0)))
|
||||
)
|
||||
(- 3.1415925 (atan-series-rad f0-10))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function sinerp
|
||||
(defun sinerp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Map amount to min,max using sine. Kinda weird, usually people use cosine."
|
||||
(lerp arg0 arg1 (sin (* 16384.0 arg2)))
|
||||
)
|
||||
|
||||
;; definition for function sinerp-clamp
|
||||
(defun sinerp-clamp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Like sinerp, but clamp to min,max."
|
||||
(cond
|
||||
((>= 0.0 arg2)
|
||||
arg0
|
||||
)
|
||||
((>= arg2 1.0)
|
||||
arg1
|
||||
)
|
||||
(else
|
||||
(sinerp arg0 arg1 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function coserp
|
||||
(defun coserp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Weird lerp with cosine (over 90 degrees?)."
|
||||
(lerp arg0 arg1 (- 1.0 (cos (* 16384.0 arg2))))
|
||||
)
|
||||
|
||||
;; definition for function coserp-clamp
|
||||
(defun coserp-clamp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Weird 90 degree lerp with cosine, clamped to min,max."
|
||||
(cond
|
||||
((>= 0.0 arg2)
|
||||
arg0
|
||||
)
|
||||
((>= arg2 1.0)
|
||||
arg1
|
||||
)
|
||||
(else
|
||||
(coserp arg0 arg1 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function coserp180
|
||||
(defun coserp180 ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Classic lerp with cosine."
|
||||
(lerp arg0 arg1 (* 0.5 (- 1.0 (cos (* 32768.0 arg2)))))
|
||||
)
|
||||
|
||||
;; definition for function coserp180-clamp
|
||||
(defun coserp180-clamp ((arg0 float) (arg1 float) (arg2 float))
|
||||
"Classic coserp with saturation."
|
||||
(cond
|
||||
((>= 0.0 arg2)
|
||||
arg0
|
||||
)
|
||||
((>= arg2 1.0)
|
||||
arg1
|
||||
)
|
||||
(else
|
||||
(coserp180 arg0 arg1 arg2)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for function ease-in-out
|
||||
(defun ease-in-out ((arg0 int) (arg1 int))
|
||||
"Weird coserp like mapping from 0 to 1 as progress goes from 0 to total."
|
||||
(local-vars (v1-0 int))
|
||||
(cond
|
||||
((>= arg1 arg0)
|
||||
1.0
|
||||
)
|
||||
((<= arg1 0)
|
||||
0.0
|
||||
)
|
||||
((begin (set! v1-0 (/ arg0 2)) (< v1-0 arg1))
|
||||
(let ((a0-1 (- arg1 arg0)))
|
||||
(+ 0.5 (* 0.5 (sin (- 16384.0 (/ (* 16384.0 (the float a0-1)) (the float v1-0))))))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(- 0.5 (* 0.5 (cos (/ (* 16384.0 (the float arg1)) (the float v1-0)))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+1039
File diff suppressed because it is too large
Load Diff
+9
@@ -0,0 +1,9 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
{
|
||||
"dgos": [
|
||||
"CGO/KERNEL.CGO",
|
||||
"CGO/GAME.CGO"
|
||||
],
|
||||
|
||||
"skip_compile_files": [],
|
||||
|
||||
"skip_compile_functions": [],
|
||||
"skip_compile_functions": [
|
||||
// math
|
||||
"logf",
|
||||
"log2f",
|
||||
"cube-root",
|
||||
"lerp-scale",
|
||||
"rand-vu-init",
|
||||
"rand-vu",
|
||||
"rand-vu-nostep",
|
||||
// matrix
|
||||
"matrix-axis-sin-cos-vu!",
|
||||
"matrix-axis-sin-cos!",
|
||||
"matrix-3x3-normalize!"
|
||||
],
|
||||
|
||||
"skip_compile_states": {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user