summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--include/libu64/gfxprint.h4
-rw-r--r--lib/ultralib/.github/workflows/ci_gcc.yml2
-rw-r--r--lib/ultralib/.gitrepo4
-rw-r--r--lib/ultralib/Makefile61
-rw-r--r--lib/ultralib/README.md14
-rw-r--r--lib/ultralib/include/PR/os_libc.h7
-rw-r--r--lib/ultralib/include/PR/rcp.h9
-rw-r--r--lib/ultralib/include/PRinternal/controller.h (renamed from lib/ultralib/src/io/controller.h)6
-rw-r--r--lib/ultralib/include/PRinternal/controller_gbpak.h (renamed from lib/ultralib/src/io/controller_gbpak.h)0
-rw-r--r--lib/ultralib/include/PRinternal/controller_voice.h (renamed from lib/ultralib/src/io/controller_voice.h)0
-rw-r--r--lib/ultralib/include/PRinternal/dbgdefs.h (renamed from lib/ultralib/include/dbgdefs.h)0
-rw-r--r--lib/ultralib/include/PRinternal/dbgproto.h (renamed from lib/ultralib/include/dbgproto.h)2
-rw-r--r--lib/ultralib/include/PRinternal/macros.h (renamed from lib/ultralib/include/macros.h)8
-rw-r--r--lib/ultralib/include/PRinternal/osint.h (renamed from lib/ultralib/src/os/osint.h)0
-rw-r--r--lib/ultralib/include/PRinternal/piint.h (renamed from lib/ultralib/src/io/piint.h)0
-rw-r--r--lib/ultralib/include/PRinternal/rmonint.h (renamed from lib/ultralib/src/rmon/rmonint.h)2
-rw-r--r--lib/ultralib/include/PRinternal/siint.h (renamed from lib/ultralib/src/io/siint.h)0
-rw-r--r--lib/ultralib/include/PRinternal/viint.h (renamed from lib/ultralib/src/io/viint.h)6
-rw-r--r--lib/ultralib/include/compiler/gcc/math.h (renamed from lib/ultralib/include/gcc/math.h)0
-rw-r--r--lib/ultralib/include/compiler/gcc/memory.h (renamed from lib/ultralib/include/gcc/memory.h)0
-rw-r--r--lib/ultralib/include/compiler/gcc/sgidefs.h (renamed from lib/ultralib/include/gcc/sgidefs.h)0
-rw-r--r--lib/ultralib/include/compiler/gcc/stdarg.h (renamed from lib/ultralib/include/gcc/stdarg.h)0
-rw-r--r--lib/ultralib/include/compiler/gcc/stdio.h (renamed from lib/ultralib/include/gcc/stdio.h)0
-rw-r--r--lib/ultralib/include/compiler/gcc/stdlib.h (renamed from lib/ultralib/include/gcc/stdlib.h)0
-rw-r--r--lib/ultralib/include/compiler/gcc/string.h (renamed from lib/ultralib/include/gcc/string.h)0
-rw-r--r--lib/ultralib/include/compiler/ido/math.h (renamed from lib/ultralib/include/ido/math.h)0
-rw-r--r--lib/ultralib/include/compiler/ido/memory.h (renamed from lib/ultralib/include/ido/memory.h)0
-rw-r--r--lib/ultralib/include/compiler/ido/stdarg.h (renamed from lib/ultralib/include/ido/stdarg.h)0
-rw-r--r--lib/ultralib/include/compiler/ido/stdio.h (renamed from lib/ultralib/include/ido/stdio.h)0
-rw-r--r--lib/ultralib/include/compiler/ido/stdlib.h (renamed from lib/ultralib/include/ido/stdlib.h)0
-rw-r--r--lib/ultralib/include/compiler/ido/string.h (renamed from lib/ultralib/include/ido/string.h)0
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/math.h1
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/memory.h23
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/sgidefs.h44
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/stdarg.h9
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/stdio.h1
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/stdlib.h81
-rw-r--r--lib/ultralib/include/compiler/modern_gcc/string.h42
-rw-r--r--lib/ultralib/include/sys/asm.h31
-rw-r--r--lib/ultralib/makefiles/gcc.mk (renamed from lib/ultralib/Makefile.gcc)21
-rw-r--r--lib/ultralib/makefiles/ido.mk (renamed from lib/ultralib/Makefile.ido)12
-rw-r--r--lib/ultralib/makefiles/modern_gcc.mk21
-rw-r--r--lib/ultralib/src/debug/assert.c2
-rw-r--r--lib/ultralib/src/debug/profile.c12
-rw-r--r--lib/ultralib/src/debug/threadprofile.c2
-rw-r--r--lib/ultralib/src/error/commonerror.c6
-rw-r--r--lib/ultralib/src/error/error.c6
-rw-r--r--lib/ultralib/src/error/errorasm.s20
-rw-r--r--lib/ultralib/src/error/kmcprintf.c250
-rw-r--r--lib/ultralib/src/flash/flashinit.c10
-rw-r--r--lib/ultralib/src/gio/giointerrupt.c2
-rw-r--r--lib/ultralib/src/gio/giorawinterrupt.c2
-rw-r--r--lib/ultralib/src/gt/dumpturbo.c4
-rw-r--r--lib/ultralib/src/gu/loadtextureblockmipmap.c4
-rw-r--r--lib/ultralib/src/gu/mtxcatf.c126
-rw-r--r--lib/ultralib/src/gu/normalize.c46
-rw-r--r--lib/ultralib/src/gu/scale.c64
-rw-r--r--lib/ultralib/src/gu/translate.c62
-rw-r--r--lib/ultralib/src/host/host_ptn64.c4
-rw-r--r--lib/ultralib/src/host/readhost.c4
-rw-r--r--lib/ultralib/src/host/writehost.c4
-rw-r--r--lib/ultralib/src/io/aigetlen.c6
-rw-r--r--lib/ultralib/src/io/aigetstat.c2
-rw-r--r--lib/ultralib/src/io/aisetfreq.c17
-rw-r--r--lib/ultralib/src/io/aisetnextbuf.c14
-rw-r--r--lib/ultralib/src/io/cartrominit.c8
-rw-r--r--lib/ultralib/src/io/contchannelreset.c4
-rw-r--r--lib/ultralib/src/io/conteeplongread.c2
-rw-r--r--lib/ultralib/src/io/conteeplongwrite.c2
-rw-r--r--lib/ultralib/src/io/conteepprobe.c4
-rw-r--r--lib/ultralib/src/io/conteepread.c8
-rw-r--r--lib/ultralib/src/io/conteepwrite.c5
-rw-r--r--lib/ultralib/src/io/contpfs.c6
-rw-r--r--lib/ultralib/src/io/contquery.c11
-rw-r--r--lib/ultralib/src/io/contramread.c5
-rw-r--r--lib/ultralib/src/io/contramwrite.c5
-rw-r--r--lib/ultralib/src/io/contreaddata.c5
-rw-r--r--lib/ultralib/src/io/contreset.c4
-rw-r--r--lib/ultralib/src/io/controller.c16
-rw-r--r--lib/ultralib/src/io/contsetch.c8
-rw-r--r--lib/ultralib/src/io/crc.c136
-rw-r--r--lib/ultralib/src/io/devmgr.c2
-rw-r--r--lib/ultralib/src/io/dpgetstat.c2
-rw-r--r--lib/ultralib/src/io/dpsetnextbuf.c2
-rw-r--r--lib/ultralib/src/io/driverominit.c6
-rw-r--r--lib/ultralib/src/io/epidma.c2
-rw-r--r--lib/ultralib/src/io/epigettype.c2
-rw-r--r--lib/ultralib/src/io/epilinkhandle.c2
-rw-r--r--lib/ultralib/src/io/epirawdma.c2
-rw-r--r--lib/ultralib/src/io/epirawread.c2
-rw-r--r--lib/ultralib/src/io/epirawwrite.c2
-rw-r--r--lib/ultralib/src/io/epiread.c2
-rw-r--r--lib/ultralib/src/io/epiwrite.c2
-rw-r--r--lib/ultralib/src/io/gbpakcheckconnector.c4
-rw-r--r--lib/ultralib/src/io/gbpakgetbank.c2
-rw-r--r--lib/ultralib/src/io/gbpakgetstatus.c2
-rw-r--r--lib/ultralib/src/io/gbpakinit.c8
-rw-r--r--lib/ultralib/src/io/gbpakpower.c4
-rw-r--r--lib/ultralib/src/io/gbpakreadid.c4
-rw-r--r--lib/ultralib/src/io/gbpakreadwrite.c2
-rw-r--r--lib/ultralib/src/io/gbpaksetbank.c2
-rw-r--r--lib/ultralib/src/io/leodiskinit.c6
-rw-r--r--lib/ultralib/src/io/leointerrupt.c10
-rw-r--r--lib/ultralib/src/io/motor.c16
-rw-r--r--lib/ultralib/src/io/pfsallocatefile.c5
-rw-r--r--lib/ultralib/src/io/pfschecker.c15
-rw-r--r--lib/ultralib/src/io/pfsdeletefile.c7
-rw-r--r--lib/ultralib/src/io/pfsfilestate.c5
-rw-r--r--lib/ultralib/src/io/pfsfreeblocks.c5
-rw-r--r--lib/ultralib/src/io/pfsgetlabel.c3
-rw-r--r--lib/ultralib/src/io/pfsgetstatus.c4
-rw-r--r--lib/ultralib/src/io/pfsinit.c4
-rw-r--r--lib/ultralib/src/io/pfsinitpak.c5
-rw-r--r--lib/ultralib/src/io/pfsisplug.c8
-rw-r--r--lib/ultralib/src/io/pfsnumfiles.c2
-rw-r--r--lib/ultralib/src/io/pfsreadwritefile.c20
-rw-r--r--lib/ultralib/src/io/pfsreformat.c5
-rw-r--r--lib/ultralib/src/io/pfsrepairid.c3
-rw-r--r--lib/ultralib/src/io/pfssearchfile.c3
-rw-r--r--lib/ultralib/src/io/pfsselectbank.c2
-rw-r--r--lib/ultralib/src/io/pfssetlabel.c3
-rw-r--r--lib/ultralib/src/io/pi.c4
-rw-r--r--lib/ultralib/src/io/piacs.c4
-rw-r--r--lib/ultralib/src/io/pidma.c2
-rw-r--r--lib/ultralib/src/io/pigetcmdq.c2
-rw-r--r--lib/ultralib/src/io/pigetstat.c4
-rw-r--r--lib/ultralib/src/io/pigettype.c2
-rw-r--r--lib/ultralib/src/io/pimgr.c30
-rw-r--r--lib/ultralib/src/io/pirawdma.c2
-rw-r--r--lib/ultralib/src/io/pirawread.c2
-rw-r--r--lib/ultralib/src/io/pirawwrite.c2
-rw-r--r--lib/ultralib/src/io/piread.c2
-rw-r--r--lib/ultralib/src/io/piwrite.c2
-rw-r--r--lib/ultralib/src/io/si.c4
-rw-r--r--lib/ultralib/src/io/siacs.c6
-rw-r--r--lib/ultralib/src/io/sigetstat.c4
-rw-r--r--lib/ultralib/src/io/sirawdma.c12
-rw-r--r--lib/ultralib/src/io/sirawread.c2
-rw-r--r--lib/ultralib/src/io/sirawwrite.c2
-rw-r--r--lib/ultralib/src/io/sp.c4
-rw-r--r--lib/ultralib/src/io/spgetstat.c2
-rw-r--r--lib/ultralib/src/io/sprawdma.c2
-rw-r--r--lib/ultralib/src/io/sprawread.c2
-rw-r--r--lib/ultralib/src/io/sprawwrite.c2
-rw-r--r--lib/ultralib/src/io/sptask.c4
-rw-r--r--lib/ultralib/src/io/vi.c6
-rw-r--r--lib/ultralib/src/io/viblack.c2
-rw-r--r--lib/ultralib/src/io/viextendvstart.c2
-rw-r--r--lib/ultralib/src/io/vifade.c2
-rw-r--r--lib/ultralib/src/io/vigetcurrcontext.c2
-rw-r--r--lib/ultralib/src/io/vigetcurrframebuf.c2
-rw-r--r--lib/ultralib/src/io/vigetmode.c2
-rw-r--r--lib/ultralib/src/io/vigetnextcontext.c2
-rw-r--r--lib/ultralib/src/io/vigetnextframebuf.c2
-rw-r--r--lib/ultralib/src/io/vimgr.c18
-rw-r--r--lib/ultralib/src/io/virepeatline.c2
-rw-r--r--lib/ultralib/src/io/visetevent.c2
-rw-r--r--lib/ultralib/src/io/visetmode.c2
-rw-r--r--lib/ultralib/src/io/visetspecial.c15
-rw-r--r--lib/ultralib/src/io/visetxscale.c2
-rw-r--r--lib/ultralib/src/io/visetyscale.c2
-rw-r--r--lib/ultralib/src/io/viswapbuf.c2
-rw-r--r--lib/ultralib/src/io/viswapcontext.c6
-rw-r--r--lib/ultralib/src/io/vitbl.c368
-rw-r--r--lib/ultralib/src/libc/bcmp.s120
-rw-r--r--lib/ultralib/src/libc/bcopy.s326
-rw-r--r--lib/ultralib/src/libc/bzero.s78
-rw-r--r--lib/ultralib/src/libc/ll.c2
-rw-r--r--lib/ultralib/src/libc/llbit.c1
-rw-r--r--lib/ultralib/src/libc/sprintf.c14
-rw-r--r--lib/ultralib/src/libc/syncprintf.c11
-rw-r--r--lib/ultralib/src/libc/xldtob.c31
-rw-r--r--lib/ultralib/src/libc/xlitob.c38
-rw-r--r--lib/ultralib/src/libc/xprintf.c143
-rw-r--r--lib/ultralib/src/libc/xstdio.h17
-rw-r--r--lib/ultralib/src/log/delay.s12
-rw-r--r--lib/ultralib/src/log/log.c4
-rw-r--r--lib/ultralib/src/os/ackramromread.c2
-rw-r--r--lib/ultralib/src/os/ackramromwrite.c2
-rw-r--r--lib/ultralib/src/os/afterprenmi.c2
-rw-r--r--lib/ultralib/src/os/createmesgqueue.c2
-rw-r--r--lib/ultralib/src/os/createthread.c6
-rw-r--r--lib/ultralib/src/os/destroythread.c2
-rw-r--r--lib/ultralib/src/os/exceptasm.s450
-rw-r--r--lib/ultralib/src/os/exit.c2
-rw-r--r--lib/ultralib/src/os/getactivequeue.c2
-rw-r--r--lib/ultralib/src/os/getcause.s4
-rw-r--r--lib/ultralib/src/os/getcompare.s4
-rw-r--r--lib/ultralib/src/os/getconfig.s4
-rw-r--r--lib/ultralib/src/os/getcount.s4
-rw-r--r--lib/ultralib/src/os/getcurrfaultthread.c4
-rw-r--r--lib/ultralib/src/os/getfpccsr.s8
-rw-r--r--lib/ultralib/src/os/getintmask.s39
-rw-r--r--lib/ultralib/src/os/getnextfaultthread.c2
-rw-r--r--lib/ultralib/src/os/getsr.s4
-rw-r--r--lib/ultralib/src/os/getthreadid.c2
-rw-r--r--lib/ultralib/src/os/getthreadpri.c2
-rw-r--r--lib/ultralib/src/os/gettime.c6
-rw-r--r--lib/ultralib/src/os/gettlbasid.s6
-rw-r--r--lib/ultralib/src/os/gettlbhi.s8
-rw-r--r--lib/ultralib/src/os/gettlblo0.s8
-rw-r--r--lib/ultralib/src/os/gettlblo1.s8
-rw-r--r--lib/ultralib/src/os/gettlbpagemask.s8
-rw-r--r--lib/ultralib/src/os/getwatchlo.s4
-rw-r--r--lib/ultralib/src/os/initialize.c10
-rw-r--r--lib/ultralib/src/os/initialize_emu.c2
-rw-r--r--lib/ultralib/src/os/initialize_isv.c6
-rw-r--r--lib/ultralib/src/os/initialize_kmc.c2
-rw-r--r--lib/ultralib/src/os/initialize_msp.c2
-rw-r--r--lib/ultralib/src/os/interrupt.s65
-rw-r--r--lib/ultralib/src/os/invaldcache.s97
-rw-r--r--lib/ultralib/src/os/invalicache.s50
-rw-r--r--lib/ultralib/src/os/jammesg.c2
-rw-r--r--lib/ultralib/src/os/maptlb.s127
-rw-r--r--lib/ultralib/src/os/maptlbrdb.s33
-rw-r--r--lib/ultralib/src/os/probetlb.s95
-rw-r--r--lib/ultralib/src/os/recvmesg.c2
-rw-r--r--lib/ultralib/src/os/sendmesg.c2
-rw-r--r--lib/ultralib/src/os/setcause.s4
-rw-r--r--lib/ultralib/src/os/setcompare.s4
-rw-r--r--lib/ultralib/src/os/setconfig.s4
-rw-r--r--lib/ultralib/src/os/setcount.s4
-rw-r--r--lib/ultralib/src/os/seteventmesg.c6
-rw-r--r--lib/ultralib/src/os/setfpccsr.s10
-rw-r--r--lib/ultralib/src/os/setintmask.s100
-rw-r--r--lib/ultralib/src/os/setsr.s4
-rw-r--r--lib/ultralib/src/os/setthreadpri.c2
-rw-r--r--lib/ultralib/src/os/settime.c4
-rw-r--r--lib/ultralib/src/os/settimer.c4
-rw-r--r--lib/ultralib/src/os/settlbasid.s30
-rw-r--r--lib/ultralib/src/os/setwatchlo.s4
-rw-r--r--lib/ultralib/src/os/startthread.c2
-rw-r--r--lib/ultralib/src/os/stopthread.c2
-rw-r--r--lib/ultralib/src/os/stoptimer.c4
-rw-r--r--lib/ultralib/src/os/thread.c6
-rw-r--r--lib/ultralib/src/os/timerintr.c6
-rw-r--r--lib/ultralib/src/os/unmaptlb.s44
-rw-r--r--lib/ultralib/src/os/unmaptlball.s26
-rw-r--r--lib/ultralib/src/os/virtualtophysical.c2
-rw-r--r--lib/ultralib/src/os/writebackdcache.s67
-rw-r--r--lib/ultralib/src/os/writebackdcacheall.s16
-rw-r--r--lib/ultralib/src/os/yieldthread.c2
-rw-r--r--lib/ultralib/src/rg/printregion.c2
-rw-r--r--lib/ultralib/src/rmon/rmonbrk.c10
-rw-r--r--lib/ultralib/src/rmon/rmoncmds.c6
-rw-r--r--lib/ultralib/src/rmon/rmonmain.c8
-rw-r--r--lib/ultralib/src/rmon/rmonmem.c8
-rw-r--r--lib/ultralib/src/rmon/rmonmisc.c20
-rw-r--r--lib/ultralib/src/rmon/rmonrcp.s8
-rw-r--r--lib/ultralib/src/rmon/rmonregs.c8
-rw-r--r--lib/ultralib/src/rmon/rmonsio.c8
-rw-r--r--lib/ultralib/src/rmon/rmontask.c6
-rw-r--r--lib/ultralib/src/vimodes/vimodefpalhaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodefpalhan1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodefpalhpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpalhpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpalhpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpalhpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallaf2.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallan1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallan2.c31
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodefpallpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempalhaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodempalhan1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodempalhpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempalhpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempalhpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempalhpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempallaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodempallaf2.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodempallan1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempallan2.c31
-rw-r--r--lib/ultralib/src/vimodes/vimodempallpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempallpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempallpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodempallpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentschaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodentschan1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodentschpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentschpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentschpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentschpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclaf2.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclan1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclan2.c31
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodentsclpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepalhaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodepalhan1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodepalhpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepalhpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepalhpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepalhpn2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepallaf1.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodepallaf2.c30
-rw-r--r--lib/ultralib/src/vimodes/vimodepallan1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepallan2.c31
-rw-r--r--lib/ultralib/src/vimodes/vimodepallpf1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepallpf2.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepallpn1.c12
-rw-r--r--lib/ultralib/src/vimodes/vimodepallpn2.c12
-rw-r--r--lib/ultralib/src/voice/voicecheckresult.c6
-rw-r--r--lib/ultralib/src/voice/voicecheckword.c10
-rw-r--r--lib/ultralib/src/voice/voicecleardictionary.c14
-rw-r--r--lib/ultralib/src/voice/voicecontread2.c11
-rw-r--r--lib/ultralib/src/voice/voicecontread36.c11
-rw-r--r--lib/ultralib/src/voice/voicecontrolgain.c9
-rw-r--r--lib/ultralib/src/voice/voicecontwrite20.c11
-rw-r--r--lib/ultralib/src/voice/voicecontwrite4.c11
-rw-r--r--lib/ultralib/src/voice/voicecountsyllables.c8
-rw-r--r--lib/ultralib/src/voice/voicecrc.c12
-rw-r--r--lib/ultralib/src/voice/voicegetreaddata.c8
-rw-r--r--lib/ultralib/src/voice/voicegetstatus.c8
-rw-r--r--lib/ultralib/src/voice/voiceinit.c9
-rw-r--r--lib/ultralib/src/voice/voicemaskdictionary.c9
-rw-r--r--lib/ultralib/src/voice/voicesetadconverter.c10
-rw-r--r--lib/ultralib/src/voice/voicesetword.c9
-rw-r--r--lib/ultralib/src/voice/voicestartreaddata.c8
-rw-r--r--lib/ultralib/src/voice/voicestopreaddata.c8
-rw-r--r--src/boot/fault_drawer.c4
-rw-r--r--src/boot/libc64/aprintf.c2
-rw-r--r--src/boot/libc64/sprintf.c6
-rw-r--r--src/boot/libu64/gfxprint.c6
-rw-r--r--src/code/lbrtc/7220C0.c4
-rw-r--r--src/code/lbrtc/722570.c4
-rw-r--r--src/code/lbrtc/722AB0.c4
-rw-r--r--src/code/m_demo.c2
-rwxr-xr-xtools/format.py2
-rwxr-xr-xtools/m2ctx.py2
-rw-r--r--tools/warnings_count/warnings_lib_current.txt4
338 files changed, 3698 insertions, 1926 deletions
diff --git a/Makefile b/Makefile
index a04a386..fe8ba6e 100644
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,8 @@ MIPS_BINUTILS_PREFIX ?= mips-linux-gnu-
TARGET := animalforest
+PROJECT_DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
BASEROM_DIR := baseroms/$(VERSION)
BASEROM := $(BASEROM_DIR)/baserom.z64
BASEROMD := $(BASEROM_DIR)/baserom-decompressed.z64
@@ -116,6 +118,7 @@ endif
CC := tools/ido/$(DETECTED_OS)/7.1/cc
CC_OLD := tools/ido/$(DETECTED_OS)/5.3/cc
+CC_ULTRALIB := $(PROJECT_DIR)/$(CC_OLD)
AS := $(MIPS_BINUTILS_PREFIX)as
LD := $(MIPS_BINUTILS_PREFIX)ld
@@ -137,7 +140,7 @@ PIGMENT := tools/pigment64/pigment64
IINC := -Iinclude -Isrc -Iassets/$(VERSION) -I. -I$(BUILD_DIR)
-IINC += -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ilib/ultralib/include/ido
+IINC += -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ilib/ultralib/include/compiler/ido
ifeq ($(KEEP_MDEBUG),0)
RM_MDEBUG = $(OBJCOPY) --remove-section .mdebug $@
@@ -360,7 +363,7 @@ $(LIBULTRA_LIB): $(ULTRALIB_LIB)
$(LIBDUMP_CMD)
$(ULTRALIB_LIB):
- $(MAKE) -C lib/ultralib VERSION=$(ULTRALIB_VERSION) TARGET=$(ULTRALIB_TARGET) FIXUPS=1 CROSS=$(MIPS_BINUTILS_PREFIX) CC=../../$(CC_OLD) AR=$(AR)
+ $(MAKE) -C lib/ultralib VERSION=$(ULTRALIB_VERSION) TARGET=$(ULTRALIB_TARGET) MODERN_LD=1 CROSS=$(MIPS_BINUTILS_PREFIX) COMPILER_DIR=$(dir $(CC_ULTRALIB)) AR=$(AR)
$(BUILD_DIR)/%.o: %.bin
$(OBJCOPY) -I binary -O elf32-big $< $@
diff --git a/include/libu64/gfxprint.h b/include/libu64/gfxprint.h
index a3aae97..ba80e35 100644
--- a/include/libu64/gfxprint.h
+++ b/include/libu64/gfxprint.h
@@ -96,9 +96,9 @@ void gfxprint_locate8x8(gfxprint* this, s32 x, s32 y);
void gfxprint_setoffset(gfxprint* this, s32 x, s32 y);
void gfxprint_putc1(gfxprint* this, char c);
void gfxprint_putc(gfxprint* this, char c);
-void gfxprint_write(gfxprint* this, const void* buffer, s32 size, s32 n);
+void gfxprint_write(gfxprint* this, const void* buffer, size_t size, size_t n);
void gfxprint_puts(gfxprint* this, const char* buffer);
-void* gfxprint_prout(void* this, const char* buffer, s32 n);
+void* gfxprint_prout(void* this, const char* buffer, size_t n);
void gfxprint_init(gfxprint* this);
void gfxprint_cleanup(gfxprint* this);
void gfxprint_open(gfxprint* this, Gfx* gListp);
diff --git a/lib/ultralib/.github/workflows/ci_gcc.yml b/lib/ultralib/.github/workflows/ci_gcc.yml
index 31efff8..8b27d56 100644
--- a/lib/ultralib/.github/workflows/ci_gcc.yml
+++ b/lib/ultralib/.github/workflows/ci_gcc.yml
@@ -23,7 +23,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install package requirements
- run: sudo apt-get install -y build-essential python3
+ run: sudo apt-get install -y binutils-mips-linux-gnu build-essential python3
- name: Get extra dependencies
uses: actions/checkout@v3
diff --git a/lib/ultralib/.gitrepo b/lib/ultralib/.gitrepo
index f9183f9..32a8c98 100644
--- a/lib/ultralib/.gitrepo
+++ b/lib/ultralib/.gitrepo
@@ -6,7 +6,7 @@
[subrepo]
remote = git@github.com:decompals/ultralib.git
branch = main
- commit = 299d7faf8798cbe75e3247ccdf4e65c09f5270dd
+ commit = 48f9f9084e06036f1a613187186c8b0f5b68ce40
parent = a10bb11ed6784c6a16a09b7eb17657d2e1bb303c
method = merge
- cmdver = 0.4.6
+ cmdver = 0.4.9
diff --git a/lib/ultralib/Makefile b/lib/ultralib/Makefile
index a4714b6..401c3d4 100644
--- a/lib/ultralib/Makefile
+++ b/lib/ultralib/Makefile
@@ -1,7 +1,8 @@
COMPARE ?= 1
-FIXUPS ?= 0
+MODERN_LD ?= 0
+MODERN_GCC ?= 0
-ifneq ($(FIXUPS),0)
+ifneq ($(MODERN_LD),0)
COMPARE := 0
endif
@@ -12,6 +13,20 @@ TARGET ?= libgultra_rom
VERSION ?= L
CROSS ?= mips-linux-gnu-
+ifeq ($(findstring libgultra,$(TARGET)),libgultra)
+COMPILER := gcc
+else ifeq ($(findstring libultra,$(TARGET)),libultra)
+COMPILER := ido
+else
+$(error Invalid Target)
+endif
+
+ifneq ($(MODERN_GCC),0)
+COMPILER := modern_gcc
+COMPARE := 0
+MODERN_LD := 0
+endif
+
BASE_DIR := extracted/$(VERSION)/$(TARGET)
BASE_AR := base/$(VERSION)/$(TARGET).a
BUILD_ROOT := build
@@ -21,19 +36,9 @@ BUILD_AR := $(BUILD_DIR)/$(TARGET).a
WORKING_DIR := $(shell pwd)
CPP := cpp -P
-AR := ar
+AR := $(CROSS)ar
-VERSION_D := 1
-VERSION_E := 2
-VERSION_F := 3
-VERSION_G := 4
-VERSION_H := 5
-VERSION_I := 6
-VERSION_J := 7
-VERSION_K := 8
-VERSION_L := 9
-
-VERSION_DEFINE := -DBUILD_VERSION=$(VERSION_$(VERSION)) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\"
+VERSION_DEFINE := -DBUILD_VERSION=VERSION_$(VERSION) -DBUILD_VERSION_STRING=\"2.0$(VERSION)\"
ifeq ($(findstring _d,$(TARGET)),_d)
DEBUGFLAG := -D_DEBUG
@@ -41,14 +46,18 @@ else
DEBUGFLAG := -DNDEBUG
endif
-ifeq ($(findstring libgultra,$(TARGET)),libgultra)
--include Makefile.gcc
-else ifeq ($(findstring libultra,$(TARGET)),libultra)
--include Makefile.ido
+ifeq ($(COMPILER),gcc)
+-include makefiles/gcc.mk
+else ifeq ($(COMPILER),ido)
+-include makefiles/ido.mk
+else ifeq ($(COMPILER),modern_gcc)
+-include makefiles/modern_gcc.mk
else
-$(error Invalid Target)
+$(error Invalid Compiler)
endif
+export COMPILER_PATH := $(COMPILER_DIR)
+
ifeq ($(findstring _rom,$(TARGET)),_rom)
CPPFLAGS += -D_FINALROM
endif
@@ -166,10 +175,10 @@ $(BUILD_DIR)/src/sp/sprite.marker: GBIDEFINE := -DF3D_GBI
$(BUILD_DIR)/src/sp/spriteex.marker: GBIDEFINE :=
$(BUILD_DIR)/src/sp/spriteex2.marker: GBIDEFINE :=
$(BUILD_DIR)/src/voice/%.marker: OPTFLAGS += -DLANG_JAPANESE -I$(WORKING_DIR)/src -I$(WORKING_DIR)/src/voice
-$(BUILD_DIR)/src/voice/%.marker: CC := tools/compile_sjis.py -D__CC=$(WORKING_DIR)/$(CC) -D__BUILD_DIR=$(BUILD_DIR)
+$(BUILD_DIR)/src/voice/%.marker: CC := $(WORKING_DIR)/tools/compile_sjis.py -D__CC=$(CC) -D__BUILD_DIR=$(BUILD_DIR)
$(C_MARKER_FILES): $(BUILD_DIR)/%.marker: %.c
- cd $(<D) && $(WORKING_DIR)/$(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
+ cd $(<D) && $(CC) $(CFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(OPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
@@ -179,7 +188,7 @@ ifneq ($(COMPARE),0)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
endif
-ifneq ($(FIXUPS),0)
+ifneq ($(MODERN_LD),0)
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
$(CROSS)objcopy --remove-section .mdebug $(WORKING_DIR)/$(@:.marker=.o)
@@ -188,7 +197,7 @@ endif
@touch $@
$(S_MARKER_FILES): $(BUILD_DIR)/%.marker: %.s
- cd $(<D) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
+ cd $(<D) && $(AS) $(ASFLAGS) $(MIPS_VERSION) $(CPPFLAGS) $(ASOPTFLAGS) $(<F) $(IINC) -o $(WORKING_DIR)/$(@:.marker=.o)
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@$(if $(findstring $(BASE_DIR)/$(@F:.marker=.o), $(BASE_OBJS)), \
@@ -198,7 +207,7 @@ ifneq ($(COMPARE),0)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
endif
-ifneq ($(FIXUPS),0)
+ifneq ($(MODERN_LD),0)
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
$(CROSS)objcopy --remove-section .mdebug $(WORKING_DIR)/$(@:.marker=.o)
@@ -210,7 +219,7 @@ endif
$(MDEBUG_FILES): $(BUILD_DIR)/src/%.marker: src/%.s
cp $(<:.marker=.s) $(dir $@)
mkdir -p $(@:.marker=)
- export USR_INCLUDE=$(WORKING_DIR)/include && cd $(@:.marker=) && $(WORKING_DIR)/$(CC) $(ASFLAGS) $(CPPFLAGS) ../$(<F) -I/usr/include -o $(notdir $(<:.s=.o))
+ export USR_INCLUDE=$(WORKING_DIR)/include && cd $(@:.marker=) && $(AS) $(ASFLAGS) $(CPPFLAGS) ../$(<F) -I/usr/include -o $(notdir $(<:.s=.o))
mv $(@:.marker=)/$(<F:.s=.o) $(@:.marker=)/..
ifneq ($(COMPARE),0)
# check if this file is in the archive; patch corrupted bytes and change file timestamps to match original if so
@@ -221,7 +230,7 @@ ifneq ($(COMPARE),0)
echo "Object file $(@F:.marker=.o) is not in the current archive" \
)
endif
-ifneq ($(FIXUPS),0)
+ifneq ($(MODERN_LD),0)
tools/set_o32abi_bit.py $(WORKING_DIR)/$(@:.marker=.o)
$(CROSS)strip $(WORKING_DIR)/$(@:.marker=.o) -N asdasdasdasd
$(CROSS)objcopy --remove-section .mdebug $(WORKING_DIR)/$(@:.marker=.o)
diff --git a/lib/ultralib/README.md b/lib/ultralib/README.md
index 8fa9b97..8128718 100644
--- a/lib/ultralib/README.md
+++ b/lib/ultralib/README.md
@@ -64,9 +64,15 @@ If building without an target archive, than you can use `COMPARE=0` like the the
note that running setup without `COMPARE=0` and no archive will result in an error,
and only needs to be run once instead of per target flag combination
-If building for use with modern linkers, than you can use `FIXUPS=1` like the the following:
+If building for use with modern linkers, than you can use `MODERN_LD=1` like the following:
-- `make VERSION=L TARGET=libgultra_rom FIXUPS=1 setup`
-- `make VERSION=L TARGET=libgultra_rom FIXUPS=1`
+- `make VERSION=L TARGET=libgultra_rom MODERN_LD=1 setup`
+- `make VERSION=L TARGET=libgultra_rom MODERN_LD=1`
-note that running with `FIXUPS=1` will automatically set `COMPARE=0`.
+note that running with `MODERN_LD=1` will automatically set `COMPARE=0`.
+
+It is also possible to build archives using modern gcc by using `MODERN_GCC=1` like the following:
+
+- `make VERSION=L TARGET=libgultra_rom MODERN_GCC=1`
+
+note that running with `MODERN_GCC=1` will automatically set `COMPARE=0` and `MODERN_LD=0`.
diff --git a/lib/ultralib/include/PR/os_libc.h b/lib/ultralib/include/PR/os_libc.h
index 35d0e8e..98624ad 100644
--- a/lib/ultralib/include/PR/os_libc.h
+++ b/lib/ultralib/include/PR/os_libc.h
@@ -80,10 +80,15 @@ extern "C" {
/* byte string operations */
-
+#ifndef MODERN_CC
extern void bcopy(const void *, void *, int);
extern int bcmp(const void *, const void *, int);
extern void bzero(void *, int);
+#else
+extern void bcopy(const void *, void *, size_t);
+extern int bcmp(const void *, const void *, size_t);
+extern void bzero(void *, size_t);
+#endif
/* Printf */
diff --git a/lib/ultralib/include/PR/rcp.h b/lib/ultralib/include/PR/rcp.h
index 47c4b34..2ae8f30 100644
--- a/lib/ultralib/include/PR/rcp.h
+++ b/lib/ultralib/include/PR/rcp.h
@@ -560,10 +560,11 @@
#define VI_CTRL_DIVOT_ON 0x00010 /* 4: default = on */
#define VI_CTRL_SERRATE_ON 0x00040 /* 6: on if interlaced */
#define VI_CTRL_ANTIALIAS_MASK 0x00300 /* [9:8] anti-alias mode */
-#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */
-#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */
-#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */
-#define VI_CTRL_PIXEL_ADV_MASK 0x01000 /* [15:12] pixel advance mode? */
+#define VI_CTRL_ANTIALIAS_MODE_0 0x00000 /* Bit [9:8] anti-alias mode: AA enabled, resampling enabled, always fetch extra lines */
+#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode: AA enabled, resampling enabled, fetch extra lines as-needed */
+#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode: AA disabled, resampling enabled, operate as if everything is covered */
+#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode: AA disabled, resampling disabled, replicate pixels */
+#define VI_CTRL_PIXEL_ADV_MASK 0x0F000 /* [15:12] pixel advance mode? */
#define VI_CTRL_PIXEL_ADV_1 0x01000 /* Bit [15:12] pixel advance mode? */
#define VI_CTRL_PIXEL_ADV_2 0x02000 /* Bit [15:12] pixel advance mode? */
#define VI_CTRL_PIXEL_ADV_3 0x03000 /* Bit [15:12] pixel advance mode? */
diff --git a/lib/ultralib/src/io/controller.h b/lib/ultralib/include/PRinternal/controller.h
index 5dac7f5..e77b38e 100644
--- a/lib/ultralib/src/io/controller.h
+++ b/lib/ultralib/include/PRinternal/controller.h
@@ -5,15 +5,15 @@
#include "PR/os_version.h"
#include "PR/rcp.h"
-//should go somewhere else but
-#define ARRLEN(x) ((s32)(sizeof(x) / sizeof(x[0])))
+#include "PRinternal/macros.h"
+
#define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4)
typedef struct
{
/* 0x0 */ u32 ramarray[15];
/* 0x3C */ u32 pifstatus;
-} OSPifRam;
+} OSPifRam ALIGNED(0x10);
typedef struct
{
diff --git a/lib/ultralib/src/io/controller_gbpak.h b/lib/ultralib/include/PRinternal/controller_gbpak.h
index db98bd4..db98bd4 100644
--- a/lib/ultralib/src/io/controller_gbpak.h
+++ b/lib/ultralib/include/PRinternal/controller_gbpak.h
diff --git a/lib/ultralib/src/io/controller_voice.h b/lib/ultralib/include/PRinternal/controller_voice.h
index 1b9dee6..1b9dee6 100644
--- a/lib/ultralib/src/io/controller_voice.h
+++ b/lib/ultralib/include/PRinternal/controller_voice.h
diff --git a/lib/ultralib/include/dbgdefs.h b/lib/ultralib/include/PRinternal/dbgdefs.h
index f7ead71..f7ead71 100644
--- a/lib/ultralib/include/dbgdefs.h
+++ b/lib/ultralib/include/PRinternal/dbgdefs.h
diff --git a/lib/ultralib/include/dbgproto.h b/lib/ultralib/include/PRinternal/dbgproto.h
index 2eabf9a..e4d3656 100644
--- a/lib/ultralib/include/dbgproto.h
+++ b/lib/ultralib/include/PRinternal/dbgproto.h
@@ -1,7 +1,7 @@
#ifndef _DBGPROTO_H__
#define _DBGPROTO_H__
-#include "dbgdefs.h"
+#include "PRinternal/dbgdefs.h"
#define KK_REV 2
diff --git a/lib/ultralib/include/macros.h b/lib/ultralib/include/PRinternal/macros.h
index 3057fc8..c84c7ad 100644
--- a/lib/ultralib/include/macros.h
+++ b/lib/ultralib/include/PRinternal/macros.h
@@ -13,4 +13,12 @@
#define __attribute__(x)
#endif
+#define ALIGN8(val) (((val) + 7) & ~7)
+
+#define STACK(stack, size) \
+ u64 stack[ALIGN8(size) / sizeof(u64)]
+
+#define STACK_START(stack) \
+ ((u8*)(stack) + sizeof(stack))
+
#endif
diff --git a/lib/ultralib/src/os/osint.h b/lib/ultralib/include/PRinternal/osint.h
index b73b609..b73b609 100644
--- a/lib/ultralib/src/os/osint.h
+++ b/lib/ultralib/include/PRinternal/osint.h
diff --git a/lib/ultralib/src/io/piint.h b/lib/ultralib/include/PRinternal/piint.h
index 50a0858..50a0858 100644
--- a/lib/ultralib/src/io/piint.h
+++ b/lib/ultralib/include/PRinternal/piint.h
diff --git a/lib/ultralib/src/rmon/rmonint.h b/lib/ultralib/include/PRinternal/rmonint.h
index 59ad736..714a63f 100644
--- a/lib/ultralib/src/rmon/rmonint.h
+++ b/lib/ultralib/include/PRinternal/rmonint.h
@@ -1,7 +1,7 @@
#ifndef _RMONINT_H
#define _RMONINT_H
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
/* mips */
diff --git a/lib/ultralib/src/io/siint.h b/lib/ultralib/include/PRinternal/siint.h
index 636a87f..636a87f 100644
--- a/lib/ultralib/src/io/siint.h
+++ b/lib/ultralib/include/PRinternal/siint.h
diff --git a/lib/ultralib/src/io/viint.h b/lib/ultralib/include/PRinternal/viint.h
index ffe0927..b3c3943 100644
--- a/lib/ultralib/src/io/viint.h
+++ b/lib/ultralib/include/PRinternal/viint.h
@@ -15,10 +15,6 @@
#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
@@ -67,5 +63,5 @@ extern __OSViContext *__osViNext;
extern u32 __additional_scanline;
__OSViContext *__osViGetCurrentContext(void);
void __osViInit(void);
-extern OSDevMgr __osViDevMgr;
+extern OSDevMgr __osViDevMgr;
#endif
diff --git a/lib/ultralib/include/gcc/math.h b/lib/ultralib/include/compiler/gcc/math.h
index 3e93ceb..3e93ceb 100644
--- a/lib/ultralib/include/gcc/math.h
+++ b/lib/ultralib/include/compiler/gcc/math.h
diff --git a/lib/ultralib/include/gcc/memory.h b/lib/ultralib/include/compiler/gcc/memory.h
index edfff5e..edfff5e 100644
--- a/lib/ultralib/include/gcc/memory.h
+++ b/lib/ultralib/include/compiler/gcc/memory.h
diff --git a/lib/ultralib/include/gcc/sgidefs.h b/lib/ultralib/include/compiler/gcc/sgidefs.h
index 56567e8..56567e8 100644
--- a/lib/ultralib/include/gcc/sgidefs.h
+++ b/lib/ultralib/include/compiler/gcc/sgidefs.h
diff --git a/lib/ultralib/include/gcc/stdarg.h b/lib/ultralib/include/compiler/gcc/stdarg.h
index af337f6..af337f6 100644
--- a/lib/ultralib/include/gcc/stdarg.h
+++ b/lib/ultralib/include/compiler/gcc/stdarg.h
diff --git a/lib/ultralib/include/gcc/stdio.h b/lib/ultralib/include/compiler/gcc/stdio.h
index 3e93ceb..3e93ceb 100644
--- a/lib/ultralib/include/gcc/stdio.h
+++ b/lib/ultralib/include/compiler/gcc/stdio.h
diff --git a/lib/ultralib/include/gcc/stdlib.h b/lib/ultralib/include/compiler/gcc/stdlib.h
index 98f8a2e..98f8a2e 100644
--- a/lib/ultralib/include/gcc/stdlib.h
+++ b/lib/ultralib/include/compiler/gcc/stdlib.h
diff --git a/lib/ultralib/include/gcc/string.h b/lib/ultralib/include/compiler/gcc/string.h
index d82e1f1..d82e1f1 100644
--- a/lib/ultralib/include/gcc/string.h
+++ b/lib/ultralib/include/compiler/gcc/string.h
diff --git a/lib/ultralib/include/ido/math.h b/lib/ultralib/include/compiler/ido/math.h
index 3e93ceb..3e93ceb 100644
--- a/lib/ultralib/include/ido/math.h
+++ b/lib/ultralib/include/compiler/ido/math.h
diff --git a/lib/ultralib/include/ido/memory.h b/lib/ultralib/include/compiler/ido/memory.h
index edfff5e..edfff5e 100644
--- a/lib/ultralib/include/ido/memory.h
+++ b/lib/ultralib/include/compiler/ido/memory.h
diff --git a/lib/ultralib/include/ido/stdarg.h b/lib/ultralib/include/compiler/ido/stdarg.h
index 62f68e0..62f68e0 100644
--- a/lib/ultralib/include/ido/stdarg.h
+++ b/lib/ultralib/include/compiler/ido/stdarg.h
diff --git a/lib/ultralib/include/ido/stdio.h b/lib/ultralib/include/compiler/ido/stdio.h
index 3e93ceb..3e93ceb 100644
--- a/lib/ultralib/include/ido/stdio.h
+++ b/lib/ultralib/include/compiler/ido/stdio.h
diff --git a/lib/ultralib/include/ido/stdlib.h b/lib/ultralib/include/compiler/ido/stdlib.h
index 98f8a2e..98f8a2e 100644
--- a/lib/ultralib/include/ido/stdlib.h
+++ b/lib/ultralib/include/compiler/ido/stdlib.h
diff --git a/lib/ultralib/include/ido/string.h b/lib/ultralib/include/compiler/ido/string.h
index d82e1f1..d82e1f1 100644
--- a/lib/ultralib/include/ido/string.h
+++ b/lib/ultralib/include/compiler/ido/string.h
diff --git a/lib/ultralib/include/compiler/modern_gcc/math.h b/lib/ultralib/include/compiler/modern_gcc/math.h
new file mode 100644
index 0000000..3e93ceb
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/math.h
@@ -0,0 +1 @@
+// Nothing needed here
diff --git a/lib/ultralib/include/compiler/modern_gcc/memory.h b/lib/ultralib/include/compiler/modern_gcc/memory.h
new file mode 100644
index 0000000..edfff5e
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/memory.h
@@ -0,0 +1,23 @@
+#ifndef _MEMORY_H
+#define _MEMORY_H
+/*
+ memory.h
+*/
+
+#ifndef _SIZE_T_DEF
+#define _SIZE_T_DEF
+typedef unsigned size_t;
+#endif
+
+void *memccpy(void *,void *,int,size_t);
+void *memchr(void *,int,size_t);
+int memcmp(const void *,const void *,size_t);
+void *memcpy(void *,const void *,size_t);
+int memicmp(void *,void *,size_t);
+void *memmove(void *,void *,size_t);
+void *memset(void *,int,size_t);
+
+void movmem(void *,void *,unsigned);
+void setmem(void *,unsigned,int);
+
+#endif
diff --git a/lib/ultralib/include/compiler/modern_gcc/sgidefs.h b/lib/ultralib/include/compiler/modern_gcc/sgidefs.h
new file mode 100644
index 0000000..56567e8
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/sgidefs.h
@@ -0,0 +1,44 @@
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ralf Baechle <ralf@gnu.org>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H 1
+
+/*
+ * Definitions for the ISA level
+ */
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+
+/*
+ * Subprogram calling convention
+ *
+ * At the moment only _MIPS_SIM_ABI32 is in use. This will change rsn.
+ * Until GCC 2.8.0 is released don't rely on this definitions because the
+ * 64bit code is essentially using the 32bit interface model just with
+ * 64bit registers.
+ */
+#define _MIPS_SIM_ABI32 1
+#define _MIPS_SIM_NABI32 2
+#define _MIPS_SIM_ABI64 3
+
+#endif /* sgidefs.h */
diff --git a/lib/ultralib/include/compiler/modern_gcc/stdarg.h b/lib/ultralib/include/compiler/modern_gcc/stdarg.h
new file mode 100644
index 0000000..1f36b0a
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/stdarg.h
@@ -0,0 +1,9 @@
+#ifndef _STDARG_H
+#define _STDARG_H
+
+#define va_list __builtin_va_list
+#define va_start __builtin_va_start
+#define va_arg __builtin_va_arg
+#define va_end __builtin_va_end
+
+#endif
diff --git a/lib/ultralib/include/compiler/modern_gcc/stdio.h b/lib/ultralib/include/compiler/modern_gcc/stdio.h
new file mode 100644
index 0000000..3e93ceb
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/stdio.h
@@ -0,0 +1 @@
+// Nothing needed here
diff --git a/lib/ultralib/include/compiler/modern_gcc/stdlib.h b/lib/ultralib/include/compiler/modern_gcc/stdlib.h
new file mode 100644
index 0000000..98f8a2e
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/stdlib.h
@@ -0,0 +1,81 @@
+#ifndef _STDLIB_H
+#define _STDLIB_H
+/*
+ stdlib.h
+*/
+
+#ifndef _SIZE_T_DEF
+#define _SIZE_T_DEF
+typedef unsigned size_t;
+#endif
+
+#ifndef _DIV_T_DEF
+#define _DIV_T_DEF
+typedef struct DIV_T {
+ int quot;
+ int rem;
+} div_t;
+#endif
+
+#ifndef _LDIV_T_DEF
+#define _LDIV_T_DEF
+typedef struct LDIV_T {
+ long quot;
+ long rem;
+} ldiv_t;
+#endif
+
+#ifndef _LLDIV_T_DEF
+#define _LLDIV_T_DEF
+typedef struct lldiv_t
+{
+ long long quot;
+ long long rem;
+} lldiv_t;
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define _max(a,b) (((a) > (b)) ? (a) : (b))
+#define _min(a,b) (((a) < (b)) ? (a) : (b))
+
+#define RAND_MAX 32767
+
+int rand(void);
+void srand(unsigned);
+
+int abs(int);
+long labs(long);
+
+div_t div(int,int);
+ldiv_t ldiv(long,long);
+lldiv_t lldiv(long long, long long);
+
+int atoi(const char *);
+long atol(const char *);
+
+long strtol(const char *,char **,int);
+unsigned long strtoul(const char *,char **,int);
+
+char *itoa(int,char *,int);
+char *ltoa(long,char *,int);
+char *ultoa(unsigned long,char *,int);
+
+double atof(const char *);
+double strtod(const char *,char **);
+
+void qsort(void *,size_t,size_t,int (*)(const void *,const void *));
+void *bsearch(const void *,const void *,size_t,size_t,int (*)(const void *,const void *));
+
+void *malloc(size_t);
+void *calloc(size_t,size_t);
+void *realloc(void *,size_t);
+void free(void *);
+
+void exit(int);
+
+void abort(void);
+
+#endif
diff --git a/lib/ultralib/include/compiler/modern_gcc/string.h b/lib/ultralib/include/compiler/modern_gcc/string.h
new file mode 100644
index 0000000..d82e1f1
--- /dev/null
+++ b/lib/ultralib/include/compiler/modern_gcc/string.h
@@ -0,0 +1,42 @@
+#ifndef _STRING_H
+#define _STRING_H
+/*
+ string.h
+*/
+
+#ifndef _SIZE_T_DEF
+#define _SIZE_T_DEF
+typedef unsigned size_t;
+#endif
+
+#include "memory.h"
+
+char *stpcpy(char *,const char *);
+char *strcat(char *,const char *);
+char *strchr(const char *,int);
+int strcmp(const char *,const char *);
+char *strcpy(char *,const char *);
+size_t strcspn(const char *,const char *);
+char *strdup(const char *);
+char *strerror(int);
+int stricmp(const char *,const char *);
+size_t strlen(const char *);
+char *strlwr(char *);
+char *strncat(char *,const char *,size_t);
+int strncmp(const char *,const char *,size_t);
+char *strncpy(char *,const char *,size_t);
+int strnicmp(const char *,const char *,size_t);
+char *strnset(char *,int,size_t);
+char *strpbrk(const char *,const char *);
+char *strrchr(const char *,int);
+char *strrev(char *);
+char *strset(char *,int);
+size_t strspn(const char *,const char *);
+char *strstr(const char *,const char *);
+char *strtok(char *,const char *);
+char *strupr(char *);
+
+#define strcmpi(s1,s2) stricmp(s1,s2)
+#define strncmpi(s1,s2,n) strnicmp(s1,s2,n)
+
+#endif
diff --git a/lib/ultralib/include/sys/asm.h b/lib/ultralib/include/sys/asm.h
index 97f8fb2..60e6ccd 100644
--- a/lib/ultralib/include/sys/asm.h
+++ b/lib/ultralib/include/sys/asm.h
@@ -83,32 +83,37 @@ extern "C" {
#endif
+#define NOP \
+ .set noreorder ;\
+ nop ;\
+ .set reorder
-#define STAY1(stmnt) \
+#define CACHE(op, reg) \
.set noreorder ;\
- stmnt ;\
+ cache op, reg ;\
.set reorder
-#define STAY2(stmnt, arg1) \
- .set noreorder ;\
- stmnt, arg1 ;\
+#define MFC0(reg, op) \
+ .set noreorder ;\
+ mfc0 reg, op ;\
.set reorder
-#define STAY3(stmnt, arg1, arg2) \
- .set noreorder ;\
- stmnt, arg1, arg2 ;\
+#define MTC0(reg, op) \
+ .set noreorder ;\
+ mtc0 reg, op ;\
.set reorder
-#define NOP \
- .set noreorder ;\
- nop ;\
+#define CFC1(reg, op) \
+ .set noreorder ;\
+ cfc1 reg, op ;\
.set reorder
-#define CACHE(op, reg) \
+#define CTC1(reg, op) \
.set noreorder ;\
- cache op, reg ;\
+ ctc1 reg, op ;\
.set reorder
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/ultralib/Makefile.gcc b/lib/ultralib/makefiles/gcc.mk
index 96f1eed..85b25a2 100644
--- a/lib/ultralib/Makefile.gcc
+++ b/lib/ultralib/makefiles/gcc.mk
@@ -1,16 +1,14 @@
-COMPILER := gcc
-AS := tools/gcc/as
-CC := tools/gcc/gcc
-AR_OLD := tools/gcc/ar
+COMPILER_DIR := $(WORKING_DIR)/tools/gcc
+AS := $(COMPILER_DIR)/gcc -x assembler-with-cpp
+CC := $(COMPILER_DIR)/gcc
+AR_OLD := $(COMPILER_DIR)/ar
PATCH_AR_FLAGS := 0 0 37777700
STRIP =
-export COMPILER_PATH := $(WORKING_DIR)/tools/gcc
-
CFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -D_LANGUAGE_C
-ASFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64 -x assembler-with-cpp
+ASFLAGS := -w -nostdinc -c -G 0 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64
CPPFLAGS = -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) $(DEBUGFLAG)
-IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/gcc -I $(WORKING_DIR)/include/PR
+IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/compiler/gcc -I $(WORKING_DIR)/include/PR
MIPS_VERSION := -mips3
ASOPTFLAGS :=
@@ -46,7 +44,7 @@ endif
export VR4300MUL := ON
$(BUILD_DIR)/src/os/initialize_isv.marker: OPTFLAGS := -O2
-$(BUILD_DIR)/src/os/initialize_isv.marker: STRIP = && tools/gcc/strip-2.7 -N initialize_isv.c $(WORKING_DIR)/$(@:.marker=.o)
+$(BUILD_DIR)/src/os/initialize_isv.marker: STRIP = && $(COMPILER_DIR)/strip-2.7 -N initialize_isv.c $(WORKING_DIR)/$(@:.marker=.o)
$(BUILD_DIR)/src/os/assert.marker: OPTFLAGS := -O0
ifeq ($(filter $(VERSION),D E F G H I),)
$(BUILD_DIR)/src/os/seterrorhandler.marker: OPTFLAGS := -O0
@@ -63,5 +61,6 @@ $(BUILD_DIR)/src/rmon/%.marker: ASFLAGS += -P
$(BUILD_DIR)/src/host/host_ptn64.marker: CFLAGS += -fno-builtin # Probably a better way to solve this
MDEBUG_FILES := $(BUILD_DIR)/src/monutil.marker
-$(BUILD_DIR)/src/monutil.marker: CC := tools/ido/cc
-$(BUILD_DIR)/src/monutil.marker: ASFLAGS := -non_shared -mips2 -fullwarn -verbose -Xcpluscomm -G 0 -woff 516,649,838,712 -Wab,-r4300_mul -nostdinc -o32 -c
+MDEBUG_COMPILER_DIR := $(WORKING_DIR)/tools/ido
+$(MDEBUG_FILES): AS := $(MDEBUG_COMPILER_DIR)/cc
+$(MDEBUG_FILES): ASFLAGS := -non_shared -mips2 -fullwarn -verbose -Xcpluscomm -G 0 -woff 516,649,838,712 -Wab,-r4300_mul -nostdinc -o32 -c
diff --git a/lib/ultralib/Makefile.ido b/lib/ultralib/makefiles/ido.mk
index 1550f4d..c5deb1d 100644
--- a/lib/ultralib/Makefile.ido
+++ b/lib/ultralib/makefiles/ido.mk
@@ -1,16 +1,14 @@
-COMPILER := ido
-AS := tools/ido/cc
-CC := tools/ido/cc
-AR_OLD := tools/ar.py
+COMPILER_DIR := $(WORKING_DIR)/tools/ido
+AS := $(COMPILER_DIR)/cc
+CC := $(COMPILER_DIR)/cc
+AR_OLD := $(WORKING_DIR)/tools/ar.py
PATCH_AR_FLAGS := 40001 110 100644
STRIP =
-export COMPILER_PATH := $(WORKING_DIR)/tools/ido
-
CFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -Xcpluscomm -fullwarn -woff 516,649,838,712
ASFLAGS := -c -Wab,-r4300_mul -G 0 -nostdinc -woff 516,649,838,712
CPPFLAGS = -D_MIPS_SZLONG=32 $(GBIDEFINE) $(VERSION_DEFINE) $(PICFLAGS) $(DEBUGFLAG)
-IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/ido -I $(WORKING_DIR)/include/PR
+IINC = -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/compiler/ido -I $(WORKING_DIR)/include/PR
MIPS_VERSION := -mips2 -o32
PICFLAGS := -non_shared
diff --git a/lib/ultralib/makefiles/modern_gcc.mk b/lib/ultralib/makefiles/modern_gcc.mk
new file mode 100644
index 0000000..a914d78
--- /dev/null
+++ b/lib/ultralib/makefiles/modern_gcc.mk
@@ -0,0 +1,21 @@
+
+COMPILER_DIR := $(dir $(which $(CROSS)gcc))
+AS := $(CROSS)gcc -x assembler-with-cpp
+CC := $(CROSS)gcc
+AR_OLD := $(CROSS)ar
+
+WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-builtin-declaration-mismatch
+WARNINGS += -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-implicit-function-declaration # TODO: Try adjusting code to remove these
+CFLAGS := -G 0 -c -nostdinc -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks -fno-PIC -fno-common -ffreestanding -fbuiltin -fno-builtin-sinf -fno-builtin-cosf -funsigned-char $(WARNINGS)
+CFLAGS += -fno-strict-aliasing # TODO: Try adjusting code to remove this
+ASFLAGS := -w -nostdinc -c -G 0 -march=vr4300 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64
+CPPFLAGS = -DMODERN_CC -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) $(DEBUGFLAG)
+IINC = -I . -I $(WORKING_DIR)/include -I $(WORKING_DIR)/include/compiler/modern_gcc -I $(WORKING_DIR)/include/PR
+MIPS_VERSION := -mips3
+ASOPTFLAGS :=
+
+ifeq ($(findstring _d,$(TARGET)),_d)
+OPTFLAGS := -Og -ggdb3 -ffast-math -fno-unsafe-math-optimizations
+else
+OPTFLAGS := -Os -ggdb3 -ffast-math -fno-unsafe-math-optimizations
+endif
diff --git a/lib/ultralib/src/debug/assert.c b/lib/ultralib/src/debug/assert.c
index ab7e313..ffdb5ee 100644
--- a/lib/ultralib/src/debug/assert.c
+++ b/lib/ultralib/src/debug/assert.c
@@ -1,5 +1,5 @@
#include "os.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "osint_debug.h"
void __assertBreak(void);
diff --git a/lib/ultralib/src/debug/profile.c b/lib/ultralib/src/debug/profile.c
index 47b19d8..bdc47ae 100644
--- a/lib/ultralib/src/debug/profile.c
+++ b/lib/ultralib/src/debug/profile.c
@@ -4,8 +4,8 @@
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
#include "PR/sptask.h"
-#include "../os/osint.h"
-#include "macros.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/macros.h"
#include "osint_debug.h"
#ifndef _FINALROM
@@ -13,10 +13,10 @@
OSTimer __osProfTimer;
OSMesg __osProfTimerMsg;
-OSMesgQueue __osProfFlushMQ ALIGNED(8);
+OSMesgQueue __osProfFlushMQ ALIGNED(0x8);
OSMesg __osProfFlushMesg;
-OSMesgQueue __osProfAckMQ ALIGNED(8);
+OSMesgQueue __osProfAckMQ ALIGNED(0x8);
OSMesg __osProfAckMesg;
u32 __osProfTimerPeriod;
@@ -26,7 +26,7 @@ u32 __osProfNumSections;
static u32 __osProfileActive = FALSE;
static u32 __osProfileIOActive = FALSE;
-unsigned char __osProfileIOStack[2400] ALIGNED(16);
+STACK(__osProfileIOStack, 0x960) ALIGNED(0x10);
static OSThread __osProfileIOThread;
@@ -130,7 +130,7 @@ void osProfileInit(OSProf* profp, u32 profcnt) {
osSetEventMesg(OS_EVENT_RDB_FLUSH_PROF, &__osProfFlushMQ, 0);
osCreateMesgQueue(&__osProfAckMQ, &__osProfAckMesg, 1);
osSetEventMesg(OS_EVENT_RDB_ACK_PROF, &__osProfAckMQ, 0);
- osCreateThread(&__osProfileIOThread, 0, __osProfileIO, NULL, &__osProfileIOStack[2400], 0x81);
+ osCreateThread(&__osProfileIOThread, 0, __osProfileIO, NULL, STACK_START(__osProfileIOStack), 0x81);
osStartThread(&__osProfileIOThread);
__osProfileIOActive = TRUE;
}
diff --git a/lib/ultralib/src/debug/threadprofile.c b/lib/ultralib/src/debug/threadprofile.c
index e383773..55f1353 100644
--- a/lib/ultralib/src/debug/threadprofile.c
+++ b/lib/ultralib/src/debug/threadprofile.c
@@ -1,6 +1,6 @@
#include "osint_debug.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
s32 __osThprofFlag = 0;
void (*__osThprofFunc)(OSThread*) = NULL;
diff --git a/lib/ultralib/src/error/commonerror.c b/lib/ultralib/src/error/commonerror.c
index 5a6f1c9..c44a774 100644
--- a/lib/ultralib/src/error/commonerror.c
+++ b/lib/ultralib/src/error/commonerror.c
@@ -3,14 +3,14 @@
#include "PR/sptask.h"
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "stdarg.h"
#ifndef _FINALROM
void __osSyncVPrintf(const char* fmt, va_list args);
-static u32 errorLogData[19] ALIGNED(8);
+static u32 errorLogData[19] ALIGNED(0x8);
static OSLog errorLog = {
OS_ERROR_MAGIC, // magic
sizeof(errorLogData), // len
@@ -22,7 +22,7 @@ static OSLog errorLog = {
static void __commonErrorHandler(s16 code, s16 numArgs, ...);
OSErrorHandler __osCommonHandler = __commonErrorHandler;
-char NULSTR[] = { '\0' };
+char NULSTR[] = "";
const char* __os_error_message[] = {
NULSTR,
diff --git a/lib/ultralib/src/error/error.c b/lib/ultralib/src/error/error.c
index 3f9ae2d..ae75840 100644
--- a/lib/ultralib/src/error/error.c
+++ b/lib/ultralib/src/error/error.c
@@ -3,13 +3,13 @@
#include "PR/os_internal.h"
#include "PR/ultralog.h"
#include "PR/ultraerror.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr);
static void __osDefaultHandler(s16 code, s16 numArgs, ...);
-static u32 errorLogData[19] ALIGNED(8);
-static OSLog errorLog ALIGNED(8) = {
+static u32 errorLogData[19] ALIGNED(0x8);
+static OSLog errorLog ALIGNED(0x8) = {
OS_ERROR_MAGIC, // magic
sizeof(errorLogData), // len
errorLogData, // base
diff --git a/lib/ultralib/src/error/errorasm.s b/lib/ultralib/src/error/errorasm.s
index 10f3561..c41cf6d 100644
--- a/lib/ultralib/src/error/errorasm.s
+++ b/lib/ultralib/src/error/errorasm.s
@@ -7,23 +7,23 @@
LEAF(__osError)
#if BUILD_VERSION < VERSION_J
- lw t0,__osErrorHandler
- beqz t0,1f
+ lw t0, __osErrorHandler
+ beqz t0, 1f
jr t0
#elif BUILD_VERSION < VERSION_K
- lw t0,__kmc_pt_mode
- bnez t0,_kmc_mode
+ lw t0, __kmc_pt_mode
+ bnez t0, _kmc_mode
- lw t0,__osErrorHandler
- beqz t0,1f
+ lw t0, __osErrorHandler
+ beqz t0, 1f
jr t0
_kmc_mode:
- lw t0,__kmcErrorHandler
- beqz t0,1f
+ lw t0, __kmcErrorHandler
+ beqz t0, 1f
jr t0
#else
- lw t0,__osCommonHandler
- beqz t0,1f
+ lw t0, __osCommonHandler
+ beqz t0, 1f
jr t0
#endif
1:
diff --git a/lib/ultralib/src/error/kmcprintf.c b/lib/ultralib/src/error/kmcprintf.c
new file mode 100644
index 0000000..830ac72
--- /dev/null
+++ b/lib/ultralib/src/error/kmcprintf.c
@@ -0,0 +1,250 @@
+// This file was added in 2.0J and removed in 2.0K
+#include "stdarg.h"
+#include "PR/os.h"
+#include "PR/rcp.h"
+#include "PR/rdb.h"
+#include "ultraerror.h"
+#include "../libc/xstdio.h"
+
+#ifndef _FINALROM
+
+extern u32 __kmc_pt_mode;
+
+static void* proutSyncPrintf(void* str, const char* buf, size_t n) {
+ size_t sent = 0;
+
+ while (sent < n) {
+ sent += __osRdbSend(buf + sent, n - sent, RDB_TYPE_GtoH_PRINT);
+ }
+ return 1;
+}
+
+static volatile unsigned int* stat = (unsigned*)0xbff08004;
+static volatile unsigned int* wport = (unsigned*)0xbff08000;
+static volatile unsigned int* piok = (unsigned*)PHYS_TO_K1(PI_STATUS_REG);
+
+static void rmonPutchar(char c) {
+ while (*piok & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
+ }
+
+ while (!(*stat & 4)) {
+ }
+
+ *wport = c;
+}
+
+static void* kmc_proutSyncPrintf(void* str, const char* buf, int n) {
+ int i;
+ char c;
+ char* p;
+ char* q;
+ char xbuf[128];
+ static int column = 0;
+
+ p = &xbuf;
+
+ for (i = 0; i < n; i++) {
+ c = *buf++;
+
+ switch (c) {
+ case '\n':
+ *p++ = '\n';
+ column = 0;
+ break;
+ case '\t':
+ do {
+ *p++ = ' ';
+ } while (++column % 8);
+ break;
+ default:
+ column++;
+ *p++ = c;
+ break;
+ }
+
+ if (c == '\n' || (p - xbuf) > 100) {
+ rmonPutchar((p - xbuf) - 1);
+
+ q = xbuf;
+ while (q != p) {
+ rmonPutchar(*q++);
+ }
+ p = xbuf;
+ }
+ }
+ if (p != xbuf) {
+ rmonPutchar((p - xbuf) - 1);
+
+ q = xbuf;
+ while (q != p) {
+ rmonPutchar(*q++);
+ }
+ }
+ return (void*)1;
+}
+
+char NULSTR[] = "";
+
+const char* __os_error_message[] = {
+ NULSTR,
+ "osCreateThread: stack pointer not aligned to 8 bytes (0x%x)",
+ "osCreateThread: priority not in range [0-255] (%d)",
+ "osStartThread: thread has bad state (running/runnable/other)",
+ "osSetThreadPri: priority not in range [0-255] (%d)",
+ "osCreateMesgQueue: message count not > 0 (%d)",
+ "osSendMesg: flag not OS_MESG_NOBLOCK or OS_MESG_BLOCK (%d)",
+ "osJamMesg: flag not OS_MESG_NOBLOCK or OS_MESG_BLOCK (%d)",
+ "osRecvMesg: flag not OS_MESG_NOBLOCK or OS_MESG_BLOCK (%d)",
+ "osSetEventMesg: unknown event type (%d)",
+ "osMapTLB: index not in range [0-30] (%d)",
+ "osMapTLB: asid argument not -1 or in range [0-255] (%d)",
+ "osUnmapTLB: index not in range [0-30] (%d)",
+ "osSetTLBASID: asid not in range [0-255] (%d)",
+ "osAiSetFrequency: freq not in range [%d-%d] (%d)",
+ "osAiSetNextBuffer: address not aligned to 8 bytes (0x%x)",
+ "osAiSetNextBuffer: size not aligned to 8 bytes (0x%x)",
+ "osDpSetNextBuffer: address not aligned to 8 bytes (0x%x)",
+ "osDpSetNextBuffer: size not aligned to 8 bytes (0x%x)",
+ "osPiRawReadIo: address not aligned to 4 bytes (0x%x)",
+ "osPiRawWriteIo: address not aligned to 4 bytes (0x%x)",
+ "osPiRawStartDma: direction not OS_READ or OS_WRITE (%d)",
+ "osPiRawStartDma: device address not aligned to 2 bytes (0x%x)",
+ "osPiRawStartDma: DRAM address not aligned to 8 bytes (0x%x)",
+ "osPiRawStartDma: size not aligned to 2 bytes (%d)",
+ "osPiRawStartDma: size not in range [0,16777216] (%d)",
+ "osPiReadIo: address not aligned to 4 bytes (0x%x)",
+ "osPiWriteIo: address not aligned to 4 bytes (0x%x)",
+ "osPiStartDma: PI Manager not yet begun by osCreatePiManager",
+ "osPiStartDma: priority not OS_MESG_PRI_[NORMAL|HIGH] (%d)",
+ "osPiStartDma: direction not OS_READ or OS_WRITE (%d)",
+ "osPiStartDma: device address not aligned to 2 bytes (0x%x)",
+ "osPiStartDma: DRAM address not aligned to 8 bytes (0x%x)",
+ "osPiStartDma: size not aligned to 2 bytes (%d)",
+ "osPiStartDma: size not in range [0,16777216] (%d)",
+ "osCreatePiManager: priority not in range [0-255] (%d)",
+ "osViGetCurrentMode: VI Manager not yet begun",
+ "osViGetCurrentFramebuffer: VI Manager not yet begun",
+ "osViGetNextFramebuffer: VI Manager not yet begun",
+ "osViSetXScale: value not in range [0.25,1.0] (%f)",
+ "osViSetXScale: VI Manager not yet begun by osCreateViManager",
+ "osViSetYScale: value not in range [0.05,1.0] (%f)",
+ "osViSetYScale: VI Manager not yet begun by osCreateViManager",
+ "osViSetSpecialFeatures: not a known feature value (%d)",
+ "osViSetSpecialFeatures: VI Manager not yet begun",
+ "osViSetMode: VI Manager not yet begun by osCreateViManager",
+ "osViSetEvent: VI Manager not yet begun by osCreateViManager",
+ "osViSwapBuffer: frame buffer not aligned to 64 bytes (0x%x)",
+ "osViSwapBuffer: VI Manager not yet begun",
+ "osCreateViManager: priority not in range [0-255] (%d)",
+ "osCreateRegion: not a known alignment (%d)",
+ "osCreateRegion: length (%d) too small for buffer size (%d)",
+ "osMalloc: invalid or corrupt region (0x%x)",
+ "osFree: invalid or corrupt region (0x%x)",
+ "osFree: invalid address (0x%x) or\n corrupt region (0x%x)",
+ "osGetRegionBufCount: invalid or corrupt region (0x%x)",
+ "osGetRegionBufSize: invalid or corrupt region (0x%x)",
+ "osSpTaskLoad: dram_stack not aligned to 16 bytes (0x%x)",
+ "osSpTaskLoad: output_buff not aligned to 16 bytes (0x%x)",
+ "osSpTaskLoad: output_buff_size not aligned to 16 bytes (0x%x)",
+ "osSpTaskLoad: yield_data_ptr not aligned to 16 bytes (0x%x)",
+ "osProfileInit: profile counter is running, call osProfileStop before init",
+ "osProfileInit: profcnt is %d",
+ "osProfileInit: histo_base pointer must be 32-bit aligned (%x)",
+ "osProfileInit: text_start (%x) >= text_end (%x)",
+ "osProfileInit: histo_size is an illegal size (%d)",
+ "osProfileStart: microseconds is < PROF_MIN_INTERVAL (%d)",
+ "osProfileStart: profiling has already been started",
+ "osProfileStop: profiling has already been stopped",
+ "osProfileStop: no profile timer to stop",
+ "osReadHost: address not aligned to 8 bytes (0x%x)",
+ "osReadHost: size either 0 or not aligned to 4 bytes (0x%x)",
+ "osWriteHost: address not aligned to 8 bytes (0x%x)",
+ "osWriteHost: size either 0 or not aligned to 4 bytes (0x%x)",
+ "osGetTime: VI manager not yet begun by osCreateViManager",
+ "osSetTime: VI manager not yet begun by osCreateViManager",
+ "osSetTimer: VI manager not yet begun by osCreateViManager",
+ "osStopTimer: VI manager not yet begun by osCreateViManager",
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ NULSTR,
+ "_handleMIDIMsg: no sound mapped",
+ "_handleMIDIMsg: no free voices",
+ "_handleMIDIMsg: couldn't map voice",
+ "_handleMIDIMsg: note off - couldn't find voice",
+ "_handleMIDIMsg: poly pressure - couldn't find voice",
+ "_handleEvent: no free voices",
+ "Synthesizer: no free updates",
+ "alSndPDeallocate: attempt to deallocate a sound which is playing",
+ "alSndpDelete: attempt to delete player with playing sounds",
+ "alSndpPlay: attempt to play a sound which is playing",
+ "alSndpSetSound: sound id (%d) out of range (0 - %d)",
+ "alSndpSetPriority: sound id (%d) out of range (0 - %d)",
+ "alSndpSet Parameter: target (%d) out of range (0 - %d)",
+ "alBnkfNew: bank file out of date",
+ "alSeqNew: 0x%x is not a midi file",
+ "alSeqNew: 0x%x is not a type 0 midi file",
+ "alSeqNew: 0x%x has more than 1 track",
+ "alSeqNew: SMPTE delta times not supported",
+ "alSeqNew: Error parsing file 0x%x (no track header)",
+ "alSeqNextEvent: Unsupported system exclusive",
+ "alSeqNextEvent: Unsupported midi meta event 0x%x",
+ "_handleMIDIMsg: Invalid program change to %d, max instruments %d",
+ "_handleMIDIMsg: Unknown midi message 0x%x",
+ "_unmapVoice: Couldn't unmap voice 0x%x",
+ "alEvtqPostEvent: Out of free events",
+ "alHeapAlloc: Can't allocate %d bytes",
+ "alHeapCheck: Heap corrupt",
+ "alHeapCheck: Heap corrupt - first block is bad",
+ "alCSeqGetTrackEvent: Running status of zero on track %d",
+ "alCSeqGetTrackEvent: Note on velocity of zero on track %d",
+ "alCSPVoiceHandler: Stopping sequence but voice not free chan %d, key %d",
+ "alSeqNextEvent: Read past end of sequence",
+ "osAiSetNextBuffer: DMA buffer location may cause audio clicks (0x%x)",
+ "_loadOutputBuffer: Modulated delay greater than total delay by %d samples",
+ "osViExtendVStart: VI Manager not yet begun by osCreateViManager",
+ "osViExtendVStart: value not in range [0-48] %d",
+ NULSTR,
+};
+
+static void kmcErrorHandler(s16 code, s16 numArgs, ...);
+OSErrorHandler __kmcErrorHandler = kmcErrorHandler;
+
+static void kmcErrorHandler(s16 code, s16 numArgs, ...) {
+ int ans;
+ va_list ap;
+ char* fmt;
+
+ fmt = __os_error_message[code];
+ va_start(ap, numArgs);
+
+ if (__kmc_pt_mode) {
+ ans = _Printf(kmc_proutSyncPrintf, NULL, fmt, ap);
+ } else {
+ ans = _Printf(proutSyncPrintf, NULL, fmt, ap);
+ }
+
+ osSyncPrintf("\n");
+
+ va_end(ap);
+}
+
+#endif
diff --git a/lib/ultralib/src/flash/flashinit.c b/lib/ultralib/src/flash/flashinit.c
index 33c7dc3..5be7cdd 100644
--- a/lib/ultralib/src/flash/flashinit.c
+++ b/lib/ultralib/src/flash/flashinit.c
@@ -1,11 +1,11 @@
#include "ultra64.h"
#include "PR/os_internal_flash.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
-u32 __osFlashID[4] ALIGNED(8);
-OSIoMesg __osFlashMsg ALIGNED(8);
-OSMesgQueue __osFlashMessageQ ALIGNED(8);
-OSPiHandle __osFlashHandler ALIGNED(8);
+u32 __osFlashID[4] ALIGNED(0x8);
+OSIoMesg __osFlashMsg ALIGNED(0x8);
+OSMesgQueue __osFlashMessageQ ALIGNED(0x8);
+OSPiHandle __osFlashHandler ALIGNED(0x8);
OSMesg __osFlashMsgBuf[1];
s32 __osFlashVersion;
diff --git a/lib/ultralib/src/gio/giointerrupt.c b/lib/ultralib/src/gio/giointerrupt.c
index 3abc04f..121c5d8 100644
--- a/lib/ultralib/src/gio/giointerrupt.c
+++ b/lib/ultralib/src/gio/giointerrupt.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "../io/piint.h"
+#include "PRinternal/piint.h"
void __osGIOInterrupt(s32 value) {
__osPiGetAccess();
diff --git a/lib/ultralib/src/gio/giorawinterrupt.c b/lib/ultralib/src/gio/giorawinterrupt.c
index 2fdc909..e36f5de 100644
--- a/lib/ultralib/src/gio/giorawinterrupt.c
+++ b/lib/ultralib/src/gio/giorawinterrupt.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../io/piint.h"
+#include "PRinternal/piint.h"
void __osGIORawInterrupt(s32 value) {
register u32 stat;
diff --git a/lib/ultralib/src/gt/dumpturbo.c b/lib/ultralib/src/gt/dumpturbo.c
index 02c0e63..91da2b7 100644
--- a/lib/ultralib/src/gt/dumpturbo.c
+++ b/lib/ultralib/src/gt/dumpturbo.c
@@ -18,7 +18,7 @@
#include <ultra64.h>
#include <gt.h>
-#include "macros.h"
+#include "PRinternal/macros.h"
#if BUILD_VERSION < VERSION_J
#ident "$Revision: 1.4 $"
@@ -29,7 +29,7 @@
#define TX_MAX 100
-static u32 textures[TX_MAX] ALIGNED(8);
+static u32 textures[TX_MAX] ALIGNED(0x8);
static u32 numtextures;
#define UNSEG_ADDR(sa) ((u32 *) (((globp)? \
diff --git a/lib/ultralib/src/gu/loadtextureblockmipmap.c b/lib/ultralib/src/gu/loadtextureblockmipmap.c
index 30ffc65..3381c72 100644
--- a/lib/ultralib/src/gu/loadtextureblockmipmap.c
+++ b/lib/ultralib/src/gu/loadtextureblockmipmap.c
@@ -16,7 +16,7 @@
#include "guint.h"
#include <stdio.h>
#include "ultra64.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#ident "$Revision: 1.49 $"
@@ -44,7 +44,7 @@ struct Tile
};
/* tram mipmaps */
-static struct Tile mipmap[MM_MAX_LEVEL+1] ALIGNED(8);
+static struct Tile mipmap[MM_MAX_LEVEL+1] ALIGNED(0x8);
static struct texelSizeParams sizeParams[4] =
{ 16, 3, 1, 0,
8, 2, 2, 1,
diff --git a/lib/ultralib/src/gu/mtxcatf.c b/lib/ultralib/src/gu/mtxcatf.c
index 6572e0f..567e46f 100644
--- a/lib/ultralib/src/gu/mtxcatf.c
+++ b/lib/ultralib/src/gu/mtxcatf.c
@@ -1,63 +1,63 @@
-
-/*
- * 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: mtxcatf.c
- * Creator: hsa@sgi.com
- * Create Date: Thu Nov 2 13:03:02 PST 1995
- *
- */
-
-#include "guint.h"
-
-void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4])
-{
- int i, j, k;
- float temp[4][4];
-
- for (i=0; i<4; i++) {
- for (j=0; j<4; j++) {
- temp[i][j] = 0.0;
- for (k=0; k<4; k++) {
- temp[i][j] += mf[i][k] * nf[k][j];
- }
- }
- }
-
- /* make sure we handle case where result is an input */
- for (i=0; i<4; i++) {
- for (j=0; j<4; j++) {
- res[i][j] = temp[i][j];
- }
- }
-}
-
-void guMtxXFMF(float mf[4][4], float x, float y, float z, float *ox, float *oy, float *oz)
-{
- *ox = mf[0][0]*x + mf[1][0]*y + mf[2][0]*z + mf[3][0];
- *oy = mf[0][1]*x + mf[1][1]*y + mf[2][1]*z + mf[3][1];
- *oz = mf[0][2]*x + mf[1][2]*y + mf[2][2]*z + mf[3][2];
-}
-
+
+/*
+ * 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: mtxcatf.c
+ * Creator: hsa@sgi.com
+ * Create Date: Thu Nov 2 13:03:02 PST 1995
+ *
+ */
+
+#include "guint.h"
+
+void guMtxCatF(float mf[4][4], float nf[4][4], float res[4][4])
+{
+ int i, j, k;
+ float temp[4][4];
+
+ for (i=0; i<4; i++) {
+ for (j=0; j<4; j++) {
+ temp[i][j] = 0.0;
+ for (k=0; k<4; k++) {
+ temp[i][j] += mf[i][k] * nf[k][j];
+ }
+ }
+ }
+
+ /* make sure we handle case where result is an input */
+ for (i=0; i<4; i++) {
+ for (j=0; j<4; j++) {
+ res[i][j] = temp[i][j];
+ }
+ }
+}
+
+void guMtxXFMF(float mf[4][4], float x, float y, float z, float *ox, float *oy, float *oz)
+{
+ *ox = mf[0][0]*x + mf[1][0]*y + mf[2][0]*z + mf[3][0];
+ *oy = mf[0][1]*x + mf[1][1]*y + mf[2][1]*z + mf[3][1];
+ *oz = mf[0][2]*x + mf[1][2]*y + mf[2][2]*z + mf[3][2];
+}
+
diff --git a/lib/ultralib/src/gu/normalize.c b/lib/ultralib/src/gu/normalize.c
index 6884b29..5cf71cd 100644
--- a/lib/ultralib/src/gu/normalize.c
+++ b/lib/ultralib/src/gu/normalize.c
@@ -1,23 +1,23 @@
-/**************************************************************************
- * *
- * 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 "guint.h"
-
-void guNormalize(float *x, float *y, float *z)
-{
- float m;
-
- m = 1/sqrtf((*x)*(*x) + (*y)*(*y) + (*z)*(*z));
- *x *= m;
- *y *= m;
- *z *= m;
-}
+/**************************************************************************
+ * *
+ * 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 "guint.h"
+
+void guNormalize(float *x, float *y, float *z)
+{
+ float m;
+
+ m = 1/sqrtf((*x)*(*x) + (*y)*(*y) + (*z)*(*z));
+ *x *= m;
+ *y *= m;
+ *z *= m;
+}
diff --git a/lib/ultralib/src/gu/scale.c b/lib/ultralib/src/gu/scale.c
index 1523cd0..70bdbcf 100644
--- a/lib/ultralib/src/gu/scale.c
+++ b/lib/ultralib/src/gu/scale.c
@@ -1,32 +1,32 @@
-/**************************************************************************
- * *
- * 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 "guint.h"
-
-void guScaleF(float mf[4][4], float x, float y, float z)
-{
- guMtxIdentF(mf);
-
- mf[0][0] = x;
- mf[1][1] = y;
- mf[2][2] = z;
- mf[3][3] = 1;
-}
-
-void guScale(Mtx *m, float x, float y, float z)
-{
- Matrix mf;
-
- guScaleF(mf, x, y, z);
-
- guMtxF2L(mf, m);
-}
+/**************************************************************************
+ * *
+ * 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 "guint.h"
+
+void guScaleF(float mf[4][4], float x, float y, float z)
+{
+ guMtxIdentF(mf);
+
+ mf[0][0] = x;
+ mf[1][1] = y;
+ mf[2][2] = z;
+ mf[3][3] = 1;
+}
+
+void guScale(Mtx *m, float x, float y, float z)
+{
+ Matrix mf;
+
+ guScaleF(mf, x, y, z);
+
+ guMtxF2L(mf, m);
+}
diff --git a/lib/ultralib/src/gu/translate.c b/lib/ultralib/src/gu/translate.c
index f086f39..18148b1 100644
--- a/lib/ultralib/src/gu/translate.c
+++ b/lib/ultralib/src/gu/translate.c
@@ -1,31 +1,31 @@
-/**************************************************************************
- * *
- * 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 "guint.h"
-
-void guTranslateF(float mf[4][4], float x, float y, float z)
-{
- guMtxIdentF(mf);
-
- mf[3][0] = x;
- mf[3][1] = y;
- mf[3][2] = z;
-}
-
-void guTranslate(Mtx *m, float x, float y, float z)
-{
- Matrix mf;
-
- guTranslateF(mf, x, y, z);
-
- guMtxF2L(mf, m);
-}
+/**************************************************************************
+ * *
+ * 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 "guint.h"
+
+void guTranslateF(float mf[4][4], float x, float y, float z)
+{
+ guMtxIdentF(mf);
+
+ mf[3][0] = x;
+ mf[3][1] = y;
+ mf[3][2] = z;
+}
+
+void guTranslate(Mtx *m, float x, float y, float z)
+{
+ Matrix mf;
+
+ guTranslateF(mf, x, y, z);
+
+ guMtxF2L(mf, m);
+}
diff --git a/lib/ultralib/src/host/host_ptn64.c b/lib/ultralib/src/host/host_ptn64.c
index 54e5e9e..bdd092f 100644
--- a/lib/ultralib/src/host/host_ptn64.c
+++ b/lib/ultralib/src/host/host_ptn64.c
@@ -3,7 +3,7 @@
#include "PR/rcp.h"
#include "memory.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
#if BUILD_VERSION >= VERSION_J || !defined(_FINALROM)
@@ -12,7 +12,7 @@ static volatile unsigned int* ptstat = (unsigned*)0xbff08004;
static volatile unsigned int* ptport = (unsigned*)0xbff08000;
static volatile unsigned int* n64piok = (unsigned*)PHYS_TO_K1(PI_STATUS_REG);
-static OSMesgQueue waitPtQueue ALIGNED(8);
+static OSMesgQueue waitPtQueue ALIGNED(0x8);
static OSMesg waitPtQueueBuf;
static u32 isWaitPtQueueCreated = FALSE;
diff --git a/lib/ultralib/src/host/readhost.c b/lib/ultralib/src/host/readhost.c
index ed6402d..9bc8d8a 100644
--- a/lib/ultralib/src/host/readhost.c
+++ b/lib/ultralib/src/host/readhost.c
@@ -3,10 +3,10 @@
#include "PR/os_internal.h"
#include "PR/rdb.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
static int readHostInitialized = FALSE;
-static OSMesgQueue readHostMesgQueue ALIGNED(8);
+static OSMesgQueue readHostMesgQueue ALIGNED(0x8);
static OSMesg readHostMesgBuf[1];
u32 __osRdb_Read_Data_Buf;
diff --git a/lib/ultralib/src/host/writehost.c b/lib/ultralib/src/host/writehost.c
index c7477e6..1d1baf4 100644
--- a/lib/ultralib/src/host/writehost.c
+++ b/lib/ultralib/src/host/writehost.c
@@ -4,10 +4,10 @@
#include "PR/rdb.h"
#include "PR/ultraerror.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
static int writeHostInitialized = FALSE;
-static OSMesgQueue writeHostMesgQueue ALIGNED(8);
+static OSMesgQueue writeHostMesgQueue ALIGNED(0x8);
static OSMesg writeHostMesgBuf[1];
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
diff --git a/lib/ultralib/src/io/aigetlen.c b/lib/ultralib/src/io/aigetlen.c
index 6b83682..aadf891 100644
--- a/lib/ultralib/src/io/aigetlen.c
+++ b/lib/ultralib/src/io/aigetlen.c
@@ -3,6 +3,12 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
+/**
+ * Returns the number of bytes remaining in a currently ongoing audio DMA.
+ *
+ * Note that audio DMA is double-buffered, a DMA can be queued while another is in-progress. This only returns
+ * information about the currently in-progress DMA.
+ */
u32 osAiGetLength(void) {
return IO_READ(AI_LEN_REG);
}
diff --git a/lib/ultralib/src/io/aigetstat.c b/lib/ultralib/src/io/aigetstat.c
index c7a3cf7..270b66e 100644
--- a/lib/ultralib/src/io/aigetstat.c
+++ b/lib/ultralib/src/io/aigetstat.c
@@ -3,6 +3,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 osAiGetStatus() {
+u32 osAiGetStatus(void) {
return IO_READ(AI_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/aisetfreq.c b/lib/ultralib/src/io/aisetfreq.c
index e41d6fa..2b0efca 100644
--- a/lib/ultralib/src/io/aisetfreq.c
+++ b/lib/ultralib/src/io/aisetfreq.c
@@ -1,12 +1,18 @@
#include "PR/rcp.h"
#include "PR/ultraerror.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: not sure if this should be here
extern s32 osViClock;
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
+/**
+ * Programs the operating frequency of the Audio DAC.
+ *
+ * @param frequency Target Playback frequency.
+ * @return The actual playback frequency, or -1 if the supplied frequency cannot be used.
+ */
s32 osAiSetFrequency(u32 frequency) {
register unsigned int dacRate;
register unsigned char bitRate;
@@ -31,15 +37,20 @@ s32 osAiSetFrequency(u32 frequency) {
}
#endif
+ // Calculate the DAC sample period ("dperiod") (dperiod + 1 = vid_clock / frequency)
f = osViClock / (float)frequency + .5f;
dacRate = f;
+ // Upcoming division by 66. If dacRate is smaller than 2 * 66 = 132, bitrate will be 1 and AI_BITRATE_REG will be
+ // programmed with 0, which results in no audio output. Return -1 to indicate an unusable frequency.
if (dacRate < AI_MIN_DAC_RATE) {
return -1;
}
+ // Calculate the largest "bitrate" (ABUS clock half period, "aclockhp") supported for this dacrate. These two
+ // quantities must satisfy (dperiod + 1) >= 66 * (aclockhp + 1), here this is taken as equality.
bitRate = dacRate / 66;
-
+ // Clamp to max value
if (bitRate > AI_MAX_BIT_RATE) {
bitRate = AI_MAX_BIT_RATE;
}
@@ -49,5 +60,7 @@ s32 osAiSetFrequency(u32 frequency) {
#if BUILD_VERSION < VERSION_J
IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON);
#endif
+ // Return the true playback frequency (frequency = vid_clock / (dperiod + 1)), which may differ from the target
+ // frequency.
return osViClock / (s32)dacRate;
}
diff --git a/lib/ultralib/src/io/aisetnextbuf.c b/lib/ultralib/src/io/aisetnextbuf.c
index 041b61d..78634a9 100644
--- a/lib/ultralib/src/io/aisetnextbuf.c
+++ b/lib/ultralib/src/io/aisetnextbuf.c
@@ -1,11 +1,20 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
+/**
+ * Submits an audio buffer to be consumed by the Audio DAC. The audio interface can queue a second DMA while another
+ * is in progress and automatically begin the next one as soon as the current DMA completes. If there is already a
+ * second DMA queued (DMA is full), -1 is returned to indicate the buffer could not be submitted.
+ *
+ * @param bufPtr Next audio buffer. Must be an 8-byte aligned KSEG0 (0x80XXXXXX) address.
+ * @param size Length of next audio buffer in bytes, maximum size 0x40000 bytes / 256 KiB. Should be a multiple of 8.
+ * @return 0 if the DMA was enqueued successfully, -1 if the DMA could not yet be queued.
+ */
s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
static u8 hdwrBugFlag = FALSE;
char* bptr;
@@ -41,6 +50,9 @@ s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
}
#if BUILD_VERSION < VERSION_J
+ //! @bug The __osAiDeviceBusy call should be above the hardware bug workaround to ensure that it was only
+ //! performed when a transfer was guaranteed to start. If this condition passes and this function returns without
+ //! submitting a buffer for DMA, the code above will lose track of when to apply the workaround.
if (__osAiDeviceBusy()) {
return -1;
}
diff --git a/lib/ultralib/src/io/cartrominit.c b/lib/ultralib/src/io/cartrominit.c
index 87aa8bb..7f2eb11 100644
--- a/lib/ultralib/src/io/cartrominit.c
+++ b/lib/ultralib/src/io/cartrominit.c
@@ -1,12 +1,12 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_version.h"
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/rcp.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
#if BUILD_VERSION >= VERSION_J
-OSPiHandle __CartRomHandle ALIGNED(8);
+OSPiHandle __CartRomHandle ALIGNED(0x8);
OSPiHandle* osCartRomInit(void) {
u32 value = 0;
u32 saveMask;
@@ -65,7 +65,7 @@ OSPiHandle* osCartRomInit(void) {
}
#else
-OSPiHandle CartRomHandle ALIGNED(8);
+OSPiHandle CartRomHandle ALIGNED(0x8);
OSPiHandle* osCartRomInit(void) {
u32 domain = 0;
u32 saveMask;
diff --git a/lib/ultralib/src/io/contchannelreset.c b/lib/ultralib/src/io/contchannelreset.c
index f6ed8a2..108a594 100644
--- a/lib/ultralib/src/io/contchannelreset.c
+++ b/lib/ultralib/src/io/contchannelreset.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 __osContChannelReset(OSMesgQueue* mq, int channel) {
s32 i;
diff --git a/lib/ultralib/src/io/conteeplongread.c b/lib/ultralib/src/io/conteeplongread.c
index d8d59f6..edebfc8 100644
--- a/lib/ultralib/src/io/conteeplongread.c
+++ b/lib/ultralib/src/io/conteeplongread.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osEepromLongRead(OSMesgQueue* mq, u8 address, u8* buffer, int length) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/conteeplongwrite.c b/lib/ultralib/src/io/conteeplongwrite.c
index c5668e1..8ecce25 100644
--- a/lib/ultralib/src/io/conteeplongwrite.c
+++ b/lib/ultralib/src/io/conteeplongwrite.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osEepromLongWrite(OSMesgQueue* mq, u8 address, u8* buffer, int length) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/conteepprobe.c b/lib/ultralib/src/io/conteepprobe.c
index b19dc49..ca09790 100644
--- a/lib/ultralib/src/io/conteepprobe.c
+++ b/lib/ultralib/src/io/conteepprobe.c
@@ -1,5 +1,5 @@
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 osEepromProbe(OSMesgQueue* mq) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/conteepread.c b/lib/ultralib/src/io/conteepread.c
index 2d334fa..502ab13 100644
--- a/lib/ultralib/src/io/conteepread.c
+++ b/lib/ultralib/src/io/conteepread.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
-OSPifRam __osEepPifRam ALIGNED(16);
+OSPifRam __osEepPifRam;
#if BUILD_VERSION >= VERSION_L
s32 __osEepromRead16K;
#endif
diff --git a/lib/ultralib/src/io/conteepwrite.c b/lib/ultralib/src/io/conteepwrite.c
index 7352430..9ebda24 100644
--- a/lib/ultralib/src/io/conteepwrite.c
+++ b/lib/ultralib/src/io/conteepwrite.c
@@ -1,7 +1,8 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
static void __osPackEepWriteData(u8 address, u8* buffer);
s32 osEepromWrite(OSMesgQueue* mq, u8 address, u8* buffer) {
diff --git a/lib/ultralib/src/io/contpfs.c b/lib/ultralib/src/io/contpfs.c
index c845a7d..8574de1 100644
--- a/lib/ultralib/src/io/contpfs.c
+++ b/lib/ultralib/src/io/contpfs.c
@@ -1,11 +1,11 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/os_version.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "PR/rmon.h"
#if BUILD_VERSION >= VERSION_J
-__OSInode __osPfsInodeCache ALIGNED(8);
+__OSInode __osPfsInodeCache ALIGNED(0x8);
s32 __osPfsInodeCacheChannel = -1;
u8 __osPfsInodeCacheBank = 250;
#endif
diff --git a/lib/ultralib/src/io/contquery.c b/lib/ultralib/src/io/contquery.c
index df038ce..d3c06fc 100644
--- a/lib/ultralib/src/io/contquery.c
+++ b/lib/ultralib/src/io/contquery.c
@@ -1,7 +1,11 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
+/**
+ * Starts to read the values for SI device status and type which are connected to the controller port and joyport
+ * connector.
+ */
s32 osContStartQuery(OSMesgQueue* mq) {
s32 ret = 0;
@@ -19,6 +23,9 @@ s32 osContStartQuery(OSMesgQueue* mq) {
return ret;
}
+/**
+ * Returns the values from osContStartQuery to status. Both functions must be paired for use.
+ */
void osContGetQuery(OSContStatus* data) {
u8 pattern;
__osContGetInitData(&pattern, data);
diff --git a/lib/ultralib/src/io/contramread.c b/lib/ultralib/src/io/contramread.c
index 9c399ee..99c8332 100644
--- a/lib/ultralib/src/io/contramread.c
+++ b/lib/ultralib/src/io/contramread.c
@@ -1,7 +1,8 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr))
diff --git a/lib/ultralib/src/io/contramwrite.c b/lib/ultralib/src/io/contramwrite.c
index a213049..0d79701 100644
--- a/lib/ultralib/src/io/contramwrite.c
+++ b/lib/ultralib/src/io/contramwrite.c
@@ -1,7 +1,8 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
extern s32 __osPfsLastChannel;
diff --git a/lib/ultralib/src/io/contreaddata.c b/lib/ultralib/src/io/contreaddata.c
index da0cac3..a2b1730 100644
--- a/lib/ultralib/src/io/contreaddata.c
+++ b/lib/ultralib/src/io/contreaddata.c
@@ -1,6 +1,7 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
static void __osPackReadData(void);
diff --git a/lib/ultralib/src/io/contreset.c b/lib/ultralib/src/io/contreset.c
index 140088a..c752f5b 100644
--- a/lib/ultralib/src/io/contreset.c
+++ b/lib/ultralib/src/io/contreset.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
void __osPackResetData(void);
diff --git a/lib/ultralib/src/io/controller.c b/lib/ultralib/src/io/controller.c
index 728c207..fd87b16 100644
--- a/lib/ultralib/src/io/controller.c
+++ b/lib/ultralib/src/io/controller.c
@@ -1,17 +1,17 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
-OSPifRam __osContPifRam ALIGNED(16);
+OSPifRam __osContPifRam;
u8 __osContLastCmd;
u8 __osMaxControllers;
OSTimer __osEepromTimer;
-OSMesgQueue __osEepromTimerQ ALIGNED(8);
+OSMesgQueue __osEepromTimerQ ALIGNED(0x8);
OSMesg __osEepromTimerMsg;
-s32 __osContinitialized = 0;
+s32 __osContinitialized = FALSE;
s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
OSMesg dummy;
@@ -20,11 +20,11 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
OSTimer mytimer;
OSMesgQueue timerMesgQueue;
- if (__osContinitialized != 0) {
+ if (__osContinitialized) {
return 0;
}
- __osContinitialized = 1;
+ __osContinitialized = TRUE;
t = osGetTime();
if (t < OS_USEC_TO_CYCLES(500000)) {
diff --git a/lib/ultralib/src/io/contsetch.c b/lib/ultralib/src/io/contsetch.c
index 0cababd..73a1ac1 100644
--- a/lib/ultralib/src/io/contsetch.c
+++ b/lib/ultralib/src/io/contsetch.c
@@ -1,7 +1,11 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
+/*
+ * This function specifies the number of devices for the functions to access when those functions access to multiple
+ * direct SI devices.
+ */
s32 osContSetCh(u8 ch) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/crc.c b/lib/ultralib/src/io/crc.c
index 3293b2d..bb6eb20 100644
--- a/lib/ultralib/src/io/crc.c
+++ b/lib/ultralib/src/io/crc.c
@@ -1,56 +1,154 @@
+/**
+ * File: crc.c
+ * Description: Functions to compute Cyclic Redundancy Check for specific addresses and data.
+ *
+ * CRC notes:
+ *
+ * General
+ * ===
+ * - CRC (Cyclic Redundancy Check) is a way of verifying that no errors were introduced in transmitted data.
+ * - It reads the entire message and generates a check number that is appended to it.
+ * - A CRC is specified by the length `n` of the check number and a number (called the generator) smaller than `1 << n`.
+ * - Different generators have different error-checking capabilities. The choice of a generator is a sophisticated
+ * mathematical problem.
+ *
+ * Mathematical basis
+ * ===
+ * - The algorithm is based on division of polynomials. The polynomials have coefficients in the field with two
+ * elements, 0 and 1, with addition given by XOR and multiplication by AND (it turns out this really is a field).
+ * Subtraction is the same as addition.
+ * - There is a one-to-one correspondence between binary polynomials and binary numbers: just evaluate the polynomial at
+ * 2, or write down an \f$ X^k \f$ corresponding to each `1 << k` the number is composed of.
+ * - The message bits `m{L}m{L-1}...m{1}m{0}` correspond to a polynomial \f$ m(X) = m_L X^L + m_{L-1} X^{L-1} + \dotsb +
+ * m_1 X^1 + m_0 X^0 \f$. We multiply this by \f$ X^n \f$ to make a space to insert the remainder at the end; this new
+ * polynomial will be the dividend.
+ * - The generator `p{n-1}p{n-2}...p{1}p{0}` corresponds to a polynomial \f$ p(X) = X^n + p_{n-1} X^{n-1} + \dotsb + p_1
+ * X^1 + p_0 X^0 \f$: the leading term is omitted in the binary description because it is always \f$ X^n \f$. The
+ * generator polynomial is the divisor.
+ * - The usual division algorithm is followed: we look along the dividend until we see a nonzero coefficient, then
+ * subtract an appropriate multiple of the divisor to cancel it out. We repeat this until we reach the end of the
+ * number.
+ * - Arithmetic in the field with two elements is particularly simple: subtraction is identical to addition, so also
+ * given by XOR, and the only multipliers required for subtracting the divisor are \f$ X^k \f$.
+ * - After applying the algorithm, the output is a polynomial \f$ R(X) \f$ so that we have
+ * \f[ m(X) X^n = Q(X) p(X) + R(X) \f]
+ * (\f$ R(X) \f$ is the *remainder after dividing by \f$ p(X) \f$*).
+ * - Therefore, \f$ m(X) X^n - R(X) \f$ is divisible by the generator polynomial. This means that if we append the
+ * binary number corresponding to \f$ R(X) \f$ to the message and rerun the algorithm, we will get 0 if no errors have
+ * been introduced.
+ *
+ *
+ * Implementation
+ * ===
+ * - We translate the binary polynomials to binary numbers by evaluating them at 2. The leading term in the generator
+ * polynomial is always \f$ X^n \f$, so we discard it to save space. In the binary field, subtraction is the same as
+ * addition, and given by XOR. Multiplication by \f$ X \f$ is given by shifting left.
+ * - Instead of fixing the message and moving the divisor polynomial right, we scan the message from the most
+ * significant digit, adding it to the end of the return value, (that is, for 1s, we shift and add 1, for 0s we just
+ * shift, effectively using the return value as a shift register).
+ * - When the return value has a 1 in the nth position (corresponding to the leading term in the generator polynomial),
+ * we binary-subtract (i.e. XOR) the return value with the generator polynomial's number.
+ * - This is repeated until we reach the end of the message.
+ * - Finally, to take into account the final multiplication by \f$ X^n \f$, we run another loop, which acts like we
+ * passed \f$ n \f$ more digits in the message that are all zero. Remember this gives us the extra space at the end for
+ * the check digits to be added.
+ *
+ *
+ * - To specify a CRC, at minimum we need the length of the check (i.e. the degree of the generator polynomial), \f$ n
+ * \f$, and the rest of the generator polynomial. This is usually expressed in the binary form, written as hex for
+ * compactness. Algorithms may also reverse or invert certain parts of the data or check to improve particular aspects
+ * of the algorithm, but the libultra functions use the simplest version.
+ *
+ *
+ * Resources
+ * ===
+ * - Wikipedia: [Cyclic redundancy check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check), and more specifically
+ * [Computation of cyclic redundancy checks](https://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks)
+ * - Ben Eater has two videos on CRCs, the last two linked on [Error Detection | Ben Eater](https://eater.net/crc)
+ * - A page that specifically describes the same shift-register-style algorithms as libultra uses: [Understanding and
+ * implementing CRC (Cyclic Redundancy Check) calculation
+ * ](http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html)
+ */
#include "PR/os_internal.h"
#if BUILD_VERSION >= VERSION_J
+#define ADDRESS_CRC_MESSAGE_LENGTH 10
+#define ADDRESS_CRC_LENGTH 5
+#define ADDRESS_CRC_GENERATOR 0x15
+#define ADDRESS_CRC_MASK ((1 << ADDRESS_CRC_LENGTH) - 1)
+
+/**
+ * CRC-5 with the generating polynomial \f$ x^5 + x^4 + x^2 + 1 \f$, AKA 0x15 = 0b(1)1 0101.
+ * It only works on the bits from 0x7FF = 11 11111111, i.e. 10 bits.
+ *
+ * Usually used as __osContAddressCrc(addr) | (addr << 5) to add the CRC to the end. The overall length of 10 + 5 bits
+ * allows the address + CRC to fit into one s16.
+ *
+ * `addr` is the address of a block in the mempak, only valid up to 0x7FF.
+ */
u8 __osContAddressCrc(u16 addr) {
u32 temp = 0;
- u32 i = 0x400;
+ u32 i = (1 << ADDRESS_CRC_MESSAGE_LENGTH);
do {
+ // temp is used as a shift register for the CRC
temp <<= 1;
if ((u32)addr & i) {
- if (temp & 0x20) {
- temp ^= 0x14;
+ if (temp & (1 << ADDRESS_CRC_LENGTH)) {
+ // Same as temp++; temp ^= 0x15 since last bit always 0 after the shift
+ temp ^= ADDRESS_CRC_GENERATOR - 1;
} else {
++temp;
}
- } else if (temp & 0x20) {
- temp ^= 0x15;
+ } else if (temp & (1 << ADDRESS_CRC_LENGTH)) {
+ temp ^= ADDRESS_CRC_GENERATOR;
}
i >>= 1;
} while (i != 0);
- i = 5;
-
+ // Acts like 5 bits of 0s are appended to addr
+ i = ADDRESS_CRC_LENGTH;
do {
temp <<= 1;
- if (temp & 0x20) {
- temp ^= 0x15;
+ if (temp & (1 << ADDRESS_CRC_LENGTH)) {
+ temp ^= ADDRESS_CRC_GENERATOR;
}
} while (--i != 0);
- return temp & 0x1F;
+ // Discard the irrelevant bits above the actual remainder
+ return temp & ADDRESS_CRC_MASK;
}
+#define DATA_CRC_MESSAGE_BYTES 32
+#define DATA_CRC_LENGTH 8
+#define DATA_CRC_GENERATOR 0x85
+
+/**
+ * CRC-8 with generating polynomial \f$ x^8 + x^7 + x^2 + 1 \f$, AKA 0x85 = 0b(1) 1000 0101.
+ * Expects exactly 0x20 = 32 bytes of data.
+ */
u8 __osContDataCrc(u8* data) {
u32 temp = 0;
u32 i;
u32 j;
- for (i = 0x20; i; --i) {
- for (j = 0x80; j; j >>= 1) {
+ for (i = DATA_CRC_MESSAGE_BYTES; i; --i) {
+ // Loop over each bit in the byte starting with most significant
+ for (j = (1 << (DATA_CRC_LENGTH - 1)); j; j >>= 1) {
temp <<= 1;
if ((*data & j) != 0) {
- if ((temp & 0x100) != 0) {
- temp ^= 0x84;
+ if ((temp & (1 << DATA_CRC_LENGTH)) != 0) {
+ // Same as ret++; ret ^= 0x85 since last bit always 0 after the shift
+ temp ^= DATA_CRC_GENERATOR - 1;
} else {
++temp;
}
- } else if (temp & 0x100) {
- temp ^= 0x85;
+ } else if (temp & (1 << DATA_CRC_LENGTH)) {
+ temp ^= DATA_CRC_GENERATOR;
}
}
@@ -59,10 +157,10 @@ u8 __osContDataCrc(u8* data) {
do {
temp <<= 1;
- if (temp & 0x100) {
- temp ^= 0x85;
+ if (temp & (1 << DATA_CRC_LENGTH)) {
+ temp ^= DATA_CRC_GENERATOR;
}
- } while (++i < 8U);
+ } while (++i < DATA_CRC_LENGTH);
return temp;
}
diff --git a/lib/ultralib/src/io/devmgr.c b/lib/ultralib/src/io/devmgr.c
index 616dee5..70b26cc 100644
--- a/lib/ultralib/src/io/devmgr.c
+++ b/lib/ultralib/src/io/devmgr.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
void __osDevMgrMain(void* args) {
OSIoMesg* mb;
diff --git a/lib/ultralib/src/io/dpgetstat.c b/lib/ultralib/src/io/dpgetstat.c
index af3ccee..54dd3ac 100644
--- a/lib/ultralib/src/io/dpgetstat.c
+++ b/lib/ultralib/src/io/dpgetstat.c
@@ -4,6 +4,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 osDpGetStatus() {
+u32 osDpGetStatus(void) {
return IO_READ(DPC_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/dpsetnextbuf.c b/lib/ultralib/src/io/dpsetnextbuf.c
index 6314472..cbf3a6f 100644
--- a/lib/ultralib/src/io/dpsetnextbuf.c
+++ b/lib/ultralib/src/io/dpsetnextbuf.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/driverominit.c b/lib/ultralib/src/io/driverominit.c
index d73d349..d3e1bcf 100644
--- a/lib/ultralib/src/io/driverominit.c
+++ b/lib/ultralib/src/io/driverominit.c
@@ -1,10 +1,10 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
-OSPiHandle DriveRomHandle ALIGNED(8);
+OSPiHandle DriveRomHandle ALIGNED(0x8);
-OSPiHandle *osDriveRomInit() {
+OSPiHandle *osDriveRomInit(void) {
u32 saveMask;
if (DriveRomHandle.baseAddress == PHYS_TO_K1(PI_DOM1_ADDR1)) {
diff --git a/lib/ultralib/src/io/epidma.c b/lib/ultralib/src/io/epidma.c
index 06a9f69..77c6be6 100644
--- a/lib/ultralib/src/io/epidma.c
+++ b/lib/ultralib/src/io/epidma.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
diff --git a/lib/ultralib/src/io/epigettype.c b/lib/ultralib/src/io/epigettype.c
index c94012c..8487e68 100644
--- a/lib/ultralib/src/io/epigettype.c
+++ b/lib/ultralib/src/io/epigettype.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
s32 osEPiGetDeviceType(OSPiHandle* pihandle, OSPiInfo* info) {
info->type = pihandle->type;
diff --git a/lib/ultralib/src/io/epilinkhandle.c b/lib/ultralib/src/io/epilinkhandle.c
index 5f51854..2e9b1fa 100644
--- a/lib/ultralib/src/io/epilinkhandle.c
+++ b/lib/ultralib/src/io/epilinkhandle.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
s32 osEPiLinkHandle(OSPiHandle* EPiHandle) {
u32 saveMask = __osDisableInt();
diff --git a/lib/ultralib/src/io/epirawdma.c b/lib/ultralib/src/io/epirawdma.c
index 69a404d..b862353 100644
--- a/lib/ultralib/src/io/epirawdma.c
+++ b/lib/ultralib/src/io/epirawdma.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/epirawread.c b/lib/ultralib/src/io/epirawread.c
index 500a2ce..f6d446c 100644
--- a/lib/ultralib/src/io/epirawread.c
+++ b/lib/ultralib/src/io/epirawread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/epirawwrite.c b/lib/ultralib/src/io/epirawwrite.c
index 79fba31..9ab98a8 100644
--- a/lib/ultralib/src/io/epirawwrite.c
+++ b/lib/ultralib/src/io/epirawwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/epiread.c b/lib/ultralib/src/io/epiread.c
index 08cd0be..b2f346b 100644
--- a/lib/ultralib/src/io/epiread.c
+++ b/lib/ultralib/src/io/epiread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osEPiReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data) {
diff --git a/lib/ultralib/src/io/epiwrite.c b/lib/ultralib/src/io/epiwrite.c
index 42a239e..767caf5 100644
--- a/lib/ultralib/src/io/epiwrite.c
+++ b/lib/ultralib/src/io/epiwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osEPiWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data) {
diff --git a/lib/ultralib/src/io/gbpakcheckconnector.c b/lib/ultralib/src/io/gbpakcheckconnector.c
index 8eb3298..1d542bc 100644
--- a/lib/ultralib/src/io/gbpakcheckconnector.c
+++ b/lib/ultralib/src/io/gbpakcheckconnector.c
@@ -1,6 +1,6 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osGbpakCheckConnector(OSPfs* pfs, u8* status) {
s32 ret;
diff --git a/lib/ultralib/src/io/gbpakgetbank.c b/lib/ultralib/src/io/gbpakgetbank.c
index a2e5f38..e448688 100644
--- a/lib/ultralib/src/io/gbpakgetbank.c
+++ b/lib/ultralib/src/io/gbpakgetbank.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 __osGbpakGetBank(OSPfs* pfs, u8* bank) {
s32 ret;
diff --git a/lib/ultralib/src/io/gbpakgetstatus.c b/lib/ultralib/src/io/gbpakgetstatus.c
index d17d15c..76e7891 100644
--- a/lib/ultralib/src/io/gbpakgetstatus.c
+++ b/lib/ultralib/src/io/gbpakgetstatus.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osGbpakGetStatus(OSPfs* pfs, u8* status) {
s32 ret;
diff --git a/lib/ultralib/src/io/gbpakinit.c b/lib/ultralib/src/io/gbpakinit.c
index 102d962..e101c1e 100644
--- a/lib/ultralib/src/io/gbpakinit.c
+++ b/lib/ultralib/src/io/gbpakinit.c
@@ -1,10 +1,10 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "controller_gbpak.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/controller_gbpak.h"
OSTimer __osGbpakTimer;
-OSMesgQueue __osGbpakTimerQ ALIGNED(8);
+OSMesgQueue __osGbpakTimerQ ALIGNED(0x8);
OSMesg __osGbpakTimerMsg;
s32 osGbpakInit(OSMesgQueue* mq, OSPfs* pfs, int channel) {
diff --git a/lib/ultralib/src/io/gbpakpower.c b/lib/ultralib/src/io/gbpakpower.c
index 3d4a8f4..e2aa6f7 100644
--- a/lib/ultralib/src/io/gbpakpower.c
+++ b/lib/ultralib/src/io/gbpakpower.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "controller_gbpak.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/controller_gbpak.h"
s32 osGbpakPower(OSPfs* pfs, s32 flag) {
s32 i;
diff --git a/lib/ultralib/src/io/gbpakreadid.c b/lib/ultralib/src/io/gbpakreadid.c
index 3e2fa19..e88fc15 100644
--- a/lib/ultralib/src/io/gbpakreadid.c
+++ b/lib/ultralib/src/io/gbpakreadid.c
@@ -1,6 +1,6 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "os_version.h"
s32 osGbpakReadId(OSPfs* pfs, OSGbpakId* id, u8* status) {
diff --git a/lib/ultralib/src/io/gbpakreadwrite.c b/lib/ultralib/src/io/gbpakreadwrite.c
index a6d4b02..fe16ee2 100644
--- a/lib/ultralib/src/io/gbpakreadwrite.c
+++ b/lib/ultralib/src/io/gbpakreadwrite.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "os_version.h"
s32 __osGbpakSetBank(OSPfs* pfs, u8 bank);
diff --git a/lib/ultralib/src/io/gbpaksetbank.c b/lib/ultralib/src/io/gbpaksetbank.c
index 7a08646..efd2267 100644
--- a/lib/ultralib/src/io/gbpaksetbank.c
+++ b/lib/ultralib/src/io/gbpaksetbank.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 __osGbpakSetBank(OSPfs* pfs, u8 bank) {
int i;
diff --git a/lib/ultralib/src/io/leodiskinit.c b/lib/ultralib/src/io/leodiskinit.c
index e9f140b..cd74e77 100644
--- a/lib/ultralib/src/io/leodiskinit.c
+++ b/lib/ultralib/src/io/leodiskinit.c
@@ -2,12 +2,12 @@
#include "PR/os_internal.h"
#include "PR/os_libc.h"
#include "PR/rcp.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
-OSPiHandle LeoDiskHandle ALIGNED(8);
+OSPiHandle LeoDiskHandle ALIGNED(0x8);
OSPiHandle *__osDiskHandle;
-OSPiHandle *osLeoDiskInit() {
+OSPiHandle *osLeoDiskInit(void) {
u32 saveMask;
LeoDiskHandle.type = DEVICE_TYPE_64DD;
diff --git a/lib/ultralib/src/io/leointerrupt.c b/lib/ultralib/src/io/leointerrupt.c
index ad34e45..a94146e 100644
--- a/lib/ultralib/src/io/leointerrupt.c
+++ b/lib/ultralib/src/io/leointerrupt.c
@@ -1,17 +1,17 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
-#include "piint.h"
-#include "macros.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/piint.h"
+#include "PRinternal/macros.h"
extern OSPiHandle *__osDiskHandle;
-u8 leoDiskStack[OS_PIM_STACKSIZE] ALIGNED(16);
+u8 leoDiskStack[OS_PIM_STACKSIZE] ALIGNED(0x10);
static void __osLeoAbnormalResume(void);
static void __osLeoResume(void);
-s32 __osLeoInterrupt() {
+s32 __osLeoInterrupt(void) {
u32 stat = 0;
volatile u32 pi_stat;
u32 bm_stat;
diff --git a/lib/ultralib/src/io/motor.c b/lib/ultralib/src/io/motor.c
index 8028d69..b859aaf 100644
--- a/lib/ultralib/src/io/motor.c
+++ b/lib/ultralib/src/io/motor.c
@@ -1,11 +1,11 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/os_version.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#if BUILD_VERSION >= VERSION_J
-static OSPifRam __MotorDataBuf[MAXCONTROLLERS] ALIGNED(8);
+static OSPifRam __MotorDataBuf[MAXCONTROLLERS];
#define READFORMAT(ptr) ((__OSContRamReadFormat*)(ptr))
@@ -134,10 +134,10 @@ s32 osMotorInit(OSMesgQueue* mq, OSPfs* pfs, int channel) {
#else
-OSPifRam _MotorStopData[MAXCONTROLLERS] ALIGNED(8);
-OSPifRam _MotorStartData[MAXCONTROLLERS] ALIGNED(8);
-u8 _motorstopbuf[32] ALIGNED(8);
-u8 _motorstartbuf[32] ALIGNED(8);
+OSPifRam _MotorStopData[MAXCONTROLLERS] ALIGNED(0x8);
+OSPifRam _MotorStartData[MAXCONTROLLERS] ALIGNED(0x8);
+u8 _motorstopbuf[32] ALIGNED(0x8);
+u8 _motorstartbuf[32] ALIGNED(0x8);
u32 __osMotorinitialized[MAXCONTROLLERS] = {0, 0, 0, 0};
s32 osMotorStop(OSPfs *pfs) {
diff --git a/lib/ultralib/src/io/pfsallocatefile.c b/lib/ultralib/src/io/pfsallocatefile.c
index 24f6fe7..c31396e 100644
--- a/lib/ultralib/src/io/pfsallocatefile.c
+++ b/lib/ultralib/src/io/pfsallocatefile.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#include "PR/rmon.h"
#define ROUND_UP_DIVIDE(numerator, denominator) (((numerator) + (denominator)-1) / (denominator))
@@ -240,7 +241,7 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name
backup_inode.inode_page[old_last_page].inode_t.bank = bank;
backup_inode.inode_page[old_last_page].inode_t.page = start_page;
- ERRCK(__osPfsRWInode(pfs, &backup_inode, OS_WRITE, old_bank));
+ ERRCK(__osPfsRWInode(pfs, &backup_inode, PFS_WRITE, old_bank));
dir.start_page = fpage;
dir.company_code = company_code;
diff --git a/lib/ultralib/src/io/pfschecker.c b/lib/ultralib/src/io/pfschecker.c
index b736200..77b691a 100644
--- a/lib/ultralib/src/io/pfschecker.c
+++ b/lib/ultralib/src/io/pfschecker.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 corrupted_init(OSPfs* pfs, __OSInodeCache* cache);
s32 corrupted(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache);
@@ -55,7 +56,7 @@ s32 osPfsChecker(OSPfs* pfs) {
bank = next_page.inode_t.bank;
if (oldbank != bank) {
- ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
oldbank = bank;
}
@@ -90,7 +91,7 @@ s32 osPfsChecker(OSPfs* pfs) {
while (CHECK_IPAGE(next_page)) {
if (bank != next_page.inode_t.bank) {
bank = next_page.inode_t.bank;
- ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
}
@@ -142,7 +143,7 @@ s32 osPfsChecker(OSPfs* pfs) {
}
for (bank = 0; bank < pfs->banks; bank++) {
- ret = __osPfsRWInode(pfs, &tmp_inode, 0, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
@@ -164,7 +165,7 @@ s32 osPfsChecker(OSPfs* pfs) {
file_next_node[j] = checked_inode.inode_page[pp] = tmp_inode.inode_page[pp];
}
}
- ERRCK(__osPfsRWInode(pfs, &checked_inode, OS_WRITE, bank));
+ ERRCK(__osPfsRWInode(pfs, &checked_inode, PFS_WRITE, bank));
}
if (fixed) {
@@ -193,7 +194,7 @@ s32 corrupted_init(OSPfs* pfs, __OSInodeCache* cache) {
for (bank = 0; bank < pfs->banks; bank++) {
offset = bank > 0 ? 1 : pfs->inode_start_page;
- ret = __osPfsRWInode(pfs, &tmp_inode, OS_READ, bank);
+ ret = __osPfsRWInode(pfs, &tmp_inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
@@ -234,7 +235,7 @@ s32 corrupted(OSPfs* pfs, __OSInodeUnit fpage, __OSInodeCache* cache) {
if (bank == fpage.inode_t.bank || cache->map[n] & (1 << (bank % PFS_BANK_LAPPED_BY))) {
if (bank != cache->bank) {
- ret = __osPfsRWInode(pfs, &cache->inode, 0, bank);
+ ret = __osPfsRWInode(pfs, &cache->inode, PFS_READ, bank);
if (ret != 0 && ret != PFS_ERR_INCONSISTENT) {
return ret;
diff --git a/lib/ultralib/src/io/pfsdeletefile.c b/lib/ultralib/src/io/pfsdeletefile.c
index e013211..c8cc537 100644
--- a/lib/ultralib/src/io/pfsdeletefile.c
+++ b/lib/ultralib/src/io/pfsdeletefile.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name) {
s32 file_no;
@@ -38,13 +39,13 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name,
startpage = dir.start_page.inode_t.page;
for (bank = dir.start_page.inode_t.bank; bank < pfs->banks;) {
- ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank));
#if BUILD_VERSION >= VERSION_J
ERRCK(__osPfsReleasePages(pfs, &inode, startpage, bank, &last_page));
#else
ERRCK(__osPfsReleasePages(pfs, &inode, startpage, &sum, bank, &last_page, TRUE));
#endif
- ERRCK(__osPfsRWInode(pfs, &inode, OS_WRITE, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_WRITE, bank));
if (last_page.ipage == PFS_EOF) {
break;
diff --git a/lib/ultralib/src/io/pfsfilestate.c b/lib/ultralib/src/io/pfsfilestate.c
index 4f80020..78b9f4a 100644
--- a/lib/ultralib/src/io/pfsfilestate.c
+++ b/lib/ultralib/src/io/pfsfilestate.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) {
s32 ret;
@@ -72,7 +73,7 @@ s32 osPfsFileState(OSPfs* pfs, s32 file_no, OSPfsState* state) {
bank = dir.start_page.inode_t.bank;
while (bank < pfs->banks) {
- ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank));
next_page = inode.inode_page[start_page];
pages++;
diff --git a/lib/ultralib/src/io/pfsfreeblocks.c b/lib/ultralib/src/io/pfsfreeblocks.c
index 68a54c6..78c07c8 100644
--- a/lib/ultralib/src/io/pfsfreeblocks.c
+++ b/lib/ultralib/src/io/pfsfreeblocks.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) {
int j;
@@ -16,7 +17,7 @@ s32 osPfsFreeBlocks(OSPfs* pfs, s32* bytes_not_used) {
PFS_CHECK_ID();
#endif
for (bank = 0; bank < pfs->banks; bank++) {
- ERRCK(__osPfsRWInode(pfs, &inode, OS_READ, bank));
+ ERRCK(__osPfsRWInode(pfs, &inode, PFS_READ, bank));
offset = ((bank > 0) ? 1 : pfs->inode_start_page);
for (j = offset; j < ARRLEN(inode.inode_page); j++) {
diff --git a/lib/ultralib/src/io/pfsgetlabel.c b/lib/ultralib/src/io/pfsgetlabel.c
index 0e4de49..adb1dcc 100644
--- a/lib/ultralib/src/io/pfsgetlabel.c
+++ b/lib/ultralib/src/io/pfsgetlabel.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsGetLabel(OSPfs* pfs, u8* label, int* len) {
int i;
diff --git a/lib/ultralib/src/io/pfsgetstatus.c b/lib/ultralib/src/io/pfsgetstatus.c
index 955412b..fa736e3 100644
--- a/lib/ultralib/src/io/pfsgetstatus.c
+++ b/lib/ultralib/src/io/pfsgetstatus.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#if BUILD_VERSION >= VERSION_J
void __osPfsRequestOneChannel(int channel, u8 cmd);
diff --git a/lib/ultralib/src/io/pfsinit.c b/lib/ultralib/src/io/pfsinit.c
index 5633c78..581cefc 100644
--- a/lib/ultralib/src/io/pfsinit.c
+++ b/lib/ultralib/src/io/pfsinit.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 osPfsInit(OSMesgQueue* queue, OSPfs* pfs, int channel) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/pfsinitpak.c b/lib/ultralib/src/io/pfsinitpak.c
index d3fde1f..65f2684 100644
--- a/lib/ultralib/src/io/pfsinitpak.c
+++ b/lib/ultralib/src/io/pfsinitpak.c
@@ -1,6 +1,7 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
#if BUILD_VERSION >= VERSION_J
static s32 __osPfsCheckRamArea(OSPfs* pfs);
diff --git a/lib/ultralib/src/io/pfsisplug.c b/lib/ultralib/src/io/pfsisplug.c
index 9607907..0104030 100644
--- a/lib/ultralib/src/io/pfsisplug.c
+++ b/lib/ultralib/src/io/pfsisplug.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
-OSPifRam __osPfsPifRam ALIGNED(16);
+OSPifRam __osPfsPifRam;
s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern) {
s32 ret = 0;
diff --git a/lib/ultralib/src/io/pfsnumfiles.c b/lib/ultralib/src/io/pfsnumfiles.c
index 7fa352e..d0af53b 100644
--- a/lib/ultralib/src/io/pfsnumfiles.c
+++ b/lib/ultralib/src/io/pfsnumfiles.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsNumFiles(OSPfs* pfs, s32* max_files, s32* files_used) {
int j;
diff --git a/lib/ultralib/src/io/pfsreadwritefile.c b/lib/ultralib/src/io/pfsreadwritefile.c
index 17afe54..ec35da3 100644
--- a/lib/ultralib/src/io/pfsreadwritefile.c
+++ b/lib/ultralib/src/io/pfsreadwritefile.c
@@ -1,20 +1,23 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
+
+#define CHECK_IPAGE(p) \
+ (((p).ipage >= pfs->inode_start_page) && ((p).inode_t.bank < pfs->banks) && ((p).inode_t.page >= 0x01) && \
+ ((p).inode_t.page < 0x80))
static s32 __osPfsGetNextPage(OSPfs* pfs, u8* bank, __OSInode* inode, __OSInodeUnit* page) {
s32 ret;
if (page->inode_t.bank != *bank) {
*bank = page->inode_t.bank;
- ERRCK(__osPfsRWInode(pfs, inode, 0, *bank));
+ ERRCK(__osPfsRWInode(pfs, inode, PFS_READ, *bank));
}
*page = inode->inode_page[page->inode_t.page];
- if (page->ipage < pfs->inode_start_page || page->inode_t.bank >= pfs->banks || page->inode_t.page <= 0 ||
- page->inode_t.page >= ARRLEN(inode->inode_page)) {
-
- if (page->ipage == 1) {
+ if (!CHECK_IPAGE(*page)) {
+ if (page->ipage == PFS_EOF) {
return PFS_ERR_INVALID;
}
@@ -54,9 +57,8 @@ s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in
return PFS_ERR_INVALID;
}
- if (dir.start_page.ipage < pfs->inode_start_page || dir.start_page.inode_t.bank >= pfs->banks ||
- dir.start_page.inode_t.page <= 0 || dir.start_page.inode_t.page >= ARRLEN(inode.inode_page)) {
- if ((dir.start_page.ipage == 1)) {
+ if (!CHECK_IPAGE(dir.start_page)) {
+ if ((dir.start_page.ipage == PFS_EOF)) {
return PFS_ERR_INVALID;
}
diff --git a/lib/ultralib/src/io/pfsreformat.c b/lib/ultralib/src/io/pfsreformat.c
index 687b456..e1768cf 100644
--- a/lib/ultralib/src/io/pfsreformat.c
+++ b/lib/ultralib/src/io/pfsreformat.c
@@ -1,6 +1,7 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
-#include "siint.h"
+#include "PRinternal/controller.h"
+#include "PRinternal/siint.h"
s32 osPfsReFormat(OSPfs* pfs, OSMesgQueue* queue, int channel) {
int j;
diff --git a/lib/ultralib/src/io/pfsrepairid.c b/lib/ultralib/src/io/pfsrepairid.c
index 348f8b2..4ad6b0a 100644
--- a/lib/ultralib/src/io/pfsrepairid.c
+++ b/lib/ultralib/src/io/pfsrepairid.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#if BUILD_VERSION >= VERSION_J
diff --git a/lib/ultralib/src/io/pfssearchfile.c b/lib/ultralib/src/io/pfssearchfile.c
index 4fa3c57..ff76d16 100644
--- a/lib/ultralib/src/io/pfssearchfile.c
+++ b/lib/ultralib/src/io/pfssearchfile.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsFindFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, s32* file_no) {
s32 j;
diff --git a/lib/ultralib/src/io/pfsselectbank.c b/lib/ultralib/src/io/pfsselectbank.c
index 7e33b2d..70a8886 100644
--- a/lib/ultralib/src/io/pfsselectbank.c
+++ b/lib/ultralib/src/io/pfsselectbank.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
#if BUILD_VERSION >= VERSION_J
s32 __osPfsSelectBank(OSPfs* pfs, u8 bank) {
diff --git a/lib/ultralib/src/io/pfssetlabel.c b/lib/ultralib/src/io/pfssetlabel.c
index 43308c7..ab6c6ea 100644
--- a/lib/ultralib/src/io/pfssetlabel.c
+++ b/lib/ultralib/src/io/pfssetlabel.c
@@ -1,5 +1,6 @@
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "controller.h"
+#include "PRinternal/controller.h"
s32 osPfsSetLabel(OSPfs* pfs, u8* label) {
int i;
diff --git a/lib/ultralib/src/io/pi.c b/lib/ultralib/src/io/pi.c
index 3e67ddb..f2cc4b9 100644
--- a/lib/ultralib/src/io/pi.c
+++ b/lib/ultralib/src/io/pi.c
@@ -1,11 +1,11 @@
#include "PR/os_internal.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-int __osPiDeviceBusy() {
+int __osPiDeviceBusy(void) {
register u32 stat = IO_READ(PI_STATUS_REG);
if (stat & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
return TRUE;
diff --git a/lib/ultralib/src/io/piacs.c b/lib/ultralib/src/io/piacs.c
index c95147f..78974dd 100644
--- a/lib/ultralib/src/io/piacs.c
+++ b/lib/ultralib/src/io/piacs.c
@@ -1,10 +1,10 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#define PI_Q_BUF_LEN 1
u32 __osPiAccessQueueEnabled = 0;
static OSMesg piAccessBuf[PI_Q_BUF_LEN];
-OSMesgQueue __osPiAccessQueue ALIGNED(8);
+OSMesgQueue __osPiAccessQueue ALIGNED(0x8);
void __osPiCreateAccessQueue(void) {
__osPiAccessQueueEnabled = 1;
diff --git a/lib/ultralib/src/io/pidma.c b/lib/ultralib/src/io/pidma.c
index 0584e12..2464a6d 100644
--- a/lib/ultralib/src/io/pidma.c
+++ b/lib/ultralib/src/io/pidma.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
s32 osPiStartDma(OSIoMesg* mb, s32 priority, s32 direction, u32 devAddr, void* dramAddr, u32 size, OSMesgQueue* mq) {
register s32 ret;
diff --git a/lib/ultralib/src/io/pigetcmdq.c b/lib/ultralib/src/io/pigetcmdq.c
index 4724301..a4919d5 100644
--- a/lib/ultralib/src/io/pigetcmdq.c
+++ b/lib/ultralib/src/io/pigetcmdq.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
OSMesgQueue* osPiGetCmdQueue(void) {
if (!__osPiDevMgr.active) {
diff --git a/lib/ultralib/src/io/pigetstat.c b/lib/ultralib/src/io/pigetstat.c
index 43e9a27..a5ba497 100644
--- a/lib/ultralib/src/io/pigetstat.c
+++ b/lib/ultralib/src/io/pigetstat.c
@@ -1,9 +1,9 @@
#include "PR/os_internal.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 osPiGetStatus() {
+u32 osPiGetStatus(void) {
return IO_READ(PI_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/pigettype.c b/lib/ultralib/src/io/pigettype.c
index f918306..67fdc72 100644
--- a/lib/ultralib/src/io/pigettype.c
+++ b/lib/ultralib/src/io/pigettype.c
@@ -3,6 +3,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-s32 osPiGetDeviceType() {
+s32 osPiGetDeviceType(void) {
return osRomType;
}
diff --git a/lib/ultralib/src/io/pimgr.c b/lib/ultralib/src/io/pimgr.c
index d98c6ad..e2c2bad 100644
--- a/lib/ultralib/src/io/pimgr.c
+++ b/lib/ultralib/src/io/pimgr.c
@@ -1,35 +1,35 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/rdb.h"
-static OSThread piThread ALIGNED(8);
-static char piThreadStack[OS_PIM_STACKSIZE] ALIGNED(16);
+static OSThread piThread ALIGNED(0x8);
+static STACK(piThreadStack, OS_PIM_STACKSIZE) ALIGNED(0x10);
#ifndef _FINALROM
-static OSThread ramromThread ALIGNED(8);
-static char ramromThreadStack[1024] ALIGNED(16);
-static OSMesgQueue getRamromQ ALIGNED(8);
+static OSThread ramromThread ALIGNED(0x8);
+static STACK(ramromThreadStack, 0x400) ALIGNED(0x10);
+static OSMesgQueue getRamromQ ALIGNED(0x8);
static OSMesg getRamromBuf[1];
-static OSMesgQueue freeRamromQ ALIGNED(8);
+static OSMesgQueue freeRamromQ ALIGNED(0x8);
static OSMesg freeRamromBuf[1];
static void ramromMain(void*);
#endif
-static OSMesgQueue piEventQueue ALIGNED(8);
+static OSMesgQueue piEventQueue ALIGNED(0x8);
static OSMesg piEventBuf[1];
OSDevMgr __osPiDevMgr = { 0 };
OSPiHandle* __osPiTable = NULL;
#if BUILD_VERSION >= VERSION_J
-OSPiHandle __Dom1SpeedParam ALIGNED(8);
-OSPiHandle __Dom2SpeedParam ALIGNED(8);
-OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &__Dom1SpeedParam, &__Dom2SpeedParam };
+OSPiHandle __Dom1SpeedParam ALIGNED(0x8);
+OSPiHandle __Dom2SpeedParam ALIGNED(0x8);
+OSPiHandle* __osCurrentHandle[2] ALIGNED(0x8) = { &__Dom1SpeedParam, &__Dom2SpeedParam };
#else
extern OSPiHandle CartRomHandle;
extern OSPiHandle LeoDiskHandle;
-OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &CartRomHandle, &LeoDiskHandle };
+OSPiHandle* __osCurrentHandle[2] ALIGNED(0x8) = { &CartRomHandle, &LeoDiskHandle };
#endif
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) {
@@ -71,11 +71,11 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC
__osPiDevMgr.acsQueue = &__osPiAccessQueue;
__osPiDevMgr.dma = __osPiRawStartDma;
__osPiDevMgr.edma = __osEPiRawStartDma;
- osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, &piThreadStack[OS_PIM_STACKSIZE], pri);
+ osCreateThread(&piThread, 0, __osDevMgrMain, &__osPiDevMgr, STACK_START(piThreadStack), pri);
osStartThread(&piThread);
#ifndef _FINALROM
- osCreateThread(&ramromThread, 0, ramromMain, NULL, ramromThreadStack + 1024, (OSPri)pri - 1);
+ osCreateThread(&ramromThread, 0, ramromMain, NULL, STACK_START(ramromThreadStack), (OSPri)pri - 1);
osStartThread(&ramromThread);
#endif
__osRestoreInt(savedMask);
diff --git a/lib/ultralib/src/io/pirawdma.c b/lib/ultralib/src/io/pirawdma.c
index d5ea8c3..db77829 100644
--- a/lib/ultralib/src/io/pirawdma.c
+++ b/lib/ultralib/src/io/pirawdma.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/pirawread.c b/lib/ultralib/src/io/pirawread.c
index 95d7082..0040bb3 100644
--- a/lib/ultralib/src/io/pirawread.c
+++ b/lib/ultralib/src/io/pirawread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "assert.h"
#include "PR/ultraerror.h"
diff --git a/lib/ultralib/src/io/pirawwrite.c b/lib/ultralib/src/io/pirawwrite.c
index 92eba84..190f682 100644
--- a/lib/ultralib/src/io/pirawwrite.c
+++ b/lib/ultralib/src/io/pirawwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
// TODO: this comes from a header
diff --git a/lib/ultralib/src/io/piread.c b/lib/ultralib/src/io/piread.c
index 42bcf3e..7550307 100644
--- a/lib/ultralib/src/io/piread.c
+++ b/lib/ultralib/src/io/piread.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osPiReadIo(u32 devAddr, u32* data) {
diff --git a/lib/ultralib/src/io/piwrite.c b/lib/ultralib/src/io/piwrite.c
index 75c00d1..7fe514f 100644
--- a/lib/ultralib/src/io/piwrite.c
+++ b/lib/ultralib/src/io/piwrite.c
@@ -1,4 +1,4 @@
-#include "piint.h"
+#include "PRinternal/piint.h"
#include "PR/ultraerror.h"
s32 osPiWriteIo(u32 devAddr, u32 data) {
diff --git a/lib/ultralib/src/io/si.c b/lib/ultralib/src/io/si.c
index 0188927..78794f5 100644
--- a/lib/ultralib/src/io/si.c
+++ b/lib/ultralib/src/io/si.c
@@ -1,10 +1,10 @@
#include "PR/os_internal.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-int __osSiDeviceBusy() {
+int __osSiDeviceBusy(void) {
register u32 stat = IO_READ(SI_STATUS_REG);
if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
diff --git a/lib/ultralib/src/io/siacs.c b/lib/ultralib/src/io/siacs.c
index 8ef5b3f..7ff12f1 100644
--- a/lib/ultralib/src/io/siacs.c
+++ b/lib/ultralib/src/io/siacs.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#define SI_Q_BUF_LEN 1
-static OSMesg siAccessBuf[SI_Q_BUF_LEN] ALIGNED(8);
-OSMesgQueue __osSiAccessQueue ALIGNED(8);
+static OSMesg siAccessBuf[SI_Q_BUF_LEN] ALIGNED(0x8);
+OSMesgQueue __osSiAccessQueue ALIGNED(0x8);
u32 __osSiAccessQueueEnabled = 0;
void __osSiCreateAccessQueue(void) {
diff --git a/lib/ultralib/src/io/sigetstat.c b/lib/ultralib/src/io/sigetstat.c
index 0225445..e21e50a 100644
--- a/lib/ultralib/src/io/sigetstat.c
+++ b/lib/ultralib/src/io/sigetstat.c
@@ -1,9 +1,9 @@
#include "PR/os_internal.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 __osSiGetStatus() {
+u32 __osSiGetStatus(void) {
return IO_READ(SI_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/sirawdma.c b/lib/ultralib/src/io/sirawdma.c
index 5fb5f8a..ea2c228 100644
--- a/lib/ultralib/src/io/sirawdma.c
+++ b/lib/ultralib/src/io/sirawdma.c
@@ -1,8 +1,6 @@
#include "PR/os_internal.h"
#include "assert.h"
-#include "siint.h"
-
-
+#include "PRinternal/siint.h"
@@ -46,9 +44,11 @@
// Adjust line numbers to match assert
#if BUILD_VERSION < VERSION_J
-#line 49
+#line 47
#endif
+#define PIF_RAM_SIZE (PIF_RAM_END + 1 - PIF_RAM_START)
+
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
@@ -66,7 +66,7 @@ s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
#endif
if (direction == OS_WRITE) {
- osWritebackDCache(dramAddr, 64);
+ osWritebackDCache(dramAddr, PIF_RAM_SIZE);
}
IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
@@ -78,7 +78,7 @@ s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
}
if (direction == OS_READ) {
- osInvalDCache(dramAddr, 64);
+ osInvalDCache(dramAddr, PIF_RAM_SIZE);
}
return 0;
diff --git a/lib/ultralib/src/io/sirawread.c b/lib/ultralib/src/io/sirawread.c
index 4ce8330..c182ff0 100644
--- a/lib/ultralib/src/io/sirawread.c
+++ b/lib/ultralib/src/io/sirawread.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "assert.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
diff --git a/lib/ultralib/src/io/sirawwrite.c b/lib/ultralib/src/io/sirawwrite.c
index 795d38a..ece13a5 100644
--- a/lib/ultralib/src/io/sirawwrite.c
+++ b/lib/ultralib/src/io/sirawwrite.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "siint.h"
+#include "PRinternal/siint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sp.c b/lib/ultralib/src/io/sp.c
index 3ad9076..98e7c40 100644
--- a/lib/ultralib/src/io/sp.c
+++ b/lib/ultralib/src/io/sp.c
@@ -1,12 +1,12 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-int __osSpDeviceBusy() {
+int __osSpDeviceBusy(void) {
register u32 stat = IO_READ(SP_STATUS_REG);
if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) {
diff --git a/lib/ultralib/src/io/spgetstat.c b/lib/ultralib/src/io/spgetstat.c
index 0cdfda6..8125b64 100644
--- a/lib/ultralib/src/io/spgetstat.c
+++ b/lib/ultralib/src/io/spgetstat.c
@@ -4,6 +4,6 @@
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-u32 __osSpGetStatus() {
+u32 __osSpGetStatus(void) {
return IO_READ(SP_STATUS_REG);
}
diff --git a/lib/ultralib/src/io/sprawdma.c b/lib/ultralib/src/io/sprawdma.c
index 6d95a49..05d9b7a 100644
--- a/lib/ultralib/src/io/sprawdma.c
+++ b/lib/ultralib/src/io/sprawdma.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sprawread.c b/lib/ultralib/src/io/sprawread.c
index 5910a9e..180b440 100644
--- a/lib/ultralib/src/io/sprawread.c
+++ b/lib/ultralib/src/io/sprawread.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sprawwrite.c b/lib/ultralib/src/io/sprawwrite.c
index 9ce3ebf..c0f83cf 100644
--- a/lib/ultralib/src/io/sprawwrite.c
+++ b/lib/ultralib/src/io/sprawwrite.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "assert.h"
diff --git a/lib/ultralib/src/io/sptask.c b/lib/ultralib/src/io/sptask.c
index 8fbfeb2..3c3ef15 100644
--- a/lib/ultralib/src/io/sptask.c
+++ b/lib/ultralib/src/io/sptask.c
@@ -2,7 +2,7 @@
#include "PR/ultraerror.h"
#include "PR/sptask.h"
#include "PR/rcp.h"
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#if BUILD_VERSION < VERSION_J
#ident "$Revision: 1.4 $"
@@ -11,7 +11,7 @@
#define _osVirtualToPhysical(ptr) \
if (ptr != NULL) { \
ptr = (void*)osVirtualToPhysical(ptr); \
- }
+ } (void)0
static OSTask tmp_task;
diff --git a/lib/ultralib/src/io/vi.c b/lib/ultralib/src/io/vi.c
index 246f01f..7023b70 100644
--- a/lib/ultralib/src/io/vi.c
+++ b/lib/ultralib/src/io/vi.c
@@ -1,13 +1,13 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/rcp.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-static __OSViContext vi[2] ALIGNED(8) = { 0 };
+static __OSViContext vi[2] ALIGNED(0x8) = { 0 };
__OSViContext* __osViCurr = &vi[0];
__OSViContext* __osViNext = &vi[1];
diff --git a/lib/ultralib/src/io/viblack.c b/lib/ultralib/src/io/viblack.c
index 30dd85c..f5fbf24 100644
--- a/lib/ultralib/src/io/viblack.c
+++ b/lib/ultralib/src/io/viblack.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/viextendvstart.c b/lib/ultralib/src/io/viextendvstart.c
index 7ee06d3..1624848 100644
--- a/lib/ultralib/src/io/viextendvstart.c
+++ b/lib/ultralib/src/io/viextendvstart.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
void osViExtendVStart(u32 value) {
#ifdef _DEBUG
diff --git a/lib/ultralib/src/io/vifade.c b/lib/ultralib/src/io/vifade.c
index 6766871..22be390 100644
--- a/lib/ultralib/src/io/vifade.c
+++ b/lib/ultralib/src/io/vifade.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/vigetcurrcontext.c b/lib/ultralib/src/io/vigetcurrcontext.c
index 7b1df9b..f33dc96 100644
--- a/lib/ultralib/src/io/vigetcurrcontext.c
+++ b/lib/ultralib/src/io/vigetcurrcontext.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/vigetcurrframebuf.c b/lib/ultralib/src/io/vigetcurrframebuf.c
index de36712..6c21e40 100644
--- a/lib/ultralib/src/io/vigetcurrframebuf.c
+++ b/lib/ultralib/src/io/vigetcurrframebuf.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
void* osViGetCurrentFramebuffer(void) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/vigetmode.c b/lib/ultralib/src/io/vigetmode.c
index 2507372..3bb492b 100644
--- a/lib/ultralib/src/io/vigetmode.c
+++ b/lib/ultralib/src/io/vigetmode.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
u32 osViGetCurrentMode(void) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/vigetnextcontext.c b/lib/ultralib/src/io/vigetnextcontext.c
index bb6012a..5f1c2e2 100644
--- a/lib/ultralib/src/io/vigetnextcontext.c
+++ b/lib/ultralib/src/io/vigetnextcontext.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
__OSViContext* __osViGetNextContext(void) {
return __osViNext;
diff --git a/lib/ultralib/src/io/vigetnextframebuf.c b/lib/ultralib/src/io/vigetnextframebuf.c
index 2985358..8d14809 100644
--- a/lib/ultralib/src/io/vigetnextframebuf.c
+++ b/lib/ultralib/src/io/vigetnextframebuf.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
void* osViGetNextFramebuffer(void) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/vimgr.c b/lib/ultralib/src/io/vimgr.c
index 0fe51d5..3b434b8 100644
--- a/lib/ultralib/src/io/vimgr.c
+++ b/lib/ultralib/src/io/vimgr.c
@@ -1,20 +1,20 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "viint.h"
-#include "../os/osint.h"
+#include "PRinternal/viint.h"
+#include "PRinternal/osint.h"
OSDevMgr __osViDevMgr = { 0 };
#if BUILD_VERSION >= VERSION_J
u32 __additional_scanline = 0;
#endif
static OSThread viThread;
-static unsigned char viThreadStack[OS_VIM_STACKSIZE] ALIGNED(16);
-static OSMesgQueue viEventQueue ALIGNED(8);
-static OSMesg viEventBuf[5] ALIGNED(8);
-static OSIoMesg viRetraceMsg ALIGNED(8);
-static OSIoMesg viCounterMsg ALIGNED(8);
+static STACK(viThreadStack, OS_VIM_STACKSIZE) ALIGNED(0x10);
+static OSMesgQueue viEventQueue ALIGNED(0x8);
+static OSMesg viEventBuf[5] ALIGNED(0x8);
+static OSIoMesg viRetraceMsg ALIGNED(0x8);
+static OSIoMesg viCounterMsg ALIGNED(0x8);
static void viMgrMain(void* arg);
void osCreateViManager(OSPri pri) {
@@ -61,7 +61,7 @@ void osCreateViManager(OSPri pri) {
__osViDevMgr.acsQueue = NULL;
__osViDevMgr.dma = NULL;
__osViDevMgr.edma = NULL;
- osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, &viThreadStack[OS_VIM_STACKSIZE], pri);
+ osCreateThread(&viThread, 0, viMgrMain, &__osViDevMgr, STACK_START(viThreadStack), pri);
__osViInit();
osStartThread(&viThread);
__osRestoreInt(savedMask);
diff --git a/lib/ultralib/src/io/virepeatline.c b/lib/ultralib/src/io/virepeatline.c
index 1bc4984..bc96773 100644
--- a/lib/ultralib/src/io/virepeatline.c
+++ b/lib/ultralib/src/io/virepeatline.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/visetevent.c b/lib/ultralib/src/io/visetevent.c
index f741a0e..b771403 100644
--- a/lib/ultralib/src/io/visetevent.c
+++ b/lib/ultralib/src/io/visetevent.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "assert.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
diff --git a/lib/ultralib/src/io/visetmode.c b/lib/ultralib/src/io/visetmode.c
index 5ab2094..114403e 100644
--- a/lib/ultralib/src/io/visetmode.c
+++ b/lib/ultralib/src/io/visetmode.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "assert.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
diff --git a/lib/ultralib/src/io/visetspecial.c b/lib/ultralib/src/io/visetspecial.c
index 0a288e5..24b4367 100644
--- a/lib/ultralib/src/io/visetspecial.c
+++ b/lib/ultralib/src/io/visetspecial.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/rcp.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
@@ -15,6 +15,19 @@
#define OS_VI_SPECIAL_MAX OS_VI_DITHER_FILTER_OFF
#endif
+/**
+ * Configures VI "special features" to be applied on the next context swap.
+ *
+ * "Special features" refer to the mode bits in the Video Interface control register that enable effects such as gamma
+ * correction, gamma dither, dither filtering, anti-aliasing filtering and divot filtering. Configuring the same
+ * setting ON and OFF in the same call will result in OFF taking precedence.
+ *
+ * Any unrecognized bits will be ignored. Note that this is very intentional as in early revisions of retail N64
+ * hardware setting bit 5 in the `features` field of OSViContext may cause physical damage to the console once it is
+ * fed to VI_CONTROL_REG on next context swap.
+ *
+ * @param func OS_VI_*_ON / OS_VI_*_OFF bits to enable or disable a setting.
+ */
void osViSetSpecialFeatures(u32 func) {
register u32 saveMask;
diff --git a/lib/ultralib/src/io/visetxscale.c b/lib/ultralib/src/io/visetxscale.c
index 6af6535..1baab29 100644
--- a/lib/ultralib/src/io/visetxscale.c
+++ b/lib/ultralib/src/io/visetxscale.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/visetyscale.c b/lib/ultralib/src/io/visetyscale.c
index c1c96f4..1202478 100644
--- a/lib/ultralib/src/io/visetyscale.c
+++ b/lib/ultralib/src/io/visetyscale.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
diff --git a/lib/ultralib/src/io/viswapbuf.c b/lib/ultralib/src/io/viswapbuf.c
index aa077cd..ec5016d 100644
--- a/lib/ultralib/src/io/viswapbuf.c
+++ b/lib/ultralib/src/io/viswapbuf.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "assert.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
diff --git a/lib/ultralib/src/io/viswapcontext.c b/lib/ultralib/src/io/viswapcontext.c
index 2f6d2c6..a19fd40 100644
--- a/lib/ultralib/src/io/viswapcontext.c
+++ b/lib/ultralib/src/io/viswapcontext.c
@@ -1,11 +1,11 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "viint.h"
+#include "PRinternal/viint.h"
// TODO: this comes from a header
#ident "$Revision: 1.17 $"
-void __osViSwapContext() {
+void __osViSwapContext(void) {
register OSViMode* vm;
register __OSViContext* vc;
u32 origin;
@@ -38,7 +38,7 @@ void __osViSwapContext() {
}
#if BUILD_VERSION >= VERSION_J
- vStart = (vm->fldRegs[field].vStart - (__additional_scanline << 0x10)) + __additional_scanline;
+ vStart = (vm->fldRegs[field].vStart - (__additional_scanline << VI_SUBPIXEL_SH)) + __additional_scanline;
#endif
hStart = vm->comRegs.hStart;
diff --git a/lib/ultralib/src/io/vitbl.c b/lib/ultralib/src/io/vitbl.c
index 476036e..a728c2c 100644
--- a/lib/ultralib/src/io/vitbl.c
+++ b/lib/ultralib/src/io/vitbl.c
@@ -1,6 +1,6 @@
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeTable[] = {
{ OS_VI_NTSC_LPN1, // type
@@ -100,15 +100,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -192,15 +192,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_NTSC_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(525), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(525), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -223,15 +224,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -316,15 +317,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -347,15 +348,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -533,15 +534,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -625,15 +626,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_PAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(625), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(625), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -656,15 +658,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -749,15 +751,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -780,15 +782,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -966,15 +968,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1058,15 +1060,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_MPAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(525), // vSync
- HSYNC(3089, 4), // hSync
- LEAP(3097, 3098), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(525), // vSync
+ HSYNC(3089, 4), // hSync
+ LEAP(3097, 3098), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1089,15 +1092,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1182,15 +1185,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1213,15 +1216,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1400,15 +1403,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1492,15 +1495,16 @@ OSViMode osViModeTable[] = {
{ OS_VI_FPAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(625), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(625), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1523,15 +1527,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1616,15 +1620,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1647,15 +1651,15 @@ OSViMode osViModeTable[] = {
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
@@ -1735,6 +1739,6 @@ OSViMode osViModeTable[] = {
HSTART(47, 617), // vStart
BURST(105, 2, 13, 0), // vBurst
VINTR(2), // vIntr
- } } }
+ } } },
#endif
};
diff --git a/lib/ultralib/src/libc/bcmp.s b/lib/ultralib/src/libc/bcmp.s
index 11db46d..def3235 100644
--- a/lib/ultralib/src/libc/bcmp.s
+++ b/lib/ultralib/src/libc/bcmp.s
@@ -9,88 +9,88 @@ WEAK(bcmp, _bcmp)
#define _bcmp bcmp
#endif
LEAF(_bcmp)
- xor v0, a0, a1
- blt a2, 16, bytecmp
+ xor v0, a0, a1
+ blt a2, 16, bytecmp
- andi v0, v0, 0x3
- negu t8, a0
- bnez v0, unalgncmp
+ andi v0, v0, 0x3
+ negu t8, a0
+ bnez v0, unalgncmp
- andi t8, t8, 0x3
- subu a2, a2, t8
- beqz t8, wordcmp
+ andi t8, t8, 0x3
+ subu a2, a2, t8
+ beqz t8, wordcmp
- move v0, v1
- lwl v0, 0(a0)
- lwl v1, 0(a1)
- addu a0, a0, t8
- addu a1, a1, t8
- bne v0, v1, cmpne
+ move v0, v1
+ lwl v0, 0(a0)
+ lwl v1, 0(a1)
+ addu a0, a0, t8
+ addu a1, a1, t8
+ bne v0, v1, cmpne
wordcmp:
- and a3, a2, ~3
- subu a2, a2, a3
- beqz a3, bytecmp
+ and a3, a2, ~3
+ subu a2, a2, a3
+ beqz a3, bytecmp
- addu a3, a3, a0
+ addu a3, a3, a0
1:
- lw v0, 0(a0)
- lw v1, 0(a1)
- addiu a0, a0, 4
- addiu a1, a1, 4
- bne v0, v1, cmpne
- bne a0, a3, 1b
+ lw v0, 0(a0)
+ lw v1, 0(a1)
+ addiu a0, a0, 4
+ addiu a1, a1, 4
+ bne v0, v1, cmpne
+ bne a0, a3, 1b
- b bytecmp
+ b bytecmp
unalgncmp:
- negu a3, a1
- andi a3, a3, 0x3
- subu a2, a2, a3
- beqz a3, partaligncmp
+ negu a3, a1
+ andi a3, a3, 0x3
+ subu a2, a2, a3
+ beqz a3, partaligncmp
+
+ addu a3, a3, a0
- addu a3, a3, a0
-
1:
- lbu v0, 0(a0)
- lbu v1, 0(a1)
- addiu a0, a0, 1
- addiu a1, a1, 1
- bne v0, v1, cmpne
- bne a0, a3, 1b
+ lbu v0, 0(a0)
+ lbu v1, 0(a1)
+ addiu a0, a0, 1
+ addiu a1, a1, 1
+ bne v0, v1, cmpne
+ bne a0, a3, 1b
partaligncmp:
- and a3, a2, ~3
- subu a2, a2, a3
- beqz a3, bytecmp
+ and a3, a2, ~3
+ subu a2, a2, a3
+ beqz a3, bytecmp
- addu a3, a3, a0
+ addu a3, a3, a0
1:
- lwl v0, 0(a0)
- lwr v0, 3(a0)
- lw v1, 0(a1)
- addiu a0, a0, 4
- addiu a1, a1, 4
- bne v0, v1, cmpne
- bne a0, a3, 1b
+ lwl v0, 0(a0)
+ lwr v0, 3(a0)
+ lw v1, 0(a1)
+ addiu a0, a0, 4
+ addiu a1, a1, 4
+ bne v0, v1, cmpne
+ bne a0, a3, 1b
bytecmp:
- addu a3, a2, a0
- blez a2, cmpdone
+ addu a3, a2, a0
+ blez a2, cmpdone
1:
- lbu v0, 0(a0)
- lbu v1, 0(a1)
- addiu a0, a0, 1
- addiu a1, a1, 1
- bne v0, v1, cmpne
- bne a0, a3, 1b
+ lbu v0, 0(a0)
+ lbu v1, 0(a1)
+ addiu a0, a0, 1
+ addiu a1, a1, 1
+ bne v0, v1, cmpne
+ bne a0, a3, 1b
cmpdone:
- move v0, zero
- jr ra
+ move v0, zero
+ jr ra
cmpne:
- li v0, 1
- jr ra
+ li v0, 1
+ jr ra
.end _bcmp
diff --git a/lib/ultralib/src/libc/bcopy.s b/lib/ultralib/src/libc/bcopy.s
index 216c378..0875741 100644
--- a/lib/ultralib/src/libc/bcopy.s
+++ b/lib/ultralib/src/libc/bcopy.s
@@ -9,212 +9,212 @@ WEAK(bcopy, _bcopy)
#define _bcopy bcopy
#endif
LEAF(_bcopy)
- move a3, a1
- beqz a2, ret
- beq a0, a1, ret
- blt a1, a0, goforwards
+ move a3, a1
+ beqz a2, ret
+ beq a0, a1, ret
+ blt a1, a0, goforwards
- add v0, a0, a2
- bge a1, v0, goforwards
- b gobackwards
+ add v0, a0, a2
+ bge a1, v0, goforwards
+ b gobackwards
goforwards:
- blt a2, 16, forwards_bytecopy
+ blt a2, 16, forwards_bytecopy
- andi v0, a0, 0x3
- andi v1, a1, 0x3
- beq v0, v1,forwalignable
+ andi v0, a0, 0x3
+ andi v1, a1, 0x3
+ beq v0, v1, forwalignable
forwards_bytecopy:
- beqz a2, ret
- addu v1, a0, a2
+ beqz a2, ret
+ addu v1, a0, a2
99:
- lb v0, 0(a0)
- addiu a0, a0, 1
- sb v0, 0(a1)
- addiu a1, a1, 1
- bne a0, v1, 99b
+ lb v0, 0(a0)
+ addiu a0, a0, 1
+ sb v0, 0(a1)
+ addiu a1, a1, 1
+ bne a0, v1, 99b
ret:
- move v0, a3
- jr ra
+ move v0, a3
+ jr ra
forwalignable:
- beqz v0, forwards
- beq v0, 1, forw_copy3
- beq v0, 2, forw_copy2
+ beqz v0, forwards
+ beq v0, 1, forw_copy3
+ beq v0, 2, forw_copy2
- lb v0, 0(a0)
- addiu a0, a0, 1
- sb v0, 0(a1)
- addiu a1, a1, 1
- addiu a2, a2, -1
- b forwards
+ lb v0, 0(a0)
+ addiu a0, a0, 1
+ sb v0, 0(a1)
+ addiu a1, a1, 1
+ addiu a2, a2, -1
+ b forwards
forw_copy2:
- lh v0, 0(a0)
- addiu a0, a0, 2
- sh v0, 0(a1)
- addiu a1, a1, 2
- addiu a2, a2, -2
- b forwards
+ lh v0, 0(a0)
+ addiu a0, a0, 2
+ sh v0, 0(a1)
+ addiu a1, a1, 2
+ addiu a2, a2, -2
+ b forwards
forw_copy3:
- lb v0, 0(a0)
- lh v1, 1(a0)
- addiu a0, a0, 3
- sb v0, 0(a1)
- sh v1, 1(a1)
- addiu a1, a1, 3
- addiu a2, a2, -3
+ lb v0, 0(a0)
+ lh v1, 1(a0)
+ addiu a0, a0, 3
+ sb v0, 0(a1)
+ sh v1, 1(a1)
+ addiu a1, a1, 3
+ addiu a2, a2, -3
forwards:
forwards_32:
- blt a2, 32, forwards_16
- lw v0, 0(a0)
- lw v1, 4(a0)
- lw t0, 8(a0)
- lw t1, 12(a0)
- lw t2, 16(a0)
- lw t3, 20(a0)
- lw ta0, 24(a0)
- lw ta1, 28(a0)
- addiu a0, a0, 32
- sw v0, 0(a1)
- sw v1, 4(a1)
- sw t0, 8(a1)
- sw t1, 12(a1)
- sw t2, 16(a1)
- sw t3, 20(a1)
- sw ta0, 24(a1)
- sw ta1, 28(a1)
- addiu a1, a1, 32
- addiu a2, a2, -32
- b forwards_32
+ blt a2, 32, forwards_16
+ lw v0, 0(a0)
+ lw v1, 4(a0)
+ lw t0, 8(a0)
+ lw t1, 12(a0)
+ lw t2, 16(a0)
+ lw t3, 20(a0)
+ lw ta0, 24(a0)
+ lw ta1, 28(a0)
+ addiu a0, a0, 32
+ sw v0, 0(a1)
+ sw v1, 4(a1)
+ sw t0, 8(a1)
+ sw t1, 12(a1)
+ sw t2, 16(a1)
+ sw t3, 20(a1)
+ sw ta0, 24(a1)
+ sw ta1, 28(a1)
+ addiu a1, a1, 32
+ addiu a2, a2, -32
+ b forwards_32
forwards_16:
- blt a2, 16, forwards_4
- lw v0, 0(a0)
- lw v1, 4(a0)
- lw t0, 8(a0)
- lw t1, 12(a0)
- addiu a0, a0, 16
- sw v0, 0(a1)
- sw v1, 4(a1)
- sw t0, 8(a1)
- sw t1, 12(a1)
- addiu a1, a1, 16
- addiu a2, a2, -16
- b forwards_16
+ blt a2, 16, forwards_4
+ lw v0, 0(a0)
+ lw v1, 4(a0)
+ lw t0, 8(a0)
+ lw t1, 12(a0)
+ addiu a0, a0, 16
+ sw v0, 0(a1)
+ sw v1, 4(a1)
+ sw t0, 8(a1)
+ sw t1, 12(a1)
+ addiu a1, a1, 16
+ addiu a2, a2, -16
+ b forwards_16
forwards_4:
- blt a2, 4, forwards_bytecopy
+ blt a2, 4, forwards_bytecopy
- lw v0, 0(a0)
- addiu a0, a0, 4
- sw v0, 0(a1)
- addiu a1, a1, 4
- addiu a2, a2, -4
- b forwards_4
+ lw v0, 0(a0)
+ addiu a0, a0, 4
+ sw v0, 0(a1)
+ addiu a1, a1, 4
+ addiu a2, a2, -4
+ b forwards_4
gobackwards:
- add a0, a0,a2
- add a1, a1,a2
- blt a2, 16, backwards_bytecopy
+ add a0, a0, a2
+ add a1, a1, a2
+ blt a2, 16, backwards_bytecopy
- andi v0, a0, 0x3
- andi v1, a1, 0x3
- beq v0, v1,backalignable
+ andi v0, a0, 0x3
+ andi v1, a1, 0x3
+ beq v0, v1, backalignable
backwards_bytecopy:
- beqz a2, ret
- addiu a0, a0, -1
- addiu a1, a1, -1
- subu v1, a0,a2
+ beqz a2, ret
+ addiu a0, a0, -1
+ addiu a1, a1, -1
+ subu v1, a0, a2
99:
- lb v0, 0(a0)
- addiu a0, a0, -1
- sb v0, 0(a1)
- addiu a1, a1, -1
- bne a0, v1,99b
-
- move v0, a3
- jr ra
+ lb v0, 0(a0)
+ addiu a0, a0, -1
+ sb v0, 0(a1)
+ addiu a1, a1, -1
+ bne a0, v1, 99b
+
+ move v0, a3
+ jr ra
backalignable:
- beqz v0, backwards
- beq v0, 3, back_copy3
- beq v0, 2, back_copy2
- lb v0, -1(a0)
- addiu a0, a0, -1
- sb v0, -1(a1)
- addiu a1, a1, -1
- addiu a2, a2, -1
+ beqz v0, backwards
+ beq v0, 3, back_copy3
+ beq v0, 2, back_copy2
+ lb v0, -1(a0)
+ addiu a0, a0, -1
+ sb v0, -1(a1)
+ addiu a1, a1, -1
+ addiu a2, a2, -1
b backwards
back_copy2:
- lh v0, -2(a0)
- addiu a0, a0, -2
- sh v0, -2(a1)
- addiu a1, a1, -2
- addiu a2, a2, -2
- b backwards
+ lh v0, -2(a0)
+ addiu a0, a0, -2
+ sh v0, -2(a1)
+ addiu a1, a1, -2
+ addiu a2, a2, -2
+ b backwards
back_copy3:
- lb v0, -1(a0)
- lh v1, -3(a0)
- addiu a0, a0, -3
- sb v0, -1(a1)
- sh v1, -3(a1)
- addiu a1, a1, -3
- addiu a2, a2, -3
+ lb v0, -1(a0)
+ lh v1, -3(a0)
+ addiu a0, a0, -3
+ sb v0, -1(a1)
+ sh v1, -3(a1)
+ addiu a1, a1, -3
+ addiu a2, a2, -3
backwards:
backwards_32:
- blt a2, 32, backwards_16
- lw v0, -4(a0)
- lw v1, -8(a0)
- lw t0, -12(a0)
- lw t1, -16(a0)
- lw t2, -20(a0)
- lw t3, -24(a0)
- lw ta0, -28(a0)
- lw ta1, -32(a0)
- addiu a0, a0, -32
- sw v0, -4(a1)
- sw v1, -8(a1)
- sw t0, -12(a1)
- sw t1, -16(a1)
- sw t2, -20(a1)
- sw t3, -24(a1)
- sw ta0, -28(a1)
- sw ta1, -32(a1)
- addiu a1, a1, -32
- addiu a2, a2, -32
- b backwards_32
+ blt a2, 32, backwards_16
+ lw v0, -4(a0)
+ lw v1, -8(a0)
+ lw t0, -12(a0)
+ lw t1, -16(a0)
+ lw t2, -20(a0)
+ lw t3, -24(a0)
+ lw ta0, -28(a0)
+ lw ta1, -32(a0)
+ addiu a0, a0, -32
+ sw v0, -4(a1)
+ sw v1, -8(a1)
+ sw t0, -12(a1)
+ sw t1, -16(a1)
+ sw t2, -20(a1)
+ sw t3, -24(a1)
+ sw ta0, -28(a1)
+ sw ta1, -32(a1)
+ addiu a1, a1, -32
+ addiu a2, a2, -32
+ b backwards_32
backwards_16:
- blt a2, 16, backwards_4
- lw v0, -4(a0)
- lw v1, -8(a0)
- lw t0, -12(a0)
- lw t1, -16(a0)
- addiu a0, a0, -16
- sw v0, -4(a1)
- sw v1, -8(a1)
- sw t0, -12(a1)
- sw t1, -16(a1)
- addiu a1, a1, -16
- addiu a2, a2, -16
- b backwards_16
+ blt a2, 16, backwards_4
+ lw v0, -4(a0)
+ lw v1, -8(a0)
+ lw t0, -12(a0)
+ lw t1, -16(a0)
+ addiu a0, a0, -16
+ sw v0, -4(a1)
+ sw v1, -8(a1)
+ sw t0, -12(a1)
+ sw t1, -16(a1)
+ addiu a1, a1, -16
+ addiu a2, a2, -16
+ b backwards_16
backwards_4:
- blt a2, 4, backwards_bytecopy
- lw v0, -4(a0)
- addiu a0, a0, -4
- sw v0, -4(a1)
- addiu a1, a1, -4
- addiu a2, a2, -4
- b backwards_4
+ blt a2, 4, backwards_bytecopy
+ lw v0, -4(a0)
+ addiu a0, a0, -4
+ sw v0, -4(a1)
+ addiu a1, a1, -4
+ addiu a2, a2, -4
+ b backwards_4
.end _bcopy
diff --git a/lib/ultralib/src/libc/bzero.s b/lib/ultralib/src/libc/bzero.s
index 894c186..c3deec0 100644
--- a/lib/ultralib/src/libc/bzero.s
+++ b/lib/ultralib/src/libc/bzero.s
@@ -12,53 +12,61 @@ WEAK(blkclr, _blkclr)
#endif
LEAF(_bzero)
XLEAF(_blkclr)
- negu v1, a0
- blt a1, 12, bytezero
+ negu v1, a0
+ blt a1, 12, bytezero
- andi v1, v1, 0x3
- subu a1, a1, v1
+ andi v1, v1, 0x3
+ subu a1, a1, v1
- beqz v1, blkzero
- swl zero, 0(a0)
- addu a0, a0, v1
+ beqz v1, blkzero
+ swl zero, 0(a0)
+ addu a0, a0, v1
blkzero:
- and a3, a1, ~31
- subu a1, a1, a3
- beqz a3, wordzero
+ /* align backwards to 0x20 */
+ and a3, a1, ~31
+ subu a1, a1, a3
+ /* If the result is zero, the amount to zero is less than 0x20 bytes */
+ beqz a3, wordzero
- addu a3, a3, a0
+ /* zero in blocks of 0x20 at a time */
+ addu a3, a3, a0
1:
- sw zero, 0(a0)
- sw zero, 4(a0)
- sw zero, 8(a0)
- sw zero, 12(a0)
- addiu a0, a0, 32
- sw zero, -16(a0)
- sw zero, -12(a0)
- sw zero, -8(a0)
- sw zero, -4(a0)
- bne a0, a3, 1b
+ sw zero, 0(a0)
+ sw zero, 4(a0)
+ sw zero, 8(a0)
+ sw zero, 12(a0)
+ addiu a0, a0, 32
+ sw zero, -16(a0)
+ sw zero, -12(a0)
+ sw zero, -8(a0)
+ sw zero, -4(a0)
+ bne a0, a3, 1b
wordzero:
- and a3, a1, ~3
- subu a1, a1, a3
- beqz a3, bytezero
+ /* align backwards to 0x4 */
+ and a3, a1, ~3
+ subu a1, a1, a3
+ /* If the result is zero, the amount to zero is less than 0x4 bytes */
+ beqz a3, bytezero
- addu a3, a3, a0
+ /* zero one word at a time */
+ addu a3, a3, a0
1:
- addiu a0, a0, 4
- sw zero, -4(a0)
- bne a0, a3, 1b
+ addiu a0, a0, 4
+ sw zero, -4(a0)
+ bne a0, a3, 1b
bytezero:
- blez a1, zerodone
- #nop
- addu a1, a1, a0
+ /* test if nothing left to zero */
+ blez a1, zerodone
+
+ /* zero one byte at a time */
+ addu a1, a1, a0
1:
- addiu a0, a0, 1
- sb zero, -1(a0)
- bne a0, a1, 1b
+ addiu a0, a0, 1
+ sb zero, -1(a0)
+ bne a0, a1, 1b
zerodone:
- jr ra
+ jr ra
.end _bzero
diff --git a/lib/ultralib/src/libc/ll.c b/lib/ultralib/src/libc/ll.c
index 4334b03..512a998 100644
--- a/lib/ultralib/src/libc/ll.c
+++ b/lib/ultralib/src/libc/ll.c
@@ -1,5 +1,3 @@
-#include "PR/os.h"
-
unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) {
return a0 >> a1;
}
diff --git a/lib/ultralib/src/libc/llbit.c b/lib/ultralib/src/libc/llbit.c
index 0680726..3e7e03b 100644
--- a/lib/ultralib/src/libc/llbit.c
+++ b/lib/ultralib/src/libc/llbit.c
@@ -1,4 +1,3 @@
-#include "PR/os.h"
#include "PR/ultratypes.h"
s64 __ll_bit_extract(u64* addr, unsigned int start_bit, unsigned int length) {
diff --git a/lib/ultralib/src/libc/sprintf.c b/lib/ultralib/src/libc/sprintf.c
index fd95523..a65fdde 100644
--- a/lib/ultralib/src/libc/sprintf.c
+++ b/lib/ultralib/src/libc/sprintf.c
@@ -5,18 +5,18 @@
// TODO: this comes from a header
#ident "$Revision: 1.23 $"
-static char* proutSprintf(char* dst, const char* src, size_t count);
+static void* proutSprintf(void* s, const char* buf, size_t n);
-int sprintf(char* dst, const char* fmt, ...) {
- s32 ans;
+int sprintf(char* s, const char* fmt, ...) {
+ int ans;
va_list ap;
va_start(ap, fmt);
- ans = _Printf(proutSprintf, dst, fmt, ap);
+ ans = _Printf(proutSprintf, s, fmt, ap);
if (ans >= 0) {
- dst[ans] = 0;
+ s[ans] = 0;
}
return ans;
}
-static char* proutSprintf(char* dst, const char* src, size_t count) {
- return (char*)memcpy((u8*)dst, (u8*)src, count) + count;
+static void* proutSprintf(void* s, const char* buf, size_t n) {
+ return (char*)memcpy(s, buf, n) + n;
}
diff --git a/lib/ultralib/src/libc/syncprintf.c b/lib/ultralib/src/libc/syncprintf.c
index 572ac73..75f858e 100644
--- a/lib/ultralib/src/libc/syncprintf.c
+++ b/lib/ultralib/src/libc/syncprintf.c
@@ -1,5 +1,6 @@
#include "stdarg.h"
#include "PR/os.h"
+#include "PR/os_internal.h"
#include "PR/rdb.h"
#include "xstdio.h"
#include "PR/rcp.h"
@@ -12,7 +13,7 @@ extern void* __printfunc;
extern u32 __kmc_pt_mode;
static void* proutSyncPrintf(void* str, const char* buf, size_t n) {
- size_t sent = 0;
+ u32 sent = 0;
while (sent < n) {
sent += __osRdbSend(buf + sent, n - sent, RDB_TYPE_GtoH_PRINT);
@@ -25,8 +26,6 @@ static volatile unsigned int* wport = (unsigned*)0xbff08000;
static volatile unsigned int* piok = (unsigned*)PHYS_TO_K1(PI_STATUS_REG);
static void rmonPutchar(char c) {
- u32 data;
-
while (*piok & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
}
@@ -44,7 +43,7 @@ static void* kmc_proutSyncPrintf(void* str, const char* buf, int n) {
char xbuf[128];
static int column = 0;
- p = &xbuf;
+ p = xbuf;
for (i = 0; i < n; i++) {
c = *buf++;
@@ -117,12 +116,12 @@ void rmonPrintf(const char* fmt, ...) {
#else
-void __osSyncVPrintf(const char* fmt, va_list args) {
+void __osSyncVPrintf(const char* fmt, va_list ap) {
int ans;
#ifndef _FINALROM
if (__printfunc != NULL) {
- ans = _Printf(__printfunc, NULL, fmt, args);
+ ans = _Printf(__printfunc, NULL, fmt, ap);
}
#endif
}
diff --git a/lib/ultralib/src/libc/xldtob.c b/lib/ultralib/src/libc/xldtob.c
index 1dc1434..f291e23 100644
--- a/lib/ultralib/src/libc/xldtob.c
+++ b/lib/ultralib/src/libc/xldtob.c
@@ -9,10 +9,10 @@
#define BUFF_LEN 0x20
-static s16 _Ldunscale(s16* pex, _Pft* px);
-static void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp);
+static short _Ldunscale(short* pex, ldouble* px);
+static void _Genld(_Pft* px, char code, unsigned char* p, short nsig, short xexp);
-static const double pows[] = {10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L};
+static const ldouble pows[] = {10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e127L, 10e255L};
// float properties
#define _D0 0
@@ -41,17 +41,16 @@ static const double pows[] = {10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L
#define _D2 2
#define _D3 3
-#define ALIGN(s, align) (((u32)(s) + ((align)-1)) & ~((align)-1))
+#define ALIGN(s, align) (((unsigned int)(s) + ((align)-1)) & ~((align)-1))
void _Ldtob(_Pft* px, char code) {
char buff[BUFF_LEN];
char *p;
- f64 ldval;
- s16 err;
- s16 nsig;
- s16 xexp;
+ ldouble ldval;
+ short err;
+ short nsig;
+ short xexp;
- // char unused[0x4];
p = buff;
ldval = px->v.ld;
@@ -61,7 +60,7 @@ void _Ldtob(_Pft* px, char code) {
px->prec = 1;
}
- err = _Ldunscale(&xexp, px);
+ err = _Ldunscale(&xexp, &px->v.ld);
if (err > 0) {
memcpy(px->s, err == 2 ? "NaN" : "Inf", px->n1 = 3);
return;
@@ -87,7 +86,7 @@ void _Ldtob(_Pft* px, char code) {
}
}
} else if (xexp > 0) {
- f64 factor = 1;
+ ldouble factor = 1;
xexp &= ~3;
@@ -160,9 +159,9 @@ void _Ldtob(_Pft* px, char code) {
_Genld(px, code, p, nsig, xexp);
}
-s16 _Ldunscale(s16* pex, _Pft* px) {
- u16* ps = (u16*)px;
- s16 xchar = (ps[_D0] & _DMASK) >> _DOFF;
+short _Ldunscale(short* pex, ldouble* px) {
+ unsigned short* ps = (unsigned short*)px;
+ short xchar = (ps[_D0] & _DMASK) >> _DOFF;
if (xchar == _DMAX) {
@@ -181,7 +180,7 @@ s16 _Ldunscale(s16* pex, _Pft* px) {
}
}
-void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) {
+void _Genld(_Pft* px, char code, unsigned char* p, short nsig, short xexp) {
const unsigned char point = '.';
if (nsig <= 0) {
@@ -299,7 +298,7 @@ void _Genld(_Pft* px, char code, u8* p, s16 nsig, s16 xexp) {
}
if ((px->flags & 0x14) == 0x10) {
- s32 n = px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2;
+ int n = px->n0 + px->n1 + px->nz1 + px->n2 + px->nz2;
if (n < px->width) {
px->nz0 = px->width - n;
diff --git a/lib/ultralib/src/libc/xlitob.c b/lib/ultralib/src/libc/xlitob.c
index 2b27b3a..608e35f 100644
--- a/lib/ultralib/src/libc/xlitob.c
+++ b/lib/ultralib/src/libc/xlitob.c
@@ -12,47 +12,47 @@
static char ldigs[] = "0123456789abcdef";
static char udigs[] = "0123456789ABCDEF";
-void _Litob(_Pft *args, char type) {
+void _Litob(_Pft *px, char code) {
char buff[BUFF_LEN];
const char *digs;
- s32 base;
- s32 i;
+ int base;
+ int i;
unsigned long long ullval;
- digs = (type == 'X') ? udigs : ldigs;
+ digs = (code == 'X') ? udigs : ldigs;
- base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16);
+ base = (code == 'o') ? 8 : ((code != 'x' && code != 'X') ? 10 : 16);
i = BUFF_LEN;
- ullval = args->v.ll;
+ ullval = px->v.ll;
- if ((type == 'd' || type == 'i') && args->v.ll < 0) {
+ if ((code == 'd' || code == 'i') && px->v.ll < 0) {
ullval = -ullval;
}
- if (ullval != 0 || args->prec != 0) {
+ if (ullval != 0 || px->prec != 0) {
buff[--i] = digs[ullval % base];
}
- args->v.ll = ullval / base;
+ px->v.ll = ullval / base;
- while (args->v.ll > 0 && i > 0) {
- lldiv_t qr = lldiv(args->v.ll, base);
+ while (px->v.ll > 0 && i > 0) {
+ lldiv_t qr = lldiv(px->v.ll, base);
- args->v.ll = qr.quot;
+ px->v.ll = qr.quot;
buff[--i] = digs[qr.rem];
}
- args->n1 = BUFF_LEN - i;
+ px->n1 = BUFF_LEN - i;
- memcpy(args->s, buff + i, args->n1);
+ memcpy(px->s, buff + i, px->n1);
- if (args->n1 < args->prec) {
- args->nz0 = args->prec - args->n1;
+ if (px->n1 < px->prec) {
+ px->nz0 = px->prec - px->n1;
}
- if (args->prec < 0 && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) {
- if ((i = args->width - args->n0 - args->nz0 - args->n1) > 0) {
- args->nz0 += i;
+ if (px->prec < 0 && (px->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) {
+ if ((i = px->width - px->n0 - px->nz0 - px->n1) > 0) {
+ px->nz0 += i;
}
}
}
diff --git a/lib/ultralib/src/libc/xprintf.c b/lib/ultralib/src/libc/xprintf.c
index 788f42c..9191e1c 100644
--- a/lib/ultralib/src/libc/xprintf.c
+++ b/lib/ultralib/src/libc/xprintf.c
@@ -1,4 +1,4 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "string.h"
#include "stdarg.h"
#include "xstdio.h"
@@ -32,7 +32,7 @@
#define PUT(s, n) \
if (0 < (n)) \
{ \
- if ((arg = (*prout)(arg, s, n)) != NULL) \
+ if ((arg = (*pfn)(arg, s, n)) != NULL) \
x.nchar += (n); \
else \
return x.nchar; \
@@ -40,19 +40,19 @@
static char spaces[] = " ";
static char zeroes[] = "00000000000000000000000000000000";
-static void _Putfld(_Pft *pf, va_list *pap, char code, char *ac);
+static void _Putfld(_Pft *px, va_list *pap, char code, char *ac);
-int _Printf(outfun prout, char *arg, const char *fmt, va_list args) {
+int _Printf(void* pfn(void*,const char*,size_t), void *arg, const char *fmt, va_list ap) {
_Pft x;
x.nchar = 0;
- while (TRUE) {
+ while (1) {
const char *s;
char c;
const char *t;
static const char fchar[] = {' ', '+', '-', '#', '0', '\0'};
- static const int fbit[] = {FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0};
+ static const unsigned int fbit[] = {FLAGS_SPACE, FLAGS_PLUS, FLAGS_MINUS, FLAGS_HASH, FLAGS_ZERO, 0};
char ac[32];
s = fmt;
@@ -73,7 +73,7 @@ int _Printf(outfun prout, char *arg, const char *fmt, va_list args) {
}
if (*s == '*') {
- x.width = va_arg(args, int);
+ x.width = va_arg(ap, int);
if (x.width < 0) {
x.width = -x.width;
@@ -87,7 +87,7 @@ int _Printf(outfun prout, char *arg, const char *fmt, va_list args) {
if (*s != '.') {
x.prec = -1;
} else if (*++s == '*') {
- x.prec = va_arg(args, int);
+ x.prec = va_arg(ap, int);
++s;
} else
for (x.prec = 0; isdigit(*s); s++) {
@@ -103,7 +103,7 @@ int _Printf(outfun prout, char *arg, const char *fmt, va_list args) {
++s;
}
- _Putfld(&x, &args, *s, ac);
+ _Putfld(&x, &ap, *s, ac);
x.width -= x.n0 + x.nz0 + x.n1 + x.nz1 + x.n2 + x.nz2;
{
@@ -139,119 +139,118 @@ int _Printf(outfun prout, char *arg, const char *fmt, va_list args) {
return 0;
}
-static void _Putfld(_Pft *x, va_list *args, char type, char *buff) {
- x->n0 = x->nz0 = x->n1 = x->nz1 = x->n2 =
- x->nz2 = 0;
+static void _Putfld(_Pft *px, va_list *pap, char code, char *ac) {
+ px->n0 = px->nz0 = px->n1 = px->nz1 = px->n2 =
+ px->nz2 = 0;
- switch (type) {
+ switch (code) {
case 'c':
- buff[x->n0++] = va_arg(*args, int);
+ ac[px->n0++] = va_arg(*pap, int);
break;
case 'd':
case 'i':
- if (x->qual == 'l') {
- x->v.ll = va_arg(*args, int);
- } else if (x->qual == 'L') {
- x->v.ll = va_arg(*args, s64);
+ if (px->qual == 'l') {
+ px->v.ll = va_arg(*pap, long);
+ } else if (px->qual == 'L') {
+ px->v.ll = va_arg(*pap, long long);
} else {
- x->v.ll = va_arg(*args, int);
+ px->v.ll = va_arg(*pap, int);
}
- if (x->qual == 'h') {
- x->v.ll = (s16)x->v.ll;
+ if (px->qual == 'h') {
+ px->v.ll = (short)px->v.ll;
}
- if (x->v.ll < 0) {
- buff[x->n0++] = '-';
- } else if (x->flags & FLAGS_PLUS) {
- buff[x->n0++] = '+';
- } else if (x->flags & FLAGS_SPACE) {
- buff[x->n0++] = ' ';
+ if (px->v.ll < 0) {
+ ac[px->n0++] = '-';
+ } else if (px->flags & FLAGS_PLUS) {
+ ac[px->n0++] = '+';
+ } else if (px->flags & FLAGS_SPACE) {
+ ac[px->n0++] = ' ';
}
- x->s = (char *)&buff[x->n0];
+ px->s = (char *)&ac[px->n0];
- _Litob(x, type);
+ _Litob(px, code);
break;
case 'x':
case 'X':
case 'u':
case 'o':
- if (x->qual == 'l') {
- x->v.ll = va_arg(*args, int);
- } else if (x->qual == 'L') {
- x->v.ll = va_arg(*args, s64);
+ if (px->qual == 'l') {
+ px->v.ll = va_arg(*pap, long);
+ } else if (px->qual == 'L') {
+ px->v.ll = va_arg(*pap, long long);
} else {
- x->v.ll = va_arg(*args, int);
+ px->v.ll = va_arg(*pap, int);
}
- if (x->qual == 'h') {
- x->v.ll = (u16)x->v.ll;
- } else if (x->qual == 0) {
- x->v.ll = (unsigned int)x->v.ll;
+ if (px->qual == 'h') {
+ px->v.ll = (unsigned short)px->v.ll;
+ } else if (px->qual == 0) {
+ px->v.ll = (unsigned int)px->v.ll;
}
- if (x->flags & FLAGS_HASH) {
- buff[x->n0++] = '0';
+ if (px->flags & FLAGS_HASH) {
+ ac[px->n0++] = '0';
- if (type == 'x' || type == 'X') {
- buff[x->n0++] = type;
+ if (code == 'x' || code == 'X') {
+ ac[px->n0++] = code;
}
}
- x->s = (char *)&buff[x->n0];
- _Litob(x, type);
+ px->s = (char *)&ac[px->n0];
+ _Litob(px, code);
break;
case 'e':
case 'f':
case 'g':
case 'E':
case 'G':
- //... okay?
- x->v.ld = x->qual == 'L' ? va_arg(*args, f64) : va_arg(*args, f64);
-
- if (LDSIGN(x->v.ld))
- buff[x->n0++] = '-';
- else if (x->flags & FLAGS_PLUS)
- buff[x->n0++] = '+';
- else if (x->flags & FLAGS_SPACE)
- buff[x->n0++] = ' ';
-
- x->s = (char *)&buff[x->n0];
- _Ldtob(x, type);
+ px->v.ld = px->qual == 'L' ? va_arg(*pap, ldouble) : va_arg(*pap, double);
+
+ if (LDSIGN(px->v.ld))
+ ac[px->n0++] = '-';
+ else if (px->flags & FLAGS_PLUS)
+ ac[px->n0++] = '+';
+ else if (px->flags & FLAGS_SPACE)
+ ac[px->n0++] = ' ';
+
+ px->s = (char *)&ac[px->n0];
+ _Ldtob(px, code);
break;
case 'n':
- if (x->qual == 'h') {
- *(va_arg(*args, u16 *)) = x->nchar;
- } else if (x->qual == 'l') {
- *va_arg(*args, unsigned int *) = x->nchar;
- } else if (x->qual == 'L') {
- *va_arg(*args, u64 *) = x->nchar;
+ if (px->qual == 'h') {
+ *va_arg(*pap, unsigned short *) = px->nchar;
+ } else if (px->qual == 'l') {
+ *va_arg(*pap, unsigned long *) = px->nchar;
+ } else if (px->qual == 'L') {
+ *va_arg(*pap, unsigned long long *) = px->nchar;
} else {
- *va_arg(*args, unsigned int *) = x->nchar;
+ *va_arg(*pap, unsigned int *) = px->nchar;
}
break;
case 'p':
- x->v.ll = (long)va_arg(*args, void *);
- x->s = (char *)&buff[x->n0];
- _Litob(x, 'x');
+ px->v.ll = (long)va_arg(*pap, void *);
+ px->s = (char *)&ac[px->n0];
+ _Litob(px, 'x');
break;
case 's':
- x->s = va_arg(*args, char *);
- x->n1 = strlen(x->s);
+ px->s = va_arg(*pap, char *);
+ px->n1 = strlen(px->s);
- if (x->prec >= 0 && x->prec < x->n1) {
- x->n1 = x->prec;
+ if (px->prec >= 0 && px->prec < px->n1) {
+ px->n1 = px->prec;
}
break;
case '%':
- buff[x->n0++] = '%';
+ ac[px->n0++] = '%';
break;
default:
- buff[x->n0++] = type;
+ ac[px->n0++] = code;
break;
}
}
diff --git a/lib/ultralib/src/libc/xstdio.h b/lib/ultralib/src/libc/xstdio.h
index bd70de8..fd55177 100644
--- a/lib/ultralib/src/libc/xstdio.h
+++ b/lib/ultralib/src/libc/xstdio.h
@@ -1,13 +1,19 @@
#ifndef _XSTDIO_H
#define _XSTDIO_H
-#include "PR/ultratypes.h"
+
#include "stdlib.h"
#include "stdarg.h"
+#ifdef __sgi
+typedef double ldouble; // IDO does not support long doubles
+#else
+typedef long double ldouble;
+#endif
+
typedef struct {
/* 0x0 */ union {
/* 0x0 */ long long ll;
- /* 0x0 */ double ld;
+ /* 0x0 */ ldouble ld;
} v;
/* 0x8 */ unsigned char* s;
/* 0xC */ int n0;
@@ -28,10 +34,9 @@ typedef struct {
#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(_Pft *args, char type);
-void _Ldtob(_Pft* args, char type);
+int _Printf(void* pfn(void*,const char*,size_t), void *arg, const char *fmt, va_list ap);
+void _Litob(_Pft *px, char code);
+void _Ldtob(_Pft* px, char code);
#endif
diff --git a/lib/ultralib/src/log/delay.s b/lib/ultralib/src/log/delay.s
index 631781a..70782f6 100644
--- a/lib/ultralib/src/log/delay.s
+++ b/lib/ultralib/src/log/delay.s
@@ -5,16 +5,16 @@
#include "sys/regdef.h"
LEAF(osDelay)
- sll t0,a0,2
- addu t0,a0
- sll t0,t0,2
- beqz a0,2f
+ sll t0, a0, 2
+ addu t0, a0
+ sll t0, t0, 2
+ beqz a0, 2f
1:
- subu t0,1
+ subu t0, 1
NOP
NOP
- bnez t0,1b
+ bnez t0, 1b
2:
j ra
diff --git a/lib/ultralib/src/log/log.c b/lib/ultralib/src/log/log.c
index 85129d2..1519c3b 100644
--- a/lib/ultralib/src/log/log.c
+++ b/lib/ultralib/src/log/log.c
@@ -4,14 +4,14 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
#ifndef _FINALROM
static u32 __osLogOKtoWrite = TRUE;
static u32 __osLogInitialized = FALSE;
-static OSMesgQueue __osLogDoneMsgQ ALIGNED(8);
+static OSMesgQueue __osLogDoneMsgQ ALIGNED(0x8);
static OSMesg __osLogMsgBuf;
void __osLogWrite(OSLog* log, s16 code, s16 numArgs, va_list argPtr);
diff --git a/lib/ultralib/src/os/ackramromread.c b/lib/ultralib/src/os/ackramromread.c
index 3de1f6f..992a4f7 100644
--- a/lib/ultralib/src/os/ackramromread.c
+++ b/lib/ultralib/src/os/ackramromread.c
@@ -12,5 +12,5 @@
#ident "$Revision: 1.3 $"
#endif
-void osAckRamromRead() {
+void osAckRamromRead(void) {
}
diff --git a/lib/ultralib/src/os/ackramromwrite.c b/lib/ultralib/src/os/ackramromwrite.c
index a99e951..32301ab 100644
--- a/lib/ultralib/src/os/ackramromwrite.c
+++ b/lib/ultralib/src/os/ackramromwrite.c
@@ -11,5 +11,5 @@
#ident "$Revision: 1.3 $"
#endif
-void osAckRamromWrite() {
+void osAckRamromWrite(void) {
}
diff --git a/lib/ultralib/src/os/afterprenmi.c b/lib/ultralib/src/os/afterprenmi.c
index 03b5b24..7568251 100644
--- a/lib/ultralib/src/os/afterprenmi.c
+++ b/lib/ultralib/src/os/afterprenmi.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-s32 osAfterPreNMI() {
+s32 osAfterPreNMI(void) {
return __osSpSetPc(0);
}
diff --git a/lib/ultralib/src/os/createmesgqueue.c b/lib/ultralib/src/os/createmesgqueue.c
index 5c92f04..72209b9 100644
--- a/lib/ultralib/src/os/createmesgqueue.c
+++ b/lib/ultralib/src/os/createmesgqueue.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 msgCount) {
diff --git a/lib/ultralib/src/os/createthread.c b/lib/ultralib/src/os/createthread.c
index 7c17834..927ef0e 100644
--- a/lib/ultralib/src/os/createthread.c
+++ b/lib/ultralib/src/os/createthread.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/R4300.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
extern __OSThreadprofile_s thprof[];
@@ -28,11 +28,11 @@ void osCreateThread(OSThread* t, OSId id, void (*entry)(void*), void* arg, void*
t->context.pc = (u32)entry;
t->context.a0 = (s64)(s32)arg; // Double cast gets rid of compiler warning
t->context.sp = (s64)(s32)sp - 16;
- t->context.ra = (u64)__osCleanupThread;
+ t->context.ra = (s64)(s32)__osCleanupThread;
mask = OS_IM_ALL;
t->context.sr = (mask & (SR_IMASK | SR_IE)) | SR_EXL;
t->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT;
- t->context.fpcsr = (u32)(FPCSR_FS | FPCSR_EV);
+ t->context.fpcsr = FPCSR_FS | FPCSR_EV | FPCSR_RM_RN;
t->fp = 0;
t->state = OS_STATE_STOPPED;
t->flags = 0;
diff --git a/lib/ultralib/src/os/destroythread.c b/lib/ultralib/src/os/destroythread.c
index c668869..5442e86 100644
--- a/lib/ultralib/src/os/destroythread.c
+++ b/lib/ultralib/src/os/destroythread.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
void osDestroyThread(OSThread* t) {
register u32 saveMask;
diff --git a/lib/ultralib/src/os/exceptasm.s b/lib/ultralib/src/os/exceptasm.s
index b7699a8..919482e 100644
--- a/lib/ultralib/src/os/exceptasm.s
+++ b/lib/ultralib/src/os/exceptasm.s
@@ -1,3 +1,7 @@
+#ifdef MODERN_CC
+.set gp=64
+#endif
+
#include "PR/R4300.h"
#include "sys/asm.h"
#include "sys/regdef.h"
@@ -7,6 +11,7 @@
#include "exceptasm.h"
#include "threadasm.h"
#include "PR/os_version.h"
+
#define KMC_CODE_ENTRY 0xBFF00014
#define KMC_WPORT 0xBFF08000
#define KMC_STAT 0xBFF08004
@@ -101,10 +106,14 @@ __os_Kdebug_Pkt:
__osPreviousThread:
.word 0
#endif
-#endif
+#endif
.text
+/**
+ * The exception preamble is copied to the exception vectors at
+ * UT_VEC, XUT_VEC, ECC_VEC, E_VEC, to direct execution to __osException
+ */
LEAF(__osExceptionPreamble)
la k0, __osException
jr k0
@@ -174,26 +183,27 @@ pt_prof:
END(__ptException)
#endif
-LEAF(__osException)
+LEAF(__osException)
+ /* Load scratch space for thread saving */
la k0, __osThreadSave
- /* save AT */
+ /* Save AT */
.set noat
sd $1, THREAD_GP1(k0);
.set at
- /* save sr */
-STAY2(mfc0 k1, C0_SR)
+ /* Save SR */
+ MFC0( k1, C0_SR)
sw k1, THREAD_SR(k0)
- /* clear interrupts */
- and k1, k1, -4
-STAY2(mtc0 k1, C0_SR)
- /* save other regs */
+ /* Disable interrupts */
+ and k1, k1, ~(SR_IE | SR_EXL)
+ MTC0( k1, C0_SR)
+ /* Save some temp registers for use in the following */
sd $8, THREAD_GP8(k0)
sd $9, THREAD_GP9(k0)
sd $10, THREAD_GP10(k0)
- /* say fp has not been used */
+ /* Mark FPU as unused */
sw zero, THREAD_FP(k0)
- /* this instruction is useless, leftover because of bad placement of an ifdef for the debug version */
-STAY2(mfc0 t0, C0_CAUSE)
+ /* This instruction is useless, leftover because of bad placement of an ifdef for the debug version */
+ MFC0( t0, C0_CAUSE)
#ifndef _FINALROM
lw t2, __kmc_pt_mode
bnez t2, skip_kmc_mode
@@ -207,7 +217,7 @@ STAY2(mfc0 t0, C0_CAUSE)
la t1, RDB_WRITE_INTR_REG
sw zero, (t1)
IP7check:
-STAY2(mfc0 t0, C0_CAUSE)
+ MFC0( t0, C0_CAUSE)
andi t0, t0, CAUSE_IP7
bne zero, t0, IP7check
la t2, RDB_BASE_REG
@@ -364,7 +374,7 @@ notIP7:
5:
sw t1, __osRdb_IP6_CurSend
checkIP6:
-STAY2(mfc0 t0, C0_CAUSE)
+ MFC0( t0, C0_CAUSE)
andi t0, t0, CAUSE_IP6
bne zero, t0, checkIP6
la t0, RDB_BASE_REG
@@ -377,7 +387,7 @@ rdbout:
ld $1, THREAD_GP1(k0)
.set at
lw k1, THREAD_SR(k0)
-STAY2(mtc0 k1, C0_SR)
+ MTC0( k1, C0_SR)
.set noreorder
nop
nop
@@ -390,8 +400,9 @@ skip_kmc_mode:
#endif
savecontext:
+ /* Save the context of the previously running thread to be restored when it resumes */
move t0, k0
- lw k0, __osRunningThread
+ lw k0, __osRunningThread
#if !defined(_FINALROM) && BUILD_VERSION >= VERSION_K
sw k0, __osPreviousThread
#endif
@@ -440,8 +451,13 @@ savecontext:
lw k1, THREAD_SR(k0)
andi t1, k1, SR_IMASK
beqz t1, savercp
-
-/*if any interrupts are enabled*/
+
+ /*
+ * If any CPU interrupts are enabled in the SR of the previous thread, bitwise-OR in the
+ * disabled CPU interrupts from the global interrupt mask.
+ * This is an attempt at reverting the effect of masking the SR of the thread with the
+ * global interrupt mask. This is however broken, see comments for osSetIntMask.
+ */
la t0, __OSGlobalIntMask
lw t0, 0(t0)
xor t2, t0, ~0 /* not except not using not */
@@ -456,9 +472,14 @@ savecontext:
or k1, k1, t1
savercp:
+ /* Save the currently masked RCP interrupts. */
lw t1, PHYS_TO_K1(MI_INTR_MASK_REG)
beqz t1, endrcp
+ /*
+ * Similar to the above comment, but for RCP interrupt enable bits rather than CPU.
+ * This suffers from the same problem as above.
+ */
la t0, __OSGlobalIntMask
lw t0, 0(t0)
@@ -470,11 +491,12 @@ savercp:
or t1, t1, t0
endrcp:
sw t1, THREAD_RCP(k0)
-STAY2(mfc0 t0, C0_EPC)
+ MFC0( t0, C0_EPC)
sw t0, THREAD_PC(k0)
lw t0, THREAD_FP(k0)
beqz t0, 1f
-STAY2(cfc1 t0, fcr31)
+ /* Save FP Registers if FPU was used by the thread */
+ CFC1( t0, fcr31)
NOP
sw t0, THREAD_FPCSR(k0)
sdc1 $f0, THREAD_FP0(k0)
@@ -494,7 +516,11 @@ STAY2(cfc1 t0, fcr31)
sdc1 $f28, THREAD_FP28(k0)
sdc1 $f30, THREAD_FP30(k0)
1:
-STAY2(mfc0 t0, C0_CAUSE)
+ /*
+ * Determine the cause of the exception or interrupt and
+ * enter appropriate handling routine
+ */
+ MFC0( t0, C0_CAUSE)
sw t0, THREAD_CAUSE(k0)
.set noreorder
@@ -518,21 +544,28 @@ no_rdb_mesg:
#endif
andi t1, t0, CAUSE_EXCMASK
+ /* Test for break exception */
li t2, EXC_BREAK
beq t1, t2, handle_break
-
+
+ /* Test for CpU (coprocessor unusable) exception */
li t2, EXC_CPU
beq t1, t2, handle_CpU
-
+
+ /* Test for interrupt, if it is not an interrupt, panic */
li t2, EXC_INT
bne t1, t2, panic
handle_interrupt:
and s0, k1, t0
next_interrupt:
+ /*
+ * Handle external interrupt causes, using a jump table
+ * to enter into the appropriate handler
+ */
andi t1, s0, SR_IMASK
srl t2, t1, 0xc
bnez t2, 1f
-
+
srl t2, t1, SR_IMASKSHIFT
addi t2, t2, 16
1:
@@ -542,272 +575,425 @@ next_interrupt:
lw t2, __osIntTable(t2)
jr t2
+/**
+ * IP6 Interrupt
+ * Only signalled by development hardware
+ */
IP6_Hdlr:
+ /* Mask out interrupt and continue */
and s0, s0, ~CAUSE_IP6
b next_interrupt
-
+
+/**
+ * IP7 Interrupt
+ * Only signalled by development hardware
+ */
IP7_Hdlr:
+ /* Mask out interrupt and continue */
and s0, s0, ~CAUSE_IP7
b next_interrupt
+/**
+ * IP8/Counter Interrupt
+ * Once the cop0 count register reaches the value of the
+ * cop0 compare register, this interrupt is triggered
+ */
counter:
-STAY2(mfc0 t1, C0_COMPARE)
-STAY2(mtc0 t1, C0_COMPARE)
+ MFC0( t1, C0_COMPARE)
+ MTC0( t1, C0_COMPARE)
li a0, MESG(OS_EVENT_COUNTER)
+ /* Post counter message */
jal send_mesg
+ /* Mask out interrupt and continue */
and s0, s0, ~CAUSE_IP8
b next_interrupt
+/**
+ * IP4/Cartridge Interrupt
+ * Signalled by the N64 Disk Drive
+ */
cart:
#if BUILD_VERSION >= VERSION_J
+ /* Mask out interrupt */
and s0, s0, ~CAUSE_IP4
+ /* Load cart callback set by __osSetHWIntrRoutine */
la t1, __osHwIntTable
add t1, HWINTR_SIZE
lw t2, HWINTR_CALLBACK(t1)
+ /* If the callback is NULL, handling is done */
beqz t2, 1f
+ /* Set up a stack and run the callback */
lw sp, HWINTR_SP(t1)
jalr t2
-
+
beqz v0, 1f
+ /* Redispatch immediately if the callback returned nonzero */
b redispatch
-
+
1:
+ /* Post a cart event message */
li a0, MESG(OS_EVENT_CART)
jal send_mesg
+ /* Continue */
b next_interrupt
#else
li a0, MESG(OS_EVENT_CART)
+ /* Mask out interrupt */
and s0, s0, ~CAUSE_IP4
- la sp, leoDiskStack
+ la sp, leoDiskStack
addiu sp, 0x1000 - 0x10 # Stack size minus initial frame
+ /* Load cart callback set by __osSetHWIntrRoutine */
li t2, HWINTR_SIZE
lw t2, __osHwIntTable(t2)
+ /* If the callback is NULL, handling is done */
beqz t2, 1f
-
+
+ /* Set up a stack and run the callback */
jalr t2
li a0, MESG(OS_EVENT_CART)
-
+
beqz v0, 1f
+ /* Redispatch immediately if the callback returned nonzero */
b redispatch
-
+
1:
+ /* Post a cart event message */
jal send_mesg
+ /* Continue */
b next_interrupt
#endif
+/**
+ * IP3/RCP Interrupt
+ * Signalled by the RCP for various reasons, described below
+ */
rcp:
+ /*
+ * Load the MI interrupts and mask with the RCP bits in the global interrupt mask
+ *
+ * @bug this clobbers the t0 register which is expected to hold the value of the
+ * C0_CAUSE register in the sw1 and sw2 handlers. If the sw1 or sw2 handler runs
+ * after this, the interrupt will not be cleared properly.
+ */
lw s1, PHYS_TO_K1(MI_INTR_REG)
la t0, __OSGlobalIntMask
lw t0, (t0)
srl t0, t0, 0x10
and s1, s1, t0
+
+/**
+ * Signal Processor (SP) Interrupt
+ */
+ /* Test for sp interrupt */
andi t1, s1, MI_INTR_SP
beqz t1, vi
- andi s1, s1, 0x3e
+ /* Test for yielded or done signals in particular */
+
+ /* Mask out SP interrupt */
+ andi s1, s1, (MI_INTR_SI | MI_INTR_AI | MI_INTR_VI | MI_INTR_PI | MI_INTR_DP)
lw ta0, PHYS_TO_K1(SP_STATUS_REG)
li t1, (SP_CLR_INTR | SP_CLR_SIG3)
+ /* Clear interrupt and signal 3 */
sw t1, PHYS_TO_K1(SP_STATUS_REG)
- andi ta0, ta0, 0x300
+ andi ta0, ta0, (SP_STATUS_YIELDED | SP_STATUS_TASKDONE)
beqz ta0, sp_other_break
+ /* Post an SP event message */
li a0, MESG(OS_EVENT_SP)
jal send_mesg
beqz s1, NoMoreRcpInts
+ /* Step over sp_other_break handler */
b vi
sp_other_break:
+ /*
+ * An sp signal that is not due to yielding or task completion, such as
+ * an sp breakpoint. Post a different event message
+ */
li a0, MESG(OS_EVENT_SP_BREAK)
jal send_mesg
beqz s1, NoMoreRcpInts
-
+
+/**
+ * Video Interface (VI) Interrupt
+ */
vi:
- andi t1, s1, 0x8
+ /* Test for vi interrupt */
+ andi t1, s1, MI_INTR_VI
beqz t1, ai
-
- andi s1, s1, 0x37
-
+
+ /* Mask out vi interrupt */
+ andi s1, s1, (MI_INTR_SP | MI_INTR_SI | MI_INTR_AI | MI_INTR_PI | MI_INTR_DP)
+
+ /* Clear interrupt */
sw zero, PHYS_TO_K1(VI_CURRENT_REG)
+
+ /* Post vi event message */
li a0, MESG(OS_EVENT_VI)
jal send_mesg
beqz s1, NoMoreRcpInts
-
+
+/**
+ * Audio Interface (AI) Interrupt
+ */
ai:
- andi t1, s1, 0x4
+ /* Test for ai interrupt */
+ andi t1, s1, MI_INTR_AI
beqz t1, si
- andi s1, s1, 0x3b
-
+ /* Mask out ai interrupt */
+ andi s1, s1, (MI_INTR_SP | MI_INTR_SI | MI_INTR_VI | MI_INTR_PI | MI_INTR_DP)
+
li t1, 1
+ /* Clear interrupt */
sw t1, PHYS_TO_K1(AI_STATUS_REG)
+ /* Post ai event message */
li a0, MESG(OS_EVENT_AI)
jal send_mesg
beqz s1, NoMoreRcpInts
-
+
+/**
+ * Serial Interface (SI) Interrupt
+ */
si:
- andi t1, s1, 0x2
+ /* Test for si interrupt */
+ andi t1, s1, MI_INTR_SI
beqz t1, pi
-
- andi s1, s1, 0x3d
- /* any write clears interrupts */
- sw zero, PHYS_TO_K1(SI_STATUS_REG)
+
+ /* Mask out si interrupt */
+ andi s1, s1, (MI_INTR_SP | MI_INTR_AI | MI_INTR_VI | MI_INTR_PI | MI_INTR_DP)
+ /* Clear interrupt */
+ sw zero, PHYS_TO_K1(SI_STATUS_REG)
+
+ /* Post si event message */
li a0, MESG(OS_EVENT_SI)
jal send_mesg
beqz s1, NoMoreRcpInts
-
+
+/**
+ * Parallel Interface (PI) Interrupt
+ */
pi:
- andi t1, s1, 0x10
+ /* Test for pi interrupt */
+ andi t1, s1, MI_INTR_PI
beqz t1, dp
- andi s1, s1, 0x2f
-
+ /* Mask out pi interrupt */
+ andi s1, s1, (MI_INTR_SP | MI_INTR_SI | MI_INTR_AI | MI_INTR_VI | MI_INTR_DP)
+
+ /* Clear interrupt */
li t1, PI_STATUS_CLR_INTR
sw t1, PHYS_TO_K1(PI_STATUS_REG)
#if BUILD_VERSION >= VERSION_J
+ /* Load pi callback */
la t1, __osPiIntTable
lw t2, (t1)
+ /* Skip callback if NULL */
beqz t2, 1f
+ /* Set up a stack and run the callback */
lw sp, 4(t1)
move a0, v0
jalr t2
+ /* If the callback returns non-zero, do not post a pi event message */
bnez v0, 2f
1:
#endif
+ /* Post pi event message */
li a0, MESG(OS_EVENT_PI)
jal send_mesg
#if BUILD_VERSION >= VERSION_J
2:
#endif
beqz s1, NoMoreRcpInts
-
+
+/**
+ * Display Processor (DP) Interrupt
+ */
dp:
- andi t1, s1, 0x20
+ /* Test for dp interrupt */
+ andi t1, s1, MI_INTR_DP
beqz t1, NoMoreRcpInts
- andi s1, s1, 0x1f
+ /* Mask out dp interrupt */
+ andi s1, s1, (MI_INTR_SP | MI_INTR_SI | MI_INTR_AI | MI_INTR_VI | MI_INTR_PI)
+ /* Clear dp interrupt */
li t1, MI_CLR_DP_INTR
sw t1, PHYS_TO_K1(MI_INIT_MODE_REG)
-
+
+ /* Post dp event message */
li a0, MESG(OS_EVENT_DP)
jal send_mesg
NoMoreRcpInts:
+ /* Mask out interrupt and continue */
and s0, s0, ~CAUSE_IP3
b next_interrupt
+/**
+ * IP5/PreNMI Interrupt
+ * Reset button has been pressed
+ */
prenmi:
+ /* Disable IP5/PreNMI interrupt for the previously running thread */
lw k1, THREAD_SR(k0)
and k1, k1, ~CAUSE_IP5
sw k1, THREAD_SR(k0)
+ /* Test __osShutdown for first PreNMI event */
la t1, __osShutdown
lw t2, 0(t1)
beqz t2, firstnmi
-
+
+ /* Mask out interrupt and redispatch immediately */
and s0, s0, ~CAUSE_IP5
b redispatch
firstnmi:
+ /* Set __osShutdown */
li t2, 1
- sw t2, 0(t1) /* __osShutdown */
+ sw t2, (t1)
+ /* Post a PreNMI event message */
li a0, MESG(OS_EVENT_PRENMI)
jal send_mesg
+ /* Mask out and disable IP5/PreNMI interrupt for the highest priority thread */
and s0, s0, ~CAUSE_IP5
lw t2, __osRunQueue
lw k1, THREAD_SR(t2)
and k1, k1, ~CAUSE_IP5
sw k1, THREAD_SR(t2)
+ /* Redispatch immediately */
b redispatch
sw2:
+ /* Mask out interrupt */
and t0, t0, ~CAUSE_SW2
-STAY2(mtc0 t0, C0_CAUSE)
+ MTC0( t0, C0_CAUSE)
+ /* Post sw2 event message */
li a0, MESG(OS_EVENT_SW2)
jal send_mesg
+ /* Mask out interrupt and continue */
and s0, s0, ~CAUSE_SW2
b next_interrupt
sw1:
+ /* Mask out interrupt */
and t0, t0, ~CAUSE_SW1
-STAY2(mtc0 t0, C0_CAUSE)
+ MTC0( t0, C0_CAUSE)
+ /* Post sw1 event message */
li a0, MESG(OS_EVENT_SW1)
jal send_mesg
+ /* Mask out interrupt and continue */
and s0, s0, ~CAUSE_SW1
b next_interrupt
handle_break:
+ /* Set last thread as having hit a break exception */
li t1, OS_FLAG_CPU_BREAK
sh t1, THREAD_FLAGS(k0)
+ /* Post a cpu break event message */
li a0, MESG(OS_EVENT_CPU_BREAK)
jal send_mesg
+
+ /* Redispatch */
b redispatch
-
+
redispatch:
+ /* Get priority of previously running thread */
lw t1, THREAD_PRI(k0)
lw t2, __osRunQueue
+ /* Get highest priority from waiting threads */
lw t3, THREAD_PRI(t2)
-
+
bge t1, t3, enqueueRunning
-
+
+ /*
+ * The previously running thread is no longer the highest priority,
+ * enqueue it to the run queue to wait its turn again
+ */
move a1, k0
la a0, __osRunQueue
-
+
jal __osEnqueueThread
-
+
j __osDispatchThread
-
+
+/**
+ * Resume the previously running thread by placing it at the top of
+ * the run queue and dispatching it
+ */
enqueueRunning:
la t1, __osRunQueue
lw t2, MQ_MTQUEUE(t1)
sw t2, THREAD_NEXT(k0)
sw k0, MQ_MTQUEUE(t1)
j __osDispatchThread
+
+/**
+ * Unhandled exceptions & interrupts end up here,
+ * trap to software by posting a fault message
+ */
panic:
+ /* Mark the thread as having faulted */
sw k0, __osFaultedThread
li t1, OS_STATE_STOPPED
sh t1, THREAD_STATE(k0)
li t1, OS_FLAG_FAULT
sh t1, THREAD_FLAGS(k0)
-STAY2(mfc0 t2, C0_BADVADDR)
+ /* Save C0_BADVADDR */
+ MFC0( t2, C0_BADVADDR)
sw t2, THREAD_BADVADDR(k0)
+ /* Post the fault message */
li a0, MESG(OS_EVENT_FAULT)
jal send_mesg
+
+ /* Dispatch next thread */
j __osDispatchThread
END(__osException)
-
+
+/**
+ * Handles posting event messages to the listening message queue, if there is one
+ */
LEAF(send_mesg)
+ /* Save return address */
move s2, ra
+
+ /* Load pointer to listening message queue */
la t2, __osEventStateTab
addu t2, t2, a0
lw t1, OS_EVENTSTATE_MESSAGE_QUEUE(t2)
+
+ /* If there is no listening message queue, done */
beqz t1, send_done
-
+
+ /* Test if the message queue is full, if so do not post the message */
lw t3, MQ_VALIDCOUNT(t1)
lw ta0, MQ_MSGCOUNT(t1)
-
+
bge t3, ta0, send_done
+ /* Add validcount to first and modulo with msgcount */
lw ta1, MQ_FIRST(t1)
addu ta1, ta1, t3
@@ -815,19 +1001,27 @@ LEAF(send_mesg)
lw ta0, MQ_MSG(t1)
mul ta1, ta1, 4
addu ta0, ta0, ta1
+
+ /* Fetch the message to post */
lw ta1, OS_EVENTSTATE_MESSAGE(t2)
- sw ta1, 0(ta0) /* msg[ta1] = */
+ /* Post the message to the message queue */
+ sw ta1, 0(ta0)
+ /* Increment the validCount */
addiu t2, t3, 1
sw t2, MQ_VALIDCOUNT(t1)
+ /*
+ * If there was a thread blocked on this message queue,
+ * wake it up
+ */
lw t2, MQ_MTQUEUE(t1)
lw t3, THREAD_NEXT(t2)
beqz t3, send_done
-
+
move a0, t1
jal __osPopThread
move t2, v0
-
+
move a1, t2
la a0, __osRunQueue
jal __osEnqueueThread
@@ -835,13 +1029,17 @@ send_done:
jr s2
END(send_mesg)
-LEAF(handle_CpU) /* coprocessor error */
+/**
+ * Handle coprocessor unusable exception
+ */
+LEAF(handle_CpU)
and t1, t0, CAUSE_CEMASK
srl t1, t1, CAUSE_CESHIFT
- li t2, 1 /* cp1 error */
+ /* if not coprocessor 1, panic */
+ li t2, 1
bne t1, t2, panic
- /* enable cp1 (fpu) for this thread */
+ /* Mark cop1 as usable for previous thread */
li t1, 1
sw t1, THREAD_FP(k0)
lw k1, THREAD_SR(k0)
@@ -850,14 +1048,25 @@ LEAF(handle_CpU) /* coprocessor error */
b enqueueRunning
END(handle_CpU)
+/**
+ * void __osEnqueueAndYield(OSThread** threadQueue);
+ *
+ * Voluntary thread yielding.
+ * Enqueues the currently running thread to the top of the
+ * thread queue `threadQueue` and yields to the highest priority
+ * unblocked runnable thread.
+ */
LEAF(__osEnqueueAndYield)
lw a1, __osRunningThread
#if !defined(_FINALROM) && BUILD_VERSION >= VERSION_K
sw a1, __osPreviousThread
#endif
-STAY2(mfc0 t0, C0_SR)
+ /* Save SR */
+ MFC0( t0, C0_SR)
ori t0, t0, SR_EXL
sw t0, THREAD_SR(a1)
+
+ /* Save callee-saved registers */
sd s0, THREAD_GP16(a1)
sd s1, THREAD_GP17(a1)
sd s2, THREAD_GP18(a1)
@@ -871,6 +1080,8 @@ STAY2(mfc0 t0, C0_SR)
sd s8, THREAD_GP30(a1)
sd ra, THREAD_GP31(a1)
sw ra, THREAD_PC(a1)
+
+ /* Save FPU callee-saved registers if the current thread has used the FPU */
lw k1, THREAD_FP(a1)
beqz k1, 1f
cfc1 k1, fcr31
@@ -886,6 +1097,10 @@ STAY2(mfc0 t0, C0_SR)
andi t1, k1, SR_IMASK
beqz t1, 2f
+ /*
+ * This code does the same thing as the block just above the `savercp` label.
+ * See the comment there for more about this.
+ */
la t0, __OSGlobalIntMask
lw t0, 0(t0)
xor t0, t0, ~0
@@ -898,36 +1113,57 @@ STAY2(mfc0 t0, C0_SR)
lw k1, PHYS_TO_K1(MI_INTR_MASK_REG)
beqz k1, 3f
+ /*
+ * This code does the same thing as the block just below the `savercp` label.
+ * See the comment there for more about this.
+ */
la k0, __OSGlobalIntMask
lw k0, 0(k0)
- srl k0, k0, 0x10
+ srl k0, k0, RCP_IMASKSHIFT
xor k0, k0, ~0
- andi k0, k0, 0x3f
+ andi k0, k0, (RCP_IMASK >> RCP_IMASKSHIFT)
lw t0, THREAD_RCP(a1)
and k0, k0, t0
or k1, k1, k0
3:
+ /*
+ * If the specified thread queue is null, skip
+ * straight to dispatching
+ */
sw k1, THREAD_RCP(a1)
beqz a0, noEnqueue
jal __osEnqueueThread
noEnqueue:
j __osDispatchThread
END(__osEnqueueAndYield)
-
-/*__osEnqueueThread(OSThread **, OSThread *)*/
+
+/**
+ * void __osEnqueueThread(OSThread** threadQueue, OSThread* thread);
+ *
+ * Enqueues `thread` to the thread queue `threadQueue`, inserted by priority
+ */
LEAF(__osEnqueueThread)
move t9, a0
lw t8, 0(a0)
lw ta3, THREAD_PRI(a1)
lw ta2, THREAD_PRI(t8)
+ /*
+ * If the current highest priority thread is a lower priority than
+ * the new thread, skip searching the queue
+ */
blt ta2, ta3, 2f
1:
+ /*
+ * Search the queue for the position to insert the thread to maintain
+ * ordering by priority
+ */
move t9, t8
lw t8, THREAD_NEXT(t8)
lw ta2, THREAD_PRI(t8)
bge ta2, ta3, 1b
2:
+ /* Insert the thread into the queue */
lw t8, THREAD_NEXT(t9)
sw t8, THREAD_NEXT(a1)
sw a1, THREAD_NEXT(t9)
@@ -935,23 +1171,42 @@ LEAF(__osEnqueueThread)
jr ra
END(__osEnqueueThread)
+/**
+ * OSThread* __osPopThread(OSThread** threadQueue);
+ *
+ * Pops the highest priority thread from the top of the
+ * thread queue `threadQueue` and returns it
+ */
LEAF(__osPopThread)
lw v0, 0(a0) /* a0 is OSThread** */
lw t9, THREAD_NEXT(v0)
sw t9, 0(a0)
jr ra
END(__osPopThread)
+
#if BUILD_VERSION >= VERSION_K
LEAF(__osNop)
jr ra
END(__osNop)
#endif
+
+/**
+ * void __osDispatchThread(void);
+ *
+ * Dispatches the next thread to run after restoring the context
+ */
LEAF(__osDispatchThread)
+ /* Obtain highest priority thread from the active run queue */
la a0, __osRunQueue
jal __osPopThread
+ /* Set thread as running */
sw v0, __osRunningThread
li t0, OS_STATE_RUNNING
sh t0, THREAD_STATE(v0)
+ /*
+ * Restore SR, masking out any interrupts that are not also
+ * enabled in the global interrupt mask
+ */
move k0, v0
#if !defined(_FINALROM) && BUILD_VERSION >= VERSION_K
@@ -964,7 +1219,7 @@ LEAF(__osDispatchThread)
jalr t0
#endif
-/* There's another 1: label somewhere around here in version J and below */
+/* There is another 1: label somewhere around here in version J and below */
#if BUILD_VERSION < VERSION_K
1:
#endif
@@ -978,7 +1233,8 @@ __osDispatchThreadSave:
and t1, t1, t0
and k1, k1, ~SR_IMASK
or k1, k1, t1
-STAY2(mtc0 k1, C0_SR)
+ MTC0( k1, C0_SR)
+/* Restore GPRs */
.set noat
ld $1, THREAD_GP1(k0)
.set at
@@ -1014,13 +1270,16 @@ STAY2(mtc0 k1, C0_SR)
mtlo k1
ld k1, THREAD_HI(k0)
mthi k1
+ /* Move thread pc to EPC so that eret will return execution to where the thread left off */
lw k1, THREAD_PC(k0)
-STAY2(mtc0 k1, C0_EPC)
+ MTC0( k1, C0_EPC)
+
+ /* Check if the FPU was used by this thread and if so also restore the FPU registers */
lw k1, THREAD_FP(k0)
beqz k1, 1f
lw k1, THREAD_FPCSR(k0)
-STAY2(ctc1 k1, fcr31)
+ CTC1( k1, fcr31)
ldc1 $f0, THREAD_FP0(k0)
ldc1 $f2, THREAD_FP2(k0)
ldc1 $f4, THREAD_FP4(k0)
@@ -1037,8 +1296,12 @@ STAY2(ctc1 k1, fcr31)
ldc1 $f26, THREAD_FP26(k0)
ldc1 $f28, THREAD_FP28(k0)
ldc1 $f30, THREAD_FP30(k0)
-
+
1:
+ /*
+ * Restore RCP interrupt mask, masking out any RCP interrupts that
+ * are not also enabled in the global interrupt mask
+ */
.set noreorder
lw k1, THREAD_RCP(k0)
la k0, __OSGlobalIntMask
@@ -1052,18 +1315,29 @@ STAY2(ctc1 k1, fcr31)
la k0, PHYS_TO_K1(MI_INTR_MASK_REG)
sw k1, 0(k0)
+ /* Empty pipeline */
nop
nop
nop
nop
+
+ /* Resume thread execution */
eret
.set reorder
END(__osDispatchThread)
+/**
+ * void __osCleanupThread(void);
+ *
+ * When a thread entrypoint function returns, it returns to this function.
+ * This function is responsible for cleaning up the thread, signalling for the
+ * current thread to be destroyed.
+ */
LEAF(__osCleanupThread)
move a0, zero
#if !defined(BBPLAYER) && !defined(__sgi)
nop
#endif
+ /* Despite being a jal, this function does not return as the thread will have been destroyed */
jal osDestroyThread
END(__osCleanupThread)
diff --git a/lib/ultralib/src/os/exit.c b/lib/ultralib/src/os/exit.c
index 24a873f..05582c5 100644
--- a/lib/ultralib/src/os/exit.c
+++ b/lib/ultralib/src/os/exit.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-void osExit() {
+void osExit(void) {
__osGIOInterrupt(16);
for (;;) {
diff --git a/lib/ultralib/src/os/getactivequeue.c b/lib/ultralib/src/os/getactivequeue.c
index 1fefc88..f2fdf5f 100644
--- a/lib/ultralib/src/os/getactivequeue.c
+++ b/lib/ultralib/src/os/getactivequeue.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
OSThread* __osGetActiveQueue(void) {
return __osActiveQueue;
diff --git a/lib/ultralib/src/os/getcause.s b/lib/ultralib/src/os/getcause.s
index 873464f..2c8c503 100644
--- a/lib/ultralib/src/os/getcause.s
+++ b/lib/ultralib/src/os/getcause.s
@@ -4,6 +4,6 @@
.text
LEAF(__osGetCause)
- STAY2(mfc0 v0, C0_CAUSE)
- jr ra
+ MFC0( v0, C0_CAUSE)
+ jr ra
END(__osGetCause)
diff --git a/lib/ultralib/src/os/getcompare.s b/lib/ultralib/src/os/getcompare.s
index 99c1758..897c793 100644
--- a/lib/ultralib/src/os/getcompare.s
+++ b/lib/ultralib/src/os/getcompare.s
@@ -4,6 +4,6 @@
.text
LEAF(__osGetCompare)
- STAY2(mfc0 v0, C0_COMPARE)
- jr ra
+ MFC0( v0, C0_COMPARE)
+ jr ra
END(__osGetCompare)
diff --git a/lib/ultralib/src/os/getconfig.s b/lib/ultralib/src/os/getconfig.s
index 8165178..9027a26 100644
--- a/lib/ultralib/src/os/getconfig.s
+++ b/lib/ultralib/src/os/getconfig.s
@@ -4,6 +4,6 @@
.text
LEAF(__osGetConfig)
- STAY2(mfc0 v0, C0_CONFIG)
- jr ra
+ MFC0( v0, C0_CONFIG)
+ jr ra
END(__osGetConfig)
diff --git a/lib/ultralib/src/os/getcount.s b/lib/ultralib/src/os/getcount.s
index 28d5a79..9ce72c6 100644
--- a/lib/ultralib/src/os/getcount.s
+++ b/lib/ultralib/src/os/getcount.s
@@ -4,6 +4,6 @@
.text
LEAF(osGetCount)
- STAY2(mfc0 v0, C0_COUNT)
- jr ra
+ MFC0( v0, C0_COUNT)
+ jr ra
END(osGetCount)
diff --git a/lib/ultralib/src/os/getcurrfaultthread.c b/lib/ultralib/src/os/getcurrfaultthread.c
index d7668c2..f8bea0e 100644
--- a/lib/ultralib/src/os/getcurrfaultthread.c
+++ b/lib/ultralib/src/os/getcurrfaultthread.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
-OSThread* __osGetCurrFaultedThread() {
+OSThread* __osGetCurrFaultedThread(void) {
return __osFaultedThread;
}
diff --git a/lib/ultralib/src/os/getfpccsr.s b/lib/ultralib/src/os/getfpccsr.s
index 56837a5..f51b1d0 100644
--- a/lib/ultralib/src/os/getfpccsr.s
+++ b/lib/ultralib/src/os/getfpccsr.s
@@ -4,6 +4,10 @@
.text
LEAF(__osGetFpcCsr)
- STAY2(cfc1 v0, fcr31)
- jr ra
+ CFC1( v0, fcr31)
+ jr ra
+#ifndef MODERN_CC
END(__osGetSR) # @bug: Should be __osGetFpcCsr
+#else
+END(__osGetFpcCsr)
+#endif
diff --git a/lib/ultralib/src/os/getintmask.s b/lib/ultralib/src/os/getintmask.s
index 573eed1..293a57c 100644
--- a/lib/ultralib/src/os/getintmask.s
+++ b/lib/ultralib/src/os/getintmask.s
@@ -7,27 +7,26 @@
.text
.set noreorder
LEAF(osGetIntMask)
- mfc0 v0, C0_SR
- andi v0, v0, OS_IM_CPU
- la t0, __OSGlobalIntMask
- lw t1, 0(t0)
- xor t0, t1, -1
- andi t0, t0, SR_IMASK
- or v0, v0, t0
+ mfc0 v0, C0_SR
+ andi v0, v0, OS_IM_CPU
+ la t0, __OSGlobalIntMask
+ lw t1, 0(t0)
+ xor t0, t1, -1
+ andi t0, t0, SR_IMASK
+ or v0, v0, t0
- lw t1, PHYS_TO_K1(MI_INTR_MASK_REG)
- beqz t1, 1f
+ lw t1, PHYS_TO_K1(MI_INTR_MASK_REG)
+ beqz t1, 1f
+ la t0, __OSGlobalIntMask # this is intentionally a macro in the branch delay slot
- la t0, __OSGlobalIntMask # this is intentionally a macro in the branch delay slot
-
- lw t0, 0(t0)
- srl t0, t0, 0x10
- xor t0, t0, -1
- andi t0, t0, 0x3f
- or t1, t1, t0
+ lw t0, 0(t0)
+ srl t0, t0, 0x10
+ xor t0, t0, -1
+ andi t0, t0, 0x3f
+ or t1, t1, t0
1:
- sll t2, t1, 0x10
- or v0, v0, t2
- jr ra
- nop
+ sll t2, t1, 0x10
+ or v0, v0, t2
+ jr ra
+ nop
END(osGetIntMask)
diff --git a/lib/ultralib/src/os/getnextfaultthread.c b/lib/ultralib/src/os/getnextfaultthread.c
index 44d723a..74c7bdc 100644
--- a/lib/ultralib/src/os/getnextfaultthread.c
+++ b/lib/ultralib/src/os/getnextfaultthread.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
OSThread* __osGetNextFaultedThread(OSThread* lastFault) {
register int saveMask = __osDisableInt();
diff --git a/lib/ultralib/src/os/getsr.s b/lib/ultralib/src/os/getsr.s
index bc9c767..2db9899 100644
--- a/lib/ultralib/src/os/getsr.s
+++ b/lib/ultralib/src/os/getsr.s
@@ -4,6 +4,6 @@
.text
LEAF(__osGetSR)
- STAY2(mfc0 v0, C0_SR)
- jr ra
+ MFC0( v0, C0_SR)
+ jr ra
END(__osGetSR)
diff --git a/lib/ultralib/src/os/getthreadid.c b/lib/ultralib/src/os/getthreadid.c
index 8bbc9f6..c2f39c9 100644
--- a/lib/ultralib/src/os/getthreadid.c
+++ b/lib/ultralib/src/os/getthreadid.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
OSId osGetThreadId(OSThread* thread) {
if (thread == NULL) {
diff --git a/lib/ultralib/src/os/getthreadpri.c b/lib/ultralib/src/os/getthreadpri.c
index 149f3f7..4e842a1 100644
--- a/lib/ultralib/src/os/getthreadpri.c
+++ b/lib/ultralib/src/os/getthreadpri.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
OSPri osGetThreadPri(OSThread* thread) {
if (thread == NULL) {
diff --git a/lib/ultralib/src/os/gettime.c b/lib/ultralib/src/os/gettime.c
index aab4133..38839ba 100644
--- a/lib/ultralib/src/os/gettime.c
+++ b/lib/ultralib/src/os/gettime.c
@@ -1,9 +1,9 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
-#include "../io/viint.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/viint.h"
-OSTime osGetTime() {
+OSTime osGetTime(void) {
u32 tmptime;
u32 elapseCount;
OSTime currentCount;
diff --git a/lib/ultralib/src/os/gettlbasid.s b/lib/ultralib/src/os/gettlbasid.s
index a0702ea..a831c0d 100644
--- a/lib/ultralib/src/os/gettlbasid.s
+++ b/lib/ultralib/src/os/gettlbasid.s
@@ -5,7 +5,7 @@
.set noreorder
.text
LEAF(__osGetTLBASID)
- mfc0 v0, C0_ENTRYHI
- jr ra
- nop
+ mfc0 v0, C0_ENTRYHI
+ jr ra
+ nop
END(__osGetTLBASID)
diff --git a/lib/ultralib/src/os/gettlbhi.s b/lib/ultralib/src/os/gettlbhi.s
index 04c03e9..1d5b1d5 100644
--- a/lib/ultralib/src/os/gettlbhi.s
+++ b/lib/ultralib/src/os/gettlbhi.s
@@ -5,13 +5,13 @@
.set noreorder
.text
LEAF(__osGetTLBHi)
- mtc0 a0, C0_INX
+ mtc0 a0, C0_INX
nop
tlbr
nop
nop
nop
- mfc0 v0, C0_ENTRYHI
- jr ra
- nop
+ mfc0 v0, C0_ENTRYHI
+ jr ra
+ nop
END(__osGetTLBHi)
diff --git a/lib/ultralib/src/os/gettlblo0.s b/lib/ultralib/src/os/gettlblo0.s
index 3b2c2ec..2833a4e 100644
--- a/lib/ultralib/src/os/gettlblo0.s
+++ b/lib/ultralib/src/os/gettlblo0.s
@@ -5,13 +5,13 @@
.set noreorder
.text
LEAF(__osGetTLBLo0)
- mtc0 a0, C0_INX
+ mtc0 a0, C0_INX
nop
tlbr
nop
nop
nop
- mfc0 v0, C0_ENTRYLO0
- jr ra
- nop
+ mfc0 v0, C0_ENTRYLO0
+ jr ra
+ nop
END(__osGetTLBLo0)
diff --git a/lib/ultralib/src/os/gettlblo1.s b/lib/ultralib/src/os/gettlblo1.s
index a24baef..31fdd76 100644
--- a/lib/ultralib/src/os/gettlblo1.s
+++ b/lib/ultralib/src/os/gettlblo1.s
@@ -5,13 +5,13 @@
.set noreorder
.text
LEAF(__osGetTLBLo1)
- mtc0 a0, C0_INX
+ mtc0 a0, C0_INX
nop
tlbr
nop
nop
nop
- mfc0 v0, C0_ENTRYLO1
- jr ra
- nop
+ mfc0 v0, C0_ENTRYLO1
+ jr ra
+ nop
END(__osGetTLBLo1)
diff --git a/lib/ultralib/src/os/gettlbpagemask.s b/lib/ultralib/src/os/gettlbpagemask.s
index de9954a..7761177 100644
--- a/lib/ultralib/src/os/gettlbpagemask.s
+++ b/lib/ultralib/src/os/gettlbpagemask.s
@@ -5,13 +5,13 @@
.set noreorder
.text
LEAF(__osGetTLBPageMask)
- mtc0 a0, C0_INX
+ mtc0 a0, C0_INX
nop
tlbr
nop
nop
nop
- mfc0 v0, C0_PAGEMASK
- jr ra
- nop
+ mfc0 v0, C0_PAGEMASK
+ jr ra
+ nop
END(__osGetTLBPageMask)
diff --git a/lib/ultralib/src/os/getwatchlo.s b/lib/ultralib/src/os/getwatchlo.s
index 4eee9ee..e1460d2 100644
--- a/lib/ultralib/src/os/getwatchlo.s
+++ b/lib/ultralib/src/os/getwatchlo.s
@@ -4,6 +4,6 @@
.text
LEAF(__osGetWatchLo)
- STAY2(mfc0 v0, C0_WATCHLO)
- jr ra
+ MFC0( v0, C0_WATCHLO)
+ jr ra
END(__osGetWatchLo)
diff --git a/lib/ultralib/src/os/initialize.c b/lib/ultralib/src/os/initialize.c
index 89f4b02..b483ad7 100644
--- a/lib/ultralib/src/os/initialize.c
+++ b/lib/ultralib/src/os/initialize.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/os_version.h"
-#include "../io/piint.h"
+#include "PRinternal/piint.h"
typedef struct {
/* 0x0 */ unsigned int inst1;
@@ -70,7 +70,7 @@ void INITIALIZE_FUNC() {
#endif
__osSetSR(__osGetSR() | SR_CU1); // enable fpu
- __osSetFpcCsr(FPCSR_FS | FPCSR_EV); // flush denorm to zero, enable invalid operation
+ __osSetFpcCsr(FPCSR_FS | FPCSR_EV | FPCSR_RM_RN); // flush denorm to zero, enable invalid operation
#if BUILD_VERSION >= VERSION_K
__osSetWatchLo(0x4900000);
#endif
@@ -184,17 +184,17 @@ void INITIALIZE_FUNC() {
}
#if !defined(_FINALROM) && BUILD_VERSION < VERSION_J
-void ptstart() {
+void ptstart(void) {
}
#elif !defined(_FINALROM) && BUILD_VERSION < VERSION_K
-static void ptstart() {
+static void ptstart(void) {
}
#endif
#if BUILD_VERSION >= VERSION_K
-void __osInitialize_autodetect() {
+void __osInitialize_autodetect(void) {
#ifndef _FINALROM
if (__checkHardware_msp()) {
__osInitialize_msp();
diff --git a/lib/ultralib/src/os/initialize_emu.c b/lib/ultralib/src/os/initialize_emu.c
index 7f7dd85..cac68d3 100644
--- a/lib/ultralib/src/os/initialize_emu.c
+++ b/lib/ultralib/src/os/initialize_emu.c
@@ -2,7 +2,7 @@
#include "PR/os_internal.h"
#include "PR/rdb.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
typedef struct {
/* 0x0 */ unsigned int inst1;
diff --git a/lib/ultralib/src/os/initialize_isv.c b/lib/ultralib/src/os/initialize_isv.c
index 50f6379..035511a 100644
--- a/lib/ultralib/src/os/initialize_isv.c
+++ b/lib/ultralib/src/os/initialize_isv.c
@@ -2,9 +2,9 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
typedef struct {
/* 0x0 */ unsigned int inst1;
@@ -27,7 +27,7 @@ void MonitorInitBreak(void);
#define IS64_MAGIC 'IS64'
-__osExceptionVector ramOldVector ALIGNED(8);
+__osExceptionVector ramOldVector ALIGNED(0x8);
u32 gISVFlag;
u16 gISVChk;
u32 gISVDbgPrnAdrs;
diff --git a/lib/ultralib/src/os/initialize_kmc.c b/lib/ultralib/src/os/initialize_kmc.c
index 4952a0d..4328da9 100644
--- a/lib/ultralib/src/os/initialize_kmc.c
+++ b/lib/ultralib/src/os/initialize_kmc.c
@@ -2,7 +2,7 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
typedef struct {
/* 0x0 */ unsigned int inst1;
diff --git a/lib/ultralib/src/os/initialize_msp.c b/lib/ultralib/src/os/initialize_msp.c
index 1f120e1..c86d7e8 100644
--- a/lib/ultralib/src/os/initialize_msp.c
+++ b/lib/ultralib/src/os/initialize_msp.c
@@ -2,7 +2,7 @@
#include "PR/os_internal.h"
#include "PR/rcp.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
typedef struct {
/* 0x0 */ unsigned int inst1;
diff --git a/lib/ultralib/src/os/interrupt.s b/lib/ultralib/src/os/interrupt.s
index 01efe1a..1f4305b 100644
--- a/lib/ultralib/src/os/interrupt.s
+++ b/lib/ultralib/src/os/interrupt.s
@@ -2,51 +2,54 @@
#include "sys/asm.h"
#include "sys/regdef.h"
#include "PR/os_version.h"
+#include "threadasm.h"
.text
.set noreorder
LEAF(__osDisableInt)
#if BUILD_VERSION >= VERSION_J
- la t2, __OSGlobalIntMask
- lw t3, (t2)
- andi t3, 0xFF00
- mfc0 t0, C0_SR
- and t1, t0, ~SR_IE
- mtc0 t1, C0_SR
- andi v0, t0, SR_IE
- lw t0, (t2)
- andi t0, 0xFF00
- beq t0, t3, No_Change_Global_Int
- la t2, __osRunningThread # this is intentionally a macro in the branch delay slot
- lw t1, 280(t2)
- andi t2, t1, 0xFF00
- and t2, t0
- and t1, 0xFFFF00FF
- or t1, t2
- and t1, -2
- mtc0 t1, $12
- nop
- nop
+ la t2, __OSGlobalIntMask
+ lw t3, (t2)
+ andi t3, SR_IMASK
+ mfc0 t0, C0_SR
+ and t1, t0, ~SR_IE
+ mtc0 t1, C0_SR
+ andi v0, t0, SR_IE
+ lw t0, (t2)
+ andi t0, SR_IMASK
+ beq t0, t3, No_Change_Global_Int
+ # @bug this la should be lw, it may never come up in practice as to reach this code
+ # the CPU bits of __OSGlobalIntMask must have changed while this function is running.
+ la t2, __osRunningThread # this is intentionally a macro in the branch delay slot
+ lw t1, THREAD_SR(t2)
+ andi t2, t1, SR_IMASK
+ and t2, t0
+ and t1, ~SR_IMASK
+ or t1, t2
+ and t1, ~SR_IE
+ mtc0 t1, C0_SR
+ nop
+ nop
No_Change_Global_Int:
- jr ra
+ jr ra
nop
#else
- mfc0 t0, C0_SR
- and t1, t0, ~SR_IE
- mtc0 t1, C0_SR
- andi v0, t0, SR_IE
+ mfc0 t0, C0_SR
+ and t1, t0, ~SR_IE
+ mtc0 t1, C0_SR
+ andi v0, t0, SR_IE
nop
- jr ra
+ jr ra
nop
#endif
END(__osDisableInt)
-
+
LEAF(__osRestoreInt)
- mfc0 t0, C0_SR
- or t0, t0, a0
- mtc0 t0, C0_SR
+ mfc0 t0, C0_SR
+ or t0, t0, a0
+ mtc0 t0, C0_SR
nop
nop
- jr ra
+ jr ra
nop
END(__osRestoreInt)
diff --git a/lib/ultralib/src/os/invaldcache.s b/lib/ultralib/src/os/invaldcache.s
index ea6a657..cabad5b 100644
--- a/lib/ultralib/src/os/invaldcache.s
+++ b/lib/ultralib/src/os/invaldcache.s
@@ -3,56 +3,89 @@
#include "sys/regdef.h"
.text
+/**
+ * void osInvalDCache(void* vaddr, s32 nbytes);
+ *
+ * Invalidates the CPU Data Cache for `nbytes` at `vaddr`.
+ * The cache is not automatically synced with physical memory, so cache
+ * lines must be invalidated to ensure old data is not used in place of
+ * newly available data supplied by an external agent in a DMA operation.
+ *
+ * If `vaddr` is not aligned to a cache line boundary, or nbytes is not a
+ * multiple of the data cache line size (16 bytes) a larger region is
+ * invalidated.
+ *
+ * If the amount to invalidate is at least the data cache size (DCACHE_SIZE),
+ * the entire data cache is invalidated.
+ */
LEAF(osInvalDCache)
- blez a1, 3f
- li t3, DCACHE_SIZE
- bgeu a1, t3, 4f
+ /* If the amount to invalidate is less than or equal to 0, return immediately */
+ blez a1, 3f
+ /*
+ * If the amount to invalidate is as large as or larger than
+ * the data cache size, invalidate all
+ */
+ li t3, DCACHE_SIZE
+ bgeu a1, t3, 4f
+ /*
+ * Ensure end address does not wrap around and end up smaller
+ * than the start address
+ */
+ move t0, a0
+ addu t1, a0, a1
+ bgeu t0, t1, 3f
- move t0, a0
- addu t1, a0, a1
- bgeu t0, t1, 3f
+ /* Mask start with cache line */
+ addiu t1, t1, -DCACHE_LINESIZE
+ andi t2, t0, DCACHE_LINEMASK
+ /* If mask is not zero, the start is not cache aligned */
+ beqz t2, 1f
+ /* Subtract mask result to align to cache line */
+ subu t0, t0, t2
+ /* Hit-Writeback-Invalidate unaligned part */
+ CACHE( (C_HWBINV | CACH_PD), (t0))
+ /* If that is all there is to do, return early */
+ bgeu t0, t1, 3f
- addiu t1, t1, -DCACHE_LINESIZE
- andi t2, t0, DCACHE_LINEMASK
- beqz t2, 1f
-
- subu t0, t0, t2
- CACHE((C_HWBINV|CACH_PD), (t0))
- bgeu t0, t1, 3f
-
-
- addiu t0, t0, DCACHE_LINESIZE
+ addiu t0, t0, DCACHE_LINESIZE
1:
- andi t2, t1, DCACHE_LINEMASK
- beqz t2, 2f
+ /* Mask end with cache line */
+ andi t2, t1, DCACHE_LINEMASK
+ /* If mask is not zero, the end is not cache aligned */
+ beqz t2, 2f
+
+ /* Subtract mask result to align to cache line */
+ subu t1, t1, t2
- subu t1, t1, t2
- CACHE((C_HWBINV|CACH_PD), 0x10(t1))
- bltu t1, t0, 3f
+ /* Hit-Writeback-Invalidate unaligned part */
+ CACHE( (C_HWBINV | CACH_PD), DCACHE_LINESIZE(t1))
+ bltu t1, t0, 3f
2:
- CACHE((C_HINV|CACH_PD), (t0))
+ /* Hit-Invalidate */
+ CACHE( (C_HINV | CACH_PD), (t0))
.set noreorder
- bltu t0, t1, 2b
- addiu t0, t0, DCACHE_LINESIZE
+ bltu t0, t1, 2b
+ addiu t0, t0, DCACHE_LINESIZE
.set reorder
3:
- jr ra
+ jr ra
4:
- li t0, KUSIZE
- addu t1, t0, t3
- addiu t1, t1, -DCACHE_LINESIZE
+ li t0, K0BASE
+ addu t1, t0, t3
+ addiu t1, t1, -DCACHE_LINESIZE
5:
- CACHE((C_IINV|CACH_PD), (t0))
+ /* Index-Writeback-Invalidate */
+ CACHE( (C_IINV | CACH_PD), (t0))
.set noreorder
- bltu t0, t1, 5b
- addiu t0, t0, DCACHE_LINESIZE
+ bltu t0, t1, 5b
+ addiu t0, t0, DCACHE_LINESIZE
.set reorder
- jr ra
+ jr ra
END(osInvalDCache)
diff --git a/lib/ultralib/src/os/invalicache.s b/lib/ultralib/src/os/invalicache.s
index f5ceb58..541b387 100644
--- a/lib/ultralib/src/os/invalicache.s
+++ b/lib/ultralib/src/os/invalicache.s
@@ -4,38 +4,48 @@
.text
LEAF(osInvalICache)
- blez a1, 2f
+ /* If the amount to invalidate is less than or equal to 0, return immediately */
+ blez a1, 2f
- li t3, ICACHE_SIZE
- bgeu a1, t3, 3f
+ /*
+ * If the amount to invalidate is as large as or larger than
+ * the instruction cache size, invalidate all
+ */
+ li t3, ICACHE_SIZE
+ bgeu a1, t3, 3f
- move t0, a0
- addu t1, a0, a1
- bgeu t0, t1, 2f
+ /*
+ * ensure end address does not wrap around and end up smaller
+ * than the start address
+ */
+ move t0, a0
+ addu t1, a0, a1
+ bgeu t0, t1, 2f
- addiu t1, t1, -ICACHE_LINESIZE
- andi t2, t0, ICACHE_LINEMASK
- subu t0, t0, t2
+ /* Mask and subtract to align to cache line */
+ addiu t1, t1, -ICACHE_LINESIZE
+ andi t2, t0, ICACHE_LINEMASK
+ subu t0, t0, t2
1:
- CACHE((C_HINV|CACH_PI), (t0))
+ CACHE( (C_HINV | CACH_PI), (t0))
.set noreorder
- bltu t0, t1, 1b
- addiu t0, t0, ICACHE_LINESIZE
+ bltu t0, t1, 1b
+ addiu t0, t0, ICACHE_LINESIZE
.set reorder
2:
- jr ra
+ jr ra
3:
- li t0, KUSIZE
- addu t1, t0, t3
- addiu t1, t1, -ICACHE_LINESIZE
+ li t0, K0BASE
+ addu t1, t0, t3
+ addiu t1, t1, -ICACHE_LINESIZE
4:
- CACHE((C_IINV|CACH_PI), (t0))
+ CACHE( (C_IINV | CACH_PI), (t0))
.set noreorder
- bltu t0, t1, 4b
- addiu t0, t0, ICACHE_LINESIZE
+ bltu t0, t1, 4b
+ addiu t0, t0, ICACHE_LINESIZE
.set reorder
- jr ra
+ jr ra
END(osInvalICache)
diff --git a/lib/ultralib/src/os/jammesg.c b/lib/ultralib/src/os/jammesg.c
index cef68da..4c509e3 100644
--- a/lib/ultralib/src/os/jammesg.c
+++ b/lib/ultralib/src/os/jammesg.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) {
register u32 saveMask;
diff --git a/lib/ultralib/src/os/maptlb.s b/lib/ultralib/src/os/maptlb.s
index 20125b6..be8b784 100644
--- a/lib/ultralib/src/os/maptlb.s
+++ b/lib/ultralib/src/os/maptlb.s
@@ -13,90 +13,90 @@
.set noreorder
LEAF(osMapTLB)
#if defined (_DEBUG) && defined (__sgi)
- bgez index, 1f
- nop
- b 2f
- nop
+ bgez index, 1f
+ nop
+ b 2f
+ nop
1:
- li t0, 0x1F
+ li t0, 0x1F
.set noat
- slt AT, index, t0
- bnez AT, 3f
- nop
+ slt AT, index, t0
+ bnez AT, 3f
+ nop
.set at
2:
- move a2, a0
- li a0, ERR_OSMAPTLB_INDEX
- li a1, 1
- j __osError
- nop
+ move a2, a0
+ li a0, ERR_OSMAPTLB_INDEX
+ li a1, 1
+ j __osError
+ nop
3:
- lw t0, asid
- li t1, -1
+ lw t0, asid
+ li t1, -1
.set noat
- slt AT, t0, t1
- beqz AT, 4f
- nop
+ slt AT, t0, t1
+ beqz AT, 4f
+ nop
.set at
- b 5f
- nop
+ b 5f
+ nop
4:
- li t1, 0xFF
+ li t1, 0xFF
.set noat
- slt AT, t1, t0
- beqz AT, 6f
- nop
+ slt AT, t1, t0
+ beqz AT, 6f
+ nop
.set at
5:
- move a2, t0
- li a0, ERR_OSMAPTLB_ASID
- li a1, 1
- j __osError
- nop
+ move a2, t0
+ li a0, ERR_OSMAPTLB_ASID
+ li a1, 1
+ j __osError
+ nop
6:
.set reorder
#endif
- STAY2(mfc0 t0, C0_ENTRYHI)
- STAY2(mtc0 index, C0_INX)
- STAY2(mtc0 pm, C0_PAGEMASK)
+ MFC0( t0, C0_ENTRYHI)
+ MTC0( index, C0_INX)
+ MTC0( pm, C0_PAGEMASK)
.set noreorder
- lw t1, asid
- beq t1, -1, 7f
- li ta0, TLBLO_G
- li t2, TLBLO_NONCOHRNT | TLBLO_D | TLBLO_V
- b 8f
- or vaddr, vaddr, t1
+ lw t1, asid
+ beq t1, -1, 7f
+ li ta0, TLBLO_G
+ li t2, (TLBLO_NONCOHRNT | TLBLO_D | TLBLO_V)
+ b 8f
+ or vaddr, vaddr, t1
.set reorder
7:
- li t2, TLBLO_NONCOHRNT | TLBLO_D | TLBLO_V | TLBLO_G
+ li t2, (TLBLO_NONCOHRNT | TLBLO_D | TLBLO_V | TLBLO_G)
8:
- STAY2(mtc0 vaddr, C0_ENTRYHI)
- beq evenpaddr, -1, 9f
- #nop
- srl t3, evenpaddr, TLBLO_PFNSHIFT
- or t3, t3, t2
- STAY2(mtc0 t3, C0_ENTRYLO0)
- b 10f
- #nop
+ MTC0( vaddr, C0_ENTRYHI)
+ beq evenpaddr, -1, 9f
+
+ srl t3, evenpaddr, TLBLO_PFNSHIFT
+ or t3, t3, t2
+ MTC0( t3, C0_ENTRYLO0)
+ b 10f
+
9:
- STAY2(mtc0 ta0, C0_ENTRYLO0)
+ MTC0( ta0, C0_ENTRYLO0)
10:
- lw t3, oddpaddr
- beq t3, -1, 11f
- #nop
- srl t3, t3, TLBLO_PFNSHIFT
- or t3, t3, t2
- STAY2(mtc0 t3, C0_ENTRYLO1)
- b 12f
- #nop
+ lw t3, oddpaddr
+ beq t3, -1, 11f
+
+ srl t3, t3, TLBLO_PFNSHIFT
+ or t3, t3, t2
+ MTC0( t3, C0_ENTRYLO1)
+ b 12f
+
11:
- STAY2(mtc0 ta0, C0_ENTRYLO1)
- bne evenpaddr, -1, 12f
- #nop
- li t3, K0BASE
- STAY2(mtc0 t3, C0_ENTRYHI)
+ MTC0( ta0, C0_ENTRYLO1)
+ bne evenpaddr, -1, 12f
+
+ li t3, K0BASE
+ MTC0( t3, C0_ENTRYHI)
12:
.set noreorder
nop
@@ -105,7 +105,6 @@ LEAF(osMapTLB)
nop
nop
nop
- STAY2(mtc0 t0, C0_ENTRYHI)
- jr ra
- #nop
+ MTC0( t0, C0_ENTRYHI)
+ jr ra
END(osMapTLB)
diff --git a/lib/ultralib/src/os/maptlbrdb.s b/lib/ultralib/src/os/maptlbrdb.s
index c004362..1714304 100644
--- a/lib/ultralib/src/os/maptlbrdb.s
+++ b/lib/ultralib/src/os/maptlbrdb.s
@@ -1,30 +1,31 @@
#include "PR/R4300.h"
+#include "PR/rdb.h"
#include "sys/asm.h"
#include "sys/regdef.h"
.text
.set noreorder
LEAF(osMapTLBRdb)
- mfc0 t0, C0_ENTRYHI
- li t1, 31
- mtc0 t1, C0_INX
- mtc0 zero, C0_PAGEMASK /*4k*/
- li t2, TLBLO_UNCACHED | TLBLO_D | TLBLO_V | TLBLO_G
- li t1, K2BASE
- mtc0 t1, C0_ENTRYHI
- li t1, KUSIZE
- srl t3, t1,TLBLO_PFNSHIFT
- or t3, t3,t2
- mtc0 t3, C0_ENTRYLO0
- li t1, TLBLO_G
- mtc0 t1, C0_ENTRYLO1
+ mfc0 t0, C0_ENTRYHI
+ li t1, NTLBENTRIES
+ mtc0 t1, C0_INX
+ mtc0 zero, C0_PAGEMASK /* 4k */
+ li t2, (TLBLO_UNCACHED | TLBLO_D | TLBLO_V | TLBLO_G)
+ li t1, K2BASE
+ mtc0 t1, C0_ENTRYHI
+ li t1, RDB_BASE_VIRTUAL_ADDR
+ srl t3, t1, TLBLO_PFNSHIFT
+ or t3, t3, t2
+ mtc0 t3, C0_ENTRYLO0
+ li t1, TLBLO_G
+ mtc0 t1, C0_ENTRYLO1
nop
tlbwi
nop
nop
nop
nop
- mtc0 t0, C0_ENTRYHI
- jr ra
- nop
+ mtc0 t0, C0_ENTRYHI
+ jr ra
+ nop
END(osMapTLBRdb)
diff --git a/lib/ultralib/src/os/probetlb.s b/lib/ultralib/src/os/probetlb.s
index 237db23..5bd4981 100644
--- a/lib/ultralib/src/os/probetlb.s
+++ b/lib/ultralib/src/os/probetlb.s
@@ -4,51 +4,82 @@
.text
.set noreorder
+/**
+ * u32 __osProbeTLB(void* vaddr);
+ *
+ * Searches the TLB for the physical address associated with
+ * the virtual address `vaddr`.
+ *
+ * Returns the physical address if found, or -1 if not found.
+ */
LEAF(__osProbeTLB)
- mfc0 t0, C0_ENTRYHI
- andi t1, t0, TLBHI_PIDMASK
- and t2, a0, -8192 # This also works: (TLBHI_VPN2MASK << 32) >> 32
- or t1, t1, t2
- mtc0 t1, C0_ENTRYHI
+ /* Set C0_ENTRYHI based on supplied vaddr */
+ mfc0 t0, C0_ENTRYHI
+ andi t1, t0, TLBHI_PIDMASK
+ and t2, a0, (TLBHI_VPN2MASK << 32) >> 32
+ or t1, t1, t2
+ mtc0 t1, C0_ENTRYHI
nop
nop
nop
+ /*
+ * TLB probe, sets C0_INX to a value matching C0_ENTRYHI.
+ * If no match is found the TLBINX_PROBE bit is set to indicate this.
+ */
tlbp
nop
nop
- mfc0 t3, C0_INX
- and t3, t3, TLBINX_PROBE
- bnez t3, 3f
- nop
+ /* Read result */
+ mfc0 t3, C0_INX
+ and t3, t3, TLBINX_PROBE
+ /* Branch if no match was found */
+ bnez t3, 3f
+ nop
+ /*
+ * Read TLB, sets C0_ENTRYHI, C0_ENTRYLO0, C0_ENTRYLO1 and C0_PAGEMASK for the TLB
+ * entry indicated by C0_INX
+ */
tlbr
nop
nop
nop
- mfc0 t3, C0_PAGEMASK
- addi t3, t3, DCACHE_SIZE
- srl t3, t3, 0x1
- and ta0, t3, a0
- bnez ta0, 1f
- addi t3, t3,-1
- mfc0 v0, C0_ENTRYLO0
- b 2f
- nop
+ /* Calculate page size = (page mask + 0x2000) >> 1 */
+ mfc0 t3, C0_PAGEMASK
+ addi t3, t3, 0x2000
+ srl t3, t3, 0x1
+ /* & with vaddr */
+ and ta0, t3, a0
+ /* Select C0_ENTRYLO0 or C0_ENTRYLO1 */
+ bnez ta0, 1f
+ /* make bitmask out of page size */
+ addi t3, t3, -1
+ mfc0 v0, C0_ENTRYLO0
+ b 2f
+ nop
1:
- mfc0 v0, C0_ENTRYLO1
+ mfc0 v0, C0_ENTRYLO1
2:
- andi ta1, v0,TLBLO_V
- beqz ta1, 3f
- nop
- and v0, v0, TLBLO_PFNMASK
- sll v0, v0, TLBLO_PFNSHIFT
- and ta1, a0, t3
- add v0, v0, ta1
- b 4f
- nop
+ /* Check valid bit and branch if not valid */
+ andi ta1, v0, TLBLO_V
+ beqz ta1, 3f
+ nop
+ /* Extract the Page Frame Number from the entry */
+ and v0, v0, TLBLO_PFNMASK
+ sll v0, v0, TLBLO_PFNSHIFT
+ /* Mask vaddr with page size mask */
+ and ta1, a0, t3
+ /* Add masked vaddr to pfn to obtain the physical address */
+ add v0, v0, ta1
+ b 4f
+ nop
3:
- li v0, -1
+ /*
+ * No physical address for the supplied virtual address was found,
+ * return -1
+ */
+ li v0, -1
4:
- mtc0 t0, C0_ENTRYHI
- jr ra
- nop
+ mtc0 t0, C0_ENTRYHI
+ jr ra
+ nop
END(__osProbeTLB)
diff --git a/lib/ultralib/src/os/recvmesg.c b/lib/ultralib/src/os/recvmesg.c
index 043ed21..e8a03f7 100644
--- a/lib/ultralib/src/os/recvmesg.c
+++ b/lib/ultralib/src/os/recvmesg.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags) {
register u32 saveMask;
diff --git a/lib/ultralib/src/os/sendmesg.c b/lib/ultralib/src/os/sendmesg.c
index 19cf3de..8b1a468 100644
--- a/lib/ultralib/src/os/sendmesg.c
+++ b/lib/ultralib/src/os/sendmesg.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags) {
register u32 saveMask;
diff --git a/lib/ultralib/src/os/setcause.s b/lib/ultralib/src/os/setcause.s
index 52e4950..0241918 100644
--- a/lib/ultralib/src/os/setcause.s
+++ b/lib/ultralib/src/os/setcause.s
@@ -4,6 +4,6 @@
.text
LEAF(__osSetCause)
- STAY2(mtc0 a0, C0_CAUSE)
- jr ra
+ MTC0( a0, C0_CAUSE)
+ jr ra
END(__osSetCause)
diff --git a/lib/ultralib/src/os/setcompare.s b/lib/ultralib/src/os/setcompare.s
index dec29a2..7f8969c 100644
--- a/lib/ultralib/src/os/setcompare.s
+++ b/lib/ultralib/src/os/setcompare.s
@@ -4,6 +4,6 @@
.text
LEAF(__osSetCompare)
- STAY2(mtc0 a0, C0_COMPARE)
- jr ra
+ MTC0( a0, C0_COMPARE)
+ jr ra
END(__osSetCompare)
diff --git a/lib/ultralib/src/os/setconfig.s b/lib/ultralib/src/os/setconfig.s
index 4f062bd..8a291ee 100644
--- a/lib/ultralib/src/os/setconfig.s
+++ b/lib/ultralib/src/os/setconfig.s
@@ -4,6 +4,6 @@
.text
LEAF(__osSetConfig)
- STAY2(mtc0 a0, C0_CONFIG)
- jr ra
+ MTC0( a0, C0_CONFIG)
+ jr ra
END(__osSetConfig)
diff --git a/lib/ultralib/src/os/setcount.s b/lib/ultralib/src/os/setcount.s
index f94f1d2..1e5bdb0 100644
--- a/lib/ultralib/src/os/setcount.s
+++ b/lib/ultralib/src/os/setcount.s
@@ -4,6 +4,6 @@
.text
LEAF(__osSetCount)
- STAY2(mtc0 a0, C0_COUNT)
- jr ra
+ MTC0( a0, C0_COUNT)
+ jr ra
END(__osSetCount)
diff --git a/lib/ultralib/src/os/seteventmesg.c b/lib/ultralib/src/os/seteventmesg.c
index f59308c..aa5f669 100644
--- a/lib/ultralib/src/os/seteventmesg.c
+++ b/lib/ultralib/src/os/seteventmesg.c
@@ -1,9 +1,9 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
-__OSEventState __osEventStateTab[OS_NUM_EVENTS] ALIGNED(8);
+__OSEventState __osEventStateTab[OS_NUM_EVENTS] ALIGNED(0x8);
#if BUILD_VERSION >= VERSION_J
u32 __osPreNMI = FALSE;
#endif
diff --git a/lib/ultralib/src/os/setfpccsr.s b/lib/ultralib/src/os/setfpccsr.s
index caeccaf..f36e5b8 100644
--- a/lib/ultralib/src/os/setfpccsr.s
+++ b/lib/ultralib/src/os/setfpccsr.s
@@ -4,7 +4,11 @@
.text
LEAF(__osSetFpcCsr)
- STAY2(cfc1 v0, fcr31)
- STAY2(ctc1 a0, fcr31)
- jr ra
+ CFC1( v0, fcr31)
+ CTC1( a0, fcr31)
+ jr ra
+#ifndef MODERN_CC
END(__osSetSR) # @bug: Should be __osSetFpcCsr
+#else
+END(__osSetFpcCsr)
+#endif
diff --git a/lib/ultralib/src/os/setintmask.s b/lib/ultralib/src/os/setintmask.s
index f19ed17..b9f93b0 100644
--- a/lib/ultralib/src/os/setintmask.s
+++ b/lib/ultralib/src/os/setintmask.s
@@ -10,47 +10,85 @@
.text
.set noreorder
-LEAF(osSetIntMask)
- mfc0 ta0, C0_SR
+/**
+ * OSIntMask osSetIntMask(OSIntMask);
+ *
+ * Sets the interrupt enable mask for the current thread. External interrupts
+ * originating either in the CPU or the RCP may be "masked out" so that they
+ * are not handled. This is sometimes important for critical code sections
+ * that must not be interrupted.
+ * Interrupts that are not enabled in the global interrupt mask __OSGlobalIntMask
+ * cannot be set here. The global interrupt mask is OS-internal and is not
+ * expected to change during runtime.
+ * The returned value is the previous interrupt enable mask so that it can be
+ * restored later.
+ *
+ * @bug Some usage of the global interrupt mask is broken both in here and in the
+ * exception handler routines.
+ * While a thread is running, the C0_SR interrupt enable bits contain the
+ * interrupt enable bits for the current thread masked by the global
+ * interrupt mask. There is an attempt to recover only the original interrupt
+ * enable bits belonging to the thread itself using the operation
+ * (SR | ~__OSGlobalIntMask).
+ * However, this does not work as intended and can cause interrupts to end
+ * up enabled when not intended to be. The same issue is present for the
+ * RCP interrupt enable bits in MI_INTR_MASK_REG.
+ * This does not cause issues in practice as __OSGlobalIntMask is almost always
+ * OS_IM_ALL, so the operation is usually simply (SR | 0).
+ */
+LEAF(osSetIntMask)
+ /* Extract interrupt enable bits from current SR */
+ mfc0 ta0, C0_SR
- andi v0, ta0, OS_IM_CPU
+ andi v0, ta0, OS_IM_CPU
- la t0, __OSGlobalIntMask
- lw t3, 0(t0)
-
- xor t0, t3,-1
- andi t0, t0,(SR_IMASK)
- or v0, v0,t0
+ /* Get value of __OSGlobalIntMask */
+ la t0, __OSGlobalIntMask
+ lw t3, 0(t0)
- lw t2, PHYS_TO_K1(MI_INTR_MASK_REG)
- beqz t2, 1f
- srl t1, t3,0x10
+ /* Bitwise-OR in the disabled CPU bits of __OSGlobalIntMask */
+ xor t0, t3, ~0
+ andi t0, t0, SR_IMASK
+ or v0, v0, t0
- xor t1, t1,-1
- andi t1, t1, MI_INTR_MASK
- or t2, t2,t1
+ /* Fetch MI_INTR_MASK_REG */
+ lw t2, PHYS_TO_K1(MI_INTR_MASK_REG)
+ /* If there are RCP interrupts masked */
+ beqz t2, 1f
+ srl t1, t3, 0x10
+
+ /* Bitwise-OR in the disabled RCP bits of __OSGlobalIntMask */
+ xor t1, t1, ~0
+ andi t1, t1, (RCP_IMASK >> RCP_IMASKSHIFT)
+ or t2, t2, t1
1:
- sll t2, t2,0x10
- or v0, v0,t2
+ /* Shift the RCP bits to not conflict with the CPU bits */
+ sll t2, t2, RCP_IMASKSHIFT
+ /* OR the CPU and RCP bits together */
+ or v0, v0, t2
- and t0, a0, MI_INTR_MASK<<0x10
- and t0, t0,t3
- srl t0, t0,0xf
- lhu t2, __osRcpImTable(t0)
- sw t2, PHYS_TO_K1(MI_INTR_MASK_REG)
-
- andi t0, a0, OS_IM_CPU
- andi t1, t3, SR_IMASK
- and t0, t0,t1
+ /* Extract RCP interrupt enable bits from requested mask and mask with __OSGlobalIntMask */
+ and t0, a0, RCP_IMASK
+ and t0, t0, t3
+ /* Convert to a value for MI_INTR_MASK_REG and set it */
+ srl t0, t0, (RCP_IMASKSHIFT - 1)
+ lhu t2, __osRcpImTable(t0)
+ sw t2, PHYS_TO_K1(MI_INTR_MASK_REG)
- and ta0, ta0, ~SR_IMASK
- or ta0, ta0,t0
+ /* Extract CPU interrupt enable bits from requested mask and mask with __OSGlobalIntMask */
+ andi t0, a0, OS_IM_CPU
+ andi t1, t3, SR_IMASK
+ and t0, t0, t1
- mtc0 ta0, C0_SR
- nop
+ and ta0, ta0, ~SR_IMASK
+ /* Bitwise OR in the remaining bits of SR and set new SR */
+ or ta0, ta0, t0
+
+ mtc0 ta0, C0_SR
nop
- jr ra
nop
+ jr ra
+ nop
END(osSetIntMask)
.rdata
diff --git a/lib/ultralib/src/os/setsr.s b/lib/ultralib/src/os/setsr.s
index d7d98fa..37540fc 100644
--- a/lib/ultralib/src/os/setsr.s
+++ b/lib/ultralib/src/os/setsr.s
@@ -4,7 +4,7 @@
.text
LEAF(__osSetSR)
- STAY2(mtc0 a0, C0_SR)
+ MTC0( a0, C0_SR)
NOP
- jr ra
+ jr ra
END(__osSetSR)
diff --git a/lib/ultralib/src/os/setthreadpri.c b/lib/ultralib/src/os/setthreadpri.c
index d836323..66c6039 100644
--- a/lib/ultralib/src/os/setthreadpri.c
+++ b/lib/ultralib/src/os/setthreadpri.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
void osSetThreadPri(OSThread* t, OSPri pri) {
register u32 saveMask;
diff --git a/lib/ultralib/src/os/settime.c b/lib/ultralib/src/os/settime.c
index b7d14e3..5a974d3 100644
--- a/lib/ultralib/src/os/settime.c
+++ b/lib/ultralib/src/os/settime.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
-#include "../io/viint.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/viint.h"
void osSetTime(OSTime time) {
diff --git a/lib/ultralib/src/os/settimer.c b/lib/ultralib/src/os/settimer.c
index 252f63c..4d2a651 100644
--- a/lib/ultralib/src/os/settimer.c
+++ b/lib/ultralib/src/os/settimer.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
-#include "../io/viint.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/viint.h"
int osSetTimer(OSTimer* t, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) {
OSTime time;
diff --git a/lib/ultralib/src/os/settlbasid.s b/lib/ultralib/src/os/settlbasid.s
index 13a17e8..e7f31fb 100644
--- a/lib/ultralib/src/os/settlbasid.s
+++ b/lib/ultralib/src/os/settlbasid.s
@@ -7,26 +7,26 @@
LEAF(osSetTLBASID)
#if defined (_DEBUG) && defined (__sgi)
.set noreorder
- bgez a0, 1f
- nop
- b 2f
- nop
+ bgez a0, 1f
+ nop
+ b 2f
+ nop
1:
- li t1, 0xFF
+ li t1, 0xFF
.set noat
- slt AT, t1, a0
- beqz AT, 3f
- nop
+ slt AT, t1, a0
+ beqz AT, 3f
+ nop
.set at
2:
- move a2, a0
- li a0, ERR_OSSETTLBASID
- li a1, 1
- j __osError
- nop
+ move a2, a0
+ li a0, ERR_OSSETTLBASID
+ li a1, 1
+ j __osError
+ nop
3:
.set reorder
#endif
- STAY2(mtc0 a0, C0_ENTRYHI)
- jr ra
+ MTC0( a0, C0_ENTRYHI)
+ jr ra
END(osSetTLBASID)
diff --git a/lib/ultralib/src/os/setwatchlo.s b/lib/ultralib/src/os/setwatchlo.s
index 91cc58e..4d54a51 100644
--- a/lib/ultralib/src/os/setwatchlo.s
+++ b/lib/ultralib/src/os/setwatchlo.s
@@ -4,7 +4,7 @@
.text
LEAF(__osSetWatchLo)
- STAY2(mtc0 a0, C0_WATCHLO)
+ MTC0( a0, C0_WATCHLO)
NOP
- jr ra
+ jr ra
END(__osSetWatchLo)
diff --git a/lib/ultralib/src/os/startthread.c b/lib/ultralib/src/os/startthread.c
index 2ce1546..f4ecaaa 100644
--- a/lib/ultralib/src/os/startthread.c
+++ b/lib/ultralib/src/os/startthread.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
void osStartThread(OSThread* t) {
register u32 saveMask = __osDisableInt();
diff --git a/lib/ultralib/src/os/stopthread.c b/lib/ultralib/src/os/stopthread.c
index 9a51652..4047308 100644
--- a/lib/ultralib/src/os/stopthread.c
+++ b/lib/ultralib/src/os/stopthread.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
void osStopThread(OSThread* t) {
register u32 saveMask = __osDisableInt();
diff --git a/lib/ultralib/src/os/stoptimer.c b/lib/ultralib/src/os/stoptimer.c
index b6db1c1..8688d6f 100644
--- a/lib/ultralib/src/os/stoptimer.c
+++ b/lib/ultralib/src/os/stoptimer.c
@@ -1,7 +1,7 @@
#include "PR/os_internal.h"
#include "PR/ultraerror.h"
-#include "osint.h"
-#include "../io/viint.h"
+#include "PRinternal/osint.h"
+#include "PRinternal/viint.h"
int osStopTimer(OSTimer* t) {
register u32 savedMask;
diff --git a/lib/ultralib/src/os/thread.c b/lib/ultralib/src/os/thread.c
index 9a4a141..5a15a61 100644
--- a/lib/ultralib/src/os/thread.c
+++ b/lib/ultralib/src/os/thread.c
@@ -1,11 +1,11 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
struct __osThreadTail __osThreadTail = { NULL, -1 };
OSThread* __osRunQueue = (OSThread*)&__osThreadTail;
OSThread* __osActiveQueue = (OSThread*)&__osThreadTail;
-OSThread* __osRunningThread = { 0 };
-OSThread* __osFaultedThread = { 0 };
+OSThread* __osRunningThread = NULL;
+OSThread* __osFaultedThread = NULL;
void __osDequeueThread(register OSThread** queue, register OSThread* t) {
register OSThread* pred;
diff --git a/lib/ultralib/src/os/timerintr.c b/lib/ultralib/src/os/timerintr.c
index 10dae50..fe92602 100644
--- a/lib/ultralib/src/os/timerintr.c
+++ b/lib/ultralib/src/os/timerintr.c
@@ -1,6 +1,6 @@
-#include "macros.h"
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
OSTime __osCurrentTime;
u32 __osBaseCounter;
@@ -10,7 +10,7 @@ OSTimer __osBaseTimer;
OSTimer* __osTimerList = &__osBaseTimer;
#ifndef _FINALROM
-OSMesgQueue __osProfTimerQ ALIGNED(8);
+OSMesgQueue __osProfTimerQ ALIGNED(0x8);
OSProf* __osProfileList;
OSProf* __osProfileListEnd;
u32 __osProfileOverflowBin;
diff --git a/lib/ultralib/src/os/unmaptlb.s b/lib/ultralib/src/os/unmaptlb.s
index 362fd1e..db7606a 100644
--- a/lib/ultralib/src/os/unmaptlb.s
+++ b/lib/ultralib/src/os/unmaptlb.s
@@ -7,39 +7,39 @@
.set noreorder
LEAF(osUnmapTLB)
#if defined (_DEBUG) && defined (__sgi)
- bgez a0, 1f
- nop
- b 2f
- nop
+ bgez a0, 1f
+ nop
+ b 2f
+ nop
1:
- li t0, 0x1F
+ li t0, 0x1F
.set noat
- slt AT, a0, t0
- bnez AT, 3f
- nop
+ slt AT, a0, t0
+ bnez AT, 3f
+ nop
.set at
2:
- move a2, a0
- li a0, ERR_OSUNMAPTLB
- li a1, 1
- j __osError
- nop
+ move a2, a0
+ li a0, ERR_OSUNMAPTLB
+ li a1, 1
+ j __osError
+ nop
3:
#endif
- mfc0 t0, C0_ENTRYHI
- mtc0 a0, C0_INX
- li t1, K0BASE
- mtc0 t1, C0_ENTRYHI
- mtc0 zero, C0_ENTRYLO0
- mtc0 zero, C0_ENTRYLO1
+ mfc0 t0, C0_ENTRYHI
+ mtc0 a0, C0_INX
+ li t1, K0BASE
+ mtc0 t1, C0_ENTRYHI
+ mtc0 zero, C0_ENTRYLO0
+ mtc0 zero, C0_ENTRYLO1
nop
tlbwi
nop
nop
nop
nop
- mtc0 t0, C0_ENTRYHI
- jr ra
- nop
+ mtc0 t0, C0_ENTRYHI
+ jr ra
+ nop
END(osUnmapTLB)
diff --git a/lib/ultralib/src/os/unmaptlball.s b/lib/ultralib/src/os/unmaptlball.s
index 6d4b264..0e09aa3 100644
--- a/lib/ultralib/src/os/unmaptlball.s
+++ b/lib/ultralib/src/os/unmaptlball.s
@@ -5,22 +5,22 @@
.text
.set noreorder
LEAF(osUnmapTLBAll)
- mfc0 t0, C0_ENTRYHI
- li t1, NTLBENTRIES-1 /* last reserved for rdb */
- li t2, KUSIZE
- mtc0 t2, C0_ENTRYHI
- mtc0 zero, C0_ENTRYLO0
- mtc0 zero, C0_ENTRYLO1
+ mfc0 t0, C0_ENTRYHI
+ li t1, NTLBENTRIES-1 /* last reserved for rdb */
+ li t2, (K0BASE & TLBHI_VPN2MASK)
+ mtc0 t2, C0_ENTRYHI
+ mtc0 zero, C0_ENTRYLO0
+ mtc0 zero, C0_ENTRYLO1
1:
- mtc0 t1, C0_INX
+ mtc0 t1, C0_INX
nop
tlbwi
nop
nop
- addi t1, t1,-1
- bgez t1, 1b
- nop
- mtc0 t0, C0_ENTRYHI
- jr ra
- nop
+ addi t1, t1, -1
+ bgez t1, 1b
+ nop
+ mtc0 t0, C0_ENTRYHI
+ jr ra
+ nop
END(osUnmapTLBAll)
diff --git a/lib/ultralib/src/os/virtualtophysical.c b/lib/ultralib/src/os/virtualtophysical.c
index 553fe68..a275c54 100644
--- a/lib/ultralib/src/os/virtualtophysical.c
+++ b/lib/ultralib/src/os/virtualtophysical.c
@@ -1,6 +1,6 @@
#include "PR/os_internal.h"
#include "PR/R4300.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
u32 osVirtualToPhysical(void* addr) {
if (IS_KSEG0(addr)) {
diff --git a/lib/ultralib/src/os/writebackdcache.s b/lib/ultralib/src/os/writebackdcache.s
index 5f5b485..95d7c6f 100644
--- a/lib/ultralib/src/os/writebackdcache.s
+++ b/lib/ultralib/src/os/writebackdcache.s
@@ -3,33 +3,52 @@
#include "sys/regdef.h"
.text
+/**
+ * void osWritebackDCache(void* vaddr, s32 nbytes);
+ *
+ * Writes back the contents of the data cache to main memory for `nbytes` at `vaddr`.
+ * If `nbytes` is as large as or larger than the data cache size, the entire cache is
+ * written back.
+ */
LEAF(osWritebackDCache)
- blez a1, 2f
- li t3, DCACHE_SIZE
- bgeu a1,t3, 3f
- move t0, a0
- addu t1, a0,a1
- bgeu t0, t1, 2f
- addiu t1, t1, -DCACHE_LINESIZE
- andi t2, t0, DCACHE_LINEMASK
- subu t0, t0,t2
+ /* If the amount to write back is less than or equal to 0, return immediately */
+ blez a1, 2f
+ /*
+ * If the amount to write back is as large as or larger than
+ * the data cache size, write back all
+ */
+ li t3, DCACHE_SIZE
+ bgeu a1, t3, 3f
+ /*
+ * ensure end address does not wrap around and end up smaller
+ * than the start address
+ */
+ move t0, a0
+ addu t1, a0, a1
+ bgeu t0, t1, 2f
+ /* Mask and subtract to align to cache line */
+ addiu t1, t1, -DCACHE_LINESIZE
+ andi t2, t0, DCACHE_LINEMASK
+ subu t0, t0, t2
1:
- .set noreorder
- cache (C_HWB|CACH_PD), (t0)
- bltu t0, t1, 1b
- addiu t0, t0, DCACHE_LINESIZE
- .set reorder
+ .set noreorder
+ cache (C_HWB | CACH_PD), (t0)
+ bltu t0, t1, 1b
+ addiu t0, t0, DCACHE_LINESIZE
+ .set reorder
2:
- jr ra
+ jr ra
+
+/* same as osWritebackDCacheAll in operation */
3:
- li t0, KUSIZE
- addu t1, t0,t3
- addiu t1, t1, -DCACHE_LINESIZE
+ li t0, K0BASE
+ addu t1, t0, t3
+ addiu t1, t1, -DCACHE_LINESIZE
4:
- .set noreorder
- cache (C_IWBINV|CACH_PD), (t0)
- bltu t0, t1, 4b
- addiu t0, t0, DCACHE_LINESIZE
- .set reorder
- jr ra
+ .set noreorder
+ cache (C_IWBINV | CACH_PD), (t0)
+ bltu t0, t1, 4b
+ addiu t0, t0, DCACHE_LINESIZE
+ .set reorder
+ jr ra
END(osWritebackDCache)
diff --git a/lib/ultralib/src/os/writebackdcacheall.s b/lib/ultralib/src/os/writebackdcacheall.s
index ee8df88..d792be8 100644
--- a/lib/ultralib/src/os/writebackdcacheall.s
+++ b/lib/ultralib/src/os/writebackdcacheall.s
@@ -4,15 +4,15 @@
.text
LEAF(osWritebackDCacheAll)
- li t0, KUSIZE
- li t2, DCACHE_SIZE
- addu t1, t0,t2
- addiu t1, t1, -DCACHE_LINESIZE
+ li t0, K0BASE
+ li t2, DCACHE_SIZE
+ addu t1, t0, t2
+ addiu t1, t1, -DCACHE_LINESIZE
1:
.set noreorder
- cache (C_IWBINV | CACH_PD), (t0)
- bltu t0, t1, 1b
- addiu t0, t0, DCACHE_LINESIZE
+ cache (C_IWBINV | CACH_PD), (t0)
+ bltu t0, t1, 1b
+ addiu t0, t0, DCACHE_LINESIZE
.set reorder
- jr ra
+ jr ra
END(osWritebackDCacheAll)
diff --git a/lib/ultralib/src/os/yieldthread.c b/lib/ultralib/src/os/yieldthread.c
index 9a4dafb..976662b 100644
--- a/lib/ultralib/src/os/yieldthread.c
+++ b/lib/ultralib/src/os/yieldthread.c
@@ -1,5 +1,5 @@
#include "PR/os_internal.h"
-#include "osint.h"
+#include "PRinternal/osint.h"
void osYieldThread(void) {
register u32 saveMask = __osDisableInt();
diff --git a/lib/ultralib/src/rg/printregion.c b/lib/ultralib/src/rg/printregion.c
index 6db8f18..947e61c 100644
--- a/lib/ultralib/src/rg/printregion.c
+++ b/lib/ultralib/src/rg/printregion.c
@@ -1,7 +1,7 @@
#include "os_version.h"
#if !defined(_FINALROM) || BUILD_VERSION < VERSION_J
-#include "../os/osint.h"
+#include "PRinternal/osint.h"
#include "PR/rmon.h"
#include "PR/region.h"
diff --git a/lib/ultralib/src/rmon/rmonbrk.c b/lib/ultralib/src/rmon/rmonbrk.c
index 0eb3242..0fe4ba2 100644
--- a/lib/ultralib/src/rmon/rmonbrk.c
+++ b/lib/ultralib/src/rmon/rmonbrk.c
@@ -1,12 +1,12 @@
#ifndef _FINALROM
#include "PR/os_internal.h"
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
-#include "rmonint.h"
+#include "PRinternal/rmonint.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
@@ -35,11 +35,11 @@ typedef struct {
} BREAKINFO;
/* first breakpoint is reserved for implementing single-stepping */
-static BREAKINFO breakpoints[NUM_BREAKPOINTS] ALIGNED(8);
+static BREAKINFO breakpoints[NUM_BREAKPOINTS] ALIGNED(0x8);
/* breakpoint for alternate branch target */
static BREAKINFO altBreak;
-static BREAKINFO RCPbreakpoints[NUM_BREAKPOINTS] ALIGNED(8);
+static BREAKINFO RCPbreakpoints[NUM_BREAKPOINTS] ALIGNED(0x8);
u8 __rmonRcpAtBreak;
diff --git a/lib/ultralib/src/rmon/rmoncmds.c b/lib/ultralib/src/rmon/rmoncmds.c
index 88600a6..d35b853 100644
--- a/lib/ultralib/src/rmon/rmoncmds.c
+++ b/lib/ultralib/src/rmon/rmoncmds.c
@@ -1,9 +1,9 @@
#ifndef _FINALROM
-#include "dbgproto.h"
-#include "rmonint.h"
+#include "PRinternal/dbgproto.h"
+#include "PRinternal/rmonint.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
diff --git a/lib/ultralib/src/rmon/rmonmain.c b/lib/ultralib/src/rmon/rmonmain.c
index 564ac44..b17434c 100644
--- a/lib/ultralib/src/rmon/rmonmain.c
+++ b/lib/ultralib/src/rmon/rmonmain.c
@@ -10,14 +10,14 @@
#ifndef _FINALROM
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
-#include "rmonint.h"
+#include "PRinternal/rmonint.h"
#include "PR/rcp.h"
-#include "sptask.h"
+#include "PR/sptask.h"
#include "PR/rdb.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
diff --git a/lib/ultralib/src/rmon/rmonmem.c b/lib/ultralib/src/rmon/rmonmem.c
index a11051b..3fe11c9 100644
--- a/lib/ultralib/src/rmon/rmonmem.c
+++ b/lib/ultralib/src/rmon/rmonmem.c
@@ -10,21 +10,21 @@
#ifndef _FINALROM
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
-#include "rmonint.h"
+#include "PRinternal/rmonint.h"
#include "PR/rdb.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
#ident "$Revision: 1.4 $"
#endif
-u8 __rmonUtilityBuffer[256] ALIGNED(8);
+u8 __rmonUtilityBuffer[256] ALIGNED(0x8);
void __rmonWriteWordTo(u32* addr, u32 val) {
while (__osSpRawWriteIo((u32)addr, val) != 0) {
diff --git a/lib/ultralib/src/rmon/rmonmisc.c b/lib/ultralib/src/rmon/rmonmisc.c
index a1aa96c..503d422 100644
--- a/lib/ultralib/src/rmon/rmonmisc.c
+++ b/lib/ultralib/src/rmon/rmonmisc.c
@@ -1,11 +1,11 @@
#ifndef _FINALROM
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
#include "PR/sptask.h"
-#include "rmonint.h"
+#include "PRinternal/rmonint.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
@@ -32,12 +32,12 @@ int __rmonSetFault(KKHeader* req) {
return TV_ERROR_NO_ERROR;
}
-OSMesgQueue __rmonMQ ALIGNED(8);
-static OSThread rmonIOThread ALIGNED(8);
-static OSMesg rmonMsgs[8] ALIGNED(8);
-static u64 rmonIOStack[2048] ALIGNED(16);
-static OSMesg rmonPiMsgs[8] ALIGNED(8);
-static OSMesgQueue rmonPiMQ ALIGNED(8);
+OSMesgQueue __rmonMQ ALIGNED(0x8);
+static OSThread rmonIOThread ALIGNED(0x8);
+static OSMesg rmonMsgs[8] ALIGNED(0x8);
+static STACK(rmonIOStack, 0x4000) ALIGNED(0x10);
+static OSMesg rmonPiMsgs[8] ALIGNED(0x8);
+static OSMesgQueue rmonPiMQ ALIGNED(0x8);
void __rmonInit(void) {
osCreateMesgQueue(&__rmonMQ, rmonMsgs, ARRLEN(rmonMsgs));
@@ -45,7 +45,7 @@ void __rmonInit(void) {
osSetEventMesg(OS_EVENT_SP_BREAK, &__rmonMQ, (OSMesg)RMON_MESG_SP_BREAK);
osSetEventMesg(OS_EVENT_FAULT, &__rmonMQ, (OSMesg)RMON_MESG_FAULT);
osSetEventMesg(OS_EVENT_THREADSTATUS, &__rmonMQ, NULL);
- osCreateThread(&rmonIOThread, 0, (void (*)(void*))__rmonIOhandler, NULL, rmonIOStack + ARRLEN(rmonIOStack),
+ osCreateThread(&rmonIOThread, 0, (void (*)(void*))__rmonIOhandler, NULL, STACK_START(rmonIOStack),
OS_PRIORITY_MAX);
osCreatePiManager(OS_PRIORITY_PIMGR, &rmonPiMQ, rmonPiMsgs, ARRLEN(rmonPiMsgs));
osStartThread(&rmonIOThread);
diff --git a/lib/ultralib/src/rmon/rmonrcp.s b/lib/ultralib/src/rmon/rmonrcp.s
index 539f41d..bddc172 100644
--- a/lib/ultralib/src/rmon/rmonrcp.s
+++ b/lib/ultralib/src/rmon/rmonrcp.s
@@ -12,7 +12,7 @@
LEAF(__rmonRCPrunning)
move v0, zero
lw t0, PHYS_TO_K1(SP_STATUS_REG)
- and t0, SP_STATUS_HALT | SP_STATUS_BROKE
+ and t0, (SP_STATUS_HALT | SP_STATUS_BROKE)
bnez t0, isHalted
ori v0, 1
isHalted:
@@ -33,7 +33,7 @@ wait4dma:
awaitIdle:
li a0, PHYS_TO_K1(SP_STATUS_REG)
lw v0, (a0)
- and v0, SP_STATUS_HALT | SP_STATUS_BROKE
+ and v0, (SP_STATUS_HALT | SP_STATUS_BROKE)
beqz v0, awaitIdle
jr ra
END(__rmonIdleRCP)
@@ -41,7 +41,7 @@ END(__rmonIdleRCP)
/* run the rsp in single-step mode to step one instruction */
LEAF(__rmonStepRCP)
li a0, PHYS_TO_K1(SP_STATUS_REG)
- li a1, SP_CLR_INTR_BREAK | SP_SET_SSTEP | SP_CLR_BROKE | SP_CLR_HALT
+ li a1, (SP_CLR_INTR_BREAK | SP_SET_SSTEP | SP_CLR_BROKE | SP_CLR_HALT)
sw a1, (a0)
b awaitIdle
END(__rmonStepRCP)
@@ -52,7 +52,7 @@ LEAF(__rmonRunRCP)
li a1, MI_INTR_MASK_SET_SP
sw a1, (a0)
li a0, PHYS_TO_K1(SP_STATUS_REG)
- li a1, SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT
+ li a1, (SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT)
sw a1, (a0)
jr ra
END(__rmonRunRCP)
diff --git a/lib/ultralib/src/rmon/rmonregs.c b/lib/ultralib/src/rmon/rmonregs.c
index 39cf5b2..7c56413 100644
--- a/lib/ultralib/src/rmon/rmonregs.c
+++ b/lib/ultralib/src/rmon/rmonregs.c
@@ -1,14 +1,14 @@
#ifndef _FINALROM
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
-#include "rmonint.h"
+#include "PRinternal/rmonint.h"
#include "PR/rdb.h"
#include "PR/os_version.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: these come from headers
#if BUILD_VERSION >= VERSION_K
@@ -34,7 +34,7 @@
static u32 RCPpc;
static u32 oldIMEMvalue;
-static u32 DMEMbuffer[4] ALIGNED(8);
+static u32 DMEMbuffer[4] ALIGNED(0x8);
typedef union {
u32 everything;
diff --git a/lib/ultralib/src/rmon/rmonsio.c b/lib/ultralib/src/rmon/rmonsio.c
index 3e45995..8b7c3fb 100644
--- a/lib/ultralib/src/rmon/rmonsio.c
+++ b/lib/ultralib/src/rmon/rmonsio.c
@@ -14,20 +14,20 @@
#include "PR/ultraerror.h"
#include "PR/ultralog.h"
#include "PR/sptask.h"
-#include "dbgproto.h"
-#include "rmonint.h"
+#include "PRinternal/dbgproto.h"
+#include "PRinternal/rmonint.h"
#include "PR/ramrom.h"
#include "PR/rdb.h"
#include "PR/rmon.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
#ident "$Revision: 1.4 $"
#endif
-static OSMesgQueue IOmq ALIGNED(8);
+static OSMesgQueue IOmq ALIGNED(0x8);
static OSMesg IOmsgs;
void* __osRdb_DbgRead_Buf;
diff --git a/lib/ultralib/src/rmon/rmontask.c b/lib/ultralib/src/rmon/rmontask.c
index 25757a7..aa40ea9 100644
--- a/lib/ultralib/src/rmon/rmontask.c
+++ b/lib/ultralib/src/rmon/rmontask.c
@@ -1,12 +1,12 @@
#ifndef _FINALROM
-#include "dbgproto.h"
+#include "PRinternal/dbgproto.h"
#include "PR/os_internal.h"
-#include "rmonint.h"
+#include "PRinternal/rmonint.h"
#include "PR/rcp.h"
#include "PR/sptask.h"
-#include "macros.h"
+#include "PRinternal/macros.h"
// TODO: this comes from a header
#if BUILD_VERSION >= VERSION_J
diff --git a/lib/ultralib/src/vimodes/vimodefpalhaf1.c b/lib/ultralib/src/vimodes/vimodefpalhaf1.c
index 5ad95fa..aeafadf 100644
--- a/lib/ultralib/src/vimodes/vimodefpalhaf1.c
+++ b/lib/ultralib/src/vimodes/vimodefpalhaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodefpalhaf1.c
+ *
+ * FPAL HAF1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalHaf1 = {
OS_VI_FPAL_HAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodefpalhan1.c b/lib/ultralib/src/vimodes/vimodefpalhan1.c
index f29ff4b..1b81094 100644
--- a/lib/ultralib/src/vimodes/vimodefpalhan1.c
+++ b/lib/ultralib/src/vimodes/vimodefpalhan1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodefpalhan1.c
+ *
+ * FPAL HAN1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalHan1 = {
OS_VI_FPAL_HAN1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodefpalhpf1.c b/lib/ultralib/src/vimodes/vimodefpalhpf1.c
index db0eb9d..5250145 100644
--- a/lib/ultralib/src/vimodes/vimodefpalhpf1.c
+++ b/lib/ultralib/src/vimodes/vimodefpalhpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpalhpf1.c
+ *
+ * FPAL HPF1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalHpf1 = {
OS_VI_FPAL_HPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpalhpf2.c b/lib/ultralib/src/vimodes/vimodefpalhpf2.c
index dfd3d92..0fc5313 100644
--- a/lib/ultralib/src/vimodes/vimodefpalhpf2.c
+++ b/lib/ultralib/src/vimodes/vimodefpalhpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpalhpf2.c
+ *
+ * FPAL HPF2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalHpf2 = {
OS_VI_FPAL_HPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpalhpn1.c b/lib/ultralib/src/vimodes/vimodefpalhpn1.c
index 8b665a8..ea16c8a 100644
--- a/lib/ultralib/src/vimodes/vimodefpalhpn1.c
+++ b/lib/ultralib/src/vimodes/vimodefpalhpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpalhpn1.c
+ *
+ * FPAL HPN1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalHpn1 = {
OS_VI_FPAL_HPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpalhpn2.c b/lib/ultralib/src/vimodes/vimodefpalhpn2.c
index c046e97..55d9253 100644
--- a/lib/ultralib/src/vimodes/vimodefpalhpn2.c
+++ b/lib/ultralib/src/vimodes/vimodefpalhpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpalhpn2.c
+ *
+ * FPAL HPN2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalHpn2 = {
OS_VI_FPAL_HPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpallaf1.c b/lib/ultralib/src/vimodes/vimodefpallaf1.c
index e4a8a9e..ad79744 100644
--- a/lib/ultralib/src/vimodes/vimodefpallaf1.c
+++ b/lib/ultralib/src/vimodes/vimodefpallaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodefpallaf1.c
+ *
+ * FPAL LAF1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLaf1 = {
OS_VI_FPAL_LAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodefpallaf2.c b/lib/ultralib/src/vimodes/vimodefpallaf2.c
index 8b3b608..fdc05a0 100644
--- a/lib/ultralib/src/vimodes/vimodefpallaf2.c
+++ b/lib/ultralib/src/vimodes/vimodefpallaf2.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodefpallaf2.c
+ *
+ * FPAL LAF2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLaf2 = {
OS_VI_FPAL_LAF2, // type
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodefpallan1.c b/lib/ultralib/src/vimodes/vimodefpallan1.c
index f190f55..3248ff4 100644
--- a/lib/ultralib/src/vimodes/vimodefpallan1.c
+++ b/lib/ultralib/src/vimodes/vimodefpallan1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpallan1.c
+ *
+ * FPAL LAN1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLan1 = {
OS_VI_FPAL_LAN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpallan2.c b/lib/ultralib/src/vimodes/vimodefpallan2.c
index 13c71e5..d5a60e8 100644
--- a/lib/ultralib/src/vimodes/vimodefpallan2.c
+++ b/lib/ultralib/src/vimodes/vimodefpallan2.c
@@ -1,20 +1,31 @@
+/**
+ * @file vimodefpallan2.c
+ *
+ * FPAL LAN2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLan2 = {
OS_VI_FPAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(625), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(625), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodefpallpf1.c b/lib/ultralib/src/vimodes/vimodefpallpf1.c
index d1c307c..3dca20b 100644
--- a/lib/ultralib/src/vimodes/vimodefpallpf1.c
+++ b/lib/ultralib/src/vimodes/vimodefpallpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpallpf1.c
+ *
+ * FPAL LPF1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLpf1 = {
OS_VI_FPAL_LPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpallpf2.c b/lib/ultralib/src/vimodes/vimodefpallpf2.c
index 385b1df..fa6b368 100644
--- a/lib/ultralib/src/vimodes/vimodefpallpf2.c
+++ b/lib/ultralib/src/vimodes/vimodefpallpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpallpf2.c
+ *
+ * FPAL LPF2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLpf2 = {
OS_VI_FPAL_LPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpallpn1.c b/lib/ultralib/src/vimodes/vimodefpallpn1.c
index 6fbcfe9..18bd211 100644
--- a/lib/ultralib/src/vimodes/vimodefpallpn1.c
+++ b/lib/ultralib/src/vimodes/vimodefpallpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpallpn1.c
+ *
+ * FPAL LPN1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLpn1 = {
OS_VI_FPAL_LPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodefpallpn2.c b/lib/ultralib/src/vimodes/vimodefpallpn2.c
index c852cf9..5ced6e6 100644
--- a/lib/ultralib/src/vimodes/vimodefpallpn2.c
+++ b/lib/ultralib/src/vimodes/vimodefpallpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodefpallpn2.c
+ *
+ * FPAL LPN2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeFpalLpn2 = {
OS_VI_FPAL_LPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodempalhaf1.c b/lib/ultralib/src/vimodes/vimodempalhaf1.c
index c9a74dc..375e469 100644
--- a/lib/ultralib/src/vimodes/vimodempalhaf1.c
+++ b/lib/ultralib/src/vimodes/vimodempalhaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodempalhaf1.c
+ *
+ * MPAL HAF1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalHaf1 = {
OS_VI_MPAL_HAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodempalhan1.c b/lib/ultralib/src/vimodes/vimodempalhan1.c
index 038163b..a47a355 100644
--- a/lib/ultralib/src/vimodes/vimodempalhan1.c
+++ b/lib/ultralib/src/vimodes/vimodempalhan1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodempalhan1.c
+ *
+ * MPAL HAN1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalHan1 = {
OS_VI_MPAL_HAN1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodempalhpf1.c b/lib/ultralib/src/vimodes/vimodempalhpf1.c
index 4bbb0e5..b47add5 100644
--- a/lib/ultralib/src/vimodes/vimodempalhpf1.c
+++ b/lib/ultralib/src/vimodes/vimodempalhpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempalhpf1.c
+ *
+ * MPAL HPF1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalHpf1 = {
OS_VI_MPAL_HPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodempalhpf2.c b/lib/ultralib/src/vimodes/vimodempalhpf2.c
index b2fad3d..3aba7b8 100644
--- a/lib/ultralib/src/vimodes/vimodempalhpf2.c
+++ b/lib/ultralib/src/vimodes/vimodempalhpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempalhpf2.c
+ *
+ * MPAL HPF2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalHpf2 = {
OS_VI_MPAL_HPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodempalhpn1.c b/lib/ultralib/src/vimodes/vimodempalhpn1.c
index 3955a4f..a2069be 100644
--- a/lib/ultralib/src/vimodes/vimodempalhpn1.c
+++ b/lib/ultralib/src/vimodes/vimodempalhpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempalhpn1.c
+ *
+ * MPAL HPN1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalHpn1 = {
OS_VI_MPAL_HPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodempalhpn2.c b/lib/ultralib/src/vimodes/vimodempalhpn2.c
index b4c7a6d..4f26be3 100644
--- a/lib/ultralib/src/vimodes/vimodempalhpn2.c
+++ b/lib/ultralib/src/vimodes/vimodempalhpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempalhpn2.c
+ *
+ * MPAL HPN2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalHpn2 = {
OS_VI_MPAL_HPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodempallaf1.c b/lib/ultralib/src/vimodes/vimodempallaf1.c
index 1369d39..2843390 100644
--- a/lib/ultralib/src/vimodes/vimodempallaf1.c
+++ b/lib/ultralib/src/vimodes/vimodempallaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodempallaf1.c
+ *
+ * MPAL LAF1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLaf1 = {
OS_VI_MPAL_LAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodempallaf2.c b/lib/ultralib/src/vimodes/vimodempallaf2.c
index 0502362..ea10c08 100644
--- a/lib/ultralib/src/vimodes/vimodempallaf2.c
+++ b/lib/ultralib/src/vimodes/vimodempallaf2.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodempallaf2.c
+ *
+ * MPAL LAF2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLaf2 = {
OS_VI_MPAL_LAF2, // type
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(524), // vSync
- HSYNC(3088, 0), // hSync
- LEAP(3100, 3100), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(524), // vSync
+ HSYNC(3088, 0), // hSync
+ LEAP(3100, 3100), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodempallan1.c b/lib/ultralib/src/vimodes/vimodempallan1.c
index a3f4e69..38fee16 100644
--- a/lib/ultralib/src/vimodes/vimodempallan1.c
+++ b/lib/ultralib/src/vimodes/vimodempallan1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempallan1.c
+ *
+ * MPAL LAN1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLan1 = {
OS_VI_MPAL_LAN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodempallan2.c b/lib/ultralib/src/vimodes/vimodempallan2.c
index 65817e7..655d6f9 100644
--- a/lib/ultralib/src/vimodes/vimodempallan2.c
+++ b/lib/ultralib/src/vimodes/vimodempallan2.c
@@ -1,20 +1,31 @@
+/**
+ * @file vimodempallan2.c
+ *
+ * MPAL LAN2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLan2 = {
OS_VI_MPAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 30, 5, 70), // burst
- VSYNC(525), // vSync
- HSYNC(3089, 4), // hSync
- LEAP(3097, 3098), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 30, 5, 70), // burst
+ VSYNC(525), // vSync
+ HSYNC(3089, 4), // hSync
+ LEAP(3097, 3098), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodempallpf1.c b/lib/ultralib/src/vimodes/vimodempallpf1.c
index 7df1655..5f5ecd0 100644
--- a/lib/ultralib/src/vimodes/vimodempallpf1.c
+++ b/lib/ultralib/src/vimodes/vimodempallpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempallpf1.c
+ *
+ * MPAL LPF1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLpf1 = {
OS_VI_MPAL_LPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodempallpf2.c b/lib/ultralib/src/vimodes/vimodempallpf2.c
index 285832e..9e5468f 100644
--- a/lib/ultralib/src/vimodes/vimodempallpf2.c
+++ b/lib/ultralib/src/vimodes/vimodempallpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempallpf2.c
+ *
+ * MPAL LPF2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLpf2 = {
OS_VI_MPAL_LPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodempallpn1.c b/lib/ultralib/src/vimodes/vimodempallpn1.c
index 8914794..45be8d2 100644
--- a/lib/ultralib/src/vimodes/vimodempallpn1.c
+++ b/lib/ultralib/src/vimodes/vimodempallpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempallpn1.c
+ *
+ * MPAL LPN1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLpn1 = {
OS_VI_MPAL_LPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodempallpn2.c b/lib/ultralib/src/vimodes/vimodempallpn2.c
index 40f381c..94e5a89 100644
--- a/lib/ultralib/src/vimodes/vimodempallpn2.c
+++ b/lib/ultralib/src/vimodes/vimodempallpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodempallpn2.c
+ *
+ * MPAL LPN2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeMpalLpn2 = {
OS_VI_MPAL_LPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodentschaf1.c b/lib/ultralib/src/vimodes/vimodentschaf1.c
index e6ad8bc..ccb6427 100644
--- a/lib/ultralib/src/vimodes/vimodentschaf1.c
+++ b/lib/ultralib/src/vimodes/vimodentschaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodentschaf1.c
+ *
+ * NTSC HAF1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscHaf1 = {
OS_VI_NTSC_HAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodentschan1.c b/lib/ultralib/src/vimodes/vimodentschan1.c
index 14711e7..71250c9 100644
--- a/lib/ultralib/src/vimodes/vimodentschan1.c
+++ b/lib/ultralib/src/vimodes/vimodentschan1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodentschan1.c
+ *
+ * NTSC HAN1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscHan1 = {
OS_VI_NTSC_HAN1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodentschpf1.c b/lib/ultralib/src/vimodes/vimodentschpf1.c
index 8f70311..172d4b4 100644
--- a/lib/ultralib/src/vimodes/vimodentschpf1.c
+++ b/lib/ultralib/src/vimodes/vimodentschpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentschpf1.c
+ *
+ * NTSC HPF1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscHpf1 = {
OS_VI_NTSC_HPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodentschpf2.c b/lib/ultralib/src/vimodes/vimodentschpf2.c
index 8533e23..6c3eaa6 100644
--- a/lib/ultralib/src/vimodes/vimodentschpf2.c
+++ b/lib/ultralib/src/vimodes/vimodentschpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentschpf2.c
+ *
+ * NTSC HPF2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscHpf2 = {
OS_VI_NTSC_HPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodentschpn1.c b/lib/ultralib/src/vimodes/vimodentschpn1.c
index f82e277..dbe4119 100644
--- a/lib/ultralib/src/vimodes/vimodentschpn1.c
+++ b/lib/ultralib/src/vimodes/vimodentschpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentschpn1.c
+ *
+ * NTSC HPN1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscHpn1 = {
OS_VI_NTSC_HPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodentschpn2.c b/lib/ultralib/src/vimodes/vimodentschpn2.c
index d1b5974..e4f0f39 100644
--- a/lib/ultralib/src/vimodes/vimodentschpn2.c
+++ b/lib/ultralib/src/vimodes/vimodentschpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentschpn2.c
+ *
+ * NTSC HPN2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscHpn2 = {
OS_VI_NTSC_HPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodentsclaf1.c b/lib/ultralib/src/vimodes/vimodentsclaf1.c
index fe12792..5acf68d 100644
--- a/lib/ultralib/src/vimodes/vimodentsclaf1.c
+++ b/lib/ultralib/src/vimodes/vimodentsclaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodentsclaf1.c
+ *
+ * NTSC LAF1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLaf1 = {
OS_VI_NTSC_LAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodentsclaf2.c b/lib/ultralib/src/vimodes/vimodentsclaf2.c
index acf2c3c..b12acab 100644
--- a/lib/ultralib/src/vimodes/vimodentsclaf2.c
+++ b/lib/ultralib/src/vimodes/vimodentsclaf2.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodentsclaf2.c
+ *
+ * NTSC LAF2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLaf2 = {
OS_VI_NTSC_LAF2, // type
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(524), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(524), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodentsclan1.c b/lib/ultralib/src/vimodes/vimodentsclan1.c
index 0092a00..0327fba 100644
--- a/lib/ultralib/src/vimodes/vimodentsclan1.c
+++ b/lib/ultralib/src/vimodes/vimodentsclan1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentsclan1.c
+ *
+ * NTSC LAN1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLan1 = {
OS_VI_NTSC_LAN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodentsclan2.c b/lib/ultralib/src/vimodes/vimodentsclan2.c
index da2747b..2ed2c83 100644
--- a/lib/ultralib/src/vimodes/vimodentsclan2.c
+++ b/lib/ultralib/src/vimodes/vimodentsclan2.c
@@ -1,20 +1,31 @@
+/**
+ * @file vimodentsclan2.c
+ *
+ * NTSC LAN2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLan2 = {
OS_VI_NTSC_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(57, 34, 5, 62), // burst
- VSYNC(525), // vSync
- HSYNC(3093, 0), // hSync
- LEAP(3093, 3093), // leap
- HSTART(108, 748), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(57, 34, 5, 62), // burst
+ VSYNC(525), // vSync
+ HSYNC(3093, 0), // hSync
+ LEAP(3093, 3093), // leap
+ HSTART(108, 748), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodentsclpf1.c b/lib/ultralib/src/vimodes/vimodentsclpf1.c
index b6bb5e7..388eb03 100644
--- a/lib/ultralib/src/vimodes/vimodentsclpf1.c
+++ b/lib/ultralib/src/vimodes/vimodentsclpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentsclpf1.c
+ *
+ * NTSC LPF1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLpf1 = {
OS_VI_NTSC_LPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodentsclpf2.c b/lib/ultralib/src/vimodes/vimodentsclpf2.c
index f3f82c7..70534cd 100644
--- a/lib/ultralib/src/vimodes/vimodentsclpf2.c
+++ b/lib/ultralib/src/vimodes/vimodentsclpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentsclpf2.c
+ *
+ * NTSC LPF2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLpf2 = {
OS_VI_NTSC_LPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodentsclpn1.c b/lib/ultralib/src/vimodes/vimodentsclpn1.c
index ecc68cb..743ebed 100644
--- a/lib/ultralib/src/vimodes/vimodentsclpn1.c
+++ b/lib/ultralib/src/vimodes/vimodentsclpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentsclpn1.c
+ *
+ * NTSC LPN1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLpn1 = {
OS_VI_NTSC_LPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodentsclpn2.c b/lib/ultralib/src/vimodes/vimodentsclpn2.c
index bce83b8..9f8a400 100644
--- a/lib/ultralib/src/vimodes/vimodentsclpn2.c
+++ b/lib/ultralib/src/vimodes/vimodentsclpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodentsclpn2.c
+ *
+ * NTSC LPN2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModeNtscLpn2 = {
OS_VI_NTSC_LPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodepalhaf1.c b/lib/ultralib/src/vimodes/vimodepalhaf1.c
index 3ff1394..e2ef308 100644
--- a/lib/ultralib/src/vimodes/vimodepalhaf1.c
+++ b/lib/ultralib/src/vimodes/vimodepalhaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodepalhaf1.c
+ *
+ * PAL HAF1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalHaf1 = {
OS_VI_PAL_HAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(640), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(640), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodepalhan1.c b/lib/ultralib/src/vimodes/vimodepalhan1.c
index 3d32ba6..c945252 100644
--- a/lib/ultralib/src/vimodes/vimodepalhan1.c
+++ b/lib/ultralib/src/vimodes/vimodepalhan1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodepalhan1.c
+ *
+ * PAL HAN1 Video Mode
+ *
+ * H = High Resolution
+ * A = Anti-Aliased
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalHan1 = {
OS_VI_PAL_HAN1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(1280), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(1, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(1280), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(1, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodepalhpf1.c b/lib/ultralib/src/vimodes/vimodepalhpf1.c
index bdd0871..5eeeb5f 100644
--- a/lib/ultralib/src/vimodes/vimodepalhpf1.c
+++ b/lib/ultralib/src/vimodes/vimodepalhpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepalhpf1.c
+ *
+ * PAL HPF1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalHpf1 = {
OS_VI_PAL_HPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodepalhpf2.c b/lib/ultralib/src/vimodes/vimodepalhpf2.c
index 565ac4f..e7dc7f7 100644
--- a/lib/ultralib/src/vimodes/vimodepalhpf2.c
+++ b/lib/ultralib/src/vimodes/vimodepalhpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepalhpf2.c
+ *
+ * PAL HPF2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * F = Deflickered Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalHpf2 = {
OS_VI_PAL_HPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodepalhpn1.c b/lib/ultralib/src/vimodes/vimodepalhpn1.c
index a0c1ecc..580756f 100644
--- a/lib/ultralib/src/vimodes/vimodepalhpn1.c
+++ b/lib/ultralib/src/vimodes/vimodepalhpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepalhpn1.c
+ *
+ * PAL HPN1 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalHpn1 = {
OS_VI_PAL_HPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodepalhpn2.c b/lib/ultralib/src/vimodes/vimodepalhpn2.c
index d6e05b8..785344d 100644
--- a/lib/ultralib/src/vimodes/vimodepalhpn2.c
+++ b/lib/ultralib/src/vimodes/vimodepalhpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepalhpn2.c
+ *
+ * PAL HPN2 Video Mode
+ *
+ * H = High Resolution
+ * P = Point Sampled
+ * N = Normal Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalHpn2 = {
OS_VI_PAL_HPN2, // type
diff --git a/lib/ultralib/src/vimodes/vimodepallaf1.c b/lib/ultralib/src/vimodes/vimodepallaf1.c
index 3d03857..c029452 100644
--- a/lib/ultralib/src/vimodes/vimodepallaf1.c
+++ b/lib/ultralib/src/vimodes/vimodepallaf1.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodepallaf1.c
+ *
+ * PAL LAF1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLaf1 = {
OS_VI_PAL_LAF1, // type
{
// comRegs
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodepallaf2.c b/lib/ultralib/src/vimodes/vimodepallaf2.c
index 4fc496c..650db68 100644
--- a/lib/ultralib/src/vimodes/vimodepallaf2.c
+++ b/lib/ultralib/src/vimodes/vimodepallaf2.c
@@ -1,21 +1,31 @@
+/**
+ * @file vimodepallaf2.c
+ *
+ * PAL LAF2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLaf2 = {
OS_VI_PAL_LAF2, // type
{
// comRegs
VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_SERRATE_ON |
- VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(624), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_ANTIALIAS_MODE_0 | VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(624), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodepallan1.c b/lib/ultralib/src/vimodes/vimodepallan1.c
index 22a893c..98f1c4e 100644
--- a/lib/ultralib/src/vimodes/vimodepallan1.c
+++ b/lib/ultralib/src/vimodes/vimodepallan1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepallan1.c
+ *
+ * PAL LAN1 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLan1 = {
OS_VI_PAL_LAN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodepallan2.c b/lib/ultralib/src/vimodes/vimodepallan2.c
index d32360b..6c7d10a 100644
--- a/lib/ultralib/src/vimodes/vimodepallan2.c
+++ b/lib/ultralib/src/vimodes/vimodepallan2.c
@@ -1,20 +1,31 @@
+/**
+ * @file vimodepallan2.c
+ *
+ * PAL LAN2 Video Mode
+ *
+ * L = Low Resolution
+ * A = Anti-Aliased
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLan2 = {
OS_VI_PAL_LAN2, // type
{
// comRegs
- VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_PIXEL_ADV_3, // ctrl
- WIDTH(320), // width
- BURST(58, 30, 4, 69), // burst
- VSYNC(625), // vSync
- HSYNC(3177, 23), // hSync
- LEAP(3183, 3181), // leap
- HSTART(128, 768), // hStart
- SCALE(2, 0), // xScale
- VCURRENT(0), // vCurrent
+ VI_CTRL_TYPE_32 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_0 |
+ VI_CTRL_PIXEL_ADV_3, // ctrl
+ WIDTH(320), // width
+ BURST(58, 30, 4, 69), // burst
+ VSYNC(625), // vSync
+ HSYNC(3177, 23), // hSync
+ LEAP(3183, 3181), // leap
+ HSTART(128, 768), // hStart
+ SCALE(2, 0), // xScale
+ VCURRENT(0), // vCurrent
},
{ // fldRegs
{
diff --git a/lib/ultralib/src/vimodes/vimodepallpf1.c b/lib/ultralib/src/vimodes/vimodepallpf1.c
index 37d68e4..f1cdc8b 100644
--- a/lib/ultralib/src/vimodes/vimodepallpf1.c
+++ b/lib/ultralib/src/vimodes/vimodepallpf1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepallpf1.c
+ *
+ * PAL LPF1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLpf1 = {
OS_VI_PAL_LPF1, // type
diff --git a/lib/ultralib/src/vimodes/vimodepallpf2.c b/lib/ultralib/src/vimodes/vimodepallpf2.c
index c37ebe1..e94ba35 100644
--- a/lib/ultralib/src/vimodes/vimodepallpf2.c
+++ b/lib/ultralib/src/vimodes/vimodepallpf2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepallpf2.c
+ *
+ * PAL LPF2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * F = Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLpf2 = {
OS_VI_PAL_LPF2, // type
diff --git a/lib/ultralib/src/vimodes/vimodepallpn1.c b/lib/ultralib/src/vimodes/vimodepallpn1.c
index eafbe6b..96bc3fe 100644
--- a/lib/ultralib/src/vimodes/vimodepallpn1.c
+++ b/lib/ultralib/src/vimodes/vimodepallpn1.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepallpn1.c
+ *
+ * PAL LPN1 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 1 = 16-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLpn1 = {
OS_VI_PAL_LPN1, // type
diff --git a/lib/ultralib/src/vimodes/vimodepallpn2.c b/lib/ultralib/src/vimodes/vimodepallpn2.c
index 49a26fd..72cf829 100644
--- a/lib/ultralib/src/vimodes/vimodepallpn2.c
+++ b/lib/ultralib/src/vimodes/vimodepallpn2.c
@@ -1,6 +1,16 @@
+/**
+ * @file vimodepallpn2.c
+ *
+ * PAL LPN2 Video Mode
+ *
+ * L = Low Resolution
+ * P = Point Sampled
+ * N = Non-Interlaced
+ * 2 = 32-bit Framebuffer
+ */
#include "PR/os.h"
#include "PR/rcp.h"
-#include "../io/viint.h"
+#include "PRinternal/viint.h"
OSViMode osViModePalLpn2 = {
OS_VI_PAL_LPN2, // type
diff --git a/lib/ultralib/src/voice/voicecheckresult.c b/lib/ultralib/src/voice/voicecheckresult.c
index 5318652..625200e 100644
--- a/lib/ultralib/src/voice/voicecheckresult.c
+++ b/lib/ultralib/src/voice/voicecheckresult.c
@@ -1,5 +1,9 @@
+/**
+ * File: voicecheckresult.c
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicecheckword.c b/lib/ultralib/src/voice/voicecheckword.c
index 05c2a59..9d2e3f8 100644
--- a/lib/ultralib/src/voice/voicecheckword.c
+++ b/lib/ultralib/src/voice/voicecheckword.c
@@ -1,12 +1,18 @@
+/**
+ * File: voicecheckwork.c
+ *
+ * Checks whether or not a word can be registered in the dictionary
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
s32 osVoiceCheckWord(u8* word) {
s32 k;
s32 ret = 0;
u16 sjis;
- u16 old = 0;
+ u16 old = '\0';
for (k = 0; word[k] != 0; k += 2) {
sjis = (word[k] << 8) + word[k + 1];
diff --git a/lib/ultralib/src/voice/voicecleardictionary.c b/lib/ultralib/src/voice/voicecleardictionary.c
index 6ed1464..ed43c1d 100644
--- a/lib/ultralib/src/voice/voicecleardictionary.c
+++ b/lib/ultralib/src/voice/voicecleardictionary.c
@@ -1,5 +1,17 @@
+/**
+ * File: voicecleardictionary.c
+ *
+ * Initializes Voice Recognition System word registration dictionary.
+ *
+ * The dictionary is initialized so that the specified "numWords" can be
+ * registered in the dictionary. 1-255 words can be registered in the dictionary.
+ *
+ * Words cannot be registered with the osVoiceSetWord before the dictionary
+ * is initialized with the osVoiceClearDictionary function
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicecontread2.c b/lib/ultralib/src/voice/voicecontread2.c
index a204ffc..083637a 100644
--- a/lib/ultralib/src/voice/voicecontread2.c
+++ b/lib/ultralib/src/voice/voicecontread2.c
@@ -1,9 +1,14 @@
+/**
+ * File: voicecontread2.c
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
-#include "io/controller_voice.h"
-#include "io/siint.h"
+#include "PRinternal/controller_voice.h"
+#include "PRinternal/siint.h"
#define READ2FORMAT(ptr) ((__OSVoiceRead2Format*)(ptr))
diff --git a/lib/ultralib/src/voice/voicecontread36.c b/lib/ultralib/src/voice/voicecontread36.c
index c537aff..249daad 100644
--- a/lib/ultralib/src/voice/voicecontread36.c
+++ b/lib/ultralib/src/voice/voicecontread36.c
@@ -1,9 +1,14 @@
+/**
+ * File: voicecontread36.c
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
-#include "io/controller_voice.h"
-#include "io/siint.h"
+#include "PRinternal/controller_voice.h"
+#include "PRinternal/siint.h"
#define READ36FORMAT(ptr) ((__OSVoiceRead36Format*)(ptr))
diff --git a/lib/ultralib/src/voice/voicecontrolgain.c b/lib/ultralib/src/voice/voicecontrolgain.c
index 95e9bb2..102b90f 100644
--- a/lib/ultralib/src/voice/voicecontrolgain.c
+++ b/lib/ultralib/src/voice/voicecontrolgain.c
@@ -1,5 +1,12 @@
+/**
+ * File: voicecontrolgain.c
+ *
+ * Adjusts the input gain of the Voice Recognition System
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicecontwrite20.c b/lib/ultralib/src/voice/voicecontwrite20.c
index d1a7446..bb5a3b2 100644
--- a/lib/ultralib/src/voice/voicecontwrite20.c
+++ b/lib/ultralib/src/voice/voicecontwrite20.c
@@ -1,9 +1,14 @@
+/**
+ * File: voicecontwrite20.c
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
-#include "io/controller_voice.h"
-#include "io/siint.h"
+#include "PRinternal/controller_voice.h"
+#include "PRinternal/siint.h"
#define WRITE20FORMAT(ptr) ((__OSVoiceWrite20Format*)(ptr))
diff --git a/lib/ultralib/src/voice/voicecontwrite4.c b/lib/ultralib/src/voice/voicecontwrite4.c
index 6f00586..bcfc1e5 100644
--- a/lib/ultralib/src/voice/voicecontwrite4.c
+++ b/lib/ultralib/src/voice/voicecontwrite4.c
@@ -1,9 +1,14 @@
+/**
+ * File: voicecontwrite4.c
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
-#include "io/controller_voice.h"
-#include "io/siint.h"
+#include "PRinternal/controller_voice.h"
+#include "PRinternal/siint.h"
#define WRITE4FORMAT(ptr) ((__OSVoiceWrite4Format*)(ptr))
diff --git a/lib/ultralib/src/voice/voicecountsyllables.c b/lib/ultralib/src/voice/voicecountsyllables.c
index b0112ef..dbe2847 100644
--- a/lib/ultralib/src/voice/voicecountsyllables.c
+++ b/lib/ultralib/src/voice/voicecountsyllables.c
@@ -1,10 +1,14 @@
+/**
+ * File: voicecountsyllables.c
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
// The VRU can store only 880 semisyllables of words in its dictionary.
// Use this function to determine the semisyllable count before adding a word with osVoiceSetWord,
-// to properly see whether it will fit.
+// to properly see whether it will fit.
void osVoiceCountSyllables(u8* data, u32* syllable) {
s32 k;
diff --git a/lib/ultralib/src/voice/voicecrc.c b/lib/ultralib/src/voice/voicecrc.c
index 56b4838..308862e 100644
--- a/lib/ultralib/src/voice/voicecrc.c
+++ b/lib/ultralib/src/voice/voicecrc.c
@@ -1,10 +1,20 @@
+/**
+ * File: voicecrc.c
+ * Description: CRC check used by the voice files
+ *
+ * For general information about CRC, see the crc.c file
+ */
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#define VOICE_CRC_LENGTH 8
#define VOICE_CRC_GENERATOR 0x85
+/**
+ * This function is essentially the same as __osContDataCrc, but allows for a variable message length, specified by
+ * `numBytes`.
+ */
u8 __osVoiceContDataCrc(u8* data, u32 length) {
s32 temp = 0;
u32 i;
diff --git a/lib/ultralib/src/voice/voicegetreaddata.c b/lib/ultralib/src/voice/voicegetreaddata.c
index d2f5063..c4f8f1b 100644
--- a/lib/ultralib/src/voice/voicegetreaddata.c
+++ b/lib/ultralib/src/voice/voicegetreaddata.c
@@ -1,5 +1,11 @@
+/**
+ * File: voicegetreaddata.c
+ *
+ * Gets voice recognition result from the Voice Recognition System
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicegetstatus.c b/lib/ultralib/src/voice/voicegetstatus.c
index e7328c1..bafa4dd 100644
--- a/lib/ultralib/src/voice/voicegetstatus.c
+++ b/lib/ultralib/src/voice/voicegetstatus.c
@@ -1,8 +1,12 @@
+/**
+ * File: voicegetstatus.c
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
-#include "io/siint.h"
+#include "PRinternal/siint.h"
s32 __osVoiceGetStatus(OSMesgQueue* mq, s32 port, u8* status) {
__OSContRequesFormatShort header;
diff --git a/lib/ultralib/src/voice/voiceinit.c b/lib/ultralib/src/voice/voiceinit.c
index 5074a84..8aacf85 100644
--- a/lib/ultralib/src/voice/voiceinit.c
+++ b/lib/ultralib/src/voice/voiceinit.c
@@ -1,5 +1,12 @@
+/**
+ * File: voiceinit.c
+ *
+ * Initializes Voice Recognition System control structure and hardware
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicemaskdictionary.c b/lib/ultralib/src/voice/voicemaskdictionary.c
index 39db7ac..60d8b18 100644
--- a/lib/ultralib/src/voice/voicemaskdictionary.c
+++ b/lib/ultralib/src/voice/voicemaskdictionary.c
@@ -1,5 +1,12 @@
+/**
+ * File: voicemaskdictionary.c
+ *
+ * Mask words registered in the voice recognition system
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicesetadconverter.c b/lib/ultralib/src/voice/voicesetadconverter.c
index d1c5eb2..f3f8591 100644
--- a/lib/ultralib/src/voice/voicesetadconverter.c
+++ b/lib/ultralib/src/voice/voicesetadconverter.c
@@ -1,9 +1,13 @@
+/**
+ * File: voicesetadconverter.c
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
-#include "io/controller_voice.h"
-#include "io/siint.h"
+#include "PRinternal/controller_voice.h"
+#include "PRinternal/siint.h"
#define SWRITEFORMAT(ptr) ((__OSVoiceSWriteFormat*)(ptr))
diff --git a/lib/ultralib/src/voice/voicesetword.c b/lib/ultralib/src/voice/voicesetword.c
index 7969fae..fb116de 100644
--- a/lib/ultralib/src/voice/voicesetword.c
+++ b/lib/ultralib/src/voice/voicesetword.c
@@ -1,5 +1,12 @@
+/**
+ * File: voicesetword.c
+ *
+ * Registers words to the Voice Recognition System dictionary
+ */
+
+#include "PRinternal/macros.h"
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicestartreaddata.c b/lib/ultralib/src/voice/voicestartreaddata.c
index ea83da0..4381e5b 100644
--- a/lib/ultralib/src/voice/voicestartreaddata.c
+++ b/lib/ultralib/src/voice/voicestartreaddata.c
@@ -1,5 +1,11 @@
+/**
+ * File: voicestartreaddata.c
+ *
+ * Start voice recognition by the Voice Recognition System
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
diff --git a/lib/ultralib/src/voice/voicestopreaddata.c b/lib/ultralib/src/voice/voicestopreaddata.c
index b43eb81..b28143f 100644
--- a/lib/ultralib/src/voice/voicestopreaddata.c
+++ b/lib/ultralib/src/voice/voicestopreaddata.c
@@ -1,5 +1,11 @@
+/**
+ * File: voicestopreaddata.c
+ *
+ * Forcibly stops voice recognition processing by the Voice Recognition System
+ */
+
#include "PR/os_internal.h"
-#include "io/controller.h"
+#include "PRinternal/controller.h"
#include "PR/os_voice.h"
#include "voiceinternal.h"
#include "os_version.h"
diff --git a/src/boot/fault_drawer.c b/src/boot/fault_drawer.c
index 1df4080..a87a715 100644
--- a/src/boot/fault_drawer.c
+++ b/src/boot/fault_drawer.c
@@ -209,7 +209,7 @@ void FaultDrawer_FillScreen(void) {
FaultDrawer_SetCursor(sFaultDrawer.xStart, sFaultDrawer.yStart);
}
-char* FaultDrawer_PrintCallback(char* arg, const char* str, size_t count) {
+void* FaultDrawer_PrintCallback(void* arg, const char* str, size_t count) {
for (; count != 0; count--, str++) {
s32 curXStart;
s32 curXEnd;
@@ -274,7 +274,7 @@ char* FaultDrawer_PrintCallback(char* arg, const char* str, size_t count) {
const char D_8003E280[] = "(null)";
s32 FaultDrawer_VPrintf(const char* fmt, va_list args) {
- return _Printf(FaultDrawer_PrintCallback, (void*)&sFaultDrawer, fmt, args);
+ return _Printf(FaultDrawer_PrintCallback, &sFaultDrawer, fmt, args);
}
s32 FaultDrawer_Printf(const char* fmt, ...) {
diff --git a/src/boot/libc64/aprintf.c b/src/boot/libc64/aprintf.c
index f2bc0c1..8b03219 100644
--- a/src/boot/libc64/aprintf.c
+++ b/src/boot/libc64/aprintf.c
@@ -1,7 +1,7 @@
#include "libc64/aprintf.h"
s32 vaprintf(PrintCallback* func, const char* fmt, va_list ap) {
- return _Printf((outfun*)*func, (char*)func, fmt, ap);
+ return _Printf(*func, func, fmt, ap);
}
s32 aprintf(PrintCallback* func, const char* fmt, ...) {
diff --git a/src/boot/libc64/sprintf.c b/src/boot/libc64/sprintf.c
index 6b05ce9..b8468cc 100644
--- a/src/boot/libc64/sprintf.c
+++ b/src/boot/libc64/sprintf.c
@@ -1,5 +1,5 @@
#include "libc64/sprintf.h"
-#include "lib/ultralib/include/ido/memory.h"
+#include "memory.h"
#include "lib/ultralib/src/libc/xstdio.h"
void* proutPrintf(void* dst, const char* fmt, size_t size) {
@@ -7,7 +7,7 @@ void* proutPrintf(void* dst, const char* fmt, size_t size) {
}
int vsprintf(char* dst, char* fmt, va_list args) {
- s32 ret = _Printf((outfun*)proutPrintf, dst, fmt, args);
+ s32 ret = _Printf(proutPrintf, dst, fmt, args);
if (ret >= 0) {
dst[ret] = '\0';
@@ -19,7 +19,7 @@ int sprintf(char* s, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ret = _Printf((outfun*)proutPrintf, s, fmt, args);
+ ret = _Printf(proutPrintf, s, fmt, args);
if (ret >= 0) {
s[ret] = '\0';
}
diff --git a/src/boot/libu64/gfxprint.c b/src/boot/libu64/gfxprint.c
index ff66e19..78bcf7b 100644
--- a/src/boot/libu64/gfxprint.c
+++ b/src/boot/libu64/gfxprint.c
@@ -185,7 +185,7 @@ void gfxprint_putc(gfxprint* this, char c) {
}
}
-void gfxprint_write(gfxprint* this, const void* buffer, s32 size, s32 n) {
+void gfxprint_write(gfxprint* this, const void* buffer, size_t size, size_t n) {
const char* buf = (const char*)buffer;
s32 i;
@@ -200,14 +200,14 @@ void gfxprint_puts(gfxprint* this, const char* buffer) {
}
}
-void* gfxprint_prout(void* this, const char* buffer, s32 n) {
+void* gfxprint_prout(void* this, const char* buffer, size_t n) {
gfxprint_write(this, buffer, sizeof(char), n);
return this;
}
void gfxprint_init(gfxprint* this) {
gfxprint_clrOpened(this);
- this->proutFunc = (PrintCallback)gfxprint_prout;
+ this->proutFunc = gfxprint_prout;
this->gListp = NULL;
this->positionX = 0;
this->positionY = 0;
diff --git a/src/code/lbrtc/7220C0.c b/src/code/lbrtc/7220C0.c
index efbf300..9a7887c 100644
--- a/src/code/lbrtc/7220C0.c
+++ b/src/code/lbrtc/7220C0.c
@@ -1,6 +1,6 @@
#include "lbrtc.h"
-#include "lib/ultralib/src/io/siint.h"
-#include "lib/ultralib/src/io/controller.h"
+#include "PRinternal/siint.h"
+#include "PRinternal/controller.h"
s32 func_800FE420_jp(OSMesgQueue* mq, OSRTCTime* time) {
u8 status;
diff --git a/src/code/lbrtc/722570.c b/src/code/lbrtc/722570.c
index 010815d..2af92d3 100644
--- a/src/code/lbrtc/722570.c
+++ b/src/code/lbrtc/722570.c
@@ -1,6 +1,6 @@
#include "lbrtc.h"
-#include "lib/ultralib/src/io/siint.h"
-#include "lib/ultralib/src/io/controller.h"
+#include "PRinternal/siint.h"
+#include "PRinternal/controller.h"
OSTimer __contRTCTimer;
OSMesgQueue __contRTCMesgQ;
diff --git a/src/code/lbrtc/722AB0.c b/src/code/lbrtc/722AB0.c
index 0c1ed89..9199271 100644
--- a/src/code/lbrtc/722AB0.c
+++ b/src/code/lbrtc/722AB0.c
@@ -1,7 +1,7 @@
#include "lbrtc.h"
#include "lb_rtc.h"
-#include "lib/ultralib/src/io/siint.h"
-#include "lib/ultralib/src/io/controller.h"
+#include "PRinternal/siint.h"
+#include "PRinternal/controller.h"
u16 total_days_internal[2][lbRTC_MONTHS_MAX + 1] = {
// Standard year
diff --git a/src/code/m_demo.c b/src/code/m_demo.c
index a317b24..97e5309 100644
--- a/src/code/m_demo.c
+++ b/src/code/m_demo.c
@@ -3,7 +3,7 @@
#include "overlays/actors/player_actor/m_player.h"
#include "m_msg_main.h"
#include "m_player_lib.h"
-#include "lib/ultralib/include/ido/memory.h"
+#include "memory.h"
#include "libc/math.h"
#include "m_field_info.h"
#include "audio.h"
diff --git a/tools/format.py b/tools/format.py
index 92490ca..be11306 100755
--- a/tools/format.py
+++ b/tools/format.py
@@ -29,7 +29,7 @@ APPLY_OPTS = ""
# Compiler options used with Clang-Tidy
# Normal warnings are disabled with -Wno-everything to focus only on tidying
-INCLUDES = "-Iinclude -Isrc -Ibuild -I. -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ibin/jp -Ibin/cn"
+INCLUDES = "-Iinclude -Isrc -Ibuild -I. -Ilib/ultralib/include -Ilib/ultralib/include/PR -Ilib/ultralib/include/compiler/ido -Ibin/jp -Ibin/cn"
DEFINES = "-D_LANGUAGE_C -DNON_MATCHING -D_MIPS_SZLONG=32"
COMPILER_OPTS = f"-fno-builtin -std=gnu90 -m32 -Wno-everything {INCLUDES} {DEFINES}"
diff --git a/tools/m2ctx.py b/tools/m2ctx.py
index 6de20af..34584a4 100755
--- a/tools/m2ctx.py
+++ b/tools/m2ctx.py
@@ -18,7 +18,7 @@ CPP_FLAGS = [
"-Ibuild",
"-Ilib/ultralib/include",
"-Ilib/ultralib/include/PR",
- "-Ilib/ultralib/include/ido",
+ "-Ilib/ultralib/include/compiler/ido",
"-D_LANGUAGE_C",
"-DF3DEX_GBI_2",
diff --git a/tools/warnings_count/warnings_lib_current.txt b/tools/warnings_count/warnings_lib_current.txt
index 517b490..6df8e3e 100644
--- a/tools/warnings_count/warnings_lib_current.txt
+++ b/tools/warnings_count/warnings_lib_current.txt
@@ -2,5 +2,5 @@ cc: Warning: -mips3 should not be used for ucode 32-bit compiles
cc: Warning: -mips3 should not be used for ucode 32-bit compiles
cc: Warning: -mips3 should not be used for ucode 32-bit compiles
cc: Warning: -mips3 should not be used for ucode 32-bit compiles
-as1: Warning: getintmask.s, line 21: Macro instruction used in branch delay slot
-as1: Warning: interrupt.s, line 20: Macro instruction used in branch delay slot
+as1: Warning: getintmask.s, line 20: Macro instruction used in branch delay slot
+as1: Warning: interrupt.s, line 23: Macro instruction used in branch delay slot