From d3ef0a34ad3d0f7825871a0a6b767fc686249a63 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 14 Oct 2021 17:52:32 +1000 Subject: [PATCH] Replace ultra headers with version J --- Makefile | 13 +- include/PR/PRimage.h | 126 ++ {src/include => include}/PR/R4300.h | 2 +- {src/include => include}/PR/abi.h | 26 +- {src/include => include}/PR/gbi.h | 363 ++-- {src/include => include}/PR/gs2dex.h | 785 ++++---- include/PR/gt.h | 365 ++++ include/PR/gu.h | 266 +++ include/PR/leo.h | 280 +++ include/PR/leoappli.h | 274 +++ {src/include => include}/PR/libaudio.h | 117 +- {src/include => include}/PR/mbi.h | 4 - include/PR/n_libaudio.h | 354 ++++ include/PR/n_libaudio_s_to_n.h | 120 ++ include/PR/os.h | 107 ++ {src/include => include}/PR/os_ai.h | 0 {src/include => include}/PR/os_cache.h | 0 {src/include => include}/PR/os_cont.h | 137 +- include/PR/os_convert.h | 105 ++ include/PR/os_debug.h | 108 ++ {src/include => include}/PR/os_eeprom.h | 0 include/PR/os_error.h | 86 + {src/include => include}/PR/os_exception.h | 0 include/PR/os_gbpak.h | 107 ++ include/PR/os_gio.h | 86 + include/PR/os_host.h | 104 ++ include/PR/os_internal.h | 49 + include/PR/os_internal_debug.h | 43 + include/PR/os_internal_error.h | 45 + include/PR/os_internal_exception.h | 49 + include/PR/os_internal_gio.h | 45 + include/PR/os_internal_host.h | 42 + include/PR/os_internal_reg.h | 57 + include/PR/os_internal_rsp.h | 48 + include/PR/os_internal_si.h | 46 + include/PR/os_internal_thread.h | 43 + include/PR/os_internal_tlb.h | 47 + {src/include => include}/PR/os_libc.h | 9 +- {src/include => include}/PR/os_message.h | 17 +- include/PR/os_motor.h | 83 + include/PR/os_pfs.h | 178 ++ include/PR/os_pi.h | 224 +++ {src/include => include}/PR/os_rdp.h | 0 include/PR/os_reg.h | 90 + include/PR/os_rsp.h | 86 + include/PR/os_si.h | 86 + include/PR/os_system.h | 118 ++ include/PR/os_thread.h | 152 ++ include/PR/os_time.h | 114 ++ {src/include => include}/PR/os_tlb.h | 0 include/PR/os_version.h | 16 + include/PR/os_vi.h | 298 +++ include/PR/os_voice.h | 108 ++ include/PR/ramrom.h | 113 ++ {src/include => include}/PR/rcp.h | 8 +- include/PR/rdb.h | 93 + include/PR/region.h | 123 ++ include/PR/rmon.h | 39 + {src/include => include}/PR/sched.h | 64 +- include/PR/sp.h | 196 ++ include/PR/sptask.h | 202 +++ include/PR/ucode.h | 192 ++ include/PR/ucode_debug.h | 54 + include/PR/ultraerror.h | 167 ++ include/PR/ultralog.h | 74 + include/PR/ultratypes.h | 90 + include/PR/uportals.h | 134 ++ include/make/PRdefs | 85 + {src/include/PR => include}/sys/asm.h | 0 include/sys/regdef.h | 45 + include/sys/u64driver.h | 131 ++ include/sys/u64gio.h | 110 ++ include/tinymon.h | 68 + include/ultra64.h | 40 + include/ultrahost.h | 58 + ld/libfiles.ntsc-beta.inc | 17 +- ld/libfiles.ntsc-final.inc | 17 +- ld/libfiles.pal-final.inc | 17 +- ld/pd.ld | 20 +- src/game/objectives/objectives.c | 2 +- src/game/propobj.c | 2 +- src/game/title.c | 8 +- src/include/PR/gbi.inc | 971 ---------- src/include/PR/gbi_old.h | 1612 ----------------- src/include/PR/gu.h | 41 - src/include/PR/libultra.h | 18 - src/include/PR/os_internal.h | 18 - src/include/PR/os_misc.h | 132 -- src/include/PR/os_pfs.h | 220 --- src/include/PR/os_pi.h | 196 -- src/include/PR/os_thread.h | 79 - src/include/PR/os_time.h | 25 - src/include/PR/os_vi.h | 235 --- src/include/PR/sptask.h | 122 -- src/include/PR/synthInternals.h | 337 ---- src/include/PR/sys/regdef.h | 104 -- src/include/PR/ucode.h | 23 - src/include/PR/ultratypes.h | 42 - src/include/asm_helper.h | 8 +- src/include/bss.h | 6 +- src/include/constants.h | 1 + src/include/data.h | 7 - src/include/lib/lib_2fba0.h | 2 - src/include/lib/lib_30ce0.h | 9 - src/include/lib/lib_34240.h | 3 +- src/include/lib/lib_37650.h | 2 +- src/include/lib/lib_39c80.h | 2 +- src/include/lib/lib_3c430.h | 2 +- src/include/lib/lib_3d280.h | 1 - src/include/lib/lib_3e3e0.h | 1 - src/include/lib/sched.h | 1 + src/include/libultra_internal.h | 73 - src/include/stdarg.h | 42 + src/include/{lib/libc/ldiv.h => stdlib.h} | 10 +- src/include/string.h | 55 + src/include/types.h | 6 +- src/include/ultra64.h | 37 - src/lib/audiomgr.c | 32 +- src/lib/boot.c | 189 +- src/lib/crash.c | 1 + src/lib/joy.c | 6 +- src/lib/lib_09660.c | 1 - src/lib/lib_2fba0.c | 11 +- src/lib/lib_317f0.c | 93 +- src/lib/lib_37650.c | 2 +- src/lib/lib_39be0.c | 4 +- src/lib/lib_39c80.c | 2 +- src/lib/lib_39f70.c | 2 +- src/lib/lib_3a100.c | 2 +- src/lib/lib_3c430.c | 2 +- src/lib/lib_3c890.c | 7 +- src/lib/lib_3ccf0.c | 7 +- src/lib/lib_3cdc0.c | 5 +- src/lib/lib_3cef0.c | 13 +- src/lib/lib_3e3e0.c | 5 +- src/lib/lib_3e730.c | 3 +- src/lib/lib_3f8a0.c | 2 - src/lib/lib_43dd0.c | 2 +- src/lib/lib_4e090.c | 1 - src/lib/main.c | 5 +- src/lib/mp3.c | 4 +- src/lib/naudio/n_abi.h | 122 ++ src/lib/naudio/n_cseqp.h | 26 + .../audio/csplayer.c => naudio/n_csplayer.c} | 149 +- .../{ultra/audio/cseq.c => naudio/n_csq.c} | 32 +- src/lib/{lib_3e8c0.c => naudio/n_env.c} | 55 +- .../{ultra/audio/event.c => naudio/n_event.c} | 36 +- src/lib/naudio/n_seqp.h | 53 + src/lib/{lib_3d280.c => naudio/n_seqplayer.c} | 61 +- src/lib/naudio/n_sndp.h | 99 + src/lib/naudio/n_syndelete.c | 6 + src/lib/naudio/n_synsetpriority.c | 6 + src/lib/naudio/n_synthInternals.h | 164 ++ .../{lib_30ce0.c => naudio/n_synthesizer.c} | 104 +- src/lib/rdp.c | 8 +- src/lib/reset.c | 15 +- src/lib/rmon.c | 1 + src/lib/sched.c | 54 +- src/lib/snd.c | 9 +- src/lib/speaker.c | 1 - src/lib/ultra/audio/bnkf.c | 10 +- src/lib/ultra/audio/cseq.h | 11 + src/lib/ultra/audio/cseqp.h | 10 + src/lib/ultra/audio/heap.c | 9 +- src/lib/ultra/audio/initfx.h | 59 + src/lib/ultra/audio/seq.h | 9 + src/{include/PR => lib/ultra/audio}/seqp.h | 15 +- src/lib/ultra/audio/sl.c | 24 + src/lib/ultra/audio/sndp.h | 102 ++ src/lib/ultra/audio/syndelete.c | 10 - src/lib/ultra/audio/synsetpriority.c | 12 - src/lib/ultra/audio/synthInternals.h | 337 ++++ src/lib/ultra/gu/align.c | 7 +- src/lib/ultra/gu/coss.c | 7 +- src/lib/ultra/gu/guint.h | 42 + src/lib/ultra/gu/sins.c | 7 +- src/lib/ultra/gu/sintable.h | 1031 +++++++++++ src/lib/ultra/gu/translate.c | 6 +- src/lib/ultra/io/ai.c | 3 +- src/lib/ultra/io/aigetlen.c | 2 +- src/lib/ultra/io/aisetfreq.c | 4 +- src/lib/ultra/io/aisetnextbuf.c | 4 +- src/lib/ultra/io/conteeplongread.c | 4 +- src/lib/ultra/io/conteeplongwrite.c | 5 +- src/lib/ultra/io/conteepprobe.c | 4 +- src/lib/ultra/io/conteepread.c | 7 +- src/lib/ultra/io/conteepwrite.c | 7 +- src/lib/ultra/io/contpfs.c | 10 +- src/lib/ultra/io/contquery.c | 6 +- src/lib/ultra/io/contramread.c | 9 +- src/lib/ultra/io/contramwrite.c | 13 +- src/lib/ultra/io/contreaddata.c | 7 +- src/lib/ultra/io/controller.c | 6 +- src/lib/ultra/io/controller.h | 209 +++ src/lib/ultra/io/crc.c | 6 +- src/lib/ultra/io/devmgr.c | 6 +- src/lib/ultra/io/dpctr.c | 4 +- src/lib/ultra/io/dpgetstat.c | 3 +- src/lib/ultra/io/dpsetstat.c | 4 +- src/lib/ultra/io/epirawdma.c | 5 +- src/lib/ultra/io/epirawread.c | 5 +- src/lib/ultra/io/epirawwrite.c | 4 +- src/lib/ultra/io/gbpakcheckconnector.c | 12 +- src/lib/ultra/io/gbpakgetstatus.c | 9 +- src/lib/ultra/io/gbpakinit.c | 11 +- src/lib/ultra/io/gbpakpower.c | 13 +- src/lib/ultra/io/gbpakreadid.c | 9 +- src/lib/ultra/io/gbpakreadwrite.c | 8 +- src/lib/ultra/io/gbpakselectbank.c | 9 +- src/lib/ultra/io/motor.c | 11 +- src/lib/ultra/io/pfsallocatefile.c | 34 +- src/lib/ultra/io/pfschecker.c | 9 +- src/lib/ultra/io/pfsdeletefile.c | 11 +- src/lib/ultra/io/pfsfilestate.c | 10 +- src/lib/ultra/io/pfsfindfile.c | 8 +- src/lib/ultra/io/pfsfreeblocks.c | 12 +- src/lib/ultra/io/pfsgetstatus.c | 8 +- src/lib/ultra/io/pfsinitpak.c | 15 +- src/lib/ultra/io/pfsinitpak2.c | 10 +- src/lib/ultra/io/pfsisplug.c | 6 +- src/lib/ultra/io/pfsnumfiles.c | 8 +- src/lib/ultra/io/pfsreadwritefile.c | 16 +- src/lib/ultra/io/pfsresizefile.c | 9 +- src/lib/ultra/io/pfsselectbank.c | 3 +- src/lib/ultra/io/piacs.c | 4 +- src/lib/ultra/io/pidma.c | 4 +- src/lib/ultra/io/pigetcmdq.c | 4 +- src/lib/ultra/io/piint.h | 116 ++ src/lib/ultra/io/pimgr.c | 8 +- src/lib/ultra/io/pirawdma.c | 4 +- src/lib/ultra/io/pirawread.c | 5 +- src/lib/ultra/io/piread.c | 4 +- src/lib/ultra/io/si.c | 4 +- src/lib/ultra/io/siacs.c | 4 +- src/lib/ultra/io/siint.h | 10 + src/lib/ultra/io/sirawdma.c | 4 +- src/lib/ultra/io/sirawread.c | 4 +- src/lib/ultra/io/sirawwrite.c | 4 +- src/lib/ultra/io/sp.c | 6 +- src/lib/ultra/io/spgetstat.c | 4 +- src/lib/ultra/io/sprawdma.c | 5 +- src/lib/ultra/io/spsetpc.c | 4 +- src/lib/ultra/io/spsetstat.c | 4 +- src/lib/ultra/io/sptask.c | 7 +- src/lib/ultra/io/sptaskyield.c | 3 +- src/lib/ultra/io/sptaskyielded.c | 5 +- src/lib/ultra/io/vi.c | 6 +- src/lib/ultra/io/viblack.c | 4 +- src/lib/ultra/io/vigetcurrcontext.c | 4 +- src/lib/ultra/io/vigetcurrframebuf.c | 4 +- src/lib/ultra/io/vigetnextframebuf.c | 4 +- src/lib/ultra/io/viint.h | 70 + src/lib/ultra/io/vimgr.c | 8 +- src/lib/ultra/io/vimodempallan1.c | 4 +- src/lib/ultra/io/vimodentsclan1.c | 4 +- src/lib/ultra/io/vimodepallan1.c | 4 +- src/lib/ultra/io/visetevent.c | 4 +- src/lib/ultra/io/visetmode.c | 4 +- src/lib/ultra/io/visetspecial.c | 5 +- src/lib/ultra/io/visetxscale.c | 4 +- src/lib/ultra/io/visetyscale.c | 4 +- src/lib/ultra/io/viswapbuf.c | 4 +- src/lib/ultra/io/viswapcontext.c | 7 +- src/lib/ultra/io/vitbl.c | 4 +- src/lib/ultra/libc/ldiv.c | 2 +- src/lib/ultra/libc/xldtob.c | 33 +- src/lib/ultra/libc/xlitob.c | 3 +- src/lib/ultra/libc/xprintf.c | 6 +- src/lib/ultra/libc/xstdio.h | 38 + src/lib/ultra/os/atomic.c | 3 +- src/lib/ultra/os/createmesgqueue.c | 6 +- src/lib/ultra/os/createthread.c | 5 +- src/lib/ultra/os/destroythread.c | 4 +- src/lib/ultra/os/exceptvars.c | 3 - src/lib/ultra/os/getcurrfaultthread.c | 4 +- src/lib/ultra/os/getmemsize.c | 5 +- src/lib/ultra/os/getthreadpri.c | 2 +- src/lib/ultra/os/gettime.c | 4 +- src/lib/ultra/os/initialize.c | 11 +- src/lib/ultra/os/initialize2.c | 9 +- src/lib/ultra/os/interrupt.c | 3 - src/lib/ultra/os/jammesg.c | 4 +- src/lib/ultra/os/osint.h | 49 + src/lib/ultra/os/recvmesg.c | 4 +- src/lib/ultra/os/resetglobalintmask.c | 6 +- src/lib/ultra/os/sendmesg.c | 4 +- src/lib/ultra/os/seteventmesg.c | 9 +- src/lib/ultra/os/setglobalintmask.c | 6 +- src/lib/ultra/os/setthreadpri.c | 4 +- src/lib/ultra/os/settimer.c | 8 +- src/lib/ultra/os/startthread.c | 4 +- src/lib/ultra/os/stopthread.c | 4 +- src/lib/ultra/os/stoptimer.c | 6 +- src/lib/ultra/os/syncputchars.c | 5 +- src/lib/ultra/os/thread.c | 7 +- src/lib/ultra/os/timerintr.c | 27 +- src/lib/ultra/os/virtualtophysical.c | 5 +- src/lib/ultra/os/yieldthread.c | 4 +- src/lib/vi.c | 1 - 299 files changed, 10766 insertions(+), 6225 deletions(-) create mode 100644 include/PR/PRimage.h rename {src/include => include}/PR/R4300.h (99%) mode change 100755 => 100644 rename {src/include => include}/PR/abi.h (89%) rename {src/include => include}/PR/gbi.h (97%) rename {src/include => include}/PR/gs2dex.h (68%) create mode 100644 include/PR/gt.h create mode 100644 include/PR/gu.h create mode 100644 include/PR/leo.h create mode 100644 include/PR/leoappli.h rename {src/include => include}/PR/libaudio.h (90%) rename {src/include => include}/PR/mbi.h (98%) create mode 100644 include/PR/n_libaudio.h create mode 100644 include/PR/n_libaudio_s_to_n.h create mode 100644 include/PR/os.h rename {src/include => include}/PR/os_ai.h (100%) rename {src/include => include}/PR/os_cache.h (100%) rename {src/include => include}/PR/os_cont.h (62%) create mode 100644 include/PR/os_convert.h create mode 100644 include/PR/os_debug.h rename {src/include => include}/PR/os_eeprom.h (100%) create mode 100644 include/PR/os_error.h rename {src/include => include}/PR/os_exception.h (100%) create mode 100644 include/PR/os_gbpak.h create mode 100644 include/PR/os_gio.h create mode 100644 include/PR/os_host.h create mode 100644 include/PR/os_internal.h create mode 100644 include/PR/os_internal_debug.h create mode 100644 include/PR/os_internal_error.h create mode 100644 include/PR/os_internal_exception.h create mode 100644 include/PR/os_internal_gio.h create mode 100644 include/PR/os_internal_host.h create mode 100644 include/PR/os_internal_reg.h create mode 100644 include/PR/os_internal_rsp.h create mode 100644 include/PR/os_internal_si.h create mode 100644 include/PR/os_internal_thread.h create mode 100644 include/PR/os_internal_tlb.h rename {src/include => include}/PR/os_libc.h (96%) rename {src/include => include}/PR/os_message.h (90%) create mode 100644 include/PR/os_motor.h create mode 100644 include/PR/os_pfs.h create mode 100644 include/PR/os_pi.h rename {src/include => include}/PR/os_rdp.h (100%) create mode 100644 include/PR/os_reg.h create mode 100644 include/PR/os_rsp.h create mode 100644 include/PR/os_si.h create mode 100644 include/PR/os_system.h create mode 100644 include/PR/os_thread.h create mode 100644 include/PR/os_time.h rename {src/include => include}/PR/os_tlb.h (100%) create mode 100644 include/PR/os_version.h create mode 100644 include/PR/os_vi.h create mode 100644 include/PR/os_voice.h create mode 100644 include/PR/ramrom.h rename {src/include => include}/PR/rcp.h (99%) mode change 100755 => 100644 create mode 100644 include/PR/rdb.h create mode 100644 include/PR/region.h create mode 100644 include/PR/rmon.h rename {src/include => include}/PR/sched.h (59%) create mode 100644 include/PR/sp.h create mode 100644 include/PR/sptask.h create mode 100644 include/PR/ucode.h create mode 100644 include/PR/ucode_debug.h create mode 100644 include/PR/ultraerror.h create mode 100644 include/PR/ultralog.h create mode 100644 include/PR/ultratypes.h create mode 100644 include/PR/uportals.h create mode 100644 include/make/PRdefs rename {src/include/PR => include}/sys/asm.h (100%) create mode 100755 include/sys/regdef.h create mode 100644 include/sys/u64driver.h create mode 100644 include/sys/u64gio.h create mode 100644 include/tinymon.h create mode 100644 include/ultra64.h create mode 100644 include/ultrahost.h delete mode 100644 src/include/PR/gbi.inc delete mode 100644 src/include/PR/gbi_old.h delete mode 100644 src/include/PR/gu.h delete mode 100644 src/include/PR/libultra.h delete mode 100644 src/include/PR/os_internal.h delete mode 100644 src/include/PR/os_misc.h delete mode 100644 src/include/PR/os_pfs.h delete mode 100644 src/include/PR/os_pi.h delete mode 100644 src/include/PR/os_thread.h delete mode 100644 src/include/PR/os_time.h delete mode 100644 src/include/PR/os_vi.h delete mode 100644 src/include/PR/sptask.h delete mode 100755 src/include/PR/synthInternals.h delete mode 100755 src/include/PR/sys/regdef.h delete mode 100644 src/include/PR/ucode.h delete mode 100644 src/include/PR/ultratypes.h delete mode 100644 src/include/lib/lib_30ce0.h delete mode 100644 src/include/libultra_internal.h create mode 100755 src/include/stdarg.h rename src/include/{lib/libc/ldiv.h => stdlib.h} (69%) mode change 100644 => 100755 create mode 100755 src/include/string.h delete mode 100644 src/include/ultra64.h create mode 100644 src/lib/naudio/n_abi.h create mode 100644 src/lib/naudio/n_cseqp.h rename src/lib/{ultra/audio/csplayer.c => naudio/n_csplayer.c} (98%) rename src/lib/{ultra/audio/cseq.c => naudio/n_csq.c} (95%) rename src/lib/{lib_3e8c0.c => naudio/n_env.c} (97%) rename src/lib/{ultra/audio/event.c => naudio/n_event.c} (74%) create mode 100644 src/lib/naudio/n_seqp.h rename src/lib/{lib_3d280.c => naudio/n_seqplayer.c} (95%) create mode 100644 src/lib/naudio/n_sndp.h create mode 100644 src/lib/naudio/n_syndelete.c create mode 100644 src/lib/naudio/n_synsetpriority.c create mode 100644 src/lib/naudio/n_synthInternals.h rename src/lib/{lib_30ce0.c => naudio/n_synthesizer.c} (90%) create mode 100644 src/lib/ultra/audio/cseq.h create mode 100644 src/lib/ultra/audio/cseqp.h create mode 100644 src/lib/ultra/audio/initfx.h create mode 100644 src/lib/ultra/audio/seq.h rename src/{include/PR => lib/ultra/audio}/seqp.h (56%) mode change 100755 => 100644 create mode 100644 src/lib/ultra/audio/sl.c create mode 100644 src/lib/ultra/audio/sndp.h delete mode 100644 src/lib/ultra/audio/syndelete.c delete mode 100644 src/lib/ultra/audio/synsetpriority.c create mode 100644 src/lib/ultra/audio/synthInternals.h create mode 100644 src/lib/ultra/gu/guint.h create mode 100644 src/lib/ultra/gu/sintable.h create mode 100755 src/lib/ultra/io/controller.h create mode 100755 src/lib/ultra/io/piint.h create mode 100755 src/lib/ultra/io/siint.h create mode 100755 src/lib/ultra/io/viint.h create mode 100755 src/lib/ultra/libc/xstdio.h create mode 100755 src/lib/ultra/os/osint.h diff --git a/Makefile b/Makefile index d4cd6296b..b69861f80 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ ifeq ($(ROMID),jpn-final) VERSION=5 endif -DEFINES := VERSION=$(VERSION) NTSC=$(NTSC) PAL=$(PAL) JPN=$(JPN) PIRACYCHECKS=$(PIRACYCHECKS) +DEFINES := VERSION=$(VERSION) NTSC=$(NTSC) PAL=$(PAL) JPN=$(JPN) PIRACYCHECKS=$(PIRACYCHECKS) _FINALROM=1 C_DEFINES := $(foreach d,$(DEFINES),-D$(d)) AS_DEFINES := $(foreach d,$(DEFINES),--defsym $(d)) --defsym _LANGUAGE_ASSEMBLY=1 @@ -90,12 +90,10 @@ MIPS3_C_FILES := \ G_C_FILES := \ $(shell find src/lib/ultra/audio -name '*.c') \ + $(shell find src/lib/naudio -name '*.c') \ src/lib/lib_2fba0.c \ - src/lib/lib_30ce0.c \ src/lib/lib_3a100.c \ - src/lib/lib_3d280.c \ src/lib/lib_3e730.c \ - src/lib/lib_3e8c0.c \ src/lib/mp3.c \ src/lib/speaker.c @@ -178,12 +176,15 @@ CFLAGS = $(C_DEFINES) \ -Xcpluscomm \ -woff 581,649,819,820,821,838,852 \ -w2 \ + -I include \ + -I include/PR \ -I src/include \ -I src/generated/$(ROMID) \ + -I src/lib/ultra/audio \ $(OPT_LVL) \ $(MIPSISET) -ASFLAGS = -march=vr4300 -mabi=32 -Isrc/include $(AS_DEFINES) +ASFLAGS = -march=vr4300 -mabi=32 -Iinclude -Iinclude/PR -Isrc/include -Isrc/lib/ultra/audio $(AS_DEFINES) C_FILES := $(shell find src/lib src/game src/inflate -name '*.c') S_FILES := $(shell find src/lib src/game src/preamble -name '*.s') @@ -506,7 +507,7 @@ $(B_DIR)/%.o: src/%.c $(ASSETMGR_O_FILES) $(B_DIR)/%.o: src/%.s @mkdir -p $(dir $@) - cpp -P -Wno-trigraphs -I src/include $(C_DEFINES) -D_LANGUAGE_ASSEMBLY -D_MIPSEB $< | $(AS) $(ASFLAGS) -o $@ + cpp -P -Wno-trigraphs -I include -I include/PR -I src/include $(C_DEFINES) -D_LANGUAGE_ASSEMBLY -D_MIPSEB $< | $(AS) $(ASFLAGS) -o $@ $(B_DIR)/assets/%.o: $(A_DIR)/%.c @mkdir -p $(dir $@) diff --git a/include/PR/PRimage.h b/include/PR/PRimage.h new file mode 100644 index 000000000..145e9326c --- /dev/null +++ b/include/PR/PRimage.h @@ -0,0 +1,126 @@ +/************************************************************************** + * + * $Revision: 1.4 $ + * $Date: 1997/11/26 00:30:50 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/PRimage.h,v $ + * + **************************************************************************/ + +#ifndef __GL_IMAGE_H__ +#define __GL_IMAGE_H__ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Defines for image files . . . . + * + * Paul Haeberli - 1984 + * Look in /usr/people/4Dgifts/iristools/imgtools for example code! + * + */ + +#include + +#define IMAGIC 0732 + +/* colormap of images */ +#define CM_NORMAL 0 /* file contains rows of values which + * are either RGB values (zsize == 3) + * or greyramp values (zsize == 1) */ +#define CM_DITHERED 1 +#define CM_SCREEN 2 /* file contains data which is a screen + * image; getrow returns buffer which + * can be displayed directly with + * writepixels */ +#define CM_COLORMAP 3 /* a colormap file */ + +#define TYPEMASK 0xff00 +#define BPPMASK 0x00ff +#define ITYPE_VERBATIM 0x0000 +#define ITYPE_RLE 0x0100 +#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE) +#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM) +#define BPP(type) ((type) & BPPMASK) +#define RLE(bpp) (ITYPE_RLE | (bpp)) +#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp)) +#define IBUFSIZE(pixels) (((pixels)+((pixels)>>6))<<2) +#define RLE_NOP 0x00 + +#define ierror(p) (((p)->flags&_IOERR)!=0) +#define ifileno(p) ((p)->file) +#define getpix(p) (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p)) +#define putpix(p,x) (--(p)->cnt>=0 \ + ? ((int)(*(p)->ptr++=(unsigned)(x))) \ + : iflsbuf(p,(unsigned)(x))) + +typedef struct { + unsigned short imagic; /* stuff saved on disk . . */ + unsigned short type; + unsigned short dim; + unsigned short xsize; + unsigned short ysize; + unsigned short zsize; + unsigned long min; + unsigned long max; + unsigned long wastebytes; + char name[80]; + unsigned long colormap; + + long file; /* stuff used in core only */ + unsigned short flags; + short dorev; + short x; + short y; + short z; + short cnt; + unsigned short *ptr; + unsigned short *base; + unsigned short *tmpbuf; + unsigned long offset; + unsigned long rleend; /* for rle images */ + unsigned long *rowstart; /* for rle images */ + long *rowsize; /* for rle images */ +} IMAGE; + +IMAGE *icreate(); +/* + * IMAGE *iopen(char *file, char *mode, unsigned int type, unsigned int dim, + * unsigned int xsize, unsigned int ysize, unsigned int zsize); + * IMAGE *fiopen(int f, char *mode, unsigned int type, unsigned int dim, + * unsigned int xsize, unsigned int ysize, unsigned int zsize); + * + * ...while iopen and fiopen can take an extended set of parameters, the + * last five are optional, so a more correct prototype would be: + * + */ +IMAGE *iopen(char *file, char *mode, ...); +IMAGE *fiopen(int f, char *mode, ...); + +/* + * + * unsigned short *ibufalloc(IMAGE *image); + * int ifilbuf(IMAGE *image); + * int iflush(IMAGE *image); + * unsigned int iflsbuf(IMAGE *image, unsigned int c); + * void isetname(IMAGE *image, char *name); + * void isetcolormap(IMAGE *image, int colormap); + */ + +int iclose(IMAGE *image); +int putrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); +int getrow(IMAGE *image, unsigned short *buffer, unsigned int y, unsigned int z); + +/* +IMAGE *iopen(); +IMAGE *icreate(); +*/ + +unsigned short *ibufalloc(); + +#define IMAGEDEF /* for backwards compatibility */ +#ifdef __cplusplus +} +#endif +#endif /* !__GL_IMAGE_H__ */ diff --git a/src/include/PR/R4300.h b/include/PR/R4300.h old mode 100755 new mode 100644 similarity index 99% rename from src/include/PR/R4300.h rename to include/PR/R4300.h index 932694d3f..0c25f1d58 --- a/src/include/PR/R4300.h +++ b/include/PR/R4300.h @@ -14,7 +14,7 @@ * * $Revision: 1.13 $ * $Date: 1997/02/11 08:15:34 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/R4300.h,v $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/R4300.h,v $ * **************************************************************************/ diff --git a/src/include/PR/abi.h b/include/PR/abi.h similarity index 89% rename from src/include/PR/abi.h rename to include/PR/abi.h index 9c826f4c5..02d440d35 100644 --- a/src/include/PR/abi.h +++ b/include/PR/abi.h @@ -17,7 +17,7 @@ * * $Revision: 1.32 $ * $Date: 1997/02/11 08:16:37 $ - * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/abi.h,v $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/abi.h,v $ * **************************************************************************/ @@ -240,7 +240,9 @@ typedef union { /* * ADPCM State */ -typedef short ADPCM_STATE[16]; +#define ADPCMVSIZE 8 +#define ADPCMFSIZE 16 +typedef short ADPCM_STATE[ADPCMFSIZE]; /* * Pole filter state @@ -400,26 +402,6 @@ typedef short ENVMIX_STATE[40]; _a->words.w1 = (unsigned int) d; \ } -/* - * -------------------------------------------------------------------- - * The below command is seemingly declared manually and used for the - * sound driver. - * -------------------------------------------------------------------- - */ - -// This is a version of aSetAudio which takes a single 32-bit parameter -// instead of two 16-bit ones. According to AziAudio, it is used to set -// ramping values when neither bit 4 nor bit 8 is set in the flags parameter. - -#define aSetVolume32(pkt, f, v, tr) \ -{ \ - Acmd *_a = (Acmd *)pkt; \ - \ - _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 16) | \ - _SHIFTL(v, 0, 16)); \ - _a->words.w1 = (unsigned int)(tr); \ -} - #endif /* _LANGUAGE_C */ #endif /* !_ABI_H_ */ diff --git a/src/include/PR/gbi.h b/include/PR/gbi.h similarity index 97% rename from src/include/PR/gbi.h rename to include/PR/gbi.h index 31b756943..170916445 100644 --- a/src/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -11,9 +11,9 @@ **************************************************************************/ /************************************************************************** * - * $Revision: 1.141 $ - * $Date: 1999/09/03 03:43:08 $ - * $Source: /exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gbi.h,v $ + * $Revision: 1.138 $ + * $Date: 1998/12/24 09:05:08 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gbi.h,v $ * **************************************************************************/ @@ -75,13 +75,13 @@ * * IMPLEMENTATION NOTE: * There is another group of RDP commands that includes the triangle commands - * generated by the RSP code. These are the raw commands the rasterizer - * hardware chews on, with slope info, etc. They will follow the RDP + * generated by the RSP code. These are the raw commands the rasterizer + * hardware chews on, with slope info, etc. They will follow the RDP * ordering... * * IMPLEMENTATION NOTE: - * The RDP hardware has some of these bit patterns wired up. If the hardware - * changes, we must adjust this table, likewise we can't change/add things + * The RDP hardware has some of these bit patterns wired up. If the hardware + * changes, we must adjust this table, likewise we can't change/add things * once the hardware is frozen. (actually, the RDP hardware only looks at * the lower 6 bits of the command byte) * @@ -198,7 +198,7 @@ #define G_TEXRECT 0xe4 /* -28 */ -/* +/* * The following commands are the "generated" RDP commands; the user * never sees them, the RSP microcode generates them. * @@ -231,8 +231,8 @@ /* masks to build RDP triangle commands: */ #define G_RDP_TRI_FILL_MASK 0x08 #define G_RDP_TRI_SHADE_MASK 0x04 -#define G_RDP_TRI_TXTR_MASK 0x02 -#define G_RDP_TRI_ZBUFF_MASK 0x01 +#define G_RDP_TRI_TXTR_MASK 0x02 +#define G_RDP_TRI_ZBUFF_MASK 0x01 /* * HACK: @@ -318,7 +318,7 @@ * * DO NOT USE THE LOW 8 BITS OF GEOMETRYMODE: * The weird bit-ordering is for the micro-code: the lower byte - * can be OR'd in with G_TRI_SHADE (11001100) to construct + * can be OR'd in with G_TRI_SHADE (11001100) to construct * the triangle command directly. Don't break it... * * DO NOT USE THE HIGH 8 BITS OF GEOMETRYMODE: @@ -332,7 +332,7 @@ * appropriately and use primcolor to see anything. * * G_SHADING_SMOOTH enabled means use all 3 colors of the triangle. - * If it is not set, then do 'flat shading', where only one vertex color + * If it is not set, then do 'flat shading', where only one vertex color * is used (and all 3 vertices are set to that same color by the ucode) * See the man page for gSP1Triangle(). * @@ -837,27 +837,27 @@ Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | \ ZMODE_OPA | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - + #define RM_ZB_XLU_SURF(clk) \ Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_OPA_DECAL(clk) \ Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - + #define RM_ZB_XLU_DECAL(clk) \ Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_CLD_SURF(clk) \ Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_OVL_SURF(clk) \ Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | \ GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - + #define RM_ZB_PCL_SURF(clk) \ Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ G_AC_DITHER | \ @@ -1044,7 +1044,7 @@ * element, we can't depend on the C compiler to align things * properly. * - * 64-bit structure alignment is enforced by wrapping structures with + * 64-bit structure alignment is enforced by wrapping structures with * unions that contain a dummy "long long int". Why this works is * explained in the ANSI C Spec, or on page 186 of the second edition * of K&R, "The C Programming Language". @@ -1108,14 +1108,14 @@ typedef struct { /* 20 bytes for above */ /* padding to bring structure size to 64 bit allignment */ - char dummy[4]; + char dummy[4]; } uSprite_t; -typedef union { +typedef union { uSprite_t s; - /* Need to make sure this is 64 bit aligned */ + /* Need to make sure this is 64 bit aligned */ long long int force_structure_allignment[3]; } uSprite; @@ -1194,7 +1194,7 @@ typedef union { */ #ifdef F3DEX_GBI_2 /* 0,4 are reserved by G_MTX */ -# define G_MV_MMTX 2 +# define G_MV_MMTX 2 # define G_MV_PMTX 6 # define G_MV_VIEWPORT 8 # define G_MV_LIGHT 10 @@ -1252,7 +1252,7 @@ typedef union { /* * These are offsets from the address in the dmem table - */ + */ #define G_MWO_NUMLIGHT 0x00 #define G_MWO_CLIP_RNX 0x04 #define G_MWO_CLIP_RNY 0x0c @@ -1334,7 +1334,7 @@ typedef union { * * Note: only directional (infinite) lights are currently supported. * - * Note: the weird order is for the DMEM alignment benefit of + * Note: the weird order is for the DMEM alignment benefit of * the microcode. * */ @@ -1655,7 +1655,7 @@ typedef struct { /* * Textured rectangles are 128 bits not 64 bits - */ + */ typedef struct { unsigned long w0; unsigned long w1; @@ -1713,9 +1713,9 @@ typedef union { } #define gsDma0p(c, s, l) \ -{{ \ +{ \ _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24), (unsigned int)(s) \ -}} +} #define gDma1p(pkt, c, s, l, p) \ { \ @@ -1727,11 +1727,11 @@ typedef union { } #define gsDma1p(c, s, l, p) \ -{{ \ +{ \ (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ _SHIFTL((l), 0, 16)), \ (unsigned int)(s) \ -}} +} #define gDma2p(pkt, c, adrs, len, idx, ofs) \ { \ @@ -1741,11 +1741,11 @@ typedef union { _g->words.w1 = (unsigned int)(adrs); \ } #define gsDma2p(c, adrs, len, idx, ofs) \ -{{ \ +{ \ (_SHIFTL((c),24,8)|_SHIFTL(((len)-1)/8,19,5)| \ _SHIFTL((ofs)/8,8,8)|_SHIFTL((idx),0,8)), \ (unsigned int)(adrs) \ -}} +} #define gSPNoOp(pkt) gDma0p(pkt, G_SPNOOP, 0, 0) #define gsSPNoOp() gsDma0p(G_SPNOOP, 0, 0) @@ -1778,10 +1778,10 @@ typedef union { _g->words.w1 = (unsigned int)(v); \ } # define gsSPVertex(v, n, v0) \ -{{ \ +{ \ (_SHIFTL(G_VTX,24,8)|_SHIFTL((n),12,8)|_SHIFTL((v0)+(n),1,7)), \ (unsigned int)(v) \ -}} +} #elif (defined(F3DEX_GBI)||defined(F3DLP_GBI)) /* * F3DEX_GBI: G_VTX GBI format was changed to support 64 vertice. @@ -1803,7 +1803,7 @@ typedef union { gsDma1p(G_VTX, v, sizeof(Vtx)*(n), ((n)-1)<<4|(v0)) #endif - + #ifdef F3DEX_GBI_2 # define gSPViewport(pkt, v) \ gDma2p((pkt), G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT, 0) @@ -1836,9 +1836,9 @@ typedef union { } #define gsImmp0(c) \ -{{ \ +{ \ _SHIFTL((c), 24, 8) \ -}} +} #define gImmp1(pkt, c, p0) \ { \ @@ -1849,9 +1849,9 @@ typedef union { } #define gsImmp1(c, p0) \ -{{ \ +{ \ _SHIFTL((c), 24, 8), (unsigned int)(p0) \ -}} +} #define gImmp2(pkt, c, p0, p1) \ { \ @@ -1862,9 +1862,9 @@ typedef union { } #define gsImmp2(c, p0, p1) \ -{{ \ +{ \ _SHIFTL((c), 24, 8), _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8)\ -}} +} #define gImmp3(pkt, c, p0, p1, p2) \ { \ @@ -1876,10 +1876,10 @@ typedef union { } #define gsImmp3(c, p0, p1, p2) \ -{{ \ +{ \ _SHIFTL((c), 24, 8), (_SHIFTL((p0), 16, 16) | \ _SHIFTL((p1), 8, 8) | _SHIFTL((p2), 0, 8))\ -}} +} #define gImmp21(pkt, c, p0, p1, dat) \ { \ @@ -1891,10 +1891,10 @@ typedef union { } #define gsImmp21(c, p0, p1, dat) \ -{{ \ +{ \ _SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | _SHIFTL((p1), 0, 8),\ (unsigned int) (dat) \ -}} +} #ifdef F3DEX_GBI_2 #define gMoveWd(pkt, index, offset, data) \ @@ -1922,13 +1922,13 @@ typedef union { } #define gsSPSprite2DScaleFlip(sx, sy, fx, fy) \ -{{ \ +{ \ (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ _SHIFTL((fx), 8, 8) | \ _SHIFTL((fy), 0, 8)), \ (_SHIFTL((sx), 16, 16) | \ _SHIFTL((sy), 0, 16)) \ -}} +} #define gSPSprite2DDraw(pkt, px, py) \ { \ @@ -1940,11 +1940,11 @@ typedef union { } #define gsSPSprite2DDraw(px, py) \ -{{ \ +{ \ (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)), \ (_SHIFTL((px), 16, 16) | \ _SHIFTL((py), 0, 16)) \ -}} +} /* @@ -1995,10 +1995,10 @@ typedef union { _g->words.w1 = 0; \ } #define gsSP1Triangle(v0, v1, v2, flag) \ -{{ \ +{ \ _SHIFTL(G_TRI1, 24, 8)|__gsSP1Triangle_w1f(v0, v1, v2, flag), \ 0 \ -}} +} /*** *** Line @@ -2012,10 +2012,10 @@ typedef union { _g->words.w1 = 0; \ } #define gsSPLine3D(v0, v1, flag) \ -{{ \ +{ \ _SHIFTL(G_LINE3D, 24, 8)|__gsSPLine3D_w1f(v0, v1, 0, flag), \ 0 \ -}} +} /*** *** LineW @@ -2035,10 +2035,10 @@ typedef union { _g->words.w1 = 0; \ } #define gsSPLineW3D(v0, v1, wd, flag) \ -{{ \ +{ \ _SHIFTL(G_LINE3D, 24, 8)|__gsSPLine3D_w1f(v0, v1, wd, flag), \ 0 \ -}} +} /*** *** 1 Quadrangle @@ -2053,16 +2053,16 @@ typedef union { } #define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ -{{ \ +{ \ (_SHIFTL(G_QUAD, 24, 8)| \ __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ -}} +} #else /* F3DEX_GBI_2 */ /*** *** 1 Triangle - ***/ + ***/ #define gSP1Triangle(pkt, v0, v1, v2, flag) \ { \ Gfx *_g = (Gfx *)(pkt); \ @@ -2071,10 +2071,10 @@ typedef union { _g->words.w1 = __gsSP1Triangle_w1f(v0, v1, v2, flag); \ } #define gsSP1Triangle(v0, v1, v2, flag) \ -{{ \ +{ \ _SHIFTL(G_TRI1, 24, 8), \ __gsSP1Triangle_w1f(v0, v1, v2, flag) \ -}} +} /*** *** Line @@ -2087,10 +2087,10 @@ typedef union { _g->words.w1 = __gsSPLine3D_w1f(v0, v1, 0, flag); \ } #define gsSPLine3D(v0, v1, flag) \ -{{ \ +{ \ _SHIFTL(G_LINE3D, 24, 8), \ __gsSPLine3D_w1f(v0, v1, 0, flag) \ -}} +} /*** *** LineW @@ -2109,10 +2109,10 @@ typedef union { _g->words.w1 = __gsSPLine3D_w1f(v0, v1, wd, flag); \ } #define gsSPLineW3D(v0, v1, wd, flag) \ -{{ \ +{ \ _SHIFTL(G_LINE3D, 24, 8), \ __gsSPLine3D_w1f(v0, v1, wd, flag) \ -}} +} /*** *** 1 Quadrangle @@ -2127,11 +2127,11 @@ typedef union { } #define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ -{{ \ +{ \ (_SHIFTL(G_TRI2, 24, 8)| \ __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ -}} +} #endif /* F3DEX_GBI_2 */ #if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) @@ -2148,11 +2148,11 @@ typedef union { } #define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ -{{ \ +{ \ (_SHIFTL(G_TRI2, 24, 8)| \ __gsSP1Triangle_w1f(v00, v01, v02, flag0)), \ __gsSP1Triangle_w1f(v10, v11, v12, flag1) \ -}} +} #endif /* F3DEX_GBI/F3DLP_GBI */ @@ -2167,10 +2167,10 @@ typedef union { } #define gsSPCullDisplayList(vstart,vend) \ -{{ \ +{ \ _SHIFTL(G_CULLDL, 24, 8) | _SHIFTL((vstart)*2, 0, 16), \ _SHIFTL((vend)*2, 0, 16) \ -}} +} #else #define gSPCullDisplayList(pkt,vstart,vend) \ @@ -2183,10 +2183,10 @@ typedef union { } #define gsSPCullDisplayList(vstart,vend) \ -{{ \ +{ \ _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart))*40), \ ((0x0f & ((vend)+1))*40) \ -}} +} #endif #define gSPSegment(pkt, segment, base) \ @@ -2230,7 +2230,7 @@ typedef union { * Insert values into Matrix * * where = element of matrix (byte offset) - * num = new element (32 bit value replacing 2 int or 2 frac matrix + * num = new element (32 bit value replacing 2 int or 2 frac matrix * componants */ #ifdef F3DEX_GBI_2 @@ -2258,7 +2258,7 @@ typedef union { #define gsSPForceMatrix(mptr) \ gsDma2p(G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0), \ gsMoveWd(G_MW_FORCEMTX,0,0x00010000) - + #else /* F3DEX_GBI_2 */ #define gSPForceMatrix(pkt, mptr) \ { \ @@ -2290,11 +2290,11 @@ typedef union { _g->words.w1 = (unsigned int)(val); \ } # define gsSPModifyVertex(vtx, where, val) \ -{{ \ +{ \ _SHIFTL(G_MODIFYVTX,24,8)| \ _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16), \ (unsigned int)(val) \ -}} +} #else # define gSPModifyVertex(pkt, vtx, where, val) \ gMoveWd(pkt, G_MW_POINTS, (vtx)*40+(where), val) @@ -2306,7 +2306,7 @@ typedef union { /* * gSPBranchLessZ Branch DL if (vtx.z) less than or equal (zval). * - * dl = DL branch to + * dl = DL branch to * vtx = Vertex * zval = Screen depth * near = Near plane @@ -2340,10 +2340,10 @@ typedef union { } #define gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, zmin, zmax) \ -{{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(dl), }}, \ -{{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - G_DEPTOZSrg(zval, near, far, flag, zmin, zmax), }} +{ _SHIFTL(G_RDPHALF_1,24,8), \ + (unsigned int)(dl), }, \ +{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ + G_DEPTOZSrg(zval, near, far, flag, zmin, zmax), } #define gSPBranchLessZ(pkt, dl, vtx, zval, near, far, flag) \ gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, 0, G_MAXZ) @@ -2353,7 +2353,7 @@ typedef union { /* * gSPBranchLessZraw Branch DL if (vtx.z) less than or equal (raw zval). * - * dl = DL branch to + * dl = DL branch to * vtx = Vertex * zval = Raw value of screen depth */ @@ -2369,10 +2369,10 @@ typedef union { } #define gsSPBranchLessZraw(dl, vtx, zval) \ -{{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(dl), }}, \ -{{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - (unsigned int)(zval), }} +{ _SHIFTL(G_RDPHALF_1,24,8), \ + (unsigned int)(dl), }, \ +{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ + (unsigned int)(zval), } /* * gSPLoadUcode RSP loads specified ucode. @@ -2392,11 +2392,11 @@ typedef union { } #define gsSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize) \ -{{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(uc_dstart), }}, \ -{{ _SHIFTL(G_LOAD_UCODE,24,8)| \ +{ _SHIFTL(G_RDPHALF_1,24,8), \ + (unsigned int)(uc_dstart), }, \ +{ _SHIFTL(G_LOAD_UCODE,24,8)| \ _SHIFTL((int)(uc_dsize)-1,0,16), \ - (unsigned int)(uc_start), }} + (unsigned int)(uc_start), } #define gSPLoadUcode(pkt, uc_start, uc_dstart) \ gSPLoadUcodeEx((pkt), (uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) @@ -2424,11 +2424,11 @@ typedef union { } #define gsSPDma_io(flag, dmem, dram, size) \ -{{ \ +{ \ _SHIFTL(G_DMA_IO,24,8)|_SHIFTL((flag),23,1)| \ _SHIFTL((dmem)/8,13,10)|_SHIFTL((size)-1,0,12), \ (unsigned int)(dram) \ -}} +} #define gSPDmaRead(pkt,dmem,dram,size) gSPDma_io((pkt),0,(dmem),(dram),(size)) #define gsSPDmaRead(dmem,dram,size) gsSPDma_io(0,(dmem),(dram),(size)) @@ -2454,7 +2454,7 @@ typedef union { #define NUMLIGHTS_7 7 /* * n should be one of: NUMLIGHTS_0, NUMLIGHTS_1, ..., NUMLIGHTS_7 - * NOTE: in addition to the number of directional lights specified, + * NOTE: in addition to the number of directional lights specified, * there is always 1 ambient light */ #define gSPNumLights(pkt, n) \ @@ -2466,7 +2466,7 @@ typedef union { #define LIGHT_2 2 #define LIGHT_3 3 #define LIGHT_4 4 -#define LIGHT_5 5 +#define LIGHT_5 5 #define LIGHT_6 6 #define LIGHT_7 7 #define LIGHT_8 8 @@ -2674,11 +2674,16 @@ typedef union { #define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \ gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) +#define gsDPSetHilite1Tile(tile, hilite, width, height) \ + gsDPSetTileSize(tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ + ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) #define gDPSetHilite2Tile(pkt, tile, hilite, width, height) \ gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) - +#define gsDPSetHilite2Tile(tile, hilite, width, height) \ + gsDPSetTileSize(tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ + ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) /* * FOG macros @@ -2691,7 +2696,7 @@ typedef union { * min, max: range 0 to 1000: 0=nearplane, 1000=farplane * min is where fog begins (usually less than max and often 0) * max is where fog is thickest (usually 1000) - * + * */ #define gSPFogFactor(pkt, fm, fo) \ gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ @@ -2726,12 +2731,12 @@ typedef union { _g->words.w1 = (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)); \ } # define gsSPTexture(s, t, level, tile, on) \ -{{ \ +{ \ (_SHIFTL(G_TEXTURE,24,8) | _SHIFTL(BOWTIE_VAL,16,8) | \ _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | _SHIFTL((on),1,7)),\ (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)) \ -}} -/* +} +/* * Different version of SPTexture macro, has an additional parameter * which is currently reserved in the microcode. */ @@ -2746,11 +2751,11 @@ typedef union { _g->words.w1 = (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)); \ } # define gsSPTextureL(s, t, level, xparam, tile, on) \ -{{ \ +{ \ (_SHIFTL(G_TEXTURE,24,8) | _SHIFTL((xparam),16,8) | \ _SHIFTL((level),11,3) | _SHIFTL((tile),8,3) | _SHIFTL((on),1,7)),\ (_SHIFTL((s),16,16) | _SHIFTL((t),0,16)) \ -}} +} #else /* * Macros to turn texture on/off @@ -2765,12 +2770,12 @@ typedef union { _g->words.w1 = (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)); \ } # define gsSPTexture(s, t, level, tile, on) \ -{{ \ +{ \ (_SHIFTL(G_TEXTURE,24,8)|_SHIFTL(BOWTIE_VAL,16,8)| \ _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)|_SHIFTL((on),0,8)), \ (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)) \ -}} -/* +} +/* * Different version of SPTexture macro, has an additional parameter * which is currently reserved in the microcode. */ @@ -2784,11 +2789,11 @@ typedef union { _g->words.w1 = (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)); \ } # define gsSPTextureL(s, t, level, xparam, tile, on) \ -{{ \ +{ \ (_SHIFTL(G_TEXTURE,24,8)|_SHIFTL((xparam),16,8)| \ _SHIFTL((level),11,3)|_SHIFTL((tile),8,3)|_SHIFTL((on),0,8)), \ (_SHIFTL((s),16,16)|_SHIFTL((t),0,16)) \ -}} +} #endif #define gSPPerspNormalize(pkt, s) gMoveWd(pkt, G_MW_PERSPNORM, 0, (s)) @@ -2813,9 +2818,9 @@ typedef union { } #define gsSPEndDisplayList() \ -{{ \ +{ \ _SHIFTL(G_ENDDL, 24, 8), 0 \ -}} +} #ifdef F3DEX_GBI_2 /* @@ -2834,15 +2839,15 @@ typedef union { } #define gsSPGeometryMode(c, s) \ -{{ \ +{ \ (_SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24)),(u32)(s) \ -}} +} #define gSPSetGeometryMode(pkt, word) gSPGeometryMode((pkt),0,(word)) #define gsSPSetGeometryMode(word) gsSPGeometryMode(0,(word)) #define gSPClearGeometryMode(pkt, word) gSPGeometryMode((pkt),(word),0) #define gsSPClearGeometryMode(word) gsSPGeometryMode((word),0) #define gSPLoadGeometryMode(pkt, word) gSPGeometryMode((pkt),-1,(word)) -#define gsSPLoadGeometryMode(word) gsSPGeometryMode(-1,(word)) +#define gsSPLoadGeometryMode(pkt, word) gsSPGeometryMode(-1,(word)) #else /* F3DEX_GBI_2 */ #define gSPSetGeometryMode(pkt, word) \ @@ -2854,9 +2859,9 @@ typedef union { } #define gsSPSetGeometryMode(word) \ -{{ \ +{ \ _SHIFTL(G_SETGEOMETRYMODE, 24, 8), (unsigned int)(word) \ -}} +} #define gSPClearGeometryMode(pkt, word) \ { \ @@ -2867,9 +2872,9 @@ typedef union { } #define gsSPClearGeometryMode(word) \ -{{ \ +{ \ _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8), (unsigned int)(word) \ -}} +} #endif /* F3DEX_GBI_2 */ #ifdef F3DEX_GBI_2 @@ -2882,10 +2887,10 @@ typedef union { } #define gsSPSetOtherMode(cmd, sft, len, data) \ -{{ \ +{ \ _SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)|_SHIFTL((len)-1,0,8), \ (unsigned int)(data) \ -}} +} #else #define gSPSetOtherMode(pkt, cmd, sft, len, data) \ { \ @@ -2897,10 +2902,10 @@ typedef union { } #define gsSPSetOtherMode(cmd, sft, len, data) \ -{{ \ +{ \ _SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8), \ (unsigned int)(data) \ -}} +} #endif /* @@ -2970,7 +2975,7 @@ typedef union { gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) #endif -/* 'blendmask' is not supported anymore. +/* 'blendmask' is not supported anymore. * The bits are reserved for future use. * Fri May 26 13:45:55 PDT 1995 */ @@ -3004,11 +3009,11 @@ typedef union { } #define gsSetImage(cmd, fmt, siz, width, i) \ -{{ \ +{ \ _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12), \ (unsigned int)(i) \ -}} +} #define gDPSetColorImage(pkt, f, s, w, i) gSetImage(pkt, G_SETCIMG, f, s, w, i) #define gsDPSetColorImage(f, s, w, i) gsSetImage(G_SETCIMG, f, s, w, i) @@ -3037,10 +3042,10 @@ typedef union { } #define gsDPSetCombine(muxs0, muxs1) \ -{{ \ +{ \ _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24), \ (unsigned int)(muxs1) \ -}} +} #define GCCc0w0(saRGB0, mRGB0, saA0, mA0) \ (_SHIFTL((saRGB0), 20, 4) | _SHIFTL((mRGB0), 15, 5) | \ @@ -3082,7 +3087,7 @@ typedef union { #define gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ -{{ \ +{ \ _SHIFTL(G_SETCOMBINE, 24, 8) | \ _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ @@ -3092,7 +3097,7 @@ typedef union { GCCc1w1(G_CCMUX_##b1, G_ACMUX_##Aa1, \ G_ACMUX_##Ac1, G_CCMUX_##d1, \ G_ACMUX_##Ab1, G_ACMUX_##Ad1)) \ -}} +} /* * SetCombineMode macros are NOT redunant. It allow the C preprocessor @@ -3116,9 +3121,9 @@ typedef union { } #define gsDPSetColor(c, d) \ -{{ \ +{ \ _SHIFTL(c, 24, 8), (unsigned int)(d) \ -}} +} #define DPRGBColor(pkt, cmd, r, g, b, a) \ gDPSetColor(pkt, cmd, \ @@ -3164,19 +3169,19 @@ typedef union { } #define gsDPSetPrimColor(m, l, r, g, b, a) \ -{{ \ +{ \ (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | \ _SHIFTL(l, 0, 8)), \ (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | \ _SHIFTL(a, 0, 8)) \ -}} +} /* * gDPSetOtherMode (This is for expert user.) * * This command makes all othermode parameters set. * Do not use this command in the same DL with another g*SPSetOtherMode DLs. - * + * * [Usage] * gDPSetOtherMode(pkt, modeA, modeB) * @@ -3208,10 +3213,10 @@ typedef union { } #define gsDPSetOtherMode(mode0, mode1) \ -{{ \ +{ \ _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24), \ (unsigned int)(mode1) \ -}} +} /* * Texturing macros @@ -3284,10 +3289,10 @@ typedef union { } #define gsDPLoadTileGeneric(c, tile, uls, ult, lrs, lrt) \ -{{ \ +{ \ _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12), \ _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | _SHIFTL(lrt, 0, 12)\ -}} +} #define gDPSetTileSize(pkt, t, uls, ult, lrs, lrt) \ gDPLoadTileGeneric(pkt, G_SETTILESIZE, t, uls, ult, lrs, lrt) @@ -3314,14 +3319,14 @@ typedef union { #define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, \ maskt, shiftt, cms, masks, shifts) \ -{{ \ +{ \ (_SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) | \ _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | _SHIFTL(tmem, 0, 9)),\ (_SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ _SHIFTL(shiftt, 10, 4) | _SHIFTL(cms, 8, 2) | \ _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4)) \ -}} +} /* * For RCP 2.0, the maximum number of texels that can be loaded @@ -3345,13 +3350,13 @@ typedef union { } #define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \ -{{ \ +{ \ (_SHIFTL(G_LOADBLOCK, 24, 8) | _SHIFTL(uls, 12, 12) | \ _SHIFTL(ult, 0, 12)), \ (_SHIFTL(tile, 24, 3) | \ _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) | \ _SHIFTL(dxt, 0, 12)) \ -}} +} #define gDPLoadTLUTCmd(pkt, tile, count) \ { \ @@ -3362,10 +3367,10 @@ typedef union { } #define gsDPLoadTLUTCmd(tile, count) \ -{{ \ +{ \ _SHIFTL(G_LOADTLUT, 24, 8), \ _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10) \ -}} +} #define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, \ pal, cms, cmt, masks, maskt, shifts, shiftt) \ @@ -3429,9 +3434,9 @@ typedef union { ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ } -/* +/* * Allow tmem address and render tile to be specified. - * The S at the end means odd lines are already word Swapped + * The S at the end means odd lines are already word Swapped */ #define gDPLoadMultiBlockS(pkt, timg, tmem, rtile, fmt, siz, width, \ height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ @@ -3647,13 +3652,13 @@ typedef union { ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ ((height)-1) << G_TEXTURE_IMAGE_FRAC) -/* +/* * Allows tmem and render tile to be specified. Useful when loading * several tiles at a time. * * Here is the static form of the pre-swapped texture block loading * See gDPLoadTextureBlockS() for reference. Basically, just don't - * calculate DxT, use 0 + * calculate DxT, use 0 */ #define gsDPLoadMultiBlockS(timg, tmem, rtile, fmt, siz, width, height, \ @@ -3737,7 +3742,7 @@ typedef union { } /* - * 4-bit load block. Allows tmem and render tile to be specified. Useful when + * 4-bit load block. Allows tmem and render tile to be specified. Useful when * loading multiple tiles. The S means odd lines are already word swapped. */ #define gDPLoadMultiBlock_4bS(pkt, timg, tmem, rtile, fmt, width, height,\ @@ -4172,7 +4177,7 @@ typedef union { G_IM_FMT_RGBA, G_IM_SIZ_16b, 4*16, 1, \ pal, 0, 0, 0, 0, 0, 0) -#endif /* _HW_VERSION_1 */ +#endif /* _HW_VERSION_1 */ /* * Load a 256-entry palette (for 8-bit CI textures) @@ -4214,7 +4219,7 @@ typedef union { gsDPLoadSync(), \ gsDPLoadTLUTCmd(G_TX_LOADTILE, 255), \ gsDPPipeSync() - + #else /* **** WORKAROUND hardware 1 load_tlut bug ****** */ #define gsDPLoadTLUT_pal256(dram) \ @@ -4269,7 +4274,7 @@ typedef union { G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, count, \ 0, 0, 0, 0, 0, 0, 0) -#endif /* _HW_VERSION_1 */ +#endif /* _HW_VERSION_1 */ #define gDPSetScissor(pkt, mode, ulx, uly, lrx, lry) \ { \ @@ -4297,24 +4302,24 @@ typedef union { } #define gsDPSetScissor(mode, ulx, uly, lrx, lry) \ -{{ \ +{ \ _SHIFTL(G_SETSCISSOR, 24, 8) | \ _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ _SHIFTL((int)((float)(uly)*4.0F), 0, 12), \ _SHIFTL(mode, 24, 2) | \ _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ _SHIFTL((int)((float)(lry)*4.0F), 0, 12) \ -}} +} #define gsDPSetScissorFrac(mode, ulx, uly, lrx, lry) \ -{{ \ +{ \ _SHIFTL(G_SETSCISSOR, 24, 8) | \ _SHIFTL((int)((ulx)), 12, 12) | \ _SHIFTL((int)((uly)), 0, 12), \ _SHIFTL(mode, 24, 2) | \ _SHIFTL((int)(lrx), 12, 12) | \ _SHIFTL((int)(lry), 0, 12) \ -}} +} /* Fraction never used in fill */ #define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \ @@ -4327,11 +4332,11 @@ typedef union { } #define gsDPFillRectangle(ulx, uly, lrx, lry) \ -{{ \ +{ \ (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | \ _SHIFTL((lry), 2, 10)), \ (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)) \ -}} +} /* like gDPFillRectangle but accepts negative arguments */ #define gDPScisFillRectangle(pkt, ulx, uly, lrx, lry) \ @@ -4357,12 +4362,12 @@ typedef union { } #define gsDPSetConvert(k0, k1, k2, k3, k4, k5) \ -{{ \ +{ \ (_SHIFTL(G_SETCONVERT, 24, 8) | \ - _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTR(k2, 5, 4)), \ + _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTL(k2, 5, 4)), \ (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | _SHIFTL(k4, 9, 9) | \ _SHIFTL(k5, 0, 9)) \ -}} +} #define gDPSetKeyR(pkt, cR, sR, wR) \ { \ @@ -4374,10 +4379,10 @@ typedef union { } #define gsDPSetKeyR(cR, sR, wR) \ -{{ \ +{ \ _SHIFTL(G_SETKEYR, 24, 8), \ _SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | _SHIFTL(sR, 0, 8) \ -}} +} #define gDPSetKeyGB(pkt, cG, sG, wG, cB, sB, wB) \ { \ @@ -4390,12 +4395,12 @@ typedef union { } #define gsDPSetKeyGB(cG, sG, wG, cB, sB, wB) \ -{{ \ +{ \ (_SHIFTL(G_SETKEYGB, 24, 8) | _SHIFTL(wG, 12, 12) | \ _SHIFTL(wB, 0, 12)), \ (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | _SHIFTL(cB, 8, 8) | \ _SHIFTL(sB, 0, 8)) \ -}} +} #define gDPNoParam(pkt, cmd) \ { \ @@ -4406,9 +4411,9 @@ typedef union { } #define gsDPNoParam(cmd) \ -{{ \ +{ \ _SHIFTL(cmd, 24, 8), 0 \ -}} +} #define gDPParam(pkt, cmd, param) \ { \ @@ -4419,25 +4424,25 @@ typedef union { } #define gsDPParam(cmd, param) \ -{{ \ +{ \ _SHIFTL(cmd, 24, 8), (param) \ -}} +} /* Notice that textured rectangles are 128-bit commands, therefore - * gsDPTextureRectangle() should not be used in display lists + * gsDPTextureRectangle() should not be used in display lists * under normal circumstances (use gsSPTextureRectangle()). * That is also why there is no gDPTextureRectangle() macros. */ #define gsDPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{{ \ +{ \ (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ _SHIFTL(yh, 0, 12)), \ (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ -}}, \ -{{ \ +}, \ +{ \ _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ -}} +} #define gDPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ { \ @@ -4453,15 +4458,15 @@ typedef union { } #define gsDPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{{ \ +{ \ (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ _SHIFTL(yh, 0, 12)), \ (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ -}}, \ -{{ \ +}, \ +{ \ _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ -}} +} #define gDPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ { \ @@ -4477,8 +4482,8 @@ typedef union { } #define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - {{(_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12))}}, \ + (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ + (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) @@ -4523,9 +4528,9 @@ typedef union { } #define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - {{(_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ + (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12))}}, \ + (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) diff --git a/src/include/PR/gs2dex.h b/include/PR/gs2dex.h similarity index 68% rename from src/include/PR/gs2dex.h rename to include/PR/gs2dex.h index 16318db17..c484ba1f1 100644 --- a/src/include/PR/gs2dex.h +++ b/include/PR/gs2dex.h @@ -1,392 +1,393 @@ -/*--------------------------------------------------------------------- - Copyright (C) 1997, Nintendo. - - File gs2dex.h - Coded by Yoshitaka Yasumoto. Jul 31, 1997. - Modified by - Comments Header file for S2DEX ucode. - - $Id: gs2dex.h,v 1.21 1998/05/28 00:14:49 has Exp $ - ---------------------------------------------------------------------*/ - -#ifndef _GS2DEX_H_ -#define _GS2DEX_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -/*===========================================================================* - * Macro - *===========================================================================*/ -#define GS_CALC_DXT(line) (((1<< G_TX_DXT_FRAC)-1)/(line)+1) -#define GS_PIX2TMEM(pix, siz) ((pix)>>(4-(siz))) -#define GS_PIX2DXT(pix, siz) GS_CALC_DXT(GS_PIX2TMEM((pix), (siz))) - -/*===========================================================================* - * Data structures for S2DEX microcode - *===========================================================================*/ - -/*---------------------------------------------------------------------------* - * Background - *---------------------------------------------------------------------------*/ -#define G_BGLT_LOADBLOCK 0x0033 -#define G_BGLT_LOADTILE 0xfff4 - -#define G_BG_FLAG_FLIPS 0x01 -#define G_BG_FLAG_FLIPT 0x10 - -/* Non scalable background plane */ -typedef struct { - u16 imageX; /* x-coordinate of upper-left position of texture (u10.5) */ - u16 imageW; /* width of the texture (u10.2) */ - s16 frameX; /* upper-left position of transferred frame (s10.2) */ - u16 frameW; /* width of transferred frame (u10.2) */ - - u16 imageY; /* y-coordinate of upper-left position of texture (u10.5) */ - u16 imageH; /* height of the texture (u10.2) */ - s16 frameY; /* upper-left position of transferred frame (s10.2) */ - u16 frameH; /* height of transferred frame (u10.2) */ - - u64 *imagePtr; /* texture source address on DRAM */ - u16 imageLoad; /* which to use, LoadBlock or LoadTile */ - u8 imageFmt; /* format of texel - G_IM_FMT_* */ - u8 imageSiz; /* size of texel - G_IM_SIZ_* */ - u16 imagePal; /* pallet number */ - u16 imageFlip; /* right & left image inversion (Inverted by G_BG_FLAG_FLIPS) */ - - /* The following is set in the initialization routine guS2DInitBg(). There is no need for the user to set it. */ - u16 tmemW; /* TMEM width and Word size of frame 1 line. - At LoadBlock, GS_PIX2TMEM(imageW/4,imageSiz) - At LoadTile GS_PIX2TMEM(frameW/4,imageSiz)+1 */ - u16 tmemH; /* height of TMEM loadable at a time (s13.2) 4 times value - When the normal texture, 512/tmemW*4 - When the CI texture, 256/tmemW*4 */ - u16 tmemLoadSH; /* SH value - At LoadBlock, tmemSize/2-1 - At LoadTile, tmemW*16-1 */ - u16 tmemLoadTH; /* TH value or Stride value - At LoadBlock, GS_CALC_DXT(tmemW) - At LoadTile, tmemH-1 */ - u16 tmemSizeW; /* skip value of imagePtr for image 1-line - At LoadBlock, tmemW*2 - At LoadTile, GS_PIX2TMEM(imageW/4,imageSiz)*2 */ - u16 tmemSize; /* skip value of imagePtr for 1-loading - = tmemSizeW*tmemH */ -} uObjBg_t; /* 40 bytes */ - -/* Scalable background plane */ -typedef struct { - u16 imageX; /* x-coordinate of upper-left position of texture (u10.5) */ - u16 imageW; /* width of texture (u10.2) */ - s16 frameX; /* upper-left position of transferred frame (s10.2) */ - u16 frameW; /* width of transferred frame (u10.2) */ - - u16 imageY; /* y-coordinate of upper-left position of texture (u10.5) */ - u16 imageH; /* height of texture (u10.2) */ - s16 frameY; /* upper-left position of transferred frame (s10.2) */ - u16 frameH; /* height of transferred frame (u10.2) */ - - u64 *imagePtr; /* texture source address on DRAM */ - u16 imageLoad; /* Which to use, LoadBlock or LoadTile? */ - u8 imageFmt; /* format of texel - G_IM_FMT_* */ - u8 imageSiz; /* size of texel - G_IM_SIZ_* */ - u16 imagePal; /* pallet number */ - u16 imageFlip; /* right & left image inversion (Inverted by G_BG_FLAG_FLIPS) */ - - u16 scaleW; /* scale value of X-direction (u5.10) */ - u16 scaleH; /* scale value of Y-direction (u5.10) */ - s32 imageYorig; /* start point of drawing on image (s20.5) */ - - u8 padding[4]; - -} uObjScaleBg_t; /* 40 bytes */ - -typedef union { - uObjBg_t b; - uObjScaleBg_t s; - long long int force_structure_alignment; -} uObjBg; - -/*---------------------------------------------------------------------------* - * 2D Objects - *---------------------------------------------------------------------------*/ -#define G_OBJ_FLAG_FLIPS 1<<0 /* inversion to S-direction */ -#define G_OBJ_FLAG_FLIPT 1<<4 /* nversion to T-direction */ - -typedef struct { - s16 objX; /* s10.2 OBJ x-coordinate of upper-left end */ - u16 scaleW; /* u5.10 Scaling of u5.10 width direction */ - u16 imageW; /* u10.5 width of u10.5 texture (length of S-direction) */ - u16 paddingX; /* Unused - Always 0 */ - s16 objY; /* s10.2 OBJ y-coordinate of s10.2 OBJ upper-left end */ - u16 scaleH; /* u5.10 Scaling of u5.10 height direction */ - u16 imageH; /* u10.5 height of u10.5 texture (length of T-direction) */ - u16 paddingY; /* Unused - Always 0 */ - u16 imageStride; /* folding width of texel (In units of 64bit word) */ - u16 imageAdrs; /* texture header position in TMEM (In units of 64bit word) */ - u8 imageFmt; /* format of texel - G_IM_FMT_* */ - u8 imageSiz; /* size of texel - G_IM_SIZ_* */ - u8 imagePal; /* pallet number (0-7) */ - u8 imageFlags; /* The display flag - G_OBJ_FLAG_FLIP* */ -} uObjSprite_t; /* 24 bytes */ - -typedef union { - uObjSprite_t s; - long long int force_structure_alignment; -} uObjSprite; - -/*---------------------------------------------------------------------------* - * 2D Matrix - *---------------------------------------------------------------------------*/ -typedef struct { - s32 A, B, C, D; /* s15.16 */ - s16 X, Y; /* s10.2 */ - u16 BaseScaleX; /* u5.10 */ - u16 BaseScaleY; /* u5.10 */ -} uObjMtx_t; /* 24 bytes */ - -typedef union { - uObjMtx_t m; - long long int force_structure_alignment; -} uObjMtx; - -typedef struct { - s16 X, Y; /* s10.2 */ - u16 BaseScaleX; /* u5.10 */ - u16 BaseScaleY; /* u5.10 */ -} uObjSubMtx_t; /* 8 bytes */ - -typedef union { - uObjSubMtx_t m; - long long int force_structure_alignment; -} uObjSubMtx; - -/*---------------------------------------------------------------------------* - * Loading into TMEM - *---------------------------------------------------------------------------*/ -#define G_OBJLT_TXTRBLOCK 0x00001033 -#define G_OBJLT_TXTRTILE 0x00fc1034 -#define G_OBJLT_TLUT 0x00000030 - -#define GS_TB_TSIZE(pix,siz) (GS_PIX2TMEM((pix),(siz))-1) -#define GS_TB_TLINE(pix,siz) (GS_CALC_DXT(GS_PIX2TMEM((pix),(siz)))) - -typedef struct { - u32 type; /* G_OBJLT_TXTRBLOCK divided into types */ - u64 *image; /* texture source address on DRAM */ - u16 tmem; /* loaded TMEM word address (8byteWORD) */ - u16 tsize; /* Texture size, Specified by macro GS_TB_TSIZE() */ - u16 tline; /* width of Texture 1-line, Specified by macro GS_TB_TLINE() */ - u16 sid; /* STATE ID Multipled by 4 (Either one of 0, 4, 8 and 12) */ - u32 flag; /* STATE flag */ - u32 mask; /* STATE mask */ -} uObjTxtrBlock_t; /* 24 bytes */ - -#define GS_TT_TWIDTH(pix,siz) ((GS_PIX2TMEM((pix), (siz))<<2)-1) -#define GS_TT_THEIGHT(pix,siz) (((pix)<<2)-1) - -typedef struct { - u32 type; /* G_OBJLT_TXTRTILE divided into types */ - u64 *image; /* texture source address on DRAM */ - u16 tmem; /* loaded TMEM word address (8byteWORD)*/ - u16 twidth; /* width of Texture (Specified by macro GS_TT_TWIDTH()) */ - u16 theight; /* height of Texture (Specified by macro GS_TT_THEIGHT()) */ - u16 sid; /* STATE ID Multipled by 4 (Either one of 0, 4, 8 and 12) */ - u32 flag; /* STATE flag */ - u32 mask; /* STATE mask */ -} uObjTxtrTile_t; /* 24 bytes */ - -#define GS_PAL_HEAD(head) ((head)+256) -#define GS_PAL_NUM(num) ((num)-1) - -typedef struct { - u32 type; /* G_OBJLT_TLUT divided into types */ - u64 *image; /* texture source address on DRAM */ - u16 phead; /* pallet number of load header (Between 256 and 511) */ - u16 pnum; /* loading pallet number -1 */ - u16 zero; /* Assign 0 all the time */ - u16 sid; /* STATE ID Multipled by 4 (Either one of 0, 4, 8 and 12)*/ - u32 flag; /* STATE flag */ - u32 mask; /* STATE mask */ -} uObjTxtrTLUT_t; /* 24 bytes */ - -typedef union { - uObjTxtrBlock_t block; - uObjTxtrTile_t tile; - uObjTxtrTLUT_t tlut; - long long int force_structure_alignment; -} uObjTxtr; - -/*---------------------------------------------------------------------------* - * Loading into TMEM & 2D Objects - *---------------------------------------------------------------------------*/ -typedef struct { - uObjTxtr txtr; - uObjSprite sprite; -} uObjTxSprite; /* 48 bytes */ - -/*===========================================================================* - * GBI Commands for S2DEX microcode - *===========================================================================*/ -/* GBI Header */ -#ifdef F3DEX_GBI_2 -#define G_OBJ_RECTANGLE_R 0xda -#define G_OBJ_MOVEMEM 0xdc -#define G_RDPHALF_0 0xe4 -#define G_OBJ_RECTANGLE 0x01 -#define G_OBJ_SPRITE 0x02 -#define G_SELECT_DL 0x04 -#define G_OBJ_LOADTXTR 0x05 -#define G_OBJ_LDTX_SPRITE 0x06 -#define G_OBJ_LDTX_RECT 0x07 -#define G_OBJ_LDTX_RECT_R 0x08 -#define G_BG_1CYC 0x09 -#define G_BG_COPY 0x0a -#define G_OBJ_RENDERMODE 0x0b -#else -#define G_BG_1CYC 0x01 -#define G_BG_COPY 0x02 -#define G_OBJ_RECTANGLE 0x03 -#define G_OBJ_SPRITE 0x04 -#define G_OBJ_MOVEMEM 0x05 -#define G_SELECT_DL 0xb0 -#define G_OBJ_RENDERMODE 0xb1 -#define G_OBJ_RECTANGLE_R 0xb2 -#define G_OBJ_LOADTXTR 0xc1 -#define G_OBJ_LDTX_SPRITE 0xc2 -#define G_OBJ_LDTX_RECT 0xc3 -#define G_OBJ_LDTX_RECT_R 0xc4 -#define G_RDPHALF_0 0xe4 -#endif - -/*---------------------------------------------------------------------------* - * Background wrapped screen - *---------------------------------------------------------------------------*/ -#define gSPBgRectangle(pkt, m, mptr) gDma0p((pkt),(m),(mptr),0) -#define gsSPBgRectangle(m, mptr) gsDma0p( (m),(mptr),0) -#define gSPBgRectCopy(pkt, mptr) gSPBgRectangle((pkt), G_BG_COPY, (mptr)) -#define gsSPBgRectCopy(mptr) gsSPBgRectangle( G_BG_COPY, (mptr)) -#define gSPBgRect1Cyc(pkt, mptr) gSPBgRectangle((pkt), G_BG_1CYC, (mptr)) -#define gsSPBgRect1Cyc(mptr) gsSPBgRectangle( G_BG_1CYC, (mptr)) - -/*---------------------------------------------------------------------------* - * 2D Objects - *---------------------------------------------------------------------------*/ -#define gSPObjSprite(pkt, mptr) gDma0p((pkt),G_OBJ_SPRITE, (mptr),0) -#define gsSPObjSprite(mptr) gsDma0p( G_OBJ_SPRITE, (mptr),0) -#define gSPObjRectangle(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE, (mptr),0) -#define gsSPObjRectangle(mptr) gsDma0p( G_OBJ_RECTANGLE, (mptr),0) -#define gSPObjRectangleR(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE_R,(mptr),0) -#define gsSPObjRectangleR(mptr) gsDma0p( G_OBJ_RECTANGLE_R,(mptr),0) - -/*---------------------------------------------------------------------------* - * 2D Matrix - *---------------------------------------------------------------------------*/ -#define gSPObjMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),0,23) -#define gsSPObjMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),0,23) -#define gSPObjSubMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),2, 7) -#define gsSPObjSubMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),2, 7) - -/*---------------------------------------------------------------------------* - * Loading into TMEM - *---------------------------------------------------------------------------*/ -#define gSPObjLoadTxtr(pkt, tptr) gDma0p((pkt),G_OBJ_LOADTXTR, (tptr),23) -#define gsSPObjLoadTxtr(tptr) gsDma0p( G_OBJ_LOADTXTR, (tptr),23) -#define gSPObjLoadTxSprite(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_SPRITE,(tptr),47) -#define gsSPObjLoadTxSprite(tptr) gsDma0p( G_OBJ_LDTX_SPRITE,(tptr),47) -#define gSPObjLoadTxRect(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT, (tptr),47) -#define gsSPObjLoadTxRect(tptr) gsDma0p( G_OBJ_LDTX_RECT, (tptr),47) -#define gSPObjLoadTxRectR(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT_R,(tptr),47) -#define gsSPObjLoadTxRectR(tptr) gsDma0p( G_OBJ_LDTX_RECT_R,(tptr),47) - -/*---------------------------------------------------------------------------* - * Select Display List - *---------------------------------------------------------------------------*/ -#define gSPSelectDL(pkt, mptr, sid, flag, mask) \ -{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } -#define gsSPSelectDL(mptr, sid, flag, mask) \ -{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } -#define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \ -{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } -#define gsSPSelectBranchDL(mptr, sid, flag, mask) \ -{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ - gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } - -/*---------------------------------------------------------------------------* - * Set general status - *---------------------------------------------------------------------------*/ -#define G_MW_GENSTAT 0x08 /* Note that it is the same value of G_MW_FOG */ - -#define gSPSetStatus(pkt, sid, val) \ - gMoveWd((pkt), G_MW_GENSTAT, (sid), (val)) -#define gsSPSetStatus(sid, val) \ - gsMoveWd( G_MW_GENSTAT, (sid), (val)) - -/*---------------------------------------------------------------------------* - * Set Object Render Mode - *---------------------------------------------------------------------------*/ -#define G_OBJRM_NOTXCLAMP 0x01 -#define G_OBJRM_XLU 0x02 /* Ignored */ -#define G_OBJRM_ANTIALIAS 0x04 /* Ignored */ -#define G_OBJRM_BILERP 0x08 -#define G_OBJRM_SHRINKSIZE_1 0x10 -#define G_OBJRM_SHRINKSIZE_2 0x20 -#define G_OBJRM_WIDEN 0x40 - -#define gSPObjRenderMode(pkt, mode) gImmp1((pkt),G_OBJ_RENDERMODE,(mode)) -#define gsSPObjRenderMode(mode) gsImmp1( G_OBJ_RENDERMODE,(mode)) - -/*===========================================================================* - * Render Mode Macro - *===========================================================================*/ -#define RM_RA_SPRITE(clk) \ - AA_EN | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define G_RM_SPRITE G_RM_OPA_SURF -#define G_RM_SPRITE2 G_RM_OPA_SURF2 -#define G_RM_RA_SPRITE RM_RA_SPRITE(1) -#define G_RM_RA_SPRITE2 RM_RA_SPRITE(2) -#define G_RM_AA_SPRITE G_RM_AA_TEX_TERR -#define G_RM_AA_SPRITE2 G_RM_AA_TEX_TERR2 -#define G_RM_XLU_SPRITE G_RM_XLU_SURF -#define G_RM_XLU_SPRITE2 G_RM_XLU_SURF2 -#define G_RM_AA_XLU_SPRITE G_RM_AA_XLU_SURF -#define G_RM_AA_XLU_SPRITE2 G_RM_AA_XLU_SURF2 - -/*===========================================================================* - * External functions - *===========================================================================*/ -extern u64 gspS2DEX_fifoTextStart[], gspS2DEX_fifoTextEnd[]; -extern u64 gspS2DEX_fifoDataStart[], gspS2DEX_fifoDataEnd[]; -extern u64 gspS2DEX_fifo_dTextStart[], gspS2DEX_fifo_dTextEnd[]; -extern u64 gspS2DEX_fifo_dDataStart[], gspS2DEX_fifo_dDataEnd[]; -extern u64 gspS2DEX2_fifoTextStart[], gspS2DEX2_fifoTextEnd[]; -extern u64 gspS2DEX2_fifoDataStart[], gspS2DEX2_fifoDataEnd[]; -extern u64 gspS2DEX2_xbusTextStart[], gspS2DEX2_xbusTextEnd[]; -extern u64 gspS2DEX2_xbusDataStart[], gspS2DEX2_xbusDataEnd[]; -extern void guS2DInitBg(uObjBg *); - -#ifdef F3DEX_GBI_2 -# define guS2DEmuBgRect1Cyc guS2D2EmuBgRect1Cyc /*Wrapper*/ -# define guS2DEmuSetScissor guS2D2EmuSetScissor /*Wrapper*/ - extern void guS2D2EmuSetScissor(u32, u32, u32, u32, u8); - extern void guS2D2EmuBgRect1Cyc(Gfx **, uObjBg *); -#else - extern void guS2DEmuSetScissor(u32, u32, u32, u32, u8); - extern void guS2DEmuBgRect1Cyc(Gfx **, uObjBg *); -#endif - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif -#endif /* _GS2DEX_H_ */ - -/*======== End of gs2dex.h ========*/ +/*--------------------------------------------------------------------- + Copyright (C) 1997, Nintendo. + + File gs2dex.h + Coded by Yoshitaka Yasumoto. Jul 31, 1997. + Modified by + Comments Header file for S2DEX ucode. + + $Id: gs2dex.h,v 1.21 1998/05/28 00:14:49 has Exp $ + ---------------------------------------------------------------------*/ + +#ifndef _GS2DEX_H_ +#define _GS2DEX_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +/*===========================================================================* + * Macro + *===========================================================================*/ +#define GS_CALC_DXT(line) (((1<< G_TX_DXT_FRAC)-1)/(line)+1) +#define GS_PIX2TMEM(pix, siz) ((pix)>>(4-(siz))) +#define GS_PIX2DXT(pix, siz) GS_CALC_DXT(GS_PIX2TMEM((pix), (siz))) + +/*===========================================================================* + * Data structures for S2DEX microcode + *===========================================================================*/ + +/*---------------------------------------------------------------------------* + * Background + *---------------------------------------------------------------------------*/ +#define G_BGLT_LOADBLOCK 0x0033 +#define G_BGLT_LOADTILE 0xfff4 + +#define G_BG_FLAG_FLIPS 0x01 +#define G_BG_FLAG_FLIPT 0x10 + +/* Non scalable background plane */ +typedef struct { + u16 imageX; /* ¥Æ¥¯¥¹¥Á¥ã¤Îº¸¾å°ÌÃÖ X ºÂɸ (u10.5) */ + u16 imageW; /* ¥Æ¥¯¥¹¥Á¥ã¤ÎÉý (u10.2) */ + s16 frameX; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤Îº¸¾å°ÌÃÖ(s10.2) */ + u16 frameW; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤ÎÉý (u10.2) */ + + u16 imageY; /* ¥Æ¥¯¥¹¥Á¥ã¤Îº¸¾å°ÌÃÖ Y ºÂɸ (u10.5) */ + u16 imageH; /* ¥Æ¥¯¥¹¥Á¥ã¤Î¹â¤µ (u10.2) */ + s16 frameY; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤Îº¸¾å°ÌÃÖ(s10.2) */ + u16 frameH; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤Î¹â¤µ (u10.2) */ + + u64 *imagePtr; /* DRAM ¾å¤Î¥Æ¥¯¥¹¥Á¥ã¥½¡¼¥¹¥¢¥É¥ì¥¹ */ + u16 imageLoad; /* LoadBlock, LoadTile ¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤« */ + u8 imageFmt; /* ¥Æ¥¯¥»¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È G_IM_FMT_* */ + u8 imageSiz; /* ¥Æ¥¯¥»¥ë¤Î¥µ¥¤¥º G_IM_SIZ_* */ + u16 imagePal; /* ¥Ñ¥ì¥Ã¥ÈÈÖ¹æ */ + u16 imageFlip; /* ¥¤¥á¡¼¥¸¤Îº¸±¦È¿Å¾ G_BG_FLAG_FLIPS ¤Çȿž */ + + /* °Ê²¼¤Ï½é´ü²½¥ë¡¼¥Á¥ó guS2DInitBg() Æâ¤ÇÀßÄꤵ¤ì¤ë¤Î¤Ç¥æ¡¼¥¶¤¬Àß + Äꤹ¤ëɬÍפϤʤ¤ */ + u16 tmemW; /* frame 1 ¥é¥¤¥ó¤Î TMEM Éý Word ¥µ¥¤¥º + LoadBlock ¤Î»þ GS_PIX2TMEM(imageW/4,imageSiz) + LoadTile ¤Î»þ GS_PIX2TMEM(frameW/4,imageSiz)+1 */ + u16 tmemH; /* °ìÅÙ¤Ë¥í¡¼¥É¤Ç¤­¤ë TMEM ¹â¤µ (s13.2) 4ÇÜÃÍ + ÄÌ¾ï¥Æ¥¯¥¹¥Á¥ã¤Î»þ 512/tmemW*4 + CI ¥Æ¥¯¥¹¥Á¥ã¤Î»þ 256/tmemW*4 */ + u16 tmemLoadSH; /* SH ÃÍ + LoadBlock ¤Î»þ tmemSize/2-1 + LoadTile ¤Î»þ tmemW*16-1 */ + u16 tmemLoadTH; /* TH ÃÍ or Stride ÃÍ + LoadBlock ¤Î»þ GS_CALC_DXT(tmemW) + LoadTile ¤Î»þ tmemH-1 */ + u16 tmemSizeW; /* image 1 ¥é¥¤¥óʬ¤Î imagePtr ¤Î¥¹¥­¥Ã¥×ÃÍ + LoadBlock ¤Î»þ tmemW*2 + LoadTile ¤Î»þ GS_PIX2TMEM(imageW/4,imageSiz)*2 */ + u16 tmemSize; /* ¥í¡¼¥É°ì²óʬ¤Î imagePtr ¤Î¥¹¥­¥Ã¥×ÃÍ + = tmemSizeW*tmemH */ +} uObjBg_t; /* 40 bytes */ + +/* Scalable background plane */ +typedef struct { + u16 imageX; /* ¥Æ¥¯¥¹¥Á¥ã¤Îº¸¾å°ÌÃÖ X ºÂɸ (u10.5) */ + u16 imageW; /* ¥Æ¥¯¥¹¥Á¥ã¤ÎÉý (u10.2) */ + s16 frameX; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤Îº¸¾å°ÌÃÖ(s10.2) */ + u16 frameW; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤ÎÉý (u10.2) */ + + u16 imageY; /* ¥Æ¥¯¥¹¥Á¥ã¤Îº¸¾å°ÌÃÖ Y ºÂɸ (u10.5) */ + u16 imageH; /* ¥Æ¥¯¥¹¥Á¥ã¤Î¹â¤µ (u10.2) */ + s16 frameY; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤Îº¸¾å°ÌÃÖ(s10.2) */ + u16 frameH; /* žÁ÷¤µ¤ì¤ë¥Õ¥ì¡¼¥à¤Î¹â¤µ (u10.2) */ + + u64 *imagePtr; /* DRAM ¾å¤Î¥Æ¥¯¥¹¥Á¥ã¥½¡¼¥¹¥¢¥É¥ì¥¹ */ + u16 imageLoad; /* LoadBlock, LoadTile ¤Î¤É¤Á¤é¤ò»ÈÍѤ¹¤ë¤« */ + u8 imageFmt; /* ¥Æ¥¯¥»¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È G_IM_FMT_* */ + u8 imageSiz; /* ¥Æ¥¯¥»¥ë¤Î¥µ¥¤¥º G_IM_SIZ_* */ + u16 imagePal; /* ¥Ñ¥ì¥Ã¥ÈÈÖ¹æ */ + u16 imageFlip; /* ¥¤¥á¡¼¥¸¤Îº¸±¦È¿Å¾ G_BG_FLAG_FLIPS ¤Çȿž */ + + u16 scaleW; /* X Êý¸þ¥¹¥±¡¼¥ëÃÍ (u5.10) */ + u16 scaleH; /* Y Êý¸þ¥¹¥±¡¼¥ëÃÍ (u5.10) */ + s32 imageYorig; /* image ¤Ë¤ª¤±¤ëÉÁ²è»ÏÅÀ (s20.5) */ + + u8 padding[4]; + +} uObjScaleBg_t; /* 40 bytes */ + +typedef union { + uObjBg_t b; + uObjScaleBg_t s; + long long int force_structure_alignment; +} uObjBg; + +/*---------------------------------------------------------------------------* + * 2D Objects + *---------------------------------------------------------------------------*/ +#define G_OBJ_FLAG_FLIPS 1<<0 /* S Êý¸þȿž */ +#define G_OBJ_FLAG_FLIPT 1<<4 /* T Êý¸þȿž */ + +typedef struct { + s16 objX; /* s10.2 OBJ º¸¾åü X ºÂɸ */ + u16 scaleW; /* u5.10 ÉýÊý¸þ¥¹¥±¡¼¥ê¥ó¥° */ + u16 imageW; /* u10.5 ¥Æ¥¯¥¹¥Á¥ã¤ÎÉý (S Êý¸þ¤ÎŤµ) */ + u16 paddingX; /* ̤»ÈÍÑ ¾ï¤Ë 0 */ + s16 objY; /* s10.2 OBJ º¸¾åü Y ºÂɸ */ + u16 scaleH; /* u5.10 ¹â¤µÊý¸þ¥¹¥±¡¼¥ê¥ó¥° */ + u16 imageH; /* u10.5 ¥Æ¥¯¥¹¥Á¥ã¤Î¹â¤µ (T Êý¸þ¤ÎŤµ) */ + u16 paddingY; /* ̤»ÈÍÑ ¾ï¤Ë 0 */ + u16 imageStride; /* ¥Æ¥¯¥»¥ë¤ÎÀÞ¤êÊÖ¤·Éý (64bit word ñ°Ì) */ + u16 imageAdrs; /* TMEM Æâ¤Î¥Æ¥¯¥¹¥Á¥ãÀèÆ¬°ÌÃÖ (64bit word ñ°Ì) */ + u8 imageFmt; /* ¥Æ¥¯¥»¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È G_IM_FMT_* */ + u8 imageSiz; /* ¥Æ¥¯¥»¥ë¤Î¥µ¥¤¥º G_IM_SIZ_* */ + u8 imagePal; /* ¥Ñ¥ì¥Ã¥ÈÈÖ¹æ 0-7 */ + u8 imageFlags; /* ɽ¼¨¥Õ¥é¥° G_OBJ_FLAG_FLIP* */ +} uObjSprite_t; /* 24 bytes */ + +typedef union { + uObjSprite_t s; + long long int force_structure_alignment; +} uObjSprite; + +/*---------------------------------------------------------------------------* + * 2D Matrix + *---------------------------------------------------------------------------*/ +typedef struct { + s32 A, B, C, D; /* s15.16 */ + s16 X, Y; /* s10.2 */ + u16 BaseScaleX; /* u5.10 */ + u16 BaseScaleY; /* u5.10 */ +} uObjMtx_t; /* 24 bytes */ + +typedef union { + uObjMtx_t m; + long long int force_structure_alignment; +} uObjMtx; + +typedef struct { + s16 X, Y; /* s10.2 */ + u16 BaseScaleX; /* u5.10 */ + u16 BaseScaleY; /* u5.10 */ +} uObjSubMtx_t; /* 8 bytes */ + +typedef union { + uObjSubMtx_t m; + long long int force_structure_alignment; +} uObjSubMtx; + +/*---------------------------------------------------------------------------* + * Loading into TMEM + *---------------------------------------------------------------------------*/ +#define G_OBJLT_TXTRBLOCK 0x00001033 +#define G_OBJLT_TXTRTILE 0x00fc1034 +#define G_OBJLT_TLUT 0x00000030 + +#define GS_TB_TSIZE(pix,siz) (GS_PIX2TMEM((pix),(siz))-1) +#define GS_TB_TLINE(pix,siz) (GS_CALC_DXT(GS_PIX2TMEM((pix),(siz)))) + +typedef struct { + u32 type; /* Type ¼ïÊÌ G_OBJLT_TXTRBLOCK */ + u64 *image; /* DRAM ¾å¤Î¥Æ¥¯¥¹¥Á¥ã¥½¡¼¥¹¥¢¥É¥ì¥¹ */ + u16 tmem; /* ¥í¡¼¥ÉÀè¤Î TMEM ¥ï¡¼¥É¥¢¥É¥ì¥¹ (8byteWORD) */ + u16 tsize; /* Texture ¥µ¥¤¥º ¥Þ¥¯¥í GS_TB_TSIZE() ¤Ç»ØÄê */ + u16 tline; /* Texture 1 ¥é¥¤¥óÉý ¥Þ¥¯¥í GS_TB_TLINE() ¤Ç»ØÄê */ + u16 sid; /* STATE ID 4 ¤ÎÇÜ¿ô¤Ç 0,4,8,12 ¤Î¤É¤ì¤« */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrBlock_t; /* 24 bytes */ + +#define GS_TT_TWIDTH(pix,siz) ((GS_PIX2TMEM((pix), (siz))<<2)-1) +#define GS_TT_THEIGHT(pix,siz) (((pix)<<2)-1) + +typedef struct { + u32 type; /* Type ¼ïÊÌ G_OBJLT_TXTRTILE */ + u64 *image; /* DRAM ¾å¤Î¥Æ¥¯¥¹¥Á¥ã¥½¡¼¥¹¥¢¥É¥ì¥¹ */ + u16 tmem; /* ¥í¡¼¥ÉÀè¤Î TMEM ¥ï¡¼¥É¥¢¥É¥ì¥¹ (8byteWORD) */ + u16 twidth; /* Texture Éý ¥Þ¥¯¥í GS_TT_TWIDTH() ¤Ç»ØÄê */ + u16 theight; /* Texture ¹â¤µ ¥Þ¥¯¥í GS_TT_THEIGHT() ¤Ç»ØÄê */ + u16 sid; /* STATE ID 4 ¤ÎÇÜ¿ô¤Ç 0,4,8,12 ¤Î¤É¤ì¤« */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrTile_t; /* 24 bytes */ + +#define GS_PAL_HEAD(head) ((head)+256) +#define GS_PAL_NUM(num) ((num)-1) + +typedef struct { + u32 type; /* Type ¼ïÊÌ G_OBJLT_TLUT */ + u64 *image; /* DRAM ¾å¤Î¥Æ¥¯¥¹¥Á¥ã¥½¡¼¥¹¥¢¥É¥ì¥¹ */ + u16 phead; /* ¥í¡¼¥ÉÀèÆ¬¤Î¥Ñ¥ì¥Ã¥ÈÈÖ¹æ 256 °Ê¾å 511 °Ê²¼ */ + u16 pnum; /* ¥í¡¼¥É¤¹¤ë¥Ñ¥ì¥Ã¥È¿ô - 1 */ + u16 zero; /* ¾ï¤Ë 0 ¤òÂåÆþ¤¹¤ë */ + u16 sid; /* STATE ID 4 ¤ÎÇÜ¿ô¤Ç 0,4,8,12 ¤Î¤É¤ì¤« */ + u32 flag; /* STATE flag */ + u32 mask; /* STATE mask */ +} uObjTxtrTLUT_t; /* 24 bytes */ + +typedef union { + uObjTxtrBlock_t block; + uObjTxtrTile_t tile; + uObjTxtrTLUT_t tlut; + long long int force_structure_alignment; +} uObjTxtr; + +/*---------------------------------------------------------------------------* + * Loading into TMEM & 2D Objects + *---------------------------------------------------------------------------*/ +typedef struct { + uObjTxtr txtr; + uObjSprite sprite; +} uObjTxSprite; /* 48 bytes */ + +/*===========================================================================* + * GBI Commands for S2DEX microcode + *===========================================================================*/ +/* GBI Header */ +#ifdef F3DEX_GBI_2 +#define G_OBJ_RECTANGLE_R 0xda +#define G_OBJ_MOVEMEM 0xdc +#define G_RDPHALF_0 0xe4 +#define G_OBJ_RECTANGLE 0x01 +#define G_OBJ_SPRITE 0x02 +#define G_SELECT_DL 0x04 +#define G_OBJ_LOADTXTR 0x05 +#define G_OBJ_LDTX_SPRITE 0x06 +#define G_OBJ_LDTX_RECT 0x07 +#define G_OBJ_LDTX_RECT_R 0x08 +#define G_BG_1CYC 0x09 +#define G_BG_COPY 0x0a +#define G_OBJ_RENDERMODE 0x0b +#else +#define G_BG_1CYC 0x01 +#define G_BG_COPY 0x02 +#define G_OBJ_RECTANGLE 0x03 +#define G_OBJ_SPRITE 0x04 +#define G_OBJ_MOVEMEM 0x05 +#define G_SELECT_DL 0xb0 +#define G_OBJ_RENDERMODE 0xb1 +#define G_OBJ_RECTANGLE_R 0xb2 +#define G_OBJ_LOADTXTR 0xc1 +#define G_OBJ_LDTX_SPRITE 0xc2 +#define G_OBJ_LDTX_RECT 0xc3 +#define G_OBJ_LDTX_RECT_R 0xc4 +#define G_RDPHALF_0 0xe4 +#endif + +/*---------------------------------------------------------------------------* + * Background wrapped screen + *---------------------------------------------------------------------------*/ +#define gSPBgRectangle(pkt, m, mptr) gDma0p((pkt),(m),(mptr),0) +#define gsSPBgRectangle(m, mptr) gsDma0p( (m),(mptr),0) +#define gSPBgRectCopy(pkt, mptr) gSPBgRectangle((pkt), G_BG_COPY, (mptr)) +#define gsSPBgRectCopy(mptr) gsSPBgRectangle( G_BG_COPY, (mptr)) +#define gSPBgRect1Cyc(pkt, mptr) gSPBgRectangle((pkt), G_BG_1CYC, (mptr)) +#define gsSPBgRect1Cyc(mptr) gsSPBgRectangle( G_BG_1CYC, (mptr)) + +/*---------------------------------------------------------------------------* + * 2D Objects + *---------------------------------------------------------------------------*/ +#define gSPObjSprite(pkt, mptr) gDma0p((pkt),G_OBJ_SPRITE, (mptr),0) +#define gsSPObjSprite(mptr) gsDma0p( G_OBJ_SPRITE, (mptr),0) +#define gSPObjRectangle(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE, (mptr),0) +#define gsSPObjRectangle(mptr) gsDma0p( G_OBJ_RECTANGLE, (mptr),0) +#define gSPObjRectangleR(pkt, mptr) gDma0p((pkt),G_OBJ_RECTANGLE_R,(mptr),0) +#define gsSPObjRectangleR(mptr) gsDma0p( G_OBJ_RECTANGLE_R,(mptr),0) + +/*---------------------------------------------------------------------------* + * 2D Matrix + *---------------------------------------------------------------------------*/ +#define gSPObjMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),0,23) +#define gsSPObjMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),0,23) +#define gSPObjSubMatrix(pkt, mptr) gDma1p((pkt),G_OBJ_MOVEMEM,(mptr),2, 7) +#define gsSPObjSubMatrix(mptr) gsDma1p( G_OBJ_MOVEMEM,(mptr),2, 7) + +/*---------------------------------------------------------------------------* + * Loading into TMEM + *---------------------------------------------------------------------------*/ +#define gSPObjLoadTxtr(pkt, tptr) gDma0p((pkt),G_OBJ_LOADTXTR, (tptr),23) +#define gsSPObjLoadTxtr(tptr) gsDma0p( G_OBJ_LOADTXTR, (tptr),23) +#define gSPObjLoadTxSprite(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_SPRITE,(tptr),47) +#define gsSPObjLoadTxSprite(tptr) gsDma0p( G_OBJ_LDTX_SPRITE,(tptr),47) +#define gSPObjLoadTxRect(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT, (tptr),47) +#define gsSPObjLoadTxRect(tptr) gsDma0p( G_OBJ_LDTX_RECT, (tptr),47) +#define gSPObjLoadTxRectR(pkt, tptr) gDma0p((pkt),G_OBJ_LDTX_RECT_R,(tptr),47) +#define gsSPObjLoadTxRectR(tptr) gsDma0p( G_OBJ_LDTX_RECT_R,(tptr),47) + +/*---------------------------------------------------------------------------* + * Select Display List + *---------------------------------------------------------------------------*/ +#define gSPSelectDL(pkt, mptr, sid, flag, mask) \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } +#define gsSPSelectDL(mptr, sid, flag, mask) \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); } +#define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \ +{ gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } +#define gsSPSelectBranchDL(mptr, sid, flag, mask) \ +{ gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \ + gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); } + +/*---------------------------------------------------------------------------* + * Set general status + *---------------------------------------------------------------------------*/ +#define G_MW_GENSTAT 0x08 /* G_MW_FOG ¤ÈƱ¤¸ÃͤʤΤÇÃí°Õ */ + +#define gSPSetStatus(pkt, sid, val) \ + gMoveWd((pkt), G_MW_GENSTAT, (sid), (val)) +#define gsSPSetStatus(sid, val) \ + gsMoveWd( G_MW_GENSTAT, (sid), (val)) + +/*---------------------------------------------------------------------------* + * Set Object Render Mode + *---------------------------------------------------------------------------*/ +#define G_OBJRM_NOTXCLAMP 0x01 +#define G_OBJRM_XLU 0x02 /* Ignored */ +#define G_OBJRM_ANTIALIAS 0x04 /* Ignored */ +#define G_OBJRM_BILERP 0x08 +#define G_OBJRM_SHRINKSIZE_1 0x10 +#define G_OBJRM_SHRINKSIZE_2 0x20 +#define G_OBJRM_WIDEN 0x40 + +#define gSPObjRenderMode(pkt, mode) gImmp1((pkt),G_OBJ_RENDERMODE,(mode)) +#define gsSPObjRenderMode(mode) gsImmp1( G_OBJ_RENDERMODE,(mode)) + +/*===========================================================================* + * Render Mode Macro + *===========================================================================*/ +#define RM_RA_SPRITE(clk) \ + AA_EN | CVG_DST_CLAMP | \ + CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ + GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) + +#define G_RM_SPRITE G_RM_OPA_SURF +#define G_RM_SPRITE2 G_RM_OPA_SURF2 +#define G_RM_RA_SPRITE RM_RA_SPRITE(1) +#define G_RM_RA_SPRITE2 RM_RA_SPRITE(2) +#define G_RM_AA_SPRITE G_RM_AA_TEX_TERR +#define G_RM_AA_SPRITE2 G_RM_AA_TEX_TERR2 +#define G_RM_XLU_SPRITE G_RM_XLU_SURF +#define G_RM_XLU_SPRITE2 G_RM_XLU_SURF2 +#define G_RM_AA_XLU_SPRITE G_RM_AA_XLU_SURF +#define G_RM_AA_XLU_SPRITE2 G_RM_AA_XLU_SURF2 + +/*===========================================================================* + * External functions + *===========================================================================*/ +extern u64 gspS2DEX_fifoTextStart[], gspS2DEX_fifoTextEnd[]; +extern u64 gspS2DEX_fifoDataStart[], gspS2DEX_fifoDataEnd[]; +extern u64 gspS2DEX_fifo_dTextStart[], gspS2DEX_fifo_dTextEnd[]; +extern u64 gspS2DEX_fifo_dDataStart[], gspS2DEX_fifo_dDataEnd[]; +extern u64 gspS2DEX2_fifoTextStart[], gspS2DEX2_fifoTextEnd[]; +extern u64 gspS2DEX2_fifoDataStart[], gspS2DEX2_fifoDataEnd[]; +extern u64 gspS2DEX2_xbusTextStart[], gspS2DEX2_xbusTextEnd[]; +extern u64 gspS2DEX2_xbusDataStart[], gspS2DEX2_xbusDataEnd[]; +extern void guS2DInitBg(uObjBg *); + +#ifdef F3DEX_GBI_2 +# define guS2DEmuBgRect1Cyc guS2D2EmuBgRect1Cyc /*Wrapper*/ +# define guS2DEmuSetScissor guS2D2EmuSetScissor /*Wrapper*/ + extern void guS2D2EmuSetScissor(u32, u32, u32, u32, u8); + extern void guS2D2EmuBgRect1Cyc(Gfx **, uObjBg *); +#else + extern void guS2DEmuSetScissor(u32, u32, u32, u32, u8); + extern void guS2DEmuBgRect1Cyc(Gfx **, uObjBg *); +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* _GS2DEX_H_ */ + +/*======== End of gs2dex.h ========*/ diff --git a/include/PR/gt.h b/include/PR/gt.h new file mode 100644 index 000000000..dbf09457d --- /dev/null +++ b/include/PR/gt.h @@ -0,0 +1,365 @@ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * ALL RIGHTS RESERVED + * + * UNPUBLISHED -- Rights reserved under the copyright laws of the United + * States. Use of a copyright notice is precautionary only and does not + * imply publication or disclosure. + * + * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or + * in similar or successor clauses in the FAR, or the DOD or NASA FAR + * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., + * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. + * + * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY + * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, + * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY + * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON + * GRAPHICS, INC. + * + */ + +/* + * File: gt.h + * Creator: hsa@sgi.com + * Create Date: Thu Oct 12 15:48:14 PDT 1995 + * + * This file defines the GBI for the TURBO 3D graphics microcode. + * The turbo microcode is a special FEATURE-LIMITED microcode designed + * for specific applications. It is not for general use. + * + * (see XXX for more information) + * + */ + +/************************************************************************** + * + * $Revision: 1.16 $ + * $Date: 1998/05/28 00:14:50 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gt.h,v $ + * + **************************************************************************/ + +#ifndef _GT_H_ +#define _GT_H_ + +/* this file should be #included AFTER gbi.h */ + +#include "sptask.h" + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif /* _LANGUAGE_C_PLUS_PLUS */ + +#include + +/* the following #defines seem out of order, but we need them + * for the microcode. + */ + +/* + * object state field: rendState + * + * This flag word is built up out of the bits from a + * subset of the G_SETGEOMETRYMODE flags from gbi.h. + * + * When each of these bits is '1', the comments below explain + * the effect on the triangles. + */ +#define GT_ZBUFFER G_ZBUFFER +#define GT_TEXTURE G_TEXTURE_ENABLE /* texture ON */ +#define GT_CULL_BACK G_CULL_BACK /* reject backfaces */ +#define GT_SHADING_SMOOTH G_SHADING_SMOOTH /* smooth shade ON */ + +/* + * object state field: textureState + * + * The lower 3 bits of this flag word contain the texture tile number + * to be used. All triangles of an object are rendered with the same + * texture tile. + */ + +/* + * object state field: flag + * + * This is a group of what would be pad bits. We use them for some + * flag bits. + */ +#define GT_FLAG_NOMTX 0x01 /* don't load the matrix */ +#define GT_FLAG_NO_XFM 0x02 /* load vtx, use verbatim */ +#define GT_FLAG_XFM_ONLY 0x04 /* xform vtx, write to *TriN */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* turbo 3D ucode: */ +extern long long int gspTurbo3DTextStart[], gspTurbo3DTextEnd[]; +extern long long int gspTurbo3DDataStart[], gspTurbo3DDataEnd[]; +extern long long int gspTurbo3D_dramTextStart[], gspTurbo3D_dramTextEnd[]; +extern long long int gspTurbo3D_dramDataStart[], gspTurbo3D_dramDataEnd[]; +extern long long int gspTurbo3D_fifoTextStart[], gspTurbo3D_fifoTextEnd[]; +extern long long int gspTurbo3D_fifoDataStart[], gspTurbo3D_fifoDataEnd[]; + +/* + * This is the global state structure. It's definition carefully + * matches the ucode, so if this structure changes, you must also change + * the ucode. + */ +typedef struct { + u16 perspNorm; /* persp normalization */ + u16 pad0; + u32 flag; + Gfx rdpOthermode; + u32 segBases[16]; /* table of segment base addrs (SEE NOTE!) */ + Vp viewport; /* the viewport to use */ + Gfx *rdpCmds; /* block of RDP data, process if !NULL + * block terminated by gDPEndDisplayList() + * (This is a segment address) + */ +} gtGlobState_t; + +/* NOTE: + * Although there are 16 segment table entries, the first one (segment 0) + * is reserved for physical memory mapping. You should not segment 0 + * to anything other than 0x0. + */ + +typedef union { + gtGlobState_t sp; + long long int force_structure_alignment; +} gtGlobState; + + +/* + * This is the 'state' structure associated with each object + * to be rendered. It's definition carefully matches the + * ucode, so if this structure changes, you must also change + * the gtoff.c tool and the ucode. + */ +typedef struct { + u32 renderState; /* render state */ + u32 textureState; /* texture state */ + u8 vtxCount; /* how many verts? */ + u8 vtxV0; /* where to load verts? */ + u8 triCount; /* how many tris? */ + u8 flag; + Gfx *rdpCmds; /* ptr (segment address) to RDP DL */ + Gfx rdpOthermode; + Mtx transform; /* the transform matrix to use */ +} gtState_t; + +typedef union { + gtState_t sp; + long long int force_structure_alignment; +} gtState; + +/* gtStateLite : same as gtState, but no matrix (see flags below) */ +/* this structure must be identical to gtState! (bad) */ +typedef struct { + u32 renderState; /* render state */ + u32 textureState; /* texture state */ + u8 vtxCount; /* how many verts? */ + u8 vtxV0; /* where to load verts? */ + u8 triCount; /* how many tris? */ + u8 flag; + Gfx *rdpCmds; /* ptr (segment address) to RDP DL */ + Gfx rdpOthermode; +} gtStateL_t; + +typedef union { + gtStateL_t sp; + long long int force_structure_alignment; +} gtStateL; + +/* + * The vertex list for the turbo display list uses the + * Vtx struct in gbi.h + * + */ + + +/* + * This structure represents a single triangle, part of the + * triangle list of the object to be rendered. + * + * NOTE: The triangle list MUST be aligned to an 8-byte boundary. + * Since this structure is only 4 bytes, we are REQUIRING that + * this structure only be used as an array of triangles, and we + * depend on the MIPS C compiler (which always aligns arrays to + * 8-byte boundaries). THIS IS DANGEROUS!!!! + * + */ +typedef struct { + u8 v0, v1, v2, flag; /* flag is which one for flat shade */ +} gtTriN; + + +/* + * This structure represents the transformed points. It is the format + * of the points written out when GT_FLAG_XFM_ONLY is set, as well as + * the format expected when GT_FLAG_NO_XFM is used. + * + * NOTE: The size and layout of these points is very similar to Vtx, + * except the screen coordinates overwrite the x,y,z,pad fields. + * (we could consider adding to the Vtx union, but we want to keep + * turbo stuff out of gbi.h) + * + * NOTE: The z is a special format. It can be used to compare vertices + * for sorting, but it should not be used for other purposes. If modified, + * the z-buffer hardware might not understand the data. + * + */ +typedef struct { + short int xscrn; /* x,y screen coordinates are SSSS10.2 */ + short int yscrn; + int zscrn; /* z screen is S15.16 */ + + short int s; /* transformed texture coord, S10.5 */ + short int t; + + u8 r; /* color (or normal) */ + u8 g; + u8 b; + u8 a; +} gtVtxOut_t; + +/* see "Data Structure" comment in gbi.h for information about why + * we use this union. + */ +typedef union { + gtVtxOut_t v; + long long int force_structure_alignment; +} gtVtxOut; + + + +/* + * state field: rdpOthermode + * + * This is one of the trickier state fields. The turbo interface + * requires the RDP othermode command to be cached by the host, + * therefore we provide a different interface in libultra to help cache + * this in the gt state (this word is just bits, you could pack them + * on your own). + * + * gtStateSetOthermode() accomplishs this, taking as arguments + * the state, one of the following mode enums, and a piece of data + * (othermode parameters from gbi.h). + * + * By definition, the othermode word from the gt state structure is sent + * to the RDP *before* any RDP commands from the rdpCmds[] field. The + * othermode is *always* sent. + * + * Stated another way, NONE of the gbi RDP othermode commands equivalent + * to those listed here are allowed in the rdpCmd[] field of the + * gt state structure. + * + * Notice also that many of these commands do not make sense for + * the turbo ucode (they control features not supported, like mip-mapping). + * They are only included here for completeness. + * + */ +typedef enum { + GT_CLEAR, /* special gt mode, clears othermode state */ + GT_ALPHACOMPARE, + GT_ZSRCSEL, + GT_RENDERMODE, + GT_ALPHADITHER, + GT_RGBDITHER, + GT_COMBKEY, + GT_TEXTCONV, + GT_TEXTFILT, + GT_TEXTLUT, + GT_TEXTLOD, + GT_TEXTDETAIL, + GT_TEXTPERSP, + GT_CYCLETYPE, + GT_PIPELINE +} gtStateOthermode_t; + +/* + * This call builds up an othermode command word. The 'mode' is one of + * the above modes, the 'data' field comes from gbi.h, it is the data + * field for the equivalent gbi setothermode macro. + */ +extern void gtStateSetOthermode(Gfx *om, gtStateOthermode_t mode, int data); + +/* + * This call dumps a turbo display list for use with gbi2mem and RSPSIM + */ +#define GT_DUMPTURBO_HANGAFTER 64 +#define GT_DUMPTURBO_NOTEXTURES 128 +extern void gtDumpTurbo(OSTask *tp,u8 flags); + +/* + * Special macros to init othermode words to all 0's, a good default + * value. + */ +#define gDPClearOtherMode(pkt) \ +{ \ + Gfx *_g = (Gfx *)(pkt); \ + \ + _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE, 24, 8); \ + _g->words.w1 = 0x0; \ +} + +#define gsDPClearOtherMode() \ +{ \ + _SHIFTL(G_RDPSETOTHERMODE, 24, 8), 0x0 \ +} + +/* + * Special macros to end DP blocks (see above). These commands + * generate all 0's, which the turbo ucode looks for. They *aren't* + * real DP commands! + */ +#define gDPEndDisplayList(pkt) gSPNoOp(pkt) +#define gsDPEndDisplayList() gsSPNoOp() + +/* + * This structure is a turbo 'object', the turbo display list is + * simply a list of these. + * + * NOTE: All pointers are segment addresses + * + * NOTE: If (statep->flag & GT_FLAG_XFM_ONLY), the trip field is + * interpreted as a pointer to gtVtxOut[] that can be used to store + * the transformed points. (statep->triCount should be 0, else bad + * things could happen...) + * + * NOTE: If (statep->flag & GT_FLAG_NO_XFM), the vtxp field is + * interpreted as a pointer to gtVtxOut[] that can be used to load + * pre-transformed points. + * + */ +typedef struct { + gtGlobState *gstatep; /* global state, usually NULL */ + gtState *statep; /* if this is NULL, end object processing */ + Vtx *vtxp; /* if this is NULL, use points in buffer */ + gtTriN *trip; /* if this is NULL, use tris in buffer */ +} gtGfx_t; + +typedef union { + gtGfx_t obj; + long long int force_structure_alignment; +} gtGfx; + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_ASSEMBLY +#include +#endif /* _LANGUAGE_ASSEMBLY */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif /* _LANGUAGE_C_PLUS_PLUS */ + +#ifdef _LANGUAGE_MAKEROM +#endif /* _LANGUAGE_MAKEROM */ + +#endif /* _GT_H_ */ diff --git a/include/PR/gu.h b/include/PR/gu.h new file mode 100644 index 000000000..f7a57ac4b --- /dev/null +++ b/include/PR/gu.h @@ -0,0 +1,266 @@ +#ifndef _GU_H_ +#define _GU_H_ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.46 $ + * $Date: 1997/11/26 00:30:53 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/gu.h,v $ + * + **************************************************************************/ + +#include +#include +#include + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#define M_PI 3.14159265358979323846 +#define M_DTOR (3.14159265358979323846/180.0) + +#define FTOFIX32(x) (long)((x) * (float)0x00010000) +#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000)) +#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff) + +#define FILTER_WRAP 0 +#define FILTER_CLAMP 1 + +#define RAND(x) (guRandom()%x) /* random number between 0 to x */ + +/* + * Data Structures + */ +typedef struct { + unsigned char *base; + int fmt, siz; + int xsize, ysize; + int lsize; + /* current tile info */ + int addr; + int w, h; + int s, t; +} Image; + +typedef struct { + float col[3]; + float pos[3]; + float a1, a2; /* actual color = col/(a1*dist + a2) */ +} PositionalLight; + + +/* + * Function Prototypes + */ + +extern int guLoadTextureBlockMipMap(Gfx **glist, unsigned char *tbuf, Image *im, + unsigned char startTile, unsigned char pal, unsigned char cms, + unsigned char cmt, unsigned char masks, unsigned char maskt, + unsigned char shifts, unsigned char shiftt, unsigned char cfs, + unsigned char cft); + +extern int guGetDPLoadTextureTileSz (int ult, int lrt); +extern void guDPLoadTextureTile (Gfx *glistp, void *timg, + int texl_fmt, int texl_size, + int img_width, int img_height, + int uls, int ult, int lrs, int lrt, + int palette, + int cms, int cmt, + int masks, int maskt, + int shifts, int shiftt); + + +/* + * matrix operations: + * + * The 'F' version is floating point, in case the application wants + * to do matrix manipulations and convert to fixed-point at the last + * minute. + */ +extern void guMtxIdent(Mtx *m); +extern void guMtxIdentF(float mf[4][4]); +extern void guOrtho(Mtx *m, float l, float r, float b, float t, + float n, float f, float scale); +extern void guOrthoF(float mf[4][4], float l, float r, float b, float t, + float n, float f, float scale); +extern void guFrustum(Mtx *m, float l, float r, float b, float t, + float n, float f, float scale); +extern void guFrustumF(float mf[4][4], float l, float r, float b, float t, + float n, float f, float scale); +extern void guPerspective(Mtx *m, u16 *perspNorm, float fovy, + float aspect, float near, float far, float scale); +extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, + float aspect, float near, float far, float scale); +extern void guLookAt(Mtx *m, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtReflect(Mtx *m, LookAt *l, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtReflectF(float mf[4][4], LookAt *l, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp); +extern void guLookAtHilite(Mtx *m, LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float xl1, float yl1, float zl1, + float xl2, float yl2, float zl2, + int twidth, int theight); +extern void guLookAtHiliteF(float mf[4][4], LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float xl1, float yl1, float zl1, + float xl2, float yl2, float zl2, + int twidth, int theight); +extern void guLookAtStereo(Mtx *m, + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float eyedist); +extern void guLookAtStereoF(float mf[4][4], + float xEye, float yEye, float zEye, + float xAt, float yAt, float zAt, + float xUp, float yUp, float zUp, + float eyedist); +extern void guRotate(Mtx *m, float a, float x, float y, float z); +extern void guRotateF(float mf[4][4], float a, float x, float y, float z); +extern void guRotateRPY(Mtx *m, float r, float p, float y); +extern void guRotateRPYF(float mf[4][4], float r, float p, float h); +extern void guAlign(Mtx *m, float a, float x, float y, float z); +extern void guAlignF(float mf[4][4], float a, float x, float y, float z); +extern void guScale(Mtx *m, float x, float y, float z); +extern void guScaleF(float mf[4][4], float x, float y, float z); +extern void guTranslate(Mtx *m, float x, float y, float z); +extern void guTranslateF(float mf[4][4], float x, float y, float z); +extern void guPosition(Mtx *m, float r, float p, float h, float s, + float x, float y, float z); +extern void guPositionF(float mf[4][4], float r, float p, float h, float s, + float x, float y, float z); +extern void guMtxF2L(float mf[4][4], Mtx *m); +extern void guMtxL2F(float mf[4][4], Mtx *m); +extern void guMtxCatF(float m[4][4], float n[4][4], float r[4][4]); +extern void guMtxCatL(Mtx *m, Mtx *n, Mtx *res); +extern void guMtxXFMF(float mf[4][4], float x, float y, float z, + float *ox, float *oy, float *oz); +extern void guMtxXFML(Mtx *m, float x, float y, float z, + float *ox, float *oy, float *oz); + +/* vector utility: */ +extern void guNormalize(float *x, float *y, float *z); + +/* light utilities: */ +void guPosLight(PositionalLight *pl, Light *l, + float xOb, float yOb, float zOb); +void guPosLightHilite(PositionalLight *pl1, PositionalLight *pl2, + Light *l1, Light *l2, + LookAt *l, Hilite *h, + float xEye, float yEye, float zEye, + float xOb, float yOb, float zOb, + float xUp, float yUp, float zUp, + int twidth, int theight); +extern int guRandom(void); + +/* + * Math functions + */ +extern float sinf(float angle); +extern float cosf(float angle); +extern signed short sins (unsigned short angle); +extern signed short coss (unsigned short angle); +extern float sqrtf(float value); + +/* + * Dump routines for low-level display lists + */ +/* flag values for guParseRdpDL() */ +#define GU_PARSERDP_VERBOSE 1 +#define GU_PARSERDP_PRAREA 2 +#define GU_PARSERDP_PRHISTO 4 +#define GU_PARSERDP_DUMPONLY 32 /* doesn't need to be same as */ + /* GU_PARSEGBI_DUMPOLNY, but this */ + /* allows app to use interchangeably */ + +extern void guParseRdpDL(u64 *rdp_dl, u64 nbytes, u8 flags); +extern void guParseString(char *StringPointer, u64 nbytes); + +/* + * NO LONGER SUPPORTED, + * use guParseRdpDL with GU_PARSERDP_DUMPONLY flags + */ +/* extern void guDumpRawRdpDL(u64 *rdp_dl, u64 nbytes); */ + +/* flag values for guBlinkRdpDL() */ +#define GU_BLINKRDP_HILITE 1 +#define GU_BLINKRDP_EXTRACT 2 + +extern void +guBlinkRdpDL(u64 *rdp_dl_in, u64 nbytes_in, + u64 *rdp_dl_out, u64 *nbytes_out, + u32 x, u32 y, u32 radius, + u8 red, u8 green, u8 blue, + u8 flags); + +/* flag values for guParseGbiDL() */ +#define GU_PARSEGBI_ROWMAJOR 1 +#define GU_PARSEGBI_NONEST 2 +#define GU_PARSEGBI_FLTMTX 4 +#define GU_PARSEGBI_SHOWDMA 8 +#define GU_PARSEGBI_ALLMTX 16 +#define GU_PARSEGBI_DUMPONLY 32 +/* +#define GU_PARSEGBI_HANGAFTER 64 +#define GU_PARSEGBI_NOTEXTURES 128 +*/ +extern void guParseGbiDL(u64 *gbi_dl, u32 nbytes, u8 flags); +extern void guDumpGbiDL(OSTask *tp,u8 flags); + +#define GU_PARSE_GBI_TYPE 1 +#define GU_PARSE_RDP_TYPE 2 +#define GU_PARSE_READY 3 +#define GU_PARSE_MEM_BLOCK 4 +#define GU_PARSE_ABI_TYPE 5 +#define GU_PARSE_STRING_TYPE 6 + +typedef struct { + int dataSize; + int dlType; + int flags; + u32 paddr; +} guDLPrintCB; + +void guSprite2DInit(uSprite *SpritePointer, + void *SourceImagePointer, + void *TlutPointer, + int Stride, + int SubImageWidth, + int SubImageHeight, + int SourceImageType, + int SourceImageBitSize, + int SourceImageOffsetS, + int SourceImageOffsetT); + +#endif /* !_GU_H_ */ diff --git a/include/PR/leo.h b/include/PR/leo.h new file mode 100644 index 000000000..96f2edd1d --- /dev/null +++ b/include/PR/leo.h @@ -0,0 +1,280 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: leo.h,v $ + $Revision: 1.29 $ + $Date: 1998/12/21 07:30:15 $ + *---------------------------------------------------------------------*/ + +#ifndef _LEO_H_ +#define _LEO_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ +typedef u32 LEOError; + +typedef u8 LEOSpdlMode; + +typedef u8 LEOStatus; + +typedef struct +{ + u8 drive; /* version of hw */ + u8 driver; /* version of sw */ + u8 deviceType; /* dev type, always 00 */ + u8 ndevices; /* # of devices, always 01 */ +} LEOVersion; + +typedef struct +{ + u32 startLBA; + u32 endLBA; + u32 nbytes; +} LEOCapacity; + +typedef struct +{ + u8 pad; + u8 yearhi; + u8 yearlo; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; +} LEODiskTime; + +typedef struct +{ + u64 lineNumber; + LEODiskTime time; +} LEOSerialNum; + +typedef struct +{ + u8 gameName[4]; + u8 gameVersion; + u8 diskNumber; + u8 ramUsage; + u8 diskUsage; + LEOSerialNum serialNumber; + u8 company[2]; + u8 freeArea[6]; +} LEODiskID; + +typedef struct +{ + LEOCmdHeader header; + union + { + struct + { + u32 lba; + u32 xfer_blks; + void *buff_ptr; + u32 rw_bytes; +#ifdef _LONGCMD + u32 size; +#endif + } readwrite; + struct + { + u32 lba; + } seek; + struct + { + void *buffer_pointer; + } readdiskid; + LEODiskTime time; + struct + { + u8 reserve1; + u8 reserve2; + u8 standby_time; + u8 sleep_time; + u32 reserve3; + } modeselect; + + } data; + +} LEOCmd; + + +#define _nbytes readwrite.rw_bytes +#define _result header.status + + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ +#define LEO_SW_VERSION 6 /* This will be returned by */ + /* LeoInquiry command */ + +#define OS_PRIORITY_LEOMGR OS_PRIORITY_PIMGR + +/* + * Drive Rom offset address + */ +#define DDROM_FONT_START 0x000a0000 +#define DDROM_WAVEDATA_START 0x00140000 + +/* + * Definition for osLeoSpdlMotor() + */ +#define ACTIVE 0 +#define STANDBY 1 +#define SLEEP 2 +#define BRAKE 4 + +#define LEO_MOTOR_ACTIVE 0 +#define LEO_MOTOR_STANDBY 1 +#define LEO_MOTOR_SLEEP 2 +#define LEO_MOTOR_BRAKE 4 + +#define NUM_LBAS 4292 /* total number of LBAs */ + +#define BLK_SIZE_ZONE0 19720 +#define BLK_SIZE_ZONE1 18360 +#define BLK_SIZE_ZONE2 17680 +#define BLK_SIZE_ZONE3 16320 +#define BLK_SIZE_ZONE4 14960 +#define BLK_SIZE_ZONE5 13600 +#define BLK_SIZE_ZONE6 12240 +#define BLK_SIZE_ZONE7 10880 +#define BLK_SIZE_ZONE8 9520 + +#define MAX_BLK_SIZE BLK_SIZE_ZONE0 +#define MIN_BLK_SIZE BLK_SIZE_ZONE8 + +/* + * Error codes + */ +#define LEO_ERROR_GOOD 0 +#define LEO_ERROR_DRIVE_NOT_READY 1 +#define LEO_ERROR_DIAGNOSTIC_FAILURE 2 +#define LEO_ERROR_COMMAND_PHASE_ERROR 3 +#define LEO_ERROR_DATA_PHASE_ERROR 4 +#define LEO_ERROR_REAL_TIME_CLOCK_FAILURE 5 +#define LEO_ERROR_BUSY 8 +#define LEO_ERROR_INCOMPATIBLE_MEDIUM_INSTALLED 11 +#define LEO_ERROR_UNKNOWN_FORMAT 11 +#define LEO_ERROR_NO_SEEK_COMPLETE 21 +#define LEO_ERROR_WRITE_FAULT 22 +#define LEO_ERROR_UNRECOVERED_READ_ERROR 23 +#define LEO_ERROR_NO_REFERENCE_POSITION_FOUND 24 +#define LEO_ERROR_TRACK_FOLLOWING_ERROR 25 +#define LEO_ERROR_TRACKING_OR_SPDL_SERVO_FAILURE 25 +#define LEO_ERROR_INVALID_COMMAND_OPERATION_CODE 31 +#define LEO_ERROR_LBA_OUT_OF_RANGE 32 +#define LEO_ERROR_WRITE_PROTECT_ERROR 33 +#define LEO_ERROR_COMMAND_CLEARED_BY_HOST 34 +#define LEO_ERROR_COMMAND_TERMINATED 34 +#define LEO_ERROR_QUEUE_FULL 35 +#define LEO_ERROR_ILLEGAL_TIMER_VALUE 36 +#define LEO_ERROR_WAITING_NMI 37 +#define LEO_ERROR_DEVICE_COMMUNICATION_FAILURE 41 +#define LEO_ERROR_MEDIUM_NOT_PRESENT 42 +#define LEO_ERROR_POWERONRESET_DEVICERESET_OCCURED 43 +#define LEO_ERROR_RAMPACK_NOT_CONNECTED 44 +#define LEO_ERROR_MEDIUM_MAY_HAVE_CHANGED 47 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESUME 49 + +/* + * Reserved + */ +#define LEO_ERROR_NOT_BOOTED_DISK 45 +#define LEO_ERROR_DIDNOT_CHANGED_DISK_AS_EXPECTED 46 + +/* + * Error codes only used in IPL + */ +#define LEO_ERROR_RTC_NOT_SET_CORRECTLY 48 +#define LEO_ERROR_DIAGNOSTIC_FAILURE_RESET 50 +#define LEO_ERROR_EJECTED_ILLEGALLY_RESET 51 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ +#define GET_ERROR(x) ((x).header.sense) + + +/************************************************************************** + * + * Extern variables + * + */ +extern LEODiskID leoBootID; +extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/ + + +/************************************************************************** + * + * Function prototypes + * + */ +/* Initialize routine */ +extern s32 LeoCreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern s32 LeoCJCreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern s32 LeoCACreateLeoManager(OSPri comPri, OSPri intPri, + OSMesg *cmdBuf, s32 cmdMsgCnt); +extern u32 LeoDriveExist(void); + +/* Synchronous functions */ +extern s32 LeoClearQueue(void); +extern s32 LeoByteToLBA(s32 startLBA, u32 nbytes, s32 *lbas); +extern s32 LeoLBAToByte(s32 startLBA, u32 nLBAs, s32 *bytes); +extern s32 LeoReadCapacity(LEOCapacity *cap, s32 dir); +extern s32 LeoInquiry(LEOVersion *ver); +extern s32 LeoTestUnitReady(LEOStatus *status); + +/* Asynchronous functions */ +extern s32 LeoSpdlMotor(LEOCmd *cmdBlock, LEOSpdlMode mode, OSMesgQueue *mq); +extern s32 LeoSeek(LEOCmd *cmdBlock, u32 lba, OSMesgQueue *mq); +extern s32 LeoRezero(LEOCmd *cmdBlock, OSMesgQueue *mq); +extern s32 LeoReadWrite(LEOCmd *cmdBlock, s32 direction, + u32 LBA, void *vAddr, u32 nLBAs, OSMesgQueue *mq); +extern s32 LeoReadDiskID(LEOCmd *cmdBlock, LEODiskID *vaddr, OSMesgQueue *mq); +extern s32 LeoSetRTC(LEOCmd *cmdBlock, LEODiskTime *RTCdata, OSMesgQueue *mq); +extern s32 LeoReadRTC(LEOCmd *cmdBlock, OSMesgQueue *mq); +extern s32 LeoModeSelectAsync(LEOCmd *cmdBlock, u32 standby, + u32 sleep, OSMesgQueue *mq); + +/* Font routines */ +extern int LeoGetKAdr(int sjis); +extern int LeoGetAAdr(int code,int *dx,int *dy, int *cy); +extern int LeoGetAAdr2(u32 ccode,int *dx,int *dy, int *cy); + +/* Boot function */ +extern void LeoBootGame(void *entry); + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_LEO_H */ diff --git a/include/PR/leoappli.h b/include/PR/leoappli.h new file mode 100644 index 000000000..619fbc083 --- /dev/null +++ b/include/PR/leoappli.h @@ -0,0 +1,274 @@ +/* + * F i l e N a m e : l e o a p p l i . h + * + **************************************************************************** + * (C) Copyright ALPS Electric Co., Ltd. 1995-1997 + **************************************************************************** + * Version + * + * ver Date + * ---- -------- + * 1.01 '97-11-18 Add MOTOR BRAKE definition for control bit. + **************************************************************************** +*/ +/*-----------------------------------*/ +/* DRIVE PARAMETER */ +/*-----------------------------------*/ +#define LEO_DISK_TYPE_MIN 0 +#define LEO_DISK_TYPE_MAX 6 + +#define LEO_LBA_MIN 0 +#define LEO_LBA_MAX 4291 + +#define LEO_LBA_ROM_TOP LEO_LBA_MIN +#define LEO_LBA_ROM_END0 1417 +#define LEO_LBA_ROM_END1 1965 +#define LEO_LBA_ROM_END2 2513 +#define LEO_LBA_ROM_END3 3061 +#define LEO_LBA_ROM_END4 3609 +#define LEO_LBA_ROM_END5 4087 +#define LEO_LBA_ROM_END6 LEO_LBA_MAX +#define LEO_LBA_RAM_TOP0 (LEO_LBA_ROM_END0+1) +#define LEO_LBA_RAM_TOP1 (LEO_LBA_ROM_END1+1) +#define LEO_LBA_RAM_TOP2 (LEO_LBA_ROM_END2+1) +#define LEO_LBA_RAM_TOP3 (LEO_LBA_ROM_END3+1) +#define LEO_LBA_RAM_TOP4 (LEO_LBA_ROM_END4+1) +#define LEO_LBA_RAM_TOP5 (LEO_LBA_ROM_END5+1) +#define LEO_LBA_RAM_TOP6 (LEO_LBA_ROM_END6+1) +#define LEO_LBA_RAM_END6 LEO_LBA_MAX + +/*-----------------------------------*/ +/* LEO FUNCTION DEFINITIONS */ +/*-----------------------------------*/ +extern void leoInitialize(OSPri PRI_WRK, OSPri PRI_INT, OSMesg *command_que_buf, u32 cmd_buff_size); +extern void leoCommand(void *CDB); +extern void LeoReset(void); +extern s32 LeoResetClear(void); + +/*-----------------------------------*/ +/* THREAD PRIORITY */ +/*-----------------------------------*/ +#define LEO_PRIORITY_WRK (OS_PRIORITY_PIMGR-1) +#define LEO_PRIORITY_INT OS_PRIORITY_PIMGR + +/*-----------------------------------*/ +/* COMMAND CODE */ +/*-----------------------------------*/ +#define LEO_COMMAND_CLEAR_QUE 0x01 +#define LEO_COMMAND_INQUIRY 0x02 +#define LEO_COMMAND_TEST_UNIT_READY 0x03 +#define LEO_COMMAND_REZERO 0x04 +#define LEO_COMMAND_READ 0x05 +#define LEO_COMMAND_WRITE 0x06 +#define LEO_COMMAND_SEEK 0x07 +#define LEO_COMMAND_START_STOP 0x08 +#define LEO_COMMAND_READ_CAPACITY 0x09 +#define LEO_COMMAND_TRANSLATE 0x0a +#define LEO_COMMAND_MODE_SELECT 0x0b +#define LEO_COMMAND_READ_DISK_ID 0x0c +#define LEO_COMMAND_READ_TIMER 0x0d +#define LEO_COMMAND_SET_TIMER 0x0e + +/*-----------------------------------*/ +/* CONTROL BIT */ +/*-----------------------------------*/ +#define LEO_CONTROL_POST 0x80 /* ENABLE POST QUEUE */ +#define LEO_CONTROL_START 0x01 /* START COMMAND */ +#define LEO_CONTROL_STBY 0x02 /* STAND-BY MODE(NOT SLEEP MODE) */ +#define LEO_CONTROL_WRT 0x01 /* READ RE-WRITE-ABLE CAPACITY */ +#define LEO_CONTROL_TBL 0x01 /* TRANSLATE BYTE TO LBA */ +#define LEO_CONTROL_BRAKE 0x04 /* SLEEP MODE(BRAKE ON) */ + +/*-----------------------------------*/ +/* BIT FIELD PARAMETER */ +/*-----------------------------------*/ +#define LEO_TEST_UNIT_MR 0x01 /* MEDIUM REMOVED */ +#define LEO_TEST_UNIT_RE 0x02 /* HEAD RETRACTED */ +#define LEO_TEST_UNIT_SS 0x04 /* SPINDLE STOPPED */ + +/*-----------------------------------*/ +/* STATUS */ +/*-----------------------------------*/ +#define LEO_STATUS_GOOD 0x00 +#define LEO_STATUS_CHECK_CONDITION 0x02 +#define LEO_STATUS_BUSY 0x08 + +/*-----------------------------------*/ +/* SENSE CODE */ +/*-----------------------------------*/ +#define LEO_SENSE_NO_ADDITIONAL_SENSE_INFOMATION 00 +#define LEO_SENSE_DRIVE_NOT_READY 01 +#define LEO_SENSE_DIAGNOSTIC_FAILURE 02 +#define LEO_SENSE_COMMAND_PHASE_ERROR 03 +#define LEO_SENSE_DATA_PHASE_ERROR 04 +#define LEO_SENSE_REAL_TIME_CLOCK_FAILURE 05 +#define LEO_SENSE_INCOMPATIBLE_MEDIUM_INSTALLED 11 +#define LEO_SENSE_UNKNOWN_FORMAT 11 +#define LEO_SENSE_NO_SEEK_COMPLETE 21 +#define LEO_SENSE_WRITE_FAULT 22 +#define LEO_SENSE_UNRECOVERED_READ_ERROR 23 +#define LEO_SENSE_NO_REFERENCE_POSITION_FOUND 24 +#define LEO_SENSE_TRACK_FOLLOWING_ERROR 25 +#define LEO_SENSE_TRACKING_OR_SPDL_SERVO_FAILURE 25 +#define LEO_SENSE_INVALID_COMMAND_OPERATION_CODE 31 +#define LEO_SENSE_LBA_OUT_OF_RANGE 32 +#define LEO_SENSE_WRITE_PROTECT_ERROR 33 +#define LEO_SENSE_COMMAND_TERMINATED 34 +#define LEO_SENSE_QUEUE_FULL 35 +#define LEO_SENSE_ILLEGAL_TIMER_VALUE 36 +#define LEO_SENSE_WAITING_NMI 37 +#define LEO_SENSE_DEVICE_COMMUNICATION_FAILURE 41 +#define LEO_SENSE_MEDIUM_NOT_PRESENT 42 +#define LEO_SENSE_POWERONRESET_DEVICERESET_OCCURED 43 +#define LEO_SENSE_MEDIUM_MAY_HAVE_CHANGED 47 +#define LEO_SENSE_EJECTED_ILLEGALLY_RESUME 49 + +/*-----------------------------------*/ +/* Command Block Header */ +/*-----------------------------------*/ +typedef struct{ + u8 command; + u8 reserve1; + u8 control; + u8 reserve3; + u8 status; + u8 sense; + u8 reserve6; + u8 reserve7; + OSMesgQueue *post; +} LEOCmdHeader; + +/*-----------------------------------*/ +/* CLEAR QUEUE(01H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdClearQue; + +/*-----------------------------------*/ +/* INQUIRY(02H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 dev_type; + u8 version; + u8 dev_num; + u8 leo_bios_ver; + u32 reserve5; +} LEOCmdInquiry; + +/*-----------------------------------*/ +/* TEST UNIT READY(03H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 test; + u8 reserve2; + u8 reserve3; + u8 reserve4; +} LEOCmdTestUnitReady; + +/*-----------------------------------*/ +/* REZERO(04H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdRezero; + +/*-----------------------------------*/ +/* READ(05H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 lba; + u32 xfer_blks; + void *buff_ptr; + u32 rw_bytes; +} LEOCmdRead; + +/*-----------------------------------*/ +/* WRITE(06H) command */ +/*-----------------------------------*/ +typedef LEOCmdRead LEOCmdWrite; + +/*-----------------------------------*/ +/* SEEK(07H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 lba; +} LEOCmdSeek; + +/*-----------------------------------*/ +/* START/STOP(08H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; +} LEOCmdStartStop; + +/*-----------------------------------*/ +/* READ CAPACITY(09H) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 start_lba; + u32 end_lba; + u32 capa_bytes; +} LEOCmdReadCapacity; + +/*-----------------------------------*/ +/* TRANSLATE(0AH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u32 start_lba; + u32 in_param; + u32 out_param; +} LEOCmdTranslate; + +/*-----------------------------------*/ +/* MODE SELECT(0BH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 page_code; + u8 reserve1; + u8 standby_time; + u8 sleep_time; + u8 led_on_time; + u8 led_off_time; + u8 reserve18; + u8 reserve19; +} LEOCmdModeSelect; + +/*-----------------------------------*/ +/* READ DISK ID(0CH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + void *buffer_pointer; +} LEOCmdReadDiskId; + +/*-----------------------------------*/ +/* READ TIMER(0DH) command */ +/*-----------------------------------*/ +typedef struct { + LEOCmdHeader header; + u8 reserve12; + u8 reserve13; + u8 year; + u8 month; + u8 day; + u8 hour; + u8 minute; + u8 second; +} LEOCmdReadTimer; + +/*-----------------------------------*/ +/* SET TIMER(0EH) command */ +/*-----------------------------------*/ +typedef LEOCmdReadTimer LEOCmdSetTimer; + +/*-------end of leoappli.h--------------------------*/ + + diff --git a/src/include/PR/libaudio.h b/include/PR/libaudio.h similarity index 90% rename from src/include/PR/libaudio.h rename to include/PR/libaudio.h index dc8826d77..fb2776de6 100644 --- a/src/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -1,3 +1,31 @@ +/*==================================================================== + * libaudio.h + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.173 $ + * $Date: 1997/12/01 12:42:21 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/libaudio.h,v $ + * + **************************************************************************/ + #ifndef __LIB_AUDIO__ #define __LIB_AUDIO__ @@ -35,11 +63,7 @@ extern "C" { #define AL_FX_BUFFER_SIZE 8192 #define AL_FRAME_INIT -1 -#if PAL -#define AL_USEC_PER_FRAME 20000 -#else -#define AL_USEC_PER_FRAME 16000 -#endif +#define AL_USEC_PER_FRAME (PAL ? 20000 : 16000) #define AL_MAX_PRIORITY 127 #define AL_GAIN_CHANGE_TIME 1000 @@ -304,27 +328,26 @@ typedef struct ALVoiceConfig_s { u8 unityPitch; /* unity pitch flag */ } ALVoiceConfig; -/** - * This struct needs some modifications but I'm not sure how yet. - * outputRate should be at 0x40 - */ typedef struct { - /*0x00*/ ALPlayer *head; /* client list head */ - /*0x04*/ ALLink pFreeList; /* list of free physical voices */ - /*0x0c*/ ALLink pAllocList; /* list of allocated physical voices */ - /*0x14*/ ALLink pLameList; /* list of voices ready to be freed */ - /*0x1c*/ s32 paramSamples; - /*0x20*/ s32 curSamples; /* samples from start of game */ - /*0x24*/ ALDMANew dma; - /*0x28*/ ALHeap *heap; - /*0x2c*/ struct ALParam_s *paramList; - /*0x30*/ struct ALMainBus_s *mainBus; - /*0x34*/ struct ALAuxBus_s *auxBus; /* ptr to array of aux bus structs */ - /*0x38*/ struct ALFilter_s *outputFilter; /* last filter in the filter chain */ - /*0x3c*/ s32 numPVoices; - /*0x40*/ s32 maxAuxBusses; - /*0x44*/ s32 outputRate; /* output sample rate */ - /*0x48*/ s32 maxOutSamples; /* Maximum samples rsp can generate + ALPlayer *head; /* client list head */ + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + + struct ALParam_s *paramList; + + struct ALMainBus_s *mainBus; + struct ALAuxBus_s *auxBus; /* ptr to array of aux bus structs */ + struct ALFilter_s *outputFilter; /* last filter in the filter chain */ + + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; /* output sample rate */ + s32 maxOutSamples; /* Maximum samples rsp can generate at one time at output rate */ } ALSynth; @@ -343,11 +366,11 @@ void alSynStartVoiceParams(ALSynth *s, ALVoice *voice, ALWaveTable *w, ALMicroTime t); void alSynStopVoice(ALSynth *s, ALVoice *voice); -void alSynSetVol(ALVoice *v, s16 vol, ALMicroTime delta); +void alSynSetVol(ALSynth *s, ALVoice *v, s16 vol, ALMicroTime delta); void alSynSetPitch(ALSynth *s, ALVoice *voice, f32 ratio); void alSynSetPan(ALSynth *s, ALVoice *voice, ALPan pan); void alSynSetFXMix(ALSynth *s, ALVoice *voice, u8 fxmix); -void n_alSynSetPriority(ALVoice *voice, s16 priority); +void alSynSetPriority(ALSynth *s, ALVoice *voice, s16 priority); s16 alSynGetPriority(ALSynth *s, ALVoice *voice); ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp); @@ -362,7 +385,7 @@ typedef struct { ALSynth drvr; } ALGlobals; -extern ALGlobals *n_syn; +extern ALGlobals *alGlobals; void alInit(ALGlobals *glob, ALSynConfig *c); void alClose(ALGlobals *glob); @@ -594,13 +617,13 @@ typedef struct { s32 eventCount; } ALEventQueue; -void n_alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, +void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount); -ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); +ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, - ALMicroTime delta, s32 arg3); + ALMicroTime delta); void alEvtqFlush(ALEventQueue *evtq); -void n_alEvtqFlushType(ALEventQueue *evtq, s16 type); +void alEvtqFlushType(ALEventQueue *evtq, s16 type); #define AL_PHASE_ATTACK 0 @@ -626,20 +649,18 @@ typedef struct ALVoiceState_s { u8 tremelo; /* current value of the tremelo */ u8 flags; /* bit 0 tremelo flag bit 1 vibrato flag */ - u32 unk38; - u32 unk3c; } ALVoiceState; typedef struct { - /*0x00*/ ALInstrument *instrument; /* instrument assigned to this chan */ - /*0x04*/ s16 bendRange; /* pitch bend range in cents */ - /*0x06*/ ALFxId fxId; /* type of fx assigned to this chan */ - /*0x07*/ ALPan pan; /* overall pan for this chan */ - /*0x08*/ u8 priority; /* priority for this chan */ - /*0x09*/ u8 vol; /* current volume for this chan */ - /*0x0a*/ u8 fxmix; /* current fx mix for this chan */ - /*0x0b*/ u8 unk0b; - /*0x0c*/ u8 sustain; /* current sustain pedal state */ + ALInstrument *instrument; /* instrument assigned to this chan */ + s16 bendRange; /* pitch bend range in cents */ + ALFxId fxId; /* type of fx assigned to this chan */ + ALPan pan; /* overall pan for this chan */ + u8 priority; /* priority for this chan */ + u8 vol; /* current volume for this chan */ + u8 fxmix; /* current fx mix for this chan */ + u8 unk0b; + u8 sustain; /* current sustain pedal state */ u8 unk0d; u8 unk0e; u8 unk0f; @@ -773,11 +794,6 @@ typedef struct { ALOscInit initOsc; ALOscUpdate updateOsc; ALOscStop stopOsc; - f32 unk7c; - f32 unk80; - s32 unk84; - u8 unk88; - u8 unk89; } ALCSPlayer; /* @@ -795,7 +811,7 @@ void alSeqGetLoc(ALSeq *seq, ALSeqMarker *marker); * Compact Sequence data representation routines */ void alCSeqNew(ALCSeq *seq, u8 *ptr); -void alCSeqNextEvent(ALCSeq *seq, ALEvent *evt, s32 arg2); +void alCSeqNextEvent(ALCSeq *seq,ALEvent *evt); s32 alCSeqGetTicks(ALCSeq *seq); f32 alCSeqTicksToSec(ALCSeq *seq, s32 ticks, u32 tempo); u32 alCSeqSecToTicks(ALCSeq *seq, f32 sec, u32 tempo); @@ -943,3 +959,6 @@ void alParseAbiCL(Acmd *cmdList, u32 nbytes); #endif #endif /* !__LIB_AUDIO__ */ + + + diff --git a/src/include/PR/mbi.h b/include/PR/mbi.h similarity index 98% rename from src/include/PR/mbi.h rename to include/PR/mbi.h index 4b3fd2a89..fed3510f8 100644 --- a/src/include/PR/mbi.h +++ b/include/PR/mbi.h @@ -60,11 +60,7 @@ * **************************************************************************/ -#ifdef F3D_OLD -#include -#else #include -#endif /************************************************************************** * diff --git a/include/PR/n_libaudio.h b/include/PR/n_libaudio.h new file mode 100644 index 000000000..3e8d57721 --- /dev/null +++ b/include/PR/n_libaudio.h @@ -0,0 +1,354 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_LIBAUDIO__ +#define __N_LIBAUDIO__ + +#include + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + + +/* + * Synthesis driver stuff + */ +typedef struct N_ALVoice_s { + ALLink node; + struct N_PVoice_s *pvoice; + ALWaveTable *table; + void *clientPrivate; + s16 state; + s16 priority; + s16 fxBus; + s16 unityPitch; +} N_ALVoice; + +typedef struct { + ALPlayer *head; /* client list head */ + ALLink pFreeList; /* list of free physical voices */ + ALLink pAllocList; /* list of allocated physical voices */ + ALLink pLameList; /* list of voices ready to be freed */ + s32 paramSamples; + s32 curSamples; /* samples from start of game */ + ALDMANew dma; + ALHeap *heap; + struct ALParam_s *paramList; + struct N_ALMainBus_s *mainBus; + struct N_ALAuxBus_s *auxBus; + struct N_ALFilter_s *outputFilter; + s32 numPVoices; + s32 maxAuxBusses; + s32 outputRate; + s32 maxOutSamples; +} N_ALSynth; + + +void n_alSynAddPlayer(ALPlayer *client); +void n_alSynAddSndPlayer(ALPlayer *client); +void n_alSynAddSeqPlayer(ALPlayer *client); + +ALFxRef n_alSynAllocFX( s16 bus,ALSynConfig *c, ALHeap *hp); +s32 n_alSynAllocVoice( N_ALVoice *voice, ALVoiceConfig *vc); + + +void n_alSynFreeVoice(N_ALVoice *voice); +ALFxRef n_alSynGetFXRef( s16 bus, s16 index); +s16 n_alSynGetPriority( N_ALVoice *voice); +void n_alSynRemovePlayer( ALPlayer *client); +void n_alSynSetFXMix(N_ALVoice *v, u8 fxmix); +void n_alSynSetFXParam(ALFxRef fx, s16 paramID, void *param); +void n_alSynFreeFX(ALFxRef *fx); +void n_alSynSetPan(N_ALVoice *v, u8 pan); +void n_alSynSetPitch( N_ALVoice *v, f32 pitch); +void n_alSynSetPriority( N_ALVoice *voice, s16 priority); +void n_alSynSetVol( N_ALVoice *v, s16 volume, ALMicroTime t); +void n_alSynStartVoice(N_ALVoice *v, ALWaveTable *table); +void n_alSynStartVoiceParams(N_ALVoice *v, ALWaveTable *w,f32 pitch, s16 vol, + ALPan pan, u8 fxmix, ALMicroTime t); +void n_alSynStopVoice( N_ALVoice *v); + +void n_alSynNew(ALSynConfig *c); +void n_alSynDelete(void); + + +/* + * Audio Library (AL) stuff + */ +typedef struct { + N_ALSynth drvr; +} N_ALGlobals; + +extern N_ALGlobals *n_alGlobals; +extern N_ALSynth *n_syn; + +void n_alInit(N_ALGlobals *g, ALSynConfig *c); +void n_alClose(N_ALGlobals *glob); +Acmd *n_alAudioFrame(Acmd *cmdList, s32 *cmdLen, + s16 *outBuf, s32 outLen); + + +/* + * Sequence Player stuff + */ +typedef struct { + struct N_ALVoice_s *voice; +} N_ALNoteEvent; + + +typedef struct { + struct N_ALVoice_s *voice; + ALMicroTime delta; + u8 vol; +} N_ALVolumeEvent; + + +typedef struct { + struct N_ALVoiceState_s *vs; + void *oscState; + u8 chan; +} N_ALOscEvent; + + +typedef struct { + s16 type; + union { + ALMIDIEvent midi; + ALTempoEvent tempo; + ALEndEvent end; + N_ALNoteEvent note; + N_ALVolumeEvent vol; + ALSeqpLoopEvent loop; + ALSeqpVolEvent spvol; + ALSeqpPriorityEvent sppriority; + ALSeqpSeqEvent spseq; + ALSeqpBankEvent spbank; + N_ALOscEvent osc; + } msg; +} N_ALEvent; + + +typedef struct { + ALLink node; + ALMicroTime delta; + N_ALEvent evt; +} N_ALEventListItem; + +void n_alEvtqNew(ALEventQueue *evtq, N_ALEventListItem *items, s32 itemCount); +ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, N_ALEvent *evt); +void n_alEvtqPostEvent(ALEventQueue *evtq, N_ALEvent *evt, ALMicroTime delta, s32 arg3); +void n_alEvtqFlushType(ALEventQueue *evtq, s16 type); + + +typedef struct N_ALVoiceState_s { + struct N_ALVoiceState_s *next;/* MUST be first */ + N_ALVoice voice; + ALSound *sound; + ALMicroTime envEndTime; /* time of envelope segment end */ + f32 pitch; /* currect pitch ratio */ + f32 vibrato; /* current value of the vibrato */ + u8 envGain; /* current envelope gain */ + u8 channel; /* channel assignment */ + u8 key; /* note on key number */ + u8 velocity; /* note on velocity */ + u8 envPhase; /* what envelope phase */ + u8 phase; + u8 tremelo; /* current value of the tremelo */ + u8 flags; /* bit 0 tremelo flag + bit 1 vibrato flag */ + u32 unk38; + u32 unk3c; +} N_ALVoiceState; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + N_ALSynth *drvr; /* reference to the client driver */ + ALSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + N_ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + N_ALVoiceState *vAllocHead; /* list head for allocated voices */ + N_ALVoiceState *vAllocTail; /* list tail for allocated voices */ + N_ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + ALSeqMarker *loopStart; + ALSeqMarker *loopEnd; + s32 loopCount; /* -1 = loop forever, 0 = no loop */ +} N_ALSeqPlayer; + +typedef struct { + ALPlayer node; /* note: must be first in structure */ + N_ALSynth *drvr; /* reference to the client driver */ + ALCSeq *target; /* current sequence */ + ALMicroTime curTime; + ALBank *bank; /* current ALBank */ + s32 uspt; /* microseconds per tick */ + s32 nextDelta; /* microseconds to next callback */ + s32 state; + u16 chanMask; /* active channels */ + s16 vol; /* overall sequence volume */ + u8 maxChannels; /* number of MIDI channels */ + u8 debugFlags; /* control which error get reported */ + N_ALEvent nextEvent; + ALEventQueue evtq; + ALMicroTime frameTime; + ALChanState *chanState; /* 16 channels for MIDI */ + N_ALVoiceState *vAllocHead; /* list head for allocated voices */ + N_ALVoiceState *vAllocTail; /* list tail for allocated voices */ + N_ALVoiceState *vFreeList; /* list of free voice state structs */ + ALOscInit initOsc; + ALOscUpdate updateOsc; + ALOscStop stopOsc; + f32 unk7c; + f32 unk80; + s32 unk84; + u8 unk88; + u8 unk89; +} N_ALCSPlayer; + + +/* + * Sequence data representation routines + */ +void n_alSeqNextEvent(ALSeq *seq, N_ALEvent *event); +void n_alSeqNewMarker(ALSeq *seq, ALSeqMarker *m, u32 ticks); + +void n_alCSeqNew(ALCSeq *seq, u8 *ptr); +void n_alCSeqNextEvent(ALCSeq *seq, N_ALEvent *evt, s32 arg2); +void n_alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks); + + +/* + * Sequence Player routines + */ +void n_alSeqpNew(N_ALSeqPlayer *seqp, ALSeqpConfig *config); +void n_alSeqpDelete(N_ALSeqPlayer *seqp); +u8 n_alSeqpGetChlVol(N_ALSeqPlayer *seqp, u8 chan); +u8 n_alSeqpGetChlFXMix(N_ALSeqPlayer *seqp, u8 chan); +ALPan n_alSeqpGetChlPan(N_ALSeqPlayer *seqp, u8 chan); +u8 n_alSeqpGetChlPriority(N_ALSeqPlayer *seqp, u8 chan); +s32 n_alSeqpGetChlProgram(N_ALSeqPlayer *seqp, u8 chan); +ALSeq *n_alSeqpGetSeq(N_ALSeqPlayer *seqp); +s32 n_alSeqpGetState(N_ALSeqPlayer *seqp); +s32 n_alSeqpGetTempo(N_ALSeqPlayer *seqp); +s16 n_alSeqpGetVol(N_ALSeqPlayer *seqp); /* Master volume control */ +void n_alSeqpPlay(N_ALSeqPlayer *seqp); +void n_alSeqpSendMidi(N_ALSeqPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); +void n_alSeqpSetBank(N_ALSeqPlayer *seqp, ALBank *b); +void n_alSeqpSetChlVol(N_ALSeqPlayer *seqp, u8 chan, u8 vol); +void n_alSeqpSetChlFXMix(N_ALSeqPlayer *seqp, u8 chan, u8 fxmix); +void n_alSeqpSetChlPan(N_ALSeqPlayer *seqp, u8 chan, ALPan pan); +void n_alSeqpSetChlPriority(N_ALSeqPlayer *seqp, u8 chan, u8 priority); +void n_alSeqpSetChlProgram(N_ALSeqPlayer *seqp, u8 chan, u8 prog); +void n_alSeqpSetSeq(N_ALSeqPlayer *seqp, ALSeq *seq); +void n_alSeqpSetTempo(N_ALSeqPlayer *seqp, s32 tempo); +void n_alSeqpSetVol(N_ALSeqPlayer *seqp, s16 vol); +void n_alSeqpStop(N_ALSeqPlayer *seqp); +void n_alSeqpLoop(N_ALSeqPlayer *seqp, ALSeqMarker *start, ALSeqMarker *end, s32 count); + + +/* + * Compressed Sequence Player routines + */ +void n_alCSPNew(N_ALCSPlayer *seqp, ALSeqpConfig *config); +void n_alCSPDelete(N_ALCSPlayer *seqp); +u8 n_alCSPGetChlVol(N_ALCSPlayer *seqp, u8 chan); +u8 n_alCSPGetChlFXMix(N_ALCSPlayer *seqp, u8 chan); +ALPan n_alCSPGetChlPan(N_ALCSPlayer *seqp, u8 chan); +u8 n_alCSPGetChlPriority(N_ALCSPlayer *seqp, u8 chan); +s32 n_alCSPGetChlProgram(N_ALCSPlayer *seqp, u8 chan); +ALCSeq *n_alCSPGetSeq(N_ALCSPlayer *seqp); +s32 n_alCSPGetState(N_ALCSPlayer *seqp); +s32 n_alCSPGetTempo(N_ALCSPlayer *seqp); +s16 n_alCSPGetVol(N_ALCSPlayer *seqp); +void n_alCSPPlay(N_ALCSPlayer *seqp); +void n_alCSPSendMidi(N_ALCSPlayer *seqp, s32 ticks, u8 status, u8 byte1, u8 byte2); +void n_alCSPSetBank(N_ALCSPlayer *seqp, ALBank *b); +void n_alCSPSetChlVol(N_ALCSPlayer *seqp, u8 chan, u8 vol); +void n_alCSPSetChlFXMix(N_ALCSPlayer *seqp, u8 chan, u8 fxmix); +void n_alCSPSetChlPan(N_ALCSPlayer *seqp, u8 chan, ALPan pan); +void n_alCSPSetChlPriority(N_ALCSPlayer *seqp, u8 chan, u8 priority); +void n_alCSPSetChlProgram(N_ALCSPlayer *seqp, u8 chan, u8 prog); +void n_alCSPSetSeq(N_ALCSPlayer *seqp, ALCSeq *seq); +void n_alCSPSetTempo(N_ALCSPlayer *seqp, s32 tempo); +void n_alCSPSetVol(N_ALCSPlayer *seqp, s16 vol); +void n_alCSPStop(N_ALCSPlayer *seqp); + + +/* + * Sound Player stuff + */ +typedef struct { + ALPlayer node; /* note: must be first in structure */ + ALEventQueue evtq; + N_ALEvent nextEvent; + N_ALSynth *drvr; /* reference to the client driver */ + s32 target; + void *sndState; + s32 maxSounds; + ALMicroTime frameTime; + ALMicroTime nextDelta; /* microseconds to next callback */ + ALMicroTime curTime; +} N_ALSndPlayer; + +void n_alSndpNew(N_ALSndPlayer *sndp, ALSndpConfig *c); +void n_alSndpDelete(void); +ALSndId n_alSndpAllocate(ALSound *sound); +void n_alSndpDeallocate(ALSndId id); +s32 n_alSndpGetState(void); +void n_alSndpPlay(void); +void n_alSndpPlayAt(ALMicroTime delta); +void n_alSndpSetFXMix(u8 mix); +void n_alSndpSetPan(ALPan pan); +void n_alSndpSetPitch(f32 pitch); +void n_alSndpSetPriority(ALSndId id, u8 priority); +void n_alSndpSetVol(s16 vol); +void n_alSndpStop(void); +ALSndId n_alSndpGetSound(void); +void n_alSndpSetSound(ALSndId id); + + +/* + * for n_audio micro code + */ +extern long long int n_aspMainTextStart[], n_aspMainTextEnd[]; +extern long long int n_aspMainDataStart[], n_aspMainDataEnd[]; + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* __N_LIBAUDIO__ */ diff --git a/include/PR/n_libaudio_s_to_n.h b/include/PR/n_libaudio_s_to_n.h new file mode 100644 index 000000000..de3e0f9cb --- /dev/null +++ b/include/PR/n_libaudio_s_to_n.h @@ -0,0 +1,120 @@ +#define ALVoice N_ALVoice +#define ALSynth N_ALSynth +#define ALGlobals N_ALGlobals + +#define alSynAddPlayer( a, b) n_alSynAddPlayer( b) +#define alSynAllocFX( a, b, c, d) n_alSynAllocFX( b, c, d) +#define alSynAllocVoice( a, b, c) n_alSynAllocVoice( b, c) +#define alSynDelete( a) n_alSynDelete() +#define alSynFreeVoice( a, b) n_alSynFreeVoice( b) +#define alSynGetFXRef( a, b, c) n_alSynGetFXRef( b, c) +#define alSynGetPriority( a, b) n_alSynGetPriority( b) +#define alSynRemovePlayer( a, b) n_alSynRemovePlayer( b) +#define alSynSetFXMix( a, b, c) n_alSynSetFXMix( b, c) +#define alSynSetFXParam( a, b, c, d) n_alSynSetFXParam( b, c, d) +#define alSynFreeFX( a, b) n_alSynFreeFX( b) +#define alSynSetPan( a, b, c) n_alSynSetPan( b, c) +#define alSynSetPitch( a, b, c) n_alSynSetPitch( b, c) +#define alSynSetPriority( a, b, c) n_alSynSetPriority( b, c) +#define alSynSetVol( a, b, c, d) n_alSynSetVol( b, c, d) +#define alSynStartVoice( a, b, c) n_alSynStartVoice( b, c) +#define alSynStartVoiceParams( a, b, c, d, e, f, g, h) \ + n_alSynStartVoiceParams( b, c, d, e, f, g, h) +#define alSynStopVoice( a, b) n_alSynStopVoice( b) +#define alSynNew( a, b) n_alSynNew( b) + +#define alInit n_alInit +#define alClose n_alClose +#define alAudioFrame n_alAudioFrame + +#define ALVoiceState N_ALVoiceState +#define ALSeqPlayer N_ALSeqPlayer +#define ALCSPlayer N_ALCSPlayer + +#define alSeqNextEvent n_alSeqNextEvent +#define alSeqNewMarker n_alSeqNewMarker + +#define alCSeqNew n_alCSeqNew +#define alCSeqNextEvent n_alCSeqNextEvent +#define alCSeqNewMarker n_alCSeqNewMarker + +#define alSeqpNew n_alSeqpNew +#define alSeqpDelete n_alSeqpDelete +#define alSeqpGetChlVol n_alSeqpGetChlVol +#define alSeqpGetChlFXMix n_alSeqpGetChlFXMix +#define alSeqpGetChlPan n_alSeqpGetChlPan +#define alSeqpGetChlPriority n_alSeqpGetChlPriority +#define alSeqpGetChlProgram n_alSeqpGetChlProgram +#define alSeqpGetSeq n_alSeqpGetSeq +#define alSeqpGetState n_alSeqpGetState +#define alSeqpGetTempo n_alSeqpGetTempo +#define alSeqpGetVol n_alSeqpGetVol +#define alSeqpPlay n_alSeqpPlay +#define alSeqpSendMidi n_alSeqpSendMidi +#define alSeqpSetBank n_alSeqpSetBank +#define alSeqpSetChlVol n_alSeqpSetChlVol +#define alSeqpSetChlFXMix n_alSeqpSetChlFXMix +#define alSeqpSetChlPan n_alSeqpSetChlPan +#define alSeqpSetChlPriority n_alSeqpSetChlPriority +#define alSeqpSetChlProgram n_alSeqpSetChlProgram +#define alSeqpSetSeq n_alSeqpSetSeq +#define alSeqpSetTempo n_alSeqpSetTempo +#define alSeqpSetVol n_alSeqpSetVol +#define alSeqpStop n_alSeqpStop +#define alSeqpLoop n_alSeqpLoop + +#define alCSPNew n_alCSPNew +#define alCSPDelete n_alCSPDelete +#define alCSPGetChlVol n_alCSPGetChlVol +#define alCSPGetChlFXMix n_alCSPGetChlFXMix +#define alCSPGetChlPan n_alCSPGetChlPan +#define alCSPGetChlPriority n_alCSPGetChlPriority +#define alCSPGetChlProgram n_alCSPGetChlProgram +#define alCSPGetSeq n_alCSPGetSeq +#define alCSPGetState n_alCSPGetState +#define alCSPGetTempo n_alCSPGetTempo +#define alCSPGetVol n_alCSPGetVol +#define alCSPPlay n_alCSPPlay +#define alCSPSendMidi n_alCSPSendMidi +#define alCSPSetBank n_alCSPSetBank +#define alCSPSetChlVol n_alCSPSetChlVol +#define alCSPSetChlFXMix n_alCSPSetChlFXMix +#define alCSPSetChlPan n_alCSPSetChlPan +#define alCSPSetChlPriority n_alCSPSetChlPriority +#define alCSPSetChlProgram n_alCSPSetChlProgram +#define alCSPSetSeq n_alCSPSetSeq +#define alCSPSetTempo n_alCSPSetTempo +#define alCSPSetVol n_alCSPSetVol +#define alCSPStop n_alCSPStop + +#define ALSoundState N_ALSoundState +#define ALSndpEvent N_ALSndpEvent +#define ALSndPlayer N_ALSndPlayer + +#define alSndpNew( a, b) n_alSndpNew( a, b) +#define alSndpDelete( a) n_alSndpDelete() +#define alSndpAllocate( a, b) n_alSndpAllocate( b) +#define alSndpDeallocate( a, b) n_alSndpDeallocate( b) +#define alSndpGetState( a) n_alSndpGetState() +#define alSndpPlay( a) n_alSndpPlay() +#define alSndpPlayAt( a, b) n_alSndpPlayAt( b) +#define alSndpSetFXMix( a, b) n_alSndpSetFXMix( b) +#define alSndpSetPan( a, b) n_alSndpSetPan( b) +#define alSndpSetPitch( a, b) n_alSndpSetPitch( b) +#define alSndpSetPriority( a, b, c) n_alSndpSetPriority( b, c) +#define alSndpSetVol( a, b) n_alSndpSetVol( b) +#define alSndpStop( a) n_alSndpStop() +#define alSndpGetSound( a) n_alSndpGetSound() +#define alSndpSetSound( a, b) n_alSndpSetSound( b) + +#define alEvtqNew n_alEvtqNew +#define alEvtqNextEvent n_alEvtqNextEvent +#define alEvtqPostEvent n_alEvtqPostEvent +#define alEvtqFlushType n_alEvtqFlushType +#define alEvtqPrintEvtQueue n_alEvtqPrintEvtQueue +#define alEvtqPrintAllocEvts n_alEvtqPrintAllocEvts + + + + + diff --git a/include/PR/os.h b/include/PR/os.h new file mode 100644 index 000000000..0c4b0d578 --- /dev/null +++ b/include/PR/os.h @@ -0,0 +1,107 @@ + +/*==================================================================== + * os.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os.h,v $ + $Revision: 1.167 $ + $Date: 1999/01/18 13:17:43 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_H_ +#define _OS_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager), + * SIM (SI Manager) + * + */ +#define OS_PIM_STACKSIZE 4096 +#define OS_VIM_STACKSIZE 4096 +#define OS_SIM_STACKSIZE 4096 + +#define OS_MIN_STACKSIZE 72 + +/* + * Leo Disk + */ + +/* transfer mode */ + +#define LEO_BLOCK_MODE 1 +#define LEO_TRACK_MODE 2 +#define LEO_SECTOR_MODE 3 + +/* + * Boot addresses + */ +#define BOOT_ADDRESS_ULTRA 0x80000400 +#define BOOT_ADDRESS_COSIM 0x80002000 +#define BOOT_ADDRESS_EMU 0x20010000 +#define BOOT_ADDRESS_INDY 0x88100000 + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_H */ diff --git a/src/include/PR/os_ai.h b/include/PR/os_ai.h similarity index 100% rename from src/include/PR/os_ai.h rename to include/PR/os_ai.h diff --git a/src/include/PR/os_cache.h b/include/PR/os_cache.h similarity index 100% rename from src/include/PR/os_cache.h rename to include/PR/os_cache.h diff --git a/src/include/PR/os_cont.h b/include/PR/os_cont.h similarity index 62% rename from src/include/PR/os_cont.h rename to include/PR/os_cont.h index cfb83c290..2754f2504 100644 --- a/src/include/PR/os_cont.h +++ b/include/PR/os_cont.h @@ -21,7 +21,7 @@ /*---------------------------------------------------------------------* Copyright (C) 1998 Nintendo. (Originated by SGI) - + $RCSfile: os_cont.h,v $ $Revision: 1.1 $ $Date: 1998/10/09 08:01:05 $ @@ -47,7 +47,7 @@ extern "C" { */ /* - * Structure for controllers + * Structure for controllers */ typedef struct { @@ -71,104 +71,6 @@ typedef struct { u8 errno; } OSContRamIo; -typedef struct -{ - /* 0x0 */ u32 ramarray[15]; - /* 0x3C */ u32 pifstatus; -} OSPifRam; - -typedef struct -{ - /* 0x0 */ u8 dummy; - /* 0x1 */ u8 txsize; - /* 0x2 */ u8 rxsize; - /* 0x3 */ u8 cmd; - /* 0x4 */ u16 button; - /* 0x6 */ s8 stick_x; - /* 0x7 */ s8 stick_y; -} __OSContReadFormat; - -typedef struct -{ - /* 0x0 */ u8 dummy; - /* 0x1 */ u8 txsize; - /* 0x2 */ u8 rxsize; - /* 0x3 */ u8 cmd; - /* 0x4 */ u8 typeh; - /* 0x5 */ u8 typel; - /* 0x6 */ u8 status; - /* 0x7 */ u8 dummy1; -} __OSContRequestFormat; - -typedef struct -{ - /* 0x0 */ u8 txsize; - /* 0x1 */ u8 rxsize; - /* 0x2 */ u8 cmd; - /* 0x3 */ u8 typeh; - /* 0x4 */ u8 typel; - /* 0x5 */ u8 status; -} __OSContRequestFormatShort; - -typedef struct -{ - /* 0x0 */ u8 dummy; - /* 0x1 */ u8 txsize; - /* 0x2 */ u8 rxsize; - /* 0x3 */ u8 cmd; - /* 0x4 */ u8 hi; - /* 0x4 */ u8 lo; - /* 0x6 */ u8 data[BLOCKSIZE]; - /* 0x26 */ u8 datacrc; -} __OSContRamReadFormat; - -typedef union { - /* 0x0 */ struct - { - /* 0x0 */ u8 bank; - /* 0x1 */ u8 page; - } inode_t; - /* 0x0 */ u16 ipage; -} __OSInodeUnit; - -typedef struct -{ - /* 0x0 */ u32 game_code; - /* 0x4 */ u16 company_code; - /* 0x6 */ __OSInodeUnit start_page; - /* 0x8 */ u8 status; - /* 0x9 */ s8 reserved; - /* 0xA */ u16 data_sum; - /* 0xC */ u8 ext_name[4]; - /* 0x10 */ u8 game_name[16]; -} __OSDir; - -typedef struct -{ - /* 0x0 */ __OSInodeUnit inode_page[128]; -} __OSInode; - -typedef struct -{ - /* 0x0 */ u32 repaired; - /* 0x4 */ u32 random; - /* 0x8 */ u64 serial_mid; - /* 0x10 */ u64 serial_low; - /* 0x18 */ u16 deviceid; - /* 0x1A */ u8 banks; - /* 0x1B */ u8 version; - /* 0x1C */ u16 checksum; - /* 0x1E */ u16 inverted_checksum; -} __OSPackId; - -typedef struct -{ - /* 0x0 */ u8 txsize; - /* 0x1 */ u8 rxsize; - /* 0x2 */ u8 cmd; - /* 0x3 */ u8 address; - /* 0x4 */ u8 data[EEPROM_BLOCK_SIZE]; -} __OSContEepromFormat; #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ @@ -194,7 +96,7 @@ typedef struct #ifdef _HW_VERSION_1 #define CONT_FRAME_ERROR 0x2 #define CONT_COLLISION_ERROR 0x1 -#endif +#endif /* Controller type */ @@ -260,39 +162,6 @@ typedef struct #define CONT_ERR_VOICE_WORD 14 #define CONT_ERR_VOICE_NO_RESPONSE 15 -#define CONT_CMD_REQUEST_STATUS 0 -#define CONT_CMD_READ_BUTTON 1 -#define CONT_CMD_READ_MEMPACK 2 -#define CONT_CMD_WRITE_MEMPACK 3 -#define CONT_CMD_READ_EEPROM 4 -#define CONT_CMD_WRITE_EEPROM 5 -#define CONT_CMD_RESET 0xff - -#define CONT_CMD_REQUEST_STATUS_TX 1 -#define CONT_CMD_READ_BUTTON_TX 1 -#define CONT_CMD_READ_MEMPACK_TX 3 -#define CONT_CMD_WRITE_MEMPACK_TX 35 -#define CONT_CMD_READ_EEPROM_TX 2 -#define CONT_CMD_WRITE_EEPROM_TX 10 -#define CONT_CMD_RESET_TX 1 - -#define CONT_CMD_REQUEST_STATUS_RX 3 -#define CONT_CMD_READ_BUTTON_RX 4 -#define CONT_CMD_READ_MEMPACK_RX 33 -#define CONT_CMD_WRITE_MEMPACK_RX 1 -#define CONT_CMD_READ_EEPROM_RX 8 -#define CONT_CMD_WRITE_EEPROM_RX 1 -#define CONT_CMD_RESET_RX 3 - -#define CONT_CMD_NOP 0xff -#define CONT_CMD_END 0xfe //indicates end of a command -#define CONT_CMD_EXE 1 //set pif ram status byte to this to do a command - -#define DIR_STATUS_EMPTY 0 -#define DIR_STATUS_UNKNOWN 1 -#define DIR_STATUS_OCCUPIED 2 - -#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4) #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) diff --git a/include/PR/os_convert.h b/include/PR/os_convert.h new file mode 100644 index 000000000..4be88b5fe --- /dev/null +++ b/include/PR/os_convert.h @@ -0,0 +1,105 @@ + +/*==================================================================== + * os_convert.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_convert.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:05 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_CONVERT_H_ +#define _OS_CONVERT_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +#define OS_CLOCK_RATE 62500000LL +#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) +#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) +#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) +#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) + +#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) +#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) + +#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) +#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Address translation routines and macros */ + +extern u32 osVirtualToPhysical(void *); +extern void * osPhysicalToVirtual(u32); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_CONVERT_H_ */ diff --git a/include/PR/os_debug.h b/include/PR/os_debug.h new file mode 100644 index 000000000..5b13d8cca --- /dev/null +++ b/include/PR/os_debug.h @@ -0,0 +1,108 @@ + +/*==================================================================== + * os_debug.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_debug.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:06 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_DEBUG_H_ +#define _OS_DEBUG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for Profiler + */ +typedef struct { + u16 *histo_base; /* histogram base */ + u32 histo_size; /* histogram size */ + u32 *text_start; /* start of text segment */ + u32 *text_end; /* end of text segment */ +} OSProf; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Profiler constants + */ +#define PROF_MIN_INTERVAL 50 /* microseconds */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Profiler Interface */ + +extern void osProfileInit(OSProf *, u32 profcnt); +extern void osProfileStart(u32); +extern void osProfileFlush(void); +extern void osProfileStop(void); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_DEBUG_H_ */ diff --git a/src/include/PR/os_eeprom.h b/include/PR/os_eeprom.h similarity index 100% rename from src/include/PR/os_eeprom.h rename to include/PR/os_eeprom.h diff --git a/include/PR/os_error.h b/include/PR/os_error.h new file mode 100644 index 000000000..f4c3b83c5 --- /dev/null +++ b/include/PR/os_error.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_error.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_error.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:06 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_ERROR_H_ +#define _OS_ERROR_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_ERROR_H_ */ diff --git a/src/include/PR/os_exception.h b/include/PR/os_exception.h similarity index 100% rename from src/include/PR/os_exception.h rename to include/PR/os_exception.h diff --git a/include/PR/os_gbpak.h b/include/PR/os_gbpak.h new file mode 100644 index 000000000..0a9999450 --- /dev/null +++ b/include/PR/os_gbpak.h @@ -0,0 +1,107 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_gbpak.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:07 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_GBPAK_H_ +#define _OS_GBPAK_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" +#include "os_pfs.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef struct { + u16 fixed1; + u16 start_address; + u8 nintendo_chr[0x30]; + u8 game_title[16]; + u16 company_code; + u8 body_code; + u8 cart_type; + u8 rom_size; + u8 ram_size; + u8 country_code; + u8 fixed2; + u8 version; + u8 isum; + u16 sum; +} OSGbpakId; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* definition for 64GB-PAK */ + +#define OS_GBPAK_POWER 0x01 +#define OS_GBPAK_RSTB_DETECTION 0x04 +#define OS_GBPAK_RSTB_STATUS 0x08 +#define OS_GBPAK_GBCART_PULL 0x40 +#define OS_GBPAK_GBCART_ON 0x80 + +#define OS_GBPAK_POWER_OFF 0x00 /* power of 64GB-PAK */ +#define OS_GBPAK_POWER_ON 0x01 + +#define OS_GBPAK_ROM_ID_SIZE 0x50 /* ID size of GB cartridge */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* 64GB-PAK */ +extern s32 osGbpakInit(OSMesgQueue *, OSPfs *, int); +extern s32 osGbpakPower(OSPfs *, s32); +extern s32 osGbpakGetStatus(OSPfs *, u8 *); +extern s32 osGbpakReadWrite(OSPfs *, u16, u16, u8 *, u16); +extern s32 osGbpakReadId(OSPfs *, OSGbpakId *, u8 *); +extern s32 osGbpakCheckConnector(OSPfs *, u8 *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_GBPAK_H_ */ diff --git a/include/PR/os_gio.h b/include/PR/os_gio.h new file mode 100644 index 000000000..ad3c020fa --- /dev/null +++ b/include/PR/os_gio.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_gio.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_gio.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:08 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_GIO_H_ +#define _OS_GIO_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_GIO_H_ */ diff --git a/include/PR/os_host.h b/include/PR/os_host.h new file mode 100644 index 000000000..1191189f4 --- /dev/null +++ b/include/PR/os_host.h @@ -0,0 +1,104 @@ + +/*==================================================================== + * os_host.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_host.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:08 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_HOST_H_ +#define _OS_HOST_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* PARTNER-N64 */ +#ifdef PTN64 +#define osReadHost osReadHost_pt +#define osWriteHost osWriteHost_pt +#endif + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Game <> Host data transfer functions */ + +extern s32 osTestHost(void); +extern void osReadHost(void *, u32); +extern void osWriteHost(void *, u32); +extern void osAckRamromRead(void); +extern void osAckRamromWrite(void); + +/* RDB port operations */ + +extern void osInitRdb(u8 *sendBuf, u32 sendSize); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_HOST_H_ */ diff --git a/include/PR/os_internal.h b/include/PR/os_internal.h new file mode 100644 index 000000000..754d1ee29 --- /dev/null +++ b/include/PR/os_internal.h @@ -0,0 +1,49 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal.h,v $ + $Revision: 1.20 $ + $Date: 1998/10/09 08:01:09 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_H_ +#define _OS_INTERNAL_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +#include "os_internal_reg.h" +#include "os_internal_exception.h" +#include "os_internal_tlb.h" +#include "os_internal_si.h" +#include "os_internal_rsp.h" +#include "os_internal_error.h" +#include "os_internal_gio.h" +#include "os_internal_thread.h" +#include "os_internal_debug.h" +#include "os_internal_host.h" + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_H */ diff --git a/include/PR/os_internal_debug.h b/include/PR/os_internal_debug.h new file mode 100644 index 000000000..7b307d6e3 --- /dev/null +++ b/include/PR/os_internal_debug.h @@ -0,0 +1,43 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_debug.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:09 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_DEBUG_H_ +#define _OS_INTERNAL_DEBUG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Debug port */ +extern void __osSyncPutChars(int, int, const char *); +extern int __osAtomicDec(unsigned int *p); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_DEBUG_H */ diff --git a/include/PR/os_internal_error.h b/include/PR/os_internal_error.h new file mode 100644 index 000000000..de188d239 --- /dev/null +++ b/include/PR/os_internal_error.h @@ -0,0 +1,45 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_error.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:10 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_ERROR_H_ +#define _OS_INTERNAL_ERROR_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Error handling */ + +extern void __osError(s16, s16, ...); +extern OSThread * __osGetCurrFaultedThread(void); +extern OSThread * __osGetNextFaultedThread(OSThread *); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_ERROR_H */ diff --git a/include/PR/os_internal_exception.h b/include/PR/os_internal_exception.h new file mode 100644 index 000000000..730dc9352 --- /dev/null +++ b/include/PR/os_internal_exception.h @@ -0,0 +1,49 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_exception.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:10 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_EXCEPTION_H_ +#define _OS_INTERNAL_EXCEPTION_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routine for HW interrupt "handler" */ +extern void __osSetHWIntrRoutine(OSHWIntr interrupt, + s32 (*handler)(void), void *stackEnd); +extern void __osGetHWIntrRoutine(OSHWIntr interrupt, + s32 (**handler)(void), void **stackEnd); + +/* Routine for global interrupt mask */ +extern void __osSetGlobalIntMask(OSHWIntr); +extern void __osResetGlobalIntMask(OSHWIntr); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_EXCEPTION_H */ diff --git a/include/PR/os_internal_gio.h b/include/PR/os_internal_gio.h new file mode 100644 index 000000000..ff133850f --- /dev/null +++ b/include/PR/os_internal_gio.h @@ -0,0 +1,45 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_gio.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:11 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_GIO_H_ +#define _OS_INTERNAL_GIO_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Development board functions */ + +extern void __osGIOInit(s32); +extern void __osGIOInterrupt(s32); +extern void __osGIORawInterrupt(s32); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_GIO_H */ diff --git a/include/PR/os_internal_host.h b/include/PR/os_internal_host.h new file mode 100644 index 000000000..b6d195130 --- /dev/null +++ b/include/PR/os_internal_host.h @@ -0,0 +1,42 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_host.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:11 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_HOST_H_ +#define _OS_INTERNAL_HOST_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* routine for rdb port */ +extern u32 __osRdbSend(u8 *buf, u32 size, u32 type); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_HOST_H */ diff --git a/include/PR/os_internal_reg.h b/include/PR/os_internal_reg.h new file mode 100644 index 000000000..d78fa5ea7 --- /dev/null +++ b/include/PR/os_internal_reg.h @@ -0,0 +1,57 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_reg.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:12 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_REG_H_ +#define _OS_INTERNAL_REG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routines to get/fetch coprocessor 0 registers */ + +extern u32 __osGetCause(void); +extern void __osSetCause(u32); +extern u32 __osGetCompare(void); +extern void __osSetCompare(u32); +extern u32 __osGetConfig(void); +extern void __osSetConfig(u32); +extern void __osSetCount(u32); +extern u32 __osGetSR(void); +extern void __osSetSR(u32); +extern u32 __osDisableInt(void); +extern void __osRestoreInt(u32); + +/* Routines to get/set floating-point control and status register */ +extern u32 __osSetFpcCsr(u32); +extern u32 __osGetFpcCsr(void); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_REG_H */ diff --git a/include/PR/os_internal_rsp.h b/include/PR/os_internal_rsp.h new file mode 100644 index 000000000..646e66796 --- /dev/null +++ b/include/PR/os_internal_rsp.h @@ -0,0 +1,48 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_rsp.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:12 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_RSP_H_ +#define _OS_INTERNAL_RSP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Signal processor interface (Sp) */ + +extern u32 __osSpGetStatus(void); +extern void __osSpSetStatus(u32); +extern s32 __osSpSetPc(u32); +extern s32 __osSpRawWriteIo(u32, u32); +extern s32 __osSpRawReadIo(u32, u32 *); +extern s32 __osSpRawStartDma(s32, u32, void *, u32); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_RSP_H */ diff --git a/include/PR/os_internal_si.h b/include/PR/os_internal_si.h new file mode 100644 index 000000000..d0eeedccb --- /dev/null +++ b/include/PR/os_internal_si.h @@ -0,0 +1,46 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_si.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:13 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_SI_H_ +#define _OS_INTERNAL_SI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Serial interface (Si) */ + +extern u32 __osSiGetStatus(void); +extern s32 __osSiRawWriteIo(u32, u32); +extern s32 __osSiRawReadIo(u32, u32 *); +extern s32 __osSiRawStartDma(s32, void *); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_SI_H */ diff --git a/include/PR/os_internal_thread.h b/include/PR/os_internal_thread.h new file mode 100644 index 000000000..1305eb58b --- /dev/null +++ b/include/PR/os_internal_thread.h @@ -0,0 +1,43 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_thread.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:13 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_THREAD_H_ +#define _OS_INTERNAL_THREAD_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* For debugger use */ + +extern OSThread * __osGetActiveQueue(void); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_THREAD_H */ diff --git a/include/PR/os_internal_tlb.h b/include/PR/os_internal_tlb.h new file mode 100644 index 000000000..b92918ffe --- /dev/null +++ b/include/PR/os_internal_tlb.h @@ -0,0 +1,47 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_internal_tlb.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:14 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_INTERNAL_TLB_H_ +#define _OS_INTERNAL_TLB_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Routines for fetch TLB info */ + +extern u32 __osGetTLBASID(void); +extern u32 __osGetTLBPageMask(s32); +extern u32 __osGetTLBHi(s32); +extern u32 __osGetTLBLo0(s32); +extern u32 __osGetTLBLo1(s32); + + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_INTERNAL_TLB_H */ diff --git a/src/include/PR/os_libc.h b/include/PR/os_libc.h similarity index 96% rename from src/include/PR/os_libc.h rename to include/PR/os_libc.h index 5418a4820..e210f87e5 100644 --- a/src/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -21,15 +21,17 @@ /*---------------------------------------------------------------------* Copyright (C) 1998 Nintendo. (Originated by SGI) - + $RCSfile: os_libc.h,v $ - $Revision: 1.3 $ - $Date: 1999/07/13 01:43:47 $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:14 $ *---------------------------------------------------------------------*/ #ifndef _OS_LIBC_H_ #define _OS_LIBC_H_ +#include "os_pfs.h" + #ifdef _LANGUAGE_C_PLUS_PLUS extern "C" { #endif @@ -78,7 +80,6 @@ extern "C" { /* byte string operations */ - extern void bcopy(const void *, void *, int); extern int bcmp(const void *, const void *, int); extern void bzero(void *, int); diff --git a/src/include/PR/os_message.h b/include/PR/os_message.h similarity index 90% rename from src/include/PR/os_message.h rename to include/PR/os_message.h index a82a90e2c..5bc565e36 100644 --- a/src/include/PR/os_message.h +++ b/include/PR/os_message.h @@ -21,7 +21,7 @@ /*---------------------------------------------------------------------* Copyright (C) 1998 Nintendo. (Originated by SGI) - + $RCSfile: os_message.h,v $ $Revision: 1.1 $ $Date: 1998/10/09 08:01:15 $ @@ -65,10 +65,6 @@ typedef struct OSMesgQueue_s { OSMesg *msg; /* Points to message buffer array */ } OSMesgQueue; -typedef struct __OSEventState { - OSMesgQueue *messageQueue; - OSMesg message; -} __OSEventState; #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ @@ -116,17 +112,6 @@ typedef struct __OSEventState { #define OS_MESG_NOBLOCK 0 #define OS_MESG_BLOCK 1 -/* - * I/O message types - */ -#define OS_MESG_TYPE_BASE (10) -#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE+0) -#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE+1) -#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE+2) -#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE+3) -#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE+4) -#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE+5) -#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE+6) #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) diff --git a/include/PR/os_motor.h b/include/PR/os_motor.h new file mode 100644 index 000000000..f8dcbd5a3 --- /dev/null +++ b/include/PR/os_motor.h @@ -0,0 +1,83 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_motor.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:15 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_MOTOR_H_ +#define _OS_MOTOR_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" +#include "os_pfs.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Rumble PAK interface */ + +extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); +#if 1 +#define MOTOR_START 1 +#define MOTOR_STOP 0 +#define osMotorStart(x) __osMotorAccess((x), MOTOR_START) +#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) +extern s32 __osMotorAccess(OSPfs *, s32); +#else +extern s32 osMotorStop(OSPfs *); +extern s32 osMotorStart(OSPfs *); +#endif + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_MOTOR_H_ */ diff --git a/include/PR/os_pfs.h b/include/PR/os_pfs.h new file mode 100644 index 000000000..59f35695f --- /dev/null +++ b/include/PR/os_pfs.h @@ -0,0 +1,178 @@ + +/*==================================================================== + * os_pfs.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_pfs.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:16 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_PFS_H_ +#define _OS_PFS_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for file system + */ +typedef struct { + int status; + OSMesgQueue *queue; + int channel; + u8 id[32]; + u8 label[32]; + int version; + int dir_size; + int inode_table; /* block location */ + int minode_table; /* mirrioring inode_table */ + int dir_table; /* block location */ + int inode_start_page; /* page # */ + u8 banks; + u8 activebank; +} OSPfs; + +typedef struct { + u32 file_size; /* bytes */ + u32 game_code; + u16 company_code; + char ext_name[4]; + char game_name[16]; +} OSPfsState; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* File System size */ +#define OS_PFS_VERSION 0x0200 +#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) +#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) + +#define PFS_FILE_NAME_LEN 16 +#define PFS_FILE_EXT_LEN 4 +#define BLOCKSIZE 32 /* bytes */ +#define PFS_ONE_PAGE 8 /* blocks */ +#define PFS_MAX_BANKS 62 + +/* File System flag */ + +#define PFS_READ 0 +#define PFS_WRITE 1 +#define PFS_CREATE 2 + +/* File System status */ +#define PFS_INITIALIZED 0x1 +#define PFS_CORRUPTED 0x2 /* File system was corrupted */ +#define PFS_ID_BROKEN 0x4 +#define PFS_MOTOR_INITIALIZED 0x8 +#define PFS_GBPAK_INITIALIZED 0x10 + +/* File System error number */ + +#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */ +#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */ + /* different one */ +#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */ +#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR +#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/ +#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/ +#define PFS_DATA_FULL 7 /* no free pages on ram pack */ +#define PFS_DIR_FULL 8 /* no free directories on ram pack*/ +#define PFS_ERR_EXIST 9 /* file exists */ +#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ +#define PFS_ERR_DEVICE 11 /* wrong device type*/ +#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */ +#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* file system interface */ + +#if VERSION >= VERSION_NTSC_1_0 +s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel, s32 *arg3); +#else +s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel); +#endif +extern s32 osPfsRepairId(OSPfs *); +extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); +extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); +extern s32 osPfsChecker(OSPfs *); +extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); +extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); +extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); +extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); +extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); +extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); +extern s32 osPfsSetLabel(OSPfs *, u8 *); +extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); +extern s32 osPfsFreeBlocks(OSPfs *, s32 *); +extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_PFS_H_ */ diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h new file mode 100644 index 000000000..0c7459784 --- /dev/null +++ b/include/PR/os_pi.h @@ -0,0 +1,224 @@ + +/*==================================================================== + * os_pi.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_pi.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:16 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_PI_H_ +#define _OS_PI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_thread.h" +#include "os_message.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for Enhanced PI interface + */ + +/* + * OSTranxInfo is set up for Leo Disk DMA. This info will be maintained + * by exception handler. This is how the PIMGR and the ISR communicate. + */ + +typedef struct { + u32 errStatus; /* error status */ + void *dramAddr; /* RDRAM buffer address (DMA) */ + void *C2Addr; /* C2 buffer address */ + u32 sectorSize; /* size of transfering sector */ + u32 C1ErrNum; /* total # of C1 errors */ + u32 C1ErrSector[4]; /* error sectors */ +} __OSBlockInfo; + +typedef struct { + u32 cmdType; /* for disk only */ + u16 transferMode; /* Block, Track, or sector? */ + u16 blockNum; /* which block is transfering */ + s32 sectorNum; /* which sector is transfering */ + u32 devAddr; /* Device buffer address */ + u32 bmCtlShadow; /* asic bm_ctl(510) register shadow ram */ + u32 seqCtlShadow; /* asic seq_ctl(518) register shadow ram */ + __OSBlockInfo block[2]; /* bolck transfer info */ +} __OSTranxInfo; + + +typedef struct OSPiHandle_s { + struct OSPiHandle_s *next; /* point to next handle on the table */ + u8 type; /* DEVICE_TYPE_BULK for disk */ + u8 latency; /* domain latency */ + u8 pageSize; /* domain page size */ + u8 relDuration; /* domain release duration */ + u8 pulse; /* domain pulse width */ + u8 domain; /* which domain */ + u32 baseAddress; /* Domain address */ + u32 speed; /* for roms only */ + /* The following are "private" elements" */ + __OSTranxInfo transferInfo; /* for disk only */ +} OSPiHandle; + +typedef struct { + u8 type; + u32 address; +} OSPiInfo; + +/* + * Structure for I/O message block + */ +typedef struct { + u16 type; /* Message type */ + u8 pri; /* Message priority (High or Normal) */ + u8 status; /* Return status */ + OSMesgQueue *retQueue; /* Return message queue to notify I/O + * completion */ +} OSIoMesgHdr; + +typedef struct { + OSIoMesgHdr hdr; /* Message header */ + void * dramAddr; /* RDRAM buffer address (DMA) */ + u32 devAddr; /* Device buffer address (DMA) */ + u32 size; /* DMA transfer size in bytes */ + OSPiHandle *piHandle; /* PI device handle */ +} OSIoMesg; + +/* + * Structure for device manager block + */ +typedef struct { + s32 active; /* Status flag */ + OSThread *thread; /* Calling thread */ + OSMesgQueue *cmdQueue; /* Command queue */ + OSMesgQueue *evtQueue; /* Event queue */ + OSMesgQueue *acsQueue; /* Access queue */ + /* Raw DMA routine */ + s32 (*dma)(s32, u32, void *, u32); + s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); +} OSDevMgr; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* Flags to indicate direction of data transfer */ + +#define OS_READ 0 /* device -> RDRAM */ +#define OS_WRITE 1 /* device <- RDRAM */ +#define OS_OTHERS 2 /* for Leo disk only */ + +/* + * I/O message types + */ +#define OS_MESG_TYPE_BASE (10) +#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE+0) +#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE+1) +#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE+2) +#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE+3) +#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE+4) +#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE+5) +#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE+6) + +/* + * I/O message priority + */ +#define OS_MESG_PRI_NORMAL 0 +#define OS_MESG_PRI_HIGH 1 + +/* + * PI/EPI + */ +#define PI_DOMAIN1 0 +#define PI_DOMAIN2 1 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + +extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Peripheral interface (Pi) */ +extern u32 osPiGetStatus(void); +extern s32 osPiGetDeviceType(void); +extern s32 osPiWriteIo(u32, u32); +extern s32 osPiReadIo(u32, u32 *); +extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, + OSMesgQueue *); +extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32); + +/* Enhanced PI interface */ + +extern OSPiHandle *osCartRomInit(void); +extern OSPiHandle *osLeoDiskInit(void); +extern OSPiHandle *osDriveRomInit(void); + +extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *); +extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 ); +extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); +extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); +extern s32 osEPiLinkHandle(OSPiHandle *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_PI_H_ */ diff --git a/src/include/PR/os_rdp.h b/include/PR/os_rdp.h similarity index 100% rename from src/include/PR/os_rdp.h rename to include/PR/os_rdp.h diff --git a/include/PR/os_reg.h b/include/PR/os_reg.h new file mode 100644 index 000000000..50aa21881 --- /dev/null +++ b/include/PR/os_reg.h @@ -0,0 +1,90 @@ + +/*==================================================================== + * os_reg.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_reg.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:17 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_REG_H_ +#define _OS_REG_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Miscellaneous operations */ + +extern u32 osGetCount(void); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_REG_H_ */ diff --git a/include/PR/os_rsp.h b/include/PR/os_rsp.h new file mode 100644 index 000000000..12116053e --- /dev/null +++ b/include/PR/os_rsp.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_rsp.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_rsp.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:17 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_RSP_H_ +#define _OS_RSP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_RSP_H_ */ diff --git a/include/PR/os_si.h b/include/PR/os_si.h new file mode 100644 index 000000000..23b07c078 --- /dev/null +++ b/include/PR/os_si.h @@ -0,0 +1,86 @@ + +/*==================================================================== + * os_si.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_si.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:18 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_SI_H_ +#define _OS_SI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_SI_H_ */ diff --git a/include/PR/os_system.h b/include/PR/os_system.h new file mode 100644 index 000000000..1179189a2 --- /dev/null +++ b/include/PR/os_system.h @@ -0,0 +1,118 @@ + +/*==================================================================== + * os_system.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_system.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:18 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_SYSTEM_H_ +#define _OS_SYSTEM_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Values for osTvType + */ +#define OS_TV_PAL 0 +#define OS_TV_NTSC 1 +#define OS_TV_MPAL 2 + +/* + * Size of buffer the retains contents after NMI + */ +#define OS_APP_NMI_BUFSIZE 64 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + +extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ +extern void *osRomBase; /* Rom base address of the game image */ +extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ +extern s32 osResetType; /* 0 = cold reset, 1 = NMI */ +extern s32 osCicId; +extern s32 osVersion; +extern u32 osMemSize; /* Memory Size */ +extern s32 osAppNMIBuffer[]; + +extern u64 osClockRate; + +extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +extern void osInitialize(void); +extern void osExit(void); +extern u32 osGetMemSize(void); + +/* pre-NMI */ +extern s32 osAfterPreNMI(void); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_SYSTEM_H_ */ diff --git a/include/PR/os_thread.h b/include/PR/os_thread.h new file mode 100644 index 000000000..246cf9ecd --- /dev/null +++ b/include/PR/os_thread.h @@ -0,0 +1,152 @@ + +/*==================================================================== + * os_thread.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_thread.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:19 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_THREAD_H_ +#define _OS_THREAD_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef s32 OSPri; +typedef s32 OSId; +typedef union +{ + struct { + f32 f_odd2; + f32 f_odd; + f32 f_even2; + f32 f_even; + } f; +} __OSfp; + +typedef struct { + u64 at, v0, v1, a0, a1, a2, a3; + u64 t0, t1, t2, t3, t4, t5, t6, t7; + u64 s0, s1, s2, s3, s4, s5, s6, s7; + u64 t8, t9, gp, sp, s8, ra; + u64 lo, hi; + u32 sr, pc, cause, badvaddr, rcp; + u32 fpcsr; + __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; + __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; +} __OSThreadContext; + +typedef struct OSThread_s { + struct OSThread_s *next; /* run/mesg queue link */ + OSPri priority; /* run/mesg queue priority */ + struct OSThread_s **queue; /* queue thread is on */ + struct OSThread_s *tlnext; /* all threads queue link */ + u16 state; /* OS_STATE_* */ + u16 flags; /* flags for rmon */ + OSId id; /* id for debugging */ + int fp; /* thread has used fp unit */ + __OSThreadContext context; /* register/interrupt mask */ +} OSThread; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* Thread states */ + +#define OS_STATE_STOPPED 1 +#define OS_STATE_RUNNABLE 2 +#define OS_STATE_RUNNING 4 +#define OS_STATE_WAITING 8 + +/* Recommended thread priorities for the system threads */ + +#define OS_PRIORITY_MAX 255 +#define OS_PRIORITY_VIMGR 254 +#define OS_PRIORITY_RMON 250 +#define OS_PRIORITY_RMONSPIN 200 +#define OS_PRIORITY_PIMGR 150 +#define OS_PRIORITY_SIMGR 140 +#define OS_PRIORITY_APPMAX 127 +#define OS_PRIORITY_IDLE 0 /* Must be 0 */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Thread operations */ + +extern void osCreateThread(OSThread *, OSId, void (*)(void *), + void *, void *, OSPri); +extern void osDestroyThread(OSThread *); +extern void osYieldThread(void); +extern void osStartThread(OSThread *); +extern void osStopThread(OSThread *); +extern OSId osGetThreadId(OSThread *); +extern void osSetThreadPri(OSThread *, OSPri); +extern OSPri osGetThreadPri(OSThread *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_THREAD_H_ */ diff --git a/include/PR/os_time.h b/include/PR/os_time.h new file mode 100644 index 000000000..deaec659c --- /dev/null +++ b/include/PR/os_time.h @@ -0,0 +1,114 @@ + +/*==================================================================== + * os_time.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_time.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:19 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_TIME_H_ +#define _OS_TIME_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_message.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure for time value + */ +typedef u64 OSTime; + +/* + * Structure for interval timer + */ +typedef struct OSTimer_s { + struct OSTimer_s *next; /* point to next timer in list */ + struct OSTimer_s *prev; /* point to previous timer in list */ + OSTime interval; /* duration set by user */ + OSTime value; /* time remaining before */ + /* timer fires */ + OSMesgQueue *mq; /* Message Queue */ + OSMesg msg; /* Message to send */ +} OSTimer; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Timer interface */ + +extern OSTime osGetTime(void); +extern void osSetTime(OSTime); +extern int osSetTimer(OSTimer *, OSTime, OSTime, + OSMesgQueue *, OSMesg); +extern int osStopTimer(OSTimer *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_TIME_H_ */ diff --git a/src/include/PR/os_tlb.h b/include/PR/os_tlb.h similarity index 100% rename from src/include/PR/os_tlb.h rename to include/PR/os_tlb.h diff --git a/include/PR/os_version.h b/include/PR/os_version.h new file mode 100644 index 000000000..4f1c3271c --- /dev/null +++ b/include/PR/os_version.h @@ -0,0 +1,16 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_version.h,v $ + $Revision: 1.1 $ + $Date: 1999/01/18 13:17:45 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_VERSION_H_ +#define _OS_VERSION_H_ + +#define OS_MAJOR_VERSION "2.0J" /* major version */ +#define OS_MINOR_VERSION 0 /* patch level */ + +#endif /* !_OS_VERSION_H_ */ diff --git a/include/PR/os_vi.h b/include/PR/os_vi.h new file mode 100644 index 000000000..5a17f2587 --- /dev/null +++ b/include/PR/os_vi.h @@ -0,0 +1,298 @@ + +/*==================================================================== + * os_vi.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. (Originated by SGI) + + $RCSfile: os_vi.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:20 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_VI_H_ +#define _OS_VI_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include "os_thread.h" +#include "os_message.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Structure to store VI register values that remain the same between 2 fields + */ +typedef struct { + u32 ctrl; + u32 width; + u32 burst; + u32 vSync; + u32 hSync; + u32 leap; + u32 hStart; + u32 xScale; + u32 vCurrent; +} OSViCommonRegs; + + +/* + * Structure to store VI register values that change between fields + */ +typedef struct { + u32 origin; + u32 yScale; + u32 vStart; + u32 vBurst; + u32 vIntr; +} OSViFieldRegs; + + +/* + * Structure for VI mode + */ +typedef struct { + u8 type; /* Mode type */ + OSViCommonRegs comRegs; /* Common registers for both fields */ + OSViFieldRegs fldRegs[2]; /* Registers for Field 1 & 2 */ +} OSViMode; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* + * Video Interface (VI) mode type + */ +#define OS_VI_NTSC_LPN1 0 /* NTSC */ +#define OS_VI_NTSC_LPF1 1 +#define OS_VI_NTSC_LAN1 2 +#define OS_VI_NTSC_LAF1 3 +#define OS_VI_NTSC_LPN2 4 +#define OS_VI_NTSC_LPF2 5 +#define OS_VI_NTSC_LAN2 6 +#define OS_VI_NTSC_LAF2 7 +#define OS_VI_NTSC_HPN1 8 +#define OS_VI_NTSC_HPF1 9 +#define OS_VI_NTSC_HAN1 10 +#define OS_VI_NTSC_HAF1 11 +#define OS_VI_NTSC_HPN2 12 +#define OS_VI_NTSC_HPF2 13 + +#define OS_VI_PAL_LPN1 14 /* PAL */ +#define OS_VI_PAL_LPF1 15 +#define OS_VI_PAL_LAN1 16 +#define OS_VI_PAL_LAF1 17 +#define OS_VI_PAL_LPN2 18 +#define OS_VI_PAL_LPF2 19 +#define OS_VI_PAL_LAN2 20 +#define OS_VI_PAL_LAF2 21 +#define OS_VI_PAL_HPN1 22 +#define OS_VI_PAL_HPF1 23 +#define OS_VI_PAL_HAN1 24 +#define OS_VI_PAL_HAF1 25 +#define OS_VI_PAL_HPN2 26 +#define OS_VI_PAL_HPF2 27 + +#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ +#define OS_VI_MPAL_LPF1 29 +#define OS_VI_MPAL_LAN1 30 +#define OS_VI_MPAL_LAF1 31 +#define OS_VI_MPAL_LPN2 32 +#define OS_VI_MPAL_LPF2 33 +#define OS_VI_MPAL_LAN2 34 +#define OS_VI_MPAL_LAF2 35 +#define OS_VI_MPAL_HPN1 36 +#define OS_VI_MPAL_HPF1 37 +#define OS_VI_MPAL_HAN1 38 +#define OS_VI_MPAL_HAF1 39 +#define OS_VI_MPAL_HPN2 40 +#define OS_VI_MPAL_HPF2 41 + +#define OS_VI_FPAL_LPN1 42 /* FPAL - Full screen PAL */ +#define OS_VI_FPAL_LPF1 43 +#define OS_VI_FPAL_LAN1 44 +#define OS_VI_FPAL_LAF1 45 +#define OS_VI_FPAL_LPN2 46 +#define OS_VI_FPAL_LPF2 47 +#define OS_VI_FPAL_LAN2 48 +#define OS_VI_FPAL_LAF2 49 +#define OS_VI_FPAL_HPN1 50 +#define OS_VI_FPAL_HPF1 51 +#define OS_VI_FPAL_HAN1 52 +#define OS_VI_FPAL_HAF1 53 +#define OS_VI_FPAL_HPN2 54 +#define OS_VI_FPAL_HPF2 55 + +/* + * Video Interface (VI) special features + */ +#define OS_VI_GAMMA_ON 0x0001 +#define OS_VI_GAMMA_OFF 0x0002 +#define OS_VI_GAMMA_DITHER_ON 0x0004 +#define OS_VI_GAMMA_DITHER_OFF 0x0008 +#define OS_VI_DIVOT_ON 0x0010 +#define OS_VI_DIVOT_OFF 0x0020 +#define OS_VI_DITHER_FILTER_ON 0x0040 +#define OS_VI_DITHER_FILTER_OFF 0x0080 + +/* + * Video Interface (VI) mode attribute bit + */ +#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ +#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ +#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ +#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ +#define OS_VI_BIT_ANTIALIAS 0x0010 +#define OS_VI_BIT_POINTSAMPLE 0x0020 +#define OS_VI_BIT_16PIXEL 0x0040 +#define OS_VI_BIT_32PIXEL 0x0080 +#define OS_VI_BIT_LORES 0x0100 +#define OS_VI_BIT_HIRES 0x0200 +#define OS_VI_BIT_NTSC 0x0400 +#define OS_VI_BIT_PAL 0x0800 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + +extern OSViMode osViModeTable[]; /* Global VI mode table */ + +extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */ +extern OSViMode osViModeNtscLpf1; +extern OSViMode osViModeNtscLan1; +extern OSViMode osViModeNtscLaf1; +extern OSViMode osViModeNtscLpn2; +extern OSViMode osViModeNtscLpf2; +extern OSViMode osViModeNtscLan2; +extern OSViMode osViModeNtscLaf2; +extern OSViMode osViModeNtscHpn1; +extern OSViMode osViModeNtscHpf1; +extern OSViMode osViModeNtscHan1; +extern OSViMode osViModeNtscHaf1; +extern OSViMode osViModeNtscHpn2; +extern OSViMode osViModeNtscHpf2; + +extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */ +extern OSViMode osViModePalLpf1; +extern OSViMode osViModePalLan1; +extern OSViMode osViModePalLaf1; +extern OSViMode osViModePalLpn2; +extern OSViMode osViModePalLpf2; +extern OSViMode osViModePalLan2; +extern OSViMode osViModePalLaf2; +extern OSViMode osViModePalHpn1; +extern OSViMode osViModePalHpf1; +extern OSViMode osViModePalHan1; +extern OSViMode osViModePalHaf1; +extern OSViMode osViModePalHpn2; +extern OSViMode osViModePalHpf2; + +extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */ +extern OSViMode osViModeMpalLpf1; +extern OSViMode osViModeMpalLan1; +extern OSViMode osViModeMpalLaf1; +extern OSViMode osViModeMpalLpn2; +extern OSViMode osViModeMpalLpf2; +extern OSViMode osViModeMpalLan2; +extern OSViMode osViModeMpalLaf2; +extern OSViMode osViModeMpalHpn1; +extern OSViMode osViModeMpalHpf1; +extern OSViMode osViModeMpalHan1; +extern OSViMode osViModeMpalHaf1; +extern OSViMode osViModeMpalHpn2; +extern OSViMode osViModeMpalHpf2; + +extern OSViMode osViModeFpalLpn1; /* Individual VI FPAL modes */ +extern OSViMode osViModeFpalLpf1; +extern OSViMode osViModeFpalLan1; +extern OSViMode osViModeFpalLaf1; +extern OSViMode osViModeFpalLpn2; +extern OSViMode osViModeFpalLpf2; +extern OSViMode osViModeFpalLan2; +extern OSViMode osViModeFpalLaf2; +extern OSViMode osViModeFpalHpn1; +extern OSViMode osViModeFpalHpf1; +extern OSViMode osViModeFpalHan1; +extern OSViMode osViModeFpalHaf1; +extern OSViMode osViModeFpalHpn2; +extern OSViMode osViModeFpalHpf2; + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Video interface (Vi) */ +extern u32 osViGetStatus(void); +extern u32 osViGetCurrentMode(void); +extern u32 osViGetCurrentLine(void); +extern u32 osViGetCurrentField(void); +extern void *osViGetCurrentFramebuffer(void); +extern void *osViGetNextFramebuffer(void); +extern void osViSetXScale(f32); +extern void osViSetYScale(f32); +extern void osViExtendVStart(u32); +extern void osViSetSpecialFeatures(u32); +extern void osViSetMode(OSViMode *); +extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); +extern void osViSwapBuffer(void *); +extern void osViBlack(u8); +extern void osViFade(u8, u16); +extern void osViRepeatLine(u8); +extern void osCreateViManager(OSPri); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_VI_H_ */ diff --git a/include/PR/os_voice.h b/include/PR/os_voice.h new file mode 100644 index 000000000..5416aa823 --- /dev/null +++ b/include/PR/os_voice.h @@ -0,0 +1,108 @@ + +/*---------------------------------------------------------------------* + Copyright (C) 1998 Nintendo. + + $RCSfile: os_voice.h,v $ + $Revision: 1.1 $ + $Date: 1998/10/09 08:01:21 $ + *---------------------------------------------------------------------*/ + +#ifndef _OS_VOICE_H_ +#define _OS_VOICE_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +typedef struct { /* Voice Recognition System */ + OSMesgQueue *__mq; /* SI Message Queue */ + int __channel; /* Controller Port # */ + s32 __mode; + u8 cmd_status; /* Command Status */ +} OSVoiceHandle; + +typedef struct { /* Voice Recognition System */ + u16 warning; + u16 answer_num; /* 0¡Á5 */ + u16 voice_level; + u16 voice_sn; + u16 voice_time; + u16 answer[5]; + u16 distance[5]; +} OSVoiceData; + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/************************************************************************** + * + * Global definitions + * + */ + +/* definition for Voice Recognition System */ + +#define VOICE_WARN_TOO_SMALL 0x0400 +#define VOICE_WARN_TOO_LARGE 0x0800 +#define VOICE_WARN_NOT_FIT 0x4000 +#define VOICE_WARN_TOO_NOISY 0x8000 + +#define VOICE_STATUS_READY 0 +#define VOICE_STATUS_START 1 +#define VOICE_STATUS_CANCEL 3 +#define VOICE_STATUS_BUSY 5 +#define VOICE_STATUS_END 7 + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* Voice Recognition System */ +extern s32 osVoiceInit(OSMesgQueue *, OSVoiceHandle *, int); +extern s32 osVoiceCheckWord(u8 *data); +extern s32 osVoiceClearDictionary(OSVoiceHandle *, u8); +extern s32 osVoiceControlGain(OSVoiceHandle *, s32, s32); +extern s32 osVoiceSetWord(OSVoiceHandle *, u8 *); +extern s32 osVoiceStartReadData(OSVoiceHandle *); +extern s32 osVoiceStopReadData(OSVoiceHandle *); +extern s32 osVoiceGetReadData(OSVoiceHandle *, OSVoiceData *); +extern s32 osVoiceMaskDictionary(OSVoiceHandle *, u8 *, int); +extern void osVoiceCountSyllables(u8 *, u32 *); + + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_VOICE_H_ */ diff --git a/include/PR/ramrom.h b/include/PR/ramrom.h new file mode 100644 index 000000000..0f2963863 --- /dev/null +++ b/include/PR/ramrom.h @@ -0,0 +1,113 @@ +#ifndef _RAMROM_H +#define _RAMROM_H + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.20 $ + * $Date: 1997/02/11 08:26:47 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ramrom.h,v $ + * + **************************************************************************/ + +/* + * Defines for the GIO card in the Nintendo Development Station + * + * The RAM on the GIO card acts as ROM for the game + * Interrupts available between the game and the Indy host + * + * The last part of the ramrom is used for communication between + * game and host. There are 6 4K buffers defined: + * log, printf, rmon to indy, rmon from indy, app to indy, app from indy + * The last 8 bytes of the buffer are used in the emulator environment + */ + +#define RAMROM_SIZE (0x1000000) + +#define RAMROM_BUF_SIZE (4096) +#define RAMROM_MSG_SIZE (RAMROM_BUF_SIZE*6) +#define RAMROM_MSG_ADDR (RAMROM_SIZE - RAMROM_MSG_SIZE) +#define RAMROM_MSG_HDR_SIZE (3*sizeof(long)) +#define RAMROM_USER_DATA_SIZE (RAMROM_MSG_SIZE-RAMROM_MSG_HDR_SIZE) + +#define RAMROM_APP_READ_ADDR (RAMROM_MSG_ADDR + (0*RAMROM_BUF_SIZE)) +#define RAMROM_APP_WRITE_ADDR (RAMROM_MSG_ADDR + (1*RAMROM_BUF_SIZE)) +#define RAMROM_RMON_READ_ADDR (RAMROM_MSG_ADDR + (2*RAMROM_BUF_SIZE)) +#define RAMROM_RMON_WRITE_ADDR (RAMROM_MSG_ADDR + (3*RAMROM_BUF_SIZE)) +#define RAMROM_PRINTF_ADDR (RAMROM_MSG_ADDR + (4*RAMROM_BUF_SIZE)) +#define RAMROM_LOG_ADDR (RAMROM_MSG_ADDR + (5*RAMROM_BUF_SIZE)) + +/*#define RAMROM_GIO_INTERRUPT (RAMROM_MSG_ADDR + RAMROM_MSG_SIZE - 4)*/ + +/* + * For the initial round of PIF bringup, we will load in a bootstrap loader + * 0x400 bytes into the ramrom, and the rom will be loaded at 0x2000 + */ +#ifndef _HW_VERSION_1 +#define RAMROM_BOOTSTRAP_OFFSET 0x40 +#define RAMROM_GAME_OFFSET 0x1000 +#define RAMROM_FONTDATA_OFFSET 0xb70 +#define RAMROM_FONTDATA_SIZE 1152 +#else +#define RAMROM_BOOTSTRAP_OFFSET 0x400 +#define RAMROM_GAME_OFFSET 0x2000 +#endif +#define RAMROM_CLOCKRATE_OFFSET 0x4 +#define RAMROM_CLOCKRATE_MASK 0xfffffff0 +#define RAMROM_BOOTADDR_OFFSET 0x8 +#define RAMROM_RELEASE_OFFSET 0xc +/* + * Second version of the PIF jumps to location 0x1000, and we'll put a jump to + * location 0x400 into the ramrom (for backwards compatibility). + */ +#define RAMROM_PIF2BOOTSTRAP_OFFSET 0x1000 + +typedef struct { + long type; + long length; /* in bytes of userdata */ + long magic; + char userdata[RAMROM_USER_DATA_SIZE]; +} RamRomBuffer; + +/* + * Interrupt values (must fit in 6 bits!) + * values are used for both request & response + * Transactions initiated by the host start with HOST + * and those initiated by the target start with GAME. + */ + +#define HOST_PIACCESS_REQ 1 +#define HOST_DBG_CMD_READY 2 +#define GAME_DBG_DATA_SEND 3 +#define HOST_DBG_DATA_ACK 4 +#define GAME_PRINTF_SEND 5 +#define HOST_PRINTF_ACK 6 +#define GAME_LOG_SEND 7 +#define HOST_LOG_ACK 8 +#define HOST_APP_CMD_READY 9 +#define GAME_APP_DATA_READY 10 +#define HOST_PROF_REQ 11 +#define GAME_PROF_SEND 12 +#define HOST_PROF_ACK 13 +#define GAME_FAULT_SEND 14 +#define HOST_FAULT_ACK 15 +#define GAME_EXIT 16 +#define HOST_DATA_ACK 17 + +#ifdef _EMULATOR +void __RamRomInit(int key, void *romaddr); +void __RamRomDestroy(int key); +#endif /* _EMULATOR */ + +#endif /* !_RAMROM_H */ diff --git a/src/include/PR/rcp.h b/include/PR/rcp.h old mode 100755 new mode 100644 similarity index 99% rename from src/include/PR/rcp.h rename to include/PR/rcp.h index 3795ff72a..2099e1094 --- a/src/include/PR/rcp.h +++ b/include/PR/rcp.h @@ -18,9 +18,9 @@ * File: rcp.h * * This file contains register and bit definitions for RCP memory map. - * $Revision: 1.20 $ - * $Date: 1997/07/23 08:35:21 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $ + * $Revision: 1.21 $ + * $Date: 1998/07/31 11:08:29 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rcp.h,v $ * **************************************************************************/ @@ -161,6 +161,8 @@ The Indy development board use cartridge domain 1: #define DEVICE_TYPE_BULK 1 /* ROM bulk */ #define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */ #define DEVICE_TYPE_SRAM 3 /* SRAM */ +/* 4-6 are reserved */ +#define DEVICE_TYPE_INIT 7 /* initial value */ /************************************************************************* * SP Memory diff --git a/include/PR/rdb.h b/include/PR/rdb.h new file mode 100644 index 000000000..78d7b20e0 --- /dev/null +++ b/include/PR/rdb.h @@ -0,0 +1,93 @@ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:29:31 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rdb.h,v $ + * + **************************************************************************/ + +#ifndef _RDB_H +#define _RDB_H + +/* U64 side address */ +#define RDB_BASE_REG 0xc0000000 +#define RDB_WRITE_INTR_REG (RDB_BASE_REG + 0x8) +#define RDB_READ_INTR_REG (RDB_BASE_REG + 0xc) +#define RDB_BASE_VIRTUAL_ADDR 0x80000000 + +/* packet type Have six bits, so can have up to 63 types */ +#define RDB_TYPE_INVALID 0 +#define RDB_TYPE_GtoH_PRINT 1 +#define RDB_TYPE_GtoH_FAULT 2 +#define RDB_TYPE_GtoH_LOG_CT 3 +#define RDB_TYPE_GtoH_LOG 4 +#define RDB_TYPE_GtoH_READY_FOR_DATA 5 +#define RDB_TYPE_GtoH_DATA_CT 6 +#define RDB_TYPE_GtoH_DATA 7 +#define RDB_TYPE_GtoH_DEBUG 8 +#define RDB_TYPE_GtoH_RAMROM 9 +#define RDB_TYPE_GtoH_DEBUG_DONE 10 +#define RDB_TYPE_GtoH_DEBUG_READY 11 +#define RDB_TYPE_GtoH_KDEBUG 12 +#define RDB_TYPE_GtoH_PROF_DATA 22 + + +#define RDB_TYPE_HtoG_LOG_DONE 13 +#define RDB_TYPE_HtoG_DEBUG 14 +#define RDB_TYPE_HtoG_DEBUG_CT 15 +#define RDB_TYPE_HtoG_DATA 16 +#define RDB_TYPE_HtoG_DATA_DONE 17 +#define RDB_TYPE_HtoG_REQ_RAMROM 18 +#define RDB_TYPE_HtoG_FREE_RAMROM 19 +#define RDB_TYPE_HtoG_KDEBUG 20 +#define RDB_TYPE_HtoG_PROF_SIGNAL 21 + + +#define RDB_PROF_ACK_SIG 1 +#define RDB_PROF_FLUSH_SIG 2 +#define PROF_BLOCK_SIZE 2048 + +#define RDB_LOG_MAX_BLOCK_SIZE 0x8000 +#define RDB_DATA_MAX_BLOCK_SIZE 0x8000 + + +/* GIO side address */ +#define GIO_RDB_BASE_REG 0xbf480000 +#define GIO_RDB_WRITE_INTR_REG (GIO_RDB_BASE_REG + 0x8) +#define GIO_RDB_READ_INTR_REG (GIO_RDB_BASE_REG + 0xc) + +/* minor device number */ +#define GIO_RDB_PRINT_MINOR 1 +#define GIO_RDB_DEBUG_MINOR 2 + +/* interrupt bit */ +#define GIO_RDB_WRITE_INTR_BIT 0x80000000 +#define GIO_RDB_READ_INTR_BIT 0x40000000 + +/* debug command */ +#define DEBUG_COMMAND_NULL 0 +#define DEBUG_COMMAND_MEMORY 1 +#define DEBUG_COMMAND_REGISTER 2 +#define DEBUG_COMMAND_INVALID 255 + +/* debug state */ +#define DEBUG_STATE_NULL 0 +#define DEBUG_STATE_RECEIVE 1 +#define DEBUG_STATE_INVALID 255 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* Structure for debug port */ +typedef struct { + unsigned type : 6; /* 0: invalid, 1: print, 2: debug */ + unsigned length : 2; /* 1, 2, or 3 */ + char buf[3]; /* character buffer */ +} rdbPacket; + +extern unsigned int __osRdbWriteOK; +extern unsigned int __osRdbSendMessage; + +#endif /* _LANGUAGE_C */ + +#endif /* !_RDB_H */ diff --git a/include/PR/region.h b/include/PR/region.h new file mode 100644 index 000000000..574e0b6a1 --- /dev/null +++ b/include/PR/region.h @@ -0,0 +1,123 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * Module: region.h + * + * $Revision: 1.8 $ + * $Date: 1997/11/26 00:30:56 $ + * $Author: mitu $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/region.h,v $ + * + * Description: + * This file contains macros and structure definitions for the region + * library. + * + **************************************************************************/ + + +#ifndef _REGION_H_ +#define _REGION_H_ + + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + + +/*************************************** + * + * Global defines + * + */ + /* Alignment sizes */ +#define ALIGNSZ (sizeof(long long)) /* 8 bytes */ +#define ALIGNOFFST (ALIGNSZ-1) + + /* size for storing index to free buffer */ +#define BUF_CTRL_SIZE ALIGNSZ + + /* Max bufcount = 32K */ +#define MAX_BUFCOUNT 0x8000 + /* code for last free buffer */ +#define BUF_FREE_WO_NEXT 0x8000 + +/* + * Global defines for alignment size (default is 8-byte alignment) + */ +#define OS_RG_ALIGN_2B 2 /* 2 bytes = 16-bit alignment */ +#define OS_RG_ALIGN_4B 4 /* 4 bytes = 32-bit alignment */ +#define OS_RG_ALIGN_8B 8 /* 8 bytes = 64-bit alignment */ +#define OS_RG_ALIGN_16B 16 /* 16 bytes = 128-bit alignment */ + +#define OS_RG_ALIGN_DEFAULT OS_RG_ALIGN_8B + + +/*************************************** + * + * Macro definitions + * + */ + +/* Perform alignment on input 's' */ +#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1)) + + +/*************************************** + * + * Typedefs & structure definitions + * + */ +/* + * Structure for region header/control area + */ +typedef struct _Region_s { + u8 *r_startBufferAddress; /* start address to data buffer */ + u8 *r_endAddress; /* end address of region */ + s32 r_bufferSize; /* size of buffers for this region */ + s32 r_bufferCount; /* up to 32K entries; MSB is used for + setting end-of-list/used */ + u16 r_freeList; /* point to array index of first + available memory buffer */ + u16 r_alignSize; /* alignment size (# of bytes) */ +} OSRegion; + +/* + * Macro to simplify accessing region header structure + */ +#define RP(x) rp->r_##x + + +/*************************************** + * + * Function prototypes + * + */ +extern void *osCreateRegion(void *, u32, u32, u32); +extern void *osMalloc(void *); +extern void osFree(void *, void *); +extern s32 osGetRegionBufCount(void *); +extern s32 osGetRegionBufSize(void *); + + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + + +#endif /* _REGION_H_ */ + + diff --git a/include/PR/rmon.h b/include/PR/rmon.h new file mode 100644 index 000000000..93873f227 --- /dev/null +++ b/include/PR/rmon.h @@ -0,0 +1,39 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:30:08 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/rmon.h,v $ + * + **************************************************************************/ + +#ifndef _RMON_H_ +#define _RMON_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#define RMON_DBG_BUF_SIZE 2048 +#define RMON_STACKSIZE 0x1000 + +extern void rmonMain( void * ); +extern void rmonPrintf( const char *, ... ); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_OS_H */ diff --git a/src/include/PR/sched.h b/include/PR/sched.h similarity index 59% rename from src/include/PR/sched.h rename to include/PR/sched.h index b29fe17c8..a3e5c8182 100644 --- a/src/include/PR/sched.h +++ b/include/PR/sched.h @@ -1,5 +1,36 @@ -#ifndef _ULTRA64_SCHED_H_ -#define _ULTRA64_SCHED_H_ +/*==================================================================== + * sched.h + * + * Synopsis: + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.7 $ + * $Date: 1997/02/11 08:32:02 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sched.h,v $ + * + **************************************************************************/ + +#ifndef __sched__ +#define __sched__ + #include #define OS_SC_STACKSIZE 0x2000 @@ -39,30 +70,6 @@ typedef struct OSScTask_s { #define OS_SC_RCP_MASK 0x0003 /* mask for needs bits */ #define OS_SC_TYPE_MASK 0x0007 /* complete type mask */ - -#define OS_SC_DP 0x0001 /* set if still needs dp */ -#define OS_SC_SP 0x0002 /* set if still needs sp */ -#define OS_SC_YIELD 0x0010 /* set if yield requested */ -#define OS_SC_YIELDED 0x0020 /* set if yield completed */ - -/* - * OSScTask->flags type identifier - */ -#define OS_SC_XBUS (OS_SC_SP | OS_SC_DP) -#define OS_SC_DRAM (OS_SC_SP | OS_SC_DP | OS_SC_DRAM_DLIST) -#define OS_SC_DP_XBUS (OS_SC_SP) -#define OS_SC_DP_DRAM (OS_SC_SP | OS_SC_DRAM_DLIST) -#define OS_SC_SP_XBUS (OS_SC_DP) -#define OS_SC_SP_DRAM (OS_SC_DP | OS_SC_DRAM_DLIST) - -/* - * private typedefs and defines - */ -#define VIDEO_MSG 666 -#define RSP_DONE_MSG 667 -#define RDP_DONE_MSG 668 -#define PRE_NMI_MSG 669 - /* * OSScClient: * @@ -73,6 +80,7 @@ typedef struct OSScTask_s { typedef struct SCClient_s { struct SCClient_s *next; /* next client in the list */ OSMesgQueue *msgQ; /* where to send the frame msg */ + s32 is8mb; } OSScClient; typedef struct { @@ -94,8 +102,8 @@ typedef struct { s32 doAudio; } OSSched; -void osCreateScheduler(OSSched *s, void *stack, u8 mode, u32 numFields); -void osScAddClient(OSSched *sc, OSScClient *c, OSMesgQueue *msgQ, OSScClient *next); +void osCreateScheduler(OSSched *s, OSThread *thread, u8 mode, u32 numFields); +void osScAddClient(OSSched *s, OSScClient *c, OSMesgQueue *msgQ, int is8mb); void osScRemoveClient(OSSched *s, OSScClient *c); OSMesgQueue *osScGetCmdQ(OSSched *s); diff --git a/include/PR/sp.h b/include/PR/sp.h new file mode 100644 index 000000000..c2ef5f7f4 --- /dev/null +++ b/include/PR/sp.h @@ -0,0 +1,196 @@ +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * Sprite library include file + * + * $Revision: 1.16 $ + * $Date: 1998/04/17 05:03:46 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sp.h,v $ + * + **************************************************************************/ + +#ifndef _SP_H_ +#define _SP_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include +#include + +struct bitmap { + s16 width; /* Size across to draw in texels */ + /* Done if width = 0 */ + + s16 width_img; /* Size across of bitmap in texels */ + /* Done if width = 0 */ + + s16 s; /* Horizontal offset into bitmap */ + /* if (s > width), then load only! */ + + s16 t; /* Vertical offset into base */ + + void *buf; /* Pointer to bitmap data */ + /* Don't re-load if new buf */ + /* is the same as the old one */ + /* Skip if NULL */ + + s16 actualHeight; /* True Height of this bitmap piece */ + + s16 LUToffset; /* LUT base index */ +}; + +typedef struct bitmap Bitmap; + +struct sprite { + s16 x,y; /* Target position */ + + s16 width, height; /* Target size */ + + f32 scalex, scaley; /* Texel to Pixel scale factor */ + + s16 expx, expy; /* Explosion spacing */ + + u16 attr; /* Attribute Flags */ + s16 zdepth; /* Z Depth */ + + u8 red; /* Red component */ + u8 green; /* Green component */ + u8 blue; /* Blue component */ + u8 alpha; /* Alpha component */ + + s16 startTLUT; /* Lookup Table Entry Starting index */ + s16 nTLUT; /* Total number of Lookup Table Entries */ + + int *LUT; /* Pointer to Lookup Table */ + + s16 istart; /* Starting bitmap index */ + s16 istep; /* Bitmaps index step (see SP_INCY) */ + /* if 0, then variable width bitmaps */ + + s16 nbitmaps; /* Total number of bitmaps */ + s16 ndisplist; /* Total number of display-list words */ + + s16 bmheight; /* Bitmap Texel height (Used) */ + s16 bmHreal; /* Bitmap Texel height (Real) */ + u8 bmfmt; /* Bitmap Format */ + u8 bmsiz; /* Bitmap Texel Size */ + + Bitmap *bitmap; /* Pointer to first bitmap */ + + Gfx *rsp_dl; /* Pointer to RSP display list */ + + Gfx *rsp_dl_next; /* Pointer to next RSP display entry */ + + s16 frac_s, /* Fractional Texture offsets */ + frac_t; /* These have 5 fraction bits */ +}; + +typedef struct sprite Sprite; + +/* + * DANGER! + * This is bad programming. Where the *heck* do these numbers come + * from? + * + * They are obviously 'maximums' from the sprite library, but since + * the sprite library is built on top of gbi.h, which includes macros + * that decode into multiple macros, etc., it is nearly impossible to + * know what these maximums should be. + * + * Worse, there are some gbi macros (texture alignment mostly) that + * decode into *many* macros, so if we choose that as a maximum, we + * are wasting TONS of space... + * + * These numbers work for "reasonable" sprite library usage, and + * there is an assert() in the library to detect when they aren't + * enough. (use the debug version) + */ +#define DL_BM_OVERHEAD (12) +#define DL_SPRITE_OVERHEAD (24) + +#define NUM_DL(nb) ((nb)*DL_BM_OVERHEAD +DL_SPRITE_OVERHEAD) + +/* + * Misc constants + */ + +#ifndef NULL +#define NULL 0 +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +/* + * For sprite->attr + */ + +#define SP_TRANSPARENT 0x00000001 +#define SP_CUTOUT 0x00000002 +#define SP_HIDDEN 0x00000004 +#define SP_Z 0x00000008 +#define SP_SCALE 0x00000010 +#define SP_FASTCOPY 0x00000020 +#define SP_OVERLAP 0x00000040 +#define SP_TEXSHIFT 0x00000080 +#define SP_FRACPOS 0x00000100 +#define SP_TEXSHUF 0x00000200 +#define SP_EXTERN 0x00000400 + +/* + * Function wrapper + */ +#if defined(F3DEX_GBI_2) +#define spMove spX2Move +#define spSetZ spX2SetZ +#define spScissor spX2Scissor +#define spDraw spX2Draw +#define spInit spX2Init +#define spFinish spX2Finish +#elif defined(F3DEX_GBI) +#define spMove spXMove +#define spSetZ spXSetZ +#define spScissor spXScissor +#define spDraw spXDraw +#define spInit spXInit +#define spFinish spXFinish +#endif + +/* + * Function prototypes + */ + +void spSetAttribute (Sprite *sp, s32 attr); +void spClearAttribute (Sprite *sp, s32 attr); +void spMove (Sprite *sp, s32 x, s32 y); +void spScale (Sprite *sp, f32 sx, f32 sy); +void spSetZ (Sprite *sp, s32 z ); +void spColor (Sprite *sp, u8 red, u8 green, u8 blue, u8 alpha); +Gfx *spDraw (Sprite *sp); +void spInit( Gfx **glistp ); +void spScissor( s32 xmin, s32 xmax, s32 ymin, s32 ymax ); +void spFinish( Gfx **glistp ); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* _SP_H_ */ diff --git a/include/PR/sptask.h b/include/PR/sptask.h new file mode 100644 index 000000000..81c9a9fb7 --- /dev/null +++ b/include/PR/sptask.h @@ -0,0 +1,202 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.9 $ + * $Date: 1998/03/05 06:40:29 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/sptask.h,v $ + * + **************************************************************************/ + +#ifndef _SPTASK_H_ +#define _SPTASK_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Type definitions + * + */ + +/* + * Task List Structure. + * + * Things an app might pass to the SP via the task list. + * Not every task ucode would need/use every field, but + * + * - type (audio, gfx, video, ...) + * - flags + * - wait for DP to drain before running new task + * - SEE BIT DEFINITIONS UNDER "Task Flags field" + * - pointer to boot ucode + * - size of boot ucode + * - pointer to ucode + * - size of ucode + * - pointer to initial DMEM data + * - size of initial DMEM data + * - pointer to DRAM stack + * - size of DRAM stack (max) + * - pointer to output buffer + * - pointer to store output buffer length + * - generic data pointer (for display list, etc.) + * - generic data length (for display list, etc.) + * - pointer to buffer where to store saved DMEM (in yield case) + * - size of buffer to store saved DMEM. + * + * IMPORTANT!!! Watch alignment issues. + * + * IMPORTANT!!! Watch data cache issues. The RCP may write data into the + * dram_stack, output_buff, output_buff_size, and the yield_data_ptr areas. + * These buffers should be cache aligned and use the entire line (16 bytes) to + * avoid corruption by writebacks by the CPU (cache tearing). + * + * IMPORTANT!!! all addresses are virtual addresses. Library does + * any necessary translation. + * + */ +typedef struct { + u32 type; + u32 flags; + + u64 *ucode_boot; + u32 ucode_boot_size; + + u64 *ucode; + u32 ucode_size; + + u64 *ucode_data; + u32 ucode_data_size; + + u64 *dram_stack; + u32 dram_stack_size; + + u64 *output_buff; + u64 *output_buff_size; + + u64 *data_ptr; + u32 data_size; + + u64 *yield_data_ptr; + u32 yield_data_size; + +} OSTask_t; + +typedef union { + OSTask_t t; + long long int force_structure_alignment; +} OSTask; + +typedef u32 OSYieldResult; + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_ASSEMBLY + +/* + * For the RSP ucode: + * offsets into the task structure + */ + +#include + +#endif + +/* + * Task Flags field + */ +#define OS_TASK_YIELDED 0x0001 +#define OS_TASK_DP_WAIT 0x0002 +#define OS_TASK_LOADABLE 0x0004 +#define OS_TASK_SP_ONLY 0x0008 +#define OS_TASK_USR0 0x0010 +#define OS_TASK_USR1 0x0020 +#define OS_TASK_USR2 0x0040 +#define OS_TASK_USR3 0x0080 + +/* + * Size of Yield buffer. The taskHdrPtr->t.yield_data_ptr must point to a + * buffer of this size. (The size is in bytes). ONLY If the task will NEVER + * yield it may be a null pointer. The buffer must be aligned to a 64 bit + * boundary. The taskHdrPtr->t.yield_data_ptr must be set to point to the + * buffer BEFORE the task is started. + */ +// @todo: Remove this || 1 hack +#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)||defined(F3DEX_GBI_2) || 1) +#define OS_YIELD_DATA_SIZE 0xc00 +#else +#define OS_YIELD_DATA_SIZE 0x900 +#endif +#define OS_YIELD_AUDIO_SIZE 0x400 + +/************************************************************************** + * + * Global definitions + * + */ + + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* + * this macro simulates atomic action. + */ +#define osSpTaskStart(tp) \ + { \ + osSpTaskLoad((tp)); \ + osSpTaskStartGo((tp)); \ + } + + +/************************************************************************** + * + * Extern variables + * + */ + + +/************************************************************************** + * + * Function prototypes + * + */ + +/* + * break this up into two steps for debugging. + */ +extern void osSpTaskLoad(OSTask *tp); +extern void osSpTaskStartGo(OSTask *tp); + +extern void osSpTaskYield(void); +extern OSYieldResult osSpTaskYielded(OSTask *tp); + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_SPTASK_H */ diff --git a/include/PR/ucode.h b/include/PR/ucode.h new file mode 100644 index 000000000..735f91495 --- /dev/null +++ b/include/PR/ucode.h @@ -0,0 +1,192 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.15 $ + * $Date: 1998/03/31 07:58:57 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ucode.h,v $ + * + **************************************************************************/ + +#ifndef _UCODE_H_ +#define _UCODE_H_ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/************************************************************************** + * + * Macro definitions + * + */ + +/* + * This is the recommended size of the SP DRAM stack area, used + * by the graphics ucode. This stack is used primarily for the + * matrix stack, so it needs to be AT LEAST (10 * 64bytes) in size. + */ +#define SP_DRAM_STACK_SIZE8 (1024) +#define SP_DRAM_STACK_SIZE64 (SP_DRAM_STACK_SIZE8 >> 3) + +/* + * This is the size of the IMEM, which is also the size of the + * graphics microcode. (other ucode might be less) + * This value is used in apps to tell the OS how much ucode to + * load. + */ +#define SP_UCODE_SIZE 4096 + +/* + * This is 1/2 the size of DMEM, which is the maximum amount of + * initialized DMEM data any of the ucode tasks need to start up. + * This value is dependent on all of the task ucodes, and is therefore + * fixed per release. + */ +#define SP_UCODE_DATA_SIZE 2048 + + +/************************************************************************** + * + * Extern variables + * + */ + +/* + * Symbols generated by "rsp2elf", included by "makerom" that indicate + * the location and size of the SP microcode objects. The ucode objects + * are loaded as part of the codesegment (arbitrary, could do other + * ways) + * + */ + +/* standard boot ucode: */ +extern long long int rspbootTextStart[], rspbootTextEnd[]; + +/* standard 3D ucode: */ +extern long long int gspFast3DTextStart[], gspFast3DTextEnd[]; +extern long long int gspFast3DDataStart[], gspFast3DDataEnd[]; + +/* 3D ucode with output to DRAM: */ +extern long long int gspFast3D_dramTextStart[], gspFast3D_dramTextEnd[]; +extern long long int gspFast3D_dramDataStart[], gspFast3D_dramDataEnd[]; + +/* 3D ucode with output through DRAM FIFO to RDP: */ +extern long long int gspFast3D_fifoTextStart[], gspFast3D_fifoTextEnd[]; +extern long long int gspFast3D_fifoDataStart[], gspFast3D_fifoDataEnd[]; + +/* 3D ucode without nearclip: */ +extern long long int gspF3DNoNTextStart[], gspF3DNoNTextEnd[]; +extern long long int gspF3DNoNDataStart[], gspF3DNoNDataEnd[]; + +/* 3D ucode without nearclip with output to DRAM: */ +extern long long int gspF3DNoN_dramTextStart[]; +extern long long int gspF3DNoN_dramTextEnd[]; +extern long long int gspF3DNoN_dramDataStart[]; +extern long long int gspF3DNoN_dramDataEnd[]; + +/* 3D ucode without nearclip with output through DRAM FIFO to RDP: */ +extern long long int gspF3DNoN_fifoTextStart[]; +extern long long int gspF3DNoN_fifoTextEnd[]; +extern long long int gspF3DNoN_fifoDataStart[]; +extern long long int gspF3DNoN_fifoDataEnd[]; + +/* 3D line ucode: */ +extern long long int gspLine3DTextStart[], gspLine3DTextEnd[]; +extern long long int gspLine3DDataStart[], gspLine3DDataEnd[]; + +/* 3D line ucode with output to DRAM: */ +extern long long int gspLine3D_dramTextStart[], gspLine3D_dramTextEnd[]; +extern long long int gspLine3D_dramDataStart[], gspLine3D_dramDataEnd[]; + +/* 3D line ucode with output through DRAM FIFO to RDP: */ +extern long long int gspLine3D_fifoTextStart[], gspLine3D_fifoTextEnd[]; +extern long long int gspLine3D_fifoDataStart[], gspLine3D_fifoDataEnd[]; + +/* 2D sprite ucode: */ +extern long long int gspSprite2DTextStart[], gspSprite2DTextEnd[]; +extern long long int gspSprite2DDataStart[], gspSprite2DDataEnd[]; + +/* 2D sprite ucode with output to DRAM: */ +extern long long int gspSprite2D_dramTextStart[], gspSprite2D_dramTextEnd[]; +extern long long int gspSprite2D_dramDataStart[], gspSprite2D_dramDataEnd[]; + +/* 2D sprite ucode with output through DRAM FIFO to RDP: */ +extern long long int gspSprite2D_fifoTextStart[], gspSprite2D_fifoTextEnd[]; +extern long long int gspSprite2D_fifoDataStart[], gspSprite2D_fifoDataEnd[]; + +/* basic audio ucode: */ +extern long long int aspMainTextStart[], aspMainTextEnd[]; +extern long long int aspMainDataStart[], aspMainDataEnd[]; + +/*========== F3DEX/F3DLX/F3DLP/L3DEX ==========*/ +/* FIFO version only */ +extern long long int gspF3DEX_fifoTextStart[], gspF3DEX_fifoTextEnd[]; +extern long long int gspF3DEX_fifoDataStart[], gspF3DEX_fifoDataEnd[]; +extern long long int gspF3DEX_NoN_fifoTextStart[], gspF3DEX_NoN_fifoTextEnd[]; +extern long long int gspF3DEX_NoN_fifoDataStart[], gspF3DEX_NoN_fifoDataEnd[]; + +extern long long int gspF3DLX_fifoTextStart[], gspF3DLX_fifoTextEnd[]; +extern long long int gspF3DLX_fifoDataStart[], gspF3DLX_fifoDataEnd[]; +extern long long int gspF3DLX_NoN_fifoTextStart[], gspF3DLX_NoN_fifoTextEnd[]; +extern long long int gspF3DLX_NoN_fifoDataStart[], gspF3DLX_NoN_fifoDataEnd[]; +extern long long int gspF3DLX_Rej_fifoTextStart[], gspF3DLX_Rej_fifoTextEnd[]; +extern long long int gspF3DLX_Rej_fifoDataStart[], gspF3DLX_Rej_fifoDataEnd[]; + +extern long long int gspF3DLP_Rej_fifoTextStart[], gspF3DLP_Rej_fifoTextEnd[]; +extern long long int gspF3DLP_Rej_fifoDataStart[], gspF3DLP_Rej_fifoDataEnd[]; +extern long long int gspL3DEX_fifoTextStart[], gspL3DEX_fifoTextEnd[]; +extern long long int gspL3DEX_fifoDataStart[], gspL3DEX_fifoDataEnd[]; + +/*========== F3DEX2/F3DLX2/F3DLP2/L3DEX2 ==========*/ +/* FIFO version */ +extern long long int gspF3DEX2_fifoTextStart[], gspF3DEX2_fifoTextEnd[]; +extern long long int gspF3DEX2_fifoDataStart[], gspF3DEX2_fifoDataEnd[]; +extern long long int gspF3DEX2_NoN_fifoTextStart[],gspF3DEX2_NoN_fifoTextEnd[]; +extern long long int gspF3DEX2_NoN_fifoDataStart[],gspF3DEX2_NoN_fifoDataEnd[]; +extern long long int gspF3DEX2_Rej_fifoTextStart[],gspF3DEX2_Rej_fifoTextEnd[]; +extern long long int gspF3DEX2_Rej_fifoDataStart[],gspF3DEX2_Rej_fifoDataEnd[]; +extern long long int gspF3DLX2_Rej_fifoTextStart[],gspF3DLX2_Rej_fifoTextEnd[]; +extern long long int gspF3DLX2_Rej_fifoDataStart[],gspF3DLX2_Rej_fifoDataEnd[]; +extern long long int gspL3DEX2_fifoTextStart[], gspL3DEX2_fifoTextEnd[]; +extern long long int gspL3DEX2_fifoDataStart[], gspL3DEX2_fifoDataEnd[]; + +/* XBUS version */ +extern long long int gspF3DEX2_xbusTextStart[], gspF3DEX2_xbusTextEnd[]; +extern long long int gspF3DEX2_xbusDataStart[], gspF3DEX2_xbusDataEnd[]; +extern long long int gspF3DEX2_NoN_xbusTextStart[],gspF3DEX2_NoN_xbusTextEnd[]; +extern long long int gspF3DEX2_NoN_xbusDataStart[],gspF3DEX2_NoN_xbusDataEnd[]; +extern long long int gspF3DEX2_Rej_xbusTextStart[],gspF3DEX2_Rej_xbusTextEnd[]; +extern long long int gspF3DEX2_Rej_xbusDataStart[],gspF3DEX2_Rej_xbusDataEnd[]; +extern long long int gspF3DLX2_Rej_xbusTextStart[],gspF3DLX2_Rej_xbusTextEnd[]; +extern long long int gspF3DLX2_Rej_xbusDataStart[],gspF3DLX2_Rej_xbusDataEnd[]; +extern long long int gspL3DEX2_xbusTextStart[], gspL3DEX2_xbusTextEnd[]; +extern long long int gspL3DEX2_xbusDataStart[], gspL3DEX2_xbusDataEnd[]; + +/************************************************************************** + * + * Function prototypes + * + */ + +#endif /* _LANGUAGE_C */ + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* !_UCODE_H */ diff --git a/include/PR/ucode_debug.h b/include/PR/ucode_debug.h new file mode 100644 index 000000000..189a7f218 --- /dev/null +++ b/include/PR/ucode_debug.h @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------* + Copyright (C) 1998, Nintendo. + + File ucode_debug.h + Coded by Yoshitaka Yasumoto. Nov 15, 1998. + + $Id: ucode_debug.h,v 1.1 1998/12/25 01:06:21 has Exp $ + *---------------------------------------------------------------------*/ +#ifndef _UCODE_DEBUG_H_ +#define _UCODE_DEBUG_H_ + +#define DEBUG_DL_PTR() IO_READ(SP_DMEM_START+0xfc0) + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +/*========== F3DEX2/F3DLX2/L3DEX2/S2DEX2 ==========*/ +/* FIFO version */ +extern long long int gspF3DEX2d_fifoTextStart[], gspF3DEX2d_fifoTextEnd[]; +extern long long int gspF3DEX2d_fifoDataStart[], gspF3DEX2d_fifoDataEnd[]; +extern long long int gspF3DEX2d_NoN_fifoTextStart[],gspF3DEX2d_NoN_fifoTextEnd[]; +extern long long int gspF3DEX2d_NoN_fifoDataStart[],gspF3DEX2d_NoN_fifoDataEnd[]; +extern long long int gspF3DEX2d_Rej_fifoTextStart[],gspF3DEX2d_Rej_fifoTextEnd[]; +extern long long int gspF3DEX2d_Rej_fifoDataStart[],gspF3DEX2d_Rej_fifoDataEnd[]; +extern long long int gspF3DLX2d_Rej_fifoTextStart[],gspF3DLX2d_Rej_fifoTextEnd[]; +extern long long int gspF3DLX2d_Rej_fifoDataStart[],gspF3DLX2d_Rej_fifoDataEnd[]; +extern long long int gspL3DEX2d_fifoTextStart[], gspL3DEX2d_fifoTextEnd[]; +extern long long int gspL3DEX2d_fifoDataStart[], gspL3DEX2d_fifoDataEnd[]; +extern long long int gspS2DEX2d_fifoTextStart[], gspS2DEX2d_fifoTextEnd[]; +extern long long int gspS2DEX2d_fifoDataStart[], gspS2DEX2d_fifoDataEnd[]; + +/* XBUS version */ +extern long long int gspF3DEX2d_xbusTextStart[], gspF3DEX2d_xbusTextEnd[]; +extern long long int gspF3DEX2d_xbusDataStart[], gspF3DEX2d_xbusDataEnd[]; +extern long long int gspF3DEX2d_NoN_xbusTextStart[],gspF3DEX2d_NoN_xbusTextEnd[]; +extern long long int gspF3DEX2d_NoN_xbusDataStart[],gspF3DEX2d_NoN_xbusDataEnd[]; +extern long long int gspF3DEX2d_Rej_xbusTextStart[],gspF3DEX2d_Rej_xbusTextEnd[]; +extern long long int gspF3DEX2d_Rej_xbusDataStart[],gspF3DEX2d_Rej_xbusDataEnd[]; +extern long long int gspF3DLX2d_Rej_xbusTextStart[],gspF3DLX2d_Rej_xbusTextEnd[]; +extern long long int gspF3DLX2d_Rej_xbusDataStart[],gspF3DLX2d_Rej_xbusDataEnd[]; +extern long long int gspL3DEX2d_xbusTextStart[], gspL3DEX2d_xbusTextEnd[]; +extern long long int gspL3DEX2d_xbusDataStart[], gspL3DEX2d_xbusDataEnd[]; +extern long long int gspS2DEX2d_xbusTextStart[], gspS2DEX2d_xbusTextEnd[]; +extern long long int gspS2DEX2d_xbusDataStart[], gspS2DEX2d_xbusDataEnd[]; + +#endif /* _LANGUAGE_C */ +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif +#endif /* !_UCODE_DEBUG_H */ + +/*======== End of ucode_debug.h ========*/ diff --git a/include/PR/ultraerror.h b/include/PR/ultraerror.h new file mode 100644 index 000000000..81ab5ac43 --- /dev/null +++ b/include/PR/ultraerror.h @@ -0,0 +1,167 @@ +/*==================================================================== + * ultraerror.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.24 $ + * $Date: 1998/01/27 23:52:11 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultraerror.h,v $ + * + **************************************************************************/ + +#ifndef __ULTRAERROR_H__ +#define __ULTRAERROR_H__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#define OS_ERROR_FMT "/usr/lib/PR/error.fmt" +#define OS_ERROR_MAGIC 0x6b617479 + +/* OS error codes */ + +#define ERR_OSCREATETHREAD_SP 1 +#define ERR_OSCREATETHREAD_PRI 2 +#define ERR_OSSTARTTHREAD 3 +#define ERR_OSSETTHREADPRI 4 +#define ERR_OSCREATEMESGQUEUE 5 +#define ERR_OSSENDMESG 6 +#define ERR_OSJAMMESG 7 +#define ERR_OSRECVMESG 8 +#define ERR_OSSETEVENTMESG 9 +#define ERR_OSMAPTLB_INDEX 10 +#define ERR_OSMAPTLB_ASID 11 +#define ERR_OSUNMAPTLB 12 +#define ERR_OSSETTLBASID 13 +#define ERR_OSAISETFREQUENCY 14 +#define ERR_OSAISETNEXTBUFFER_ADDR 15 +#define ERR_OSAISETNEXTBUFFER_SIZE 16 +#define ERR_OSDPSETNEXTBUFFER_ADDR 17 +#define ERR_OSDPSETNEXTBUFFER_SIZE 18 +#define ERR_OSPIRAWREADIO 19 +#define ERR_OSPIRAWWRITEIO 20 +#define ERR_OSPIRAWSTARTDMA_DIR 21 +#define ERR_OSPIRAWSTARTDMA_DEVADDR 22 +#define ERR_OSPIRAWSTARTDMA_ADDR 23 +#define ERR_OSPIRAWSTARTDMA_SIZE 24 +#define ERR_OSPIRAWSTARTDMA_RANGE 25 +#define ERR_OSPIREADIO 26 +#define ERR_OSPIWRITEIO 27 +#define ERR_OSPISTARTDMA_PIMGR 28 +#define ERR_OSPISTARTDMA_PRI 29 +#define ERR_OSPISTARTDMA_DIR 30 +#define ERR_OSPISTARTDMA_DEVADDR 31 +#define ERR_OSPISTARTDMA_ADDR 32 +#define ERR_OSPISTARTDMA_SIZE 33 +#define ERR_OSPISTARTDMA_RANGE 34 +#define ERR_OSCREATEPIMANAGER 35 +#define ERR_OSVIGETCURRENTMODE 36 +#define ERR_OSVIGETCURRENTFRAMEBUFFER 37 +#define ERR_OSVIGETNEXTFRAMEBUFFER 38 +#define ERR_OSVISETXSCALE_VALUE 39 +#define ERR_OSVISETXSCALE_VIMGR 40 +#define ERR_OSVISETYSCALE_VALUE 41 +#define ERR_OSVISETYSCALE_VIMGR 42 +#define ERR_OSVISETSPECIAL_VALUE 43 +#define ERR_OSVISETSPECIAL_VIMGR 44 +#define ERR_OSVISETMODE 45 +#define ERR_OSVISETEVENT 46 +#define ERR_OSVISWAPBUFFER_ADDR 47 +#define ERR_OSVISWAPBUFFER_VIMGR 48 +#define ERR_OSCREATEVIMANAGER 49 +#define ERR_OSCREATEREGION_ALIGN 50 +#define ERR_OSCREATEREGION_SIZE 51 +#define ERR_OSMALLOC 52 +#define ERR_OSFREE_REGION 53 +#define ERR_OSFREE_ADDR 54 +#define ERR_OSGETREGIONBUFCOUNT 55 +#define ERR_OSGETREGIONBUFSIZE 56 +#define ERR_OSSPTASKLOAD_DRAM 57 +#define ERR_OSSPTASKLOAD_OUT 58 +#define ERR_OSSPTASKLOAD_OUTSIZE 59 +#define ERR_OSSPTASKLOAD_YIELD 60 +#define ERR_OSPROFILEINIT_STR 61 +#define ERR_OSPROFILEINIT_CNT 62 +#define ERR_OSPROFILEINIT_ALN 63 +#define ERR_OSPROFILEINIT_ORD 64 +#define ERR_OSPROFILEINIT_SIZ 65 +#define ERR_OSPROFILESTART_TIME 66 +#define ERR_OSPROFILESTART_FLAG 67 +#define ERR_OSPROFILESTOP_FLAG 68 +#define ERR_OSPROFILESTOP_TIMER 69 +#define ERR_OSREADHOST_ADDR 70 +#define ERR_OSREADHOST_SIZE 71 +#define ERR_OSWRITEHOST_ADDR 72 +#define ERR_OSWRITEHOST_SIZE 73 +#define ERR_OSGETTIME 74 +#define ERR_OSSETTIME 75 +#define ERR_OSSETTIMER 76 +#define ERR_OSSTOPTIMER 77 +#define ERR_ALSEQP_NO_SOUND 100 +#define ERR_ALSEQP_NO_VOICE 101 +#define ERR_ALSEQP_MAP_VOICE 102 +#define ERR_ALSEQP_OFF_VOICE 103 +#define ERR_ALSEQP_POLY_VOICE 104 +#define ERR_ALSNDP_NO_VOICE 105 +#define ERR_ALSYN_NO_UPDATE 106 +#define ERR_ALSNDPDEALLOCATE 107 +#define ERR_ALSNDPDELETE 108 +#define ERR_ALSNDPPLAY 109 +#define ERR_ALSNDPSETSOUND 110 +#define ERR_ALSNDPSETPRIORITY 111 +#define ERR_ALSNDPSETPAR 112 +#define ERR_ALBNKFNEW 113 +#define ERR_ALSEQNOTMIDI 114 +#define ERR_ALSEQNOTMIDI0 115 +#define ERR_ALSEQNUMTRACKS 116 +#define ERR_ALSEQTIME 117 +#define ERR_ALSEQTRACKHDR 118 +#define ERR_ALSEQSYSEX 119 +#define ERR_ALSEQMETA 120 +#define ERR_ALSEQPINVALIDPROG 121 +#define ERR_ALSEQPUNKNOWNMIDI 122 +#define ERR_ALSEQPUNMAP 123 +#define ERR_ALEVENTNOFREE 124 +#define ERR_ALHEAPNOFREE 125 +#define ERR_ALHEAPCORRUPT 126 +#define ERR_ALHEAPFIRSTBLOCK 127 +#define ERR_ALCSEQZEROSTATUS 128 +#define ERR_ALCSEQZEROVEL 129 +#define ERR_ALCSPVNOTFREE 130 +#define ERR_ALSEQOVERRUN 131 +#define ERR_OSAISETNEXTBUFFER_ENDADDR 132 +#define ERR_ALMODDELAYOVERFLOW 133 +#define ERR_OSVIEXTENDVSTART_VIMGR 134 +#define ERR_OSVIEXTENDVSTART_VALUE 135 + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) +typedef void (*OSErrorHandler)(s16, s16, ...); + +OSErrorHandler osSetErrorHandler(OSErrorHandler); +#endif + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif /* __ULTRAERROR_H__ */ diff --git a/include/PR/ultralog.h b/include/PR/ultralog.h new file mode 100644 index 000000000..ebd7630e4 --- /dev/null +++ b/include/PR/ultralog.h @@ -0,0 +1,74 @@ +/*==================================================================== + * ultralog.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * $Revision: 1.6 $ + * $Date: 1997/02/11 08:39:05 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultralog.h,v $ + * + **************************************************************************/ + +#ifndef __log__ +#define __log__ + +#ifdef _LANGUAGE_C_PLUS_PLUS +extern "C" { +#endif + +#include + +#define OS_LOG_MAX_ARGS 16 +#define OS_LOG_MAGIC 0x20736a73 +#define OS_LOG_FLOAT(x) (*(int *) &(x)) +#define OS_LOG_VERSION 1 + +typedef struct { + u32 magic; /* log identifier */ + u32 len; /* length of log data + log structure */ + u32 *base; /* starting addr array */ + s32 startCount; /* read offset from dataBase */ + s32 writeOffset; /* write offset from dataBase */ +} OSLog; + +typedef struct { + u32 magic; + u32 timeStamp; + u16 argCount; + u16 eventID; +} OSLogItem; + +typedef struct { + u32 magic; /* log identifier */ + u32 version; /* 1 */ +} OSLogFileHdr; + +void osCreateLog(OSLog *log, u32 *base, s32 len); +void osLogEvent(OSLog *log, s16 code, s16 numArgs, ...); +void osFlushLog(OSLog *log); +u32 osLogFloat(f32); + +extern void osDelay(int count); + +#ifdef _LANGUAGE_C_PLUS_PLUS +} +#endif + +#endif diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h new file mode 100644 index 000000000..b8b9b0843 --- /dev/null +++ b/include/PR/ultratypes.h @@ -0,0 +1,90 @@ +#ifndef _ULTRATYPES_H_ +#define _ULTRATYPES_H_ + + +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + + +/************************************************************************* + * + * File: ultratypes.h + * + * This file contains various types used in Ultra64 interfaces. + * + * $Revision: 1.6 $ + * $Date: 1997/12/17 04:02:06 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultratypes.h,v $ + * + **************************************************************************/ + + + +/********************************************************************** + * General data types for R4300 + */ +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +typedef unsigned char u8; /* unsigned 8-bit */ +typedef unsigned short int u16; /* unsigned 16-bit */ +typedef unsigned int u32; /* unsigned 32-bit */ +typedef unsigned long long int u64; /* unsigned 64-bit */ + +typedef signed char s8; /* signed 8-bit */ +typedef signed short int s16; /* signed 16-bit */ +typedef signed int s32; /* signed 32-bit */ +typedef signed long long int s64; /* signed 64-bit */ + +typedef volatile unsigned char vu8; /* unsigned 8-bit */ +typedef volatile unsigned short vu16; /* unsigned 16-bit */ +typedef volatile unsigned long vu32; /* unsigned 32-bit */ +typedef volatile unsigned long long vu64; /* unsigned 64-bit */ + +typedef volatile signed char vs8; /* signed 8-bit */ +typedef volatile short vs16; /* signed 16-bit */ +typedef volatile long vs32; /* signed 32-bit */ +typedef volatile long long vs64; /* signed 64-bit */ + +typedef float f32; /* single prec floating point */ +typedef double f64; /* double prec floating point */ + +#if !defined(_SIZE_T) && !defined(_SIZE_T_) && !defined(_SIZE_T_DEF) +#define _SIZE_T +#define _SIZE_T_DEF /* exeGCC size_t define label */ +#if (_MIPS_SZLONG == 32) +typedef unsigned int size_t; +#endif +#if (_MIPS_SZLONG == 64) +typedef unsigned long size_t; +#endif +#endif + +#endif /* _LANGUAGE_C */ + + +/************************************************************************* + * Common definitions + */ +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#endif /* _ULTRATYPES_H_ */ + diff --git a/include/PR/uportals.h b/include/PR/uportals.h new file mode 100644 index 000000000..42359fd93 --- /dev/null +++ b/include/PR/uportals.h @@ -0,0 +1,134 @@ +/*==================================================================== + * uportals.h + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +/************************************************************************** + * + * uportals.h - header file for the ultraportals library + * + * $Revision: 1.12 $ + * $Date: 1997/02/11 08:40:49 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/uportals.h,v $ + * + **************************************************************************/ + + + +#ifndef __ULTRAPORTALS_H__ +#define __ULTRAPORTALS_H__ + +#include +#include "matrix.h" +#include "vector.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ENABLEPORTALS +#define ENABLEPORTALS +#endif + +#define UP_MAXPVERTS 16 /* max number of portal verts */ +#define UP_MAXCELLS 50 /* max number of cells */ +#define UP_CELLNL 32 /* max length of cell names */ +#define UP_OBNL 32 /* max length of obejct names */ + +typedef struct +{ + vec3 min, max; /* min and max pts of the box */ +} upBox; + +typedef struct _upPortalData * _portalptr; +typedef struct _upCellData * _cellptr; +typedef struct _upObjectData * _objectptr; + +typedef struct _upPortalData +{ + int numverts; /* number of verts in the portal*/ + _cellptr attached_cell; /* cell on the 'other side' */ + vec3 verts[UP_MAXPVERTS]; /* the actual vertices */ +#ifdef MVTVIEW + int mvt_id; /* if has mvt, this is the id */ +#endif +} upPortalData; + +typedef struct _upCellData +{ + int numportals; /* number of portals */ + int numobjects; /* number of objects */ + int rendered; /* last frame number rendered */ + _portalptr *portals; /* array for the actual portals */ + _objectptr *objects; /* array for 'detail' objects */ + upBox bbox; /* bounding box of the cell */ + Gfx *dlist; /* associated display list */ + char name[UP_CELLNL]; /* name of the cell */ + float eyeheight; /* height to constrain eyept to */ + int zone; /* current zone number */ +} upCellData; + +typedef struct _upObjectData +{ + int rendered; /* last frame number rendered */ + upBox bbox; /* bounding box for the object */ + Gfx *dlist; /* associated display list */ + char name[UP_OBNL]; /* name of the object */ +} upObjectData; + +typedef struct +{ + int numcells; /* how many cells are there? */ + upCellData cells[UP_MAXCELLS]; /* the actual cells */ + Gfx *rootdlist; /* display list for all cells */ + vec2 portalmin, portalmax; /* XY bbox used by upCheckCells */ + float near, far; /* near, far clipping planes */ + FMatrix viewmat; /* viewing matrix (world->eye) */ + FMatrix projmat; /* proj matrix (eye->screen) */ + FMatrix compmat; /* view * proj (world->screen) */ + int portaldepth; /* depth of the portal stack */ + int framecount; /* current frame number */ +} upLocateData; + +/* + * Functions: + */ +extern void upInit(); /* generated automatically by flt2walk */ +extern Gfx *upAddVisibleCells(Gfx * glistp, vec3 eyept); +extern void upTogglePortalBounds(); +extern void upToggleScissorBox(); + +/* + * Globals: + */ +extern upLocateData upLocator; /* also extern by test_portals.h */ + +/* + * Macros: + */ +#define UP_HUGEVAL 3.40282347e+37 +#define PT_IN_BOX(p,box) ((p)[0] > (box).min[0] && (p)[0] < (box).max[0] &&\ + (p)[1] > (box).min[1] && (p)[1] < (box).max[1] &&\ + (p)[2] > (box).min[2] && (p)[2] < (box).max[2]) + + +#ifdef __Cplusplus +} +#endif + +#endif diff --git a/include/make/PRdefs b/include/make/PRdefs new file mode 100644 index 000000000..f5456a7ae --- /dev/null +++ b/include/make/PRdefs @@ -0,0 +1,85 @@ +# +# Commondefs for Project Reality source tree +# +# Makefiles which include this should first define PRDEPTH to be the relative +# path from their parent directory. + +include $(ROOT)/usr/include/make/commondefs + +# +# Use $(MAKE) $(MAKEARGS) instead of $(MAKEF) so that make -n works +# This gets around the fact that $(MAKE) works and $(MAKEF) does not. +# MAKEARGS is based directly on $(MAKEF) in commondefs. +# +MAKEARGS = VCFLAGS="$(VCFLAGS)" VFFLAGS="$(VFFLAGS)" \ + VPFLAGS="$(VPFLAGS)" VMKDEPFLAGS="$(VMKDEPFLAGS)" + +# make sure 'default' does not hit these rules +defaultrule: default + +# +# Compile tree for RCP 1.0 or RCP 2.0 +# +#GCDEFS = $(HW_FLAGS) +#GCDEFS = $(HW_FLAGS) -B -Wab,-r4300_mul +#ifdef __GCC__ +GCDEFS = +#else +GCDEFS = $(HW_FLAGS) -Wab,-r4300_mul +#endif + +# +# VCS compiler options +# +VCSOPTS = $(GVCSOPTS) $(LVCSOPTS) $(VVCSOPTS) +GVCSOPTS = +acc -V -M -Mupdate -Mmakep=pmake \ + -CC "-mips2 -Wab,-big_got -Wab,-dwalign" -lgl -limage \ + -P $(PRDEPTH)/rdpsim/pli/pli.tab $(ROOT)/usr/lib/PR/libpli.a + +SHELL = /bin/sh + +FLT2C = $(ROOT)/usr/sbin/flt2c +IC = $(ROOT)/usr/sbin/ic +#ifdef __GCC__ +MAKEROM = $(GCCDIR)/mipse/bin/mild +#else +MAKEROM = $(ROOT)/usr/sbin/makerom +#endif +MIDIPARSE = $(ROOT)/usr/sbin/midiparse +MIDICVT = $(ROOT)/usr/sbin/midicvt +MIDICOMP = $(ROOT)/usr/sbin/midicomp +SBC = $(ROOT)/usr/sbin/sbc +NLD = $(ROOT)/usr/sbin/nld +RGB2C = $(ROOT)/usr/sbin/rgb2c +MKSPRITE = $(ROOT)/usr/sbin/mksprite +MKISPRITE = $(ROOT)/usr/sbin/mkisprite +TABLEDESIGN = $(ROOT)/usr/sbin/tabledesign +VADPCM_ENC = $(ROOT)/usr/sbin/vadpcm_enc +RSPASM = $(ROOT)/usr/sbin/rspasm +BUILDTASK = $(ROOT)/usr/sbin/buildtask +RSP2ELF = $(ROOT)/usr/sbin/rsp2elf + +DATA2RDRAM = $(PRDEPTH)/tools/data/data2rdram +RDRAM2DATA = $(PRDEPTH)/tools/data/rdram2data +TMEMFMT = $(PRDEPTH)/tools/tmemfmt/tmemfmt + +ECS2VL = $(PRDEPTH)/rdpsim/tools/ecs2vl +ECSGEN = $(PRDEPTH)/rdpsim/tools/ecs_gen +MERRG = $(PRDEPTH)/rdpsim/tools/merrg +RMVCOM = $(PRDEPTH)/rdpsim/tools/remove_comments +TAB2VMEM= $(PRDEPTH)/rdpsim/tools/tab2vmem +TAB2WVS = $(PRDEPTH)/rdpsim/tools/tab2wvs +VSIG = $(PRDEPTH)/rdpsim/tools/vsig +XNET = $(PRDEPTH)/rdpsim/tools/xnet + +ASYIN = /ecad/ecs/ecs_2.4/bin/asyin +MAKEINI = /ecad/ecs/ecs_2.4/bin/makeini + +VCSDIR = /ecad/vcs/vcs_2.2/sgi +VCS = $(VCSDIR)/bin/vcs + +LOG_RESULT = \ + @echo -n "!!! $(*:T) of" `basename \`pwd\``": "; \ + grep "number of errors" $*.out + +LOG_ERROR = $(LOG_RESULT) diff --git a/src/include/PR/sys/asm.h b/include/sys/asm.h similarity index 100% rename from src/include/PR/sys/asm.h rename to include/sys/asm.h diff --git a/include/sys/regdef.h b/include/sys/regdef.h new file mode 100755 index 000000000..34c271936 --- /dev/null +++ b/include/sys/regdef.h @@ -0,0 +1,45 @@ +#ifndef __REGDEF_H__ +#define __REGDEF_H__ +#ifdef __cplusplus +extern "C" { +#endif +/* +* +* Copyright 1992, Silicon Graphics, Inc. +* All Rights Reserved. +* +* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; +* the contents of this file may not be disclosed to third parties, copied or +* duplicated in any form, in whole or in part, without the prior written +* permission of Silicon Graphics, Inc. +* +* RESTRICTED RIGHTS LEGEND: +* Use, duplication or disclosure by the Government is subject to restrictions +* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data +* and Computer Software clause at DFARS 252.227-7013, and/or in similar or +* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - +* rights reserved under the Copyright Laws of the United States. +*/ +/* ------------------------------------------------------------------ */ +/* | Copyright Unpublished, MIPS Computer Systems, Inc. All Rights | */ +/* | Reserved. This software contains proprietary and confidential | */ +/* | information of MIPS and its suppliers. Use, disclosure or | */ +/* | reproduction is prohibited without the prior express written | */ +/* | consent of MIPS. | */ +/* ------------------------------------------------------------------ */ +#ident "$Revision: 1.9 $" +/* regdef.h 1.2 */ + +/* + * Mips register definitions. + */ + +#ifdef mips +#include +/*#include */ +#endif /* mips */ + +#ifdef __cplusplus +} +#endif +#endif /* !__REGDEF_H__ */ diff --git a/include/sys/u64driver.h b/include/sys/u64driver.h new file mode 100644 index 000000000..db4fe3361 --- /dev/null +++ b/include/sys/u64driver.h @@ -0,0 +1,131 @@ +#ifndef __SYS_U64DRIVER_H__ +#define __SYS_U64DRIVER_H__ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied or + * duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - + * rights reserved under the Copyright Laws of the United States. + * + */ + +#include +#include +#include "u64gio.h" + + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + + +#define U64_MINOR_PRINT 1 +#define U64_MINOR_DEBUG 2 +#define U64_MINOR_LOGGING 3 +#define U64_MINOR_DATA 4 +#define U64_MINOR_FAULT 5 +#define U64_MINOR_KDEBUG 6 +#define U64_MINOR_PROFILE 7 +#define NUMBER_MINORS 8 /* don't use minor zero , but must count 0-7 */ + +#define U64_MINOR_PRINT_BUF_SIZE 0x80000 /* buffer used by incoming printf data */ +#define U64_MINOR_DEBUG_BUF_SIZE 0x4000 +#define U64_MINOR_LOGGING_BUF_SIZE RDB_LOG_MAX_BLOCK_SIZE /* buffer used by incoming logging data */ +#define U64_MINOR_DATA_BUF_SIZE RDB_DATA_MAX_BLOCK_SIZE /* buffer used by incoming data */ +#define U64_MINOR_FAULT_BUF_SIZE 1024 /* buffer used for incoming fault data */ +#define U64_MINOR_KDEBUG_BUF_SIZE 1024 /* buffer used for incoming kdebug data */ +#define U64_MINOR_PROFILE_BUF_SIZE 2048 /* buffer used for incoming profile data */ +#define U64_MINOR_PROFILE_SEND_BUF_SIZE 16 /* only send one byte messages */ +#define U64_INTERNAL_WRITE_BUF_SIZE 0x8000 /* buffer used to store packets waiting to go out */ + + + +#define u64_increment_Qptr(x) { ((x) = ((x) + 1) & 0xff) ; } + + +typedef struct { + sema_t minor_sema; /* used to allow only one app to open the minor */ + sema_t read_sema; /* used to block while waiting for data */ + sema_t write_sema; /* only allow one entry to write at a time */ + int read_count; /* the number of bytes waiting to be read */ + int write_count; /* the number of bytes waiting to be written */ + int read_cur_write; + int write_cur_write; + int read_cur_read; + int write_cur_read; + unsigned char *read_buf; + unsigned char *write_buf; + int read_buf_size; /* measured in unsigned char's */ + int write_buf_size; /* measured in unsigned char's */ + int incoming_ct; /* used by minors that receive data from game */ + /* indicates how many bytes left in block */ + /* before signaling game that transfer is done */ + /* used by logging and game to host data stuff */ + int message; /* when not zero, send this message to game to */ + /* indicate that data or log data has been read */ + struct pollhead *phead; +} u64_minor; + +/* + * Our private one-per-board data structure + * The user can't get at any of this + */ +struct u64_data { + + volatile struct u64_board *board; + unsigned char *memaddr; /* 16/32 bit access R/W */ + + /* + * Only one client may be in the kernel at a time; this semaphore is used + * to prevent multiple clients from overrunning each other's interactions + * with the hardware. + */ + sema_t ioctl_sema; + + /* + * The ramrom_sema is used by the driver so that it can arbitrate for the + * control of ramrom with the game, and sleep while waiting for the game + * to respond. + */ + sema_t ramrom_sema; + + /* + * Allocate a megabyte buffer which we can use when reading/writing data + * to or from the board (we can't copyin/copyout directly from the user's + * buffer, because those routines use 64 bit transfers). + */ + unsigned int *oneMeg; + + union { + u64_write_arg_t u64_write; /* WRITE, SAFE_WRITE */ + u64_read_arg_t u64_read; /* READ, SAFE_READ */ + } args; + + /* rdb port */ + unsigned int *write_buf; + unsigned int write_buf_cur_write; + unsigned int write_buf_cur_read; + unsigned int write_buf_ct; /* number of packets waiting for transmission */ + unsigned int write_buf_size; /* measured in rdbPackets */ + sema_t write_buf_sema; + u64_minor minors[NUMBER_MINORS]; + +}; + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +#endif /* __SYS_U64DRIVER_H__ */ + + + + + + diff --git a/include/sys/u64gio.h b/include/sys/u64gio.h new file mode 100644 index 000000000..106a9ccd9 --- /dev/null +++ b/include/sys/u64gio.h @@ -0,0 +1,110 @@ +#ifndef __SYS_U64GIO_H__ +#define __SYS_U64GIO_H__ + +/* + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied or + * duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - + * rights reserved under the Copyright Laws of the United States. + * + */ + +#define DEV_U64 "/dev/u64" +#define DEV_U64_PRINT "/dev/u64_print" +#define DEV_U64_DEBUG "/dev/u64_debug" +#define DEV_U64_LOG "/dev/u64_logging" +#define DEV_U64_DATA "/dev/u64_data" +#define DEV_U64_FAULT "/dev/u64_fault" +#define DEV_U64_KDEBUG "/dev/u64_kdebug" +#define DEV_U64_PROFILE "/dev/u64_profile" +/* + * ioctls + */ +#define U64IOC ('u'<<24|'6'<<16) +#define U64IOCTL(x) (U64IOC|x) + +#define U64_RESET U64IOCTL(1) /* arg: 0 - deassert, 1 - assert */ +#define U64_WRITE U64IOCTL(2) +#define U64_READ U64IOCTL(3) +#define U64_SAFE_WRITE U64IOCTL(4) +#define U64_SAFE_READ U64IOCTL(5) +#define U64_LISTEN U64IOCTL(6) /* arg is register value for listen */ +#define U64_SIGNAL U64IOCTL(7) /* arg is register value for signal */ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + +/* structure for WRITE & SAFE_WRITE*/ +typedef struct u64_write_arg { + void *buffer; + long ramrom_addr; + int nbytes; +} u64_write_arg_t; + +/* structure for READ & SAFE_READ */ +typedef struct u64_read_arg { + void *buffer; + long ramrom_addr; + int nbytes; +} u64_read_arg_t; + +/* NOTE: if game is in reset, don't interrupt the game */ + +struct u64_board { + volatile unsigned int product_id_reg; /* bf400000, read only */ + unsigned char fill_0[0x3fc]; + volatile unsigned int reset_control; /* bf400400, write only */ + unsigned char fill_1[0x3fc]; + volatile unsigned int cart_interrupt; /* bf400800, read/write */ + unsigned char fill_3[0x1fc]; + volatile unsigned int dram_page_cntrl;/* bf400a00, read/write */ + unsigned char fill_2[0x1fc]; + volatile unsigned int gio_interrupt; /* bf400c00, read only */ + unsigned char fill_4[0x1fc]; + volatile unsigned int gio_sync; /* bf400e00, read only */ +}; + +#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ + +/* + * _U64_PRODUCT_ID_REG - GIO bus Product ID register + */ +#define _U64_PRODUCT_ID_MASK 0x0000007f +#define _U64_PRODUCT_ID_VALUE 0x00000015 + +/* + * reset control register has two bits defined + */ +#define _U64_RESET_CONTROL_NMI 0x4 +#define _U64_RESET_CONTROL_RESET 0x2 + +/* + * Only look at the least significant 5 bits of the sync and interrupt + * registers. Future revs of the firmware may provide more. + */ + +#define _U64_REGMASK 0x1f + +/* + * 16MB available, one meg at a time, selected by the 4 bit + * dram_page_cntrl register setting. + */ +#define U64_MEM_SIZE 0x100000 + +/* + * Declare size of gio-addressable memory to mmap, and provide the base + * physical address so that clients who want to mmap() may do so. + */ +#define U64_GIOBUS_SIZE 0x200000 /* 2 MB */ +#define U64_GIOBUS_BASE 0x1f400000 + +#endif /* __SYS_U64GIO_H__ */ diff --git a/include/tinymon.h b/include/tinymon.h new file mode 100644 index 000000000..5856d4f69 --- /dev/null +++ b/include/tinymon.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1995, Silicon Graphics, Inc. All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; + * the contents of this file may not be disclosed to third parties, copied + * or duplicated in any form, in whole or in part, without the prior written + * permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to restrictions + * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data + * and Computer Software clause at DFARS 252.227-7013, and/or in similar or + * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished + * rights reserved under the Copyright Laws of the United States. + * + * Module: tinymon.h: constants for use with the tinymon family of debug servers + */ + +#define GIO_BASE_REG_UPPER 0x1800 +#define GIO_BASE_REG_UPPER_K1 0xb800 +#define GIO_INTR_REG_OFFSET 0x0 +#define GIO_SYNC_REG_OFFSET 0x400 +#define CART_INTR_REG_OFFSET 0x800 + +#define RAMROM_BASE_UPPER 0x1000 +#define RAMROM_BASE_UPPER_K1 0xb000 + +/* + * jal will or in the upper four bits of 0xb0000000 whenever we invoke these + * routines. + */ +#define PIFMON_WRITE_ADDR 0xfc00030 + +#define PI_BASE_REG_UPPER 0x0460 +#define PI_BASE_REG_UPPER_K1 0xa460 +#define PI_STATUS_REG_OFFSET 0x10 + +/* + * PI status register has 3 bits active when read from (PI_STATUS_REG - read) + * Bit 0: DMA busy - set when DMA is in progress + * Bit 1: IO busy - set when IO is in progress + * Bit 2: Error - set when R4300 issues IO request while DMA is busy + */ +#define PI_STATUS_ERROR 0x04 +#define PI_STATUS_IO_BUSY 0x02 +#define PI_STATUS_DMA_BUSY 0x01 + +/* + * Host to R4300 protocol definitions. + * + * Host writes DG_RAMROM_REQUEST, DG_RAMROM_CMD_READY to the cartridge + * interrupt register (which the R4300 can poll), + * + * R4300 writes DG_RAMROM_GRANT, DG_RAMROM_CMD_DONE to the gio sync register + * (which the host can poll). + */ + +#define DG_CARTREG_MASK 0x3f + +#define DG_RAMROM_REQUEST 1 +#define DG_RAMROM_GRANT 2 +#define DG_RAMROM_CMD_READY 3 +#define DG_RAMROM_CMD_DONE 4 + +#define DG_TINYMON_READ_OP 1 +#define DG_TINYMON_WRITE_OP 2 +#define DG_TINYMON_DMA_READ_OP 3 +#define DG_TINYMON_DMA_WRITE_OP 4 diff --git a/include/ultra64.h b/include/ultra64.h new file mode 100644 index 000000000..357287204 --- /dev/null +++ b/include/ultra64.h @@ -0,0 +1,40 @@ + +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + *************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.10 $ + * $Date: 1997/02/11 08:37:33 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultra64.h,v $ + * + **************************************************************************/ + +#ifndef _ULTRA64_H_ +#define _ULTRA64_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/ultrahost.h b/include/ultrahost.h new file mode 100644 index 000000000..865b113b1 --- /dev/null +++ b/include/ultrahost.h @@ -0,0 +1,58 @@ +/************************************************************************** + * * + * Copyright (C) 1995, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + *************************************************************************/ + +/************************************************************************** + * + * $Revision: 1.8 $ + * $Date: 1997/07/02 02:35:06 $ + * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/ultrahost.h,v $ + * + **************************************************************************/ + +#ifndef _ULTRAHOST_H_ +#define _ULTRAHOST_H_ + +#ifdef PTN64 /* { */ + +#define execl execl_pt + +#define uhOpenGame uhOpenGame_pt +#define uhCloseGame uhCloseGame_pt + +#define uhReadGame uhReadGame_pt +#define uhWriteGame uhWriteGame_pt +#define uhReadRamrom uhReadRamrom_pt +#define uhWriteRamrom uhWriteRamrom_pt +#define uhPartnerCmd uhPartnerCmd_pt +#define uhGload uhGload_pt + +int uhPartnerCmd(int,char *); +int uhGload(int,char *); + +#endif /* } */ + +#ifdef __cplusplus +extern "C" { +#endif +int uhOpenGame(const char *); +int uhCloseGame(int); + +int uhReadGame(int, void *, int); +int uhWriteGame(int, void *, int); +int uhWriteRamrom(int, void *, void*, int); +int uhReadRamrom(int, void *, void*, int); + +#ifdef __cplusplus +} +#endif + +#endif /* ULTRAHOST */ diff --git a/ld/libfiles.ntsc-beta.inc b/ld/libfiles.ntsc-beta.inc index 44052cadb..f4697d4b9 100644 --- a/ld/libfiles.ntsc-beta.inc +++ b/ld/libfiles.ntsc-beta.inc @@ -68,36 +68,37 @@ build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/lib_2fba0.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ - build/ROMID/lib/lib_30ce0.o (section); \ + build/ROMID/lib/naudio/n_synthesizer.o (section); \ + build/ROMID/lib/ultra/audio/sl.o (section); \ build/ROMID/lib/lib_317f0.o (section); \ build/ROMID/lib/speaker.o (section); \ - build/ROMID/lib/ultra/audio/csplayer.o (section); \ + build/ROMID/lib/naudio/n_csplayer.o (section); \ build/ROMID/lib/lib_37650.o (section); \ build/ROMID/lib/ultra/audio/bnkf.o (section); \ build/ROMID/lib/mp3.o (section); \ build/ROMID/lib/lib_38d10.o (section); \ - build/ROMID/lib/ultra/audio/cseq.o (section); \ + build/ROMID/lib/naudio/n_csq.o (section); \ build/ROMID/lib/lib_39be0.o (section); \ build/ROMID/lib/lib_39c80.o (section); \ build/ROMID/lib/lib_39f70.o (section); \ - build/ROMID/lib/ultra/audio/syndelete.o (section); \ + build/ROMID/lib/naudio/n_syndelete.o (section); \ build/ROMID/lib/lib_39fe0.o (section); \ build/ROMID/lib/lib_3a100.o (section); \ build/ROMID/lib/lib_3c430.o (section); \ - build/ROMID/lib/ultra/audio/event.o (section); \ + build/ROMID/lib/naudio/n_event.o (section); \ build/ROMID/lib/lib_3c890.o (section); \ build/ROMID/lib/lib_3ccf0.o (section); \ build/ROMID/lib/lib_3cdc0.o (section); \ build/ROMID/lib/lib_3cef0.o (section); \ - build/ROMID/lib/lib_3d280.o (section); \ + build/ROMID/lib/naudio/n_seqplayer.o (section); \ build/ROMID/lib/lib_3e3e0.o (section); \ build/ROMID/lib/lib_3e730.o (section); \ - build/ROMID/lib/lib_3e8c0.o (section); \ + build/ROMID/lib/naudio/n_env.o (section); \ build/ROMID/lib/lib_3f8a0.o (section); \ build/ROMID/lib/lib_43dd0.o (section); \ build/ROMID/lib/lib_446d0.o (section); \ build/ROMID/lib/lib_44bc0.o (section); \ - build/ROMID/lib/ultra/audio/synsetpriority.o (section); \ + build/ROMID/lib/naudio/n_synsetpriority.o (section); \ build/ROMID/lib/lib_44f60.o (section); \ build/ROMID/lib/lib_45ed0.o (section); \ build/ROMID/lib/lib_461c0.o (section); \ diff --git a/ld/libfiles.ntsc-final.inc b/ld/libfiles.ntsc-final.inc index 78a113886..55bc3d28b 100644 --- a/ld/libfiles.ntsc-final.inc +++ b/ld/libfiles.ntsc-final.inc @@ -65,36 +65,37 @@ build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/lib_2fba0.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ - build/ROMID/lib/lib_30ce0.o (section); \ + build/ROMID/lib/naudio/n_synthesizer.o (section); \ + build/ROMID/lib/ultra/audio/sl.o (section); \ build/ROMID/lib/lib_317f0.o (section); \ build/ROMID/lib/speaker.o (section); \ - build/ROMID/lib/ultra/audio/csplayer.o (section); \ + build/ROMID/lib/naudio/n_csplayer.o (section); \ build/ROMID/lib/lib_37650.o (section); \ build/ROMID/lib/ultra/audio/bnkf.o (section); \ build/ROMID/lib/mp3.o (section); \ build/ROMID/lib/lib_38d10.o (section); \ - build/ROMID/lib/ultra/audio/cseq.o (section); \ + build/ROMID/lib/naudio/n_csq.o (section); \ build/ROMID/lib/lib_39be0.o (section); \ build/ROMID/lib/lib_39c80.o (section); \ build/ROMID/lib/lib_39f70.o (section); \ - build/ROMID/lib/ultra/audio/syndelete.o (section); \ + build/ROMID/lib/naudio/n_syndelete.o (section); \ build/ROMID/lib/lib_39fe0.o (section); \ build/ROMID/lib/lib_3a100.o (section); \ build/ROMID/lib/lib_3c430.o (section); \ - build/ROMID/lib/ultra/audio/event.o (section); \ + build/ROMID/lib/naudio/n_event.o (section); \ build/ROMID/lib/lib_3c890.o (section); \ build/ROMID/lib/lib_3ccf0.o (section); \ build/ROMID/lib/lib_3cdc0.o (section); \ build/ROMID/lib/lib_3cef0.o (section); \ - build/ROMID/lib/lib_3d280.o (section); \ + build/ROMID/lib/naudio/n_seqplayer.o (section); \ build/ROMID/lib/lib_3e3e0.o (section); \ build/ROMID/lib/lib_3e730.o (section); \ - build/ROMID/lib/lib_3e8c0.o (section); \ + build/ROMID/lib/naudio/n_env.o (section); \ build/ROMID/lib/lib_3f8a0.o (section); \ build/ROMID/lib/lib_43dd0.o (section); \ build/ROMID/lib/lib_446d0.o (section); \ build/ROMID/lib/lib_44bc0.o (section); \ - build/ROMID/lib/ultra/audio/synsetpriority.o (section); \ + build/ROMID/lib/naudio/n_synsetpriority.o (section); \ build/ROMID/lib/lib_44f60.o (section); \ build/ROMID/lib/lib_45ed0.o (section); \ build/ROMID/lib/lib_461c0.o (section); \ diff --git a/ld/libfiles.pal-final.inc b/ld/libfiles.pal-final.inc index 360d7ed1c..18905112d 100644 --- a/ld/libfiles.pal-final.inc +++ b/ld/libfiles.pal-final.inc @@ -65,36 +65,37 @@ build/ROMID/lib/ultra/audio/heap.o (section); \ build/ROMID/lib/lib_2fba0.o (section); \ build/ROMID/lib/lib_2fc60.o (section); \ - build/ROMID/lib/lib_30ce0.o (section); \ + build/ROMID/lib/naudio/n_synthesizer.o (section); \ + build/ROMID/lib/ultra/audio/sl.o (section); \ build/ROMID/lib/lib_317f0.o (section); \ build/ROMID/lib/speaker.o (section); \ - build/ROMID/lib/ultra/audio/csplayer.o (section); \ + build/ROMID/lib/naudio/n_csplayer.o (section); \ build/ROMID/lib/lib_37650.o (section); \ build/ROMID/lib/ultra/audio/bnkf.o (section); \ build/ROMID/lib/mp3.o (section); \ build/ROMID/lib/lib_38d10.o (section); \ - build/ROMID/lib/ultra/audio/cseq.o (section); \ + build/ROMID/lib/naudio/n_csq.o (section); \ build/ROMID/lib/lib_39be0.o (section); \ build/ROMID/lib/lib_39c80.o (section); \ build/ROMID/lib/lib_39f70.o (section); \ - build/ROMID/lib/ultra/audio/syndelete.o (section); \ + build/ROMID/lib/naudio/n_syndelete.o (section); \ build/ROMID/lib/lib_39fe0.o (section); \ build/ROMID/lib/lib_3a100.o (section); \ build/ROMID/lib/lib_3c430.o (section); \ - build/ROMID/lib/ultra/audio/event.o (section); \ + build/ROMID/lib/naudio/n_event.o (section); \ build/ROMID/lib/lib_3c890.o (section); \ build/ROMID/lib/lib_3ccf0.o (section); \ build/ROMID/lib/lib_3cdc0.o (section); \ build/ROMID/lib/lib_3cef0.o (section); \ - build/ROMID/lib/lib_3d280.o (section); \ + build/ROMID/lib/naudio/n_seqplayer.o (section); \ build/ROMID/lib/lib_3e3e0.o (section); \ build/ROMID/lib/lib_3e730.o (section); \ - build/ROMID/lib/lib_3e8c0.o (section); \ + build/ROMID/lib/naudio/n_env.o (section); \ build/ROMID/lib/lib_3f8a0.o (section); \ build/ROMID/lib/lib_43dd0.o (section); \ build/ROMID/lib/lib_446d0.o (section); \ build/ROMID/lib/lib_44bc0.o (section); \ - build/ROMID/lib/ultra/audio/synsetpriority.o (section); \ + build/ROMID/lib/naudio/n_synsetpriority.o (section); \ build/ROMID/lib/lib_44f60.o (section); \ build/ROMID/lib/lib_45ed0.o (section); \ build/ROMID/lib/lib_461c0.o (section); \ diff --git a/ld/pd.ld b/ld/pd.ld index 9543da79a..01a2d180b 100644 --- a/ld/pd.ld +++ b/ld/pd.ld @@ -122,22 +122,6 @@ SECTIONS _val7f11c1d0 = 0x11c3; #endif -#if VERSION >= VERSION_PAL_FINAL - rspbootTextStart = 0x80059fe0; - rspbootTextEnd = 0x8005a0b0; - aspMainTextStart = 0x8005b180; - aspMainTextEnd = 0x8005c180; - aspMainDataStart = 0x8008a2d0; - aspMainDataEnd = 0x8008aad0; -#else - rspbootTextStart = 0x80059fe0; - rspbootTextEnd = 0x8005a0b0; - aspMainTextStart = 0x8005b4d0; - aspMainTextEnd = 0x8005c4d0; - aspMainDataStart = 0x8008a2d0; - aspMainDataEnd = 0x8008aad0; -#endif - osTvType = 0x80000300; osRomType = 0x80000304; osRomBase = 0x80000308; @@ -271,8 +255,8 @@ SECTIONS gspDataStart = _dataSegmentEnd - 0x800 - 0xb50; gspDataEnd = gspDataStart + 0x800; - aspMainDataStart = gspDataEnd; - aspMainDataEnd = aspMainDataStart + 0xb50; + aspDataStart = gspDataEnd; + aspDataEnd = aspDataStart + 0xb50; /*************************************************************************** * bss diff --git a/src/game/objectives/objectives.c b/src/game/objectives/objectives.c index 82213c0ef..741e01e84 100644 --- a/src/game/objectives/objectives.c +++ b/src/game/objectives/objectives.c @@ -67,7 +67,7 @@ void func0f095350(u32 arg0, u32 *arg1) value = *ptr; } - *arg1 = *(u32 *)(osRomBase | arg0 | 0xa0000000); + *arg1 = *(u32 *)((u32)osRomBase | arg0 | 0xa0000000); __osPiRelAccess(); } diff --git a/src/game/propobj.c b/src/game/propobj.c index bd3c89931..c9ec7d680 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -67060,7 +67060,7 @@ void func0f08e224(struct doorobj *door) } } -extern u32 osCicId; +extern s32 osCicId; void func0f08e2ac(struct doorobj *door) { diff --git a/src/game/title.c b/src/game/title.c index 550b83f23..328bcc64f 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -36,8 +36,8 @@ u32 var8009ccb8; s16 var800624a0 = 480; s32 var800624a4 = false; -u32 var800624a8 = 0x00000000; -u32 var800624ac = 0x00000000; +s32 var800624a8 = 0; +s32 var800624ac = 0; u32 var800624b0 = 0x00000000; s32 g_TitleMode = -1; s32 g_TitleNextMode = -1; @@ -5396,7 +5396,7 @@ void titleTickNintendoLogo(void) } if (joyGetButtonsPressedThisFrame(0, 0xffff)) { - if (osResetType == RESET_TYPE_NMI) { + if (osResetType == 1 /*warm*/) { var800624a8 = 1; titleSetNextMode(TITLEMODE_PDLOGO); } else if (var800624a8 == 0) { @@ -6095,7 +6095,7 @@ void titleTickRareLogo(void) g_TitleTimer += g_Vars.lvupdate240_60; if (joyGetButtonsPressedThisFrame(0, 0xffff)) { - if (osResetType == RESET_TYPE_NMI) { + if (osResetType == 1 /*warm*/) { var800624a8 = 1; titleSetNextMode(TITLEMODE_PDLOGO); } else if (var800624a8 == 0) { diff --git a/src/include/PR/gbi.inc b/src/include/PR/gbi.inc deleted file mode 100644 index 15edb66b2..000000000 --- a/src/include/PR/gbi.inc +++ /dev/null @@ -1,971 +0,0 @@ -/* - * Graphics Binary Interface - * This supports Fast3D, Fast3DEX, and Fast3DEX2. - */ - -/* Fast3DZEX support */ -.ifdef F3DZEX_GBI - .set F3DEX_GBI_2, 1 -.endif - -/* Macros */ - -/* commands with no parameters */ -.macro f3d_noparam cmd - .word (\cmd << 24), 0x00000000 -.endm - -.macro gsImmp1 cmd, param - .word (\cmd << 24), \param -.endm - -/* DMA helper */ -.macro gsDma1p cmd, segAddr, length, params - .word (\cmd << 24) | ((\params & 0xFFFF) << 16) | (\length & 0xFFFF) - .word \segAddr -.endm - -/* DMA helper 3*/ -.macro gsDma3p cmd, byte2, byte3, byte4, segAddr - .byte \cmd, \byte2, \byte3, \byte4 - .word \segAddr -.endm - -/* Helper for RGBA colors. */ -.macro sDPRGBColor cmd r, g, b, a - .word \cmd << 24 - .byte \r, \g, \b, \a -.endm - -/* Opcodes */ - -.ifdef F3DEX_GBI_2 -.set G_MTX, 0xDA -.set G_MOVEMEM, 0xDC -.set G_VTX, 0x01 -.set G_DL, 0xDE -.set G_TRI2, 0x06 -.set G_RDPHALF_1, 0xE1 -.set G_RDPHALF_2, 0xF1 -.set G_GEOMETRYMODE, 0xD9 /* Fast3DEX2 uses one GeometryMode opcode. */ -.set G_ENDDL, 0xDF -.set G_SETOTHERMODE_L, 0xE2 -.set G_SETOTHERMODE_H, 0xE3 -.set G_TEXTURE, 0xD7 -.set G_MOVEWORD, 0xDB -.set G_TRI1, 0x05 -.set G_NOOP, 0xC0 -.set G_RDPLOADSYNC, 0xE6 -.set G_RDPPIPESYNC, 0xE7 -.set G_RDPTILESYNC, 0xE8 -.set G_RDPFULLSYNC, 0xE9 -.set G_LOADTLUT, 0xF0 -.set G_SETTILESIZE, 0xF2 -.set G_LOADBLOCK, 0xF3 -.set G_SETTILE, 0xF5 -.set G_SETFILLCOLOR, 0xF7 -.set G_SETFOGCOLOR, 0xF8 -.set G_SETBLENDCOLOR, 0xF9 -.set G_SETPRIMCOLOR, 0xFA -.set G_SETENVCOLOR, 0xFB -.set G_SETCOMBINE, 0xFC -.set G_SETTIMG, 0xFD -.set G_TEXRECT, 0xE4 - -.else /* F3D and F3DEX */ -.set G_MTX, 0x01 -.set G_MOVEMEM, 0x03 -.set G_VTX, 0x04 -.set G_DL, 0x06 -.set G_TRI2, 0xB1 -.set G_RDPHALF_CONT, 0xB2 -.set G_RDPHALF_2, 0xB3 -.set G_RDPHALF_1, 0xB4 -.set G_CLEARGEOMETRYMODE, 0xB6 -.set G_SETGEOMETRYMODE, 0xB7 -.set G_ENDDL, 0xB8 -.set G_SETOTHERMODE_L, 0xB9 -.set G_SETOTHERMODE_H, 0xBA -.set G_TEXTURE, 0xBB -.set G_MOVEWORD, 0xBC -.set G_TRI1, 0xBF -.set G_NOOP, 0xC0 -.set G_TEXRECT, 0xE4 -.set G_RDPLOADSYNC, 0xE6 -.set G_RDPPIPESYNC, 0xE7 -.set G_RDPTILESYNC, 0xE8 -.set G_RDPFULLSYNC, 0xE9 -.set G_LOADTLUT, 0xF0 -.set G_SETTILESIZE, 0xF2 -.set G_LOADBLOCK, 0xF3 -.set G_SETTILE, 0xF5 -.set G_FILLRECT, 0xF6 -.set G_SETFILLCOLOR, 0xF7 -.set G_SETFOGCOLOR, 0xF8 -.set G_SETBLENDCOLOR, 0xF9 -.set G_SETPRIMCOLOR, 0xFA -.set G_SETENVCOLOR, 0xFB -.set G_SETCOMBINE, 0xFC -.set G_SETTIMG, 0xFD -.endif - -/* Arguments */ - -/* gSPMatrix */ -.ifdef F3DEX_GBI_2 -.set G_MTX_MODELVIEW, 0x00 -.set G_MTX_PROJECTION, 0x04 -.set G_MTX_MUL, 0x00 -.set G_MTX_LOAD, 0x02 -.set G_MTX_NOPUSH, 0x00 -.set G_MTX_PUSH, 0x01 - -.else /* F3D and F3DEX */ -.set G_MTX_MODELVIEW, 0x00 -.set G_MTX_PROJECTION, 0x01 -.set G_MTX_MUL, 0x00 -.set G_MTX_LOAD, 0x02 -.set G_MTX_NOPUSH, 0x00 -.set G_MTX_PUSH, 0x04 -.endif - -/* gSPLight */ -.ifdef F3DEX_GBI_2 -.set G_MVO_L0, (2*24) -.else -.set G_MV_L0, 0x86 -.endif - -/* gSPDisplayList / gSPBranchDisplayList */ -.set G_DL_PUSH, 0x00 -.set G_DL_NOPUSH, 0x01 - -/* gSPXGeometryMode */ -.ifdef F3DEX_GBI_2 -.set G_ZBUFFER, 0x00000001 -.set G_SHADE, 0x00000004 -.set G_SHADING_SMOOTH, 0x00200000 -.set G_CULL_FRONT, 0x00000200 -.set G_CULL_BACK, 0x00000400 -.set G_FOG, 0x00010000 -.set G_LIGHTING, 0x00020000 -.set G_TEXTURE_GEN, 0x00040000 -.set G_TEXTURE_GEN_LINEAR, 0x00080000 - -.else /* F3D and F3DEX */ -.set G_ZBUFFER, 0x00000001 -.set G_SHADE, 0x00000004 -.set G_SHADING_SMOOTH, 0x00000200 -.set G_CULL_FRONT, 0x00001000 -.set G_CULL_BACK, 0x00002000 -.set G_FOG, 0x00010000 -.set G_LIGHTING, 0x00020000 -.set G_TEXTURE_GEN, 0x00040000 -.set G_TEXTURE_GEN_LINEAR, 0x00080000 -.endif - -/* - * Used for matching F3DEX2-style geometry mode usage. - * Ignored when building with Fast3DEX2. - */ -.set G_ORDER_SFIRST, 0 -.set G_ORDER_CFIRST, 1 - -/* gSPSetOtherMode (L) */ -.set G_MDSFT_ALPHACOMPARE, 0 -.set G_MDSFT_ZSRCSEL, 2 -.set G_MDSFT_RENDERMODE, 3 -.set G_MDSFT_BLENDER, 16 - -.set G_AC_NONE, (0 << G_MDSFT_ALPHACOMPARE) -.set G_AC_THRESHOLD, (1 << G_MDSFT_ALPHACOMPARE) -.set G_AC_DITHER, (3 << G_MDSFT_ALPHACOMPARE) - -.set G_ZS_PIXEL, (0 << G_MDSFT_ZSRCSEL) -.set G_ZS_PRIM, (1 << G_MDSFT_ZSRCSEL) - -/************************* Set Render Mode *************************/ - -/* Cycle-Independent Blender Settings */ - -.set AA_EN, 0x8 -.set Z_CMP, 0x10 -.set Z_UPD, 0x20 -.set IM_RD, 0x40 -.set CLR_ON_CVG, 0x80 -.set CVG_DST_CLAMP, 0 -.set CVG_DST_WRAP, 0x100 -.set CVG_DST_FULL, 0x200 -.set CVG_DST_SAVE, 0x300 -.set ZMODE_OPA, 0 -.set ZMODE_INTER, 0x400 -.set ZMODE_XLU, 0x800 -.set ZMODE_DEC, 0xc00 -.set CVG_X_ALPHA, 0x1000 -.set ALPHA_CVG_SEL, 0x2000 -.set FORCE_BL, 0x4000 -.set TEX_EDGE, 0x0000 /* used to be 0x8000 */ - -/* Cycle-Dependent Blender Settings */ -/* Blender runs the formula: (P * A + M - B) / (A + B) */ -/* P and M values */ -.set G_BL_CLR_IN, 0 /* 1st cycle: get color from input pixel. - 2nd cycle: param is the numerator of the formula as computed for the first cycle. */ -.set G_BL_CLR_MEM, 1 /* Takes color from the framebuffer */ -.set G_BL_CLR_BL, 2 /* Takes color from the blend color register */ -.set G_BL_CLR_FOG, 3 /* Takes color from the fog color register */ -/* A values */ -.set G_BL_A_IN, 0 /* Parameter is alpha value of input pixel */ -.set G_BL_A_FOG, 1 /* Alpha value from the fog color register */ -.set G_BL_A_SHADE, 2 /* Calculated alpha value for the pixel, presumably */ -/* B values */ -.set G_BL_1MA, 0 /* 1.0 - source alpha */ -.set G_BL_A_MEM, 1 /* Framebuffer alpha value */ -.set G_BL_1, 2 /* Constant 1.0 */ -/* A and B values */ -.set G_BL_0, 3 /* Constant 0.0 */ - -.macro .BL_DEPENDENT_SETTING label, p, a, m, b - .set \label\()_CYCLE1, ((\p << 30) | (\a << 26) | (\m << 22) | (\b << 18)) - .set \label\()_CYCLE2, ((\p << 28) | (\a << 24) | (\m << 20) | (\b << 16)) -.endm - -.macro .BL_DEPENDENT_SETTING_CYCLE1_ONLY label, p, a, m, b - .set \label, ((\p << 30) | (\a << 26) | (\m << 22) | (\b << 18)) -.endm - -.BL_DEPENDENT_SETTING BL_DEP_SETTING_ZERO, G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_IN, G_BL_1MA /* Basically (0, 0, 0 ,0) */ - -/* Properly label these later! */ -.BL_DEPENDENT_SETTING BL_DEP_SETTING_1, G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM -.BL_DEPENDENT_SETTING BL_DEP_SETTING_2, G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA -.BL_DEPENDENT_SETTING BL_DEP_SETTING_3, G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1 -.BL_DEPENDENT_SETTING BL_DEP_SETTING_4, G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1 -.BL_DEPENDENT_SETTING BL_DEP_SETTING_5, G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM - -.BL_DEPENDENT_SETTING_CYCLE1_ONLY BL_DEP_SETTING_FOG_SHADE_A, G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA -.BL_DEPENDENT_SETTING_CYCLE1_ONLY BL_DEP_SETTING_FOG_PRIM_A, G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA -.BL_DEPENDENT_SETTING_CYCLE1_ONLY BL_DEP_SETTING_PASS, G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1 - -.macro .SET_RENDER_MODE label, indeptSettings, deptSettings - .set \label , (\indeptSettings | \deptSettings\()_CYCLE1) - .set \label\()2 , (\indeptSettings | \deptSettings\()_CYCLE2) -.endm - -/* TODO: Make these more readable */ -.SET_RENDER_MODE G_RM_AA_ZB_OPA_SURF, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_RA_ZB_OPA_SURF, (AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_ZB_XLU_SURF, (AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_XLU), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_OPA_DECAL, (AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ALPHA_CVG_SEL | ZMODE_DEC), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_RA_ZB_OPA_DECAL, (AA_EN | Z_CMP | CVG_DST_WRAP | ALPHA_CVG_SEL | ZMODE_DEC), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_ZB_XLU_DECAL, (AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_DEC), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_OPA_INTER, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ALPHA_CVG_SEL | ZMODE_INTER), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_RA_ZB_OPA_INTER, (AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ALPHA_CVG_SEL | ZMODE_INTER), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_ZB_XLU_INTER, (AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_INTER), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_XLU_LINE, (AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_XLU), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_DEC_LINE, (AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_DEC), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_TEX_EDGE, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_ZB_TEX_INTER, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_INTER | TEX_EDGE), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_ZB_SUB_SURF, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_ZB_PCL_SURF, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | G_AC_DITHER), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_OPA_TERR, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_TEX_TERR, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_ZB_SUB_TERR, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_OPA_SURF, (AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_RA_OPA_SURF, (AA_EN | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_XLU_SURF, (AA_EN | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_XLU_LINE, (AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_DEC_LINE, (AA_EN | IM_RD | CVG_DST_FULL | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_TEX_EDGE, (AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_SUB_SURF, (AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_AA_PCL_SURF, (AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | G_AC_DITHER), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_OPA_TERR, (AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_TEX_TERR, (AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_AA_SUB_TERR, (AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_ZB_OPA_SURF, (Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_OPA), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_ZB_XLU_SURF, (Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_ZB_OPA_DECAL, (Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC), BL_DEP_SETTING_1 -.SET_RENDER_MODE G_RM_ZB_XLU_DECAL, (Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_ZB_CLD_SURF, (Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_ZB_OVL_SURF, (Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_ZB_PCL_SURF, (Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | G_AC_DITHER), BL_DEP_SETTING_3 -.SET_RENDER_MODE G_RM_OPA_SURF, (CVG_DST_CLAMP | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_3 -.SET_RENDER_MODE G_RM_XLU_SURF, (IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_TEX_EDGE, (CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | TEX_EDGE | AA_EN), BL_DEP_SETTING_3 -.SET_RENDER_MODE G_RM_CLD_SURF, (IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_2 -.SET_RENDER_MODE G_RM_PCL_SURF, (CVG_DST_FULL | FORCE_BL | ZMODE_OPA | G_AC_DITHER), BL_DEP_SETTING_3 -.SET_RENDER_MODE G_RM_ADD, (IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA), BL_DEP_SETTING_4 -.SET_RENDER_MODE G_RM_NOOP, (0), BL_DEP_SETTING_ZERO -.SET_RENDER_MODE G_RM_VISCVG, (IM_RD | FORCE_BL), BL_DEP_SETTING_5 -.SET_RENDER_MODE G_RM_OPA_CI, (CVG_DST_CLAMP | ZMODE_OPA), BL_DEP_SETTING_3 - -/* Custom version of G_RM_AA_ZB_XLU_SURF with Z_UPD */ -.SET_RENDER_MODE G_RM_CUSTOM_AA_ZB_XLU_SURF, (AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_XLU), BL_DEP_SETTING_2 - -/* Special mode types only for mode 1 */ -.set G_RM_FOG_SHADE_A, BL_DEP_SETTING_FOG_SHADE_A -.set G_RM_FOG_PRIM_A, BL_DEP_SETTING_FOG_PRIM_A -.set G_RM_PASS, BL_DEP_SETTING_PASS - -/*******************************************************************/ - -/* gSPSetOtherMode (H) */ -.set G_MDSFT_ALPHADITHER, 4 -.set G_MDSFT_RGBDITHER, 6 -.set G_MDSFT_COMBKEY, 8 -.set G_MDSFT_TEXTCONV, 9 -.set G_MDSFT_TEXTFILT, 12 -.set G_MDSFT_TEXTLUT, 14 -.set G_MDSFT_TEXTLOD, 16 -.set G_MDSFT_TEXTDETAIL, 17 -.set G_MDSFT_TEXTPERSP, 19 -.set G_MDSFT_CYCLETYPE, 20 -.set G_MDSFT_PIPELINE, 23 - -.set G_CYC_1CYCLE, (0 << G_MDSFT_CYCLETYPE) -.set G_CYC_2CYCLE, (1 << G_MDSFT_CYCLETYPE) -.set G_CYC_COPY, (2 << G_MDSFT_CYCLETYPE) -.set G_CYC_FILL, (3 << G_MDSFT_CYCLETYPE) - -.set G_TP_NONE, (0 << G_MDSFT_TEXTPERSP) -.set G_TP_PERSP, (1 << G_MDSFT_TEXTPERSP) - -.set G_TD_CLAMP, (0 << G_MDSFT_TEXTDETAIL) -.set G_TD_SHARPEN, (1 << G_MDSFT_TEXTDETAIL) -.set G_TD_DETAIL, (2 << G_MDSFT_TEXTDETAIL) - -.set G_TL_TILE, (0 << G_MDSFT_TEXTLOD) -.set G_TL_LOD, (1 << G_MDSFT_TEXTLOD) - -.set G_TT_NONE, (0 << G_MDSFT_TEXTLUT) -.set G_TT_RGBA16, (2 << G_MDSFT_TEXTLUT) -.set G_TT_IA16, (3 << G_MDSFT_TEXTLUT) - -.set G_TF_POINT, (0 << G_MDSFT_TEXTFILT) -.set G_TF_AVERAGE, (3 << G_MDSFT_TEXTFILT) -.set G_TF_BILERP, (2 << G_MDSFT_TEXTFILT) - -.set G_TC_CONV, (0 << G_MDSFT_TEXTCONV) -.set G_TC_FILTCONV, (5 << G_MDSFT_TEXTCONV) -.set G_TC_FILT, (6 << G_MDSFT_TEXTCONV) - -.set G_CK_NONE, (0 << G_MDSFT_COMBKEY) -.set G_CK_KEY, (1 << G_MDSFT_COMBKEY) - -.set G_CD_MAGICSQ, (0 << G_MDSFT_RGBDITHER) -.set G_CD_BAYER, (1 << G_MDSFT_RGBDITHER) -.set G_CD_NOISE, (2 << G_MDSFT_RGBDITHER) - -/* gDPSetTile */ -.set G_TX_LOADTILE, 0x7 -.set G_TX_RENDERTILE, 0x0 - -/* axis clamp and mirror flags */ -.set G_TX_NOMIRROR, 0x0 -.set G_TX_WRAP, 0x0 -.set G_TX_MIRROR, 0x1 -.set G_TX_CLAMP, 0x2 - -/* mask flags */ -.set G_TX_NOMASK, 0x0 - -/* shift flags */ -.set G_TX_NOLOD, 0x0 - -/* gDPSetCombine */ -.set G_CCMUX_COMBINED, 0 -.set G_CCMUX_TEXEL0, 1 -.set G_CCMUX_TEXEL1, 2 -.set G_CCMUX_PRIMITIVE, 3 -.set G_CCMUX_SHADE, 4 -.set G_CCMUX_ENVIRONMENT, 5 -.set G_CCMUX_CENTER, 6 -.set G_CCMUX_SCALE, 6 -.set G_CCMUX_COMBINED_ALPHA, 7 -.set G_CCMUX_TEXEL0_ALPHA, 8 -.set G_CCMUX_TEXEL1_ALPHA, 9 -.set G_CCMUX_PRIMITIVE_ALPHA, 10 -.set G_CCMUX_SHADE_ALPHA, 11 -.set G_CCMUX_ENV_ALPHA, 12 -.set G_CCMUX_LOD_FRACTION, 13 -.set G_CCMUX_PRIM_LOD_FRAC, 14 -.set G_CCMUX_NOISE, 7 -.set G_CCMUX_K4, 7 -.set G_CCMUX_K5, 15 -.set G_CCMUX_1, 6 -.set G_CCMUX_0, 31 - -/* alpha combiner */ -.set G_ACMUX_COMBINED, 0 -.set G_ACMUX_TEXEL0, 1 -.set G_ACMUX_TEXEL1, 2 -.set G_ACMUX_PRIMITIVE, 3 -.set G_ACMUX_SHADE, 4 -.set G_ACMUX_ENVIRONMENT, 5 -.set G_ACMUX_LOD_FRACTION, 0 -.set G_ACMUX_PRIM_LOD_FRAC, 6 -.set G_ACMUX_1, 6 -.set G_ACMUX_0, 7 - -/* gDPSetTextureImage */ -/* fmt */ -.set G_IM_FMT_RGBA, 0x00 -.set G_IM_FMT_YUV, 0x01 -.set G_IM_FMT_CI, 0x02 -.set G_IM_FMT_IA, 0x03 -.set G_IM_FMT_I, 0x04 - -/* size */ -.set G_IM_SIZ_4b, 0x00 -.set G_IM_SIZ_8b, 0x01 -.set G_IM_SIZ_16b, 0x02 -.set G_IM_SIZ_32b, 0x03 - -.set G_TX_DXT_FRAC, 11 -.set G_TEXTURE_IMAGE_FRAC, 2 - -/* gDPLoadBlock*/ -.set G_TX_DXT_FRAC, 11 -.set G_TEXTURE_IMAGE_FRAC, 2 - -/* gSPNumLights / gSPFogFactor */ - -/* Index in DMEM table */ -.set G_MW_NUMLIGHT, 0x02 -.set G_MW_FOG, 0x08 -.set G_MW_PERSPNORM, 0x0E - -/* Offsets in DMEM table */ -.set G_MWO_NUMLIGHT, 0x00 -.set G_MWO_FOG, 0x00 - -/* Parameter for gsSPNumLights; not really needed but is good for formality. */ -.set NUMLIGHTS_0, 1 -.set NUMLIGHTS_1, 1 -.set NUMLIGHTS_2, 2 -.set NUMLIGHTS_3, 3 -.set NUMLIGHTS_4, 4 -.set NUMLIGHTS_5, 5 -.set NUMLIGHTS_6, 6 -.set NUMLIGHTS_7, 7 - -/* GBI macros */ - -/* gsMoveWd */ -.macro gsMoveWd index, offset, data - .ifdef F3DEX_GBI_2 - .word G_MOVEWORD << 24 | ((\index & 0xFF) << 16) | (\offset & 0xFFFF) - .else - .word G_MOVEWORD << 24 | ((\offset & 0xFFFF) << 8) | (\index & 0xFF) - .endif - .word \data -.endm - -.set G_MWO_NUMLIGHT, 0x00 -/* - * gSPNumLights - * Parameter: - * n = NUMLIGHTS_* (ranges from 0 to 7) - */ -.macro gsSPNumLights n - .ifdef F3DEX_GBI_2 - gsMoveWd G_MW_NUMLIGHT, G_MWO_NUMLIGHT, (\n * 24) - .else - gsMoveWd G_MW_NUMLIGHT, G_MWO_NUMLIGHT, ((\n + 1) * 32 + 0x80000000) - .endif -.endm - -/* gSPMatrix */ -.macro gsSPMatrix matrix, params - .ifdef F3DEX_GBI_2 - gsDma3p G_MTX, 0x38, 0, (\params ^ G_MTX_PUSH), \matrix - .else /* Fast3D and Fast3DEX */ - gsDma1p G_MTX, \matrix, 64, \params - .endif -.endm - -/* gSPLight */ -.macro gsSPLight light, num - .ifdef F3DEX_GBI_2 - gsDma3p G_MOVEMEM, 8, ((G_MVO_L0+((\num-1)*24))/8), 10, \light - .else /* Fast3D and Fast3DEX */ - gsDma1p G_MOVEMEM, \light, 16, ((\num)-1)*2+G_MV_L0 - .endif -.endm - -/* gSPVertex */ -.macro gsSPVertex verts, num, index - .ifdef F3DEX_GBI_2 - .word (G_VTX << 24) | ((\num & 0xFF) << 12) | (((\index+\num) & 0x7F) << 1) - .word \verts - .else /* Fast3D and Fast3DEX */ - .ifdef F3DEX_GBI - gsDma1p G_VTX, \verts, (\num)<<10|(16*(\num)-1), (2*\index) - .else /* Fast3D */ - gsDma1p G_VTX, \verts, 16*\num, ((\num)-1)<<4|(\index) - .endif - .endif -.endm - -/* - * gSPGeometryMode - * In Fast3DEX2 it is better to use this, as the RSP geometry mode - * is able to be set and cleared in a single command. - */ -.macro gsSPGeometryMode cc, ff, order - .ifdef F3DEX_GBI_2 - .word (G_GEOMETRYMODE << 24) | ((~(\cc)) & 0x00FFFFFF) - .word \ff - .else - .if \order == 0 - gsSPSetGeometryMode \ff - gsSPClearGeometryMode \cc - .else - gsSPClearGeometryMode \cc - gsSPSetGeometryMode \ff - .endif - .endif -.endm - -/* gSPSetGeometryMode */ -.macro gsSPSetGeometryMode, flags - .ifdef F3DEX_GBI_2 - .word (G_GEOMETRYMODE << 24) | 0x00FFFFFF - .word \flags - .else /* Fast3D and Fast3DEX */ - .word G_SETGEOMETRYMODE << 24 - .word \flags - .endif -.endm - -/* gSPClearGeometryMode */ -.macro gsSPClearGeometryMode, flags - .ifdef F3DEX_GBI_2 - .word (G_GEOMETRYMODE << 24) | ((~(\flags)) & 0x00FFFFFF) - .word 0 - .else /* Fast3D and Fast3DEX */ - .word G_CLEARGEOMETRYMODE << 24 - .word \flags - .endif -.endm - -/* gSPPerspNormalize */ -.macro gsSPPerspNormalize, perspNorm - .ifndef F3D_OLD - gsMoveWd G_MW_PERSPNORM, 0, \perspNorm - .else - gsImmp1 G_RDPHALF_1, \perspNorm - .endif -.endm - -/* gSPEndDisplayList */ -.macro gsSPEndDisplayList - f3d_noparam G_ENDDL -.endm - -/* gSPSetOtherMode */ -.macro gsSPSetOtherMode cmd, sft, len, data - .ifdef F3DEX_GBI_2 - .word ((\cmd & 0xFF) << 24) | ((32 - (\sft & 0xFF) - (\len & 0xFF)) << 8) | ((\len-1) & 0xFF) - .word \data - .else /* Fast3D and Fast3DEX2 */ - .word ((\cmd & 0xFF) << 24) | ((\sft & 0xFF) << 8) | (\len & 0xFF) - .word \data - .endif -.endm - -.macro gsSPTexture scaleS, scaleT, level, tile, enable - .ifdef F3DEX_GBI_2 - .word (G_TEXTURE << 24) | ((\level & 0x7) << 11) | ((\tile & 0x7) << 8) | (\enable*2) - .word ((\scaleS & 0xFFFF) << 16) | (\scaleT & 0xFFFF) - .else /* Fast3D and Fast3DEX */ - .word (G_TEXTURE << 24) | ((\level & 0x7) << 11) | ((\tile & 0x7) << 8) | \enable - .word ((\scaleS & 0xFFFF) << 16) | (\scaleT & 0xFFFF) - .endif -.endm - -/* gSPSetRenderMode */ -.macro gsDPSetRenderMode cycle1Mode, cycle2Mode - gsSPSetOtherMode G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \cycle1Mode | \cycle2Mode -.endm - -/* gDPSetTexturePersp */ -.macro gsDPSetTexturePersp type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, \type -.endm - -/* gDPSetCycleType */ -.macro gsDPSetCycleType type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, \type -.endm - -/* gDPSetTextureDetail */ -.macro gsDPSetTextureDetail type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, \type -.endm - -/* gDPSetTextureLOD*/ -.macro gsDPSetTextureLOD type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, \type -.endm - -/* gDPSetTextureTLUT */ -.macro gsDPSetTextureLUT type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, \type -.endm - -/* gDPSetTextureFilter */ -.macro gsDPSetTextureFilter type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, \type -.endm - -/* gDPSetTextureConvert */ -.macro gsDPSetTextureConvert type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, \type -.endm - -/* gDPSetCombineKey */ -.macro gsDPSetCombineKey type - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, \type -.endm - -/* gDPSetColorDither */ -.macro gsDPSetColorDither mode - gsSPSetOtherMode G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, \mode -.endm - -/* gsDPSetAlphaCompare */ -.macro gsDPSetAlphaCompare type - gsSPSetOtherMode G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, \type -.endm - -/* gDPSetDepthSource */ -.macro gsDPSetDepthSource src - gsSPSetOtherMode G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, \src -.endm - -/* gSPDisplayList */ -.macro gsSPDisplayList dl - gsDma1p G_DL, \dl, 0, G_DL_PUSH -.endm - -/* gSPBranchDisplayList */ -.macro gsSPBranchList dl - gsDma1p G_DL, \dl, 0, G_DL_NOPUSH -.endm - -/* - * gSP1Triangle - * Note: flag has no effect on this implementation of gSP1Triangle. - */ -.macro gsSP1Triangle v0, v1, v2, flag - .ifndef F3DEX_GBI_2 - .word G_TRI1 << 24 - .ifdef F3DEX_GBI /* Fast3DEX */ - .word (\v0*2 << 16) | (\v1*2 << 8) | \v2*2 - .else /* Fast3D */ - .word (\v0*10 << 16) | (\v1*10 << 8) | \v2*10 - .endif - .else /* Fast3DEX2 */ - .byte G_TRI1, \v0*2, \v1*2, \v2*2 - .word 0 - .endif -.endm - -/* - * gSP2Triangles - * Note: flag has no effect on this implementation of gSP2Triangles. - */ -.macro gsSP2Triangles v0, v1, v2, flag0, v3, v4, v5, flag1 - .ifdef F3DEX_GBI_SHARED /* Fast3DEX and Fast3DEX2 have the same G_TRI2 syntax. */ - .word (G_TRI2 << 24) | (\v0*2 << 16) | (\v1*2 << 8) | \v2*2 - .word (0x00 << 24) | (\v3*2 << 16) | (\v4*2 << 8) | \v5*2 - .else /* Backwards compatibility with Fast3D. */ - gsSP1Triangle \v0, \v1, \v2, \flag0 - gsSP1Triangle \v3, \v4, \v5, \flag1 - .endif -.endm - -/* gDPNoOp */ -.macro gsDPNoOp - f3d_noparam G_NOOP -.endm - -/* gSPTextureRectangle */ -.macro gsSPTextureRectangle xl, yl, xh, yh, tile, s, t, dsdx, dtdy - .word (G_TEXRECT << 24) | (\xh << 12) | \yh - .word (\tile << 24) | (\xl << 12) | \yl - .ifdef F3D_OLD - .word (G_RDPHALF_2 << 24) - .else - .word (G_RDPHALF_1 << 24) - .endif - .word (\s << 16) | \t - .ifdef F3D_OLD - .word (G_RDPHALF_CONT << 24) - .else - .word (G_RDPHALF_2 << 24) - .endif - .word (\dsdx << 16) | \dtdy -.endm - -/* gDPLoadSync */ -.macro gsDPLoadSync - f3d_noparam G_RDPLOADSYNC -.endm - -/* gDPPipeSync*/ -.macro gsDPPipeSync - f3d_noparam G_RDPPIPESYNC -.endm - -/* gDPFullSync*/ -.macro gsDPFullSync - f3d_noparam G_RDPFULLSYNC -.endm - -/* gDPLoadTLUTCmd */ -.macro gsDPLoadTLUTCmd tile, count - .word G_LOADTLUT << 24 - .word ((\tile & 0x7) << 24) | ((\count - 1) & 0x3FF) << 14 -.endm - -/* gDPTileSync */ -.macro gsDPTileSync - f3d_noparam G_RDPTILESYNC -.endm - -/* gDPSetTileSize */ -.macro gsDPSetTileSize tile, uls, ult, lrs, lrt - .word (G_SETTILESIZE << 24) | ((\uls & 0x0FFF) << 12) | (\ult & 0x0FFF) - .word ((\tile & 0x7) << 24) | ((\lrs & 0x0FFF) << 12) | (\lrt & 0x0FFF) -.endm - -/* gsDPLoadBlock */ -.macro gsDPLoadBlock tile, uls, ult, lrs, dxt - .word (G_LOADBLOCK << 24) | ((\uls & 0x0FFF) << 12) | (\ult & 0x0FFF) - .word ((\tile & 0x7) << 24) | ((\lrs & 0x0FFF) << 12) | (\dxt & 0x0FFF) -.endm - -/* gDPSetTile */ -.macro gsDPSetTile fmt, siz, line, tmem, tile, palette, cmt, maskt, shiftt, cms, masks, shifts - .word (G_SETTILE << 24) | ((\fmt & 0x7) << 21) | ((\siz & 0x3) << 19) | ((\line & 0x1FF) << 9) | (\tmem & 0x1FF) - .word ((\tile & 0x7) << 24) | ((\palette & 0xF) << 20) | ((\cmt & 0x3) << 18) | ((\maskt & 0xF) << 14) | ((\shiftt & 0xF) << 10) | ((\cms & 0x3) << 8) | ((\masks & 0xF) << 4) | (\shifts & 0xF) -.endm - -/* gDPFillRectangle */ -.macro gsDPFillRectangle ulx, uly, lrx, lry - .word (G_FILLRECT << 24) | ((\lrx & 0x3FF) << 14) | ((\lry & 0x3FF) << 2) - .word ((\ulx & 0x3FF) << 14) | ((\uly & 0x3FF) << 2) -.endm - -/* gDPSetFillColor */ -.macro gsDPSetFillColor fillValue - .word G_SETFILLCOLOR << 24 - .word \fillValue -.endm - -/* gDPSetFogColor */ -.macro gsDPSetFogColor r, g, b, a - sDPRGBColor G_SETFOGCOLOR, \r, \g, \b, \a -.endm - -/* gDPSetBlendColor */ -.macro gsDPSetBlendColor r, g, b, a - sDPRGBColor G_SETBLENDCOLOR, \r, \g, \b, \a -.endm - -/* gDPSetPrimColor */ -.macro gsDPSetPrimColor m, l, r, g, b, a - .word (G_SETPRIMCOLOR << 24) | ((\m & 0xFF) << 8) | (\l & 0xFF) - .word (\r << 24) | (\g << 16) | (\b << 8) | \a -.endm - -/* gDPSetEnvColor */ -.macro gsDPSetEnvColor r, g, b, a - sDPRGBColor G_SETENVCOLOR, \r, \g, \b, \a -.endm - -/* gDPSetCombine */ -.macro gsDPSetCombine muxs0, muxs1 - .word (G_SETCOMBINE << 24) | (\muxs0 & 0x00FFFFFF) - .word \muxs1 -.endm - -/* gDPSetCombineMode */ -.macro gsDPSetCombineModeLERP a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1 - .word (G_SETCOMBINE << 24) | ((\a0 & 0xF) << 20) | ((\c0 & 0x1F) << 15) | ((\Aa0 & 0x7) << 12) | ((\Ac0 & 0x7) << 9) | ((\a1 & 0xF) << 5) | (\c1 & 0x1F) - .word ((\b0 & 0xF) << 28) | ((\b1 & 0xF) << 24) | ((\Aa1 & 0x7) << 21) | ((\Ac1 & 0x7) << 18) | ((\d0 & 0x7) << 15) | ((\Ab0 & 0x7) << 12) | ((\Ad0 & 0x7) << 9) | ((\d1 & 0x7) << 6) | ((\Ab1 & 0x7) << 3) | (\Ad1 & 0x7) -.endm - -/* gDPSetCombineMode1Cycle */ -.macro gsDPSetCombineModeLERP1Cycle a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0 - gsDPSetCombineModeLERP \a0, \b0, \c0, \d0, \Aa0, \Ab0, \Ac0, \Ad0, \a0, \b0, \c0, \d0, \Aa0, \Ab0, \Ac0, \Ad0 -.endm - -/* gDPSetTextureImage */ -.macro gsDPSetTextureImage fmt, size, width, segAddr - .word (G_SETTIMG << 24) | ((\fmt & 0x7) << 21) | ((\size & 0x3) << 19) | ((\width-1) & 0x0FFF) - .word \segAddr -.endm - -/* gDPLoadTextureBlock */ -/* Calculate gDPLoadBlock for 8, 16, and 32 bit textures */ -.macro _calc_gsDPLoadBlockNot4b width, height, shift, incr, byteSize - .if (((\width * \byteSize) / 8) > 1) /* result of TXL2WORDS is greater than 1 */ - gsDPLoadBlock G_TX_LOADTILE, 0, 0, (((\width * \height) + \incr) >> \shift) - 1, (((1 << G_TX_DXT_FRAC) + ((\width * \byteSize) / 8) - 1) / ((\width * \byteSize) / 8)) - .else /* result of TXL2WORDS is 1 */ - gsDPLoadBlock G_TX_LOADTILE, 0, 0, (((\width * \height) + \incr) >> \shift) - 1, (1 << G_TX_DXT_FRAC) - .endif -.endm - -/* Calculate gDPLoadBlock for 4-bit textures */ -.macro _calc_gsDPLoadBlock4b width, height - .if ((\width / 16) > 1) /* result of TXL2WORDS_4b is greater than 1 */ - gsDPLoadBlock G_TX_LOADTILE, 0, 0, (((\width * \height) + 3) >> 2) - 1, (((1 << G_TX_DXT_FRAC) + (\width / 16) - 1) / (\width / 16)) - .else /* result of TXL2WORDS_4b is 1 */ - gsDPLoadBlock G_TX_LOADTILE, 0, 0, (((\width * \height) + 3) >> 2) - 1, (1 << G_TX_DXT_FRAC) - .endif -.endm - -/* Calculate gDPLoadBlock using texture bit size, width, and height */ -.macro _calc_gsDPLoadBlock siz, width, height - .if (\siz == G_IM_SIZ_4b) - _calc_gsDPLoadBlock4b \width, \height - .elseif (\siz == G_IM_SIZ_8b) - _calc_gsDPLoadBlockNot4b \width, \height, 1, 1, 1 - .elseif (\siz == G_IM_SIZ_16b) - _calc_gsDPLoadBlockNot4b \width, \height, 0, 0, 2 - .elseif (\siz == G_IM_SIZ_32b) - _calc_gsDPLoadBlockNot4b \width, \height, 0, 0, 4 - .endif -.endm - -/* - * gDPLoadTextureBlock is a macro that allows you to easily load a texture in the f3d family of ucodes - * Parameters: - * timg = label to the texture data - * fmt = image format (G_IM_FMT_RGBA, G_IM_FMT_CI, G_IM_FMT_IA, G_IM_FMT_I, or G_IM_FMT_YUV) - * siz = bits per pixel (G_IM_SIZ_4b, G_IM_SIZ_8b, G_IM_SIZ_16b, or G_IM_SIZ_32b) - * width = width of the texture in pixels - * height = height of the texture in pixels - * pal = palette id to use if using G_IM_FMT_CI, otherwise it should be 0. - * cms = Clamp & Mirror flags for the S axis - * cmt = Clamp & Mirror flags for the T axis - * masks = Sets how much of the S axis is shown before clamping. This is usually just log2(width). - * maskt = Sets how much of the T axis is shown before clamping. This is usually just log2(height). - * shifts = Sets the amount to shift S axis values after perspective division. This is usually G_TX_NOLOD. - * shiftt = Sets the amount to shift T axis values after perspective division. This is usually G_TX_NOLOD. - */ -.macro gsDPLoadTextureBlock timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt - .if (\siz == G_IM_SIZ_32b) - gsDPSetTextureImage \fmt, \siz, 1, \timg - gsDPSetTile \fmt, \siz, 0, 0, G_TX_LOADTILE, 0, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - .else - gsDPSetTextureImage \fmt, G_IM_SIZ_16b, 1, \timg - gsDPSetTile \fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - .endif - - gsDPLoadSync - _calc_gsDPLoadBlock \siz, \width, \height - gsDPPipeSync - - .if (\siz == G_IM_SIZ_4b) - gsDPSetTile \fmt, \siz, (7 >> 3), 0, G_TX_RENDERTILE, \pal, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - .elseif (\siz == G_IM_SIZ_8b) - gsDPSetTile \fmt, \siz, ((\width + 7) >> 3), 0, G_TX_RENDERTILE, \pal, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - .else - gsDPSetTile \fmt, \siz, (((\width * 2) + 7) >> 3), 0, G_TX_RENDERTILE, \pal, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - .endif - - gsDPSetTileSize G_TX_RENDERTILE, 0, 0, ((\width - 1) << G_TEXTURE_IMAGE_FRAC), ((\height - 1) << G_TEXTURE_IMAGE_FRAC) -.endm - -/* - * gDPLoadTLUT_pal16, loads 16 colors into the TLUT - * Parameters: - * pal = palette number to use. - * timg_pal = label to palette data - */ -.macro gsDPLoadTLUT_pal16 pal, timg_pal - gsDPSetTextureImage G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, \timg_pal - gsDPTileSync - gsDPSetTile 0, 0, 0, (256+(((\pal)&0xf)*16)), G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0 - gsDPLoadSync - gsDPLoadTLUTCmd G_TX_LOADTILE, 16 - gsDPPipeSync -.endm - -/* - * gDPLoadTLUT_pal256, loads 256 colors into the TLUT - * Parameters: - * timg_pal = label to palette data - */ -.macro gsDPLoadTLUT_pal256 timg_pal - gsDPSetTextureImage G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, \timg_pal - gsDPTileSync - gsDPSetTile 0, 0, 0, 256, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0 - gsDPLoadSync - gsDPLoadTLUTCmd G_TX_LOADTILE, 256 - gsDPPipeSync -.endm - -/* - * gDPLoadTextureBlock_4b is a macro that allows you to easily load a 4-bit texture in the Fast3D family of ucodes. - * Parameters: - * timg = label to the texture data - * fmt = image format (G_IM_FMT_RGBA, G_IM_FMT_CI, G_IM_FMT_IA, G_IM_FMT_I, or G_IM_FMT_YUV) - * width = width of the texture in pixels - * height = height of the texture in pixels - * pal = palette id to use if using G_IM_FMT_CI, otherwise it should be 0. - * cms = Clamp & Mirror flags for the S axis - * cmt = Clamp & Mirror flags for the T axis - * masks = Sets how much of the S axis is shown before clamping. This is usually just log2(width). - * maskt = Sets how much of the T axis is shown before clamping. This is usually just log2(height). - * shifts = Sets the amount to shift S axis values after perspective division. This is usually G_TX_NOLOD. - * shiftt = Sets the amount to shift T axis values after perspective division. This is usually G_TX_NOLOD. - */ - -.macro gsDPLoadTextureBlock_4b timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt - gsDPSetTextureImage \fmt, G_IM_SIZ_16b, 1, \timg - gsDPSetTile \fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - gsDPLoadSync - _calc_gsDPLoadBlock4b \width, \height - gsDPPipeSync - gsDPSetTile \fmt, G_IM_SIZ_4b, ((((\width) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, \pal, \cmt, \maskt, \shiftt, \cms, \masks, \shifts - gsDPSetTileSize G_TX_RENDERTILE, 0, 0, ((\width) - 1) << G_TEXTURE_IMAGE_FRAC, ((\height) - 1) << G_TEXTURE_IMAGE_FRAC -.endm - -/* - * gSPFogFactor - * Parameters: - * fm = z multiplier - * fo = z offset - * - * FOG FORMULA: alpha(fog) = (eyespace z) * fm + fo (CLAMPED 0 to 255) - * note: (eyespace z) ranges [-1, 1] - */ -.macro gsSPFogFactor fm, fo - gsMoveWd G_MW_FOG, G_MWO_FOG, ((\fm & 0xFFFF) << 16) | (\fo & 0xFFFF) -.endm - -/* - * gSPFogPosition - * Parameters: - * min = Place where fog starts (0 at the near plane, and 1000 at the far plane) - * max = Place where fog saturates (0 at the near plane, and 1000 at the far plane) - * - * This macro will throw an error if min or max is outside the range [0, 1000] - * - * Note: The min can be larger than max, as that just makes objects fade when they - * get closer to the camera. - */ -.macro gsSPFogPosition min, max - .if (\min >= 0 && \min <= 1000 && \max >= 0 && \max <= 1000) - gsMoveWd G_MW_FOG, G_MWO_FOG, (((128000 / (\max - \min)) & 0xFFFF) << 16) | ((((500 - \min) * 256) / (\max - \min)) & 0xFFFF) - .elseif \min < 0 || \min > 1000 - .error "[gsSPFogPosition]: min should be in the range [0, 1000]" - .elseif \max < 0 || \max > 1000 - .error "[gsSPFogPosition]: max should be in the range [0, 1000]" - .endif -.endm diff --git a/src/include/PR/gbi_old.h b/src/include/PR/gbi_old.h deleted file mode 100644 index ebb6c7790..000000000 --- a/src/include/PR/gbi_old.h +++ /dev/null @@ -1,1612 +0,0 @@ -#ifndef _ULTRA64_GBI_H_ -#define _ULTRA64_GBI_H_ - -/* Types */ - -/* Vertex (set up for use with colors) */ -typedef struct -{ - short ob[3]; /* x, y, z */ - unsigned short flag; - short tc[2]; /* texture coord */ - unsigned char cn[4]; /* color & alpha */ -} Vtx_t; - -/* Vertex (set up for use with normals) */ -typedef struct -{ - short ob[3]; /* x, y, z */ - unsigned short flag; - short tc[2]; /* texture coord */ - signed char n[3]; /* normal */ - unsigned char a; /* alpha */ -} Vtx_tn; - -typedef union -{ - Vtx_t v; /* Use this one for colors */ - Vtx_tn n; /* Use this one for normals */ - long long int force_structure_alignment; -} Vtx; - - -typedef struct -{ - short vscale[4]; /* scale, 2 bits fraction */ - short vtrans[4]; /* translate, 2 bits fraction */ -} Vp_t; - -typedef union -{ - Vp_t vp; - long long int force_structure_alignment; -} Vp; - -typedef long int Mtx_t[4][4]; -typedef union -{ - Mtx_t m; - long long int force_structure_alignment; -} Mtx; - -typedef struct -{ - unsigned int w0; - unsigned int w1; -} Gwords; - -/* TODO: fill in the rest of the members */ -typedef union -{ - Gwords words; - long long int force_structure_alignment; -} Gfx; - -#define GPACK_RGBA5551(r, g, b, a) \ - ((((r) << 8) & 0xF800) | \ - (((g) << 3) & 0x07C0) | \ - (((b) >> 2) & 0x003E) | \ - ((a) & 0x0001)) -#define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) - -#define G_SPNOOP 0x00 -#define G_MTX 0x01 -#define G_MOVEMEM 0x03 -#define G_VTX 0x04 -#define G_DL 0x06 -#define G_LOAD_UCODE 0xAF -#define G_BRANCH_Z 0xB0 -#ifdef F3DEX_GBI -#define G_TRI2 0xB1 -#endif -#ifndef F3DEX_GBI -#define G_RDPHALF_CONT 0xB2 -#else -#define G_MODIFYVTX 0xB2 -#endif -#define G_RDPHALF_2 0xB3 -#define G_RDPHALF_1 0xB4 -#define G_QUAD 0xB5 -#define G_CLEARGEOMETRYMODE 0xB6 -#define G_SETGEOMETRYMODE 0xB7 -#define G_ENDDL 0xB8 -#define G_TEXTURE 0xBB -#define G_MOVEWORD 0xBC -#define G_POPMTX 0xBD -#define G_CULLDL 0xBE -#define G_TRI1 0xBF -#define G_NOOP 0xC0 -#define G_TEXRECT 0xE4 -#define G_TEXRECTFLIP 0xE5 -#define G_RDPLOADSYNC 0xE6 -#define G_RDPPIPESYNC 0xE7 -#define G_RDPTILESYNC 0xE8 -#define G_RDPFULLSYNC 0xE9 -#define G_SETKEYGB 0xEA -#define G_SETKEYR 0xEB -#define G_SETCONVERT 0xEC -#define G_SETSCISSOR 0xED -#define G_SETPRIMDEPTH 0xEE -#define G_RDPSETOTHERMODE 0xEF -#define G_LOADTLUT 0xF0 -#define G_SETTILESIZE 0xF2 -#define G_LOADBLOCK 0xF3 -#define G_LOADTILE 0xF4 -#define G_SETTILE 0xF5 -#define G_FILLRECT 0xF6 -#define G_SETFILLCOLOR 0xF7 -#define G_SETFOGCOLOR 0xF8 -#define G_SETBLENDCOLOR 0xF9 -#define G_SETPRIMCOLOR 0xFA -#define G_SETENVCOLOR 0xFB -#define G_SETCOMBINE 0xFC -#define G_SETTIMG 0xFD -#define G_SETZIMG 0xFE -#define G_SETCIMG 0xFF - -#define G_DL_PUSH 0x00 -#define G_DL_NOPUSH 0x01 - -/* SETOTHERMODE_L SHIFTS */ - -#define G_MDSFT_ALPHACOMPARE 0 -#define G_MDSFT_ZSRCSEL 2 -#define G_MDSFT_RENDERMODE 3 -#define G_MDSFT_BLENDER 16 - -/* SETOTHERMODE_H SHIFTS */ - -#define G_MDSFT_ALPHADITHER 4 -#define G_MDSFT_RGBDITHER 6 -#define G_MDSFT_COMBKEY 8 -#define G_MDSFT_TEXTCONV 9 -#define G_MDSFT_TEXTFILT 12 -#define G_MDSFT_TEXTLUT 14 -#define G_MDSFT_TEXTLOD 16 -#define G_MDSFT_TEXTDETAIL 17 -#define G_MDSFT_TEXTPERSP 19 -#define G_MDSFT_CYCLETYPE 20 -#define G_MDSFT_PIPELINE 23 - -#define G_ZBUFFER 0x00000001 -#define G_TEXTURE_ENABLE 0x00000002 -#define G_SHADE 0x00000004 -#define G_SHADING_SMOOTH 0x00000200 -#define G_CULL_FRONT 0x00001000 -#define G_CULL_BACK 0x00002000 -#define G_CULL_BOTH 0x00003000 -#define G_FOG 0x00010000 -#define G_LIGHTING 0x00020000 -#define G_TEXTURE_GEN 0x00040000 -#define G_TEXTURE_GEN_LINEAR 0x00080000 -#define G_LOD 0x00100000 -#define G_CLIPPING 0x00800000 - -#define G_IM_FMT_RGBA 0 -#define G_IM_FMT_YUV 1 -#define G_IM_FMT_CI 2 -#define G_IM_FMT_IA 3 -#define G_IM_FMT_I 4 - -#define G_IM_SIZ_4b 0 -#define G_IM_SIZ_8b 1 -#define G_IM_SIZ_16b 2 -#define G_IM_SIZ_32b 3 -#define G_IM_SIZ_DD 5 - -#define G_AC_NONE (0 << 0) -#define G_AC_THRESHOLD (1 << 0) -#define G_AC_DITHER (3 << 0) - -#define G_ZS_PIXEL (0 << 2) -#define G_ZS_PRIM (1 << 2) - -#define G_CD_MAGICSQ (0 << 6) -#define G_CD_BAYER (1 << 6) -#define G_CD_NOISE (2 << 6) - -#define G_CK_NONE (0 << 8) -#define G_CK_KEY (1 << 8) - -#define G_TC_CONV (0 << 9) -#define G_TC_FILTCONV (5 << 9) -#define G_TC_FILT (6 << 9) - -#define G_TF_POINT (0 << 12) -#define G_TF_BILERP (2 << 12) -#define G_TF_AVERAGE (3 << 12) - -#define G_TT_NONE (0 << 14) -#define G_TT_RGBA16 (2 << 14) -#define G_TT_IA16 (3 << 14) - -#define G_TL_TILE (0 << 16) -#define G_TL_LOD (1 << 16) - -#define G_TD_CLAMP (0 << 17) -#define G_TD_SHARPEN (1 << 17) -#define G_TD_DETAIL (2 << 17) - -#define G_TP_NONE (0 << 19) -#define G_TP_PERSP (1 << 19) - -#define G_CYC_1CYCLE (0 << 20) -#define G_CYC_2CYCLE (1 << 20) -#define G_CYC_COPY (2 << 20) -#define G_CYC_FILL (3 << 20) - -#define G_PM_NPRIMITIVE (0 << 23) -#define G_PM_1PRIMITIVE (1 << 23) - -#define G_SC_NON_INTERLACE 0 -#define G_SC_ODD_INTERLACE 3 -#define G_SC_EVEN_INTERLACE 2 - -#define G_TX_LOADTILE 7 -#define G_TX_RENDERTILE 0 - -#define G_TX_NOMIRROR 0 -#define G_TX_WRAP 0 -#define G_TX_MIRROR 1 -#define G_TX_CLAMP 2 -#define G_TX_NOMASK 0 -#define G_TX_NOLOD 0 - -#define G_TX_LDBLK_MAX_TXL 2047 - -#define G_MV_VIEWPORT 0x80 -#define G_MV_LOOKATY 0x82 -#define G_MV_LOOKATX 0x84 -#define G_MV_L0 0x86 -#define G_MV_L1 0x88 -#define G_MV_L2 0x8A -#define G_MV_L3 0x8C -#define G_MV_L4 0x8E -#define G_MV_L5 0x90 -#define G_MV_L6 0x92 -#define G_MV_L7 0x94 -#define G_MV_TXTATT 0x96 -#define G_MV_MATRIX_1 0x9E -#define G_MV_MATRIX_2 0x98 -#define G_MV_MATRIX_3 0x9A -#define G_MV_MATRIX_4 0x9C - -#define G_SETOTHERMODE_L 0xB9 -#define G_SETOTHERMODE_H 0xBA - -/* G_SETOTHERMODE_L render modes */ - -#define AA_EN 0x8 -#define Z_CMP 0x10 -#define Z_UPD 0x20 -#define IM_RD 0x40 -#define CLR_ON_CVG 0x80 -#define CVG_DST_CLAMP 0 -#define CVG_DST_WRAP 0x100 -#define CVG_DST_FULL 0x200 -#define CVG_DST_SAVE 0x300 -#define ZMODE_OPA 0 -#define ZMODE_INTER 0x400 -#define ZMODE_XLU 0x800 -#define ZMODE_DEC 0xc00 -#define CVG_X_ALPHA 0x1000 -#define ALPHA_CVG_SEL 0x2000 -#define FORCE_BL 0x4000 -#define TEX_EDGE 0x0000 - -#define G_BL_CLR_IN 0 -#define G_BL_CLR_MEM 1 -#define G_BL_CLR_BL 2 -#define G_BL_CLR_FOG 3 -#define G_BL_1MA 0 -#define G_BL_A_MEM 1 -#define G_BL_A_IN 0 -#define G_BL_A_FOG 1 -#define G_BL_A_SHADE 2 -#define G_BL_1 2 -#define G_BL_0 3 - -#define GBL_c1(m1a, m1b, m2a, m2b) \ - (m1a) << 30 | (m1b) << 26 | (m2a) << 22 | (m2b) << 18 -#define GBL_c2(m1a, m1b, m2a, m2b) \ - (m1a) << 28 | (m1b) << 24 | (m2a) << 20 | (m2b) << 16 - -#define RM_AA_ZB_OPA_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_SURF(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_DECAL(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ALPHA_CVG_SEL | \ - ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_DECAL(clk) \ - AA_EN | Z_CMP | CVG_DST_WRAP | ALPHA_CVG_SEL | \ - ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_DECAL(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ALPHA_CVG_SEL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ - ALPHA_CVG_SEL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_INTER(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_XLU_LINE(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_DEC_LINE(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_TEX_EDGE(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_TEX_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_INTER | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_SUB_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_PCL_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_TEX_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_SUB_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - - -#define RM_AA_OPA_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_OPA_SURF(clk) \ - AA_EN | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_XLU_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | \ - ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_XLU_LINE(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_DEC_LINE(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_TEX_EDGE(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_SUB_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_PCL_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_OPA_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_TEX_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_SUB_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - - -#define RM_ZB_OPA_SURF(clk) \ - Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | \ - ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_ZB_XLU_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_OPA_DECAL(clk) \ - Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_ZB_XLU_DECAL(clk) \ - Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_CLD_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_OVL_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_PCL_SURF(clk) \ - Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ - G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - - -#define RM_OPA_SURF(clk) \ - CVG_DST_CLAMP | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_XLU_SURF(clk) \ - IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_TEX_EDGE(clk) \ - CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL |\ - ZMODE_OPA | TEX_EDGE | AA_EN | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_CLD_SURF(clk) \ - IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_PCL_SURF(clk) \ - CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ - G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_ADD(clk) \ - IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1) - -#define RM_NOOP(clk) \ - GBL_c##clk(0, 0, 0, 0) - -#define RM_VISCVG(clk) \ - IM_RD | FORCE_BL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM) - -/* for rendering to an 8-bit framebuffer */ -#define RM_OPA_CI(clk) \ - CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - - - -#define G_RM_AA_ZB_OPA_SURF RM_AA_ZB_OPA_SURF(1) -#define G_RM_AA_ZB_OPA_SURF2 RM_AA_ZB_OPA_SURF(2) -#define G_RM_AA_ZB_XLU_SURF RM_AA_ZB_XLU_SURF(1) -#define G_RM_AA_ZB_XLU_SURF2 RM_AA_ZB_XLU_SURF(2) -#define G_RM_AA_ZB_OPA_DECAL RM_AA_ZB_OPA_DECAL(1) -#define G_RM_AA_ZB_OPA_DECAL2 RM_AA_ZB_OPA_DECAL(2) -#define G_RM_AA_ZB_XLU_DECAL RM_AA_ZB_XLU_DECAL(1) -#define G_RM_AA_ZB_XLU_DECAL2 RM_AA_ZB_XLU_DECAL(2) -#define G_RM_AA_ZB_OPA_INTER RM_AA_ZB_OPA_INTER(1) -#define G_RM_AA_ZB_OPA_INTER2 RM_AA_ZB_OPA_INTER(2) -#define G_RM_AA_ZB_XLU_INTER RM_AA_ZB_XLU_INTER(1) -#define G_RM_AA_ZB_XLU_INTER2 RM_AA_ZB_XLU_INTER(2) -#define G_RM_AA_ZB_XLU_LINE RM_AA_ZB_XLU_LINE(1) -#define G_RM_AA_ZB_XLU_LINE2 RM_AA_ZB_XLU_LINE(2) -#define G_RM_AA_ZB_DEC_LINE RM_AA_ZB_DEC_LINE(1) -#define G_RM_AA_ZB_DEC_LINE2 RM_AA_ZB_DEC_LINE(2) -#define G_RM_AA_ZB_TEX_EDGE RM_AA_ZB_TEX_EDGE(1) -#define G_RM_AA_ZB_TEX_EDGE2 RM_AA_ZB_TEX_EDGE(2) -#define G_RM_AA_ZB_TEX_INTER RM_AA_ZB_TEX_INTER(1) -#define G_RM_AA_ZB_TEX_INTER2 RM_AA_ZB_TEX_INTER(2) -#define G_RM_AA_ZB_SUB_SURF RM_AA_ZB_SUB_SURF(1) -#define G_RM_AA_ZB_SUB_SURF2 RM_AA_ZB_SUB_SURF(2) -#define G_RM_AA_ZB_PCL_SURF RM_AA_ZB_PCL_SURF(1) -#define G_RM_AA_ZB_PCL_SURF2 RM_AA_ZB_PCL_SURF(2) -#define G_RM_AA_ZB_OPA_TERR RM_AA_ZB_OPA_TERR(1) -#define G_RM_AA_ZB_OPA_TERR2 RM_AA_ZB_OPA_TERR(2) -#define G_RM_AA_ZB_TEX_TERR RM_AA_ZB_TEX_TERR(1) -#define G_RM_AA_ZB_TEX_TERR2 RM_AA_ZB_TEX_TERR(2) -#define G_RM_AA_ZB_SUB_TERR RM_AA_ZB_SUB_TERR(1) -#define G_RM_AA_ZB_SUB_TERR2 RM_AA_ZB_SUB_TERR(2) - -#define G_RM_RA_ZB_OPA_SURF RM_RA_ZB_OPA_SURF(1) -#define G_RM_RA_ZB_OPA_SURF2 RM_RA_ZB_OPA_SURF(2) -#define G_RM_RA_ZB_OPA_DECAL RM_RA_ZB_OPA_DECAL(1) -#define G_RM_RA_ZB_OPA_DECAL2 RM_RA_ZB_OPA_DECAL(2) -#define G_RM_RA_ZB_OPA_INTER RM_RA_ZB_OPA_INTER(1) -#define G_RM_RA_ZB_OPA_INTER2 RM_RA_ZB_OPA_INTER(2) - -#define G_RM_AA_OPA_SURF RM_AA_OPA_SURF(1) -#define G_RM_AA_OPA_SURF2 RM_AA_OPA_SURF(2) -#define G_RM_AA_XLU_SURF RM_AA_XLU_SURF(1) -#define G_RM_AA_XLU_SURF2 RM_AA_XLU_SURF(2) -#define G_RM_AA_XLU_LINE RM_AA_XLU_LINE(1) -#define G_RM_AA_XLU_LINE2 RM_AA_XLU_LINE(2) -#define G_RM_AA_DEC_LINE RM_AA_DEC_LINE(1) -#define G_RM_AA_DEC_LINE2 RM_AA_DEC_LINE(2) -#define G_RM_AA_TEX_EDGE RM_AA_TEX_EDGE(1) -#define G_RM_AA_TEX_EDGE2 RM_AA_TEX_EDGE(2) -#define G_RM_AA_SUB_SURF RM_AA_SUB_SURF(1) -#define G_RM_AA_SUB_SURF2 RM_AA_SUB_SURF(2) -#define G_RM_AA_PCL_SURF RM_AA_PCL_SURF(1) -#define G_RM_AA_PCL_SURF2 RM_AA_PCL_SURF(2) -#define G_RM_AA_OPA_TERR RM_AA_OPA_TERR(1) -#define G_RM_AA_OPA_TERR2 RM_AA_OPA_TERR(2) -#define G_RM_AA_TEX_TERR RM_AA_TEX_TERR(1) -#define G_RM_AA_TEX_TERR2 RM_AA_TEX_TERR(2) -#define G_RM_AA_SUB_TERR RM_AA_SUB_TERR(1) -#define G_RM_AA_SUB_TERR2 RM_AA_SUB_TERR(2) - -#define G_RM_RA_OPA_SURF RM_RA_OPA_SURF(1) -#define G_RM_RA_OPA_SURF2 RM_RA_OPA_SURF(2) - -#define G_RM_ZB_OPA_SURF RM_ZB_OPA_SURF(1) -#define G_RM_ZB_OPA_SURF2 RM_ZB_OPA_SURF(2) -#define G_RM_ZB_XLU_SURF RM_ZB_XLU_SURF(1) -#define G_RM_ZB_XLU_SURF2 RM_ZB_XLU_SURF(2) -#define G_RM_ZB_OPA_DECAL RM_ZB_OPA_DECAL(1) -#define G_RM_ZB_OPA_DECAL2 RM_ZB_OPA_DECAL(2) -#define G_RM_ZB_XLU_DECAL RM_ZB_XLU_DECAL(1) -#define G_RM_ZB_XLU_DECAL2 RM_ZB_XLU_DECAL(2) -#define G_RM_ZB_CLD_SURF RM_ZB_CLD_SURF(1) -#define G_RM_ZB_CLD_SURF2 RM_ZB_CLD_SURF(2) -#define G_RM_ZB_OVL_SURF RM_ZB_OVL_SURF(1) -#define G_RM_ZB_OVL_SURF2 RM_ZB_OVL_SURF(2) -#define G_RM_ZB_PCL_SURF RM_ZB_PCL_SURF(1) -#define G_RM_ZB_PCL_SURF2 RM_ZB_PCL_SURF(2) - -#define G_RM_OPA_SURF RM_OPA_SURF(1) -#define G_RM_OPA_SURF2 RM_OPA_SURF(2) -#define G_RM_XLU_SURF RM_XLU_SURF(1) -#define G_RM_XLU_SURF2 RM_XLU_SURF(2) -#define G_RM_CLD_SURF RM_CLD_SURF(1) -#define G_RM_CLD_SURF2 RM_CLD_SURF(2) -#define G_RM_TEX_EDGE RM_TEX_EDGE(1) -#define G_RM_TEX_EDGE2 RM_TEX_EDGE(2) -#define G_RM_PCL_SURF RM_PCL_SURF(1) -#define G_RM_PCL_SURF2 RM_PCL_SURF(2) -#define G_RM_ADD RM_ADD(1) -#define G_RM_ADD2 RM_ADD(2) -#define G_RM_NOOP RM_NOOP(1) -#define G_RM_NOOP2 RM_NOOP(2) -#define G_RM_VISCVG RM_VISCVG(1) -#define G_RM_VISCVG2 RM_VISCVG(2) -#define G_RM_OPA_CI RM_OPA_CI(1) -#define G_RM_OPA_CI2 RM_OPA_CI(2) - - -#define G_RM_FOG_SHADE_A GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA) -#define G_RM_FOG_PRIM_A GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA) -#define G_RM_PASS GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define G_MWO_NUMLIGHT 0x00 -#define G_MW_NUMLIGHT 0x02 -#define NUML(n) (((n)+1)*32 + 0x80000000) -#define G_MW_PERSPNORM 0x0e - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - -/* DMA macro */ - -#define gDma1p(pkt, c, s, l, p) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ - _SHIFTL((l), 0, 16)); \ - _g->words.w1 = (unsigned int)(s); \ -} - -#define gsDma1p(c, s, l, p) \ -{ \ - _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ - _SHIFTL((l), 0, 16)); \ - _g->words.w1 = (unsigned int)(s); \ -} - -/* Matrix */ - -#define gSPMatrix(pkt, m, p) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_MTX, 24, 8) \ - | _SHIFTL((p), 16, 8) \ - | _SHIFTL(sizeof(Mtx), 0, 16); \ - _g->words.w1 = (u32)(m); \ -} - -#define gsSPMatrix(m, p) \ -{ \ - _g->words.w0 = _SHIFTL(G_MTX, 24, 8) \ - | _SHIFTL((p), 16, 8) \ - | _SHIFTL(sizeof(Mtx), 0, 16); \ - _g->words.w1 = (u32)(m); \ -} - -/* Vertex */ -/* Syntax change from Fast3D to Fast3DEX */ - -#ifndef F3DEX_GBI -#define gSPVertex(pkt, v, n, v0) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_VTX, 24, 8) \ - | _SHIFTL(((n)-1) << 4 | (v0), 16, 8) \ - | _SHIFTL(sizeof(Vtx)*(n), 0, 16); \ - _g->words.w1 = (u32)(v); \ -} - -#define gsSPVertex(v, n, v0) \ -{ \ - _g->words.w0 = _SHIFTL(G_VTX, 24, 8) \ - | _SHIFTL(((n)-1) << 4 | (v0), 16, 8) \ - | _SHIFTL(sizeof(Vtx)*(n), 0, 16); \ - _g->words.w1 = (u32)(v); \ -} - -#else /* Fast3DEX */ -#define gSPVertex(pkt, v, n, v0) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_VTX, 24, 8) \ - | _SHIFTL(((v0)*2), 16, 8) \ - | _SHIFTL((n << 10) | ((sizeof(Vtx)*(n))-1), 0, 16); \ - _g->words.w1 = (u32)(v); \ -} - -#define gsSPVertex(v, n, v0) \ -{ \ - _g->words.w0 = _SHIFTL(G_VTX, 24, 8) \ - | _SHIFTL(((v0)*2), 16, 8) \ - | _SHIFTL((n << 10) | ((sizeof(Vtx)*(n))-1), 0, 16); \ - _g->words.w1 = (u32)(v); \ -} -#endif - -/* LoadSync */ - -#define gDPLoadSync(pkt) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_RDPLOADSYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -#define gsDPLoadSync() \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPLOADSYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -/* PipeSync */ - -#define gDPPipeSync(pkt) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_RDPPIPESYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -#define gsDPPipeSync() \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPPIPESYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -/* TileSync */ - -#define gDPTileSync(pkt) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_RDPTILESYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -#define gsDPTileSync() \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPTILESYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -/* FullSync */ - -#define gDPFullSync(pkt) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_RDPFULLSYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -#define gsDPFullSync() \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPFULLSYNC, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -/* DisplayList */ - -#define gSPDisplayList(pkt, dl) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_DL, 24, 8); \ - _g->words.w1 = (u32)(dl); \ -} - -#define gsSPDisplayList(dl) \ -{ \ - _g->words.w0 = _SHIFTL(G_DL, 24, 8); \ - _g->words.w1 = (u32)(dl); \ -} - -/* BranchList */ - -#define gSPBranchList(pkt,dl) \ - gDma1p(pkt, G_DL, dl, 0, G_DL_NOPUSH) - -#define gsSPBranchList(pkt,dl) \ - gsDma1p(G_DL, dl, 0, G_DL_NOPUSH) - -/* EndDisplayList */ - -#define gSPEndDisplayList(pkt) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_ENDDL, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -#define gsSPEndDisplayList() \ -{ \ - _g->words.w0 = _SHIFTL(G_ENDDL, 24, 8); \ - _g->words.w1 = 0x00000000; \ -} - -/* SetOtherMode */ - -#define gSPSetOtherMode(pkt, cmd, shift, length, data) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL((cmd), 24, 8) \ - | _SHIFTL((shift), 8, 8) \ - | _SHIFTL(((length)-1), 0, 8); \ - _g->words.w1 = (data); \ -} - -#define gsSPSetOtherMode(cmd, shift, length, data) \ -{ \ - _g->words.w0 = _SHIFTL((cmd), 24, 8) \ - | _SHIFTL((shift), 8, 8) \ - | _SHIFTL(((length)-1), 0, 8); \ - _g->words.w1 = (data); \ -} - -/* SetCycleType */ - -#define gDPSetCycleType(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 3, type) - -#define gsDPSetCycleType(pkt, type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 3, type) - -/* PipeLineMode */ - -#define gDPPipelineMode(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, 0x17, 2, mode) - -#define gsDPPipelineMode(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, 0x17, 2, mode) - -/* SetScissor */ - -#define gDPSetScissor(pkt, mode, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) \ - | _SHIFTL((int)((float)(ulx)*4.0f), 12, 12) \ - | _SHIFTL((int)((float)(uly)*4.0f), 0, 12); \ - _g->words.w1 = _SHIFTL((mode), 24, 8) \ - | _SHIFTL((int)((float)(lrx)*4.0f), 12, 12) \ - | _SHIFTL((int)((float)(lry)*4.0f), 0, 12); \ -} - -#define gsDPSetScissor(mode, ulx, uly, lrx, lry) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) \ - | _SHIFTL((int)((float)(ulx)*4.0f), 12, 12) \ - | _SHIFTL((int)((float)(uly)*4.0f), 0, 12); \ - _g->words.w1 = _SHIFTL((mode), 24, 8) \ - | _SHIFTL((int)((float)(lrx)*4.0f), 12, 12) \ - | _SHIFTL((int)((float)(lry)*4.0f), 0, 12); \ -} - -/* SetCombine */ - -#define gDPSetCombine(pkt, muxs0, muxs1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) \ - | _SHIFTL((muxs0), 0, 24); \ - _g->words.w1 = (muxs1); \ -} - -#define gsDPSetCombine(muxs0, muxs1) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) \ - | _SHIFTL((muxs0), 0, 24); \ - _g->words.w1 = (muxs1); \ -} - -/* SetTextureLOD */ - -#define gDPSetTextureLOD(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 2, type) - -#define gsDPSetTextureLOD(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 2, type) - -/* SetTextureLUT */ - -#define gDPSetTextureLUT(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 3, type) - -#define gsDPSetTextureLUT(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 3, type) - -/* SetTextureDetail */ - -#define gDPSetTextureDetail(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 3, type) - -#define gsDPSetTextureDetail(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 3, type) - -/* SetTexturePersp */ - -#define gDPSetTexturePersp(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 2, type) - -#define gsDPSetTexturePersp(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 2, type) - -/* SetTextureFilter */ - -#define gDPSetTextureFilter(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 3, type) - -#define gsDPSetTextureFilter(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 3, type) - -/* SetTextureConvert */ - -#define gDPSetTextureConvert(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 4, type) - -#define gsDPSetTextureConvert(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 4, type) - -/* SetCombineKey */ - -#define gDPSetCombineKey(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 2, type) - -#define gsDPSetCombineKey(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 2, type) - -/* SetColorDither */ - -#define gDPSetColorDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 3, mode) - -#define gsDPSetColorDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 3, mode) - -/* FillColor */ - -#define gDPSetFillColor(pkt, color) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_SETFILLCOLOR, 24, 8); \ - _g->words.w1 = color; \ -} - -#define gsDPSetFillColor(color) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETFILLCOLOR, 24, 8); \ - _g->words.w1 = color; \ -} - -/* FillRectangle */ - -#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_FILLRECT, 24, 8) \ - | _SHIFTL((lrx), 14, 10) \ - | _SHIFTL((lry), 2, 10); \ - _g->words.w1 = _SHIFTL(0, 24, 8) \ - | _SHIFTL((ulx), 14, 10) \ - | _SHIFTL((uly), 2, 10); \ -} - -#define gsDPFillRectangle(ulx, uly, lrx, lry) \ -{ \ - _g->words.w0 = _SHIFTL(G_FILLRECT, 24, 8) \ - | _SHIFTL((lrx), 14, 10) \ - | _SHIFTL((lry), 2, 10); \ - _g->words.w1 = _SHIFTL(0, 24, 8) \ - | _SHIFTL((ulx), 14, 10) \ - | _SHIFTL((uly), 2, 10); \ -} - -/* SetAlphaCompare */ - -#define gDPSetAlphaCompare(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 3, type) - -#define gsDPSetAlphaCompare(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 3, type) - -/* SetDepthSource */ - -#define gDPSetDepthSource(pkt, src) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 2, src) - -#define gsDPSetDepthSource(src) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 2, src) - -/* SetRenderMode */ - -#define gDPSetRenderMode(pkt, c0, c1) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 30, (c0) | (c1)) - -#define gsDPSetRenderMode(c0, c1) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 30, (c0) | (c1)) - -/* ClearGeometryMode */ - -#define gSPClearGeometryMode(pkt, mode) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8); \ - _g->words.w1 = mode; \ -} - -#define gsSPClearGeometryMode(pkt, mode) \ -{ \ - _g->words.w0 = _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8); \ - _g->words.w1 = mode; \ -} - -/* SetGeometryMode */ - -#define gSPSetGeometryMode(pkt, word) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = _SHIFTL(G_SETGEOMETRYMODE, 24, 8); \ - _g->words.w1 = word; \ -} - -#define gsSPSetGeometryMode(word) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETGEOMETRYMODE, 24, 8); \ - _g->words.w1 = word; \ -} - -/* NumLights */ - -#define gSPNumLights(pkt, n) \ - gMoveWd(pkt, G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) - -#define gsSPNumLights(n) \ - gsMoveWd(G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) - -/* Texture */ - -#define gSPTexture(pkt, sc, tc, level, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_TEXTURE, 24, 8) \ - | _SHIFTL(0, 16, 8) \ - | _SHIFTL((level), 11, 3) \ - | _SHIFTL((tile), 8, 3) \ - | _SHIFTL((on), 0, 8); \ - _g->words.w1 = _SHIFTL((sc), 16, 16) \ - | _SHIFTL((tc), 0, 16); \ -} - -#define gsSPTexture(sc, tc, level, tile, on) \ -{ \ - _g->words.w0 = _SHIFTL(G_TEXTURE, 24, 8) \ - | _SHIFTL(0, 16, 8) \ - | _SHIFTL((level), 11, 3) \ - | _SHIFTL((tile), 8, 3) \ - | _SHIFTL((on), 0, 8); \ - _g->words.w1 = _SHIFTL((sc), 16, 16) \ - | _SHIFTL((tc), 0, 16); \ -} - -/* SetColorImage */ - -#define gDPSetColorImage(pkt, fmt, size, width, image) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETCIMG, 24, 8) \ - | _SHIFTL((fmt), 21, 3) \ - | _SHIFTL((size), 19, 2) \ - | _SHIFTL((width)-1, 0, 12); \ - _g->words.w1 = (image); \ -} - -#define gsDPSetColorImage(fmt, size, width, image) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETCIMG, 24, 8) \ - | _SHIFTL((fmt), 21, 3) \ - | _SHIFTL((size), 19, 2) \ - | _SHIFTL((width)-1, 0, 12); \ - _g->words.w1 = (image); \ -} - -/* SetTileSize */ - -#define gDPSetTileSize(pkt, tile, uls, ult, lrs, lrt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETTILESIZE, 24, 8) \ - | _SHIFTL(uls, 12, 12) \ - | _SHIFTL(ult, 0, 12); \ - _g->words.w1 = _SHIFTL(tile, 24, 3) \ - | _SHIFTL(lrs, 12, 12) \ - | _SHIFTL(lrt, 0, 12); \ -} - -#define gsDPSetTileSize(tile, uls, ult, lrs, lrt) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETTILESIZE, 24, 8) \ - | _SHIFTL(uls, 12, 12) \ - | _SHIFTL(ult, 0, 12); \ - _g->words.w1 = _SHIFTL(tile, 24, 3) \ - | _SHIFTL(lrs, 12, 12) \ - | _SHIFTL(lrt, 0, 12); \ -} - -/* LoadBlock */ - -#define gDPLoadBlock(pkt, tile, uls, ult, lrs, dxt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_LOADBLOCK, 24, 8) \ - | _SHIFTL((uls), 12, 12) \ - | _SHIFTL((ult), 0, 12); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((MIN((lrs),G_TX_LDBLK_MAX_TXL)), 12, 12) \ - | _SHIFTL((dxt), 0, 12); \ -} - -#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \ -{ \ - _g->words.w0 = _SHIFTL(G_LOADBLOCK, 24, 8) \ - | _SHIFTL((uls), 12, 12) \ - | _SHIFTL((ult), 0, 12); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((MIN((lrs),G_TX_LDBLK_MAX_TXL)), 12, 12) \ - | _SHIFTL((dxt), 0, 12); \ -} - -/* SetTile */ - -#define gDPSetTile(pkt, fmt, siz, line, tmem, tile, \ - palette, cmt, maskt, shiftt, cms, masks, shifts) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETTILE, 24, 8) \ - | _SHIFTL((fmt), 21, 3) \ - | _SHIFTL((siz), 19, 2) \ - | _SHIFTL((line), 9, 9) \ - | _SHIFTL((tmem), 0, 9); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((palette), 20, 4) \ - | _SHIFTL((cmt), 18, 2) \ - | _SHIFTL((maskt), 14, 4) \ - | _SHIFTL((shiftt), 10, 4) \ - | _SHIFTL((cms), 8, 2) \ - | _SHIFTL((masks), 4, 4) \ - | _SHIFTL((shifts), 0, 4); \ -} - -#define gsDPSetTile(fmt, siz, line, tmem, tile, \ - palette, cmt, maskt, shiftt, cms, masks, shifts) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETTILE, 24, 8) \ - | _SHIFTL((fmt), 21, 3) \ - | _SHIFTL((siz), 19, 2) \ - | _SHIFTL((line), 9, 9) \ - | _SHIFTL((tmem), 0, 9); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((palette), 20, 4) \ - | _SHIFTL((cmt), 18, 2) \ - | _SHIFTL((maskt), 14, 4) \ - | _SHIFTL((shiftt), 10, 4) \ - | _SHIFTL((cms), 8, 2) \ - | _SHIFTL((masks), 4, 4) \ - | _SHIFTL((shifts), 0, 4); \ -} - -/* SetDepthImage */ - -#define gDPSetDepthImage(pkt, image) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETZIMG, 24, 8); \ - _g->words.w1 = (image); \ -} - -#define gsDPSetDepthImage(image) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETZIMG, 24, 8); \ - _g->words.w1 = (image); \ -} - -/* SetPrimColor */ - -#define gDPSetPrimColor(pkt, m, l, r, g, b, a) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETPRIMCOLOR, 24, 8) \ - | _SHIFTL(m, 8, 8) \ - | _SHIFTL(l, 0, 8); \ - _g->words.w1 = _SHIFTL(r, 24, 8) \ - | _SHIFTL(g, 16, 8) \ - | _SHIFTL(b, 8, 8) \ - | _SHIFTL(a, 0, 8); \ -} - -#define gsDPSetPrimColor(m, l, r, g, b, a) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETPRIMCOLOR, 24, 8) \ - | _SHIFTL(m, 8, 8) \ - | _SHIFTL(l, 0, 8); \ - _g->words.w1 = _SHIFTL(r, 24, 8) \ - | _SHIFTL(g, 16, 8) \ - | _SHIFTL(b, 8, 8) \ - | _SHIFTL(a, 0, 8); \ -} - -/* SetEnvColor */ - -#define gDPSetEnvColor(pkt, r, g, b, a) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETENVCOLOR, 24, 8); \ - _g->words.w1 = _SHIFTL((r), 24, 8) \ - | _SHIFTL((g), 16, 8) \ - | _SHIFTL((b), 8, 8) \ - | _SHIFTL((a), 0, 8); \ -} - -#define gsDPSetEnvColor(r, g, b, a) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETENVCOLOR, 24, 8); \ - _g->words.w1 = _SHIFTL((r), 24, 8) \ - | _SHIFTL((g), 16, 8) \ - | _SHIFTL((b), 8, 8) \ - | _SHIFTL((a), 0, 8); \ -} - -/* SetTextureImage */ - -#define gDPSetTextureImage(pkt, fmt, size, width, img) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_SETTIMG, 24, 8) \ - | _SHIFTL((fmt), 21, 3) \ - | _SHIFTL((size), 19, 2) \ - | _SHIFTL((width)-1, 0, 12); \ - _g->words.w1 = (u32)(img); \ -} - -#define gsDPSetTextureImage(fmt, size, width, img) \ -{ \ - _g->words.w0 = _SHIFTL(G_SETTIMG, 24, 8) \ - | _SHIFTL((fmt), 21, 3) \ - | _SHIFTL((size), 19, 2) \ - | _SHIFTL((width)-1, 0, 12); \ - _g->words.w1 = (u32)(img); \ -} - -/* MoveWd */ - -#define gMoveWd(pkt, index, offset, data) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_MOVEWORD, 24, 8) \ - | _SHIFTL((offset), 8, 16) \ - | _SHIFTL((index), 0, 8); \ - _g->words.w1 = (u32)(data); \ -} - -#define gsMoveWd(index, offset, data) \ -{ \ - _g->words.w0 = _SHIFTL(G_MOVEWORD, 24, 8) \ - | _SHIFTL((offset), 8, 16) \ - | _SHIFTL((index), 0, 8); \ - _g->words.w1 = (u32)(data); \ -} - -/* Matrix Operations */ - -#define G_MTX_MODELVIEW 0x00 -#define G_MTX_PROJECTION 0x01 -#define G_MTX_MUL 0x00 -#define G_MTX_LOAD 0x02 -#define G_MTX_NOPUSH 0x00 -#define G_MTX_PUSH 0x04 - -/* PopMatrix */ - -#define gSPPopMatrix(pkt, n) \ -{ \ - Gfx *_g = (Gfx *) (pkt); \ - _g->words.w0 = 0xBD000000; \ - _g->words.w1 = (n); \ -} - -#define gsSPPopMatrix(pkt, n) \ -{ \ - _g->words.w0 = 0xBD000000; \ - _g->words.w1 = (n); \ -} - -/* Viewport */ - -#define gSPViewport(pkt, v) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(G_MV_VIEWPORT, 16, 8) \ - | _SHIFTL(sizeof(Vp), 0, 16); \ - _g->words.w1 = (u32)(v); \ -} - -#define gsSPViewport(v) \ -{ \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(G_MV_VIEWPORT, 16, 8) \ - | _SHIFTL(sizeof(Vp), 0, 16); \ - _g->words.w1 = (u32)(v); \ -} - -/* 1Triangle */ -/* Fast3DEX changes how the triangle incices are stored for G_TRI1 (0xBF) */ - -#ifndef F3DEX_GBI -#define gSP1Triangle(pkt, v0, v1, v2, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ - _g->words.w1 = _SHIFTL((flag), 24, 8) \ - | _SHIFTL((v0)*10, 16, 8) \ - | _SHIFTL((v1)*10, 8, 8) \ - | _SHIFTL((v2)*10, 0, 8); \ -} - -#define gsSP1Triangle(v0, v1, v2, flag) \ -{ \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ - _g->words.w1 = _SHIFTL((flag), 24, 8) \ - | _SHIFTL((v0)*10, 16, 8) \ - | _SHIFTL((v1)*10, 8, 8) \ - | _SHIFTL((v2)*10, 0, 8); \ -} - -#else -#define gSP1Triangle(pkt, v0, v1, v2, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ - _g->words.w1 = _SHIFTL((flag), 24, 8) \ - | _SHIFTL((v0)*2, 16, 8) \ - | _SHIFTL((v1)*2, 8, 8) \ - | _SHIFTL((v2)*2, 0, 8); \ -} - -#define gsSP1Triangle(v0, v1, v2, flag) \ -{ \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ - _g->words.w1 = _SHIFTL((flag), 24, 8) \ - | _SHIFTL((v0)*2, 16, 8) \ - | _SHIFTL((v1)*2, 8, 8) \ - | _SHIFTL((v2)*2, 0, 8); \ -} -#endif - - -/* TextureRectangle */ -/* Last two commands (G_RDPHALF_CONT (which was replaced with G_MODIFYVTX) and G_RDPHALF_2) changed for this macro in Fast3DEX and onwards. */ - -#ifndef F3DEX_GBI -#define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_TEXRECT, 24, 8) \ - | _SHIFTL((xh), 12, 12) \ - | _SHIFTL((yh), 0, 12); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((xl), 12, 12) \ - | _SHIFTL((yl), 0, 12); \ -} \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_2, 24, 8); \ - _g->words.w1 = _SHIFTL((s), 16, 16) \ - | _SHIFTL((t), 0, 16); \ -} \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_CONT, 24, 8); \ - _g->words.w1 = _SHIFTL((dsdx), 16, 16) \ - | _SHIFTL((dtdy), 0, 16); \ -} - -#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - _g->words.w0 = _SHIFTL(G_TEXRECT, 24, 8) \ - | _SHIFTL((xh), 12, 12) \ - | _SHIFTL((yh), 0, 12); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((xl), 12, 12) \ - | _SHIFTL((yl), 0, 12); \ -} \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPHALF_2, 24, 8); \ - _g->words.w1 = _SHIFTL((s), 16, 16) \ - | _SHIFTL((t), 0, 16); \ -} \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPHALF_CONT, 24, 8); \ - _g->words.w1 = _SHIFTL((dsdx), 16, 16) \ - | _SHIFTL((dtdy), 0, 16); \ -} - -#else -#define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_TEXRECT, 24, 8) \ - | _SHIFTL((xh), 12, 12) \ - | _SHIFTL((yh), 0, 12); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((xl), 12, 12) \ - | _SHIFTL((yl), 0, 12); \ -} \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \ - _g->words.w1 = _SHIFTL((s), 16, 16) \ - | _SHIFTL((t), 0, 16); \ -} \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_2, 24, 8); \ - _g->words.w1 = _SHIFTL((dsdx), 16, 16) \ - | _SHIFTL((dtdy), 0, 16); \ -} - -#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - _g->words.w0 = _SHIFTL(G_TEXRECT, 24, 8) \ - | _SHIFTL((xh), 12, 12) \ - | _SHIFTL((yh), 0, 12); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) \ - | _SHIFTL((xl), 12, 12) \ - | _SHIFTL((yl), 0, 12); \ -} \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \ - _g->words.w1 = _SHIFTL((s), 16, 16) \ - | _SHIFTL((t), 0, 16); \ -} \ -{ \ - _g->words.w0 = _SHIFTL(G_RDPHALF_2, 24, 8); \ - _g->words.w1 = _SHIFTL((dsdx), 16, 16) \ - | _SHIFTL((dtdy), 0, 16); \ -} -#endif - -/* Lights and Light Operations */ - -typedef struct { - unsigned char col[3]; - char pad1; - unsigned char colc[3]; - char pad2; - signed char dir[3]; - char pad3; -} Light_t; - -typedef struct { - unsigned char col[3]; - char pad1; - unsigned char colc[3]; - char pad2; -} Ambient_t; - -typedef union { - Ambient_t l; - long long int force_structure_alignment[1]; -} Ambient; - -typedef union { - Light_t l; - long long int force_structure_alignment[2]; -} Light; - -typedef struct { - Ambient a; - Light l[4]; -} Lights4; - -typedef struct { - Light l[2]; -} LookAt; - -typedef struct { - int x1, y1, x2, y2; -} Hilite_t; - -typedef union { - Hilite_t h; - long int force_alignmnet[4]; -} Hilite; - -/* for gSPNumLights */ -#define NUMLIGHTS_0 1 -#define NUMLIGHTS_1 1 -#define NUMLIGHTS_2 2 -#define NUMLIGHTS_3 3 -#define NUMLIGHTS_4 4 -#define NUMLIGHTS_5 5 -#define NUMLIGHTS_6 6 -#define NUMLIGHTS_7 7 - -/* for gSPLight */ -#define LIGHT_1 1 -#define LIGHT_2 2 -#define LIGHT_3 3 -#define LIGHT_4 4 -#define LIGHT_5 5 -#define LIGHT_6 6 -#define LIGHT_7 7 -#define LIGHT_8 8 - -/* Lights */ - -#define gSPLight(pkt, l, n) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(((n)-1)*2+G_MV_L0, 16, 8) \ - | _SHIFTL(sizeof(Light), 0, 16); \ - _g->words.w1 = (u32)(l); \ -} - -#define gsSPLight(l, n) \ -{ \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(((n)-1)*2+G_MV_L0, 16, 8) \ - | _SHIFTL(sizeof(Light), 0, 16); \ - _g->words.w1 = (u32)(l); \ -} - -/* LookAtX */ - -#define gSPLookAtX(pkt, la) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(G_MV_LOOKATX, 16, 8) \ - | _SHIFTL(sizeof(Light), 0, 16); \ - _g->words.w1 = (u32)(la); \ -} - -#define gsSPLookAtX(la) \ -{ \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(G_MV_LOOKATX, 16, 8) \ - | _SHIFTL(sizeof(Light), 0, 16); \ - _g->words.w1 = (u32)(la); \ -} - -/* LookAtY */ - -#define gSPLookAtY(pkt, la) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(G_MV_LOOKATY, 16, 8) \ - | _SHIFTL(sizeof(Light), 0, 16); \ - _g->words.w1 = (u32)(la); \ -} - -#define gsSPLookAtY(la) \ -{ \ - _g->words.w0 = _SHIFTL(G_MOVEMEM, 24, 8) \ - | _SHIFTL(G_MV_LOOKATY, 16, 8) \ - | _SHIFTL(sizeof(Light), 0, 16); \ - _g->words.w1 = (u32)(la); \ -} - -/* LookAt */ - -#define gSPLookAt(pkt, la) \ -{ \ - gSPLookAtX((pkt), (la)) \ - gSPLookAtY((pkt), (char *)(la)+16) \ -} - -#define gsSPLookAt(la) \ -{ \ - gsSPLookAtX((la)) \ - gsSPLookAtY((char *)(la)+16) \ -} - -/* PerspNormalize */ - -#ifndef F3DEX_GBI -#define gSPPerspNormalize(pkt, s) \ -{ \ - Gfx *g = pkt; \ - g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \ - g->words.w1 = s; \ -} - -#define gsSPPerspNormalize(s) \ -{ \ - g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \ - g->words.w1 = s; \ -} - -#else -#define gSPPerspNormalize(pkt, s) \ - gMoveWd(pkt, G_MW_PERSPNORM, 0, (s)) - -#define gsSPPerspNormalize(s) \ - gsMoveWd(G_MW_PERSPNORM, 0, (s)) -#endif - -#endif diff --git a/src/include/PR/gu.h b/src/include/PR/gu.h deleted file mode 100644 index 8982feb10..000000000 --- a/src/include/PR/gu.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _ULTRA64_GU_H_ -#define _ULTRA64_GU_H_ - -#define GU_PI 3.1415926 - -#define FTOFIX32(x) (long)((x) * (float)0x00010000) -#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000)) -#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff) - -/* Functions */ - -void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, - float near, float far, float scale); -void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, - float far, float scale); -void guOrtho(Mtx *m, float left, float right, float bottom, float top, - float near, float far, float scale); -void guTranslate(Mtx *m, float x, float y, float z); -void guRotate(Mtx *m, float a, float x, float y, float z); -void guScale(Mtx *m, float x, float y, float z); -void guMtxF2L(float mf[4][4], Mtx *m); -void guMtxIdent(Mtx *m); -void guMtxIdentF(float mf[4][4]); -void guMtxL2F(float mf[4][4], Mtx *m); -void guNormalize(float *, float *, float *); -void guAlignF(float mf[4][4], float a, float x, float y, float z); -void guRotateF(float mf[4][4], float a, float x, float y, float z); -void guFrustumF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale); - -void guLookAt(Mtx *m, float xEye, float yEye, float zEye, - float xAt, float yAt, float zAt, - float xUp, float yUp, float zUp); - -signed short coss(unsigned short x); -signed short sins(unsigned short x); - -/* Used only in Fast3DEX2 */ -void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye, - float xAt, float yAt, float zAt, - float xUp, float yUp, float zUp); -#endif diff --git a/src/include/PR/libultra.h b/src/include/PR/libultra.h deleted file mode 100644 index 07dd0f401..000000000 --- a/src/include/PR/libultra.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _LIBULTRA_H -#define _LIBULTRA_H - -#define OS_TV_TYPE_PAL 0 -#define OS_TV_TYPE_NTSC 1 -#define OS_TV_TYPE_MPAL 2 - -#define RESET_TYPE_COLD_RESET 0 -#define RESET_TYPE_NMI 1 -#define RESET_TYPE_BOOT_DISK 2 - -extern s32 osTvType; -extern u32 osRomBase; -extern u32 osResetType; -extern u32 osMemSize; -extern u8 osAppNmiBuffer[64]; - -#endif /* _LIBULTRA_H */ diff --git a/src/include/PR/os_internal.h b/src/include/PR/os_internal.h deleted file mode 100644 index a18e03674..000000000 --- a/src/include/PR/os_internal.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _ULTRA64_OS_INTERNAL_H_ -#define _ULTRA64_OS_INTERNAL_H_ - -/* Internal functions used by the operating system */ -/* Do not include this header in application code */ - -/* Variables */ - -//extern u64 osClockRate; - -/* Functions */ - -/*u32 __osProbeTLB(void *); -u32 __osDisableInt(void); -void __osRestoreInt(u32);*/ -OSThread *__osGetCurrFaultedThread(void); - -#endif diff --git a/src/include/PR/os_misc.h b/src/include/PR/os_misc.h deleted file mode 100644 index 80c1cf09c..000000000 --- a/src/include/PR/os_misc.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef _ULTRA64_OS_MISC_H_ -#define _ULTRA64_OS_MISC_H_ - -/* float properties */ -#define _D0 0 -#define _DBIAS 0x3ff -#define _DLONG 1 -#define _DOFF 4 -#define _FBIAS 0x7e -#define _FOFF 7 -#define _FRND 1 -#define _LBIAS 0x3ffe -#define _LOFF 15 - -/* integer properties */ -#define _C2 1 -#define _CSIGN 1 -#define _ILONG 0 -#define _MBMAX 8 -#define NAN 2 -#define INF 1 -#define FINITE -1 -#define _DFRAC ((1 << _DOFF) - 1) -#define _DMASK (0x7fff & ~_DFRAC) -#define _DMAX ((1 << (15 - _DOFF)) - 1) -#define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1)) -#define _DSIGN 0x8000 -#define _D1 1 /* big-endian order */ -#define _D2 2 -#define _D3 3 - -#define FLAGS_SPACE 1 -#define FLAGS_PLUS 2 -#define FLAGS_MINUS 4 -#define FLAGS_HASH 8 -#define FLAGS_ZERO 16 - -#define BLOCKSIZE 32 - -#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0]))) - -#define ERRCK(fn) \ - ret = fn; \ - if (ret != 0) \ - return ret; - -typedef struct { - union { - /* 00 */ long long s64; - double f64; - } value; - /* 08 */ char *buff; - /* 0c */ int n0; - /* 10 */ int num_leading_zeros; - /* 14 */ int part2_len; - /* 18 */ int num_mid_zeros; - /* 1c */ int part3_len; - /* 20 */ int num_trailing_zeros; - /* 24 */ int precision; - /* 28 */ int width; - /* 2c */ unsigned int size; - /* 30 */ unsigned int flags; - /* 34 */ char length; -} printf_struct; - -typedef char *va_list; - -#define _FP 1 -#define _INT 0 -#define _STRUCT 2 - -#define _VA_FP_SAVE_AREA 0x10 -#define _VA_ALIGN(p, a) (((unsigned int)(((char *)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4)) -#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) - -#define __va_stack_arg(list, mode) \ - ( \ - ((list) = (char *)_VA_ALIGN(list, __builtin_alignof(mode)) + \ - _VA_ALIGN(sizeof(mode), 4)), \ - (((char *)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode)))) - -#define __va_double_arg(list, mode) \ - ( \ - (((long)list & 0x1) /* 1 byte aligned? */ \ - ? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \ - : (((long)list & 0x2) /* 2 byte aligned? */ \ - ? (list = (char *)((long)list + 10), (char *)((long)list - 24 - _VA_FP_SAVE_AREA)) \ - : __va_stack_arg(list, mode)))) - -#define va_arg(list, mode) ((mode *)(((__builtin_classof(mode) == _FP && \ - __builtin_alignof(mode) == sizeof(double)) \ - ? __va_double_arg(list, mode) \ - : __va_stack_arg(list, mode))))[-1] -#define va_end(__list) - -#define EEPROM_MAXBLOCKS 64 -#define EEP16K_MAXBLOCKS 256 -#define EEPROM_BLOCK_SIZE 8 - -/* - * PI/EPI - */ -#define PI_DOMAIN1 0 -#define PI_DOMAIN2 1 - -#define OS_CLOCK_RATE 62500000LL -#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) -#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) -#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) -#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) -#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) - -#define LEO_BLOCK_MODE 1 -#define LEO_TRACK_MODE 2 -#define LEO_SECTOR_MODE 3 - -/* Miscellaneous OS functions */ - -void osInitialize(void); -u32 osGetCount(void); - -u32 osVirtualToPhysical(void *); - -f32 cosf(f32 arg0); -f32 sinf(f32 arg0); -f32 sqrtf(f32 arg0); - -void *memcpy(void *, const void *, size_t); -size_t strlen(const char *s); -char *strchr(const char *s, int c); - -#endif diff --git a/src/include/PR/os_pfs.h b/src/include/PR/os_pfs.h deleted file mode 100644 index d87bf4524..000000000 --- a/src/include/PR/os_pfs.h +++ /dev/null @@ -1,220 +0,0 @@ - -/*==================================================================== - * os_pfs.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_pfs.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:05 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_PFS_H_ -#define _OS_PFS_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "os_message.h" - - -/************************************************************************** - * - * Type definitions - * - */ - -typedef struct { - int status; - OSMesgQueue *queue; - int channel; - u8 id[32]; - u8 label[32]; - int version; - int dir_size; - int inode_table; /* block location */ - int minode_table; /* mirrioring inode_table */ - int dir_table; /* block location */ - int inode_start_page; /* page # */ - u8 banks; - u8 activebank; -} OSPfs; - -typedef struct { - u32 file_size; /* bytes */ - u32 game_code; - u16 company_code; - char ext_name[4]; - char game_name[16]; -} OSPfsState; - -typedef struct { - u16 fixed1; /* Fixed data (0x00, 0xc3) */ - u16 start_address; /* Program start address */ - u8 nintendo_chr[0x30]; /* "Nintendo" character data */ - u8 game_title[16]; /* Game title */ - u16 company_code; /* Company code */ - u8 body_code; /* Body code */ - u8 cart_type; /* Game pak type */ - u8 rom_size; /* ROM size */ - u8 ram_size; /* RAM size */ - u8 country_code; /* country code */ - u8 fixed_data; /* fixed data(0x33) */ - u8 version; /* Mask ROM version number */ - u8 isum; /* Complement check */ - u16 sum; /* Sum check */ -} OSGbpakId; - -/************************************************************************** - * - * Global definitions - * - */ - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -#define PFS_ERR_NOPACK 1 /* no memory card is plugged */ -#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a different one */ -#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */ -#define PFS_ERR_CONTRFAIL 4 -#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist */ -#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad */ -#define PFS_DATA_FULL 7 /* no free pages on ram pack */ -#define PFS_DIR_FULL 8 /* no free directories on ram pack */ -#define PFS_ERR_EXIST 9 /* file exists */ -#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ -#define PFS_ERR_DEVICE 11 /* wrong device type */ -#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */ -#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */ - -#define OS_PFS_VERSION 0x0200 -#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) -#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) - -#define OS_GBPAK_POWER 0x01 -#define OS_GBPAK_RSTB_DETECTION 0x04 -#define OS_GBPAK_RSTB_STATUS 0x08 -#define OS_GBPAK_GBCART_PULL 0x40 -#define OS_GBPAK_GBCART_ON 0x80 - -#define OS_GBPAK_POWER_OFF 0 -#define OS_GBPAK_POWER_ON 1 - -#define PFS_FILE_NAME_LEN 16 -#define PFS_FILE_EXT_LEN 4 -#define BLOCKSIZE 32 /* bytes */ -#define PFS_ONE_PAGE 8 /* blocks */ -#define PFS_MAX_BANKS 62 -#define PFS_LABEL_AREA 7 -#define PFS_INODE_SIZE_PER_PAGE 128 -#define PFS_PAGE_NOT_USED 3 -#define PFS_WRITTEN 2 -#define PFS_PAGE_SIZE (BLOCKSIZE * PFS_ONE_PAGE) - -#define PFS_READ 0 -#define PFS_WRITE 1 -#define PFS_CREATE 2 - -#define PFS_INITIALIZED 0x01 -#define PFS_CORRUPTED 0x02 -#define PFS_ID_BROKEN 0x04 -#define PFS_MOTOR_INITIALIZED 0x08 -#define PFS_GBPAK_INITIALIZED 0x10 - -/************************************************************************** - * - * Macro definitions - * - */ - -#define osMotorStop(pfs) osMotorAccess(pfs, 0) -#define osMotorStart(pfs) osMotorAccess(pfs, 1) - -#define SET_ACTIVEBANK_TO_ZERO \ - if (pfs->activebank != 0) \ - { \ - pfs->activebank = 0; \ - ERRCK(__osPfsSelectBank(pfs)) \ - } - -#define PFS_CHECK_ID \ - if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ - return PFS_ERR_NEW_PACK; - -#define PFS_CHECK_STATUS \ - if ((pfs->status & PFS_INITIALIZED) == 0) \ - return PFS_ERR_INVALID; - -#define PFS_GET_STATUS \ - __osSiGetAccess(); \ - ret = __osPfsGetStatus(queue, channel); \ - __osSiRelAccess(); \ - if (ret != 0) \ - return ret; - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -s32 osPfsIsPlug(OSMesgQueue *, u8 *); -s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name, s32 num_bytes, s32 *file_no); -s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name, s32 *file_no); -s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name); -s32 osPfsFileState(OSPfs *pfs, s32 file_no, OSPfsState *state); -s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data); -s32 osPfsFreeBlocks(OSPfs* pfs, s32 *bytes_not_used); -s32 osPfsReSizeFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, u32 numbytes); - -#if VERSION >= VERSION_NTSC_1_0 -s32 osPfsInitPak(OSMesgQueue *mq, OSPfs *pfs, s32 channel, s32 *arg3); -#else -s32 osPfsInitPak(OSMesgQueue *mq, OSPfs *pfs, s32 channel); -#endif - -s32 osMotorAccess(OSPfs *pfs, u32 vibrate); -void osSetUpMempakWrite(s32 channel, OSPifRam* buf); -s32 osMotorProbe(OSMesgQueue *mq, OSPfs *pfs, s32 channel); - -s32 osGbpakCheckConnector(OSPfs *pfs, u8 *status); -s32 osGbpakGetStatus(OSPfs *pfs, u8 *status); -s32 osGbpakInit(OSMesgQueue *siMessegeQ, OSPfs *pfs, s32 channel); -s32 osGbpakPower(OSPfs *pfs, s32 flag); -s32 osGbpakReadId(OSPfs *pfs, OSGbpakId *id, u8 *status); -s32 osGbpakReadWrite(OSPfs *pfs, u16 flag, u16 address, u8 *buffer, u16 size); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_PFS_H_ */ diff --git a/src/include/PR/os_pi.h b/src/include/PR/os_pi.h deleted file mode 100644 index d41375dc5..000000000 --- a/src/include/PR/os_pi.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef _ULTRA64_PI_H_ -#define _ULTRA64_PI_H_ - -/* Ultra64 Parallel Interface */ - -/* Types */ - -typedef struct -{ - u32 errStatus; - void *dramAddr; - void *C2Addr; - u32 sectorSize; - u32 C1ErrNum; - u32 C1ErrSector[4]; -} __OSBlockInfo; - -typedef struct -{ - u32 cmdType; - u16 transferMode; - u16 blockNum; - s32 sectorNum; - u32 devAddr; - u32 bmCtlShadow; - u32 seqCtlShadow; - __OSBlockInfo block[2]; -} __OSTranxInfo; - -typedef struct OSPiHandle_s -{ - struct OSPiHandle_s *next; - u8 type; - u8 latency; - u8 pageSize; - u8 relDuration; - u8 pulse; - u8 domain; - u32 baseAddress; - u32 speed; - __OSTranxInfo transferInfo; -} OSPiHandle; - -typedef struct -{ - u8 type; - u32 address; -} OSPiInfo; - -typedef struct -{ - u16 type; - u8 pri; - u8 status; - OSMesgQueue *retQueue; -} OSIoMesgHdr; - -typedef struct -{ - /*0x00*/ OSIoMesgHdr hdr; - /*0x08*/ void *dramAddr; - /*0x0C*/ u32 devAddr; - /*0x10*/ u32 size; - OSPiHandle *piHandle; //from the official definition -} OSIoMesg; - -typedef struct { - s32 active; /* Status flag */ - OSThread *thread; /* Calling thread */ - OSMesgQueue *cmdQueue; /* Command queue */ - OSMesgQueue *evtQueue; /* Event queue */ - OSMesgQueue *acsQueue; /* Access queue */ - /* Raw DMA routine */ - s32 (*dma)(s32, u32, void *, u32); - s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); -} OSDevMgr; - -/* Definitions */ - -#define OS_READ 0 // device -> RDRAM -#define OS_WRITE 1 // device <- RDRAM - -#define OS_MESG_PRI_NORMAL 0 -#define OS_MESG_PRI_HIGH 1 - -#define WAIT_ON_IOBUSY(stat) \ - stat = IO_READ(PI_STATUS_REG); \ - while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ - stat = IO_READ(PI_STATUS_REG); - -#define UPDATE_REG(reg, var) \ - if (cHandle->var != pihandle->var) \ - IO_WRITE(reg, pihandle->var); - -#define LEO_BASE_REG 0x05000000 - -#define LEO_CMD (LEO_BASE_REG + 0x508) -#define LEO_STATUS (LEO_BASE_REG + 0x508) - -#define LEO_BM_CTL (LEO_BASE_REG + 0x510) -#define LEO_BM_STATUS (LEO_BASE_REG + 0x510) - -#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518) -#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518) - -#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) //C2 Sector Buffer -#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) //Data Sector Buffer -#define LEO_DATA (LEO_BASE_REG + 0x500) //Data -#define LEO_MISC_REG (LEO_BASE_REG + 0x504) //Misc Register -#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) //Current Track -#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) //Sector Error Status -#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) //Current Sector -#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) //Hard Reset -#define LEO_C1_S0 (LEO_BASE_REG + 0x524) //C1 -#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) //Sector Size (in bytes) -#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) //C1 -#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) //Sectors per Block, Full Size -#define LEO_C1_S4 (LEO_BASE_REG + 0x534) //C1 -#define LEO_C1_S6 (LEO_BASE_REG + 0x538) //C1 -#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) //Current Address? -#define LEO_ID_REG (LEO_BASE_REG + 0x540) //ID -#define LEO_TEST_REG (LEO_BASE_REG + 0x544) //Test Read -#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) //Test Write -#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) //Microsequencer RAM - -#define LEO_STATUS_PRESENCE_MASK 0xFFFF - -#define LEO_STATUS_DATA_REQUEST 0x40000000 -#define LEO_STATUS_C2_TRANSFER 0x10000000 -#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000 -#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000 -#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000 -#define LEO_STATUS_DISK_PRESENT 0x01000000 -#define LEO_STATUS_BUSY_STATE 0x00800000 -#define LEO_STATUS_RESET_STATE 0x00400000 -#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000 -#define LEO_STATUS_HEAD_RETRACTED 0x00080000 -#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000 -#define LEO_STATUS_MECHANIC_ERROR 0x00020000 -#define LEO_STATUS_DISK_CHANGE 0x00010000 - -#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) -#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) -#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED) -#define LEO_STATUS_MODE_ACTIVE 0 - -#define LEO_CUR_TK_INDEX_LOCK 0x60000000 - -#define LEO_BM_STATUS_RUNNING 0x80000000 -#define LEO_BM_STATUS_ERROR 0x04000000 -#define LEO_BM_STATUS_MICRO 0x02000000 -#define LEO_BM_STATUS_BLOCK 0x01000000 -#define LEO_BM_STATUS_C1CORRECTION 0x00800000 -#define LEO_BM_STATUS_C1DOUBLE 0x00400000 -#define LEO_BM_STATUS_C1SINGLE 0x00200000 -#define LEO_BM_STATUS_C1ERROR 0x00010000 - -#define LEO_BM_CTL_START 0x80000000 -#define LEO_BM_CTL_MODE 0x40000000 -#define LEO_BM_CTL_IMASK 0x20000000 -#define LEO_BM_CTL_RESET 0x10000000 -#define LEO_BM_CTL_DISABLE_OR 0x08000000 -#define LEO_BM_CTL_DISABLE_C1 0x04000000 -#define LEO_BM_CTL_BLOCK 0x02000000 -#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 - -#define LEO_BM_CTL_CONTROL_MASK 0xFF000000 -#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000 -#define LEO_BM_CTL_SECTOR_SHIFT 16 - -#define LEO_CMD_TYPE_0 0 -#define LEO_CMD_TYPE_1 1 -#define LEO_CMD_TYPE_2 2 - -#define LEO_ERROR_GOOD 0 -#define LEO_ERROR_4 4 -#define LEO_ERROR_22 22 -#define LEO_ERROR_23 23 -#define LEO_ERROR_24 24 -#define LEO_ERROR_29 29 - -/* Functions */ - -s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, - u32 devAddr, void *vAddr, u32 nbytes, OSMesgQueue *mq); -void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, - s32 cmdMsgCnt); -OSMesgQueue *osPiGetCmdQueue(void); -s32 osPiWriteIo(u32 devAddr, u32 data); -s32 osPiReadIo(u32 devAddr, u32 *data); -s32 osPiRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size); -s32 osEPiRawStartDma(OSPiHandle *pihandle, s32 direction, u32 devAddr, void *dramAddr, u32 size); -void __osDevMgrMain(void *args); - - -#endif diff --git a/src/include/PR/os_thread.h b/src/include/PR/os_thread.h deleted file mode 100644 index 5a92dd34b..000000000 --- a/src/include/PR/os_thread.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef _ULTRA64_THREAD_H_ -#define _ULTRA64_THREAD_H_ - -/* Recommended priorities for system threads */ -#define OS_PRIORITY_MAX 255 -#define OS_PRIORITY_VIMGR 254 -#define OS_PRIORITY_RMON 250 -#define OS_PRIORITY_RMONSPIN 200 -#define OS_PRIORITY_PIMGR 150 -#define OS_PRIORITY_SIMGR 140 -#define OS_PRIORITY_APPMAX 127 -#define OS_PRIORITY_IDLE 0 - -#define OS_STATE_STOPPED 1 -#define OS_STATE_RUNNABLE 2 -#define OS_STATE_RUNNING 4 -#define OS_STATE_WAITING 8 - -/* Types */ - -typedef s32 OSPri; -typedef s32 OSId; - -typedef union -{ - struct { - f32 f_odd2; - f32 f_odd; - f32 f_even2; - f32 f_even; - } f; -} __OSfp; - -typedef struct -{ - u64 at, v0, v1, a0, a1, a2, a3; - u64 t0, t1, t2, t3, t4, t5, t6, t7; - u64 s0, s1, s2, s3, s4, s5, s6, s7; - u64 t8, t9, gp, sp, s8, ra; - u64 lo, hi; - u32 sr, pc, cause, badvaddr, rcp; - u32 fpcsr; - __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; - __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; -} __OSThreadContext; - -typedef struct -{ - u32 flag; - u32 count; - u64 time; -} __OSThreadprofile_s; - -typedef struct OSThread_s -{ - /*0x00*/ struct OSThread_s *next; - /*0x04*/ OSPri priority; - /*0x08*/ struct OSThread_s **queue; - /*0x0C*/ struct OSThread_s *tlnext; - /*0x10*/ u16 state; - /*0x12*/ u16 flags; - /*0x14*/ OSId id; - /*0x18*/ int fp; - /*0x1C*/ __OSThreadprofile_s *thprof; - /*0x20*/ __OSThreadContext context; -} OSThread; - - -/* Functions */ - -void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), - void *arg, void *sp, OSPri pri); -OSId osGetThreadId(OSThread *thread); -OSPri osGetThreadPri(OSThread *thread); -void osSetThreadPri(OSThread *thread, OSPri pri); -void osStartThread(OSThread *thread); -void osStopThread(OSThread *thread); - -#endif diff --git a/src/include/PR/os_time.h b/src/include/PR/os_time.h deleted file mode 100644 index 5020599f4..000000000 --- a/src/include/PR/os_time.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _ULTRA64_TIME_H_ -#define _ULTRA64_TIME_H_ -#include - -/* Types */ - -typedef struct OSTimer_str -{ - struct OSTimer_str *next; - struct OSTimer_str *prev; - u64 interval; - u64 remaining; - OSMesgQueue *mq; - OSMesg *msg; -} OSTimer; - -typedef u64 OSTime; - -/* Functions */ - -OSTime osGetTime(void); -void osSetTime(OSTime time); -int osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMesg msg); - -#endif diff --git a/src/include/PR/os_vi.h b/src/include/PR/os_vi.h deleted file mode 100644 index 94237e1b0..000000000 --- a/src/include/PR/os_vi.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef _ULTRA64_VI_H_ -#define _ULTRA64_VI_H_ - -/* Ultra64 Video Interface */ - - -/* - * Video Interface (VI) mode type - */ -#define OS_VI_NTSC_LPN1 0 /* NTSC */ -#define OS_VI_NTSC_LPF1 1 -#define OS_VI_NTSC_LAN1 2 -#define OS_VI_NTSC_LAF1 3 -#define OS_VI_NTSC_LPN2 4 -#define OS_VI_NTSC_LPF2 5 -#define OS_VI_NTSC_LAN2 6 -#define OS_VI_NTSC_LAF2 7 -#define OS_VI_NTSC_HPN1 8 -#define OS_VI_NTSC_HPF1 9 -#define OS_VI_NTSC_HAN1 10 -#define OS_VI_NTSC_HAF1 11 -#define OS_VI_NTSC_HPN2 12 -#define OS_VI_NTSC_HPF2 13 - -#define OS_VI_PAL_LPN1 14 /* PAL */ -#define OS_VI_PAL_LPF1 15 -#define OS_VI_PAL_LAN1 16 -#define OS_VI_PAL_LAF1 17 -#define OS_VI_PAL_LPN2 18 -#define OS_VI_PAL_LPF2 19 -#define OS_VI_PAL_LAN2 20 -#define OS_VI_PAL_LAF2 21 -#define OS_VI_PAL_HPN1 22 -#define OS_VI_PAL_HPF1 23 -#define OS_VI_PAL_HAN1 24 -#define OS_VI_PAL_HAF1 25 -#define OS_VI_PAL_HPN2 26 -#define OS_VI_PAL_HPF2 27 - -#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ -#define OS_VI_MPAL_LPF1 29 -#define OS_VI_MPAL_LAN1 30 -#define OS_VI_MPAL_LAF1 31 -#define OS_VI_MPAL_LPN2 32 -#define OS_VI_MPAL_LPF2 33 -#define OS_VI_MPAL_LAN2 34 -#define OS_VI_MPAL_LAF2 35 -#define OS_VI_MPAL_HPN1 36 -#define OS_VI_MPAL_HPF1 37 -#define OS_VI_MPAL_HAN1 38 -#define OS_VI_MPAL_HAF1 39 -#define OS_VI_MPAL_HPN2 40 -#define OS_VI_MPAL_HPF2 41 - -#define OS_VI_FPAL_LPN1 42 /* FPAL - fullscreen PAL */ -#define OS_VI_FPAL_LPF1 43 -#define OS_VI_FPAL_LAN1 44 -#define OS_VI_FPAL_LAF1 45 -#define OS_VI_FPAL_LPN2 46 -#define OS_VI_FPAL_LPF2 47 -#define OS_VI_FPAL_LAN2 48 -#define OS_VI_FPAL_LAF2 49 -#define OS_VI_FPAL_HPN1 50 -#define OS_VI_FPAL_HPF1 51 -#define OS_VI_FPAL_HAN1 52 -#define OS_VI_FPAL_HAF1 53 -#define OS_VI_FPAL_HPN2 54 -#define OS_VI_FPAL_HPF2 55 - -/* Special Features */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 - -#define OS_VI_GAMMA 0x08 -#define OS_VI_GAMMA_DITHER 0x04 -#define OS_VI_DIVOT 0x10 -#define OS_VI_DITHER_FILTER 0x10000 -#define OS_VI_UNK200 0x200 -#define OS_VI_UNK100 0x100 - -#define VI_STATE_01 0x01 -#define VI_STATE_XSCALE_UPDATED 0x02 -#define VI_STATE_YSCALE_UPDATED 0x04 -#define VI_STATE_08 0x08 -#define VI_STATE_10 0x10 -#define VI_STATE_BLACK 0x20 -#define VI_STATE_REPEATLINE 0x40 -#define VI_STATE_FADE 0x80 - -#define VI_STATE_BLACK 0x20 - -#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */ - -#define VI_SCALE_MASK 0xfff -#define VI_2_10_FPART_MASK 0x3ff -#define VI_SUBPIXEL_SH 0x10 - -#define BURST(hsync_width, color_width, vsync_width, color_start) \ - (hsync_width | (color_width << 8) | (vsync_width << 16) | (color_start << 20)) -#define WIDTH(v) v -#define VSYNC(v) v -#define HSYNC(duration, leap) (duration | (leap << 16)) -#define LEAP(upper, lower) ((upper << 16) | lower) -#define START(start, end) ((start << 16) | end) - -#define FTOFIX(val, i, f) ((u32)(val * (f32)(1 << f)) & ((1 << (i + f)) - 1)) - -#define F210(val) FTOFIX(val, 2, 10) -#define SCALE(scaleup, off) (F210((1.0f / (f32)scaleup)) | (F210((f32)off) << 16)) - -#define VCURRENT(v) v //seemingly unused -#define ORIGIN(v) v -#define VINTR(v) v -#define HSTART START - -/* Types */ - -typedef struct -{ - u32 ctrl; - u32 width; - u32 burst; - u32 vSync; - u32 hSync; - u32 leap; - u32 hStart; - u32 xScale; - u32 vCurrent; -} OSViCommonRegs; - -typedef struct -{ - u32 origin; - u32 yScale; - u32 vStart; - u32 vBurst; - u32 vIntr; -} OSViFieldRegs; - -typedef struct -{ - u8 type; - OSViCommonRegs comRegs; - OSViFieldRegs fldRegs[2]; -} OSViMode; - -typedef struct -{ - /* 0x00 */ u16 unk00; //some kind of flags. swap buffer sets to 0x10 - /* 0x02 */ u16 retraceCount; - /* 0x04 */ void* buffer; - /* 0x08 */ OSViMode *unk08; - /* 0x0c */ u32 features; - /* 0x10 */ OSMesgQueue *mq; - /* 0x14 */ OSMesg *msg; - /* 0x18 */ u32 unk18; - /* 0x1c */ u32 unk1c; - /* 0x20 */ u32 unk20; - /* 0x24 */ f32 unk24; - /* 0x28 */ u16 unk28; - /* 0x2c */ u32 unk2c; -} OSViContext; - -typedef struct -{ - /* 0x0 */ f32 factor; - /* 0x4 */ u16 offset; - /* 0x8 */ u32 scale; -} __OSViScale; - -typedef struct -{ - /* 0x0 */ u16 state; - /* 0x2 */ u16 retraceCount; - /* 0x4 */ void *framep; - /* 0x8 */ OSViMode *modep; - /* 0xC */ u32 control; - /* 0x10 */ OSMesgQueue *msgq; - /* 0x14 */ OSMesg msg; - /* 0x18 */ __OSViScale x; - /* 0x24 */ __OSViScale y; -} __OSViContext; - -void osCreateViManager(OSPri pri); -void osViSetMode(OSViMode *mode); -void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount); -void osViBlack(u8 active); -void osViSetSpecialFeatures(u32 func); -void osViSwapBuffer(void *vaddr); -void osViSetXScale(f32 scale); -void osViSetYScale(f32 scale); - - -#define OS_VI_NTSC_LPN1 0 /* NTSC */ -#define OS_VI_NTSC_LPF1 1 -#define OS_VI_NTSC_LAN1 2 -#define OS_VI_NTSC_LAF1 3 -#define OS_VI_NTSC_LPN2 4 -#define OS_VI_NTSC_LPF2 5 -#define OS_VI_NTSC_LAN2 6 -#define OS_VI_NTSC_LAF2 7 -#define OS_VI_NTSC_HPN1 8 -#define OS_VI_NTSC_HPF1 9 -#define OS_VI_NTSC_HAN1 10 -#define OS_VI_NTSC_HAF1 11 -#define OS_VI_NTSC_HPN2 12 -#define OS_VI_NTSC_HPF2 13 - -#define OS_VI_PAL_LPN1 14 /* PAL */ -#define OS_VI_PAL_LPF1 15 -#define OS_VI_PAL_LAN1 16 -#define OS_VI_PAL_LAF1 17 -#define OS_VI_PAL_LPN2 18 -#define OS_VI_PAL_LPF2 19 -#define OS_VI_PAL_LAN2 20 -#define OS_VI_PAL_LAF2 21 -#define OS_VI_PAL_HPN1 22 -#define OS_VI_PAL_HPF1 23 -#define OS_VI_PAL_HAN1 24 -#define OS_VI_PAL_HAF1 25 -#define OS_VI_PAL_HPN2 26 -#define OS_VI_PAL_HPF2 27 - -extern OSViMode osViModeTable[]; /* Global VI mode table */ - - -#endif diff --git a/src/include/PR/sptask.h b/src/include/PR/sptask.h deleted file mode 100644 index 2d9abb6eb..000000000 --- a/src/include/PR/sptask.h +++ /dev/null @@ -1,122 +0,0 @@ -#ifndef _ULTRA64_SPTASK_H_ -#define _ULTRA64_SPTASK_H_ - -/* Task Types */ -#define M_GFXTASK 1 -#define M_AUDTASK 2 -#define M_VIDTASK 3 -#define M_HVQTASK 6 -#define M_HVQMTASK 7 - -#if (defined(F3DEX_GBI) || defined(F3DLP_GBI) || defined(F3DEX_GBI_2) || 1) -#define OS_YIELD_DATA_SIZE 0xc00 -#else -#define OS_YIELD_DATA_SIZE 0x900 -#endif -#define OS_YIELD_AUDIO_SIZE 0x400 - -/* Flags */ -#define M_TASK_FLAG0 1 -#define M_TASK_FLAG1 2 - -#define OS_TASK_YIELDED 0x0001 -#define OS_TASK_DP_WAIT 0x0002 -#define OS_TASK_LOADABLE 0x0004 -#define OS_TASK_SP_ONLY 0x0008 -#define OS_TASK_USR0 0x0010 -#define OS_TASK_USR1 0x0020 -#define OS_TASK_USR2 0x0040 -#define OS_TASK_USR3 0x0080 - -/* SpStatus */ -#define SPSTATUS_CLEAR_HALT 0x00000001 -#define SPSTATUS_SET_HALT 0x00000002 -#define SPSTATUS_CLEAR_BROKE 0x00000004 -#define SPSTATUS_CLEAR_INTR 0x00000008 -#define SPSTATUS_SET_INTR 0x00000010 -#define SPSTATUS_CLEAR_SSTEP 0x00000020 -#define SPSTATUS_SET_SSTEP 0x00000040 -#define SPSTATUS_CLEAR_INTR_ON_BREAK 0x00000080 -#define SPSTATUS_SET_INTR_ON_BREAK 0x00000100 -#define SPSTATUS_CLEAR_SIGNAL0 0x00000200 -#define SPSTATUS_SET_SIGNAL0 0x00000400 -#define SPSTATUS_CLEAR_SIGNAL1 0x00000800 -#define SPSTATUS_SET_SIGNAL1 0x00001000 -#define SPSTATUS_CLEAR_SIGNAL2 0x00002000 -#define SPSTATUS_SET_SIGNAL2 0x00004000 -#define SPSTATUS_CLEAR_SIGNAL3 0x00008000 -#define SPSTATUS_SET_SIGNAL3 0x00010000 -#define SPSTATUS_CLEAR_SIGNAL4 0x00020000 -#define SPSTATUS_SET_SIGNAL4 0x00040000 -#define SPSTATUS_CLEAR_SIGNAL5 0x00080000 -#define SPSTATUS_SET_SIGNAL5 0x00100000 -#define SPSTATUS_CLEAR_SIGNAL6 0x00200000 -#define SPSTATUS_SET_SIGNAL6 0x00800000 -#define SPSTATUS_CLEAR_SIGNAL7 0x01000000 -#define SPSTATUS_SET_SIGNAL7 0x02000000 - -#define SPSTATUS_HALT 0x0001 -#define SPSTATUS_BROKE 0x0002 -#define SPSTATUS_DMA_BUSY 0x0004 -#define SPSTATUS_DMA_FULL 0x0008 -#define SPSTATUS_IO_FULL 0x0010 -#define SPSTATUS_SINGLE_STEP 0x0020 -#define SPSTATUS_INTERRUPT_ON_BREAK 0x0040 -#define SPSTATUS_SIGNAL0_SET 0x0080 -#define SPSTATUS_SIGNAL1_SET 0x0100 -#define SPSTATUS_SIGNAL2_SET 0x0200 -#define SPSTATUS_SIGNAL3_SET 0x0400 -#define SPSTATUS_SIGNAL4_SET 0x0800 -#define SPSTATUS_SIGNAL5_SET 0x1000 -#define SPSTATUS_SIGNAL6_SET 0x2000 -#define SPSTATUS_SIGNAL7_SET 0x4000 - -/* Types */ -/* Types */ - -typedef struct -{ - /*0x00*/ u32 type; - /*0x04*/ u32 flags; - - /*0x08*/ u64 *ucode_boot; - /*0x0C*/ u32 ucode_boot_size; - - /*0x10*/ u64 *ucode; - /*0x14*/ u32 ucode_size; - - /*0x18*/ u64 *ucode_data; - /*0x1C*/ u32 ucode_data_size; - - /*0x20*/ u64 *dram_stack; - /*0x24*/ u32 dram_stack_size; - - /*0x28*/ u64 *output_buff; - /*0x2C*/ u64 *output_buff_size; - - /*0x30*/ u64 *data_ptr; - /*0x34*/ u32 data_size; - - /*0x38*/ u64 *yield_data_ptr; - /*0x3C*/ u32 yield_data_size; -} OSTask_t; // size = 0x40 - -typedef union { - OSTask_t t; - long long int force_structure_alignment; -} OSTask; - -typedef u32 OSYieldResult; - -/* Functions */ - -#define osSpTaskStart(p) \ - osSpTaskLoad(p); \ - osSpTaskStartGo(p); - -void osSpTaskLoad(OSTask *task); -void osSpTaskStartGo(OSTask *task); -void osSpTaskYield(void); -OSYieldResult osSpTaskYielded(OSTask *task); - -#endif diff --git a/src/include/PR/synthInternals.h b/src/include/PR/synthInternals.h deleted file mode 100755 index 8589574f8..000000000 --- a/src/include/PR/synthInternals.h +++ /dev/null @@ -1,337 +0,0 @@ -/*==================================================================== - * audioInternals.h - * - * Synopsis: - * - * Copyright 1993, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -#ifndef __audioInternals__ -#define __audioInternals__ - -#include - -/* - * filter message ids - */ -enum { - AL_FILTER_FREE_VOICE, - AL_FILTER_SET_SOURCE, - AL_FILTER_ADD_SOURCE, - AL_FILTER_ADD_UPDATE, - AL_FILTER_RESET, - AL_FILTER_SET_WAVETABLE, -/* AL_FILTER_SET_DMA_PROC,*/ -/* AL_FILTER_SKIP_LOOP,*/ - AL_FILTER_SET_DRAM, - AL_FILTER_SET_PITCH, - AL_FILTER_SET_UNITY_PITCH, - AL_FILTER_START, -/* AL_FILTER_SET_DECAY,*/ -/* AL_FILTER_SET_FC,*/ - AL_FILTER_SET_STATE, - AL_FILTER_SET_VOLUME, - AL_FILTER_SET_PAN, - AL_FILTER_START_VOICE_ALT, - AL_FILTER_START_VOICE, - AL_FILTER_STOP_VOICE, - AL_FILTER_SET_FXAMT -}; - -#define AL_MAX_RSP_SAMPLES 160 - -/* - * buffer locations based on AL_MAX_RSP_SAMPLES - */ -#define AL_DECODER_IN 0 -#define AL_RESAMPLER_OUT 0 -#define AL_TEMP_0 0 -#define AL_DECODER_OUT 320 -#define AL_TEMP_1 320 -#define AL_TEMP_2 640 -#define AL_MAIN_L_OUT 1088 -#define AL_MAIN_R_OUT 1408 -#define AL_AUX_L_OUT 1728 -#define AL_AUX_R_OUT 2048 - -/* - * filter types - */ -enum { - AL_ADPCM, - AL_RESAMPLE, - AL_BUFFER, - AL_SAVE, - AL_ENVMIX, - AL_FX, - AL_AUXBUS, - AL_MAINBUS -}; - -typedef struct ALParam_s { - struct ALParam_s *next; - s32 delta; - s16 type; - union { - f32 f; - s32 i; - } data; - union { - f32 f; - s32 i; - } moredata; - union { - f32 f; - s32 i; - } stillmoredata; - union { - f32 f; - s32 i; - } yetstillmoredata; -} ALParam; - -typedef struct { - struct ALParam_s *next; - s32 delta; - s16 type; - s16 unity; /* disable resampler */ - f32 pitch; - s16 volume; - ALPan pan; - u8 fxMix; - s32 samples; - struct ALWaveTable_s *wave; -} ALStartParamAlt; - -typedef struct { - struct ALParam_s *next; - s32 delta; - s16 type; - s16 unity; /* disable resampler */ - struct ALWaveTable_s *wave; -} ALStartParam; - -typedef struct { - struct ALParam_s *next; - s32 delta; - s16 type; - struct PVoice_s *pvoice; -} ALFreeParam; - -typedef Acmd *(*ALCmdHandler)(void *, s16 *, s32, s32, Acmd *); -typedef s32 (*ALSetParam)(void *, s32, void *); - -typedef struct ALFilter_s { - struct ALFilter_s *source; - ALCmdHandler handler; - ALSetParam setParam; - s16 inp; - s16 outp; - s32 type; -} ALFilter; - -void alFilterNew(ALFilter *f, ALCmdHandler h, ALSetParam s, s32 type); - -#define AL_MAX_ADPCM_STATES 3 /* Depends on number of subframes - * per frame and loop length - */ -typedef struct { - ALFilter filter; - ADPCM_STATE *state; - ADPCM_STATE *lstate; - ALRawLoop loop; - struct ALWaveTable_s *table; - s32 bookSize; - ALDMAproc dma; - void *dmaState; - s32 sample; - s32 lastsam; - s32 first; - s32 memin; -} ALLoadFilter; - -void alLoadNew(ALLoadFilter *f, ALDMANew dma, ALHeap *hp); -Acmd *alAdpcmPull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); -Acmd *alRaw16Pull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); -s32 alLoadParam(void *filter, s32 paramID, void *param); - -typedef struct ALResampler_s { - ALFilter filter; - RESAMPLE_STATE *state; - f32 ratio; - s32 upitch; - f32 delta; - s32 first; - ALParam *ctrlList; - ALParam *ctrlTail; - s32 motion; -} ALResampler; - -typedef struct { - s16 fc; - s16 fgain; - union { - s16 fccoef[16]; - s64 force_aligned; - } fcvec; - POLEF_STATE *fstate; - s32 first; -} ALLowPass; - -typedef struct { - u32 input; - u32 output; - s16 ffcoef; - s16 fbcoef; - s16 gain; - f32 rsinc; - f32 rsval; - s32 rsdelta; - f32 rsgain; - ALLowPass *lp; - ALResampler *rs; -} ALDelay; - -typedef s32 (*ALSetFXParam)(void *, s32, void *); -typedef struct { - struct ALFilter_s filter; - s16 *base; - s16 *input; - u32 length; - ALDelay *delay; - u8 section_count; - ALSetFXParam paramHdl; -} ALFx; - -void alFxNew(ALFx *r, ALSynConfig *c, ALHeap *hp); -Acmd *alFxPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); -s32 alFxParam(void *filter, s32 paramID, void *param); -s32 alFxParamHdl(void *filter, s32 paramID, void *param); - -#define AL_MAX_MAIN_BUS_SOURCES 1 -typedef struct ALMainBus_s { - ALFilter filter; - s32 sourceCount; - s32 maxSources; - ALFilter **sources; -} ALMainBus; - -void alMainBusNew(ALMainBus *m, void *ptr, s32 len); -Acmd *alMainBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); -s32 alMainBusParam(void *filter, s32 paramID, void *param); - -#define AL_MAX_AUX_BUS_SOURCES 8 -#define AL_MAX_AUX_BUS_FX 1 -typedef struct ALAuxBus_s { - ALFilter filter; - s32 sourceCount; - s32 maxSources; - ALFilter **sources; - ALFx fx[AL_MAX_AUX_BUS_FX]; -} ALAuxBus; - -void alAuxBusNew(ALAuxBus *m, void *ptr, s32 len); -Acmd *alAuxBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); -s32 alAuxBusParam(void *filter, s32 paramID, void *param); - -void alResampleNew(ALResampler *r, ALHeap *hp); -Acmd *alResamplePull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); -s32 alResampleParam(void *f, s32 paramID, void *param); - -typedef struct ALSave_s { - ALFilter filter; - s32 dramout; - s32 first; -} ALSave; - -void alSaveNew(ALSave *r); -Acmd *alSavePull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); -s32 alSaveParam(void *f, s32 paramID, void *param); - -typedef struct ALEnvMixer_s { - u8 unk00[0x40]; - ALFilter filter; - ENVMIX_STATE *state; - s16 pan; - s16 volume; - s16 cvolL; - s16 cvolR; - s16 dryamt; - s16 wetamt; - u16 lratl; - s16 lratm; - s16 ltgt; - u16 rratl; - s16 rratm; - s16 rtgt; - s32 delta; - s32 segEnd; - s32 first; - ALParam *ctrlList; - ALParam *ctrlTail; - //ALFilter **sources; - s32 motion; -} ALEnvMixer; - -void alEnvmixerNew(ALEnvMixer *e, ALHeap *hp); -Acmd *alEnvmixerPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); -s32 alEnvmixerParam(void *filter, s32 paramID, void *param); - - -/* - * heap stuff - */ -typedef struct { - s32 magic; /* check structure integrety */ - s32 size; /* size of this allocated block */ - u8 *file; /* file that this alloc was called from */ - s32 line; /* line that it was called from */ - s32 count; /* heap call number */ - s32 pad0; - s32 pad1; - s32 pad2; /* Make it 32 bytes */ -} HeapInfo; - -#define AL_CACHE_ALIGN 15 - -/* - * synth stuff - */ - -typedef struct PVoice_s { - ALLink node; - struct ALVoice_s *vvoice; - ALFilter *channelKnob; - ALLoadFilter decoder; - ALResampler resampler; - ALEnvMixer envmixer; - s32 offset; -} PVoice; - -/* - * prototypes for private driver functions - */ -ALParam *__allocParam(void); -void __freeParam(ALParam *param); -void _freePVoice(PVoice *pvoice); -void _collectPVoices(void); - -s32 _timeToSamples(s32 micros); -ALMicroTime _samplesToTime(ALSynth *synth, s32 samples); - -#endif - diff --git a/src/include/PR/sys/regdef.h b/src/include/PR/sys/regdef.h deleted file mode 100755 index 8d319a2bc..000000000 --- a/src/include/PR/sys/regdef.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1990-1992, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ -/* - * Copyright 1985 by MIPS Computer Systems, Inc. - */ -#ifndef __SYS_REGDEF_H__ -#define __SYS_REGDEF_H__ - -#ident "$Revision: 3.7 $" - -#include "sgidefs.h" - -#if (_MIPS_SIM == _MIPS_SIM_ABI32) -#define zero $0 /* wired zero */ -#define AT $at /* assembler temp */ -#define v0 $2 /* return value */ -#define v1 $3 -#define a0 $4 /* argument registers */ -#define a1 $5 -#define a2 $6 -#define a3 $7 -#define t0 $8 /* caller saved */ -#define t1 $9 -#define t2 $10 -#define t3 $11 -#define t4 $12 /* caller saved - 32 bit env arg reg 64 bit */ -#define ta0 $12 /* caller saved in 32 bit - arg regs in 64 bit */ -#define t5 $13 -#define ta1 $13 -#define t6 $14 -#define ta2 $14 -#define t7 $15 -#define ta3 $15 -#define s0 $16 /* callee saved */ -#define s1 $17 -#define s2 $18 -#define s3 $19 -#define s4 $20 -#define s5 $21 -#define s6 $22 -#define s7 $23 -#define t8 $24 /* code generator */ -#define t9 $25 -#define jp $25 /* PIC jump register */ -#define k0 $26 /* kernel temporary */ -#define k1 $27 -#define gp $28 /* global pointer */ -#define sp $29 /* stack pointer */ -#define fp $30 /* frame pointer */ -#define s8 $30 /* calle saved */ -#define ra $31 /* return address */ -#endif - -#if (_MIPS_SIM == _MIPS_SIM_ABI64) -#define zero $0 /* wired zero */ -#define AT $at /* assembler temp */ -#define v0 $2 /* return value - caller saved */ -#define v1 $3 -#define a0 $4 /* argument registers */ -#define a1 $5 -#define a2 $6 -#define a3 $7 -#define a4 $8 /* arg reg 64 bit; caller saved in 32 bit */ -#define ta0 $8 -#define a5 $9 -#define ta1 $9 -#define a6 $10 -#define ta2 $10 -#define a7 $11 -#define ta3 $11 -#define t0 $12 /* caller saved */ -#define t1 $13 -#define t2 $14 -#define t3 $15 -#define s0 $16 /* callee saved */ -#define s1 $17 -#define s2 $18 -#define s3 $19 -#define s4 $20 -#define s5 $21 -#define s6 $22 -#define s7 $23 -#define t8 $24 /* caller saved */ -#define t9 $25 /* callee address for PIC/temp */ -#define jp $25 /* PIC jump register */ -#define k0 $26 /* kernel temporary */ -#define k1 $27 -#define gp $28 /* global pointer - caller saved for PIC */ -#define sp $29 /* stack pointer */ -#define fp $30 /* frame pointer */ -#define s8 $30 /* callee saved */ -#define ra $31 /* return address */ -#endif - -#endif /* __SYS_REGDEF_H__ */ diff --git a/src/include/PR/ucode.h b/src/include/PR/ucode.h deleted file mode 100644 index 37fd19775..000000000 --- a/src/include/PR/ucode.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _ULTRA64_UCODE_H_ -#define _ULTRA64_UCODE_H_ - -#define SP_DRAM_STACK_SIZE8 0x400 -#define SP_UCODE_SIZE 0x1000 -#define SP_UCODE_DATA_SIZE 0x800 - -// standard boot ucode -extern u64 rspF3DBootStart[], rspF3DBootEnd[]; - -// F3D ucode -extern u64 rspF3DStart[], rspF3DEnd[]; - -// F3D ucode data -extern u64 rspF3DDataStart[], rspF3DDataEnd[]; - -// aspMain (audio) ucode -extern u64 rspAspMainStart[], rspAspMainEnd[]; - -// aspMain ucode data -extern u64 rspAspMainDataStart[], rspAspMainDataEnd[]; - -#endif diff --git a/src/include/PR/ultratypes.h b/src/include/PR/ultratypes.h deleted file mode 100644 index f4c8a8ff0..000000000 --- a/src/include/PR/ultratypes.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _ULTRA64_TYPES_H_ -#define _ULTRA64_TYPES_H_ - -#ifndef NULL -#define NULL (void *)0 -#endif - -#define TRUE 1 -#define FALSE 0 - -#define OS_TV_PAL 0 -#define OS_TV_NTSC 1 -#define OS_TV_MPAL 2 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -typedef signed char s8; -typedef unsigned char u8; -typedef signed short int s16; -typedef unsigned short int u16; -typedef signed int s32; -typedef unsigned int u32; -typedef signed long long int s64; -typedef unsigned long long int u64; - -typedef volatile u8 vu8; -typedef volatile u16 vu16; -typedef volatile u32 vu32; -typedef volatile u64 vu64; -typedef volatile s8 vs8; -typedef volatile s16 vs16; -typedef volatile s32 vs32; -typedef volatile s64 vs64; - -typedef float f32; -typedef double f64; - -typedef unsigned long size_t; - -#endif - -#endif diff --git a/src/include/asm_helper.h b/src/include/asm_helper.h index 61b5cfa4a..2f9e90f9d 100644 --- a/src/include/asm_helper.h +++ b/src/include/asm_helper.h @@ -1,9 +1,9 @@ #ifndef _ASM_HELPER_H #define _ASM_HELPER_H -#include "PR/R4300.h" -#include "PR/sys/regdef.h" -#include "PR/sys/asm.h" -#include "PR/rcp.h" +#include +#include +#include +#include #define STAY1(stmnt) .set noreorder; stmnt; .set reorder; #define STAY2(stmnt, arg1) .set noreorder; stmnt, arg1; .set reorder; diff --git a/src/include/bss.h b/src/include/bss.h index e3a6a508e..0e187b5a3 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -11,7 +11,7 @@ extern u32 var8008ae2c; extern u32 var8008ae30; extern OSThread g_MainThread; extern OSMesgQueue var8008db30; -extern OSSched g_SchedThread; +extern OSSched g_Sched; extern OSViMode var8008dcc0[2]; extern OSViMode *var8008dd60[2]; extern u32 var8008de08; @@ -21,7 +21,6 @@ extern u8 g_BootBufferDirtyIndexes[3]; extern s32 g_BootBufferIndex0; extern OSPiHandle CartRomHandle; extern OSPiHandle LeoDiskHandle; -extern OSPifRam __osPfsPifRam; extern OSTimer var80090ab0; extern OSMesgQueue var80090ad0; extern OSMesg var80090ae8; @@ -59,19 +58,16 @@ extern u8 *var8009c644; extern u8 var8009c650[]; extern u8 *var8009c6d8; extern u8 *var8009c6dc; -extern __OSEventState __osEventStateTab[15]; extern OSTimer var8009c760; extern OSTime __osCurrentTime; extern u32 __osBaseCounter; extern u32 __osViIntrCount; extern OSMesgQueue __osPiAccessQueue; -extern OSPifRam __osContPifRam; extern u8 __osContLastCmd; extern u8 __osMaxControllers; extern OSTimer __osEepromTimer; extern OSMesgQueue __osEepromTimerQ; extern OSMesg __osEepromTimerMsg; -extern OSPifRam __osEepPifRam; extern u32 var8009ca84; extern u8 *g_FrameBuffers[2]; extern u8 var8009caec[4]; diff --git a/src/include/constants.h b/src/include/constants.h index 6dbf2cc13..82b65124a 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1,6 +1,7 @@ #ifndef _IN_CONSTANTS_H #define _IN_CONSTANTS_H #include "versions.h" +#include "math.h" #include "animations.h" #include "files.h" #include "sequences.h" diff --git a/src/include/data.h b/src/include/data.h index e3f044aaa..ef49054fe 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -33,7 +33,6 @@ extern OSPiHandle *__osCurrentHandle[2]; extern u32 var8005cf30; extern OSTime osClockRate; extern s32 osViClock; -extern u32 _osShutdown; extern u32 __osGlobalIntMask; extern u32 var8005cf84; extern u8 g_LoadType; @@ -83,8 +82,6 @@ extern u32 var8005f038; extern u16 *g_RdpOutBufferEnd; extern u16 *g_RdpOutBufferStart; extern struct rdptask *g_RdpCurTask; -extern ALGlobals *n_alGlobals; -extern ALGlobals *n_syn; extern u32 var8005f120; extern u32 var8005f124; extern u32 var8005f128; @@ -107,11 +104,7 @@ extern u32 var8005f704; extern OSViMode osViModeTable[]; extern u32 var80060890; extern OSTimer *__osTimerList; -extern __OSViContext var800608b0[2]; -extern __OSViContext *__osViCurr; -extern __OSViContext *__osViNext; extern u32 __osPiAccessQueueEnabled; -extern u32 __osThreadTail; extern OSThread *__osRunQueue; extern OSThread *__osActiveQueue; extern OSThread *__osRunningThread; diff --git a/src/include/lib/lib_2fba0.h b/src/include/lib/lib_2fba0.h index 4f1921fdf..798bed360 100644 --- a/src/include/lib/lib_2fba0.h +++ b/src/include/lib/lib_2fba0.h @@ -4,6 +4,4 @@ #include "data.h" #include "types.h" -void n_alInit(ALGlobals *g, ALSynConfig *c); - #endif diff --git a/src/include/lib/lib_30ce0.h b/src/include/lib/lib_30ce0.h deleted file mode 100644 index 0fbff6a9c..000000000 --- a/src/include/lib/lib_30ce0.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _IN_LIB_LIB_30CE0_H -#define _IN_LIB_LIB_30CE0_H -#include -#include "data.h" -#include "types.h" - -void n_alSynNew(ALSynConfig *c); - -#endif diff --git a/src/include/lib/lib_34240.h b/src/include/lib/lib_34240.h index 726919a14..4a2ddcb16 100644 --- a/src/include/lib/lib_34240.h +++ b/src/include/lib/lib_34240.h @@ -4,8 +4,7 @@ #include "data.h" #include "types.h" -u32 alCSPNew(void); -u32 func00034df8(void); +u32 __n_CSPHandleNextSeqEvent(void); u32 func00034f0c(void); u32 func00034fb8(void); u32 func00035110(void); diff --git a/src/include/lib/lib_37650.h b/src/include/lib/lib_37650.h index 104aee20f..397b1e99b 100644 --- a/src/include/lib/lib_37650.h +++ b/src/include/lib/lib_37650.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -void func00037650(ALCSPlayer *seqp, ALBank *bank); +void func00037650(N_ALCSPlayer *seqp, ALBank *bank); #endif diff --git a/src/include/lib/lib_39c80.h b/src/include/lib/lib_39c80.h index 081a11b7d..2b669501a 100644 --- a/src/include/lib/lib_39c80.h +++ b/src/include/lib/lib_39c80.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -void func00039c80(ALCSPlayer *seqp, s16 volume); +void func00039c80(N_ALCSPlayer *seqp, s16 volume); void func00039cd0(ALCSPlayer *seqp); u32 func00039e5c(void); diff --git a/src/include/lib/lib_3c430.h b/src/include/lib/lib_3c430.h index 73485f8c0..bf79ae856 100644 --- a/src/include/lib/lib_3c430.h +++ b/src/include/lib/lib_3c430.h @@ -4,6 +4,6 @@ #include "data.h" #include "types.h" -Acmd *func0003c430(s32 arg0, void *arg1); +Acmd *n_alSavePull(s32 arg0, void *arg1); #endif diff --git a/src/include/lib/lib_3d280.h b/src/include/lib/lib_3d280.h index 292867a4e..5284f3844 100644 --- a/src/include/lib/lib_3d280.h +++ b/src/include/lib/lib_3d280.h @@ -10,6 +10,5 @@ u32 func0003d69c(void); u32 func0003d72c(void); u32 func0003d8a4(void); u32 func0003d9cc(void); -void __n_resetPerfChanState(ALSeqPlayer *seqp, s32 chan); #endif diff --git a/src/include/lib/lib_3e3e0.h b/src/include/lib/lib_3e3e0.h index 275dd25e6..22e3b0276 100644 --- a/src/include/lib/lib_3e3e0.h +++ b/src/include/lib/lib_3e3e0.h @@ -8,7 +8,6 @@ u32 func0003e3e0(void); u32 func0003e490(void); u32 func0003e540(void); u32 func0003e5b8(void); -u32 n_alSynSetFXParam(void); u32 func0003e674(void); #endif diff --git a/src/include/lib/sched.h b/src/include/lib/sched.h index 818d9ed0b..c397461d9 100644 --- a/src/include/lib/sched.h +++ b/src/include/lib/sched.h @@ -1,6 +1,7 @@ #ifndef _IN_BOOT_SCHED_H #define _IN_BOOT_SCHED_H #include +#include void func00001b28(u32 arg0); void __scHandleRetraceViaPri(OSSched *sc, OSScTask *t); diff --git a/src/include/libultra_internal.h b/src/include/libultra_internal.h deleted file mode 100644 index 15bfadf89..000000000 --- a/src/include/libultra_internal.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _LIBULTRA_INTERNAL_H_ -#define _LIBULTRA_INTERNAL_H_ -#include - -typedef struct -{ - u32 initialized; //probably something like initialized? - OSThread *mgrThread; - OSMesgQueue *unk08; - OSMesgQueue *unk0c; - OSMesgQueue *unk10; - s32 (*dma_func)(s32,u32,void*,size_t); - u64 force_align; -} OSMgrArgs; - -typedef struct -{ - /* 0x0 */ __OSInode inode; - /* 0x100 */ u8 bank; - /* 0x101 */ u8 map[256]; -} __OSInodeCache; - -s32 __osDisableInt(); -void __osRestoreInt(s32); -s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer); -s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force); -void __osEnqueueAndYield(OSThread**); -void __osDequeueThread(OSThread**, OSThread*); -void __osEnqueueThread(OSThread**, OSThread*); -OSThread* __osPopThread(OSThread**); -s32 __osSiRawStartDma(s32, void*); -void __osSiCreateAccessQueue(); -void __osSiGetAccess(); -void __osSiRelAccess(); -u32 __osProbeTLB(void*); -void __osPiCreateAccessQueue(); -void __osPiGetAccess(); -void __osSetSR(u32); -u32 __osGetSR(); -void __osSetFpcCsr(u32); -s32 __osSiRawReadIo(u32, u32*); -s32 __osSiRawWriteIo(u32, u32); -s32 osPiRawReadIo(u32 a0, u32 *a1); -void __osSpSetStatus(u32); -u32 __osSpGetStatus(); -s32 __osSpSetPc(u32); -s32 __osSpDeviceBusy(); -s32 __osSiDeviceBusy(); -s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size); -void __osViInit(); -__OSViContext * __osViGetCurrentContext(); -void __osViSwapContext(); -void __osSetTimerIntr(u64); -u64 __osInsertTimer(OSTimer *); -void __osSetCompare(u32); -s32 __osAiDeviceBusy(); -void __osDispatchThread(); -u32 __osGetCause(); -s32 __osAtomicDec(u32*); -s32 __osPfsSelectBank(OSPfs *pfs, u8 bank); -u16 __osSumCalc(u8 *ptr, int length); -s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); -s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid); -s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp); -s32 __osGetId(OSPfs *pfs); -s32 __osCheckId(OSPfs *pfs); -s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank); -u8 __osContAddressCrc(u16 inaddr); -u8 __osContDataCrc(u8 *data); -s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 initial_page, u8 bank, __OSInodeUnit *final_page); -s32 __osGbpakSelectBank(OSPfs *pfs, u8 bank); - -#endif diff --git a/src/include/stdarg.h b/src/include/stdarg.h new file mode 100755 index 000000000..d39676633 --- /dev/null +++ b/src/include/stdarg.h @@ -0,0 +1,42 @@ +#ifndef STDARG_H +#define STDARG_H + +// When not building with IDO, use the builtin vaarg macros for portability. +#ifndef __sgi +#define va_list __builtin_va_list +#define va_start __builtin_va_start +#define va_arg __builtin_va_arg +#define va_end __builtin_va_end +#else + +typedef char *va_list; +#define _FP 1 +#define _INT 0 +#define _STRUCT 2 + +#define _VA_FP_SAVE_AREA 0x10 +#define _VA_ALIGN(p, a) (((unsigned int)(((char *)p) + ((a) > 4 ? (a) : 4) - 1)) & -((a) > 4 ? (a) : 4)) +#define va_start(vp, parmN) (vp = ((va_list)&parmN + sizeof(parmN))) + +#define __va_stack_arg(list, mode) \ + ( \ + ((list) = (char *)_VA_ALIGN(list, __builtin_alignof(mode)) + \ + _VA_ALIGN(sizeof(mode), 4)), \ + (((char *)list) - (_VA_ALIGN(sizeof(mode), 4) - sizeof(mode)))) + +#define __va_double_arg(list, mode) \ + ( \ + (((long)list & 0x1) /* 1 byte aligned? */ \ + ? (list = (char *)((long)list + 7), (char *)((long)list - 6 - _VA_FP_SAVE_AREA)) \ + : (((long)list & 0x2) /* 2 byte aligned? */ \ + ? (list = (char *)((long)list + 10), (char *)((long)list - 24 - _VA_FP_SAVE_AREA)) \ + : __va_stack_arg(list, mode)))) + +#define va_arg(list, mode) ((mode *)(((__builtin_classof(mode) == _FP && \ + __builtin_alignof(mode) == sizeof(double)) \ + ? __va_double_arg(list, mode) \ + : __va_stack_arg(list, mode))))[-1] +#define va_end(__list) + +#endif +#endif diff --git a/src/include/lib/libc/ldiv.h b/src/include/stdlib.h old mode 100644 new mode 100755 similarity index 69% rename from src/include/lib/libc/ldiv.h rename to src/include/stdlib.h index e4f86c292..6fbb6ce2f --- a/src/include/lib/libc/ldiv.h +++ b/src/include/stdlib.h @@ -1,6 +1,9 @@ -#ifndef _IN_LIB_LIBC_LDIV_H -#define _IN_LIB_LIBC_LDIV_H +#ifndef __STDLIB_H__ +#define __STDLIB_H__ +#ifndef NULL +#define NULL 0 +#endif typedef struct lldiv_t { long long quot; @@ -15,5 +18,4 @@ typedef struct ldiv_t lldiv_t lldiv(long long num, long long denom); ldiv_t ldiv(long num, long denom); - -#endif +#endif /* !__STDLIB_H__ */ diff --git a/src/include/string.h b/src/include/string.h new file mode 100755 index 000000000..9c809db00 --- /dev/null +++ b/src/include/string.h @@ -0,0 +1,55 @@ +#ifndef __STRING_H__ +#define __STRING_H__ +#ifdef __cplusplus +extern "C" { +#endif +#ident "$Revision: 1.23 $" +/* +* +* Copyright 1992, Silicon Graphics, Inc. +* All Rights Reserved. +* +* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.; +* the contents of this file may not be disclosed to third parties, copied or +* duplicated in any form, in whole or in part, without the prior written +* permission of Silicon Graphics, Inc. +* +* RESTRICTED RIGHTS LEGEND: +* Use, duplication or disclosure by the Government is subject to restrictions +* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data +* and Computer Software clause at DFARS 252.227-7013, and/or in similar or +* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - +* rights reserved under the Copyright Laws of the United States. +*/ +/* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ +/* Copyright (c) 1988 AT&T */ +/* All Rights Reserved */ + +/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF */ +/* UNIX System Laboratories, Inc. */ +/* The copyright notice above does not evidence any */ +/* actual or intended publication of such source code. */ + + +#if !defined(_SIZE_T) && !defined(_SIZE_T_) +#define _SIZE_T +#if (_MIPS_SZLONG == 32) +typedef unsigned int size_t; +#endif +#if (_MIPS_SZLONG == 64) +typedef unsigned long size_t; +#endif +#endif + +#ifndef NULL +#define NULL 0 +#endif + +extern void *memcpy(void *, const void *, size_t); +extern char *strchr(const char *, int); +extern size_t strlen(const char *); + +#ifdef __cplusplus +} +#endif +#endif /* !__STRING_H__ */ diff --git a/src/include/types.h b/src/include/types.h index 679c67794..b25936718 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -1,6 +1,8 @@ #ifndef _IN_TYPES_H #define _IN_TYPES_H #include +#include +#include "n_libaudio.h" #include "constants.h" #include "gbiex.h" #include "lang.h" @@ -6238,7 +6240,7 @@ struct var80094ed8 { /*0x0ec*/ u32 unk0ec; /*0x0f0*/ u32 unk0f0; /*0x0f4*/ u32 unk0f4; - /*0x0f8*/ ALCSPlayer *seqp; + /*0x0f8*/ N_ALCSPlayer *seqp; /*0x0fc*/ void *unk0fc; /*0x100*/ u16 unk100; /*0x104*/ u32 unk104; @@ -6948,7 +6950,7 @@ typedef struct { OSMesg audioFrameMsgBuf[8]; OSMesgQueue audioReplyMsgQ; OSMesg audioReplyMsgBuf[8]; - ALGlobals g; + N_ALGlobals g; } AMAudioMgr; typedef struct { diff --git a/src/include/ultra64.h b/src/include/ultra64.h deleted file mode 100644 index c2a3bc654..000000000 --- a/src/include/ultra64.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _ULTRA64_H_ -#define _ULTRA64_H_ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) -#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) -#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) -#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) - -#endif diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index 7173782c2..9caf144a5 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -6,7 +6,6 @@ #include "lib/lib_09660.h" #include "lib/lib_2fba0.h" #include "lib/lib_2fc60.h" -#include "lib/lib_30ce0.h" #include "lib/libc/ll.h" #include "data.h" #include "types.h" @@ -33,7 +32,6 @@ u32 var800915c0; u32 var800915c4; AMAudioMgr g_AudioManager; OSScClient var800918d0; -u32 var800918d8; u32 var800918dc; u32 var800918e0; u32 var800918e4; @@ -1343,9 +1341,9 @@ void amgrMain(void *arg) static u32 var8005d514 = 1; #if VERSION >= VERSION_PAL_FINAL - osScAddClient(&g_SchedThread, &var800918d0, &g_AudioManager.audioFrameMsgQ, (void *)true); + osScAddClient(&g_Sched, &var800918d0, &g_AudioManager.audioFrameMsgQ, true); #else - osScAddClient(&g_SchedThread, &var800918d0, &g_AudioManager.audioFrameMsgQ, (void *)!IS4MB()); + osScAddClient(&g_Sched, &var800918d0, &g_AudioManager.audioFrameMsgQ, !IS4MB()); #endif while (!done) { @@ -1404,10 +1402,10 @@ glabel amgrHandleFrameMsg /* 945c: afbf001c */ sw $ra,0x1c($sp) /* 9460: 10c00007 */ beqz $a2,.L00009480 /* 9464: afa50034 */ sw $a1,0x34($sp) -/* 9468: 3c048009 */ lui $a0,%hi(g_SchedThread) +/* 9468: 3c048009 */ lui $a0,%hi(g_Sched) /* 946c: 3c018009 */ lui $at,%hi(g_AmgrCurrentCmdList) /* 9470: ac2618f4 */ sw $a2,%lo(g_AmgrCurrentCmdList)($at) -/* 9474: 2484dbd0 */ addiu $a0,$a0,%lo(g_SchedThread) +/* 9474: 2484dbd0 */ addiu $a0,$a0,%lo(g_Sched) /* 9478: 0c0007ea */ jal __scHandleRetraceViaPri /* 947c: 00c02825 */ or $a1,$a2,$zero .L00009480: @@ -1466,7 +1464,7 @@ glabel amgrHandleFrameMsg /* 9548: a0780000 */ sb $t8,0x0($v1) .L0000954c: /* 954c: 8fa40024 */ lw $a0,0x24($sp) -/* 9550: 0c00c4b9 */ jal alAudioFrame +/* 9550: 0c00c4b9 */ jal n_alAudioFrame /* 9554: 86070004 */ lh $a3,0x4($s0) /* 9558: 26060008 */ addiu $a2,$s0,0x8 /* 955c: 3c038006 */ lui $v1,%hi(rspbootTextStart) @@ -1475,12 +1473,12 @@ glabel amgrHandleFrameMsg /* 9568: 24040002 */ addiu $a0,$zero,0x2 /* 956c: 3c198009 */ lui $t9,%hi(g_AudioManager+0x280) /* 9570: 2508a0b0 */ addiu $t0,$t0,%lo(rspbootTextEnd) -/* 9574: 3c0a8006 */ lui $t2,%hi(aspMainTextStart) -/* 9578: 3c0b8009 */ lui $t3,%hi(aspMainDataStart) +/* 9574: 3c0a8006 */ lui $t2,%hi(aspTextStart) +/* 9578: 3c0b8009 */ lui $t3,%hi(aspDataStart) /* 957c: 27391848 */ addiu $t9,$t9,%lo(g_AudioManager+0x280) /* 9580: 01034823 */ subu $t1,$t0,$v1 -/* 9584: 254ab4d0 */ addiu $t2,$t2,%lo(aspMainTextStart) -/* 9588: 256ba2d0 */ addiu $t3,$t3,%lo(aspMainDataStart) +/* 9584: 254ab4d0 */ addiu $t2,$t2,%lo(aspTextStart) +/* 9588: 256ba2d0 */ addiu $t3,$t3,%lo(aspDataStart) /* 958c: 240c1000 */ addiu $t4,$zero,0x1000 /* 9590: 240d0800 */ addiu $t5,$zero,0x800 /* 9594: acc00000 */ sw $zero,0x0($a2) @@ -1532,12 +1530,12 @@ glabel amgrHandleFrameMsg // extern u32 vara4500004; // extern u8 rspbootTextStart; // extern u8 rspbootTextEnd; -// extern u8 aspMainTextStart; -// extern u8 aspMainDataStart; +// extern u8 aspTextStart; +// extern u8 aspDataStart; // // if (g_AmgrCurrentCmdList) { // g_AmgrCurrentCmdList = g_AmgrCurrentCmdList; -// __scHandleRetraceViaPri(&g_SchedThread, g_AmgrCurrentCmdList); +// __scHandleRetraceViaPri(&g_Sched, g_AmgrCurrentCmdList); // } // // amgrClearDmaBuffers(); @@ -1561,7 +1559,7 @@ glabel amgrHandleFrameMsg // } // } // -// cmd = alAudioFrame(datastart, &var800918e8, outbuffer, info->framesamples); +// cmd = n_alAudioFrame(datastart, &var800918e8, outbuffer, info->framesamples); // // task = &info->task; // @@ -1573,8 +1571,8 @@ glabel amgrHandleFrameMsg // task->list.t.flags = 0; // task->list.t.ucode_boot = (u64 *) &rspbootTextStart; // task->list.t.ucode_boot_size = (u32) &rspbootTextEnd - (u32) &rspbootTextStart; -// task->list.t.ucode = (u64 *) &aspMainTextStart; -// task->list.t.ucode_data = (u64 *) &aspMainDataStart; +// task->list.t.ucode = (u64 *) &aspTextStart; +// task->list.t.ucode_data = (u64 *) &asaspart; // task->list.t.ucode_size = SP_UCODE_SIZE; // task->list.t.ucode_data_size = SP_UCODE_DATA_SIZE; // task->list.t.data_ptr = (u64 *) datastart; diff --git a/src/lib/boot.c b/src/lib/boot.c index 8091ff346..c4afd6df4 100644 --- a/src/lib/boot.c +++ b/src/lib/boot.c @@ -22,184 +22,13 @@ OSThread g_RmonThread; OSThread g_IdleThread; OSThread g_MainThread; -u32 var8008d900; -u32 var8008d904; -u32 var8008d908; -u32 var8008d90c; -u32 var8008d910; -u32 var8008d914; -u32 var8008d918; -u32 var8008d91c; -u32 var8008d920; -u32 var8008d924; -u32 var8008d928; -u32 var8008d92c; -u32 var8008d930; -u32 var8008d934; -u32 var8008d938; -u32 var8008d93c; -u32 var8008d940; -u32 var8008d944; -u32 var8008d948; -u32 var8008d94c; -u32 var8008d950; -u32 var8008d954; -u32 var8008d958; -u32 var8008d95c; -u32 var8008d960; -u32 var8008d964; -u32 var8008d968; -u32 var8008d96c; -u32 var8008d970; -u32 var8008d974; -u32 var8008d978; -u32 var8008d97c; -u32 var8008d980; -u32 var8008d984; -u32 var8008d988; -u32 var8008d98c; -u32 var8008d990; -u32 var8008d994; -u32 var8008d998; -u32 var8008d99c; -u32 var8008d9a0; -u32 var8008d9a4; -u32 var8008d9a8; -u32 var8008d9ac; -u32 var8008d9b0; -u32 var8008d9b4; -u32 var8008d9b8; -u32 var8008d9bc; -u32 var8008d9c0; -u32 var8008d9c4; -u32 var8008d9c8; -u32 var8008d9cc; -u32 var8008d9d0; -u32 var8008d9d4; -u32 var8008d9d8; -u32 var8008d9dc; -u32 var8008d9e0; -u32 var8008d9e4; -u32 var8008d9e8; -u32 var8008d9ec; -u32 var8008d9f0; -u32 var8008d9f4; -u32 var8008d9f8; -u32 var8008d9fc; -u32 var8008da00; -u32 var8008da04; -u32 var8008da08; -u32 var8008da0c; -u32 var8008da10; -u32 var8008da14; -u32 var8008da18; -u32 var8008da1c; -u32 var8008da20; -u32 var8008da24; -u32 var8008da28; -u32 var8008da2c; -u32 var8008da30; -u32 var8008da34; -u32 var8008da38; -u32 var8008da3c; -u32 var8008da40; -u32 var8008da44; -u32 var8008da48; -u32 var8008da4c; -u32 var8008da50; -u32 var8008da54; -u32 var8008da58; -u32 var8008da5c; -u32 var8008da60; -u32 var8008da64; -u32 var8008da68; -u32 var8008da6c; -u32 var8008da70; -u32 var8008da74; -u32 var8008da78; -u32 var8008da7c; -u32 var8008da80; -u32 var8008da84; -u32 var8008da88; -u32 var8008da8c; -u32 var8008da90; -u32 var8008da94; -u32 var8008da98; -u32 var8008da9c; -u32 var8008daa0; -u32 var8008daa4; -u32 var8008daa8; -u32 var8008daac; -u32 var8008dab0; -u32 var8008dab4; -u32 var8008dab8; -u32 var8008dabc; -u32 var8008dac0; -u32 var8008dac4; -u32 var8008dac8; -u32 var8008dacc; -u32 var8008dad0; -u32 var8008dad4; -u32 var8008dad8; -u32 var8008dadc; -u32 var8008dae0; -u32 var8008dae4; -u32 var8008dae8; -u32 var8008daec; -u32 var8008daf0; -u32 var8008daf4; -u32 var8008daf8; -u32 var8008dafc; -u32 var8008db00; -u32 var8008db04; -u32 var8008db08; -u32 var8008db0c; -u32 var8008db10; -u32 var8008db14; -u32 var8008db18; -u32 var8008db1c; -u32 var8008db20; -u32 var8008db24; -u32 var8008db28; -u32 var8008db2c; +OSThread g_SchedThread; OSMesgQueue var8008db30; -OSMesg var8008db48; -u32 var8008db4c; -u32 var8008db50; -u32 var8008db54; -u32 var8008db58; -u32 var8008db5c; -u32 var8008db60; -u32 var8008db64; -u32 var8008db68; -u32 var8008db6c; -u32 var8008db70; -u32 var8008db74; -u32 var8008db78; -u32 var8008db7c; -u32 var8008db80; -u32 var8008db84; -u32 var8008db88; -u32 var8008db8c; -u32 var8008db90; -u32 var8008db94; -u32 var8008db98; -u32 var8008db9c; -u32 var8008dba0; -u32 var8008dba4; -u32 var8008dba8; -u32 var8008dbac; -u32 var8008dbb0; -u32 var8008dbb4; -u32 var8008dbb8; -u32 var8008dbbc; -u32 var8008dbc0; -u32 var8008dbc4; +OSMesg var8008db48[32]; OSMesgQueue *g_SchedCmdQ; u32 var8008dbcc; -OSSched g_SchedThread; +OSSched g_Sched; OSScClient var8008dca8; -u32 var8008dcb0; u32 g_OsMemSize; #if VERSION < VERSION_NTSC_1_0 @@ -510,7 +339,7 @@ void __osSetFpcCsr(u32 arg0); // s32 i; // //#if VERSION >= VERSION_NTSC_1_0 -// if (osResetType == RESET_TYPE_NMI) { +// if (osResetType == 1) { // g_OsMemSize = *(u32 *)0x803f50b8; // } else { // *(u32 *)0x803f50b8 = g_OsMemSize = osMemSize; @@ -758,16 +587,16 @@ void bootCreateRmonThread(void) void bootCreateSchedThread(void) { - osCreateMesgQueue(&var8008db30, &var8008db48, 32); + osCreateMesgQueue(&var8008db30, var8008db48, ARRAYCOUNT(var8008db48)); if (osTvType == OS_TV_MPAL) { - osCreateScheduler(&g_SchedThread, &var8008d900, OS_VI_MPAL_LAN1, 1); + osCreateScheduler(&g_Sched, &g_SchedThread, OS_VI_MPAL_LAN1, 1); } else { - osCreateScheduler(&g_SchedThread, &var8008d900, OS_VI_NTSC_LAN1, 1); + osCreateScheduler(&g_Sched, &g_SchedThread, OS_VI_NTSC_LAN1, 1); } - osScAddClient(&g_SchedThread, &var8008dca8, &var8008db30, 0); - g_SchedCmdQ = osScGetCmdQ(&g_SchedThread); + osScAddClient(&g_Sched, &var8008dca8, &var8008db30, 0); + g_SchedCmdQ = osScGetCmdQ(&g_Sched); } void bootPhase2(void *arg) diff --git a/src/lib/crash.c b/src/lib/crash.c index 9539d488a..02e3f0d38 100644 --- a/src/lib/crash.c +++ b/src/lib/crash.c @@ -1,4 +1,5 @@ #include +#include "os_internal.h" #include "constants.h" #include "bss.h" #include "lib/tlb.h" diff --git a/src/lib/joy.c b/src/lib/joy.c index 3eaf90eaa..36791d8d3 100644 --- a/src/lib/joy.c +++ b/src/lib/joy.c @@ -1460,7 +1460,7 @@ glabel joyStopRumble /* 163b8: 018d3821 */ addu $a3,$t4,$t5 .NB000163bc: /* 163bc: 00e02025 */ or $a0,$a3,$zero -/* 163c0: 0c014370 */ jal osMotorAccess +/* 163c0: 0c014370 */ jal __osMotorAccess /* 163c4: afa60024 */ sw $a2,0x24($sp) /* 163c8: 8fa60024 */ lw $a2,0x24($sp) /* 163cc: 24010004 */ addiu $at,$zero,0x4 @@ -1479,7 +1479,7 @@ glabel joyStopRumble /* 163fc: 01cf3821 */ addu $a3,$t6,$t7 .NB00016400: /* 16400: 00e02025 */ or $a0,$a3,$zero -/* 16404: 0c014370 */ jal osMotorAccess +/* 16404: 0c014370 */ jal __osMotorAccess /* 16408: afa60024 */ sw $a2,0x24($sp) /* 1640c: 8fa60024 */ lw $a2,0x24($sp) /* 16410: 24010004 */ addiu $at,$zero,0x4 @@ -1497,7 +1497,7 @@ glabel joyStopRumble /* 1643c: 0018c0c0 */ sll $t8,$t8,0x3 /* 16440: 03193821 */ addu $a3,$t8,$t9 .NB00016444: -/* 16444: 0c014370 */ jal osMotorAccess +/* 16444: 0c014370 */ jal __osMotorAccess /* 16448: 00e02025 */ or $a0,$a3,$zero .NB0001644c: /* 1644c: 8fa8002c */ lw $t0,0x2c($sp) diff --git a/src/lib/lib_09660.c b/src/lib/lib_09660.c index 25bbffb22..4e2b944bd 100644 --- a/src/lib/lib_09660.c +++ b/src/lib/lib_09660.c @@ -9,7 +9,6 @@ #include "lib/lib_09660.h" #include "lib/memory.h" #include "lib/mtx.h" -#include "lib/lib_30ce0.h" #include "data.h" #include "types.h" diff --git a/src/lib/lib_2fba0.c b/src/lib/lib_2fba0.c index 3fb7658c0..211318921 100644 --- a/src/lib/lib_2fba0.c +++ b/src/lib/lib_2fba0.c @@ -1,27 +1,26 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_30ce0.h" #include "lib/lib_39fc0.h" #include "data.h" #include "types.h" -ALGlobals *n_alGlobals = NULL; -ALGlobals *n_syn = NULL; +N_ALGlobals *n_alGlobals = NULL; +N_ALSynth *n_syn = NULL; -void n_alInit(ALGlobals *g, ALSynConfig *c) +void n_alInit(N_ALGlobals *g, ALSynConfig *c) { if (!n_alGlobals) { n_alGlobals = g; if (!n_syn) { - n_syn = n_alGlobals; + n_syn = &n_alGlobals->drvr; n_alSynNew(c); } } } -void n_alClose(ALGlobals *g) +void n_alClose(N_ALGlobals *g) { if (n_alGlobals) { n_alSynDelete(); diff --git a/src/lib/lib_317f0.c b/src/lib/lib_317f0.c index 3e1270248..a7b15c37a 100644 --- a/src/lib/lib_317f0.c +++ b/src/lib/lib_317f0.c @@ -3,7 +3,6 @@ #include "bss.h" #include "lib/snd.h" #include "lib/lib_2fc60.h" -#include "lib/lib_30ce0.h" #include "lib/lib_317f0.h" #include "lib/lib_39c80.h" #include "lib/lib_39fe0.h" @@ -180,7 +179,7 @@ glabel func000317f0 /* 31a1c: 27a50028 */ addiu $a1,$sp,0x28 /* 31a20: 24070001 */ addiu $a3,$zero,0x1 /* 31a24: 25640014 */ addiu $a0,$t3,0x14 -/* 31a28: 0c00f184 */ jal alEvtqPostEvent +/* 31a28: 0c00f184 */ jal n_alEvtqPostEvent /* 31a2c: 8d660048 */ lw $a2,0x48($t3) /* 31a30: 3c0d8006 */ lui $t5,%hi(var8005f12c) /* 31a34: 8dadf12c */ lw $t5,%lo(var8005f12c)($t5) @@ -347,7 +346,7 @@ glabel func000317f0 /* 31a1c: 27a50028 */ addiu $a1,$sp,0x28 /* 31a20: 24070001 */ addiu $a3,$zero,0x1 /* 31a24: 25640014 */ addiu $a0,$t3,0x14 -/* 31a28: 0c00f184 */ jal alEvtqPostEvent +/* 31a28: 0c00f184 */ jal n_alEvtqPostEvent /* 31a2c: 8d660048 */ lw $a2,0x48($t3) /* 31a30: 3c0d8006 */ lui $t5,%hi(var8005f12c) /* 31a34: 8dadf12c */ lw $t5,%lo(var8005f12c)($t5) @@ -510,7 +509,7 @@ glabel func000317f0 /* 3315c: 27a50028 */ addiu $a1,$sp,0x28 /* 33160: 24070001 */ addiu $a3,$zero,0x1 /* 33164: 25640014 */ addiu $a0,$t3,0x14 -/* 33168: 0c00f678 */ jal alEvtqPostEvent +/* 33168: 0c00f678 */ jal n_alEvtqPostEvent /* 3316c: 8d660048 */ lw $a2,0x48($t3) /* 33170: 3c0d8006 */ lui $t5,0x8006 /* 33174: 8dad163c */ lw $t5,0x163c($t5) @@ -552,7 +551,7 @@ glabel func00031a68 /* 31aa4: 27a5001c */ addiu $a1,$sp,0x1c /* 31aa8: 24070001 */ addiu $a3,$zero,0x1 /* 31aac: 25040014 */ addiu $a0,$t0,0x14 -/* 31ab0: 0c00f184 */ jal alEvtqPostEvent +/* 31ab0: 0c00f184 */ jal n_alEvtqPostEvent /* 31ab4: 8d060048 */ lw $a2,0x48($t0) /* 31ab8: 10000006 */ b .L00031ad4 /* 31abc: 00000000 */ nop @@ -807,7 +806,7 @@ glabel var7005477c /* 31dc8: 8fa500b8 */ lw $a1,0xb8($sp) /* 31dcc: 34068235 */ dli $a2,0x8235 /* 31dd0: 00003825 */ or $a3,$zero,$zero -/* 31dd4: 0c00f184 */ jal alEvtqPostEvent +/* 31dd4: 0c00f184 */ jal n_alEvtqPostEvent /* 31dd8: 24840014 */ addiu $a0,$a0,20 /* 31ddc: 10000045 */ b .L00031ef4 /* 31de0: 00000000 */ nop @@ -844,12 +843,12 @@ glabel var7005477c /* 31e54: 27a50044 */ addiu $a1,$sp,0x44 /* 31e58: 240603e8 */ addiu $a2,$zero,0x3e8 /* 31e5c: 00003825 */ or $a3,$zero,$zero -/* 31e60: 0c00f184 */ jal alEvtqPostEvent +/* 31e60: 0c00f184 */ jal n_alEvtqPostEvent /* 31e64: 24840014 */ addiu $a0,$a0,20 /* 31e68: 8fa40054 */ lw $a0,0x54($sp) /* 31e6c: 00002825 */ or $a1,$zero,$zero /* 31e70: 240603e8 */ addiu $a2,$zero,0x3e8 -/* 31e74: 0c00f33c */ jal alSynSetVol +/* 31e74: 0c00f33c */ jal n_alSynSetVol /* 31e78: 2484000c */ addiu $a0,$a0,0xc .L00031e7c: /* 31e7c: 8fac0054 */ lw $t4,0x54($sp) @@ -873,7 +872,7 @@ glabel var7005477c /* 31ec0: 8fa500b8 */ lw $a1,0xb8($sp) /* 31ec4: 240603e9 */ addiu $a2,$zero,0x3e9 /* 31ec8: 00003825 */ or $a3,$zero,$zero -/* 31ecc: 0c00f184 */ jal alEvtqPostEvent +/* 31ecc: 0c00f184 */ jal n_alEvtqPostEvent /* 31ed0: 24840014 */ addiu $a0,$a0,20 /* 31ed4: 10000003 */ b .L00031ee4 /* 31ed8: 00000000 */ nop @@ -1279,7 +1278,7 @@ glabel var7005477c /* 324b0: 8fa40060 */ lw $a0,0x60($sp) /* 324b4: 8fa50078 */ lw $a1,0x78($sp) /* 324b8: 8fa60080 */ lw $a2,0x80($sp) -/* 324bc: 0c00f33c */ jal alSynSetVol +/* 324bc: 0c00f33c */ jal n_alSynSetVol /* 324c0: 2484000c */ addiu $a0,$a0,0xc /* 324c4: 240c0002 */ addiu $t4,$zero,0x2 /* 324c8: a7ac0094 */ sh $t4,0x94($sp) @@ -1290,7 +1289,7 @@ glabel var7005477c /* 324dc: 27a50094 */ addiu $a1,$sp,0x94 /* 324e0: 8fa60080 */ lw $a2,0x80($sp) /* 324e4: 00003825 */ or $a3,$zero,$zero -/* 324e8: 0c00f184 */ jal alEvtqPostEvent +/* 324e8: 0c00f184 */ jal n_alEvtqPostEvent /* 324ec: 24840014 */ addiu $a0,$a0,20 /* 324f0: 8fad0060 */ lw $t5,0x60($sp) /* 324f4: 91ae0044 */ lbu $t6,0x44($t5) @@ -1338,7 +1337,7 @@ glabel var7005477c /* 32590: 27a50094 */ addiu $a1,$sp,0x94 /* 32594: 8fa60080 */ lw $a2,0x80($sp) /* 32598: 00003825 */ or $a3,$zero,$zero -/* 3259c: 0c00f184 */ jal alEvtqPostEvent +/* 3259c: 0c00f184 */ jal n_alEvtqPostEvent /* 325a0: 24840014 */ addiu $a0,$a0,20 .L000325a4: /* 325a4: 1000029c */ b .L00033018 @@ -1404,7 +1403,7 @@ glabel var7005477c /* 32684: 8fa40060 */ lw $a0,0x60($sp) /* 32688: 00002825 */ or $a1,$zero,$zero /* 3268c: 8fa60080 */ lw $a2,0x80($sp) -/* 32690: 0c00f33c */ jal alSynSetVol +/* 32690: 0c00f33c */ jal n_alSynSetVol /* 32694: 2484000c */ addiu $a0,$a0,0xc /* 32698: 8fa90080 */ lw $t1,0x80($sp) /* 3269c: 11200010 */ beqz $t1,.L000326e0 @@ -1418,7 +1417,7 @@ glabel var7005477c /* 326bc: 27a50094 */ addiu $a1,$sp,0x94 /* 326c0: 8fa60080 */ lw $a2,0x80($sp) /* 326c4: 00003825 */ or $a3,$zero,$zero -/* 326c8: 0c00f184 */ jal alEvtqPostEvent +/* 326c8: 0c00f184 */ jal n_alEvtqPostEvent /* 326cc: 24840014 */ addiu $a0,$a0,20 /* 326d0: 8fb90060 */ lw $t9,0x60($sp) /* 326d4: 240c0002 */ addiu $t4,$zero,0x2 @@ -1775,7 +1774,7 @@ glabel var7005477c /* 32bbc: 8fa40060 */ lw $a0,0x60($sp) /* 32bc0: 8fa50078 */ lw $a1,0x78($sp) /* 32bc4: 02003025 */ or $a2,$s0,$zero -/* 32bc8: 0c00f33c */ jal alSynSetVol +/* 32bc8: 0c00f33c */ jal n_alSynSetVol /* 32bcc: 2484000c */ addiu $a0,$a0,0xc .L00032bd0: /* 32bd0: 10000111 */ b .L00033018 @@ -1887,7 +1886,7 @@ glabel var7005477c /* 32d68: 8fa40060 */ lw $a0,0x60($sp) /* 32d6c: 8fa50078 */ lw $a1,0x78($sp) /* 32d70: 8fa60080 */ lw $a2,0x80($sp) -/* 32d74: 0c00f33c */ jal alSynSetVol +/* 32d74: 0c00f33c */ jal n_alSynSetVol /* 32d78: 2484000c */ addiu $a0,$a0,0xc .L00032d7c: /* 32d7c: 100000a6 */ b .L00033018 @@ -2011,7 +2010,7 @@ glabel var7005477c /* 32f44: 8fa40060 */ lw $a0,0x60($sp) /* 32f48: 8fa50078 */ lw $a1,0x78($sp) /* 32f4c: 8fa60080 */ lw $a2,0x80($sp) -/* 32f50: 0c00f33c */ jal alSynSetVol +/* 32f50: 0c00f33c */ jal n_alSynSetVol /* 32f54: 2484000c */ addiu $a0,$a0,0xc /* 32f58: 240e0002 */ addiu $t6,$zero,0x2 /* 32f5c: a7ae0094 */ sh $t6,0x94($sp) @@ -2022,7 +2021,7 @@ glabel var7005477c /* 32f70: 27a50094 */ addiu $a1,$sp,0x94 /* 32f74: 8fa60080 */ lw $a2,0x80($sp) /* 32f78: 00003825 */ or $a3,$zero,$zero -/* 32f7c: 0c00f184 */ jal alEvtqPostEvent +/* 32f7c: 0c00f184 */ jal n_alEvtqPostEvent /* 32f80: 24840014 */ addiu $a0,$a0,20 /* 32f84: 8fb90060 */ lw $t9,0x60($sp) /* 32f88: 93280044 */ lbu $t0,0x44($t9) @@ -2318,7 +2317,7 @@ glabel var7005477c /* 33508: 8fa500b8 */ lw $a1,0xb8($sp) /* 3350c: 34068235 */ dli $a2,0x8235 /* 33510: 00003825 */ or $a3,$zero,$zero -/* 33514: 0c00f678 */ jal alEvtqPostEvent +/* 33514: 0c00f678 */ jal n_alEvtqPostEvent /* 33518: 24840014 */ addiu $a0,$a0,0x14 /* 3351c: 10000045 */ beqz $zero,.NB00033634 /* 33520: 00000000 */ sll $zero,$zero,0x0 @@ -2355,12 +2354,12 @@ glabel var7005477c /* 33594: 27a50044 */ addiu $a1,$sp,0x44 /* 33598: 240603e8 */ addiu $a2,$zero,0x3e8 /* 3359c: 00003825 */ or $a3,$zero,$zero -/* 335a0: 0c00f678 */ jal alEvtqPostEvent +/* 335a0: 0c00f678 */ jal n_alEvtqPostEvent /* 335a4: 24840014 */ addiu $a0,$a0,0x14 /* 335a8: 8fa40054 */ lw $a0,0x54($sp) /* 335ac: 00002825 */ or $a1,$zero,$zero /* 335b0: 240603e8 */ addiu $a2,$zero,0x3e8 -/* 335b4: 0c00f830 */ jal alSynSetVol +/* 335b4: 0c00f830 */ jal n_alSynSetVol /* 335b8: 2484000c */ addiu $a0,$a0,0xc .NB000335bc: /* 335bc: 8fac0054 */ lw $t4,0x54($sp) @@ -2384,7 +2383,7 @@ glabel var7005477c /* 33600: 8fa500b8 */ lw $a1,0xb8($sp) /* 33604: 240603e9 */ addiu $a2,$zero,0x3e9 /* 33608: 00003825 */ or $a3,$zero,$zero -/* 3360c: 0c00f678 */ jal alEvtqPostEvent +/* 3360c: 0c00f678 */ jal n_alEvtqPostEvent /* 33610: 24840014 */ addiu $a0,$a0,0x14 /* 33614: 10000003 */ beqz $zero,.NB00033624 /* 33618: 00000000 */ sll $zero,$zero,0x0 @@ -2717,7 +2716,7 @@ glabel var7005477c /* 33ae0: 8fa40060 */ lw $a0,0x60($sp) /* 33ae4: 8fa50078 */ lw $a1,0x78($sp) /* 33ae8: 8fa60080 */ lw $a2,0x80($sp) -/* 33aec: 0c00f830 */ jal alSynSetVol +/* 33aec: 0c00f830 */ jal n_alSynSetVol /* 33af0: 2484000c */ addiu $a0,$a0,0xc /* 33af4: 24190002 */ addiu $t9,$zero,0x2 /* 33af8: a7b90094 */ sh $t9,0x94($sp) @@ -2728,7 +2727,7 @@ glabel var7005477c /* 33b0c: 27a50094 */ addiu $a1,$sp,0x94 /* 33b10: 8fa60080 */ lw $a2,0x80($sp) /* 33b14: 00003825 */ or $a3,$zero,$zero -/* 33b18: 0c00f678 */ jal alEvtqPostEvent +/* 33b18: 0c00f678 */ jal n_alEvtqPostEvent /* 33b1c: 24840014 */ addiu $a0,$a0,0x14 /* 33b20: 8faf0060 */ lw $t7,0x60($sp) /* 33b24: 91e80044 */ lbu $t0,0x44($t7) @@ -2765,7 +2764,7 @@ glabel var7005477c /* 33b98: 27a50094 */ addiu $a1,$sp,0x94 /* 33b9c: 8fa60080 */ lw $a2,0x80($sp) /* 33ba0: 00003825 */ or $a3,$zero,$zero -/* 33ba4: 0c00f678 */ jal alEvtqPostEvent +/* 33ba4: 0c00f678 */ jal n_alEvtqPostEvent /* 33ba8: 24840014 */ addiu $a0,$a0,0x14 .NB00033bac: /* 33bac: 1000027e */ beqz $zero,.NB000345a8 @@ -2820,7 +2819,7 @@ glabel var7005477c /* 33c64: 8fa40060 */ lw $a0,0x60($sp) /* 33c68: 00002825 */ or $a1,$zero,$zero /* 33c6c: 8fa60080 */ lw $a2,0x80($sp) -/* 33c70: 0c00f830 */ jal alSynSetVol +/* 33c70: 0c00f830 */ jal n_alSynSetVol /* 33c74: 2484000c */ addiu $a0,$a0,0xc /* 33c78: 8fac0080 */ lw $t4,0x80($sp) /* 33c7c: 11800010 */ beqz $t4,.NB00033cc0 @@ -2834,7 +2833,7 @@ glabel var7005477c /* 33c9c: 27a50094 */ addiu $a1,$sp,0x94 /* 33ca0: 8fa60080 */ lw $a2,0x80($sp) /* 33ca4: 00003825 */ or $a3,$zero,$zero -/* 33ca8: 0c00f678 */ jal alEvtqPostEvent +/* 33ca8: 0c00f678 */ jal n_alEvtqPostEvent /* 33cac: 24840014 */ addiu $a0,$a0,0x14 /* 33cb0: 8faa0060 */ lw $t2,0x60($sp) /* 33cb4: 24180002 */ addiu $t8,$zero,0x2 @@ -3191,7 +3190,7 @@ glabel var7005477c /* 3419c: 8fa40060 */ lw $a0,0x60($sp) /* 341a0: 8fa50078 */ lw $a1,0x78($sp) /* 341a4: 02003025 */ or $a2,$s0,$zero -/* 341a8: 0c00f830 */ jal alSynSetVol +/* 341a8: 0c00f830 */ jal n_alSynSetVol /* 341ac: 2484000c */ addiu $a0,$a0,0xc .NB000341b0: /* 341b0: 100000fd */ beqz $zero,.NB000345a8 @@ -3292,7 +3291,7 @@ glabel var7005477c /* 34320: 8fa40060 */ lw $a0,0x60($sp) /* 34324: 8fa50078 */ lw $a1,0x78($sp) /* 34328: 8fa60080 */ lw $a2,0x80($sp) -/* 3432c: 0c00f830 */ jal alSynSetVol +/* 3432c: 0c00f830 */ jal n_alSynSetVol /* 34330: 2484000c */ addiu $a0,$a0,0xc .NB00034334: /* 34334: 1000009c */ beqz $zero,.NB000345a8 @@ -3405,7 +3404,7 @@ glabel var7005477c /* 344d4: 8fa40060 */ lw $a0,0x60($sp) /* 344d8: 8fa50078 */ lw $a1,0x78($sp) /* 344dc: 8fa60080 */ lw $a2,0x80($sp) -/* 344e0: 0c00f830 */ jal alSynSetVol +/* 344e0: 0c00f830 */ jal n_alSynSetVol /* 344e4: 2484000c */ addiu $a0,$a0,0xc /* 344e8: 240d0002 */ addiu $t5,$zero,0x2 /* 344ec: a7ad0094 */ sh $t5,0x94($sp) @@ -3416,7 +3415,7 @@ glabel var7005477c /* 34500: 27a50094 */ addiu $a1,$sp,0x94 /* 34504: 8fa60080 */ lw $a2,0x80($sp) /* 34508: 00003825 */ or $a3,$zero,$zero -/* 3450c: 0c00f678 */ jal alEvtqPostEvent +/* 3450c: 0c00f678 */ jal n_alEvtqPostEvent /* 34510: 24840014 */ addiu $a0,$a0,0x14 /* 34514: 8fa90060 */ lw $t1,0x60($sp) /* 34518: 912f0044 */ lbu $t7,0x44($t1) @@ -3557,7 +3556,7 @@ glabel func00033100 /* 33154: 27a50020 */ addiu $a1,$sp,0x20 /* 33158: 34068235 */ dli $a2,0x8235 /* 3315c: 00003825 */ or $a3,$zero,$zero -/* 33160: 0c00f184 */ jal alEvtqPostEvent +/* 33160: 0c00f184 */ jal n_alEvtqPostEvent /* 33164: 24840014 */ addiu $a0,$a0,20 /* 33168: 10000001 */ b .L00033170 /* 3316c: 00000000 */ nop @@ -4170,7 +4169,7 @@ glabel func00033820 /* 339c8: 27a5002c */ addiu $a1,$sp,0x2c /* 339cc: 00003825 */ or $a3,$zero,$zero /* 339d0: 24840014 */ addiu $a0,$a0,20 -/* 339d4: 0c00f184 */ jal alEvtqPostEvent +/* 339d4: 0c00f184 */ jal n_alEvtqPostEvent /* 339d8: 24c60001 */ addiu $a2,$a2,0x1 /* 339dc: 8fae0044 */ lw $t6,0x44($sp) /* 339e0: 25ca0001 */ addiu $t2,$t6,0x1 @@ -4185,7 +4184,7 @@ glabel func00033820 /* 33a00: 27a5002c */ addiu $a1,$sp,0x2c /* 33a04: 00003825 */ or $a3,$zero,$zero /* 33a08: 24840014 */ addiu $a0,$a0,20 -/* 33a0c: 0c00f184 */ jal alEvtqPostEvent +/* 33a0c: 0c00f184 */ jal n_alEvtqPostEvent /* 33a10: 24c60001 */ addiu $a2,$a2,0x1 .L00033a14: /* 33a14: 8fb8005c */ lw $t8,0x5c($sp) @@ -4242,7 +4241,7 @@ glabel func00033820 /* 33ad8: 27a5001c */ addiu $a1,$sp,0x1c /* 33adc: 8fa60048 */ lw $a2,0x48($sp) /* 33ae0: 00003825 */ or $a3,$zero,$zero -/* 33ae4: 0c00f184 */ jal alEvtqPostEvent +/* 33ae4: 0c00f184 */ jal n_alEvtqPostEvent /* 33ae8: 24840014 */ addiu $a0,$a0,20 .L00033aec: /* 33aec: 8faf007c */ lw $t7,0x7c($sp) @@ -4373,7 +4372,7 @@ glabel func00033820 /* 34f44: 27a5002c */ addiu $a1,$sp,0x2c /* 34f48: 00003825 */ or $a3,$zero,$zero /* 34f4c: 24840014 */ addiu $a0,$a0,0x14 -/* 34f50: 0c00f678 */ jal alEvtqPostEvent +/* 34f50: 0c00f678 */ jal n_alEvtqPostEvent /* 34f54: 24c60001 */ addiu $a2,$a2,0x1 /* 34f58: 8fab0044 */ lw $t3,0x44($sp) /* 34f5c: 256c0001 */ addiu $t4,$t3,0x1 @@ -4388,7 +4387,7 @@ glabel func00033820 /* 34f7c: 27a5002c */ addiu $a1,$sp,0x2c /* 34f80: 00003825 */ or $a3,$zero,$zero /* 34f84: 24840014 */ addiu $a0,$a0,0x14 -/* 34f88: 0c00f678 */ jal alEvtqPostEvent +/* 34f88: 0c00f678 */ jal n_alEvtqPostEvent /* 34f8c: 24c60001 */ addiu $a2,$a2,0x1 .NB00034f90: /* 34f90: 8fae005c */ lw $t6,0x5c($sp) @@ -4445,7 +4444,7 @@ glabel func00033820 /* 35054: 27a5001c */ addiu $a1,$sp,0x1c /* 35058: 8fa60048 */ lw $a2,0x48($sp) /* 3505c: 00003825 */ or $a3,$zero,$zero -/* 35060: 0c00f678 */ jal alEvtqPostEvent +/* 35060: 0c00f678 */ jal n_alEvtqPostEvent /* 35064: 24840014 */ addiu $a0,$a0,0x14 .NB00035068: /* 35068: 8fad007c */ lw $t5,0x7c($sp) @@ -4502,7 +4501,7 @@ glabel audioStop /* 33b94: 27a50018 */ addiu $a1,$sp,0x18 /* 33b98: 00003025 */ or $a2,$zero,$zero /* 33b9c: 00003825 */ or $a3,$zero,$zero -/* 33ba0: 0c00f184 */ jal alEvtqPostEvent +/* 33ba0: 0c00f184 */ jal n_alEvtqPostEvent /* 33ba4: 24840014 */ addiu $a0,$a0,20 .L00033ba8: /* 33ba8: 10000001 */ b .L00033bb0 @@ -4546,7 +4545,7 @@ glabel audioStop /* 33b8c: 27a50018 */ addiu $a1,$sp,0x18 /* 33b90: 00003025 */ or $a2,$zero,$zero /* 33b94: 00003825 */ or $a3,$zero,$zero -/* 33b98: 0c00f184 */ jal alEvtqPostEvent +/* 33b98: 0c00f184 */ jal n_alEvtqPostEvent /* 33b9c: 24840014 */ addiu $a0,$a0,0x14 .L00033ba0: /* 33ba0: 10000001 */ b .L00033ba8 @@ -4580,7 +4579,7 @@ glabel audioStop /* 350e4: 27a50018 */ addiu $a1,$sp,0x18 /* 350e8: 00003025 */ or $a2,$zero,$zero /* 350ec: 00003825 */ or $a3,$zero,$zero -/* 350f0: 0c00f678 */ jal alEvtqPostEvent +/* 350f0: 0c00f678 */ jal n_alEvtqPostEvent /* 350f4: 24840014 */ addiu $a0,$a0,0x14 .NB000350f8: /* 350f8: 10000001 */ beqz $zero,.NB00035100 @@ -4616,7 +4615,7 @@ glabel func00033bc0 /* 33c04: 27a50018 */ addiu $a1,$sp,0x18 /* 33c08: 00003025 */ or $a2,$zero,$zero /* 33c0c: 00003825 */ or $a3,$zero,$zero -/* 33c10: 0c00f184 */ jal alEvtqPostEvent +/* 33c10: 0c00f184 */ jal n_alEvtqPostEvent /* 33c14: 24840014 */ addiu $a0,$a0,20 .L00033c18: /* 33c18: 10000001 */ b .L00033c20 @@ -4664,7 +4663,7 @@ glabel func00033c30 /* 33ca4: 27a5001c */ addiu $a1,$sp,0x1c /* 33ca8: 00003025 */ or $a2,$zero,$zero /* 33cac: 00003825 */ or $a3,$zero,$zero -/* 33cb0: 0c00f184 */ jal alEvtqPostEvent +/* 33cb0: 0c00f184 */ jal n_alEvtqPostEvent /* 33cb4: 24840014 */ addiu $a0,$a0,20 .L00033cb8: /* 33cb8: 8faf0018 */ lw $t7,0x18($sp) @@ -4721,7 +4720,7 @@ glabel func00033cf0 /* 33d64: 27a5001c */ addiu $a1,$sp,0x1c /* 33d68: 00003025 */ or $a2,$zero,$zero /* 33d6c: 00003825 */ or $a3,$zero,$zero -/* 33d70: 0c00f184 */ jal alEvtqPostEvent +/* 33d70: 0c00f184 */ jal n_alEvtqPostEvent /* 33d74: 24840014 */ addiu $a0,$a0,20 .L00033d78: /* 33d78: 8faf0018 */ lw $t7,0x18($sp) @@ -4818,7 +4817,7 @@ glabel func00033e50 /* 33e90: 27a50018 */ addiu $a1,$sp,0x18 /* 33e94: 00003025 */ or $a2,$zero,$zero /* 33e98: 00003825 */ or $a3,$zero,$zero -/* 33e9c: 0c00f184 */ jal alEvtqPostEvent +/* 33e9c: 0c00f184 */ jal n_alEvtqPostEvent /* 33ea0: 24840014 */ addiu $a0,$a0,20 /* 33ea4: 10000001 */ b .L00033eac /* 33ea8: 00000000 */ nop @@ -4929,7 +4928,7 @@ glabel func00033f44 /* 33fe0: 27a5001c */ addiu $a1,$sp,0x1c /* 33fe4: 00003025 */ or $a2,$zero,$zero /* 33fe8: 00003825 */ or $a3,$zero,$zero -/* 33fec: 0c00f184 */ jal alEvtqPostEvent +/* 33fec: 0c00f184 */ jal n_alEvtqPostEvent /* 33ff0: 24840014 */ addiu $a0,$a0,20 .L00033ff4: /* 33ff4: 8faa002c */ lw $t2,0x2c($sp) @@ -4997,7 +4996,7 @@ glabel func00033f44 /* 3539c: 27a5001c */ addiu $a1,$sp,0x1c /* 353a0: 00003025 */ or $a2,$zero,$zero /* 353a4: 00003825 */ or $a3,$zero,$zero -/* 353a8: 0c00f678 */ jal alEvtqPostEvent +/* 353a8: 0c00f678 */ jal n_alEvtqPostEvent /* 353ac: 24840014 */ addiu $a0,$a0,0x14 .NB000353b0: /* 353b0: 8faa002c */ lw $t2,0x2c($sp) diff --git a/src/lib/lib_37650.c b/src/lib/lib_37650.c index dc1cffad7..a7a880407 100644 --- a/src/lib/lib_37650.c +++ b/src/lib/lib_37650.c @@ -20,7 +20,7 @@ glabel func00037650 /* 37674: 27a50018 */ addiu $a1,$sp,0x18 /* 37678: 00003025 */ or $a2,$zero,$zero /* 3767c: 00003825 */ or $a3,$zero,$zero -/* 37680: 0c00f184 */ jal alEvtqPostEvent +/* 37680: 0c00f184 */ jal n_alEvtqPostEvent /* 37684: 24840048 */ addiu $a0,$a0,0x48 /* 37688: 10000001 */ b .L00037690 /* 3768c: 00000000 */ nop diff --git a/src/lib/lib_39be0.c b/src/lib/lib_39be0.c index 3c6d93995..1ce0d6a6c 100644 --- a/src/lib/lib_39be0.c +++ b/src/lib/lib_39be0.c @@ -18,7 +18,7 @@ glabel func00039be0 /* 39c04: 27a50018 */ addiu $a1,$sp,0x18 /* 39c08: 00003025 */ or $a2,$zero,$zero /* 39c0c: 00003825 */ or $a3,$zero,$zero -/* 39c10: 0c00f184 */ jal alEvtqPostEvent +/* 39c10: 0c00f184 */ jal n_alEvtqPostEvent /* 39c14: 24840048 */ addiu $a0,$a0,0x48 /* 39c18: 10000001 */ b .L00039c20 /* 39c1c: 00000000 */ nop @@ -40,7 +40,7 @@ glabel func00039c30 /* 39c48: 27a50018 */ addiu $a1,$sp,0x18 /* 39c4c: 00003025 */ or $a2,$zero,$zero /* 39c50: 00003825 */ or $a3,$zero,$zero -/* 39c54: 0c00f184 */ jal alEvtqPostEvent +/* 39c54: 0c00f184 */ jal n_alEvtqPostEvent /* 39c58: 24840048 */ addiu $a0,$a0,0x48 /* 39c5c: 10000001 */ b .L00039c64 /* 39c60: 00000000 */ nop diff --git a/src/lib/lib_39c80.c b/src/lib/lib_39c80.c index 3c7c39de3..ed0c7beab 100644 --- a/src/lib/lib_39c80.c +++ b/src/lib/lib_39c80.c @@ -20,7 +20,7 @@ glabel func00039c80 /* 39ca4: 27a50018 */ addiu $a1,$sp,0x18 /* 39ca8: 00003025 */ or $a2,$zero,$zero /* 39cac: 00003825 */ or $a3,$zero,$zero -/* 39cb0: 0c00f184 */ jal alEvtqPostEvent +/* 39cb0: 0c00f184 */ jal n_alEvtqPostEvent /* 39cb4: 24840048 */ addiu $a0,$a0,0x48 /* 39cb8: 10000001 */ b .L00039cc0 /* 39cbc: 00000000 */ nop diff --git a/src/lib/lib_39f70.c b/src/lib/lib_39f70.c index 13f11b7b0..3b665d14e 100644 --- a/src/lib/lib_39f70.c +++ b/src/lib/lib_39f70.c @@ -16,7 +16,7 @@ glabel func00039f70 /* 39f88: 27a50018 */ addiu $a1,$sp,0x18 /* 39f8c: 00003025 */ or $a2,$zero,$zero /* 39f90: 00003825 */ or $a3,$zero,$zero -/* 39f94: 0c00f184 */ jal alEvtqPostEvent +/* 39f94: 0c00f184 */ jal n_alEvtqPostEvent /* 39f98: 24840048 */ addiu $a0,$a0,0x48 /* 39f9c: 10000001 */ b .L00039fa4 /* 39fa0: 00000000 */ nop diff --git a/src/lib/lib_3a100.c b/src/lib/lib_3a100.c index 6ab807b6b..35d8f130f 100644 --- a/src/lib/lib_3a100.c +++ b/src/lib/lib_3a100.c @@ -1,5 +1,5 @@ #include -#include "PR/synthInternals.h" +#include "synthInternals.h" #include "constants.h" #include "game/atan2f.h" #include "bss.h" diff --git a/src/lib/lib_3c430.c b/src/lib/lib_3c430.c index dbccf6ba9..c04daa63d 100644 --- a/src/lib/lib_3c430.c +++ b/src/lib/lib_3c430.c @@ -6,7 +6,7 @@ #include "types.h" GLOBAL_ASM( -glabel func0003c430 +glabel n_alSavePull /* 3c430: 27bdffd8 */ addiu $sp,$sp,-40 /* 3c434: afbf0014 */ sw $ra,0x14($sp) /* 3c438: afa40028 */ sw $a0,0x28($sp) diff --git a/src/lib/lib_3c890.c b/src/lib/lib_3c890.c index 6d42d9466..48ab9417b 100644 --- a/src/lib/lib_3c890.c +++ b/src/lib/lib_3c890.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3c4d0.h" #include "lib/lib_3e730.h" #include "data.h" @@ -74,7 +73,7 @@ glabel func0003c900 ); GLOBAL_ASM( -glabel func0003c970 +glabel n_alSynAddSeqPlayer /* 3c970: 27bdffe0 */ addiu $sp,$sp,-32 /* 3c974: afbf0014 */ sw $ra,0x14($sp) /* 3c978: afa40020 */ sw $a0,0x20($sp) @@ -154,7 +153,7 @@ glabel func0003c9e0 /* 3ca8c: 8faf0024 */ lw $t7,0x24($sp) /* 3ca90: 8fb80028 */ lw $t8,0x28($sp) /* 3ca94: af0f0008 */ sw $t7,0x8($t8) -/* 3ca98: 0c00c541 */ jal __allocParam +/* 3ca98: 0c00c541 */ jal __n_allocParam /* 3ca9c: 00000000 */ nop /* 3caa0: afa20020 */ sw $v0,0x20($sp) /* 3caa4: 8fb90020 */ lw $t9,0x20($sp) @@ -181,7 +180,7 @@ glabel func0003c9e0 /* 3caf8: 10000001 */ b .L0003cb00 /* 3cafc: 00000000 */ nop .L0003cb00: -/* 3cb00: 0c00c541 */ jal __allocParam +/* 3cb00: 0c00c541 */ jal __n_allocParam /* 3cb04: 00000000 */ nop /* 3cb08: afa20020 */ sw $v0,0x20($sp) /* 3cb0c: 8fb90020 */ lw $t9,0x20($sp) diff --git a/src/lib/lib_3ccf0.c b/src/lib/lib_3ccf0.c index 943feae62..66e3fd5cd 100644 --- a/src/lib/lib_3ccf0.c +++ b/src/lib/lib_3ccf0.c @@ -1,13 +1,12 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3e730.h" #include "data.h" #include "types.h" GLOBAL_ASM( -glabel alSynSetVol +glabel n_alSynSetVol /* 3ccf0: 27bdffe0 */ addiu $sp,$sp,-32 /* 3ccf4: afbf0014 */ sw $ra,0x14($sp) /* 3ccf8: afa40020 */ sw $a0,0x20($sp) @@ -17,7 +16,7 @@ glabel alSynSetVol /* 3cd08: 8dcf0008 */ lw $t7,0x8($t6) /* 3cd0c: 11e00023 */ beqz $t7,.L0003cd9c /* 3cd10: 00000000 */ nop -/* 3cd14: 0c00c541 */ jal __allocParam +/* 3cd14: 0c00c541 */ jal __n_allocParam /* 3cd18: 00000000 */ nop /* 3cd1c: afa2001c */ sw $v0,0x1c($sp) /* 3cd20: 8fb8001c */ lw $t8,0x1c($sp) @@ -41,7 +40,7 @@ glabel alSynSetVol /* 3cd64: 87b80026 */ lh $t8,0x26($sp) /* 3cd68: 8fb9001c */ lw $t9,0x1c($sp) /* 3cd6c: af38000c */ sw $t8,0xc($t9) -/* 3cd70: 0c00c5a6 */ jal _timeToSamples +/* 3cd70: 0c00c5a6 */ jal _n_timeToSamples /* 3cd74: 8fa40028 */ lw $a0,0x28($sp) /* 3cd78: 8fa9001c */ lw $t1,0x1c($sp) /* 3cd7c: ad220010 */ sw $v0,0x10($t1) diff --git a/src/lib/lib_3cdc0.c b/src/lib/lib_3cdc0.c index f76835d35..ce926e2eb 100644 --- a/src/lib/lib_3cdc0.c +++ b/src/lib/lib_3cdc0.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3e730.h" #include "data.h" #include "types.h" @@ -18,7 +17,7 @@ glabel func0003cdc0 /* 3cddc: 8dcf0008 */ lw $t7,0x8($t6) /* 3cde0: 11e0003c */ beqz $t7,.L0003ced4 /* 3cde4: 00000000 */ nop -/* 3cde8: 0c00c541 */ jal __allocParam +/* 3cde8: 0c00c541 */ jal __n_allocParam /* 3cdec: 00000000 */ nop /* 3cdf0: afa2001c */ sw $v0,0x1c($sp) /* 3cdf4: 8fb8001c */ lw $t8,0x1c($sp) @@ -66,7 +65,7 @@ glabel func0003cdc0 /* 3ce98: c7a6003c */ lwc1 $f6,0x3c($sp) /* 3ce9c: 8fab001c */ lw $t3,0x1c($sp) /* 3cea0: e5660018 */ swc1 $f6,0x18($t3) -/* 3cea4: 0c00c5a6 */ jal _timeToSamples +/* 3cea4: 0c00c5a6 */ jal _n_timeToSamples /* 3cea8: 8fa40044 */ lw $a0,0x44($sp) /* 3ceac: 8fac001c */ lw $t4,0x1c($sp) /* 3ceb0: ad82001c */ sw $v0,0x1c($t4) diff --git a/src/lib/lib_3cef0.c b/src/lib/lib_3cef0.c index 746cd96c0..807fc3ea8 100644 --- a/src/lib/lib_3cef0.c +++ b/src/lib/lib_3cef0.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3e730.h" #include "data.h" #include "types.h" @@ -16,7 +15,7 @@ glabel func0003cef0 /* 3cf04: 8dcf0008 */ lw $t7,0x8($t6) /* 3cf08: 11e0001f */ beqz $t7,.L0003cf88 /* 3cf0c: 00000000 */ nop -/* 3cf10: 0c00c541 */ jal __allocParam +/* 3cf10: 0c00c541 */ jal __n_allocParam /* 3cf14: 00000000 */ nop /* 3cf18: afa2001c */ sw $v0,0x1c($sp) /* 3cf1c: 8fb8001c */ lw $t8,0x1c($sp) @@ -67,7 +66,7 @@ glabel func0003cfa0 /* 3cfb4: 8dcf0008 */ lw $t7,0x8($t6) /* 3cfb8: 11e0001f */ beqz $t7,.L0003d038 /* 3cfbc: 00000000 */ nop -/* 3cfc0: 0c00c541 */ jal __allocParam +/* 3cfc0: 0c00c541 */ jal __n_allocParam /* 3cfc4: 00000000 */ nop /* 3cfc8: afa2001c */ sw $v0,0x1c($sp) /* 3cfcc: 8fb8001c */ lw $t8,0x1c($sp) @@ -118,7 +117,7 @@ glabel func0003d050 /* 3d064: 8dcf0008 */ lw $t7,0x8($t6) /* 3d068: 11e0001f */ beqz $t7,.L0003d0e8 /* 3d06c: 00000000 */ nop -/* 3d070: 0c00c541 */ jal __allocParam +/* 3d070: 0c00c541 */ jal __n_allocParam /* 3d074: 00000000 */ nop /* 3d078: afa2001c */ sw $v0,0x1c($sp) /* 3d07c: 8fb8001c */ lw $t8,0x1c($sp) @@ -168,7 +167,7 @@ glabel func0003d100 /* 3d110: 8dcf0008 */ lw $t7,0x8($t6) /* 3d114: 11e0001c */ beqz $t7,.L0003d188 /* 3d118: 00000000 */ nop -/* 3d11c: 0c00c541 */ jal __allocParam +/* 3d11c: 0c00c541 */ jal __n_allocParam /* 3d120: 00000000 */ nop /* 3d124: afa2001c */ sw $v0,0x1c($sp) /* 3d128: 8fb8001c */ lw $t8,0x1c($sp) @@ -220,7 +219,7 @@ glabel func0003d1a0 /* 3d1c4: 8f280088 */ lw $t0,0x88($t9) /* 3d1c8: 1100001f */ beqz $t0,.L0003d248 /* 3d1cc: 00000000 */ nop -/* 3d1d0: 0c00c541 */ jal __allocParam +/* 3d1d0: 0c00c541 */ jal __n_allocParam /* 3d1d4: 00000000 */ nop /* 3d1d8: afa2001c */ sw $v0,0x1c($sp) /* 3d1dc: 8fa9001c */ lw $t1,0x1c($sp) @@ -253,7 +252,7 @@ glabel func0003d1a0 /* 3d244: 00000000 */ nop .L0003d248: /* 3d248: 8fad0020 */ lw $t5,0x20($sp) -/* 3d24c: 0c00c57d */ jal _freePVoice +/* 3d24c: 0c00c57d */ jal _n_freePVoice /* 3d250: 8da40008 */ lw $a0,0x8($t5) .L0003d254: /* 3d254: 8fab0020 */ lw $t3,0x20($sp) diff --git a/src/lib/lib_3e3e0.c b/src/lib/lib_3e3e0.c index c724d39ce..0eeb9c715 100644 --- a/src/lib/lib_3e3e0.c +++ b/src/lib/lib_3e3e0.c @@ -1,7 +1,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3a100.h" #include "lib/lib_3e730.h" #include "data.h" @@ -22,7 +21,7 @@ glabel func0003e3e0 /* 3e3f4: 8dcf0008 */ lw $t7,0x8($t6) /* 3e3f8: 11e0001f */ beqz $t7,.L0003e478 /* 3e3fc: 00000000 */ nop -/* 3e400: 0c00c541 */ jal __allocParam +/* 3e400: 0c00c541 */ jal __n_allocParam /* 3e404: 00000000 */ nop /* 3e408: afa2001c */ sw $v0,0x1c($sp) /* 3e40c: 8fb8001c */ lw $t8,0x1c($sp) @@ -73,7 +72,7 @@ glabel func0003e490 /* 3e4a4: 8dcf0008 */ lw $t7,0x8($t6) /* 3e4a8: 11e0001f */ beqz $t7,.L0003e528 /* 3e4ac: 00000000 */ nop -/* 3e4b0: 0c00c541 */ jal __allocParam +/* 3e4b0: 0c00c541 */ jal __n_allocParam /* 3e4b4: 00000000 */ nop /* 3e4b8: afa2001c */ sw $v0,0x1c($sp) /* 3e4bc: 8fb8001c */ lw $t8,0x1c($sp) diff --git a/src/lib/lib_3e730.c b/src/lib/lib_3e730.c index 9139b54de..9e7b4fb2c 100644 --- a/src/lib/lib_3e730.c +++ b/src/lib/lib_3e730.c @@ -2,7 +2,6 @@ #include "constants.h" #include "bss.h" #include "lib/mtx.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3e730.h" #include "lib/lib_43dd0.h" #include "lib/lib_44f60.h" @@ -24,7 +23,7 @@ glabel func0003e730 /* 3e744: 8dcf0008 */ lw $t7,0x8($t6) /* 3e748: 11e0001f */ beqz $t7,.L0003e7c8 /* 3e74c: 00000000 */ nop -/* 3e750: 0c00c541 */ jal __allocParam +/* 3e750: 0c00c541 */ jal __n_allocParam /* 3e754: 00000000 */ nop /* 3e758: afa2001c */ sw $v0,0x1c($sp) /* 3e75c: 8fb8001c */ lw $t8,0x1c($sp) diff --git a/src/lib/lib_3f8a0.c b/src/lib/lib_3f8a0.c index 964bbbc8e..b3530103d 100644 --- a/src/lib/lib_3f8a0.c +++ b/src/lib/lib_3f8a0.c @@ -1,9 +1,7 @@ #include -#include "PR/synthInternals.h" #include "constants.h" #include "bss.h" #include "lib/mtx.h" -#include "lib/lib_30ce0.h" #include "lib/lib_3e8c0.h" #include "lib/lib_43dd0.h" #include "lib/lib_44f60.h" diff --git a/src/lib/lib_43dd0.c b/src/lib/lib_43dd0.c index e71af9ae1..6c96e0319 100644 --- a/src/lib/lib_43dd0.c +++ b/src/lib/lib_43dd0.c @@ -640,7 +640,7 @@ glabel func00044650 /* 4469c: 27a50020 */ addiu $a1,$sp,0x20 /* 446a0: 8fa6001c */ lw $a2,0x1c($sp) /* 446a4: 00003825 */ or $a3,$zero,$zero -/* 446a8: 0c00f184 */ jal alEvtqPostEvent +/* 446a8: 0c00f184 */ jal n_alEvtqPostEvent /* 446ac: 24840048 */ addiu $a0,$a0,0x48 /* 446b0: 10000001 */ b .L000446b8 /* 446b4: 00000000 */ nop diff --git a/src/lib/lib_4e090.c b/src/lib/lib_4e090.c index e5284b59b..cfea5749d 100644 --- a/src/lib/lib_4e090.c +++ b/src/lib/lib_4e090.c @@ -1,5 +1,4 @@ #include -#include "libultra_internal.h" #include "constants.h" #include "bss.h" #include "lib/libc/ll.h" diff --git a/src/lib/main.c b/src/lib/main.c index 8a9f10723..5decadf74 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -1,4 +1,5 @@ #include +#include #include "lib/sched.h" #include "constants.h" #include "game/camdraw.h" @@ -1576,7 +1577,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400"; // } // // // Copy the texture to the framebuffer -// if (osTvType != OS_TV_TYPE_PAL) { +// if (osTvType != OS_TV_PAL) { // s32 fby = 0; // // for (y = 0; y < 48 * 507; y += 507) { @@ -1620,7 +1621,7 @@ const char var70053aa0[] = " -ml0 -me0 -mgfx100 -mvtx50 -mt700 -ma400"; // // Design the program to either go into an infinite loop or display a // // message indicating a system error. // // -// if (osTvType == OS_TV_TYPE_PAL) { +// if (osTvType == OS_TV_PAL) { // while (1); // } // diff --git a/src/lib/mp3.c b/src/lib/mp3.c index d6cd15450..95497f8f5 100644 --- a/src/lib/mp3.c +++ b/src/lib/mp3.c @@ -830,7 +830,7 @@ s32 func00038ba8(s32 arg0, u8 *arg1, s32 arg2, s32 arg3) arg2 = g_Mp3Vars.var8009c3c0 - g_Mp3Vars.var8009c3c4; } - proc = n_syn->drvr.dma(&sp1c); + proc = n_syn->dma(&sp1c); sp1c = OS_K0_TO_PHYSICAL(proc(g_Mp3Vars.var8009c390 + g_Mp3Vars.var8009c3c4, arg2, 0)); bcopy((u8 *)sp1c, arg1, arg2); @@ -845,7 +845,7 @@ void func00038cac(void) u32 state; ALDMAproc proc; - proc = n_syn->drvr.dma(&state); + proc = n_syn->dma(&state); proc(g_Mp3Vars.var8009c390 + g_Mp3Vars.var8009c3c4, 0x400, 0); } diff --git a/src/lib/naudio/n_abi.h b/src/lib/naudio/n_abi.h new file mode 100644 index 000000000..f408a90c5 --- /dev/null +++ b/src/lib/naudio/n_abi.h @@ -0,0 +1,122 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_ABI__ +#define __N_ABI__ + +/* + * BEGIN C-specific section: (typedef's) + */ + +#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) + + +/* + * Macros to assemble the audio command list + */ + +#define n_aADPCMdec(pkt, s, f, c, a, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ADPCM, 24, 8) | _SHIFTL(s, 0, 24)); \ + _a->words.w1 = (_SHIFTL(f, 28, 4) | _SHIFTL(c, 16, 12) | \ + _SHIFTL(a, 12, 4) | _SHIFTL(d, 0, 12)); \ +} + +#define n_aPoleFilter(pkt, f, g, t, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_POLEF, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(g, 0, 16)); \ + _a->words.w1 = (_SHIFTL(t, 24, 8) | \ + _SHIFTL((unsigned int)(s), 0, 24)); \ +} + +#define n_aEnvMixer(pkt, f, t, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_ENVMIXER, 24, 8) | _SHIFTL(f, 16, 8) |\ + _SHIFTL(t, 0, 16)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define n_aInterleave(pkt) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_INTERLEAVE, 24, 8); \ +} + +#define n_aLoadBuffer(pkt, c, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL(c, 12, 12)|\ + _SHIFTL(d, 0, 12)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define n_aResample(pkt, s, f, p, i, o) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_RESAMPLE, 24, 8) | _SHIFTL(s, 0, 24));\ + _a->words.w1 = (_SHIFTL(f, 30, 2) | _SHIFTL(p, 14, 16) | \ + _SHIFTL(i, 2, 12) | _SHIFTL(o, 0, 2)); \ +} + +#define n_aSaveBuffer(pkt, c, d, s) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL(c, 12, 12)|\ + _SHIFTL(d, 0, 12)); \ + _a->words.w1 = (unsigned int)(s); \ +} + +#define n_aSetVolume(pkt, f, v, t, r) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = (_SHIFTL(A_SETVOL, 24, 8) | _SHIFTL(f, 16, 8) | \ + _SHIFTL(v, 0, 16)); \ + _a->words.w1 = _SHIFTL(t, 16, 16) | _SHIFTL(r, 0, 16); \ +} + +#define n_aLoadADPCM(pkt, c, d) \ +{ \ + Acmd *_a = (Acmd *)pkt; \ + \ + _a->words.w0 = _SHIFTL(A_LOADADPCM, 24, 8) | _SHIFTL(c, 0, 24); \ + _a->words.w1 = (unsigned int) d; \ +} + +#endif /* _LANGUAGE_C */ + +#endif /* __N_ABI__ */ + + + + + + + diff --git a/src/lib/naudio/n_cseqp.h b/src/lib/naudio/n_cseqp.h new file mode 100644 index 000000000..9d60b6700 --- /dev/null +++ b/src/lib/naudio/n_cseqp.h @@ -0,0 +1,26 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_CSEQP__ +#define __N_CSEQP__ + +void __n_CSPPostNextSeqEvent(N_ALCSPlayer *seqp); + + +#endif /* __N_CSEQP__ */ diff --git a/src/lib/ultra/audio/csplayer.c b/src/lib/naudio/n_csplayer.c similarity index 98% rename from src/lib/ultra/audio/csplayer.c rename to src/lib/naudio/n_csplayer.c index 802ca203a..f4e9b3a5e 100644 --- a/src/lib/ultra/audio/csplayer.c +++ b/src/lib/naudio/n_csplayer.c @@ -1,23 +1,12 @@ -#include -#include "PR/seqp.h" -#include "constants.h" -#include "bss.h" -#include "lib/snd.h" -#include "lib/lib_2fc60.h" -#include "lib/lib_30ce0.h" -#include "lib/lib_317f0.h" -#include "lib/lib_39c80.h" -#include "lib/lib_39fe0.h" -#include "lib/lib_3a100.h" -#include "lib/lib_3c4d0.h" -#include "lib/lib_3ccf0.h" -#include "lib/lib_3cdc0.h" -#include "lib/lib_3cef0.h" -#include "lib/lib_3d280.h" -#include "lib/lib_3e3e0.h" -#include "lib/lib_3e730.h" -#include "data.h" -#include "types.h" +#include "versions.h" +#include +#include +#include +#include +#include "n_libaudio.h" +#include "n_seqp.h" +#include "cseq.h" +#include "n_cseqp.h" void __n_CSPRepostEvent(ALEventQueue *evtq, ALEventListItem *item); void __n_setUsptFromTempo(ALCSPlayer *seqp, f32 tempo); @@ -291,12 +280,12 @@ u32 var8005f56c = 0x00000000; ALMicroTime __CSPVoiceHandler(void *node); -void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c) +void n_alCSPNew(N_ALCSPlayer *seqp, ALSeqpConfig *c) { s32 i; - ALEventListItem *items; - ALVoiceState *vs; - ALVoiceState *voices; + N_ALEventListItem *items; + N_ALVoiceState *vs; + N_ALVoiceState *voices; ALHeap *hp = c->heap; @@ -305,7 +294,7 @@ void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c) */ seqp->bank = 0; seqp->target = NULL; - seqp->drvr = &n_syn->drvr; + seqp->drvr = n_syn; seqp->chanMask = 0xffff; func00039cd0(seqp); @@ -334,12 +323,12 @@ void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c) */ seqp->maxChannels = c->maxChannels; seqp->chanState = alHeapAlloc(hp, c->maxChannels, sizeof(ALChanState) ); - __initChanState((ALSeqPlayer*)seqp); + __n_initChanState((N_ALSeqPlayer*)seqp); /* * init the voice state array */ - voices = alHeapAlloc(hp, c->maxVoices, sizeof(ALVoiceState)); + voices = alHeapAlloc(hp, c->maxVoices, sizeof(N_ALVoiceState)); seqp->vFreeList = 0; for (i = 0; i < c->maxVoices; i++) { vs = &voices[i]; @@ -353,7 +342,7 @@ void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c) /* * init the event queue */ - items = alHeapAlloc(hp, c->maxEvents, sizeof(ALEventListItem)); + items = alHeapAlloc(hp, c->maxEvents, sizeof(N_ALEventListItem)); n_alEvtqNew(&seqp->evtq, items, c->maxEvents); @@ -364,7 +353,7 @@ void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *c) seqp->node.handler = __CSPVoiceHandler; seqp->node.clientData = seqp; - func0003c970(seqp); + n_alSynAddSeqPlayer(&seqp->node); } GLOBAL_ASM( @@ -444,7 +433,7 @@ glabel var700547e4 /* 344f4: 8c384780 */ lw $t8,%lo(var70054780)($at) /* 344f8: 03000008 */ jr $t8 /* 344fc: 00000000 */ nop -/* 34500: 0c00d37e */ jal func00034df8 +/* 34500: 0c00d37e */ jal __n_CSPHandleNextSeqEvent /* 34504: 8fa40074 */ lw $a0,0x74($sp) /* 34508: 10000220 */ b .L00034d8c /* 3450c: 00000000 */ nop @@ -454,7 +443,7 @@ glabel var700547e4 /* 3451c: 27a50064 */ addiu $a1,$sp,0x64 /* 34520: 24070001 */ addiu $a3,$zero,0x1 /* 34524: 25040048 */ addiu $a0,$t0,0x48 -/* 34528: 0c00f184 */ jal alEvtqPostEvent +/* 34528: 0c00f184 */ jal n_alEvtqPostEvent /* 3452c: 8d06005c */ lw $a2,0x5c($t0) /* 34530: 10000216 */ b .L00034d8c /* 34534: 00000000 */ nop @@ -515,7 +504,7 @@ glabel var700547e4 /* 34608: 00108403 */ sra $s0,$s0,0x10 /* 3460c: 02002825 */ or $a1,$s0,$zero /* 34610: 8fa40060 */ lw $a0,0x60($sp) -/* 34614: 0c00f33c */ jal alSynSetVol +/* 34614: 0c00f33c */ jal n_alSynSetVol /* 34618: 8fa6005c */ lw $a2,0x5c($sp) /* 3461c: 100001db */ b .L00034d8c /* 34620: 00000000 */ nop @@ -586,7 +575,7 @@ glabel var700547e4 /* 34718: 00408825 */ or $s1,$v0,$zero /* 3471c: 02203025 */ or $a2,$s1,$zero /* 34720: 02002825 */ or $a1,$s0,$zero -/* 34724: 0c00f33c */ jal alSynSetVol +/* 34724: 0c00f33c */ jal n_alSynSetVol /* 34728: 24840004 */ addiu $a0,$a0,0x4 /* 3472c: 240c0016 */ addiu $t4,$zero,0x16 /* 34730: a7ac0064 */ sh $t4,0x64($sp) @@ -598,7 +587,7 @@ glabel var700547e4 /* 34748: 27a50064 */ addiu $a1,$sp,0x64 /* 3474c: 8fa6005c */ lw $a2,0x5c($sp) /* 34750: 00003825 */ or $a3,$zero,$zero -/* 34754: 0c00f184 */ jal alEvtqPostEvent +/* 34754: 0c00f184 */ jal n_alEvtqPostEvent /* 34758: 24840048 */ addiu $a0,$a0,0x48 /* 3475c: 1000018b */ b .L00034d8c /* 34760: 00000000 */ nop @@ -706,7 +695,7 @@ glabel var700547e4 /* 348f4: 27a50064 */ addiu $a1,$sp,0x64 /* 348f8: 8fa6005c */ lw $a2,0x5c($sp) /* 348fc: 00003825 */ or $a3,$zero,$zero -/* 34900: 0c00f184 */ jal alEvtqPostEvent +/* 34900: 0c00f184 */ jal n_alEvtqPostEvent /* 34904: 24840048 */ addiu $a0,$a0,0x48 /* 34908: 10000120 */ b .L00034d8c /* 3490c: 00000000 */ nop @@ -743,7 +732,7 @@ glabel var700547e4 /* 34984: 00408825 */ or $s1,$v0,$zero /* 34988: 02203025 */ or $a2,$s1,$zero /* 3498c: 02002825 */ or $a1,$s0,$zero -/* 34990: 0c00f33c */ jal alSynSetVol +/* 34990: 0c00f33c */ jal n_alSynSetVol /* 34994: 24840004 */ addiu $a0,$a0,0x4 /* 34998: 8faf0058 */ lw $t7,0x58($sp) /* 3499c: 8df90000 */ lw $t9,0x0($t7) @@ -968,7 +957,7 @@ glabel var700547e4 /* 34cc4: 34c6ffff */ ori $a2,$a2,0xffff /* 34cc8: 27a50064 */ addiu $a1,$sp,0x64 /* 34ccc: 00003825 */ or $a3,$zero,$zero -/* 34cd0: 0c00f184 */ jal alEvtqPostEvent +/* 34cd0: 0c00f184 */ jal n_alEvtqPostEvent /* 34cd4: 24840048 */ addiu $a0,$a0,0x48 .L00034cd8: /* 34cd8: 1000002c */ b .L00034d8c @@ -1049,48 +1038,48 @@ glabel var700547e4 ); GLOBAL_ASM( -glabel func00034df8 +glabel __n_CSPHandleNextSeqEvent .late_rodata glabel var700547e8 -.word func00034df8+0x64 +.word __n_CSPHandleNextSeqEvent+0x64 glabel var700547ec -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var700547f0 -.word func00034df8+0x80 +.word __n_CSPHandleNextSeqEvent+0x80 glabel var700547f4 -.word func00034df8+0x9c +.word __n_CSPHandleNextSeqEvent+0x9c glabel var700547f8 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var700547fc -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054800 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054804 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054808 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var7005480c -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054810 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054814 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054818 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var7005481c -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054820 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054824 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var70054828 -.word func00034df8+0xf4 +.word __n_CSPHandleNextSeqEvent+0xf4 glabel var7005482c -.word func00034df8+0xe4 +.word __n_CSPHandleNextSeqEvent+0xe4 glabel var70054830 -.word func00034df8+0xe4 +.word __n_CSPHandleNextSeqEvent+0xe4 glabel var70054834 -.word func00034df8+0xe4 +.word __n_CSPHandleNextSeqEvent+0xe4 .text /* 34df8: 27bdffd8 */ addiu $sp,$sp,-40 /* 34dfc: afbf0014 */ sw $ra,0x14($sp) @@ -1105,7 +1094,7 @@ glabel var70054834 /* 34e1c: 8fb80028 */ lw $t8,0x28($sp) /* 34e20: 27a50018 */ addiu $a1,$sp,0x18 /* 34e24: 24060001 */ addiu $a2,$zero,0x1 -/* 34e28: 0c00e3ac */ jal alCSeqNextEvent +/* 34e28: 0c00e3ac */ jal n_alCSeqNextEvent /* 34e2c: 8f040018 */ lw $a0,0x18($t8) /* 34e30: 87b90018 */ lh $t9,0x18($sp) /* 34e34: 2728ffff */ addiu $t0,$t9,-1 @@ -1146,7 +1135,7 @@ glabel var70054834 /* 34ec0: 34c6ffff */ ori $a2,$a2,0xffff /* 34ec4: 27a50018 */ addiu $a1,$sp,0x18 /* 34ec8: 00003825 */ or $a3,$zero,$zero -/* 34ecc: 0c00f184 */ jal alEvtqPostEvent +/* 34ecc: 0c00f184 */ jal n_alEvtqPostEvent /* 34ed0: 24840048 */ addiu $a0,$a0,0x48 .L00034ed4: /* 34ed4: 10000007 */ b .L00034ef4 @@ -1201,7 +1190,7 @@ glabel func00034f0c /* 34f78: 00408025 */ or $s0,$v0,$zero /* 34f7c: 02003025 */ or $a2,$s0,$zero /* 34f80: 87a5002a */ lh $a1,0x2a($sp) -/* 34f84: 0c00f33c */ jal alSynSetVol +/* 34f84: 0c00f33c */ jal n_alSynSetVol /* 34f88: 24840004 */ addiu $a0,$a0,0x4 .L00034f8c: /* 34f8c: 8fab002c */ lw $t3,0x2c($sp) @@ -1691,7 +1680,7 @@ glabel var70054a74 /* 35250: 27a500a4 */ addiu $a1,$sp,0xa4 /* 35254: 8fa600a0 */ lw $a2,0xa0($sp) /* 35258: 00003825 */ or $a3,$zero,$zero -/* 3525c: 0c00f184 */ jal alEvtqPostEvent +/* 3525c: 0c00f184 */ jal n_alEvtqPostEvent /* 35260: 24840048 */ addiu $a0,$a0,0x48 .L00035264: /* 35264: 100007e6 */ b .L00037200 @@ -1910,7 +1899,7 @@ glabel var70054a74 /* 35588: 27a500a4 */ addiu $a1,$sp,0xa4 /* 3558c: 8fa600a0 */ lw $a2,0xa0($sp) /* 35590: 00003825 */ or $a3,$zero,$zero -/* 35594: 0c00f184 */ jal alEvtqPostEvent +/* 35594: 0c00f184 */ jal n_alEvtqPostEvent /* 35598: 24840048 */ addiu $a0,$a0,0x48 /* 3559c: 8fac009c */ lw $t4,0x9c($sp) /* 355a0: 918f0037 */ lbu $t7,0x37($t4) @@ -2040,7 +2029,7 @@ glabel var70054a74 /* 35770: 27a500a4 */ addiu $a1,$sp,0xa4 /* 35774: 8fa600a0 */ lw $a2,0xa0($sp) /* 35778: 00003825 */ or $a3,$zero,$zero -/* 3577c: 0c00f184 */ jal alEvtqPostEvent +/* 3577c: 0c00f184 */ jal n_alEvtqPostEvent /* 35780: 24840048 */ addiu $a0,$a0,0x48 /* 35784: 8faa009c */ lw $t2,0x9c($sp) /* 35788: 91490037 */ lbu $t1,0x37($t2) @@ -2165,7 +2154,7 @@ glabel var70054a74 /* 35948: 27a500a4 */ addiu $a1,$sp,0xa4 /* 3594c: 8fa600a0 */ lw $a2,0xa0($sp) /* 35950: 00003825 */ or $a3,$zero,$zero -/* 35954: 0c00f184 */ jal alEvtqPostEvent +/* 35954: 0c00f184 */ jal n_alEvtqPostEvent /* 35958: 24840048 */ addiu $a0,$a0,0x48 /* 3595c: 8fb900b8 */ lw $t9,0xb8($sp) /* 35960: 8f2d0008 */ lw $t5,0x8($t9) @@ -2197,7 +2186,7 @@ glabel var70054a74 /* 359c8: 27a500a4 */ addiu $a1,$sp,0xa4 /* 359cc: 8fa600a0 */ lw $a2,0xa0($sp) /* 359d0: 00003825 */ or $a3,$zero,$zero -/* 359d4: 0c00f184 */ jal alEvtqPostEvent +/* 359d4: 0c00f184 */ jal n_alEvtqPostEvent /* 359d8: 24840048 */ addiu $a0,$a0,0x48 .L000359dc: /* 359dc: 8fb80094 */ lw $t8,0x94($sp) @@ -2333,7 +2322,7 @@ glabel var70054a74 /* 35bc4: 00408025 */ or $s0,$v0,$zero /* 35bc8: 02003025 */ or $a2,$s0,$zero /* 35bcc: 02202825 */ or $a1,$s1,$zero -/* 35bd0: 0c00f33c */ jal alSynSetVol +/* 35bd0: 0c00f33c */ jal n_alSynSetVol /* 35bd4: 24840004 */ addiu $a0,$a0,0x4 /* 35bd8: 10000589 */ b .L00037200 /* 35bdc: 00000000 */ nop @@ -2363,7 +2352,7 @@ glabel var70054a74 /* 35c38: 00408025 */ or $s0,$v0,$zero /* 35c3c: 02003025 */ or $a2,$s0,$zero /* 35c40: 02202825 */ or $a1,$s1,$zero -/* 35c44: 0c00f33c */ jal alSynSetVol +/* 35c44: 0c00f33c */ jal n_alSynSetVol /* 35c48: 24840004 */ addiu $a0,$a0,0x4 .L00035c4c: /* 35c4c: 8fb900c8 */ lw $t9,0xc8($sp) @@ -2673,7 +2662,7 @@ glabel var70054a74 /* 360bc: 00c13023 */ subu $a2,$a2,$at /* 360c0: 000630c0 */ sll $a2,$a2,0x3 /* 360c4: 00c13021 */ addu $a2,$a2,$at -/* 360c8: 0c00f184 */ jal alEvtqPostEvent +/* 360c8: 0c00f184 */ jal n_alEvtqPostEvent /* 360cc: 00063080 */ sll $a2,$a2,0x2 .L000360d0: /* 360d0: 93b80067 */ lbu $t8,0x67($sp) @@ -2872,7 +2861,7 @@ glabel var70054a74 /* 363ac: 00408025 */ or $s0,$v0,$zero /* 363b0: 02003025 */ or $a2,$s0,$zero /* 363b4: 87a500b6 */ lh $a1,0xb6($sp) -/* 363b8: 0c00f33c */ jal alSynSetVol +/* 363b8: 0c00f33c */ jal n_alSynSetVol /* 363bc: 24840004 */ addiu $a0,$a0,0x4 .L000363c0: /* 363c0: 8fae00c8 */ lw $t6,0xc8($sp) @@ -4209,7 +4198,7 @@ glabel var70054a74 /* 35250: 27a500a4 */ addiu $a1,$sp,0xa4 /* 35254: 8fa600a0 */ lw $a2,0xa0($sp) /* 35258: 00003825 */ or $a3,$zero,$zero -/* 3525c: 0c00f184 */ jal alEvtqPostEvent +/* 3525c: 0c00f184 */ jal n_alEvtqPostEvent /* 35260: 24840048 */ addiu $a0,$a0,0x48 .L00035264: /* 35264: 100007e6 */ b .L00037200 @@ -4428,7 +4417,7 @@ glabel var70054a74 /* 35588: 27a500a4 */ addiu $a1,$sp,0xa4 /* 3558c: 8fa600a0 */ lw $a2,0xa0($sp) /* 35590: 00003825 */ or $a3,$zero,$zero -/* 35594: 0c00f184 */ jal alEvtqPostEvent +/* 35594: 0c00f184 */ jal n_alEvtqPostEvent /* 35598: 24840048 */ addiu $a0,$a0,0x48 /* 3559c: 8fac009c */ lw $t4,0x9c($sp) /* 355a0: 918f0037 */ lbu $t7,0x37($t4) @@ -4558,7 +4547,7 @@ glabel var70054a74 /* 35770: 27a500a4 */ addiu $a1,$sp,0xa4 /* 35774: 8fa600a0 */ lw $a2,0xa0($sp) /* 35778: 00003825 */ or $a3,$zero,$zero -/* 3577c: 0c00f184 */ jal alEvtqPostEvent +/* 3577c: 0c00f184 */ jal n_alEvtqPostEvent /* 35780: 24840048 */ addiu $a0,$a0,0x48 /* 35784: 8faa009c */ lw $t2,0x9c($sp) /* 35788: 91490037 */ lbu $t1,0x37($t2) @@ -4683,7 +4672,7 @@ glabel var70054a74 /* 35948: 27a500a4 */ addiu $a1,$sp,0xa4 /* 3594c: 8fa600a0 */ lw $a2,0xa0($sp) /* 35950: 00003825 */ or $a3,$zero,$zero -/* 35954: 0c00f184 */ jal alEvtqPostEvent +/* 35954: 0c00f184 */ jal n_alEvtqPostEvent /* 35958: 24840048 */ addiu $a0,$a0,0x48 /* 3595c: 8fb900b8 */ lw $t9,0xb8($sp) /* 35960: 8f2d0008 */ lw $t5,0x8($t9) @@ -4715,7 +4704,7 @@ glabel var70054a74 /* 359c8: 27a500a4 */ addiu $a1,$sp,0xa4 /* 359cc: 8fa600a0 */ lw $a2,0xa0($sp) /* 359d0: 00003825 */ or $a3,$zero,$zero -/* 359d4: 0c00f184 */ jal alEvtqPostEvent +/* 359d4: 0c00f184 */ jal n_alEvtqPostEvent /* 359d8: 24840048 */ addiu $a0,$a0,0x48 .L000359dc: /* 359dc: 8fb80094 */ lw $t8,0x94($sp) @@ -4851,7 +4840,7 @@ glabel var70054a74 /* 35bc4: 00408025 */ or $s0,$v0,$zero /* 35bc8: 02003025 */ or $a2,$s0,$zero /* 35bcc: 02202825 */ or $a1,$s1,$zero -/* 35bd0: 0c00f33c */ jal alSynSetVol +/* 35bd0: 0c00f33c */ jal n_alSynSetVol /* 35bd4: 24840004 */ addiu $a0,$a0,0x4 /* 35bd8: 10000589 */ b .L00037200 /* 35bdc: 00000000 */ nop @@ -4881,7 +4870,7 @@ glabel var70054a74 /* 35c38: 00408025 */ or $s0,$v0,$zero /* 35c3c: 02003025 */ or $a2,$s0,$zero /* 35c40: 02202825 */ or $a1,$s1,$zero -/* 35c44: 0c00f33c */ jal alSynSetVol +/* 35c44: 0c00f33c */ jal n_alSynSetVol /* 35c48: 24840004 */ addiu $a0,$a0,0x4 .L00035c4c: /* 35c4c: 8fb900c8 */ lw $t9,0xc8($sp) @@ -5191,7 +5180,7 @@ glabel var70054a74 /* 360bc: 00c13023 */ subu $a2,$a2,$at /* 360c0: 000630c0 */ sll $a2,$a2,0x3 /* 360c4: 00c13021 */ addu $a2,$a2,$at -/* 360c8: 0c00f184 */ jal alEvtqPostEvent +/* 360c8: 0c00f184 */ jal n_alEvtqPostEvent /* 360cc: 00063080 */ sll $a2,$a2,0x2 .L000360d0: /* 360d0: 93b80067 */ lbu $t8,0x67($sp) @@ -5390,7 +5379,7 @@ glabel var70054a74 /* 363ac: 00408025 */ or $s0,$v0,$zero /* 363b0: 02003025 */ or $a2,$s0,$zero /* 363b4: 87a500b6 */ lh $a1,0xb6($sp) -/* 363b8: 0c00f33c */ jal alSynSetVol +/* 363b8: 0c00f33c */ jal n_alSynSetVol /* 363bc: 24840004 */ addiu $a0,$a0,0x4 .L000363c0: /* 363c0: 8fae00c8 */ lw $t6,0xc8($sp) @@ -6481,7 +6470,7 @@ glabel func0003759c /* 37608: 25040048 */ addiu $a0,$t0,0x48 /* 3760c: 012a0019 */ multu $t1,$t2 /* 37610: 00003012 */ mflo $a2 -/* 37614: 0c00f184 */ jal alEvtqPostEvent +/* 37614: 0c00f184 */ jal n_alEvtqPostEvent /* 37618: 00000000 */ nop /* 3761c: 10000001 */ b .L00037624 /* 37620: 00000000 */ nop diff --git a/src/lib/ultra/audio/cseq.c b/src/lib/naudio/n_csq.c similarity index 95% rename from src/lib/ultra/audio/cseq.c rename to src/lib/naudio/n_csq.c index 1cbdb1b91..09c5eba48 100644 --- a/src/lib/ultra/audio/cseq.c +++ b/src/lib/naudio/n_csq.c @@ -1,15 +1,13 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/lib_3c4d0.h" -#include "data.h" -#include "types.h" +#include +#include "n_libaudio.h" +#include +#include -u32 __alCSeqGetTrackEvent(ALCSeq *seq, u32 track, ALEvent *event, s32 arg3); +u32 __n_alCSeqGetTrackEvent(ALCSeq *seq, u32 track, N_ALEvent *event, s32 arg3); u8 __getTrackByte(ALCSeq *seq, u32 track); u32 __readVarLen(ALCSeq *seq,u32 track); -void alCSeqNew(ALCSeq *seq, u8 *ptr) +void n_alCSeqNew(ALCSeq *seq, u8 *ptr) { u32 i, tmpOff, flagTmp; @@ -39,7 +37,7 @@ void alCSeqNew(ALCSeq *seq, u8 *ptr) seq->qnpt = 1.0f / (f32)seq->base->division; } -void alCSeqNextEvent(ALCSeq *seq, ALEvent *evt, s32 arg2) +void n_alCSeqNextEvent(ALCSeq *seq, N_ALEvent *evt, s32 arg2) { u32 i; u32 firstTime = 0xffffffff; @@ -59,7 +57,7 @@ void alCSeqNextEvent(ALCSeq *seq, ALEvent *evt, s32 arg2) } } - __alCSeqGetTrackEvent(seq, firstTrack, evt, arg2); + __n_alCSeqGetTrackEvent(seq, firstTrack, evt, arg2); evt->msg.midi.ticks = firstTime; seq->lastTicks += firstTime; @@ -72,7 +70,7 @@ void alCSeqNextEvent(ALCSeq *seq, ALEvent *evt, s32 arg2) seq->deltaFlag = 1; } -u32 __alCSeqGetTrackEvent(ALCSeq *seq, u32 track, ALEvent *event, s32 arg3) +u32 __n_alCSeqGetTrackEvent(ALCSeq *seq, u32 track, N_ALEvent *event, s32 arg3) { u32 offset; u8 status, loopCt, curLpCt, *tmpPtr; @@ -200,13 +198,13 @@ void alCSeqGetLoc(ALCSeq *seq, ALCSeqMarker *m) } } -void alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks) +void n_alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks) { - ALEvent evt; + N_ALEvent evt; ALCSeq tempSeq; s32 i; - alCSeqNew(&tempSeq, (u8*)seq->base); + n_alCSeqNew(&tempSeq, (u8*)seq->base); do { m->validTracks = tempSeq.validTracks; @@ -221,7 +219,7 @@ void alCSeqNewMarker(ALCSeq *seq, ALCSeqMarker *m, u32 ticks) m->evtDeltaTicks[i] = tempSeq.evtDeltaTicks[i]; } - alCSeqNextEvent(&tempSeq, &evt, 0); + n_alCSeqNextEvent(&tempSeq, &evt, 0); if (evt.type == AL_SEQ_END_EVT) { break; @@ -239,7 +237,7 @@ glabel func00039718 /* 3972c: afa70224 */ sw $a3,0x224($sp) /* 39730: 8fae0218 */ lw $t6,0x218($sp) /* 39734: 27a40110 */ addiu $a0,$sp,0x110 -/* 39738: 0c00e34c */ jal alCSeqNew +/* 39738: 0c00e34c */ jal n_alCSeqNew /* 3973c: 8dc50000 */ lw $a1,0x0($t6) /* 39740: 8faf0220 */ lw $t7,0x220($sp) /* 39744: afa00108 */ sw $zero,0x108($sp) @@ -305,7 +303,7 @@ glabel func00039718 /* 39828: afae010c */ sw $t6,0x10c($sp) /* 3982c: 27a40110 */ addiu $a0,$sp,0x110 /* 39830: 27a50208 */ addiu $a1,$sp,0x208 -/* 39834: 0c00e3ac */ jal alCSeqNextEvent +/* 39834: 0c00e3ac */ jal n_alCSeqNextEvent /* 39838: 00003025 */ or $a2,$zero,$zero /* 3983c: 87b90208 */ lh $t9,0x208($sp) /* 39840: 24010013 */ addiu $at,$zero,0x13 diff --git a/src/lib/lib_3e8c0.c b/src/lib/naudio/n_env.c similarity index 97% rename from src/lib/lib_3e8c0.c rename to src/lib/naudio/n_env.c index d0e902ad8..1b4ff3f28 100644 --- a/src/lib/lib_3e8c0.c +++ b/src/lib/naudio/n_env.c @@ -1,19 +1,7 @@ -#include -#include "PR/synthInternals.h" -#include "constants.h" -#include "bss.h" -#include "lib/mtx.h" -#include "lib/lib_30ce0.h" -#include "lib/lib_3e8c0.h" -#include "lib/lib_43dd0.h" -#include "lib/lib_44f60.h" -#include "lib/lib_45ed0.h" -#include "lib/lib_461c0.h" -#include "lib/lib_46650.h" -#include "lib/lib_47550.h" -#include "lib/libc/ll.h" -#include "data.h" -#include "types.h" +#include "n_synthInternals.h" +#include +#include +#include GLOBAL_ASM( glabel func0003e8c0 @@ -545,7 +533,7 @@ glabel var70054b30 /* 3f008: 8d0c000c */ lw $t4,0xc($t0) /* 3f00c: ad800088 */ sw $zero,0x88($t4) /* 3f010: 8fb80020 */ lw $t8,0x20($sp) -/* 3f014: 0c00c57d */ jal _freePVoice +/* 3f014: 0c00c57d */ jal _n_freePVoice /* 3f018: 8f04000c */ lw $a0,0xc($t8) /* 3f01c: 1000003c */ b .L0003f110 /* 3f020: 00000000 */ nop @@ -633,7 +621,7 @@ glabel var70054b30 /* 3f160: 8fab0050 */ lw $t3,0x50($sp) /* 3f164: ad600080 */ sw $zero,0x80($t3) .L0003f168: -/* 3f168: 0c00c559 */ jal __freeParam +/* 3f168: 0c00c559 */ jal _n_freeParam /* 3f16c: 8fa40034 */ lw $a0,0x34($sp) /* 3f170: 8fa80050 */ lw $t0,0x50($sp) /* 3f174: 8d0c007c */ lw $t4,0x7c($t0) @@ -669,36 +657,33 @@ glabel var70054b30 /* 3f1e0: 00000000 */ nop ); -s32 n_alEnvmixerParam(void *filter, s32 paramID, void *param) +s32 n_alEnvmixerParam(N_PVoice *filter, s32 paramID, void *param) { - ALEnvMixer *e = (ALEnvMixer *) filter; + N_PVoice *e = filter; switch (paramID) { case AL_FILTER_ADD_UPDATE: - if (e->ctrlTail) { - e->ctrlTail->next = (ALParam *)param; + if (e->em_ctrlTail) { + e->em_ctrlTail->next = (ALParam *)param; } else { - e->ctrlList = (ALParam *)param; + e->em_ctrlList = (ALParam *)param; } - e->ctrlTail = (ALParam *)param; + e->em_ctrlTail = (ALParam *)param; break; case AL_FILTER_RESET: - e->first = 1; - e->motion = AL_STOPPED; - e->volume = 1; - - // @dangerous: Unsure which properties these refer to - // as the ALEnvMixer struct was modified - *(s32 *)((u32)e + 0x74) = 0; - *(f32 *)((u32)e + 0x4c) = 0; - *(s32 *)((u32)e + 0x50) = 1; - *(s32 *)((u32)e + 0x48) = 0; + e->em_first = 1; + e->em_motion = AL_STOPPED; + e->em_volume = 1; + e->em_segEnd = 0; + e->rs_delta = 0; + e->rs_first = 1; + e->rs_upitch = 0; n_alLoadParam(e, AL_FILTER_RESET, param); break; case AL_FILTER_START: - e->motion = AL_PLAYING; + e->em_motion = AL_PLAYING; break; default: n_alLoadParam(e, paramID, param); diff --git a/src/lib/ultra/audio/event.c b/src/lib/naudio/n_event.c similarity index 74% rename from src/lib/ultra/audio/event.c rename to src/lib/naudio/n_event.c index 0da6fe4c8..6238c1d32 100644 --- a/src/lib/ultra/audio/event.c +++ b/src/lib/naudio/n_event.c @@ -1,13 +1,9 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/lib_30ce0.h" -#include "lib/lib_3c4d0.h" -#include "lib/lib_3e730.h" -#include "data.h" -#include "types.h" +#include +#include "n_libaudio.h" +#include +#include -void n_alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount) +void n_alEvtqNew(ALEventQueue *evtq, N_ALEventListItem *items, s32 itemCount) { s32 i; @@ -22,15 +18,15 @@ void n_alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount) } } -ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt) +ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, N_ALEvent *evt) { - ALEventListItem *item; + N_ALEventListItem *item; ALMicroTime delta; OSIntMask mask; mask = osSetIntMask(OS_IM_NONE); - item = (ALEventListItem *)evtq->allocList.next; + item = (N_ALEventListItem *)evtq->allocList.next; if (item) { alUnlink((ALLink *)item); @@ -52,17 +48,17 @@ ALMicroTime n_alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt) return delta; } -void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta, s32 arg3) +void n_alEvtqPostEvent(ALEventQueue *evtq, N_ALEvent *evt, ALMicroTime delta, s32 arg3) { - ALEventListItem *item; - ALEventListItem *nextItem; + N_ALEventListItem *item; + N_ALEventListItem *nextItem; ALLink *node; s32 postAtEnd = 0; OSIntMask mask; mask = osSetIntMask(OS_IM_NONE); - item = (ALEventListItem *)evtq->freeList.next; + item = (N_ALEventListItem *)evtq->freeList.next; if (!item) { osSetIntMask(mask); @@ -92,7 +88,7 @@ void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta, s32 ar alLink((ALLink *)item, node); break; } else { - nextItem = (ALEventListItem *)node->next; + nextItem = (N_ALEventListItem *)node->next; if (delta < nextItem->delta) { item->delta = delta; @@ -113,7 +109,7 @@ void n_alEvtqFlushType(ALEventQueue *evtq, s16 type) { ALLink *thisNode; ALLink *nextNode; - ALEventListItem *thisItem, *nextItem; + N_ALEventListItem *thisItem, *nextItem; OSIntMask mask; mask = osSetIntMask(OS_IM_NONE); @@ -122,8 +118,8 @@ void n_alEvtqFlushType(ALEventQueue *evtq, s16 type) while (thisNode != 0) { nextNode = thisNode->next; - thisItem = (ALEventListItem *)thisNode; - nextItem = (ALEventListItem *)nextNode; + thisItem = (N_ALEventListItem *)thisNode; + nextItem = (N_ALEventListItem *)nextNode; if (thisItem->evt.type == type) { if (nextItem) { diff --git a/src/lib/naudio/n_seqp.h b/src/lib/naudio/n_seqp.h new file mode 100644 index 000000000..5d476c9d1 --- /dev/null +++ b/src/lib/naudio/n_seqp.h @@ -0,0 +1,53 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_SEQP__ +#define __N_SEQP__ + +#define KILL_TIME 50000 /* 50 ms */ + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + + +void __n_unmapVoice(N_ALSeqPlayer *seqp, N_ALVoice *voice); +char __n_voiceNeedsNoteKill(N_ALSeqPlayer *seqp, N_ALVoice *voice, ALMicroTime killTime); +void __n_seqpReleaseVoice(N_ALSeqPlayer *seqp, N_ALVoice *voice, ALMicroTime deltaTime); + + +N_ALVoiceState *__n_mapVoice(N_ALSeqPlayer *, u8, u8, u8); +N_ALVoiceState *__n_lookupVoice(N_ALSeqPlayer *, u8, u8); +ALSound *__n_lookupSound(N_ALSeqPlayer *, u8, u8, u8); +ALSound *__n_lookupSoundQuick(N_ALSeqPlayer *, u8, u8, u8); +s16 __n_vsVol(N_ALVoiceState *voice, N_ALSeqPlayer *seqp); +ALMicroTime __n_vsDelta(N_ALVoiceState *voice, ALMicroTime t); +ALPan __n_vsPan(N_ALVoiceState *voice, N_ALSeqPlayer *seqp); +void __n_initFromBank(N_ALSeqPlayer *seqp, ALBank *b); +void __n_initChanState(N_ALSeqPlayer *seqp); +void __n_resetPerfChanState(N_ALSeqPlayer *seqp, s32 chan); +void __n_setInstChanState(N_ALSeqPlayer *seqp, ALInstrument *inst, s32 chan); +void __n_seqpStopOsc(N_ALSeqPlayer *seqp, N_ALVoiceState *vs); +void __n_postNextSeqEvent(N_ALSeqPlayer *seqp); + +#endif /* __N_SEQP__ */ diff --git a/src/lib/lib_3d280.c b/src/lib/naudio/n_seqplayer.c similarity index 95% rename from src/lib/lib_3d280.c rename to src/lib/naudio/n_seqplayer.c index ec14f11de..7ed3fb843 100644 --- a/src/lib/lib_3d280.c +++ b/src/lib/naudio/n_seqplayer.c @@ -1,14 +1,9 @@ -#include -#include "PR/seqp.h" -#include "constants.h" -#include "bss.h" -#include "lib/lib_30ce0.h" -#include "lib/lib_3c4d0.h" -#include "lib/lib_3ccf0.h" -#include "lib/lib_3d280.h" -#include "lib/lib_44bc0.h" -#include "data.h" -#include "types.h" +#include +#include +#include +#include "n_libaudio.h" +#include "n_seqp.h" +#include "seq.h" GLOBAL_ASM( glabel func0003d280 @@ -69,10 +64,10 @@ glabel func0003d280 /* 3d33c: 27bd0008 */ addiu $sp,$sp,0x8 ); -void __seqpReleaseVoice(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime deltaTime) +void __seqpReleaseVoice(N_ALSeqPlayer *seqp, N_ALVoice *voice, ALMicroTime deltaTime) { - ALEvent evt; - ALVoiceState *vs = (ALVoiceState *)voice->clientPrivate; + N_ALEvent evt; + N_ALVoiceState *vs = (N_ALVoiceState *)voice->clientPrivate; /* * if in attack phase, remove all pending volume @@ -82,14 +77,14 @@ void __seqpReleaseVoice(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime deltaTime if (vs->envPhase == AL_PHASE_ATTACK) { ALLink *thisNode; ALLink *nextNode; - ALEventListItem *thisItem, *nextItem; + N_ALEventListItem *thisItem, *nextItem; thisNode = seqp->evtq.allocList.next; while (thisNode != 0) { nextNode = thisNode->next; - thisItem = (ALEventListItem *)thisNode; - nextItem = (ALEventListItem *)nextNode; + thisItem = (N_ALEventListItem *)thisNode; + nextItem = (N_ALEventListItem *)nextNode; if (thisItem->evt.type == AL_SEQP_ENV_EVT) { if (thisItem->evt.msg.vol.voice == voice) { @@ -112,21 +107,21 @@ void __seqpReleaseVoice(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime deltaTime vs->envEndTime = seqp->curTime + deltaTime; n_alSynSetPriority(voice, 0); /* make candidate for stealing */ - alSynSetVol(voice, 0, deltaTime); + n_alSynSetVol(voice, 0, deltaTime); evt.type = AL_NOTE_END_EVT; evt.msg.note.voice = voice; deltaTime += (PAL ? 40000 : 32000); - alEvtqPostEvent(&seqp->evtq, &evt, deltaTime, 0); + n_alEvtqPostEvent(&seqp->evtq, &evt, deltaTime, 0); } -char __n_voiceNeedsNoteKill(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime killTime) +char __n_voiceNeedsNoteKill(N_ALSeqPlayer *seqp, N_ALVoice *voice, ALMicroTime killTime) { ALLink *thisNode; ALLink *nextNode; - ALEventListItem *thisItem; + N_ALEventListItem *thisItem; ALMicroTime itemTime = 0; char needsNoteKill = TRUE; @@ -134,14 +129,14 @@ char __n_voiceNeedsNoteKill(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime killT while (thisNode != 0) { nextNode = thisNode->next; - thisItem = (ALEventListItem *)thisNode; + thisItem = (N_ALEventListItem *)thisNode; itemTime += thisItem->delta; if (thisItem->evt.type == AL_NOTE_END_EVT) { if (thisItem->evt.msg.note.voice == voice) { if (itemTime > killTime) { - if ((ALEventListItem *)nextNode) { - ((ALEventListItem *)nextNode)->delta += thisItem->delta; + if ((N_ALEventListItem *)nextNode) { + ((N_ALEventListItem *)nextNode)->delta += thisItem->delta; } alUnlink(thisNode); @@ -524,7 +519,7 @@ glabel func0003d9cc /* 3dacc: 27bd0018 */ addiu $sp,$sp,0x18 ); -ALMicroTime __n_vsDelta(ALVoiceState *vs, ALMicroTime t) +ALMicroTime __n_vsDelta(N_ALVoiceState *vs, ALMicroTime t) { /* * If we are interrupting a previously set envelope segment, we @@ -542,7 +537,7 @@ ALMicroTime __n_vsDelta(ALVoiceState *vs, ALMicroTime t) } } -ALPan __vsPan(ALVoiceState *vs, ALSeqPlayer *seqp) +ALPan __vsPan(N_ALVoiceState *vs, N_ALSeqPlayer *seqp) { s32 tmp; @@ -553,7 +548,7 @@ ALPan __vsPan(ALVoiceState *vs, ALSeqPlayer *seqp) return (ALPan) tmp; } -void __n_initFromBank(ALSeqPlayer *seqp, ALBank *b) +void __n_initFromBank(N_ALSeqPlayer *seqp, ALBank *b) { /* * init the chanState with the default instrument @@ -580,7 +575,7 @@ void __n_initFromBank(ALSeqPlayer *seqp, ALBank *b) } } -void __initChanState(ALSeqPlayer *seqp) +void __n_initChanState(N_ALSeqPlayer *seqp) { int i; @@ -590,7 +585,7 @@ void __initChanState(ALSeqPlayer *seqp) } } -void __n_resetPerfChanState(ALSeqPlayer *seqp, s32 chan) +void __n_resetPerfChanState(N_ALSeqPlayer *seqp, s32 chan) { seqp->chanState[chan].fxId = AL_FX_NONE; seqp->chanState[chan].fxmix = AL_DEFAULT_FXMIX; @@ -824,15 +819,15 @@ glabel __n_setInstChanState /* 3e29c: 27bd0008 */ addiu $sp,$sp,0x8 ); -void __n_seqpStopOsc(ALSeqPlayer *seqp, ALVoiceState *vs) +void __n_seqpStopOsc(N_ALSeqPlayer *seqp, N_ALVoiceState *vs) { - ALEventListItem *thisNode,*nextNode; + N_ALEventListItem *thisNode,*nextNode; s16 evtType; - thisNode = (ALEventListItem*)seqp->evtq.allocList.next; + thisNode = (N_ALEventListItem*)seqp->evtq.allocList.next; while (thisNode) { - nextNode = (ALEventListItem*)thisNode->node.next; + nextNode = (N_ALEventListItem*)thisNode->node.next; evtType = thisNode->evt.type; if (evtType == AL_TREM_OSC_EVT || evtType == AL_VIB_OSC_EVT) { diff --git a/src/lib/naudio/n_sndp.h b/src/lib/naudio/n_sndp.h new file mode 100644 index 000000000..51220d3b5 --- /dev/null +++ b/src/lib/naudio/n_sndp.h @@ -0,0 +1,99 @@ +/*==================================================================== + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_SNDP__ +#define __N_SNDP__ + +#include +#include "n_libaudio.h" + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define MIN_RATIO 0.0001 + +typedef enum { + AL_SNDP_PLAY_EVT, + AL_SNDP_STOP_EVT, + AL_SNDP_PAN_EVT, + AL_SNDP_VOL_EVT, + AL_SNDP_PITCH_EVT, + AL_SNDP_API_EVT, + AL_SNDP_DECAY_EVT, + AL_SNDP_END_EVT, + AL_SNDP_FX_EVT +} ALSndpMsgType; + +typedef struct { + N_ALVoice voice; + ALSound *sound; /* sound referenced here */ + s16 priority; + f32 pitch; /* current playback pitch */ + s32 state; /* play state for this sound */ + s16 vol; /* volume - combined with volume from bank */ + ALPan pan; /* pan - 0 = left, 127 = right */ + u8 fxMix; /* wet/dry mix - 0 = dry, 127 = wet */ +} N_ALSoundState; + +typedef union { + + N_ALEvent msg; + + struct { + s16 type; + N_ALSoundState *state; + } common; + + struct { + s16 type; + N_ALSoundState *state; + s16 vol; + } vol; + + struct { + s16 type; + N_ALSoundState *state; + f32 pitch; + } pitch; + + struct { + s16 type; + N_ALSoundState *state; + ALPan pan; + } pan; + + struct { + s16 type; + N_ALSoundState *state; + u8 mix; + } fx; + +} N_ALSndpEvent; + +static ALMicroTime _n_sndpVoiceHandler(void *node); +static void _n_handleEvent(N_ALSndpEvent *event); +static void _removeEvents(ALEventQueue *evtq, N_ALSoundState *state); +static s32 _DivS32ByF32 (s32 i, f32 f); + +#endif /* __N_SNDP__ */ diff --git a/src/lib/naudio/n_syndelete.c b/src/lib/naudio/n_syndelete.c new file mode 100644 index 000000000..cada0ce33 --- /dev/null +++ b/src/lib/naudio/n_syndelete.c @@ -0,0 +1,6 @@ +#include "n_synthInternals.h" + +void n_alSynDelete(void) +{ + n_syn->head = NULL; +} diff --git a/src/lib/naudio/n_synsetpriority.c b/src/lib/naudio/n_synsetpriority.c new file mode 100644 index 000000000..980f7c74d --- /dev/null +++ b/src/lib/naudio/n_synsetpriority.c @@ -0,0 +1,6 @@ +#include "n_synthInternals.h" + +void n_alSynSetPriority(N_ALVoice *voice, s16 priority) +{ + voice->priority = priority; +} diff --git a/src/lib/naudio/n_synthInternals.h b/src/lib/naudio/n_synthInternals.h new file mode 100644 index 000000000..05e491702 --- /dev/null +++ b/src/lib/naudio/n_synthInternals.h @@ -0,0 +1,164 @@ +/*==================================================================== + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __N_SYNTHINTERNALS__ +#define __N_SYNTHINTERNALS__ + +#include +#include +#include "n_abi.h" + +#define SAMPLE_ROUND +#undef SAMPLE_ROUND + +#define FINAL_ROUND + +#define SAMPLES 184 +#define SAMPLE184(delta) (((delta) + (SAMPLES / 2)) / SAMPLES) * SAMPLES +#define FIXED_SAMPLE SAMPLES + +#define N_AL_DECODER_IN 0 +#define N_AL_RESAMPLER_OUT 0 +#define N_AL_TEMP_0 0 +#define N_AL_DECODER_OUT 368 +#define N_AL_TEMP_1 368 +#define N_AL_TEMP_2 736 +#define N_AL_MAIN_L_OUT 1248 +#define N_AL_MAIN_R_OUT 1616 +#define N_AL_AUX_L_OUT 1984 +#define N_AL_AUX_R_OUT 2352 + +#define N_AL_DIVIDED 368 + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + struct N_PVoice_s *pvoice; +} N_ALFreeParam; + +typedef struct N_PVoice_s { + ALLink node; + struct N_ALVoice_s *vvoice; + /** ALLoadFilter *********************************/ + ADPCM_STATE *dc_state; + ADPCM_STATE *dc_lstate; + ALRawLoop dc_loop; + struct ALWaveTable_s *dc_table; + s32 dc_bookSize; + ALDMAproc dc_dma; + void *dc_dmaState; + s32 dc_sample; + s32 dc_lastsam; + s32 dc_first; + s32 dc_memin; + /** ALResampler *********************************/ + RESAMPLE_STATE *rs_state; + f32 rs_ratio; + s32 rs_upitch; + f32 rs_delta; + s32 rs_first; + /** ALEnvMixer *********************************/ + ENVMIX_STATE *em_state; + s16 em_pan; + s16 em_volume; + s16 em_cvolL; + s16 em_cvolR; + s16 em_dryamt; + s16 em_wetamt; + u16 em_lratl; + s16 em_lratm; + s16 em_ltgt; + u16 em_rratl; + s16 em_rratm; + s16 em_rtgt; + s32 em_delta; + s32 em_segEnd; + s32 em_first; + ALParam *em_ctrlList; + ALParam *em_ctrlTail; + s32 em_motion; + s32 offset; +} N_PVoice; + + +typedef Acmd *(*N_ALCmdHandler)(s32, Acmd *); + +typedef struct N_ALFilter_s { + struct N_ALFilter_s *source; + N_ALCmdHandler handler; + ALSetParam setParam; + s16 inp; + s16 outp; + s32 type; +} N_ALFilter; + +typedef struct N_ALMainBus_s { + N_ALFilter filter; +} N_ALMainBus; + + + +typedef struct N_ALAuxBus_s { + ALFilter filter; + s32 sourceCount; + s32 maxSources; + N_PVoice **sources; + ALFx *fx; + ALFx *fx_array[AL_MAX_AUX_BUS_SOURCES]; +} N_ALAuxBus; + +void alN_PVoiceNew(N_PVoice *mv, ALDMANew dmaNew, ALHeap *hp); + +ALParam *__n_allocParam(void); +void _n_freeParam(ALParam *param); +void _n_freePVoice(N_PVoice *pvoice); +void _n_collectPVoices(void); +s32 _n_timeToSamples(s32 micros); +ALMicroTime _n_samplesToTime(s32 samples); + + +Acmd *n_alAdpcmPull(N_PVoice *f,s16 *outp, s32 byteCount, Acmd *p); +s32 n_alLoadParam(N_PVoice *filter, s32 paramID, void *param); + +Acmd *n_alResamplePull(N_PVoice *f, s16 *outp,Acmd *p); +s32 n_alResampleParam(N_PVoice *f, s32 paramID, void *param); + +Acmd *n_alEnvmixerPull(N_PVoice *f, s32 sampleOffset, Acmd *p); +s32 n_alEnvmixerParam(N_PVoice *p, s32 paramID, void *param); + +s32 n_alAuxBusParam( s32 paramID, void *param); +Acmd *n_alAuxBusPull( s32 sampleOffset, Acmd *p); + +Acmd *n_alFxPull( s32 sampleOffset, Acmd *p); +s32 n_alFxParamHdl(void *filter, s32 paramID, void *param); +void n_alFxNew(ALFx **r, ALSynConfig *c, ALHeap *hp); + +Acmd *n_alMainBusPull( s32 sampleOffset, Acmd *p); +s32 n_alMainBusParam( s32 paramID, void *param); + +Acmd *n_alSavePull(s32 sampleOffset, Acmd *p); +s32 n_alSaveParam( s32 paramID, void *param); + +void n_alSaveNew(void); + +void n_alSynNew(ALSynConfig *c); +void n_alSynDelete(void); + +#endif /* __N_SYNTHINTERNALS__ */ diff --git a/src/lib/lib_30ce0.c b/src/lib/naudio/n_synthesizer.c similarity index 90% rename from src/lib/lib_30ce0.c rename to src/lib/naudio/n_synthesizer.c index 564b97bfe..92cd57912 100644 --- a/src/lib/lib_30ce0.c +++ b/src/lib/naudio/n_synthesizer.c @@ -1,13 +1,4 @@ -#include -#include "PR/synthInternals.h" -#include "constants.h" -#include "bss.h" -#include "lib/lib_30ce0.h" -#include "lib/lib_39fe0.h" -#include "lib/lib_3a100.h" -#include "lib/lib_3c430.h" -#include "data.h" -#include "types.h" +#include "n_synthInternals.h" GLOBAL_ASM( glabel n_alSynNew @@ -412,10 +403,10 @@ glabel n_alSynNew /* 312e0: 00000000 */ nop ); -s32 __nextSampleTime(ALPlayer **client); -s32 _timeToSamplesNoRound(s32 micros); +s32 __n_nextSampleTime(ALPlayer **client); +s32 _n_timeToSamplesNoRound(s32 micros); -Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen) +Acmd *n_alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen) { ALPlayer *client; Acmd *cmdlEnd = cmdList; @@ -423,7 +414,7 @@ Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen) s32 nOut; s16 *lOutBuf = outBuf; - if (n_syn->drvr.head == 0) { + if (n_syn->head == 0) { *cmdLen = 0; return cmdList; /* nothing to do */ } @@ -445,11 +436,11 @@ Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen) * during the client handler. */ - for (n_syn->drvr.paramSamples = __nextSampleTime(&client); - n_syn->drvr.paramSamples - n_syn->drvr.curSamples < outLen; - n_syn->drvr.paramSamples = __nextSampleTime(&client)) { - n_syn->drvr.paramSamples &= ~0xf; - client->samplesLeft += _timeToSamplesNoRound((*client->handler)(client)); + for (n_syn->paramSamples = __n_nextSampleTime(&client); + n_syn->paramSamples - n_syn->curSamples < outLen; + n_syn->paramSamples = __n_nextSampleTime(&client)) { + n_syn->paramSamples &= ~0xf; + client->samplesLeft += _n_timeToSamplesNoRound((*client->handler)(client)); } /* for safety's sake, always store paramSamples aligned to 16 sample boundary. @@ -457,83 +448,83 @@ Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen) * routine (alSynAllocVoice) it will get timestamped with an aligned value and * will be processed immediately next audio frame. */ - n_syn->drvr.paramSamples &= ~0xf; + n_syn->paramSamples &= ~0xf; /* * Now build the command list in small chunks */ while (outLen > 0) { - nOut = MIN(n_syn->drvr.outputRate, outLen); + nOut = MIN(n_syn->outputRate, outLen); cmdPtr = cmdlEnd; - n_syn->drvr.maxOutSamples = (s32)lOutBuf; + n_syn->maxOutSamples = (s32)lOutBuf; - cmdlEnd = func0003c430(n_syn->drvr.curSamples, cmdPtr); + cmdlEnd = n_alSavePull(n_syn->curSamples, cmdPtr); outLen -= nOut; lOutBuf += nOut << 1; /* For Stereo */ - n_syn->drvr.curSamples += nOut; + n_syn->curSamples += nOut; } *cmdLen = (s32) (cmdlEnd - cmdList); - _collectPVoices(); /* collect free physical voices */ + _n_collectPVoices(); /* collect free physical voices */ return cmdlEnd; } -ALParam *__allocParam() +ALParam *__n_allocParam() { ALParam *update = NULL; - if (n_syn->drvr.paramList) { - update = n_syn->drvr.paramList; - n_syn->drvr.paramList = n_syn->drvr.paramList->next; + if (n_syn->paramList) { + update = n_syn->paramList; + n_syn->paramList = n_syn->paramList->next; update->next = 0; } return update; } -void __freeParam(ALParam *param) +void _n_freeParam(ALParam *param) { - param->next = n_syn->drvr.paramList; - n_syn->drvr.paramList = param; + param->next = n_syn->paramList; + n_syn->paramList = param; } -void _collectPVoices(void) +void _n_collectPVoices(void) { ALLink *dl; - while ((dl = n_syn->drvr.pLameList.next) != 0) { + while ((dl = n_syn->pLameList.next) != 0) { alUnlink(dl); - alLink(dl, &n_syn->drvr.pFreeList); + alLink(dl, &n_syn->pFreeList); } } -void _freePVoice(PVoice *pvoice) +void _n_freePVoice(N_PVoice *pvoice) { /* * move the voice from the allocated list to the lame list */ alUnlink((ALLink *)pvoice); - alLink((ALLink *)pvoice, &n_syn->drvr.pLameList); + alLink((ALLink *)pvoice, &n_syn->pLameList); } -s32 _timeToSamplesNoRound(s32 micros) +s32 _n_timeToSamplesNoRound(s32 micros) { // Should be outputRate but struct is not sized correctly - f32 tmp = ((f32)micros) * n_syn->drvr.maxAuxBusses / 1000000.0f + 0.5f; + f32 tmp = ((f32)micros) * n_syn->maxAuxBusses / 1000000.0f + 0.5f; return (s32)tmp; } GLOBAL_ASM( -glabel _timeToSamples +glabel _n_timeToSamples /* 31698: 27bdffe8 */ addiu $sp,$sp,-24 /* 3169c: afbf0014 */ sw $ra,0x14($sp) /* 316a0: afa40018 */ sw $a0,0x18($sp) -/* 316a4: 0c00c58d */ jal _timeToSamplesNoRound +/* 316a4: 0c00c58d */ jal _n_timeToSamplesNoRound /* 316a8: 8fa40018 */ lw $a0,0x18($sp) /* 316ac: 2401fff0 */ addiu $at,$zero,-16 /* 316b0: 10000003 */ b .L000316c0 @@ -547,42 +538,19 @@ glabel _timeToSamples /* 316cc: 00000000 */ nop ); -s32 __nextSampleTime(ALPlayer **client) +s32 __n_nextSampleTime(ALPlayer **client) { ALMicroTime delta = 0x7fffffff; /* max delta for s32 */ ALPlayer *cl; *client = 0; - for (cl = n_syn->drvr.head; cl != 0; cl = cl->next) { - if ((cl->samplesLeft - n_syn->drvr.curSamples) < delta) { + for (cl = n_syn->head; cl != 0; cl = cl->next) { + if ((cl->samplesLeft - n_syn->curSamples) < delta) { *client = cl; - delta = cl->samplesLeft - n_syn->drvr.curSamples; + delta = cl->samplesLeft - n_syn->curSamples; } } return (*client)->samplesLeft; } - -void alLink(ALLink *ln, ALLink *to) -{ - ln->next = to->next; - ln->prev = to; - - if (to->next) { - to->next->prev = ln; - } - - to->next = ln; -} - -void alUnlink(ALLink *ln) -{ - if (ln->next) { - ln->next->prev = ln->prev; - } - - if (ln->prev) { - ln->prev->next = ln->next; - } -} diff --git a/src/lib/rdp.c b/src/lib/rdp.c index e5310aefc..c97472f64 100644 --- a/src/lib/rdp.c +++ b/src/lib/rdp.c @@ -60,8 +60,6 @@ struct rdptask g_RdpTaskB = { struct rdptask *g_RdpCurTask = &g_RdpTaskA; -extern u8 rspbootTextStart; -extern u8 rspbootTextEnd; extern u8 gspTextStart; extern u8 gspDataStart; @@ -85,8 +83,8 @@ void rdpCreateTask(Gfx *gdlstart, Gfx *gdlend, u32 arg2, void *msg) sctask = &g_RdpCurTask->sctask; task = &sctask->list; - task->t.ucode_boot = (u64 *) &rspbootTextStart; - task->t.ucode_boot_size = (u32) (&rspbootTextEnd - &rspbootTextStart); + task->t.ucode_boot = (u64 *) rspbootTextStart; + task->t.ucode_boot_size = (u32) ((u32)rspbootTextEnd - (u32)rspbootTextStart); if (rspbootTextStart); @@ -106,7 +104,7 @@ void rdpCreateTask(Gfx *gdlstart, Gfx *gdlend, u32 arg2, void *msg) sctask->framebuffer = g_RdpCurTask->framebuffer; osWritebackDCacheAll(); - __scHandleRetraceViaPri(&g_SchedThread, sctask); + __scHandleRetraceViaPri(&g_Sched, sctask); // Swap g_RdpCurTask g_RdpCurTask = (struct rdptask *)((u32)g_RdpCurTask ^ (u32) &g_RdpTaskA ^ (u32) &g_RdpTaskB); diff --git a/src/lib/reset.c b/src/lib/reset.c index 0082e8dc7..ed88abfe3 100644 --- a/src/lib/reset.c +++ b/src/lib/reset.c @@ -5,16 +5,7 @@ #include "data.h" #include "types.h" -OSMesg g_ResetMesg; -u32 var8008fa84; -u32 var8008fa88; -u32 var8008fa8c; -u32 var8008fa90; -u32 var8008fa94; -u32 var8008fa98; -u32 var8008fa9c; -u32 var8008faa0; -u32 var8008faa4; +OSMesg g_ResetMesgs[10]; OSMesgQueue g_ResetMesgQueue; OSThread g_ResetThread; u8 g_ResetStack[STACKSIZE_RESET]; @@ -50,7 +41,7 @@ void resetproc(void *data) #if PAL mode = &osViModeTable[OS_VI_PAL_LAN1]; #else - if (osTvType == OS_TV_TYPE_MPAL) { + if (osTvType == OS_TV_MPAL) { mode = &osViModeTable[OS_VI_MPAL_LAN1]; } else { mode = &osViModeTable[OS_VI_NTSC_LAN1]; @@ -81,7 +72,7 @@ void resetproc(void *data) void resetThreadCreate(void) { - osCreateMesgQueue(&g_ResetMesgQueue, &g_ResetMesg, 10); + osCreateMesgQueue(&g_ResetMesgQueue, g_ResetMesgs, ARRAYCOUNT(g_ResetMesgs)); osSetEventMesg(OS_EVENT_PRENMI, &g_ResetMesgQueue, (OSMesg) 669); osCreateThread(&g_ResetThread, THREAD_RESET, resetproc, 0, &g_ResetStack[STACKSIZE_RESET], THREADPRI_RESET); osStartThread(&g_ResetThread); diff --git a/src/lib/rmon.c b/src/lib/rmon.c index a83cb1a2e..f34fd28b6 100644 --- a/src/lib/rmon.c +++ b/src/lib/rmon.c @@ -1,4 +1,5 @@ #include +#include #include "constants.h" #include "bss.h" #include "lib/crash.h" diff --git a/src/lib/sched.c b/src/lib/sched.c index a85b63095..38f0fcf73 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -18,6 +18,46 @@ #include "data.h" #include "types.h" +/* + * private typedefs and defines + */ +#define VIDEO_MSG 666 +#define RSP_DONE_MSG 667 +#define RDP_DONE_MSG 668 +#define PRE_NMI_MSG 669 + +/* + * OSScTask state + */ +#define OS_SC_DP 0x0001 /* set if still needs dp */ +#define OS_SC_SP 0x0002 /* set if still needs sp */ +#define OS_SC_YIELD 0x0010 /* set if yield requested */ +#define OS_SC_YIELDED 0x0020 /* set if yield completed */ + +/* + * OSScTask->flags type identifier + */ +#define OS_SC_XBUS (OS_SC_SP | OS_SC_DP) +#define OS_SC_DRAM (OS_SC_SP | OS_SC_DP | OS_SC_DRAM_DLIST) +#define OS_SC_DP_XBUS (OS_SC_SP) +#define OS_SC_DP_DRAM (OS_SC_SP | OS_SC_DRAM_DLIST) +#define OS_SC_SP_XBUS (OS_SC_DP) +#define OS_SC_SP_DRAM (OS_SC_DP | OS_SC_DRAM_DLIST) + +/* + * private functions + */ +void __scMain(void *arg); +void __scHandleRetrace(OSSched *s); +void __scHandleRSP(OSSched *s); +void __scHandleRDP(OSSched *s); +void __scAppendList(OSSched *s, OSScTask *t); +OSScTask *__scTaskReady(OSScTask *t); +s32 __scTaskComplete(OSSched *s,OSScTask *t); +void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); +void __scYield(OSSched *s); +s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP); + OSViMode var8008dcc0[2]; OSViMode *var8008dd60[2]; OSViMode var8008dd68[2]; @@ -100,12 +140,12 @@ void func00001b98(u32 value) } } -void osCreateLog(void) +void osCreateLog2(void) { var8005ce70 = osGetCount(); } -void osCreateScheduler(OSSched *sc, void *stack, u8 mode, u32 numFields) +void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) { sc->curRSPTask = 0; sc->curRDPTask = 0; @@ -116,8 +156,8 @@ void osCreateScheduler(OSSched *sc, void *stack, u8 mode, u32 numFields) sc->audioListTail = 0; sc->gfxListTail = 0; sc->retraceMsg.type = OS_SC_RETRACE_MSG; - sc->prenmiMsg.type = 5; // OS_SC_PRE_NMI_MSG - sc->thread = stack; + sc->prenmiMsg.type = 5; //OS_SC_PRE_NMI_MSG; + sc->thread = thread; resetThreadCreate(); @@ -140,19 +180,19 @@ void osCreateScheduler(OSSched *sc, void *stack, u8 mode, u32 numFields) osSetEventMesg(OS_EVENT_DP, &sc->interruptQ, (OSMesg)RDP_DONE_MSG); osViSetEvent(&sc->interruptQ, (OSMesg)VIDEO_MSG, numFields); - osCreateLog(); + osCreateLog2(); osCreateThread(sc->thread, THREAD_SCHED, &__scMain, sc, bootAllocateStack(THREAD_SCHED, STACKSIZE_SCHED), THREADPRI_SCHED); osStartThread(sc->thread); } -void osScAddClient(OSSched *sc, OSScClient *c, OSMesgQueue *msgQ, OSScClient *next) +void osScAddClient(OSSched *sc, OSScClient *c, OSMesgQueue *msgQ, int is8mb) { OSIntMask mask; mask = osSetIntMask(1); c->msgQ = msgQ; - c[1].next = next; + c->is8mb = is8mb; c->next = sc->clientList; sc->clientList = c; diff --git a/src/lib/snd.c b/src/lib/snd.c index 9cddda5f3..e9f9d5387 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -1,4 +1,5 @@ #include +#include "n_libaudio.h" #include "constants.h" #include "game/file.h" #include "game/lv.h" @@ -2014,9 +2015,9 @@ void snd0000f67c(struct var80094ed8 *arg0) } arg0->unk0fc = alHeapAlloc(&g_SndHeap, 1, var8009520c); - arg0->seqp = alHeapAlloc(&g_SndHeap, 1, sizeof(ALCSPlayer)); + arg0->seqp = alHeapAlloc(&g_SndHeap, 1, sizeof(N_ALCSPlayer)); - alCSPNew(arg0->seqp, &config); + n_alCSPNew(arg0->seqp, &config); func00037650(arg0->seqp, var80095204); } @@ -2327,7 +2328,7 @@ glabel snd0000fc48 /* fd20: 0c001d3c */ jal rzipInflate /* fd24: 27a60034 */ addiu $a2,$sp,0x34 /* fd28: 02002025 */ or $a0,$s0,$zero -/* fd2c: 0c00e34c */ jal alCSeqNew +/* fd2c: 0c00e34c */ jal n_alCSeqNew /* fd30: 8e0500fc */ lw $a1,0xfc($s0) /* fd34: 8e0400f8 */ lw $a0,0xf8($s0) /* fd38: 0c00e6f8 */ jal func00039be0 @@ -2458,7 +2459,7 @@ glabel snd0000fc48 /* 10274: a00c0000 */ sb $t4,0x0($zero) .NB00010278: /* 10278: 02002025 */ or $a0,$s0,$zero -/* 1027c: 0c00e840 */ jal alCSeqNew +/* 1027c: 0c00e840 */ jal n_alCSeqNew /* 10280: 8e0500fc */ lw $a1,0xfc($s0) /* 10284: 8e0400f8 */ lw $a0,0xf8($s0) /* 10288: 0c00ebec */ jal func00039be0 diff --git a/src/lib/speaker.c b/src/lib/speaker.c index 79b8e9d93..2106cd37e 100644 --- a/src/lib/speaker.c +++ b/src/lib/speaker.c @@ -4,7 +4,6 @@ #include "lib/snd.h" #include "lib/speaker.h" #include "lib/lib_2fc60.h" -#include "lib/lib_30ce0.h" #include "lib/lib_317f0.h" #include "lib/lib_39c80.h" #include "lib/lib_39fe0.h" diff --git a/src/lib/ultra/audio/bnkf.c b/src/lib/ultra/audio/bnkf.c index 2c9b2dc53..30ec2d12e 100644 --- a/src/lib/ultra/audio/bnkf.c +++ b/src/lib/ultra/audio/bnkf.c @@ -1,10 +1,6 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/lib_37650.h" -#include "lib/lib_3c4d0.h" -#include "data.h" -#include "types.h" +#include +#include +#include void _bnkfPatchBank(ALBank *bank, s32 offset, s32 table); void _bnkfPatchInst(ALInstrument *inst, s32 offset, s32 table); diff --git a/src/lib/ultra/audio/cseq.h b/src/lib/ultra/audio/cseq.h new file mode 100644 index 000000000..0342398f5 --- /dev/null +++ b/src/lib/ultra/audio/cseq.h @@ -0,0 +1,11 @@ + + + +#ifndef __cseq__ +#define __cseq__ + + +char __alCSeqNextDelta(ALCSeq *seq, s32 *pDeltaTicks); + + +#endif /* __cseq__ */ diff --git a/src/lib/ultra/audio/cseqp.h b/src/lib/ultra/audio/cseqp.h new file mode 100644 index 000000000..bb72541dd --- /dev/null +++ b/src/lib/ultra/audio/cseqp.h @@ -0,0 +1,10 @@ + + +#ifndef __cseqp__ +#define __cseqp__ + + +void __CSPPostNextSeqEvent(ALCSPlayer *seqp); + + +#endif /* __cseqp__ */ diff --git a/src/lib/ultra/audio/heap.c b/src/lib/ultra/audio/heap.c index 31a070625..b59bcbc9c 100644 --- a/src/lib/ultra/audio/heap.c +++ b/src/lib/ultra/audio/heap.c @@ -1,8 +1,7 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include "synthInternals.h" +#include +#include +#include void alHeapInit(ALHeap *hp, u8 *base, s32 len) { diff --git a/src/lib/ultra/audio/initfx.h b/src/lib/ultra/audio/initfx.h new file mode 100644 index 000000000..704e1f4a0 --- /dev/null +++ b/src/lib/ultra/audio/initfx.h @@ -0,0 +1,59 @@ +/*==================================================================== + * initfx.h + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __initfx__ +#define __initfx__ + +#define MAX_L0 AL_FX_BUFFER_SIZE/4 +#define MAX_L1 AL_FX_BUFFER_SIZE/4 +#define MAX_L2 AL_FX_BUFFER_SIZE/2 + +#define L0_INC MAX_L0/128 +#define L1_INC MAX_L1/128 +#define L2_INC MAX_L2/128 + +#define SMALLROOM_SECT_CNT 3 +#define SMALLROOM_SIZE AL_FX_BUFFER_SIZE +#define SMALLROOM_L0 880 /* 22 ms */ +#define SMALLROOM_C0 9830 +#define SMALLROOM_L1 1400 /* 35 ms */ +#define SMALLROOM_C1 3276 +#define SMALLROOM_L2 2640 /* 66 ms */ +#define SMALLROOM_C2 10000 +#define SMALLROOM_FILT_CNT 1 +#define SMALLROOM_FC0 0x4000 /* .25 */ + +#define BIGROOM_SECT_CNT 3 +#define BIGROOM_SIZE AL_FX_BUFFER_SIZE +#define BIGROOM_L0 1408 /* 32 ms */ +#define BIGROOM_C0 9830 +#define BIGROOM_L1 1984 /* 45 ms */ +#define BIGROOM_C1 9830 +#define BIGROOM_L2 3792 /* 86 ms */ +#define BIGROOM_C2 12000 +#define BIGROOM_FILT_CNT 1 +#define BIGROOM_FC0 0x4000 /* .25 */ + +#define ECHO_SIZE AL_FX_BUFFER_SIZE +#define ECHO_SECT_CNT 1 +#define ECHO_L0 7936 /* 180 ms */ +#define ECHO_C0 0x6000 + +#endif diff --git a/src/lib/ultra/audio/seq.h b/src/lib/ultra/audio/seq.h new file mode 100644 index 000000000..479b3396d --- /dev/null +++ b/src/lib/ultra/audio/seq.h @@ -0,0 +1,9 @@ + + +#ifndef __seq__ +#define __seq__ + +char __alSeqNextDelta (ALSeq *seq, s32 *pDeltaTicks); + + +#endif /* __seq__ */ diff --git a/src/include/PR/seqp.h b/src/lib/ultra/audio/seqp.h old mode 100755 new mode 100644 similarity index 56% rename from src/include/PR/seqp.h rename to src/lib/ultra/audio/seqp.h index 9e5196370..dbfc4732b --- a/src/include/PR/seqp.h +++ b/src/lib/ultra/audio/seqp.h @@ -12,26 +12,25 @@ ALVoiceState *__mapVoice(ALSeqPlayer *, u8, u8, u8); void __unmapVoice(ALSeqPlayer *seqp, ALVoice *voice); -char __n_voiceNeedsNoteKill(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime killTime); /* sct 1/5/96 */ +char __voiceNeedsNoteKill(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime killTime); /* sct 1/5/96 */ ALVoiceState *__lookupVoice(ALSeqPlayer *, u8, u8); ALSound *__lookupSound(ALSeqPlayer *, u8, u8, u8); ALSound *__lookupSoundQuick(ALSeqPlayer *, u8, u8, u8); s16 __vsVol(ALVoiceState *voice, ALSeqPlayer *seqp); -ALMicroTime __n_vsDelta(ALVoiceState *voice, ALMicroTime t); +ALMicroTime __vsDelta(ALVoiceState *voice, ALMicroTime t); ALPan __vsPan(ALVoiceState *voice, ALSeqPlayer *seqp); -void __n_initFromBank(ALSeqPlayer *seqp, ALBank *b); +void __initFromBank(ALSeqPlayer *seqp, ALBank *b); void __initChanState(ALSeqPlayer *seqp); -void __n_resetPerfChanState(ALSeqPlayer *seqp, s32 chan); -void __n_setInstChanState(ALSeqPlayer *seqp, ALInstrument *inst, s32 chan); +void __resetPerfChanState(ALSeqPlayer *seqp, s32 chan); +void __setInstChanState(ALSeqPlayer *seqp, ALInstrument *inst, s32 chan); void __seqpPrintVoices(ALSeqPlayer *); -void __seqpReleaseVoice(ALSeqPlayer *seqp, ALVoice *voice, - ALMicroTime deltaTime); +void __seqpReleaseVoice(ALSeqPlayer *seqp, ALVoice *voice, ALMicroTime deltaTime); -void __n_seqpStopOsc(ALSeqPlayer *seqp, ALVoiceState *vs); +void __seqpStopOsc(ALSeqPlayer *seqp, ALVoiceState *vs); void __postNextSeqEvent(ALSeqPlayer *seqp); /* sct 11/7/95 */ diff --git a/src/lib/ultra/audio/sl.c b/src/lib/ultra/audio/sl.c new file mode 100644 index 000000000..3443634b4 --- /dev/null +++ b/src/lib/ultra/audio/sl.c @@ -0,0 +1,24 @@ +#include + +void alLink(ALLink *ln, ALLink *to) +{ + ln->next = to->next; + ln->prev = to; + + if (to->next) { + to->next->prev = ln; + } + + to->next = ln; +} + +void alUnlink(ALLink *ln) +{ + if (ln->next) { + ln->next->prev = ln->prev; + } + + if (ln->prev) { + ln->prev->next = ln->next; + } +} diff --git a/src/lib/ultra/audio/sndp.h b/src/lib/ultra/audio/sndp.h new file mode 100644 index 000000000..951ab392b --- /dev/null +++ b/src/lib/ultra/audio/sndp.h @@ -0,0 +1,102 @@ +/*==================================================================== + * sndp.h + * + * Synopsis: + * + * Copyright 1995, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + + +#ifndef __SNDP__ +#define __SNDP__ + +#include + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define MIN_RATIO 0.0001 + +typedef enum { + AL_SNDP_PLAY_EVT, + AL_SNDP_STOP_EVT, + AL_SNDP_PAN_EVT, + AL_SNDP_VOL_EVT, + AL_SNDP_PITCH_EVT, + AL_SNDP_API_EVT, + AL_SNDP_DECAY_EVT, + AL_SNDP_END_EVT, + AL_SNDP_FX_EVT +} ALSndpMsgType; + +typedef struct { + ALVoice voice; + ALSound *sound; /* sound referenced here */ + s16 priority; + f32 pitch; /* current playback pitch */ + s32 state; /* play state for this sound */ + s16 vol; /* volume - combined with volume from bank */ + ALPan pan; /* pan - 0 = left, 127 = right */ + u8 fxMix; /* wet/dry mix - 0 = dry, 127 = wet */ +} ALSoundState; + +typedef union { + + ALEvent msg; + + struct { + s16 type; + ALSoundState *state; + } common; + + struct { + s16 type; + ALSoundState *state; + s16 vol; + } vol; + + struct { + s16 type; + ALSoundState *state; + f32 pitch; + } pitch; + + struct { + s16 type; + ALSoundState *state; + ALPan pan; + } pan; + + struct { + s16 type; + ALSoundState *state; + u8 mix; + } fx; + +} ALSndpEvent; + +static ALMicroTime _sndpVoiceHandler(void *node); +static void _handleEvent(ALSndPlayer *sndp, ALSndpEvent *event); +static void _removeEvents(ALEventQueue *evtq, ALSoundState *state); +static s32 _DivS32ByF32 (s32 i, f32 f); + +#endif diff --git a/src/lib/ultra/audio/syndelete.c b/src/lib/ultra/audio/syndelete.c deleted file mode 100644 index 0dca408bc..000000000 --- a/src/lib/ultra/audio/syndelete.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" - -void n_alSynDelete(void) -{ - n_syn->drvr.head = NULL; -} diff --git a/src/lib/ultra/audio/synsetpriority.c b/src/lib/ultra/audio/synsetpriority.c deleted file mode 100644 index 42bc63c30..000000000 --- a/src/lib/ultra/audio/synsetpriority.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/mp3.h" -#include "lib/lib_3a100.h" -#include "data.h" -#include "types.h" - -void n_alSynSetPriority(ALVoice *voice, s16 priority) -{ - voice->priority = priority; -} diff --git a/src/lib/ultra/audio/synthInternals.h b/src/lib/ultra/audio/synthInternals.h new file mode 100644 index 000000000..0e575129e --- /dev/null +++ b/src/lib/ultra/audio/synthInternals.h @@ -0,0 +1,337 @@ +/*==================================================================== + * audioInternals.h + * + * Synopsis: + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ + +#ifndef __audioInternals__ +#define __audioInternals__ + +#include + +/* + * filter message ids + */ +enum { + AL_FILTER_FREE_VOICE, + AL_FILTER_SET_SOURCE, + AL_FILTER_ADD_SOURCE, + AL_FILTER_ADD_UPDATE, + AL_FILTER_RESET, + AL_FILTER_SET_WAVETABLE, + /* AL_FILTER_SET_DMA_PROC,*/ + /* AL_FILTER_SKIP_LOOP,*/ + AL_FILTER_SET_DRAM, + AL_FILTER_SET_PITCH, + AL_FILTER_SET_UNITY_PITCH, + AL_FILTER_START, + /* AL_FILTER_SET_DECAY,*/ + /* AL_FILTER_SET_FC,*/ + AL_FILTER_SET_STATE, + AL_FILTER_SET_VOLUME, + AL_FILTER_SET_PAN, + AL_FILTER_START_VOICE_ALT, + AL_FILTER_START_VOICE, + AL_FILTER_STOP_VOICE, + AL_FILTER_SET_FXAMT +}; + +#define AL_MAX_RSP_SAMPLES 160 + +/* + * buffer locations based on AL_MAX_RSP_SAMPLES + */ +#define AL_DECODER_IN 0 +#define AL_RESAMPLER_OUT 0 +#define AL_TEMP_0 0 +#define AL_DECODER_OUT 320 +#define AL_TEMP_1 320 +#define AL_TEMP_2 640 +#define AL_MAIN_L_OUT 1088 +#define AL_MAIN_R_OUT 1408 +#define AL_AUX_L_OUT 1728 +#define AL_AUX_R_OUT 2048 + +/* + * filter types + */ +enum { + AL_ADPCM, + AL_RESAMPLE, + AL_BUFFER, + AL_SAVE, + AL_ENVMIX, + AL_FX, + AL_AUXBUS, + AL_MAINBUS +}; + +typedef struct ALParam_s { + struct ALParam_s *next; + s32 delta; + s16 type; + union { + f32 f; + s32 i; + } data; + union { + f32 f; + s32 i; + } moredata; + union { + f32 f; + s32 i; + } stillmoredata; + union { + f32 f; + s32 i; + } yetstillmoredata; +} ALParam; + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + s16 unity; /* disable resampler */ + f32 pitch; + s16 volume; + ALPan pan; + u8 fxMix; + s32 samples; + struct ALWaveTable_s *wave; +} ALStartParamAlt; + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + s16 unity; /* disable resampler */ + struct ALWaveTable_s *wave; +} ALStartParam; + +typedef struct { + struct ALParam_s *next; + s32 delta; + s16 type; + struct PVoice_s *pvoice; +} ALFreeParam; + +typedef Acmd *(*ALCmdHandler)(void *, s16 *, s32, s32, Acmd *); +typedef s32 (*ALSetParam)(void *, s32, void *); + +typedef struct ALFilter_s { + struct ALFilter_s *source; + ALCmdHandler handler; + ALSetParam setParam; + s16 inp; + s16 outp; + s32 type; +} ALFilter; + +void alFilterNew(ALFilter *f, ALCmdHandler h, ALSetParam s, s32 type); + +#define AL_MAX_ADPCM_STATES 3 + +typedef struct { + ALFilter filter; + ADPCM_STATE *state; + ADPCM_STATE *lstate; + ALRawLoop loop; + struct ALWaveTable_s *table; + s32 bookSize; + ALDMAproc dma; + void *dmaState; + s32 sample; + s32 lastsam; + s32 first; + s32 memin; +} ALLoadFilter; + +void alLoadNew(ALLoadFilter *f, ALDMANew dma, ALHeap *hp); +Acmd *alAdpcmPull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); +Acmd *alRaw16Pull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); +s32 alLoadParam(void *filter, s32 paramID, void *param); + +typedef struct ALResampler_s { + ALFilter filter; + RESAMPLE_STATE *state; + f32 ratio; + s32 upitch; + f32 delta; + s32 first; + ALParam *ctrlList; + ALParam *ctrlTail; + s32 motion; +} ALResampler; + +typedef struct { + s16 fc; + s16 fgain; + union { + s16 fccoef[16]; + s64 force_aligned; + } fcvec; + POLEF_STATE *fstate; + s32 first; +} ALLowPass; + +typedef struct { + u32 input; + u32 output; + s16 ffcoef; + s16 fbcoef; + s16 gain; + f32 rsinc; + f32 rsval; + s32 rsdelta; + f32 rsgain; + ALLowPass *lp; + ALResampler *rs; +} ALDelay; + +typedef s32 (*ALSetFXParam)(void *, s32, void *); +typedef struct { + struct ALFilter_s filter; + s16 *base; + s16 *input; + u32 length; + ALDelay *delay; + u8 section_count; + ALSetFXParam paramHdl; +} ALFx; + +void alFxNew(ALFx *r, ALSynConfig *c, ALHeap *hp); +Acmd *alFxPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alFxParam(void *filter, s32 paramID, void *param); +s32 alFxParamHdl(void *filter, s32 paramID, void *param); + +#define AL_MAX_MAIN_BUS_SOURCES 1 +typedef struct ALMainBus_s { + ALFilter filter; + s32 sourceCount; + s32 maxSources; + ALFilter **sources; +} ALMainBus; + +void alMainBusNew(ALMainBus *m, void *ptr, s32 len); +Acmd *alMainBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alMainBusParam(void *filter, s32 paramID, void *param); + +#define AL_MAX_AUX_BUS_SOURCES 8 +#define AL_MAX_AUX_BUS_FX 1 +typedef struct ALAuxBus_s { + ALFilter filter; + s32 sourceCount; + s32 maxSources; + ALFilter **sources; + ALFx fx[AL_MAX_AUX_BUS_FX]; +} ALAuxBus; + +void alAuxBusNew(ALAuxBus *m, void *ptr, s32 len); +Acmd *alAuxBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alAuxBusParam(void *filter, s32 paramID, void *param); + +void alResampleNew(ALResampler *r, ALHeap *hp); +Acmd *alResamplePull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alResampleParam(void *f, s32 paramID, void *param); + +typedef struct ALSave_s { + ALFilter filter; + s32 dramout; + s32 first; +} ALSave; + +void alSaveNew(ALSave *r); +Acmd *alSavePull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alSaveParam(void *f, s32 paramID, void *param); + +typedef struct ALEnvMixer_s { + ALFilter filter; + ENVMIX_STATE *state; + s16 pan; + s16 volume; + s16 cvolL; + s16 cvolR; + s16 dryamt; + s16 wetamt; + u16 lratl; + s16 lratm; + s16 ltgt; + u16 rratl; + s16 rratm; + s16 rtgt; + s32 delta; + s32 segEnd; + s32 first; + ALParam *ctrlList; + ALParam *ctrlTail; + ALFilter **sources; + s32 motion; +} ALEnvMixer; + +void alEnvmixerNew(ALEnvMixer *e, ALHeap *hp); +Acmd *alEnvmixerPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alEnvmixerParam(void *filter, s32 paramID, void *param); + + +/* + * heap stuff + */ +typedef struct { + s32 magic; /* check structure integrety */ + s32 size; /* size of this allocated block */ + u8 *file; /* file that this alloc was called from */ + s32 line; /* line that it was called from */ + s32 count; /* heap call number */ + s32 pad0; + s32 pad1; + s32 pad2; /* Make it 32 bytes */ +} HeapInfo; + +#define AL_CACHE_ALIGN 15 + +/* + * synth stuff + */ + +typedef struct PVoice_s { + ALLink node; + struct ALVoice_s *vvoice; + ALFilter *channelKnob; + ALLoadFilter decoder; + ALResampler resampler; + ALEnvMixer envmixer; + s32 offset; +} PVoice; + +/* + * prototypes for private driver functions + */ +ALParam *__allocParam(void); +void __freeParam(ALParam *param); +void _freePVoice(ALSynth *drvr, PVoice *pvoice); +void _collectPVoices(ALSynth *drvr); + +s32 _timeToSamples(ALSynth *ALSynth, s32 micros); +ALMicroTime _samplesToTime(ALSynth *synth, s32 samples); + +void _init_lpfilter(ALLowPass *lp); + +#endif + diff --git a/src/lib/ultra/gu/align.c b/src/lib/ultra/gu/align.c index 9a041fa8b..6a7ce86ce 100644 --- a/src/lib/ultra/gu/align.c +++ b/src/lib/ultra/gu/align.c @@ -1,9 +1,4 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/mtx.h" -#include "data.h" -#include "types.h" +#include "guint.h" void guAlignF(float mf[4][4], float a, float x, float y, float z) { diff --git a/src/lib/ultra/gu/coss.c b/src/lib/ultra/gu/coss.c index 621cf7548..4bef02674 100644 --- a/src/lib/ultra/gu/coss.c +++ b/src/lib/ultra/gu/coss.c @@ -1,9 +1,4 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/mtx.h" -#include "data.h" -#include "types.h" +#include "guint.h" signed short coss(unsigned short x) { diff --git a/src/lib/ultra/gu/guint.h b/src/lib/ultra/gu/guint.h new file mode 100644 index 000000000..c3206dd58 --- /dev/null +++ b/src/lib/ultra/gu/guint.h @@ -0,0 +1,42 @@ +/************************************************************************** + * * + * Copyright (C) 1994, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ + +#include "mbi.h" +#include "gu.h" + +typedef union +{ + struct + { + unsigned int hi; + unsigned int lo; + } word; + + double d; +} du; + +typedef union +{ + unsigned int i; + float f; +} fu; + +#ifndef __GL_GL_H__ + +typedef float Matrix[4][4]; + +#endif + +#define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5)) +#define ABS(d) ((d) > 0) ? (d) : -(d) + +extern float __libm_qnan_f; diff --git a/src/lib/ultra/gu/sins.c b/src/lib/ultra/gu/sins.c index ded59ef18..be1c8e229 100644 --- a/src/lib/ultra/gu/sins.c +++ b/src/lib/ultra/gu/sins.c @@ -1,9 +1,4 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/mtx.h" -#include "data.h" -#include "types.h" +#include "guint.h" s16 sintable[] = { 0x0000, 0x0032, 0x0064, 0x0096, 0x00c9, 0x00fb, 0x012d, 0x0160, 0x0192, 0x01c4, diff --git a/src/lib/ultra/gu/sintable.h b/src/lib/ultra/gu/sintable.h new file mode 100644 index 000000000..b5e1a45ab --- /dev/null +++ b/src/lib/ultra/gu/sintable.h @@ -0,0 +1,1031 @@ + +/* + * Do not edit this file -- it was generated by "maketable". + */ + +static signed short sintable[0x400] = { + 0x0000, + 0x0032, + 0x0064, + 0x0096, + 0x00c9, + 0x00fb, + 0x012d, + 0x0160, + 0x0192, + 0x01c4, + 0x01f7, + 0x0229, + 0x025b, + 0x028e, + 0x02c0, + 0x02f2, + 0x0324, + 0x0357, + 0x0389, + 0x03bb, + 0x03ee, + 0x0420, + 0x0452, + 0x0484, + 0x04b7, + 0x04e9, + 0x051b, + 0x054e, + 0x0580, + 0x05b2, + 0x05e4, + 0x0617, + 0x0649, + 0x067b, + 0x06ad, + 0x06e0, + 0x0712, + 0x0744, + 0x0776, + 0x07a9, + 0x07db, + 0x080d, + 0x083f, + 0x0871, + 0x08a4, + 0x08d6, + 0x0908, + 0x093a, + 0x096c, + 0x099f, + 0x09d1, + 0x0a03, + 0x0a35, + 0x0a67, + 0x0a99, + 0x0acb, + 0x0afe, + 0x0b30, + 0x0b62, + 0x0b94, + 0x0bc6, + 0x0bf8, + 0x0c2a, + 0x0c5c, + 0x0c8e, + 0x0cc0, + 0x0cf2, + 0x0d25, + 0x0d57, + 0x0d89, + 0x0dbb, + 0x0ded, + 0x0e1f, + 0x0e51, + 0x0e83, + 0x0eb5, + 0x0ee7, + 0x0f19, + 0x0f4b, + 0x0f7c, + 0x0fae, + 0x0fe0, + 0x1012, + 0x1044, + 0x1076, + 0x10a8, + 0x10da, + 0x110c, + 0x113e, + 0x116f, + 0x11a1, + 0x11d3, + 0x1205, + 0x1237, + 0x1269, + 0x129a, + 0x12cc, + 0x12fe, + 0x1330, + 0x1361, + 0x1393, + 0x13c5, + 0x13f6, + 0x1428, + 0x145a, + 0x148c, + 0x14bd, + 0x14ef, + 0x1520, + 0x1552, + 0x1584, + 0x15b5, + 0x15e7, + 0x1618, + 0x164a, + 0x167b, + 0x16ad, + 0x16df, + 0x1710, + 0x1741, + 0x1773, + 0x17a4, + 0x17d6, + 0x1807, + 0x1839, + 0x186a, + 0x189b, + 0x18cd, + 0x18fe, + 0x1930, + 0x1961, + 0x1992, + 0x19c3, + 0x19f5, + 0x1a26, + 0x1a57, + 0x1a88, + 0x1aba, + 0x1aeb, + 0x1b1c, + 0x1b4d, + 0x1b7e, + 0x1baf, + 0x1be1, + 0x1c12, + 0x1c43, + 0x1c74, + 0x1ca5, + 0x1cd6, + 0x1d07, + 0x1d38, + 0x1d69, + 0x1d9a, + 0x1dcb, + 0x1dfc, + 0x1e2d, + 0x1e5d, + 0x1e8e, + 0x1ebf, + 0x1ef0, + 0x1f21, + 0x1f52, + 0x1f82, + 0x1fb3, + 0x1fe4, + 0x2015, + 0x2045, + 0x2076, + 0x20a7, + 0x20d7, + 0x2108, + 0x2139, + 0x2169, + 0x219a, + 0x21ca, + 0x21fb, + 0x222b, + 0x225c, + 0x228c, + 0x22bd, + 0x22ed, + 0x231d, + 0x234e, + 0x237e, + 0x23ae, + 0x23df, + 0x240f, + 0x243f, + 0x2470, + 0x24a0, + 0x24d0, + 0x2500, + 0x2530, + 0x2560, + 0x2591, + 0x25c1, + 0x25f1, + 0x2621, + 0x2651, + 0x2681, + 0x26b1, + 0x26e1, + 0x2711, + 0x2740, + 0x2770, + 0x27a0, + 0x27d0, + 0x2800, + 0x2830, + 0x285f, + 0x288f, + 0x28bf, + 0x28ee, + 0x291e, + 0x294e, + 0x297d, + 0x29ad, + 0x29dd, + 0x2a0c, + 0x2a3c, + 0x2a6b, + 0x2a9b, + 0x2aca, + 0x2af9, + 0x2b29, + 0x2b58, + 0x2b87, + 0x2bb7, + 0x2be6, + 0x2c15, + 0x2c44, + 0x2c74, + 0x2ca3, + 0x2cd2, + 0x2d01, + 0x2d30, + 0x2d5f, + 0x2d8e, + 0x2dbd, + 0x2dec, + 0x2e1b, + 0x2e4a, + 0x2e79, + 0x2ea8, + 0x2ed7, + 0x2f06, + 0x2f34, + 0x2f63, + 0x2f92, + 0x2fc0, + 0x2fef, + 0x301e, + 0x304c, + 0x307b, + 0x30a9, + 0x30d8, + 0x3107, + 0x3135, + 0x3163, + 0x3192, + 0x31c0, + 0x31ef, + 0x321d, + 0x324b, + 0x3279, + 0x32a8, + 0x32d6, + 0x3304, + 0x3332, + 0x3360, + 0x338e, + 0x33bc, + 0x33ea, + 0x3418, + 0x3446, + 0x3474, + 0x34a2, + 0x34d0, + 0x34fe, + 0x352b, + 0x3559, + 0x3587, + 0x35b5, + 0x35e2, + 0x3610, + 0x363d, + 0x366b, + 0x3698, + 0x36c6, + 0x36f3, + 0x3721, + 0x374e, + 0x377c, + 0x37a9, + 0x37d6, + 0x3803, + 0x3831, + 0x385e, + 0x388b, + 0x38b8, + 0x38e5, + 0x3912, + 0x393f, + 0x396c, + 0x3999, + 0x39c6, + 0x39f3, + 0x3a20, + 0x3a4d, + 0x3a79, + 0x3aa6, + 0x3ad3, + 0x3b00, + 0x3b2c, + 0x3b59, + 0x3b85, + 0x3bb2, + 0x3bde, + 0x3c0b, + 0x3c37, + 0x3c64, + 0x3c90, + 0x3cbc, + 0x3ce9, + 0x3d15, + 0x3d41, + 0x3d6d, + 0x3d99, + 0x3dc5, + 0x3df1, + 0x3e1d, + 0x3e49, + 0x3e75, + 0x3ea1, + 0x3ecd, + 0x3ef9, + 0x3f25, + 0x3f50, + 0x3f7c, + 0x3fa8, + 0x3fd3, + 0x3fff, + 0x402b, + 0x4056, + 0x4082, + 0x40ad, + 0x40d8, + 0x4104, + 0x412f, + 0x415a, + 0x4186, + 0x41b1, + 0x41dc, + 0x4207, + 0x4232, + 0x425d, + 0x4288, + 0x42b3, + 0x42de, + 0x4309, + 0x4334, + 0x435f, + 0x4389, + 0x43b4, + 0x43df, + 0x4409, + 0x4434, + 0x445f, + 0x4489, + 0x44b4, + 0x44de, + 0x4508, + 0x4533, + 0x455d, + 0x4587, + 0x45b1, + 0x45dc, + 0x4606, + 0x4630, + 0x465a, + 0x4684, + 0x46ae, + 0x46d8, + 0x4702, + 0x472c, + 0x4755, + 0x477f, + 0x47a9, + 0x47d2, + 0x47fc, + 0x4826, + 0x484f, + 0x4879, + 0x48a2, + 0x48cc, + 0x48f5, + 0x491e, + 0x4948, + 0x4971, + 0x499a, + 0x49c3, + 0x49ec, + 0x4a15, + 0x4a3e, + 0x4a67, + 0x4a90, + 0x4ab9, + 0x4ae2, + 0x4b0b, + 0x4b33, + 0x4b5c, + 0x4b85, + 0x4bad, + 0x4bd6, + 0x4bfe, + 0x4c27, + 0x4c4f, + 0x4c78, + 0x4ca0, + 0x4cc8, + 0x4cf0, + 0x4d19, + 0x4d41, + 0x4d69, + 0x4d91, + 0x4db9, + 0x4de1, + 0x4e09, + 0x4e31, + 0x4e58, + 0x4e80, + 0x4ea8, + 0x4ed0, + 0x4ef7, + 0x4f1f, + 0x4f46, + 0x4f6e, + 0x4f95, + 0x4fbd, + 0x4fe4, + 0x500b, + 0x5032, + 0x505a, + 0x5081, + 0x50a8, + 0x50cf, + 0x50f6, + 0x511d, + 0x5144, + 0x516b, + 0x5191, + 0x51b8, + 0x51df, + 0x5205, + 0x522c, + 0x5253, + 0x5279, + 0x52a0, + 0x52c6, + 0x52ec, + 0x5313, + 0x5339, + 0x535f, + 0x5385, + 0x53ab, + 0x53d1, + 0x53f7, + 0x541d, + 0x5443, + 0x5469, + 0x548f, + 0x54b5, + 0x54da, + 0x5500, + 0x5525, + 0x554b, + 0x5571, + 0x5596, + 0x55bb, + 0x55e1, + 0x5606, + 0x562b, + 0x5650, + 0x5675, + 0x569b, + 0x56c0, + 0x56e5, + 0x5709, + 0x572e, + 0x5753, + 0x5778, + 0x579d, + 0x57c1, + 0x57e6, + 0x580a, + 0x582f, + 0x5853, + 0x5878, + 0x589c, + 0x58c0, + 0x58e5, + 0x5909, + 0x592d, + 0x5951, + 0x5975, + 0x5999, + 0x59bd, + 0x59e1, + 0x5a04, + 0x5a28, + 0x5a4c, + 0x5a6f, + 0x5a93, + 0x5ab7, + 0x5ada, + 0x5afd, + 0x5b21, + 0x5b44, + 0x5b67, + 0x5b8b, + 0x5bae, + 0x5bd1, + 0x5bf4, + 0x5c17, + 0x5c3a, + 0x5c5d, + 0x5c7f, + 0x5ca2, + 0x5cc5, + 0x5ce7, + 0x5d0a, + 0x5d2d, + 0x5d4f, + 0x5d71, + 0x5d94, + 0x5db6, + 0x5dd8, + 0x5dfa, + 0x5e1d, + 0x5e3f, + 0x5e61, + 0x5e83, + 0x5ea5, + 0x5ec6, + 0x5ee8, + 0x5f0a, + 0x5f2c, + 0x5f4d, + 0x5f6f, + 0x5f90, + 0x5fb2, + 0x5fd3, + 0x5ff4, + 0x6016, + 0x6037, + 0x6058, + 0x6079, + 0x609a, + 0x60bb, + 0x60dc, + 0x60fd, + 0x611e, + 0x613e, + 0x615f, + 0x6180, + 0x61a0, + 0x61c1, + 0x61e1, + 0x6202, + 0x6222, + 0x6242, + 0x6263, + 0x6283, + 0x62a3, + 0x62c3, + 0x62e3, + 0x6303, + 0x6323, + 0x6342, + 0x6362, + 0x6382, + 0x63a1, + 0x63c1, + 0x63e0, + 0x6400, + 0x641f, + 0x643f, + 0x645e, + 0x647d, + 0x649c, + 0x64bb, + 0x64da, + 0x64f9, + 0x6518, + 0x6537, + 0x6556, + 0x6574, + 0x6593, + 0x65b2, + 0x65d0, + 0x65ef, + 0x660d, + 0x662b, + 0x664a, + 0x6668, + 0x6686, + 0x66a4, + 0x66c2, + 0x66e0, + 0x66fe, + 0x671c, + 0x673a, + 0x6757, + 0x6775, + 0x6792, + 0x67b0, + 0x67cd, + 0x67eb, + 0x6808, + 0x6825, + 0x6843, + 0x6860, + 0x687d, + 0x689a, + 0x68b7, + 0x68d4, + 0x68f1, + 0x690d, + 0x692a, + 0x6947, + 0x6963, + 0x6980, + 0x699c, + 0x69b9, + 0x69d5, + 0x69f1, + 0x6a0e, + 0x6a2a, + 0x6a46, + 0x6a62, + 0x6a7e, + 0x6a9a, + 0x6ab5, + 0x6ad1, + 0x6aed, + 0x6b08, + 0x6b24, + 0x6b40, + 0x6b5b, + 0x6b76, + 0x6b92, + 0x6bad, + 0x6bc8, + 0x6be3, + 0x6bfe, + 0x6c19, + 0x6c34, + 0x6c4f, + 0x6c6a, + 0x6c84, + 0x6c9f, + 0x6cba, + 0x6cd4, + 0x6cef, + 0x6d09, + 0x6d23, + 0x6d3e, + 0x6d58, + 0x6d72, + 0x6d8c, + 0x6da6, + 0x6dc0, + 0x6dda, + 0x6df3, + 0x6e0d, + 0x6e27, + 0x6e40, + 0x6e5a, + 0x6e73, + 0x6e8d, + 0x6ea6, + 0x6ebf, + 0x6ed9, + 0x6ef2, + 0x6f0b, + 0x6f24, + 0x6f3d, + 0x6f55, + 0x6f6e, + 0x6f87, + 0x6fa0, + 0x6fb8, + 0x6fd1, + 0x6fe9, + 0x7002, + 0x701a, + 0x7032, + 0x704a, + 0x7062, + 0x707a, + 0x7092, + 0x70aa, + 0x70c2, + 0x70da, + 0x70f2, + 0x7109, + 0x7121, + 0x7138, + 0x7150, + 0x7167, + 0x717e, + 0x7196, + 0x71ad, + 0x71c4, + 0x71db, + 0x71f2, + 0x7209, + 0x7220, + 0x7236, + 0x724d, + 0x7264, + 0x727a, + 0x7291, + 0x72a7, + 0x72bd, + 0x72d4, + 0x72ea, + 0x7300, + 0x7316, + 0x732c, + 0x7342, + 0x7358, + 0x736e, + 0x7383, + 0x7399, + 0x73ae, + 0x73c4, + 0x73d9, + 0x73ef, + 0x7404, + 0x7419, + 0x742e, + 0x7443, + 0x7458, + 0x746d, + 0x7482, + 0x7497, + 0x74ac, + 0x74c0, + 0x74d5, + 0x74ea, + 0x74fe, + 0x7512, + 0x7527, + 0x753b, + 0x754f, + 0x7563, + 0x7577, + 0x758b, + 0x759f, + 0x75b3, + 0x75c7, + 0x75da, + 0x75ee, + 0x7601, + 0x7615, + 0x7628, + 0x763b, + 0x764f, + 0x7662, + 0x7675, + 0x7688, + 0x769b, + 0x76ae, + 0x76c1, + 0x76d3, + 0x76e6, + 0x76f9, + 0x770b, + 0x771e, + 0x7730, + 0x7742, + 0x7754, + 0x7767, + 0x7779, + 0x778b, + 0x779d, + 0x77af, + 0x77c0, + 0x77d2, + 0x77e4, + 0x77f5, + 0x7807, + 0x7818, + 0x782a, + 0x783b, + 0x784c, + 0x785d, + 0x786e, + 0x787f, + 0x7890, + 0x78a1, + 0x78b2, + 0x78c3, + 0x78d3, + 0x78e4, + 0x78f4, + 0x7905, + 0x7915, + 0x7925, + 0x7936, + 0x7946, + 0x7956, + 0x7966, + 0x7976, + 0x7985, + 0x7995, + 0x79a5, + 0x79b5, + 0x79c4, + 0x79d4, + 0x79e3, + 0x79f2, + 0x7a02, + 0x7a11, + 0x7a20, + 0x7a2f, + 0x7a3e, + 0x7a4d, + 0x7a5b, + 0x7a6a, + 0x7a79, + 0x7a87, + 0x7a96, + 0x7aa4, + 0x7ab3, + 0x7ac1, + 0x7acf, + 0x7add, + 0x7aeb, + 0x7af9, + 0x7b07, + 0x7b15, + 0x7b23, + 0x7b31, + 0x7b3e, + 0x7b4c, + 0x7b59, + 0x7b67, + 0x7b74, + 0x7b81, + 0x7b8e, + 0x7b9b, + 0x7ba8, + 0x7bb5, + 0x7bc2, + 0x7bcf, + 0x7bdc, + 0x7be8, + 0x7bf5, + 0x7c02, + 0x7c0e, + 0x7c1a, + 0x7c27, + 0x7c33, + 0x7c3f, + 0x7c4b, + 0x7c57, + 0x7c63, + 0x7c6f, + 0x7c7a, + 0x7c86, + 0x7c92, + 0x7c9d, + 0x7ca9, + 0x7cb4, + 0x7cbf, + 0x7ccb, + 0x7cd6, + 0x7ce1, + 0x7cec, + 0x7cf7, + 0x7d02, + 0x7d0c, + 0x7d17, + 0x7d22, + 0x7d2c, + 0x7d37, + 0x7d41, + 0x7d4b, + 0x7d56, + 0x7d60, + 0x7d6a, + 0x7d74, + 0x7d7e, + 0x7d88, + 0x7d91, + 0x7d9b, + 0x7da5, + 0x7dae, + 0x7db8, + 0x7dc1, + 0x7dcb, + 0x7dd4, + 0x7ddd, + 0x7de6, + 0x7def, + 0x7df8, + 0x7e01, + 0x7e0a, + 0x7e13, + 0x7e1b, + 0x7e24, + 0x7e2c, + 0x7e35, + 0x7e3d, + 0x7e45, + 0x7e4d, + 0x7e56, + 0x7e5e, + 0x7e66, + 0x7e6d, + 0x7e75, + 0x7e7d, + 0x7e85, + 0x7e8c, + 0x7e94, + 0x7e9b, + 0x7ea3, + 0x7eaa, + 0x7eb1, + 0x7eb8, + 0x7ebf, + 0x7ec6, + 0x7ecd, + 0x7ed4, + 0x7edb, + 0x7ee1, + 0x7ee8, + 0x7eee, + 0x7ef5, + 0x7efb, + 0x7f01, + 0x7f08, + 0x7f0e, + 0x7f14, + 0x7f1a, + 0x7f20, + 0x7f25, + 0x7f2b, + 0x7f31, + 0x7f36, + 0x7f3c, + 0x7f41, + 0x7f47, + 0x7f4c, + 0x7f51, + 0x7f56, + 0x7f5b, + 0x7f60, + 0x7f65, + 0x7f6a, + 0x7f6f, + 0x7f74, + 0x7f78, + 0x7f7d, + 0x7f81, + 0x7f85, + 0x7f8a, + 0x7f8e, + 0x7f92, + 0x7f96, + 0x7f9a, + 0x7f9e, + 0x7fa2, + 0x7fa6, + 0x7fa9, + 0x7fad, + 0x7fb0, + 0x7fb4, + 0x7fb7, + 0x7fba, + 0x7fbe, + 0x7fc1, + 0x7fc4, + 0x7fc7, + 0x7fca, + 0x7fcc, + 0x7fcf, + 0x7fd2, + 0x7fd4, + 0x7fd7, + 0x7fd9, + 0x7fdc, + 0x7fde, + 0x7fe0, + 0x7fe2, + 0x7fe4, + 0x7fe6, + 0x7fe8, + 0x7fea, + 0x7fec, + 0x7fed, + 0x7fef, + 0x7ff1, + 0x7ff2, + 0x7ff3, + 0x7ff5, + 0x7ff6, + 0x7ff7, + 0x7ff8, + 0x7ff9, + 0x7ffa, + 0x7ffb, + 0x7ffb, + 0x7ffc, + 0x7ffd, + 0x7ffd, + 0x7ffe, + 0x7ffe, + 0x7ffe, + 0x7ffe, + 0x7ffe, + 0x7fff, +}; diff --git a/src/lib/ultra/gu/translate.c b/src/lib/ultra/gu/translate.c index e895f7b06..025792bd5 100644 --- a/src/lib/ultra/gu/translate.c +++ b/src/lib/ultra/gu/translate.c @@ -1,8 +1,4 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include "guint.h" void guTranslateF(float mf[4][4], float x, float y, float z) { diff --git a/src/lib/ultra/io/ai.c b/src/lib/ultra/io/ai.c index 1f85ea9b4..5ed693ca9 100644 --- a/src/lib/ultra/io/ai.c +++ b/src/lib/ultra/io/ai.c @@ -1,4 +1,5 @@ -#include +#include +#include s32 __osAiDeviceBusy(void) { diff --git a/src/lib/ultra/io/aigetlen.c b/src/lib/ultra/io/aigetlen.c index 03ef2d31d..8d18f8d39 100644 --- a/src/lib/ultra/io/aigetlen.c +++ b/src/lib/ultra/io/aigetlen.c @@ -1,4 +1,4 @@ -#include +#include u32 osAiGetLength(void) { diff --git a/src/lib/ultra/io/aisetfreq.c b/src/lib/ultra/io/aisetfreq.c index 4c961c0d4..870dff49a 100644 --- a/src/lib/ultra/io/aisetfreq.c +++ b/src/lib/ultra/io/aisetfreq.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "../os/osint.h" s32 osAiSetFrequency(u32 frequency) { diff --git a/src/lib/ultra/io/aisetnextbuf.c b/src/lib/ultra/io/aisetnextbuf.c index 6d2701e30..6026716fa 100644 --- a/src/lib/ultra/io/aisetnextbuf.c +++ b/src/lib/ultra/io/aisetnextbuf.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include "../os/osint.h" s32 osAiSetNextBuffer(void *bufPtr, u32 size) { diff --git a/src/lib/ultra/io/conteeplongread.c b/src/lib/ultra/io/conteeplongread.c index 203f1c3ce..b7fae6f34 100644 --- a/src/lib/ultra/io/conteeplongread.c +++ b/src/lib/ultra/io/conteeplongread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "controller.h" s32 osEepromLongRead(OSMesgQueue *mq, u8 address, u8 *buffer, int length) { diff --git a/src/lib/ultra/io/conteeplongwrite.c b/src/lib/ultra/io/conteeplongwrite.c index 65367509d..085ad517c 100644 --- a/src/lib/ultra/io/conteeplongwrite.c +++ b/src/lib/ultra/io/conteeplongwrite.c @@ -1,6 +1,5 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include "controller.h" s32 osEepromLongWrite(OSMesgQueue *mq, u8 address, u8 *buffer, int length) { diff --git a/src/lib/ultra/io/conteepprobe.c b/src/lib/ultra/io/conteepprobe.c index 5dec518f7..a9e365d69 100644 --- a/src/lib/ultra/io/conteepprobe.c +++ b/src/lib/ultra/io/conteepprobe.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include "controller.h" +#include "siint.h" s32 osEepromProbe(OSMesgQueue *mq) { diff --git a/src/lib/ultra/io/conteepread.c b/src/lib/ultra/io/conteepread.c index f6cbd00f5..300fa9318 100644 --- a/src/lib/ultra/io/conteepread.c +++ b/src/lib/ultra/io/conteepread.c @@ -1,6 +1,7 @@ -#include -#include "bss.h" -#include "data.h" +#include "versions.h" +#include +#include "controller.h" +#include "siint.h" OSPifRam __osEepPifRam; diff --git a/src/lib/ultra/io/conteepwrite.c b/src/lib/ultra/io/conteepwrite.c index 413a0d560..45e8da79b 100644 --- a/src/lib/ultra/io/conteepwrite.c +++ b/src/lib/ultra/io/conteepwrite.c @@ -1,6 +1,7 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include "controller.h" +#include "siint.h" +#include void __osPackEepWriteData(u8 address, u8 *buffer); diff --git a/src/lib/ultra/io/contpfs.c b/src/lib/ultra/io/contpfs.c index 5d9c090e6..c574853b7 100644 --- a/src/lib/ultra/io/contpfs.c +++ b/src/lib/ultra/io/contpfs.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 g_PfsPrevChannel = -1; u8 g_PfsPrevBank = 250; @@ -188,7 +184,7 @@ s32 __osGetId(OSPfs *pfs) __OSPackId *id; if (pfs->activebank != 0) { - ERRCK(__osPfsSelectBank(pfs, 0)) + ERRCK(__osPfsSelectBank(pfs, 0)); } ERRCK(__osContRamRead(pfs->queue, pfs->channel, 1, (u8*)temp)); diff --git a/src/lib/ultra/io/contquery.c b/src/lib/ultra/io/contquery.c index ff6717032..7a5a10544 100644 --- a/src/lib/ultra/io/contquery.c +++ b/src/lib/ultra/io/contquery.c @@ -1,6 +1,6 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include "controller.h" +#include "siint.h" s32 osContStartQuery(OSMesgQueue *mq) { diff --git a/src/lib/ultra/io/contramread.c b/src/lib/ultra/io/contramread.c index b758ad7bb..769ceda4a 100644 --- a/src/lib/ultra/io/contramread.c +++ b/src/lib/ultra/io/contramread.c @@ -1,10 +1,11 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include +#include "controller.h" +#include "siint.h" s32 __osPfsLastChannel = -1; -s32 __osContRamRead(OSMesgQueue* ctrlrqueue, s32 channel, u16 addr, u8* data) +s32 __osContRamRead(OSMesgQueue* ctrlrqueue, int channel, u16 addr, u8* data) { s32 ret; s32 i; diff --git a/src/lib/ultra/io/contramwrite.c b/src/lib/ultra/io/contramwrite.c index ee53fb546..55f68908c 100644 --- a/src/lib/ultra/io/contramwrite.c +++ b/src/lib/ultra/io/contramwrite.c @@ -1,8 +1,11 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include +#include "controller.h" +#include "siint.h" -s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force) +extern s32 __osPfsLastChannel; + +s32 __osContRamWrite(OSMesgQueue* mq, int channel, u16 address, u8* buffer, int force) { s32 ret = 0; s32 i; @@ -10,7 +13,7 @@ s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 s32 retry = 2; u8 crc; - if (force != 1 && address < PFS_LABEL_AREA && address != 0) { + if (force != 1 && address < 7 && address != 0) { return 0; } diff --git a/src/lib/ultra/io/contreaddata.c b/src/lib/ultra/io/contreaddata.c index 310dcc2ac..10d414d28 100644 --- a/src/lib/ultra/io/contreaddata.c +++ b/src/lib/ultra/io/contreaddata.c @@ -1,6 +1,7 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include +#include "siint.h" +#include "controller.h" void __osPackReadData(void); diff --git a/src/lib/ultra/io/controller.c b/src/lib/ultra/io/controller.c index b6026f8e1..80b2bbf10 100644 --- a/src/lib/ultra/io/controller.c +++ b/src/lib/ultra/io/controller.c @@ -1,5 +1,7 @@ -#include -#include "data.h" +#include +#include +#include "controller.h" +#include "siint.h" OSPifRam __osContPifRam; u8 __osContLastCmd; diff --git a/src/lib/ultra/io/controller.h b/src/lib/ultra/io/controller.h new file mode 100755 index 000000000..8af6aceaa --- /dev/null +++ b/src/lib/ultra/io/controller.h @@ -0,0 +1,209 @@ +#ifndef _CONTROLLER_H +#define _CONTROLLER_H +#include +#include + +//should go somewhere else but +#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0]))) +#define CHNL_ERR(format) ((format.rxsize & CHNL_ERR_MASK) >> 4) + +typedef struct +{ + /* 0x0 */ u32 ramarray[15]; + /* 0x3C */ u32 pifstatus; +} OSPifRam; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u16 button; + /* 0x6 */ s8 stick_x; + /* 0x7 */ s8 stick_y; +} __OSContReadFormat; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 typeh; + /* 0x5 */ u8 typel; + /* 0x6 */ u8 status; + /* 0x7 */ u8 dummy1; +} __OSContRequestFormat; + +typedef struct +{ + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 typeh; + /* 0x4 */ u8 typel; + /* 0x5 */ u8 status; +} __OSContRequestFormatShort; + +typedef struct +{ + /* 0x0 */ u8 dummy; + /* 0x1 */ u8 txsize; + /* 0x2 */ u8 rxsize; + /* 0x3 */ u8 cmd; + /* 0x4 */ u8 hi; + /* 0x5 */ u8 lo; + /* 0x6 */ u8 data[BLOCKSIZE]; + /* 0x26 */ u8 datacrc; +} __OSContRamReadFormat; + +typedef union { + /* 0x0 */ struct + { + /* 0x0 */ u8 bank; + /* 0x1 */ u8 page; + } inode_t; + /* 0x0 */ u16 ipage; +} __OSInodeUnit; + +typedef struct +{ + /* 0x0 */ u32 game_code; + /* 0x4 */ u16 company_code; + /* 0x6 */ __OSInodeUnit start_page; + /* 0x8 */ u8 status; + /* 0x9 */ s8 reserved; + /* 0xA */ u16 data_sum; + /* 0xC */ u8 ext_name[PFS_FILE_EXT_LEN]; + /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN]; +} __OSDir; + +typedef struct +{ + /* 0x0 */ __OSInodeUnit inode_page[128]; +} __OSInode; + +typedef struct +{ + /* 0x0 */ u32 repaired; + /* 0x4 */ u32 random; + /* 0x8 */ u64 serial_mid; + /* 0x10 */ u64 serial_low; + /* 0x18 */ u16 deviceid; + /* 0x1A */ u8 banks; + /* 0x1B */ u8 version; + /* 0x1C */ u16 checksum; + /* 0x1E */ u16 inverted_checksum; +} __OSPackId; + +typedef struct +{ + /* 0x0 */ u8 txsize; + /* 0x1 */ u8 rxsize; + /* 0x2 */ u8 cmd; + /* 0x3 */ u8 address; + /* 0x4 */ u8 data[EEPROM_BLOCK_SIZE]; +} __OSContEepromFormat; + +//from: http://en64.shoutwiki.com/wiki/SI_Registers_Detailed#CONT_CMD_Usage +#define CONT_CMD_REQUEST_STATUS 0 +#define CONT_CMD_READ_BUTTON 1 +#define CONT_CMD_READ_MEMPACK 2 +#define CONT_CMD_WRITE_MEMPACK 3 +#define CONT_CMD_READ_EEPROM 4 +#define CONT_CMD_WRITE_EEPROM 5 +#define CONT_CMD_RESET 0xff + +#define CONT_CMD_REQUEST_STATUS_TX 1 +#define CONT_CMD_READ_BUTTON_TX 1 +#define CONT_CMD_READ_MEMPACK_TX 3 +#define CONT_CMD_WRITE_MEMPACK_TX 35 +#define CONT_CMD_READ_EEPROM_TX 2 +#define CONT_CMD_WRITE_EEPROM_TX 10 +#define CONT_CMD_RESET_TX 1 + +#define CONT_CMD_REQUEST_STATUS_RX 3 +#define CONT_CMD_READ_BUTTON_RX 4 +#define CONT_CMD_READ_MEMPACK_RX 33 +#define CONT_CMD_WRITE_MEMPACK_RX 1 +#define CONT_CMD_READ_EEPROM_RX 8 +#define CONT_CMD_WRITE_EEPROM_RX 1 +#define CONT_CMD_RESET_RX 3 + +#define CONT_CMD_NOP 0xff +#define CONT_CMD_END 0xfe //indicates end of a command +#define CONT_CMD_EXE 1 //set pif ram status byte to this to do a command + +#define DIR_STATUS_EMPTY 0 +#define DIR_STATUS_UNKNOWN 1 +#define DIR_STATUS_OCCUPIED 2 + + +typedef struct +{ + /* 0x0 */ __OSInode inode; + /* 0x100 */ u8 bank; + /* 0x101 */ u8 map[256]; +} __OSInodeCache; + +extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *); +u16 __osSumcalc(u8 *ptr, int length); +s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); +s32 __osRepairPackId(OSPfs *pfs, __OSPackId *badid, __OSPackId *newid); +s32 __osCheckPackId(OSPfs *pfs, __OSPackId *temp); +s32 __osGetId(OSPfs *pfs); +s32 __osCheckId(OSPfs *pfs); +s32 __osPfsRWInode(OSPfs *pfs, __OSInode *inode, u8 flag, u8 bank); +s32 __osPfsSelectBank(OSPfs *pfs, u8 bank); +s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int file_size_in_pages, int *first_page, u8 bank, int *decleared, int *last_page); +s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 start_page, u8 bank, __OSInodeUnit *last_page); +s32 __osBlockSum(OSPfs *pfs, u8 page_no, u16 *sum, u8 bank); +s32 __osContRamRead(OSMesgQueue *mq, int channel, u16 address, u8 *buffer); +s32 __osContRamWrite(OSMesgQueue *mq, int channel, u16 address, u8 *buffer, int force); +void __osContGetInitData(u8 *pattern, OSContStatus *data); +void __osPackRequestData(u8 cmd); +void __osPfsRequestData(u8 cmd); +void __osPfsGetInitData(u8* pattern, OSContStatus* data); +u8 __osContAddressCrc(u16 addr); +u8 __osContDataCrc(u8 *data); +s32 __osPfsGetStatus(OSMesgQueue *queue, int channel); +s32 __osGbpakSelectBank(OSPfs *pfs, u8 bank); + +extern u8 __osContLastCmd; +extern OSTimer __osEepromTimer; +extern OSMesg __osEepromTimerMsg; +extern OSMesgQueue __osEepromTimerQ; +extern OSPifRam __osEepPifRam; +extern OSPifRam __osContPifRam; +extern OSPifRam __osPfsPifRam; +extern u8 __osMaxControllers; + +//some version of this almost certainly existed since there's plenty of times where it's used right before a return 0 +#define ERRCK(fn) \ + ret = fn; \ + if (ret != 0) \ + return ret; + +#define SET_ACTIVEBANK_TO_ZERO \ + if (pfs->activebank != 0) \ + { \ + pfs->activebank = 0; \ + ERRCK(__osPfsSelectBank(pfs)) \ + } + +#define PFS_CHECK_ID \ + if (__osCheckId(pfs) == PFS_ERR_NEW_PACK) \ + return PFS_ERR_NEW_PACK; +#endif + +#define PFS_CHECK_STATUS \ + if ((pfs->status & PFS_INITIALIZED) == 0) \ + return PFS_ERR_INVALID; + +#define PFS_GET_STATUS \ + __osSiGetAccess(); \ + ret = __osPfsGetStatus(queue, channel); \ + __osSiRelAccess(); \ + if (ret != 0) \ + return ret; diff --git a/src/lib/ultra/io/crc.c b/src/lib/ultra/io/crc.c index 83b2659a6..eed604c88 100644 --- a/src/lib/ultra/io/crc.c +++ b/src/lib/ultra/io/crc.c @@ -1,8 +1,4 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include u8 __osContAddressCrc(u16 inaddr) { diff --git a/src/lib/ultra/io/devmgr.c b/src/lib/ultra/io/devmgr.c index 6c18af4ee..4427ce838 100644 --- a/src/lib/ultra/io/devmgr.c +++ b/src/lib/ultra/io/devmgr.c @@ -1,6 +1,6 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include +#include "piint.h" void __osDevMgrMain(void *args) { diff --git a/src/lib/ultra/io/dpctr.c b/src/lib/ultra/io/dpctr.c index f1cd1645d..c9504bd07 100644 --- a/src/lib/ultra/io/dpctr.c +++ b/src/lib/ultra/io/dpctr.c @@ -1,5 +1,5 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include void osDpGetCounters(u32 *array) { diff --git a/src/lib/ultra/io/dpgetstat.c b/src/lib/ultra/io/dpgetstat.c index cc5ed1dfb..4d2ffc80f 100644 --- a/src/lib/ultra/io/dpgetstat.c +++ b/src/lib/ultra/io/dpgetstat.c @@ -1,4 +1,5 @@ -#include +#include +#include u32 osDpGetStatus() { diff --git a/src/lib/ultra/io/dpsetstat.c b/src/lib/ultra/io/dpsetstat.c index 2fd495208..dea6190c1 100644 --- a/src/lib/ultra/io/dpsetstat.c +++ b/src/lib/ultra/io/dpsetstat.c @@ -1,5 +1,5 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include void osDpSetStatus(u32 data) { diff --git a/src/lib/ultra/io/epirawdma.c b/src/lib/ultra/io/epirawdma.c index ec7d0b8ea..c265d9807 100644 --- a/src/lib/ultra/io/epirawdma.c +++ b/src/lib/ultra/io/epirawdma.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include "piint.h" s32 osEPiRawStartDma(OSPiHandle *handle, s32 direction, u32 devAddr, void *dramAddr, u32 size) { diff --git a/src/lib/ultra/io/epirawread.c b/src/lib/ultra/io/epirawread.c index 0d1e645a0..891df9180 100644 --- a/src/lib/ultra/io/epirawread.c +++ b/src/lib/ultra/io/epirawread.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include "piint.h" s32 osEPiRawReadIo(OSPiHandle *handle, u32 devAddr, u32 *data) { diff --git a/src/lib/ultra/io/epirawwrite.c b/src/lib/ultra/io/epirawwrite.c index 1f46ec449..f5798b179 100644 --- a/src/lib/ultra/io/epirawwrite.c +++ b/src/lib/ultra/io/epirawwrite.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "piint.h" s32 osEPiRawWriteIo(OSPiHandle *handle, u32 devAddr, u32 data) { diff --git a/src/lib/ultra/io/gbpakcheckconnector.c b/src/lib/ultra/io/gbpakcheckconnector.c index 06cd0b569..a5fedc786 100644 --- a/src/lib/ultra/io/gbpakcheckconnector.c +++ b/src/lib/ultra/io/gbpakcheckconnector.c @@ -1,8 +1,6 @@ -#include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" /** * The internal operations performed by the osGbpakCheckConnector function are @@ -49,7 +47,7 @@ s32 osGbpakCheckConnector(OSPfs *pfs, u8 *status) u16 blocknum; u8 blocks[3][4][0x20]; u8 blocksloaded[3][4]; - bool stilllooking; + s32 stilllooking; ret = osGbpakGetStatus(pfs, status); @@ -152,7 +150,7 @@ s32 osGbpakCheckConnector(OSPfs *pfs, u8 *status) // Compare them and bail out if different if (bcmp(blocks[thisslot][blocknum], blocks[0][blocknum], 32) != 0) { - stilllooking = false; + stilllooking = 0; goto end; } diff --git a/src/lib/ultra/io/gbpakgetstatus.c b/src/lib/ultra/io/gbpakgetstatus.c index 282da88b4..d9aec147c 100644 --- a/src/lib/ultra/io/gbpakgetstatus.c +++ b/src/lib/ultra/io/gbpakgetstatus.c @@ -1,9 +1,6 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" s32 osGbpakGetStatus(OSPfs *pfs, u8 *status) { diff --git a/src/lib/ultra/io/gbpakinit.c b/src/lib/ultra/io/gbpakinit.c index 078aaeebd..bd89ce997 100644 --- a/src/lib/ultra/io/gbpakinit.c +++ b/src/lib/ultra/io/gbpakinit.c @@ -1,15 +1,12 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" OSTimer var80090ab0; OSMesgQueue var80090ad0; OSMesg var80090ae8; -s32 osGbpakInit(OSMesgQueue *queue, OSPfs *pfs, s32 channel) +s32 osGbpakInit(OSMesgQueue *queue, OSPfs *pfs, int channel) { s32 ret; s32 i; diff --git a/src/lib/ultra/io/gbpakpower.c b/src/lib/ultra/io/gbpakpower.c index f3f73ea1c..53f142aa9 100644 --- a/src/lib/ultra/io/gbpakpower.c +++ b/src/lib/ultra/io/gbpakpower.c @@ -1,9 +1,10 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" + +extern OSTimer var80090ab0; +extern OSMesgQueue var80090ad0; +extern OSMesg var80090ae8; s32 osGbpakPower(OSPfs *pfs, s32 flag) { diff --git a/src/lib/ultra/io/gbpakreadid.c b/src/lib/ultra/io/gbpakreadid.c index bbd08cce7..f2dac752a 100644 --- a/src/lib/ultra/io/gbpakreadid.c +++ b/src/lib/ultra/io/gbpakreadid.c @@ -1,9 +1,6 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" u32 g_OsGbNintendoData[] = { 0xceed6666, 0xcc0d000b, 0x03730083, 0x000c000d, diff --git a/src/lib/ultra/io/gbpakreadwrite.c b/src/lib/ultra/io/gbpakreadwrite.c index ab5346881..ff5f81506 100644 --- a/src/lib/ultra/io/gbpakreadwrite.c +++ b/src/lib/ultra/io/gbpakreadwrite.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 osGbpakReadWrite(OSPfs *pfs, u16 flag, u16 address, u8 *buffer, u16 size) { diff --git a/src/lib/ultra/io/gbpakselectbank.c b/src/lib/ultra/io/gbpakselectbank.c index 1cc5f7fb6..c119a01ee 100644 --- a/src/lib/ultra/io/gbpakselectbank.c +++ b/src/lib/ultra/io/gbpakselectbank.c @@ -1,9 +1,6 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" s32 __osGbpakSelectBank(OSPfs *pfs, u8 bank) { diff --git a/src/lib/ultra/io/motor.c b/src/lib/ultra/io/motor.c index 020b3a207..45eaa421a 100644 --- a/src/lib/ultra/io/motor.c +++ b/src/lib/ultra/io/motor.c @@ -1,13 +1,10 @@ -#include -#include "constants.h" -#include "bss.h" -#include "lib/mtx.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" OSPifRam osPifBuffers[MAXCONTROLLERS]; -s32 osMotorAccess(OSPfs *pfs, u32 vibrate) +s32 __osMotorAccess(OSPfs *pfs, s32 vibrate) { s32 i; s32 ret; diff --git a/src/lib/ultra/io/pfsallocatefile.c b/src/lib/ultra/io/pfsallocatefile.c index f8d48d416..0d436c6ec 100644 --- a/src/lib/ultra/io/pfsallocatefile.c +++ b/src/lib/ultra/io/pfsallocatefile.c @@ -1,17 +1,13 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" -s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, s32 fileSizeInPages, s32 *startPage, u8 bank, s32 *decleared, s32 *finalPage); +s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int fileSizeInPages, int *startPage, u8 bank, int *decleared, int *finalPage); -s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name, s32 num_bytes, s32 *file_no) +s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name, int num_bytes, s32 *file_no) { - s32 startPage; - s32 decleared; - s32 prevPage; + int startPage; + int decleared; + int prevPage; s32 oldPrevPage = 0; s32 ret = 0; s32 fileSizeInPages; @@ -28,7 +24,7 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_na return PFS_ERR_INVALID; } - fileSizeInPages = (num_bytes + PFS_PAGE_SIZE - 1) / PFS_PAGE_SIZE; + fileSizeInPages = (num_bytes + 255) / (BLOCKSIZE * PFS_ONE_PAGE); if ((ret = osPfsFindFile(pfs, company_code, game_code, game_name, ext_name, file_no)) != 0 && ret != PFS_ERR_INVALID) { @@ -114,20 +110,20 @@ s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_na return __osContRamWrite(pfs->queue, pfs->channel, pfs->dir_table + *file_no, (u8*)&dir, 0); } -s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, s32 fileSizeInPages, s32 *startPage, u8 bank, s32 *decleared, s32 *finalPage) +s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int fileSizeInPages, int *startPage, u8 bank, int *decleared, int *finalPage) { s32 j; s32 spage, prevPage; s32 ret = 0; s32 offset = (bank > 0) ? 1 : pfs->inode_start_page; - for (j = offset; j < PFS_INODE_SIZE_PER_PAGE; j++) { - if (inode->inode_page[j].ipage == PFS_PAGE_NOT_USED) { + for (j = offset; j < ARRLEN(inode->inode_page); j++) { + if (inode->inode_page[j].ipage == 3) { break; } } - if (j == PFS_INODE_SIZE_PER_PAGE) { + if (j == ARRLEN(inode->inode_page)) { *startPage = -1; return ret; } @@ -137,8 +133,8 @@ s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, s32 fileSizeInPages, s32 *s prevPage = j; j++; - while (fileSizeInPages > *decleared && j < PFS_INODE_SIZE_PER_PAGE) { - if (inode->inode_page[j].ipage == PFS_PAGE_NOT_USED) { + while (fileSizeInPages > *decleared && j < ARRLEN(inode->inode_page)) { + if (inode->inode_page[j].ipage == 3) { inode->inode_page[prevPage].inode_t.bank = (u8)bank; inode->inode_page[prevPage].inode_t.page = (u8)j; prevPage = j; @@ -150,7 +146,7 @@ s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, s32 fileSizeInPages, s32 *s *startPage = spage; - if (j == PFS_INODE_SIZE_PER_PAGE && fileSizeInPages > *decleared) { + if (j == ARRLEN(inode->inode_page) && fileSizeInPages > *decleared) { *finalPage = prevPage; } else { inode->inode_page[prevPage].ipage = 1; diff --git a/src/lib/ultra/io/pfschecker.c b/src/lib/ultra/io/pfschecker.c index 001e45679..16bfcbeeb 100644 --- a/src/lib/ultra/io/pfschecker.c +++ b/src/lib/ultra/io/pfschecker.c @@ -1,10 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "lib/libc/ll.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 corrupted_init(OSPfs *pfs, __OSInodeCache *cache); s32 corrupted(OSPfs *pfs, __OSInodeUnit fpage, __OSInodeCache *cache); diff --git a/src/lib/ultra/io/pfsdeletefile.c b/src/lib/ultra/io/pfsdeletefile.c index 11be40ff4..d2ecc0d7e 100644 --- a/src/lib/ultra/io/pfsdeletefile.c +++ b/src/lib/ultra/io/pfsdeletefile.c @@ -1,10 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "lib/libc/ll.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name) { @@ -77,7 +72,7 @@ s32 __osPfsReleasePages(OSPfs *pfs, __OSInode *inode, u8 initial_page, u8 bank, do { prev = next; next = inode->inode_page[next.inode_t.page]; - inode->inode_page[prev.inode_t.page].ipage = PFS_PAGE_NOT_USED; + inode->inode_page[prev.inode_t.page].ipage = 3; } while (next.ipage >= pfs->inode_start_page && next.inode_t.bank == bank); *final_page = next; diff --git a/src/lib/ultra/io/pfsfilestate.c b/src/lib/ultra/io/pfsfilestate.c index 05ea04c4e..a57e7a3ce 100644 --- a/src/lib/ultra/io/pfsfilestate.c +++ b/src/lib/ultra/io/pfsfilestate.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 osPfsFileState(OSPfs *pfs, s32 fileNo, OSPfsState *state) { @@ -42,7 +38,7 @@ s32 osPfsFileState(OSPfs *pfs, s32 fileNo, OSPfsState *state) pages = 0; bank = 0xff; - while (true) { + while (TRUE) { if (page.ipage < pfs->inode_start_page) { break; } diff --git a/src/lib/ultra/io/pfsfindfile.c b/src/lib/ultra/io/pfsfindfile.c index 391e61319..65b3c71c5 100644 --- a/src/lib/ultra/io/pfsfindfile.c +++ b/src/lib/ultra/io/pfsfindfile.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, s32 *file_no) { diff --git a/src/lib/ultra/io/pfsfreeblocks.c b/src/lib/ultra/io/pfsfreeblocks.c index 88cc28a3e..c52d30912 100644 --- a/src/lib/ultra/io/pfsfreeblocks.c +++ b/src/lib/ultra/io/pfsfreeblocks.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 osPfsFreeBlocks(OSPfs *pfs, s32 *remaining) { @@ -29,8 +25,8 @@ s32 osPfsFreeBlocks(OSPfs *pfs, s32 *remaining) offset = ((bank > 0) ? 1 : pfs->inode_start_page); - for (j = offset; j < PFS_INODE_SIZE_PER_PAGE; j++) { - if (inode.inode_page[j].ipage == PFS_PAGE_NOT_USED) { + for (j = offset; j < ARRLEN(inode.inode_page); j++) { + if (inode.inode_page[j].ipage == 3) { pages++; } } diff --git a/src/lib/ultra/io/pfsgetstatus.c b/src/lib/ultra/io/pfsgetstatus.c index 95deef075..66aad1d85 100644 --- a/src/lib/ultra/io/pfsgetstatus.c +++ b/src/lib/ultra/io/pfsgetstatus.c @@ -1,10 +1,12 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include "controller.h" +#include "siint.h" void __osPfsRequestOneChannel(int channel, u8 cmd); void __osPfsGetOneChannelData(int channel, OSContStatus *data); +extern u8 g_PfsPrevBank; + s32 __osPfsGetStatus(OSMesgQueue *queue, int channel) { s32 ret; diff --git a/src/lib/ultra/io/pfsinitpak.c b/src/lib/ultra/io/pfsinitpak.c index 5d7a4db56..51224086b 100644 --- a/src/lib/ultra/io/pfsinitpak.c +++ b/src/lib/ultra/io/pfsinitpak.c @@ -1,10 +1,7 @@ #include "versions.h" -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" s32 __osPfsCheckRamArea(OSPfs* pfs); s32 func00007084(OSPfs *pfs); @@ -47,7 +44,7 @@ s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel) ret = __osCheckPackId(pfs, id); if (ret != 0) { - pfs->status |= 4; + pfs->status |= PFS_ID_BROKEN; return ret; } } @@ -56,8 +53,8 @@ s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel) ret = __osRepairPackId(pfs, id, &newid); if (ret != 0) { - if (ret == 10) { - pfs->status |= 4; + if (ret == PFS_ERR_ID_FATAL) { + pfs->status |= PFS_ID_BROKEN; } return ret; diff --git a/src/lib/ultra/io/pfsinitpak2.c b/src/lib/ultra/io/pfsinitpak2.c index 6bbe27e16..4d1075b6e 100644 --- a/src/lib/ultra/io/pfsinitpak2.c +++ b/src/lib/ultra/io/pfsinitpak2.c @@ -1,9 +1,7 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include "versions.h" +#include +#include "controller.h" +#include "siint.h" s32 __osPfsCheckRamArea2(OSPfs* pfs); diff --git a/src/lib/ultra/io/pfsisplug.c b/src/lib/ultra/io/pfsisplug.c index 488ba194c..897c36a46 100644 --- a/src/lib/ultra/io/pfsisplug.c +++ b/src/lib/ultra/io/pfsisplug.c @@ -1,6 +1,6 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include "controller.h" +#include "siint.h" OSPifRam __osPfsPifRam; diff --git a/src/lib/ultra/io/pfsnumfiles.c b/src/lib/ultra/io/pfsnumfiles.c index 6086c88ca..ac0f2a78c 100644 --- a/src/lib/ultra/io/pfsnumfiles.c +++ b/src/lib/ultra/io/pfsnumfiles.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" s32 osPfsNumFiles(OSPfs *pfs, s32 *max_files, s32 *files_used) { diff --git a/src/lib/ultra/io/pfsreadwritefile.c b/src/lib/ultra/io/pfsreadwritefile.c index 784c81a91..dd29b015e 100644 --- a/src/lib/ultra/io/pfsreadwritefile.c +++ b/src/lib/ultra/io/pfsreadwritefile.c @@ -1,9 +1,5 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" #define CHECK_IPAGE(p, pfs) \ (((p).ipage >= (pfs).inode_start_page) && ((p).inode_t.bank < (pfs).banks) && ((p).inode_t.page >= 0x01) && \ @@ -34,7 +30,7 @@ s32 __osPfsGetNextPage(OSPfs *pfs, u8 *bank, __OSInode *inode, __OSInodeUnit *pa return 0; } -s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8* data) +s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, int offset, int size, u8* data) { s32 ret; __OSDir dir; @@ -86,7 +82,7 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8 return PFS_ERR_INCONSISTENT; } - if (flag == PFS_READ && ((dir.status & PFS_WRITTEN) == 0)) { + if (flag == PFS_READ && ((dir.status & DIR_STATUS_OCCUPIED) == 0)) { return PFS_ERR_BAD_DATA; } @@ -135,8 +131,8 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 fileNo, u8 flag, s32 offset, s32 size, u8 blockSize--; } - if (flag == PFS_WRITE && !(dir.status & PFS_WRITTEN)) { - dir.status |= PFS_WRITTEN; + if (flag == PFS_WRITE && !(dir.status & DIR_STATUS_OCCUPIED)) { + dir.status |= DIR_STATUS_OCCUPIED; if (pfs->activebank != 0 && (ret = __osPfsSelectBank(pfs, 0)) != 0) { return ret; diff --git a/src/lib/ultra/io/pfsresizefile.c b/src/lib/ultra/io/pfsresizefile.c index 070633f20..f111a73c5 100644 --- a/src/lib/ultra/io/pfsresizefile.c +++ b/src/lib/ultra/io/pfsresizefile.c @@ -1,9 +1,6 @@ -#include -#include "libultra_internal.h" -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include +#include "controller.h" +#include "siint.h" GLOBAL_ASM( glabel osPfsReSizeFile diff --git a/src/lib/ultra/io/pfsselectbank.c b/src/lib/ultra/io/pfsselectbank.c index 145152726..8bc9d87fa 100644 --- a/src/lib/ultra/io/pfsselectbank.c +++ b/src/lib/ultra/io/pfsselectbank.c @@ -1,4 +1,5 @@ -#include +#include +#include "controller.h" s32 __osPfsSelectBank(OSPfs *pfs, u8 bank) { diff --git a/src/lib/ultra/io/piacs.c b/src/lib/ultra/io/piacs.c index 9bfcd9b52..649bede04 100644 --- a/src/lib/ultra/io/piacs.c +++ b/src/lib/ultra/io/piacs.c @@ -1,6 +1,4 @@ -#include -#include "data.h" -#include "bss.h" +#include OSMesg piAccessBuf; u32 var8009c7a4; diff --git a/src/lib/ultra/io/pidma.c b/src/lib/ultra/io/pidma.c index 106858231..75d758d1b 100644 --- a/src/lib/ultra/io/pidma.c +++ b/src/lib/ultra/io/pidma.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "piint.h" s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, u32 devAddr, void *dramAddr, u32 size, OSMesgQueue *mq) { diff --git a/src/lib/ultra/io/pigetcmdq.c b/src/lib/ultra/io/pigetcmdq.c index 52b67225b..2d71b5d5e 100644 --- a/src/lib/ultra/io/pigetcmdq.c +++ b/src/lib/ultra/io/pigetcmdq.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "piint.h" OSMesgQueue *osPiGetCmdQueue(void) { diff --git a/src/lib/ultra/io/piint.h b/src/lib/ultra/io/piint.h new file mode 100755 index 000000000..71a38edc6 --- /dev/null +++ b/src/lib/ultra/io/piint.h @@ -0,0 +1,116 @@ +#ifndef _PIINT_H +#define _PIINT_H +#include +#include + +//https://github.com/LuigiBlood/64dd/wiki/Memory-Map + +#define LEO_BASE_REG 0x05000000 + +#define LEO_CMD (LEO_BASE_REG + 0x508) +#define LEO_STATUS (LEO_BASE_REG + 0x508) + +#define LEO_BM_CTL (LEO_BASE_REG + 0x510) +#define LEO_BM_STATUS (LEO_BASE_REG + 0x510) + +#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518) +#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518) + +#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) //C2 Sector Buffer +#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) //Data Sector Buffer +#define LEO_DATA (LEO_BASE_REG + 0x500) //Data +#define LEO_MISC_REG (LEO_BASE_REG + 0x504) //Misc Register +#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) //Current Track +#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) //Sector Error Status +#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) //Current Sector +#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) //Hard Reset +#define LEO_C1_S0 (LEO_BASE_REG + 0x524) //C1 +#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) //Sector Size (in bytes) +#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) //C1 +#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) //Sectors per Block, Full Size +#define LEO_C1_S4 (LEO_BASE_REG + 0x534) //C1 +#define LEO_C1_S6 (LEO_BASE_REG + 0x538) //C1 +#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) //Current Address? +#define LEO_ID_REG (LEO_BASE_REG + 0x540) //ID +#define LEO_TEST_REG (LEO_BASE_REG + 0x544) //Test Read +#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) //Test Write +#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) //Microsequencer RAM + +#define LEO_STATUS_PRESENCE_MASK 0xFFFF + +#define LEO_STATUS_DATA_REQUEST 0x40000000 +#define LEO_STATUS_C2_TRANSFER 0x10000000 +#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000 +#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000 +#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000 +#define LEO_STATUS_DISK_PRESENT 0x01000000 +#define LEO_STATUS_BUSY_STATE 0x00800000 +#define LEO_STATUS_RESET_STATE 0x00400000 +#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000 +#define LEO_STATUS_HEAD_RETRACTED 0x00080000 +#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000 +#define LEO_STATUS_MECHANIC_ERROR 0x00020000 +#define LEO_STATUS_DISK_CHANGE 0x00010000 + +#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED) +#define LEO_STATUS_MODE_ACTIVE 0 + +#define LEO_CUR_TK_INDEX_LOCK 0x60000000 + +#define LEO_BM_STATUS_RUNNING 0x80000000 //Running +#define LEO_BM_STATUS_ERROR 0x04000000 //Error +#define LEO_BM_STATUS_MICRO 0x02000000 //Micro Status? +#define LEO_BM_STATUS_BLOCK 0x01000000 //Block Transfer +#define LEO_BM_STATUS_C1CORRECTION 0x00800000 //C1 Correction +#define LEO_BM_STATUS_C1DOUBLE 0x00400000 //C1 Double +#define LEO_BM_STATUS_C1SINGLE 0x00200000 //C1 Single +#define LEO_BM_STATUS_C1ERROR 0x00010000 //C1 Error + +#define LEO_BM_CTL_START 0x80000000 //Start Buffer Manager +#define LEO_BM_CTL_MODE 0x40000000 //Buffer Manager Mode +#define LEO_BM_CTL_IMASK 0x20000000 //BM Interrupt Mask +#define LEO_BM_CTL_RESET 0x10000000 //Buffer Manager Reset +#define LEO_BM_CTL_DISABLE_OR 0x08000000 //Disable OR Check? +#define LEO_BM_CTL_DISABLE_C1 0x04000000 //Disable C1 Correction +#define LEO_BM_CTL_BLOCK 0x02000000 //Block Transfer +#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 //Mechanic Interrupt Reset + +#define LEO_BM_CTL_CONTROL_MASK 0xFF000000 +#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000 +#define LEO_BM_CTL_SECTOR_SHIFT 16 + +#define LEO_CMD_TYPE_0 0 //TODO: name +#define LEO_CMD_TYPE_1 1 //TODO: name +#define LEO_CMD_TYPE_2 2 //TODO: name + +#define LEO_ERROR_GOOD 0 +#define LEO_ERROR_4 4 //maybe busy? +#define LEO_ERROR_22 22 // +#define LEO_ERROR_23 23 //unrecovered read error? +#define LEO_ERROR_24 24 //no reference position found? +#define LEO_ERROR_29 29 // + +extern OSDevMgr __osPiDevMgr; +extern OSPiHandle *__osCurrentHandle[2]; +extern OSPiHandle CartRomHandle; +extern OSPiHandle LeoDiskHandle; +extern OSMesgQueue __osPiAccessQueue; +extern u32 __osPiAccessQueueEnabled; + +int __osPiDeviceBusy(void); +void __osDevMgrMain(void *); +void __osPiCreateAccessQueue(void); +void __osPiRelAccess(void); +void __osPiGetAccess(void); +OSMesgQueue *osPiGetCmdQueue(void); + +#define OS_RAMROM_STACKSIZE 1024 + +#define WAIT_ON_IOBUSY(stat) \ + stat = IO_READ(PI_STATUS_REG); \ + while (stat & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) \ + stat = IO_READ(PI_STATUS_REG); + +#endif diff --git a/src/lib/ultra/io/pimgr.c b/src/lib/ultra/io/pimgr.c index 64c47c146..ad6af29e8 100644 --- a/src/lib/ultra/io/pimgr.c +++ b/src/lib/ultra/io/pimgr.c @@ -1,6 +1,5 @@ -#include -#include "bss.h" -#include "data.h" +#include +#include "piint.h" OSPiHandle CartRomHandle; OSPiHandle LeoDiskHandle; @@ -9,6 +8,9 @@ char piThreadStack[512]; OSMesgQueue piEventQueue; OSMesg piEventBuf[4]; +s32 osPiRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size); +s32 osEPiRawStartDma(OSPiHandle *handle, s32 direction, u32 devAddr, void *dramAddr, u32 size); + OSDevMgr __osPiDevMgr = {0}; OSPiHandle *__osPiTable = NULL; OSPiHandle *__osCurrentHandle[2] = { &CartRomHandle, &LeoDiskHandle }; diff --git a/src/lib/ultra/io/pirawdma.c b/src/lib/ultra/io/pirawdma.c index 387e516ae..ad02785b9 100644 --- a/src/lib/ultra/io/pirawdma.c +++ b/src/lib/ultra/io/pirawdma.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "piint.h" s32 osPiRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) { diff --git a/src/lib/ultra/io/pirawread.c b/src/lib/ultra/io/pirawread.c index 82551515b..4e705c825 100644 --- a/src/lib/ultra/io/pirawread.c +++ b/src/lib/ultra/io/pirawread.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include "controller.h" +#include "piint.h" s32 osPiRawReadIo(u32 devAddr, u32 *data) { diff --git a/src/lib/ultra/io/piread.c b/src/lib/ultra/io/piread.c index 71fd30920..7e35a7aae 100644 --- a/src/lib/ultra/io/piread.c +++ b/src/lib/ultra/io/piread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "piint.h" s32 osPiReadIo(u32 devAddr, u32 *data) { diff --git a/src/lib/ultra/io/si.c b/src/lib/ultra/io/si.c index 868472e3e..ae20ee978 100644 --- a/src/lib/ultra/io/si.c +++ b/src/lib/ultra/io/si.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "siint.h" int __osSiDeviceBusy() { diff --git a/src/lib/ultra/io/siacs.c b/src/lib/ultra/io/siacs.c index 2c855b391..09f10862e 100644 --- a/src/lib/ultra/io/siacs.c +++ b/src/lib/ultra/io/siacs.c @@ -1,6 +1,4 @@ -#include -#include "data.h" -#include "bss.h" +#include OSMesg siAccessBuf; u32 var8009c7c4; diff --git a/src/lib/ultra/io/siint.h b/src/lib/ultra/io/siint.h new file mode 100755 index 000000000..45bf56bfa --- /dev/null +++ b/src/lib/ultra/io/siint.h @@ -0,0 +1,10 @@ +#ifndef _SIINT_H +#define _SIINT_H +#include +#include + +void __osSiGetAccess(void); +void __osSiRelAccess(void); +int __osSiDeviceBusy(void); +void __osSiCreateAccessQueue(void); +#endif diff --git a/src/lib/ultra/io/sirawdma.c b/src/lib/ultra/io/sirawdma.c index 464027899..c03cadde0 100644 --- a/src/lib/ultra/io/sirawdma.c +++ b/src/lib/ultra/io/sirawdma.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "siint.h" s32 __osSiRawStartDma(s32 direction, void *dramAddr) { diff --git a/src/lib/ultra/io/sirawread.c b/src/lib/ultra/io/sirawread.c index 0b273778b..8cd3c2e0d 100644 --- a/src/lib/ultra/io/sirawread.c +++ b/src/lib/ultra/io/sirawread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "siint.h" s32 __osSiRawReadIo(u32 devAddr, u32 *data) { diff --git a/src/lib/ultra/io/sirawwrite.c b/src/lib/ultra/io/sirawwrite.c index 492e01ef0..ac0696367 100644 --- a/src/lib/ultra/io/sirawwrite.c +++ b/src/lib/ultra/io/sirawwrite.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "siint.h" s32 __osSiRawWriteIo(u32 devAddr, u32 data) { diff --git a/src/lib/ultra/io/sp.c b/src/lib/ultra/io/sp.c index bc84c1658..198756c7e 100644 --- a/src/lib/ultra/io/sp.c +++ b/src/lib/ultra/io/sp.c @@ -1,5 +1,7 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include +#include +#include "../os/osint.h" int __osSpDeviceBusy() { diff --git a/src/lib/ultra/io/spgetstat.c b/src/lib/ultra/io/spgetstat.c index 2c8832a60..374d47c05 100644 --- a/src/lib/ultra/io/spgetstat.c +++ b/src/lib/ultra/io/spgetstat.c @@ -1,5 +1,5 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include u32 __osSpGetStatus() { diff --git a/src/lib/ultra/io/sprawdma.c b/src/lib/ultra/io/sprawdma.c index 4c43a0bd0..ec58ac3a5 100644 --- a/src/lib/ultra/io/sprawdma.c +++ b/src/lib/ultra/io/sprawdma.c @@ -1,5 +1,6 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include +#include "../os/osint.h" s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) { diff --git a/src/lib/ultra/io/spsetpc.c b/src/lib/ultra/io/spsetpc.c index 87a2a4095..fa20c7603 100644 --- a/src/lib/ultra/io/spsetpc.c +++ b/src/lib/ultra/io/spsetpc.c @@ -1,5 +1,5 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include s32 __osSpSetPc(u32 data) { diff --git a/src/lib/ultra/io/spsetstat.c b/src/lib/ultra/io/spsetstat.c index 4dd087363..a72f4edaa 100644 --- a/src/lib/ultra/io/spsetstat.c +++ b/src/lib/ultra/io/spsetstat.c @@ -1,5 +1,5 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include void __osSpSetStatus(u32 data) { diff --git a/src/lib/ultra/io/sptask.c b/src/lib/ultra/io/sptask.c index 8b23a58da..b55161ca2 100644 --- a/src/lib/ultra/io/sptask.c +++ b/src/lib/ultra/io/sptask.c @@ -1,6 +1,7 @@ -#include -#include "libultra_internal.h" -#include "data.h" +#include +#include +#include +#include "../os/osint.h" OSTask tmp_task; diff --git a/src/lib/ultra/io/sptaskyield.c b/src/lib/ultra/io/sptaskyield.c index cec70651a..78637cec4 100644 --- a/src/lib/ultra/io/sptaskyield.c +++ b/src/lib/ultra/io/sptaskyield.c @@ -1,4 +1,5 @@ -#include +#include +#include void osSpTaskYield(void) { diff --git a/src/lib/ultra/io/sptaskyielded.c b/src/lib/ultra/io/sptaskyielded.c index 9853cc75d..6c0734476 100644 --- a/src/lib/ultra/io/sptaskyielded.c +++ b/src/lib/ultra/io/sptaskyielded.c @@ -1,5 +1,6 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include +#include OSYieldResult osSpTaskYielded(OSTask *tp) { diff --git a/src/lib/ultra/io/vi.c b/src/lib/ultra/io/vi.c index 83e49c720..1e7ef1650 100644 --- a/src/lib/ultra/io/vi.c +++ b/src/lib/ultra/io/vi.c @@ -1,5 +1,7 @@ -#include -#include "data.h" +#include +#include +#include +#include "viint.h" __OSViContext var800608b0[2] = {0}; __OSViContext *__osViCurr = &var800608b0[0]; diff --git a/src/lib/ultra/io/viblack.c b/src/lib/ultra/io/viblack.c index e08b649c6..f1451f933 100644 --- a/src/lib/ultra/io/viblack.c +++ b/src/lib/ultra/io/viblack.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void osViBlack(u8 active) { diff --git a/src/lib/ultra/io/vigetcurrcontext.c b/src/lib/ultra/io/vigetcurrcontext.c index c07b1d43a..315509fc9 100644 --- a/src/lib/ultra/io/vigetcurrcontext.c +++ b/src/lib/ultra/io/vigetcurrcontext.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" __OSViContext *__osViGetCurrentContext(void) { diff --git a/src/lib/ultra/io/vigetcurrframebuf.c b/src/lib/ultra/io/vigetcurrframebuf.c index 0a0c2f733..0236952fd 100644 --- a/src/lib/ultra/io/vigetcurrframebuf.c +++ b/src/lib/ultra/io/vigetcurrframebuf.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void *osViGetCurrentFramebuffer(void) { diff --git a/src/lib/ultra/io/vigetnextframebuf.c b/src/lib/ultra/io/vigetnextframebuf.c index e16ea5e02..dc7933729 100644 --- a/src/lib/ultra/io/vigetnextframebuf.c +++ b/src/lib/ultra/io/vigetnextframebuf.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void *osViGetNextFramebuffer(void) { diff --git a/src/lib/ultra/io/viint.h b/src/lib/ultra/io/viint.h new file mode 100755 index 000000000..f80e754ae --- /dev/null +++ b/src/lib/ultra/io/viint.h @@ -0,0 +1,70 @@ +#ifndef _VIINT_H +#define _VIINT_H +#include + +#define OS_TV_TYPE_PAL 0 +#define OS_TV_TYPE_NTSC 1 +#define OS_TV_TYPE_MPAL 2 + +//TODO: figure out what this is +#define VI_STATE_01 0x01 +#define VI_STATE_XSCALE_UPDATED 0x02 +#define VI_STATE_YSCALE_UPDATED 0x04 +#define VI_STATE_08 0x08 //related to control regs changing +#define VI_STATE_10 0x10 //swap buffer +#define VI_STATE_BLACK 0x20 //probably related to a black screen +#define VI_STATE_REPEATLINE 0x40 //repeat line? +#define VI_STATE_FADE 0x80 //fade + +#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */ +#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */ +#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */ + +#define VI_SCALE_MASK 0xfff //see rcp scale_x/scale_y +#define VI_2_10_FPART_MASK 0x3ff +#define VI_SUBPIXEL_SH 0x10 + +#define BURST(hsync_width, color_width, vsync_width, color_start) \ + (hsync_width | (color_width << 8) | (vsync_width << 16) | (color_start << 20)) +#define WIDTH(v) v +#define VSYNC(v) v +#define HSYNC(duration, leap) (duration | (leap << 16)) +#define LEAP(upper, lower) ((upper << 16) | lower) +#define START(start, end) ((start << 16) | end) + +#define FTOFIX(val, i, f) ((u32)(val * (f32)(1 << f)) & ((1 << (i + f)) - 1)) + +#define F210(val) FTOFIX(val, 2, 10) +#define SCALE(scaleup, off) (F210((1.0f / (f32)scaleup)) | (F210((f32)off) << 16)) + +#define VCURRENT(v) v //seemingly unused +#define ORIGIN(v) v +#define VINTR(v) v +#define HSTART START + +typedef struct +{ + /* 0x0 */ f32 factor; + /* 0x4 */ u16 offset; + /* 0x8 */ u32 scale; +} __OSViScale; + +typedef struct +{ + /* 0x0 */ u16 state; + /* 0x2 */ u16 retraceCount; + /* 0x4 */ void *framep; + /* 0x8 */ OSViMode *modep; + /* 0xC */ u32 control; + /* 0x10 */ OSMesgQueue *msgq; + /* 0x14 */ OSMesg msg; + /* 0x18 */ __OSViScale x; + /* 0x24 */ __OSViScale y; +} __OSViContext; + +void __osViSwapContext(void); +extern __OSViContext *__osViCurr; +extern __OSViContext *__osViNext; +__OSViContext *__osViGetCurrentContext(void); +void __osViInit(void); +#endif diff --git a/src/lib/ultra/io/vimgr.c b/src/lib/ultra/io/vimgr.c index 4fdad94bd..f91d42468 100644 --- a/src/lib/ultra/io/vimgr.c +++ b/src/lib/ultra/io/vimgr.c @@ -1,5 +1,7 @@ -#include -#include "bss.h" +#include +#include +#include "viint.h" +#include "../os/osint.h" OSDevMgr __osViDevMgr = {0}; u32 var8005cefc = 0; @@ -84,7 +86,7 @@ void viMgrMain(void *args) dm = (OSDevMgr *)args; - while (true) { + while (TRUE) { osRecvMesg(dm->evtQueue, (OSMesg) &mb, OS_MESG_BLOCK); switch (mb->hdr.type) { diff --git a/src/lib/ultra/io/vimodempallan1.c b/src/lib/ultra/io/vimodempallan1.c index 69050d034..e7751c5f2 100644 --- a/src/lib/ultra/io/vimodempallan1.c +++ b/src/lib/ultra/io/vimodempallan1.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include "viint.h" OSViMode osViModeMpalLan1 = { OS_VI_MPAL_LAN1, // type diff --git a/src/lib/ultra/io/vimodentsclan1.c b/src/lib/ultra/io/vimodentsclan1.c index 7af8d321b..06462fa67 100644 --- a/src/lib/ultra/io/vimodentsclan1.c +++ b/src/lib/ultra/io/vimodentsclan1.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include "viint.h" OSViMode osViModeNtscLan1 = { OS_VI_NTSC_LAN1, // type diff --git a/src/lib/ultra/io/vimodepallan1.c b/src/lib/ultra/io/vimodepallan1.c index 4ecdfcafe..a3682c674 100644 --- a/src/lib/ultra/io/vimodepallan1.c +++ b/src/lib/ultra/io/vimodepallan1.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include "viint.h" OSViMode osViModePalLan1 = { OS_VI_PAL_LAN1, // type diff --git a/src/lib/ultra/io/visetevent.c b/src/lib/ultra/io/visetevent.c index fb6e28d11..3b1628ea4 100644 --- a/src/lib/ultra/io/visetevent.c +++ b/src/lib/ultra/io/visetevent.c @@ -1,5 +1,5 @@ -#include "libultra_internal.h" -#include "data.h" +#include +#include "viint.h" void osViSetEvent(OSMesgQueue *mq, OSMesg m, u32 retraceCount) { diff --git a/src/lib/ultra/io/visetmode.c b/src/lib/ultra/io/visetmode.c index a9a69a925..38f6cc90e 100644 --- a/src/lib/ultra/io/visetmode.c +++ b/src/lib/ultra/io/visetmode.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void osViSetMode(OSViMode *modep) { diff --git a/src/lib/ultra/io/visetspecial.c b/src/lib/ultra/io/visetspecial.c index 8e069a74e..d618c85be 100644 --- a/src/lib/ultra/io/visetspecial.c +++ b/src/lib/ultra/io/visetspecial.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include "viint.h" void osViSetSpecialFeatures(u32 func) { diff --git a/src/lib/ultra/io/visetxscale.c b/src/lib/ultra/io/visetxscale.c index 8ec846533..0995bc5ad 100644 --- a/src/lib/ultra/io/visetxscale.c +++ b/src/lib/ultra/io/visetxscale.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void osViSetXScale(f32 value) { diff --git a/src/lib/ultra/io/visetyscale.c b/src/lib/ultra/io/visetyscale.c index a75773aaf..6b9603e20 100644 --- a/src/lib/ultra/io/visetyscale.c +++ b/src/lib/ultra/io/visetyscale.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void osViSetYScale(f32 value) { diff --git a/src/lib/ultra/io/viswapbuf.c b/src/lib/ultra/io/viswapbuf.c index d330b7eef..768d3d30e 100644 --- a/src/lib/ultra/io/viswapbuf.c +++ b/src/lib/ultra/io/viswapbuf.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "viint.h" void osViSwapBuffer(void *frameBufPtr) { diff --git a/src/lib/ultra/io/viswapcontext.c b/src/lib/ultra/io/viswapcontext.c index 2b212ec20..edd653956 100644 --- a/src/lib/ultra/io/viswapcontext.c +++ b/src/lib/ultra/io/viswapcontext.c @@ -1,5 +1,8 @@ -#include -#include "data.h" +#include +#include +#include "viint.h" + +extern u32 var8005cefc; void __osViSwapContext() { diff --git a/src/lib/ultra/io/vitbl.c b/src/lib/ultra/io/vitbl.c index 96e583ada..55fb22fbf 100644 --- a/src/lib/ultra/io/vitbl.c +++ b/src/lib/ultra/io/vitbl.c @@ -1,4 +1,6 @@ -#include +#include +#include +#include "viint.h" OSViMode osViModeTable[] = { {OS_VI_NTSC_LPN1, //type diff --git a/src/lib/ultra/libc/ldiv.c b/src/lib/ultra/libc/ldiv.c index 3eda0aa29..3a7d57c14 100644 --- a/src/lib/ultra/libc/ldiv.c +++ b/src/lib/ultra/libc/ldiv.c @@ -1,4 +1,4 @@ -#include "lib/libc/ldiv.h" +#include lldiv_t lldiv(long long num, long long denom) { diff --git a/src/lib/ultra/libc/xldtob.c b/src/lib/ultra/libc/xldtob.c index e19f335bb..4869b4c74 100644 --- a/src/lib/ultra/libc/xldtob.c +++ b/src/lib/ultra/libc/xldtob.c @@ -1,6 +1,7 @@ -#include +#include +#include +#include "xstdio.h" -u32 _Ldtob(void); short _Ldunscale(short *pex, printf_struct *px); void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp); @@ -25,6 +26,34 @@ const u32 var70052514[] = {0x7f73bf3c}; const u32 var70052518[] = {0x4e614e00}; const u32 var7005251c[] = {0x496e6600}; +/* float properties */ +#define _D0 0 +#define _DBIAS 0x3ff +#define _DLONG 1 +#define _DOFF 4 +#define _FBIAS 0x7e +#define _FOFF 7 +#define _FRND 1 +#define _LBIAS 0x3ffe +#define _LOFF 15 + +/* integer properties */ +#define _C2 1 +#define _CSIGN 1 +#define _ILONG 0 +#define _MBMAX 8 +#define NAN 2 +#define INF 1 +#define FINITE -1 +#define _DFRAC ((1 << _DOFF) - 1) +#define _DMASK (0x7fff & ~_DFRAC) +#define _DMAX ((1 << (15 - _DOFF)) - 1) +#define _DNAN (0x8000 | _DMAX << _DOFF | 1 << (_DOFF - 1)) +#define _DSIGN 0x8000 +#define _D1 1 /* big-endian order */ +#define _D2 2 +#define _D3 3 + GLOBAL_ASM( glabel _Ldtob /* 4c50: 27bdff20 */ addiu $sp,$sp,-224 diff --git a/src/lib/ultra/libc/xlitob.c b/src/lib/ultra/libc/xlitob.c index b8a77d1e0..d90dcd5c1 100644 --- a/src/lib/ultra/libc/xlitob.c +++ b/src/lib/ultra/libc/xlitob.c @@ -1,6 +1,5 @@ #include -#include "data.h" -#include "lib/libc/ldiv.h" +#include "xstdio.h" #define BUFF_LEN 0x18 diff --git a/src/lib/ultra/libc/xprintf.c b/src/lib/ultra/libc/xprintf.c index a624b6c09..151b1d4ba 100644 --- a/src/lib/ultra/libc/xprintf.c +++ b/src/lib/ultra/libc/xprintf.c @@ -1,6 +1,6 @@ -#include -#include "lib/libc/xprintf.h" -#include "constants.h" +#include +#include +#include "xstdio.h" char spaces[] = " "; char zeroes[] = "00000000000000000000000000000000"; diff --git a/src/lib/ultra/libc/xstdio.h b/src/lib/ultra/libc/xstdio.h new file mode 100755 index 000000000..178b654c2 --- /dev/null +++ b/src/lib/ultra/libc/xstdio.h @@ -0,0 +1,38 @@ +#ifndef _XSTDIO_H +#define _XSTDIO_H +#include +#include +#include + +typedef struct +{ + union { + /* 00 */ long long s64; + double f64; + } value; + /* 08 */ char *buff; + /* 0c */ int n0; + /* 10 */ int num_leading_zeros; + /* 14 */ int part2_len; + /* 18 */ int num_mid_zeros; + /* 1c */ int part3_len; + /* 20 */ int num_trailing_zeros; + /* 24 */ int precision; + /* 28 */ int width; + /* 2c */ unsigned int size; + /* 30 */ unsigned int flags; + /* 34 */ char length; +} printf_struct; + +#define FLAGS_SPACE 1 +#define FLAGS_PLUS 2 +#define FLAGS_MINUS 4 +#define FLAGS_HASH 8 +#define FLAGS_ZERO 16 +typedef char *outfun(char*,const char*,size_t); + +int _Printf(outfun prout, char *arg, const char *fmt, va_list args); +void _Litob(printf_struct *args, char type); +void _Ldtob(printf_struct *args, char type); + +#endif diff --git a/src/lib/ultra/os/atomic.c b/src/lib/ultra/os/atomic.c index e83ff0780..5bd1d07b4 100644 --- a/src/lib/ultra/os/atomic.c +++ b/src/lib/ultra/os/atomic.c @@ -1,5 +1,4 @@ -#include -#include "data.h" +#include int __osAtomicDec(unsigned int *p) { diff --git a/src/lib/ultra/os/createmesgqueue.c b/src/lib/ultra/os/createmesgqueue.c index 919bd99d6..790b4a2d0 100644 --- a/src/lib/ultra/os/createmesgqueue.c +++ b/src/lib/ultra/os/createmesgqueue.c @@ -1,5 +1,7 @@ -#include -#include "data.h" +#include +#include "osint.h" + +extern struct __osThreadTail __osThreadTail; void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 msgCount) { diff --git a/src/lib/ultra/os/createthread.c b/src/lib/ultra/os/createthread.c index 953d85a3e..b723fcac9 100644 --- a/src/lib/ultra/os/createthread.c +++ b/src/lib/ultra/os/createthread.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include "osint.h" void __osCleanupThread(void); diff --git a/src/lib/ultra/os/destroythread.c b/src/lib/ultra/os/destroythread.c index 9a823dc4d..6a7f66508 100644 --- a/src/lib/ultra/os/destroythread.c +++ b/src/lib/ultra/os/destroythread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" void osDestroyThread(OSThread *t) { diff --git a/src/lib/ultra/os/exceptvars.c b/src/lib/ultra/os/exceptvars.c index 1aedd87a8..676924820 100644 --- a/src/lib/ultra/os/exceptvars.c +++ b/src/lib/ultra/os/exceptvars.c @@ -1,6 +1,3 @@ #include -#include "constants.h" -#include "data.h" -#include "types.h" OSThread __osThreadSave; diff --git a/src/lib/ultra/os/getcurrfaultthread.c b/src/lib/ultra/os/getcurrfaultthread.c index f46be6c3b..393b126c8 100644 --- a/src/lib/ultra/os/getcurrfaultthread.c +++ b/src/lib/ultra/os/getcurrfaultthread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" OSThread *__osGetCurrFaultedThread() { diff --git a/src/lib/ultra/os/getmemsize.c b/src/lib/ultra/os/getmemsize.c index a71714316..a9de1b690 100644 --- a/src/lib/ultra/os/getmemsize.c +++ b/src/lib/ultra/os/getmemsize.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include GLOBAL_ASM( glabel osGetMemSize diff --git a/src/lib/ultra/os/getthreadpri.c b/src/lib/ultra/os/getthreadpri.c index 84cca28ef..43a2ff344 100644 --- a/src/lib/ultra/os/getthreadpri.c +++ b/src/lib/ultra/os/getthreadpri.c @@ -1,4 +1,4 @@ -#include +#include extern OSThread *__osRunningThread; diff --git a/src/lib/ultra/os/gettime.c b/src/lib/ultra/os/gettime.c index 876f176da..52b03b082 100644 --- a/src/lib/ultra/os/gettime.c +++ b/src/lib/ultra/os/gettime.c @@ -1,5 +1,5 @@ -#include -#include "bss.h" +#include +#include "osint.h" OSTime osGetTime() { diff --git a/src/lib/ultra/os/initialize.c b/src/lib/ultra/os/initialize.c index fba935f2e..74b1d6893 100644 --- a/src/lib/ultra/os/initialize.c +++ b/src/lib/ultra/os/initialize.c @@ -1,6 +1,7 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include +#include +#include typedef struct { unsigned int inst1; @@ -10,7 +11,7 @@ typedef struct { } __osExceptionVector; extern __osExceptionVector __osExceptionPreamble; -extern u32 osAppNMIBuffer; +extern s32 osAppNMIBuffer[]; u32 __osFinalRom; @@ -55,7 +56,7 @@ void osInitialize(void) osClockRate = osClockRate * 3 / 4; #endif - if (osResetType == RESET_TYPE_COLD_RESET) { + if (osResetType == 0 /*cold reset*/) { bzero(&osAppNMIBuffer, 0x40); } diff --git a/src/lib/ultra/os/initialize2.c b/src/lib/ultra/os/initialize2.c index 2a9201735..dc7de4bc8 100644 --- a/src/lib/ultra/os/initialize2.c +++ b/src/lib/ultra/os/initialize2.c @@ -1,6 +1,7 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include +#include +#include /** * Note: This file is included in PAL only. @@ -14,7 +15,7 @@ typedef struct { } __osExceptionVector; extern __osExceptionVector __osExceptionPreamble; -extern u32 osAppNMIBuffer; +extern s32 osAppNMIBuffer[]; u32 var80060fe0pf = 0; u32 var80060fe4pf = 62500000; diff --git a/src/lib/ultra/os/interrupt.c b/src/lib/ultra/os/interrupt.c index 3ee2e655c..f6d13fa37 100644 --- a/src/lib/ultra/os/interrupt.c +++ b/src/lib/ultra/os/interrupt.c @@ -1,6 +1,3 @@ -#include -#include "data.h" - GLOBAL_ASM( glabel __osDisableInt /* 495b0: 3c0a8006 */ lui $t2,%hi(__osGlobalIntMask) diff --git a/src/lib/ultra/os/jammesg.c b/src/lib/ultra/os/jammesg.c index a08f03489..b14650305 100644 --- a/src/lib/ultra/os/jammesg.c +++ b/src/lib/ultra/os/jammesg.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { diff --git a/src/lib/ultra/os/osint.h b/src/lib/ultra/os/osint.h new file mode 100755 index 000000000..d682fb62b --- /dev/null +++ b/src/lib/ultra/os/osint.h @@ -0,0 +1,49 @@ +#ifndef _OSINT_H +#define _OSINT_H +#include + +typedef struct __OSEventState +{ + OSMesgQueue *messageQueue; + OSMesg message; +} __OSEventState; + +extern struct __osThreadTail +{ + OSThread *next; + OSPri priority; +} __osThreadTail; + +//maybe should be in exceptasm.h? +extern void __osEnqueueAndYield(OSThread **); +extern void __osDequeueThread(OSThread **, OSThread *); +extern void __osEnqueueThread(OSThread **, OSThread *); +extern OSThread *__osPopThread(OSThread **); +extern void __osDispatchThread(void); + +extern void __osSetTimerIntr(OSTime); +extern OSTime __osInsertTimer(OSTimer *); +extern void __osTimerInterrupt(void); +extern u32 __osProbeTLB(void *); +extern int __osSpDeviceBusy(void); + +extern OSThread *__osRunningThread; +extern OSThread *__osActiveQueue; +extern OSThread *__osFaultedThread; +extern OSThread *__osRunQueue; + +extern OSTimer *__osTimerList; +extern OSTimer __osBaseTimer; +extern OSTime __osCurrentTime; +extern u32 __osBaseCounter; +extern u32 __osViIntrCount; +extern u32 __osTimerCounter; + +extern __OSEventState __osEventStateTab[OS_NUM_EVENTS]; + +//not sure if this should be here +extern s32 osViClock; +extern void __osTimerServicesInit(void); +extern s32 __osAiDeviceBusy(void); +extern int __osDpDeviceBusy(void); +#endif diff --git a/src/lib/ultra/os/recvmesg.c b/src/lib/ultra/os/recvmesg.c index edcf690af..e530b091c 100644 --- a/src/lib/ultra/os/recvmesg.c +++ b/src/lib/ultra/os/recvmesg.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flags) { diff --git a/src/lib/ultra/os/resetglobalintmask.c b/src/lib/ultra/os/resetglobalintmask.c index b656cc000..bfebf4530 100644 --- a/src/lib/ultra/os/resetglobalintmask.c +++ b/src/lib/ultra/os/resetglobalintmask.c @@ -1,5 +1,7 @@ -#include -#include "data.h" +#include +#include + +extern u32 __osGlobalIntMask; void __osResetGlobalIntMask(OSHWIntr interrupt) { diff --git a/src/lib/ultra/os/sendmesg.c b/src/lib/ultra/os/sendmesg.c index d98acc728..db529fb97 100644 --- a/src/lib/ultra/os/sendmesg.c +++ b/src/lib/ultra/os/sendmesg.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) { diff --git a/src/lib/ultra/os/seteventmesg.c b/src/lib/ultra/os/seteventmesg.c index 7295e940a..6ddfad143 100644 --- a/src/lib/ultra/os/seteventmesg.c +++ b/src/lib/ultra/os/seteventmesg.c @@ -1,11 +1,12 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include "osint.h" -__OSEventState __osEventStateTab[15]; +__OSEventState __osEventStateTab[OS_NUM_EVENTS]; u32 var80060890 = 0; +extern u32 _osShutdown; + void osSetEventMesg(OSEvent event, OSMesgQueue *mq, OSMesg msg) { register u32 saveMask = __osDisableInt(); diff --git a/src/lib/ultra/os/setglobalintmask.c b/src/lib/ultra/os/setglobalintmask.c index 38a0c43e5..4e87e2f26 100644 --- a/src/lib/ultra/os/setglobalintmask.c +++ b/src/lib/ultra/os/setglobalintmask.c @@ -1,5 +1,7 @@ -#include -#include "data.h" +#include +#include + +extern u32 __osGlobalIntMask; void __osSetGlobalIntMask(OSHWIntr mask) { diff --git a/src/lib/ultra/os/setthreadpri.c b/src/lib/ultra/os/setthreadpri.c index 4095df3ae..85194fae5 100644 --- a/src/lib/ultra/os/setthreadpri.c +++ b/src/lib/ultra/os/setthreadpri.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" void osSetThreadPri(OSThread *t, OSPri pri) { diff --git a/src/lib/ultra/os/settimer.c b/src/lib/ultra/os/settimer.c index 1f0270ba6..7d10f9e3c 100644 --- a/src/lib/ultra/os/settimer.c +++ b/src/lib/ultra/os/settimer.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" int osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMesg msg) { @@ -10,9 +10,9 @@ int osSetTimer(OSTimer *t, OSTime value, OSTime interval, OSMesgQueue *mq, OSMes t->interval = interval; if (value != 0) { - t->remaining = value; + t->value = value; } else { - t->remaining = interval; + t->value = interval; } t->mq = mq; diff --git a/src/lib/ultra/os/startthread.c b/src/lib/ultra/os/startthread.c index 5ab29a67a..82d93809c 100644 --- a/src/lib/ultra/os/startthread.c +++ b/src/lib/ultra/os/startthread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" void osStartThread(OSThread *t) { diff --git a/src/lib/ultra/os/stopthread.c b/src/lib/ultra/os/stopthread.c index bd15c7677..ba626731f 100644 --- a/src/lib/ultra/os/stopthread.c +++ b/src/lib/ultra/os/stopthread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" void osStopThread(OSThread *t) { diff --git a/src/lib/ultra/os/stoptimer.c b/src/lib/ultra/os/stoptimer.c index 81cc27abd..636ff2139 100644 --- a/src/lib/ultra/os/stoptimer.c +++ b/src/lib/ultra/os/stoptimer.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" int osStopTimer(OSTimer *t) { @@ -15,7 +15,7 @@ int osStopTimer(OSTimer *t) timep = t->next; if (timep != __osTimerList) { - timep->remaining += t->remaining; + timep->value += t->value; } t->prev->next = t->next; diff --git a/src/lib/ultra/os/syncputchars.c b/src/lib/ultra/os/syncputchars.c index afcee0437..341c8f1fa 100644 --- a/src/lib/ultra/os/syncputchars.c +++ b/src/lib/ultra/os/syncputchars.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include GLOBAL_ASM( glabel __osSyncPutChars diff --git a/src/lib/ultra/os/thread.c b/src/lib/ultra/os/thread.c index 32273c7b1..c3662d1ba 100644 --- a/src/lib/ultra/os/thread.c +++ b/src/lib/ultra/os/thread.c @@ -1,8 +1,7 @@ -#include -#include "data.h" +#include +#include "osint.h" -u32 __osThreadTail = 0x00000000; -u32 var80060934 = 0xffffffff; +struct __osThreadTail __osThreadTail = {0, -1}; OSThread *__osRunQueue = (OSThread *)&__osThreadTail; OSThread *__osActiveQueue = (OSThread *)&__osThreadTail; OSThread *__osRunningThread = NULL; diff --git a/src/lib/ultra/os/timerintr.c b/src/lib/ultra/os/timerintr.c index aedb5b906..0bd03af78 100644 --- a/src/lib/ultra/os/timerintr.c +++ b/src/lib/ultra/os/timerintr.c @@ -1,6 +1,5 @@ -#include -#include "data.h" -#include "bss.h" +#include +#include "osint.h" OSTimer var8009c760; OSTime __osCurrentTime; @@ -18,8 +17,8 @@ void __osTimerServicesInit(void) __osTimerList->prev = __osTimerList; __osTimerList->next = __osTimerList->prev; - __osTimerList->remaining = 0; - __osTimerList->interval = __osTimerList->remaining; + __osTimerList->value = 0; + __osTimerList->interval = __osTimerList->value; __osTimerList->mq = NULL; __osTimerList->msg = 0; } @@ -47,9 +46,9 @@ void __osTimerInterrupt(void) elapsed_cycles = count - __osTimerCounter; __osTimerCounter = count; - if (elapsed_cycles < t->remaining) { - t->remaining -= elapsed_cycles; - __osSetTimerIntr(t->remaining); + if (elapsed_cycles < t->value) { + t->value -= elapsed_cycles; + __osSetTimerIntr(t->value); return; } else { t->prev->next = t->next; @@ -62,7 +61,7 @@ void __osTimerInterrupt(void) } if (t->interval != 0) { - t->remaining = t->interval; + t->value = t->interval; __osInsertTimer(t); } } @@ -91,16 +90,16 @@ OSTime __osInsertTimer(OSTimer *t) savedMask = __osDisableInt(); - for (timep = __osTimerList->next, tim = t->remaining; - timep != __osTimerList && tim > timep->remaining; - tim -= timep->remaining, timep = timep->next) { + for (timep = __osTimerList->next, tim = t->value; + timep != __osTimerList && tim > timep->value; + tim -= timep->value, timep = timep->next) { ; } - t->remaining = tim; + t->value = tim; if (timep != __osTimerList) { - timep->remaining -= tim; + timep->value -= tim; } t->next = timep; diff --git a/src/lib/ultra/os/virtualtophysical.c b/src/lib/ultra/os/virtualtophysical.c index 518ef92ed..245d10457 100644 --- a/src/lib/ultra/os/virtualtophysical.c +++ b/src/lib/ultra/os/virtualtophysical.c @@ -1,5 +1,6 @@ -#include -#include "data.h" +#include +#include +#include "osint.h" u32 osVirtualToPhysical(void *addr) { diff --git a/src/lib/ultra/os/yieldthread.c b/src/lib/ultra/os/yieldthread.c index 9e3143a29..46547142b 100644 --- a/src/lib/ultra/os/yieldthread.c +++ b/src/lib/ultra/os/yieldthread.c @@ -1,5 +1,5 @@ -#include -#include "data.h" +#include +#include "osint.h" void osYieldThread(void) { diff --git a/src/lib/vi.c b/src/lib/vi.c index ed9f53f03..2a7ad4f82 100644 --- a/src/lib/vi.c +++ b/src/lib/vi.c @@ -12,7 +12,6 @@ #include "lib/vi.h" #include "lib/memory.h" #include "lib/mtx.h" -#include "lib/lib_30ce0.h" #include "data.h" #include "types.h"