├── .clang-format
├── .github
└── workflows
│ ├── linux.yml
│ ├── mac.yml
│ ├── main.yml
│ ├── switch.yml
│ └── windows.yml
├── .gitignore
├── .gitmodules
├── .vscode
├── c_cpp_properties.json
└── settings.json
├── CMakeLists.txt
├── ExecutableResource.h
├── Info.plist
├── LICENSE.md
├── README.md
├── Resource.rc
├── Starship.desktop
├── assets
└── yaml
│ ├── cn
│ └── rev1
│ │ └── ast_audio.yaml
│ ├── eu
│ └── rev0
│ │ └── ast_audio.yaml
│ ├── jp
│ └── rev0
│ │ └── ast_audio.yaml
│ └── us
│ ├── rev0
│ ├── ast_7_ti_1.yaml
│ ├── ast_7_ti_2.yaml
│ ├── ast_8_ti.yaml
│ ├── ast_9_ti.yaml
│ ├── ast_A_ti.yaml
│ ├── ast_allies.yaml
│ ├── ast_andross.yaml
│ ├── ast_aquas.yaml
│ ├── ast_area_6.yaml
│ ├── ast_arwing.yaml
│ ├── ast_audio.yaml
│ ├── ast_bg_planet.yaml
│ ├── ast_bg_space.yaml
│ ├── ast_blue_marine.yaml
│ ├── ast_bolse.yaml
│ ├── ast_common.yaml
│ ├── ast_corneria.yaml
│ ├── ast_ending.yaml
│ ├── ast_ending_award_back.yaml
│ ├── ast_ending_award_front.yaml
│ ├── ast_ending_expert.yaml
│ ├── ast_enmy_planet.yaml
│ ├── ast_enmy_space.yaml
│ ├── ast_font_3d.yaml
│ ├── ast_fortuna.yaml
│ ├── ast_great_fox.yaml
│ ├── ast_katina.yaml
│ ├── ast_landmaster.yaml
│ ├── ast_logo.yml
│ ├── ast_macbeth.yaml
│ ├── ast_map.yaml
│ ├── ast_meteo.yaml
│ ├── ast_option.yaml
│ ├── ast_radio.yaml
│ ├── ast_sector_x.yaml
│ ├── ast_sector_y.yaml
│ ├── ast_sector_z.yaml
│ ├── ast_solar.yaml
│ ├── ast_star_wolf.yaml
│ ├── ast_text.yaml
│ ├── ast_titania.yaml
│ ├── ast_title.yaml
│ ├── ast_training.yaml
│ ├── ast_ve1_boss.yaml
│ ├── ast_venom_1.yaml
│ ├── ast_venom_2.yaml
│ ├── ast_versus.yaml
│ ├── ast_vs_menu.yaml
│ ├── ast_warp_zone.yaml
│ └── ast_zoness.yaml
│ └── rev1
│ ├── ast_7_ti_1.yaml
│ ├── ast_7_ti_2.yaml
│ ├── ast_8_ti.yaml
│ ├── ast_9_ti.yaml
│ ├── ast_A_ti.yaml
│ ├── ast_allies.yaml
│ ├── ast_andross.yaml
│ ├── ast_aquas.yaml
│ ├── ast_area_6.yaml
│ ├── ast_arwing.yaml
│ ├── ast_audio.yaml
│ ├── ast_bg_planet.yaml
│ ├── ast_bg_space.yaml
│ ├── ast_blue_marine.yaml
│ ├── ast_bolse.yaml
│ ├── ast_common.yaml
│ ├── ast_corneria.yaml
│ ├── ast_ending.yaml
│ ├── ast_ending_award_back.yaml
│ ├── ast_ending_award_front.yaml
│ ├── ast_ending_expert.yaml
│ ├── ast_enmy_planet.yaml
│ ├── ast_enmy_space.yaml
│ ├── ast_font_3d.yaml
│ ├── ast_fortuna.yaml
│ ├── ast_great_fox.yaml
│ ├── ast_katina.yaml
│ ├── ast_landmaster.yaml
│ ├── ast_logo.yml
│ ├── ast_macbeth.yaml
│ ├── ast_map.yaml
│ ├── ast_meteo.yaml
│ ├── ast_option.yaml
│ ├── ast_radio.yaml
│ ├── ast_sector_x.yaml
│ ├── ast_sector_y.yaml
│ ├── ast_sector_z.yaml
│ ├── ast_solar.yaml
│ ├── ast_star_wolf.yaml
│ ├── ast_text.yaml
│ ├── ast_titania.yaml
│ ├── ast_title.yaml
│ ├── ast_training.yaml
│ ├── ast_ve1_boss.yaml
│ ├── ast_venom_1.yaml
│ ├── ast_venom_2.yaml
│ ├── ast_versus.yaml
│ ├── ast_vs_menu.yaml
│ ├── ast_warp_zone.yaml
│ └── ast_zoness.yaml
├── cmake
├── automate-vcpkg.cmake
├── configure-packaging.cmake
├── ios.toolchain.cmake
├── modules
│ ├── FindOgg.cmake
│ ├── FindPulseAudio.cmake
│ ├── FindVorbis.cmake
│ ├── FindlibUsb.cmake
│ └── Findudev.cmake
├── packaging.cmake
└── toolchain-x86_64-w64-mingw32.cmake
├── config.yml
├── docs
├── BUILDING.md
├── poweredbylus.darkmode.png
└── poweredbylus.lightmode.png
├── include
├── PR
│ ├── abi.h
│ ├── assert.h
│ ├── controller.h
│ ├── gs2dex.h
│ ├── gt.h
│ ├── gu.h
│ ├── guint.h
│ ├── libaudio.h
│ ├── mbi.h
│ ├── primage.h
│ ├── ramrom.h
│ ├── rdb.h
│ ├── region.h
│ ├── rmon.h
│ ├── sched.h
│ ├── sp.h
│ ├── sptask.h
│ ├── ucode.h
│ ├── ultraerror.h
│ ├── ultralog.h
│ ├── uportals.h
│ ├── viint.h
│ └── xstdio.h
├── alignment.h
├── assets
│ ├── ast_7_ti_1.h
│ ├── ast_7_ti_2.h
│ ├── ast_8_ti.h
│ ├── ast_9_ti.h
│ ├── ast_A_ti.h
│ ├── ast_allies.h
│ ├── ast_andross.h
│ ├── ast_aquas.h
│ ├── ast_area_6.h
│ ├── ast_arwing.h
│ ├── ast_audio.h
│ ├── ast_bg_planet.h
│ ├── ast_bg_space.h
│ ├── ast_blue_marine.h
│ ├── ast_bolse.h
│ ├── ast_common.h
│ ├── ast_corneria.h
│ ├── ast_ending.h
│ ├── ast_ending_award_back.h
│ ├── ast_ending_award_front.h
│ ├── ast_ending_expert.h
│ ├── ast_enmy_planet.h
│ ├── ast_enmy_space.h
│ ├── ast_font_3d.h
│ ├── ast_fortuna.h
│ ├── ast_great_fox.h
│ ├── ast_katina.h
│ ├── ast_landmaster.h
│ ├── ast_logo.h
│ ├── ast_macbeth.h
│ ├── ast_map.h
│ ├── ast_meteo.h
│ ├── ast_option.h
│ ├── ast_radio.h
│ ├── ast_sector_x.h
│ ├── ast_sector_y.h
│ ├── ast_sector_z.h
│ ├── ast_solar.h
│ ├── ast_star_wolf.h
│ ├── ast_text.h
│ ├── ast_titania.h
│ ├── ast_title.h
│ ├── ast_training.h
│ ├── ast_ve1_boss.h
│ ├── ast_venom_1.h
│ ├── ast_venom_2.h
│ ├── ast_versus.h
│ ├── ast_vs_menu.h
│ ├── ast_warp_zone.h
│ ├── ast_zoness.h
│ ├── namefix.py
│ └── rcp_setup.h
├── audioseq_cmd.h
├── audiothread_cmd.h
├── bgm.h
├── buffers.h
├── common.h
├── dbgdefs.h
├── dbgproto.h
├── debug.h
├── fox_co.h
├── fox_hud.h
├── fox_map.h
├── fox_option.h
├── fox_record.h
├── functions.h
├── gfx.h
├── gfx_dimensions.h
├── global.h
├── hit64.h
├── hud.h
├── i1.h
├── i2.h
├── i3.h
├── i4.h
├── i5.h
├── i6.h
├── libc
│ ├── math.h
│ ├── stdarg.h
│ ├── stdbool.h
│ ├── stddef.h
│ ├── stdint.h
│ ├── stdlib.h
│ └── string.h
├── libultra
│ ├── sys
│ │ ├── u64driver.h
│ │ └── u64gio.h
│ ├── tinymon.h
│ └── ultrahost.h
├── macro.inc
├── macros.h
├── mods.h
├── osint.h
├── piint.h
├── portable-file-dialogs.h
├── prevent_bss_reordering.h
├── prevent_bss_reordering2.h
├── prevent_bss_reordering3.h
├── prevent_context_reordering.h
├── rmonint.h
├── sf64_tagging.h
├── sf64audio_external.h
├── sf64audio_provisional.h
├── sf64context.h
├── sf64dma.h
├── sf64event.h
├── sf64level.h
├── sf64math.h
├── sf64mesg.h
├── sf64object.h
├── sf64player.h
├── sf64save.h
├── sf64thread.h
├── sfx.h
├── siint.h
├── sys.h
└── variables.h
├── linker_scripts
└── jp
│ └── rev0
│ └── symbol_addrs_overlays.txt
├── logo.png
├── nx-logo.jpg
├── port
├── assets
│ └── textures
│ │ └── hud
│ │ ├── sBoostGaugeArrow0
│ │ ├── sBoostGaugeArrow1
│ │ ├── sBoostGaugeArrow2
│ │ ├── sBoostGaugeArrow3
│ │ ├── sBoostGaugeArrow4
│ │ ├── sBoostGaugeArrow5
│ │ ├── sBoostGaugeArrow6
│ │ ├── sBoostGaugeArrow7
│ │ └── sBoostGaugeArrow8
└── shaders
│ ├── directx
│ └── default.shader.hlsl
│ ├── metal
│ └── default.shader.metal
│ └── opengl
│ ├── default.shader.fs
│ └── default.shader.vs
├── properties.h.in
├── src
├── audio
│ ├── audio_context.c
│ ├── audio_effects.c
│ ├── audio_general.c
│ ├── audio_heap.c
│ ├── audio_load.c
│ ├── audio_playback.c
│ ├── audio_seqplayer.c
│ ├── audio_synthesis.c
│ ├── audio_thread.c
│ ├── mixer.c
│ ├── mixer.h
│ ├── note_data.c
│ └── wave_samples.c
├── buffers.c
├── dmatable.c
├── driverominit.c
├── engine
│ ├── fox_360.c
│ ├── fox_beam.c
│ ├── fox_bg.c
│ ├── fox_blur.c
│ ├── fox_boss.c
│ ├── fox_col1.c
│ ├── fox_col2.c
│ ├── fox_colheaders.c
│ ├── fox_context.c
│ ├── fox_demo.c
│ ├── fox_display.c
│ ├── fox_edata.c
│ ├── fox_edata_info.c
│ ├── fox_edisplay.c
│ ├── fox_effect.c
│ ├── fox_enmy.c
│ ├── fox_enmy2.c
│ ├── fox_fade.c
│ ├── fox_game.c
│ ├── fox_hud.c
│ ├── fox_load.c
│ ├── fox_load_inits.c
│ ├── fox_message.c
│ ├── fox_msg_palette.c
│ ├── fox_pause.c
│ ├── fox_play.c
│ ├── fox_radio.c
│ ├── fox_rcp.c
│ ├── fox_rcp_init.c
│ ├── fox_rcp_setup.c
│ ├── fox_reset.c
│ ├── fox_save.c
│ ├── fox_shapes.c
│ ├── fox_std_lib.c
│ ├── fox_tank.c
│ ├── fox_versus.c
│ ├── fox_wheels.c
│ ├── guPerspectiveF.c
│ ├── lookat.c
│ └── water_effect.inc
├── libc_math64.c
├── libc_sprintf.c
├── libultra
│ ├── debug
│ │ └── kdebugserver.c
│ ├── gcc_fix
│ │ ├── __floatundisf.c
│ │ └── sqrtf.c.inc
│ ├── gu
│ │ ├── cosf.c
│ │ ├── lookat.c
│ │ ├── mtxutil.c
│ │ ├── ortho.c
│ │ ├── perspective.c
│ │ ├── sinf.c
│ │ └── sqrtf.c
│ ├── host
│ │ └── readhost.c
│ ├── io
│ │ ├── ai.c
│ │ ├── aigetlen.c
│ │ ├── aisetfreq.c
│ │ ├── aisetnextbuf.c
│ │ ├── cartrominit.c
│ │ ├── conteepprobe.c
│ │ ├── conteepread.c
│ │ ├── conteepwrite.c
│ │ ├── contquery.c
│ │ ├── contramread.c
│ │ ├── contramwrite.c
│ │ ├── contreaddata.c
│ │ ├── controller.c
│ │ ├── crc.c
│ │ ├── devmgr.c
│ │ ├── dpsetstat.c
│ │ ├── epidma.c
│ │ ├── epirawdma.c
│ │ ├── epirawread.c
│ │ ├── epirawwrite.c
│ │ ├── leodiskinit.c
│ │ ├── leointerrupt.c
│ │ ├── motor.c
│ │ ├── pfsgetstatus.c
│ │ ├── pfsisplug.c
│ │ ├── piacs.c
│ │ ├── pidma.c
│ │ ├── pigetcmdq.c
│ │ ├── pimgr.c
│ │ ├── pirawdma.c
│ │ ├── pirawread.c
│ │ ├── si.c
│ │ ├── siacs.c
│ │ ├── sirawdma.c
│ │ ├── sirawread.c
│ │ ├── sirawwrite.c
│ │ ├── sp.c
│ │ ├── spgetstat.c
│ │ ├── sprawdma.c
│ │ ├── sprawread.c
│ │ ├── sprawwrite.c
│ │ ├── spsetpc.c
│ │ ├── spsetstat.c
│ │ ├── sptask.c
│ │ ├── sptaskyield.c
│ │ ├── sptaskyielded.c
│ │ ├── vi.c
│ │ ├── viblack.c
│ │ ├── vigetcurrcontext.c
│ │ ├── vimgr.c
│ │ ├── virepeatline.c
│ │ ├── visetevent.c
│ │ ├── visetmode.c
│ │ ├── visetspecial.c
│ │ ├── viswapbuf.c
│ │ └── viswapcontext.c
│ ├── libc
│ │ ├── ldiv.c
│ │ ├── ll.c
│ │ ├── string.c
│ │ ├── xldtob.c
│ │ ├── xlitob.c
│ │ └── xprintf.c
│ ├── os
│ │ ├── createmesgqueue.c
│ │ ├── createthread.c
│ │ ├── destroythread.c
│ │ ├── getactivequeue.c
│ │ ├── getthreadpri.c
│ │ ├── gettime.c
│ │ ├── initialize.c
│ │ ├── initrdb.c
│ │ ├── jammesg.c
│ │ ├── rdbsend.c
│ │ ├── recvmesg.c
│ │ ├── resetglobalintmask.c
│ │ ├── sendmesg.c
│ │ ├── seteventmesg.c
│ │ ├── setglobalintmask.c
│ │ ├── setthreadpri.c
│ │ ├── settime.c
│ │ ├── settimer.c
│ │ ├── startthread.c
│ │ ├── stopthread.c
│ │ ├── thread.c
│ │ ├── timerintr.c
│ │ ├── virtualtophysical.c
│ │ └── yieldthread.c
│ ├── rmon
│ │ ├── rmonbrk.c
│ │ ├── rmoncmds.c
│ │ ├── rmonmain.c
│ │ ├── rmonmem.c
│ │ ├── rmonmisc.c
│ │ ├── rmonregs.c
│ │ ├── rmonsio.c
│ │ └── rmontask.c
│ └── vimodes
│ │ ├── vimodempallan1.c
│ │ ├── vimodentsclan1.c
│ │ └── vimodepallan1.c
├── mods
│ ├── bosskiller.c
│ ├── fpscounter.c
│ ├── hit64.c
│ ├── levelselect.c
│ ├── object_ram.c
│ ├── object_ram.h
│ ├── sfxjukebox.c
│ ├── sfxjukebox2.c
│ └── spawner.c
├── overlays
│ ├── ovl_ending
│ │ ├── fox_end1.c
│ │ ├── fox_end2.c
│ │ └── fox_end2_data.c
│ ├── ovl_i1
│ │ ├── fox_co.c
│ │ ├── fox_i1.c
│ │ ├── fox_tr.c
│ │ ├── fox_tr360.c
│ │ └── fox_ve1.c
│ ├── ovl_i2
│ │ ├── fox_i2.c
│ │ ├── fox_me.c
│ │ └── fox_sx.c
│ ├── ovl_i3
│ │ ├── fox_a6.c
│ │ ├── fox_aq.c
│ │ ├── fox_i3.c
│ │ ├── fox_so.c
│ │ └── fox_zo.c
│ ├── ovl_i4
│ │ ├── fox_bo.c
│ │ ├── fox_fo.c
│ │ ├── fox_i4.c
│ │ ├── fox_ka.c
│ │ └── fox_sz.c
│ ├── ovl_i5
│ │ ├── fox_ground.c
│ │ ├── fox_i5.c
│ │ ├── fox_ma.c
│ │ ├── fox_ti.c
│ │ └── fox_ti_cs.c
│ ├── ovl_i6
│ │ ├── fox_andross.c
│ │ ├── fox_i6.c
│ │ ├── fox_sy.c
│ │ ├── fox_turret.c
│ │ └── fox_ve2.c
│ ├── ovl_menu
│ │ ├── fox_i_menu.c
│ │ ├── fox_map.c
│ │ ├── fox_option.c
│ │ ├── fox_title.c
│ │ └── fox_title.h
│ └── ovl_unused
│ │ └── fox_unused.c
├── port
│ ├── Engine.cpp
│ ├── Engine.h
│ ├── GBIMiddleware.cpp
│ ├── Game.cpp
│ ├── audio
│ │ └── GameAudio.h
│ ├── extractor
│ │ ├── GameExtractor.cpp
│ │ └── GameExtractor.h
│ ├── hooks
│ │ ├── Events.h
│ │ ├── impl
│ │ │ ├── EventSystem.cpp
│ │ │ └── EventSystem.h
│ │ └── list
│ │ │ ├── ActionEvent.h
│ │ │ ├── ActorEvent.h
│ │ │ ├── EngineEvent.h
│ │ │ └── ItemEvent.h
│ ├── interpolation
│ │ ├── FrameInterpolation.cpp
│ │ └── FrameInterpolation.h
│ ├── mods
│ │ ├── PortEnhancements.c
│ │ └── PortEnhancements.h
│ ├── notification
│ │ ├── notification.cpp
│ │ └── notification.h
│ ├── patches
│ │ ├── DisplayListPatch.cpp
│ │ └── DisplayListPatch.h
│ ├── resource
│ │ ├── importers
│ │ │ ├── AnimFactory.cpp
│ │ │ ├── AnimFactory.h
│ │ │ ├── ColPolyFactory.cpp
│ │ │ ├── ColPolyFactory.h
│ │ │ ├── EnvSettingsFactory.cpp
│ │ │ ├── EnvSettingsFactory.h
│ │ │ ├── GenericArrayFactory.cpp
│ │ │ ├── GenericArrayFactory.h
│ │ │ ├── HitboxFactory.cpp
│ │ │ ├── HitboxFactory.h
│ │ │ ├── LimbFactory.cpp
│ │ │ ├── LimbFactory.h
│ │ │ ├── MessageFactory.cpp
│ │ │ ├── MessageFactory.h
│ │ │ ├── MessageLookupFactory.cpp
│ │ │ ├── MessageLookupFactory.h
│ │ │ ├── ObjectInitFactory.cpp
│ │ │ ├── ObjectInitFactory.h
│ │ │ ├── ResourceUtil.h
│ │ │ ├── ScriptCommandFactory.cpp
│ │ │ ├── ScriptCommandFactory.h
│ │ │ ├── ScriptFactory.cpp
│ │ │ ├── ScriptFactory.h
│ │ │ ├── SkeletonFactory.cpp
│ │ │ ├── SkeletonFactory.h
│ │ │ ├── Vec3fFactory.cpp
│ │ │ ├── Vec3fFactory.h
│ │ │ ├── Vec3sFactory.cpp
│ │ │ ├── Vec3sFactory.h
│ │ │ └── audio
│ │ │ │ ├── AudioTableFactory.cpp
│ │ │ │ ├── AudioTableFactory.h
│ │ │ │ ├── BookFactory.cpp
│ │ │ │ ├── BookFactory.h
│ │ │ │ ├── DrumFactory.cpp
│ │ │ │ ├── DrumFactory.h
│ │ │ │ ├── EnvelopeFactory.cpp
│ │ │ │ ├── EnvelopeFactory.h
│ │ │ │ ├── InstrumentFactory.cpp
│ │ │ │ ├── InstrumentFactory.h
│ │ │ │ ├── LoopFactory.cpp
│ │ │ │ ├── LoopFactory.h
│ │ │ │ ├── SampleFactory.cpp
│ │ │ │ ├── SampleFactory.h
│ │ │ │ ├── SoundFontFactory.cpp
│ │ │ │ └── SoundFontFactory.h
│ │ ├── loaders
│ │ │ ├── AudioLoader.cpp
│ │ │ └── AudioLoader.h
│ │ └── type
│ │ │ ├── Animation.cpp
│ │ │ ├── Animation.h
│ │ │ ├── ColPoly.cpp
│ │ │ ├── ColPoly.h
│ │ │ ├── EnvSettings.cpp
│ │ │ ├── EnvSettings.h
│ │ │ ├── GenericArray.cpp
│ │ │ ├── GenericArray.h
│ │ │ ├── Hitbox.cpp
│ │ │ ├── Hitbox.h
│ │ │ ├── Limb.cpp
│ │ │ ├── Limb.h
│ │ │ ├── Message.cpp
│ │ │ ├── Message.h
│ │ │ ├── ObjectInit.cpp
│ │ │ ├── ObjectInit.h
│ │ │ ├── ResourceType.h
│ │ │ ├── Script.cpp
│ │ │ ├── Script.h
│ │ │ ├── Skeleton.cpp
│ │ │ ├── Skeleton.h
│ │ │ ├── Vec3fArray.cpp
│ │ │ ├── Vec3fArray.h
│ │ │ ├── Vec3sArray.cpp
│ │ │ ├── Vec3sArray.h
│ │ │ └── audio
│ │ │ ├── AdpcmBook.cpp
│ │ │ ├── AdpcmBook.h
│ │ │ ├── AdpcmLoop.cpp
│ │ │ ├── AdpcmLoop.h
│ │ │ ├── AudioContext.h
│ │ │ ├── AudioTable.cpp
│ │ │ ├── AudioTable.h
│ │ │ ├── Drum.cpp
│ │ │ ├── Drum.h
│ │ │ ├── Envelope.cpp
│ │ │ ├── Envelope.h
│ │ │ ├── Instrument.cpp
│ │ │ ├── Instrument.h
│ │ │ ├── Sample.cpp
│ │ │ ├── Sample.h
│ │ │ ├── SoundFont.cpp
│ │ │ └── SoundFont.h
│ └── ui
│ │ ├── ImguiUI.cpp
│ │ ├── ImguiUI.h
│ │ ├── ResolutionEditor.cpp
│ │ ├── ResolutionEditor.h
│ │ ├── UIWidgets.cpp
│ │ └── UIWidgets.h
└── sys
│ ├── sys_fault.c
│ ├── sys_joybus.c
│ ├── sys_lib.c
│ ├── sys_lights.c
│ ├── sys_main.c
│ ├── sys_math.c
│ ├── sys_matrix.c
│ ├── sys_memory.c
│ ├── sys_save.c
│ └── sys_timer.c
├── starship.ico
├── starship.manifest
├── tools
├── .gitignore
├── Makefile
├── aifc_decode
├── aifc_decode.c
├── check_format.sh
├── comptool.py
├── disassemble_sound.py
├── find_duplicates.py
├── fixfloats.py
├── float-convert.py
├── format.py
├── gfxdis.f3dex
├── global_bss_check.py
├── m2ctx.py
├── mio0-decompressor
│ ├── LICENSE
│ ├── README.md
│ ├── libmio0.c
│ ├── libmio0.h
│ └── utils.h
├── name_fixer.py
├── permuter_settings.toml
├── progress.py
├── requirements-python.txt
├── set_o32abi_bit.py
├── textconv.py
├── upload_progress.py
└── used_symbols.py
└── yamls
├── eu
└── rev0
│ ├── assets.yaml
│ ├── header.yaml
│ ├── main.yaml
│ └── overlays.yaml
├── jp
├── rev0
│ ├── assets.yaml
│ ├── header.yaml
│ ├── main.yaml
│ └── overlays.yaml
└── rev1
│ ├── assets.yaml
│ ├── header.yaml
│ ├── main.yaml
│ └── overlays.yaml
├── ln
└── rev0
│ ├── assets.yaml
│ ├── header.yaml
│ ├── main.yaml
│ └── overlays.yaml
└── us
├── rev0
├── assets.yaml
├── header.yaml
├── main.yaml
└── overlays.yaml
└── rev1
├── assets.yaml
├── header.yaml
├── main.yaml
└── overlays.yaml
/.clang-format:
--------------------------------------------------------------------------------
1 | IndentWidth: 4
2 | Language: Cpp
3 | UseTab: Never
4 | ColumnLimit: 120
5 | PointerAlignment: Left
6 | BreakBeforeBraces: Attach
7 | SpaceAfterCStyleCast: true
8 | Cpp11BracedListStyle: false
9 | IndentCaseLabels: true
10 | BinPackArguments: true
11 | BinPackParameters: true
12 | AlignAfterOpenBracket: Align
13 | AlignOperands: true
14 | BreakBeforeTernaryOperators: true
15 | BreakBeforeBinaryOperators: None
16 | AllowShortBlocksOnASingleLine: true
17 | AllowShortIfStatementsOnASingleLine: false
18 | AllowShortLoopsOnASingleLine: false
19 | AllowShortCaseLabelsOnASingleLine: false
20 | AllowShortFunctionsOnASingleLine: false
21 | AlignEscapedNewlines: Left
22 | AlignTrailingComments: true
23 | SortIncludes: false
--------------------------------------------------------------------------------
/.github/workflows/mac.yml:
--------------------------------------------------------------------------------
1 | name: MacOS Validation
2 |
3 | on:
4 | pull_request:
5 | branches: [ "*" ]
6 |
7 | jobs:
8 | build:
9 | runs-on: macOS-latest
10 | steps:
11 | - uses: actions/checkout@v4
12 | with:
13 | submodules: recursive
14 | - name: Install dependencies
15 | run: brew install sdl2 libpng glew ninja cmake libzip nlohmann-json tinyxml2 spdlog vorbis-tools
16 | - name: Build
17 | run: |
18 | cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release
19 | cmake --build build-cmake -j
20 | - name: Create Package
21 | run: |
22 | mkdir starship-release
23 | mv build-cmake/Starship starship-release/
24 | - name: Publish packaged artifacts
25 | uses: actions/upload-artifact@v4
26 | with:
27 | name: starship-mac-x64
28 | path: starship-release
29 | retention-days: 1
--------------------------------------------------------------------------------
/.github/workflows/switch.yml:
--------------------------------------------------------------------------------
1 | name: Switch Validation
2 |
3 | on:
4 | pull_request:
5 | branches: [ "*" ]
6 |
7 | jobs:
8 | build-switch:
9 | runs-on: ubuntu-latest
10 | container:
11 | image: devkitpro/devkita64:20241023
12 | steps:
13 | - uses: actions/checkout@v4
14 | with:
15 | submodules: recursive
16 | - name: Install dependencies
17 | run: |
18 | sudo apt-get update
19 | sudo apt-get install -y ninja-build
20 | sudo apt-get remove -y cmake
21 | git -C libultraship remote add nx https://github.com/Net64DD/libultraship.git
22 | git -C libultraship fetch nx
23 | git -C libultraship checkout nx/main-nx
24 | wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh -O /tmp/cmake.sh
25 | sudo sh /tmp/cmake.sh --prefix=/usr/local/ --exclude-subdir
26 | cmake -H. -Bbuild-switch -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake
27 | cmake --build build-switch --config Release -j3
28 | wget -O gamecontrollerdb.txt https://github.com/mdqinc/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt
29 | mv README.md readme.txt
30 | mv build-switch/*.nro Starship.nro
31 | - name: Upload build
32 | uses: actions/upload-artifact@v4
33 | with:
34 | name: Starship-switch
35 | retention-days: 1
36 | path: |
37 | Starship.nro
38 | config.yml
39 | assets
40 | gamecontrollerdb.txt
--------------------------------------------------------------------------------
/.github/workflows/windows.yml:
--------------------------------------------------------------------------------
1 | name: Windows Validation
2 |
3 | on:
4 | pull_request:
5 | branches: [ "*" ]
6 |
7 | jobs:
8 | build:
9 | runs-on: windows-2022
10 | steps:
11 | - uses: actions/checkout@v4
12 | with:
13 | submodules: recursive
14 | - name: Build
15 | run: |
16 | cmake -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 -DCMAKE_BUILD_TYPE=Release
17 | cmake --build ./build/x64
18 | - name: Upload build
19 | uses: actions/upload-artifact@v4
20 | with:
21 | name: starship-windows
22 | path: ./build/x64/Debug
23 | retention-days: 1
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | asm
2 | expected
3 | __pycache__
4 | .splat/
5 | starfox64.ld
6 | starfox64.uncompressed.ld
7 | starfox64.*.*.yaml
8 | starfox64.us.modded.map
9 | ctx.c
10 | ctx.c.m2c
11 | *.d
12 | *_auto.ld
13 | *.n64
14 | *.z64
15 | *.v64
16 | *.u64
17 | *.bin
18 | *.otr
19 | *.o2r
20 | *.log
21 | *.eeprom
22 | assets/yaml/us/ast_test.yaml
23 | /audio_data
24 | src/assets/*
25 | /build
26 | build-new/
27 | tools/mio0
28 | tools/ido-recomp
29 | debug/
30 | .venv/
31 | m2cfiles/
32 | TempComp.bin.mio0
33 | torch.hash.yml
34 | cmake-build-*/
35 | .idea/
36 | .vs
37 | build*
38 | logs/
39 | /mods/
40 | starship.cfg.json
41 | default.sav
42 | imgui.ini
43 | .vs
44 | default.sav
45 | imgui.ini
46 | starship.cfg.json
47 | imgui.ini
48 | starship.cfg.json
49 | Starship.log
50 | *.sav
51 | *.lib
52 | *.pdb
53 | dumps/
54 | _packages/*
55 | *.DS_Store
56 | src/jp/
57 | src/eu/
58 | src/cn/
59 |
60 | properties.h
61 | mods*/
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "tools/asm-differ"]
2 | path = tools/asm-differ
3 | url = https://github.com/simonlindholm/asm-differ
4 | [submodule "tools/Torch"]
5 | path = tools/Torch
6 | url = https://github.com/HarbourMasters/Torch
7 | [submodule "libultraship"]
8 | path = libultraship
9 | url = https://github.com/Kenix3/libultraship.git
10 |
--------------------------------------------------------------------------------
/.vscode/c_cpp_properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "configurations": [
3 | {
4 | "name": "Linux",
5 | "compilerPath": "${default}",
6 | "compilerArgs": [
7 | "-m32"
8 | ],
9 | "intelliSenseMode": "${default}", // Shouldn't matter
10 | "includePath": [
11 | "${workspaceFolder}/**",
12 | "src",
13 | "build",
14 | "include"
15 | ],
16 | "defines": [
17 | "_LANGUAGE_C",
18 | "__sgi",
19 | "_MIPS_SZLONG=32",
20 | "F3DEX_GBI",
21 | "GBI_FLOATS"
22 | ],
23 | "cStandard": "gnu89", // C89 + some GNU extensions from C99 like C++ comments
24 | "cppStandard": "${default}"
25 | }
26 | ],
27 | "version": 4
28 | }
--------------------------------------------------------------------------------
/ExecutableResource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Resource.rc
4 | //
5 | #define IDI_ICON1 111
6 |
7 | // Next default values for new objects
8 | //
9 | #ifdef APSTUDIO_INVOKED
10 | #ifndef APSTUDIO_READONLY_SYMBOLS
11 | #define _APS_NEXT_RESOURCE_VALUE 113
12 | #define _APS_NEXT_COMMAND_VALUE 40001
13 | #define _APS_NEXT_CONTROL_VALUE 1001
14 | #define _APS_NEXT_SYMED_VALUE 101
15 | #endif
16 | #endif
17 |
--------------------------------------------------------------------------------
/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleName
8 | Starship
9 | CFBundleExecutable
10 | Starship
11 | CFBundleGetInfoString
12 | 0.1.0
13 | CFBundleIconFile
14 | Starship.icns
15 | CFBundleIdentifier
16 | com.Starship.Starship
17 | CFBundleDocumentTypes
18 |
19 |
20 | CFBundleInfoDictionaryVersion
21 | 6.0
22 | CFBundlePackageType
23 | APPL
24 | CFBundleShortVersionString
25 | 0.1.0
26 | CFBundleSignature
27 | ZMM
28 | CFBundleVersion
29 | 0.1.0
30 | NSHumanReadableCopyright
31 | Copyright 2024 HarbourMasters.
32 | LSApplicationCategoryType
33 | public.app-category.games
34 | LSMinimumSystemVersion
35 | 10.15
36 | LSArchitecturePriority
37 |
38 | arm64
39 | x86_64
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Starship.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Version=1.0
3 | Name=2SHIP
4 | Exec=Starship
5 | Terminal=false
6 | Icon=logo
7 | Type=Application
8 | Categories=Game;
9 | X-AppImage-Integrate=false
--------------------------------------------------------------------------------
/assets/yaml/cn/rev1/ast_audio.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | force: true
3 | header:
4 | code:
5 | - '#include "sys.h"'
6 | - '#include "sf64audio_provisional.h"'
7 |
8 | audio_setup:
9 | type: NAUDIO:V1:AUDIO_SETUP
10 | driver: SF64
11 | audio_seq:
12 | size: 0x3AB10
13 | offset: 0xDD890
14 | audio_bank:
15 | size: 0x1CB20
16 | offset: 0x1183A0
17 | audio_table:
18 | size: 0x691AF0
19 | offset: 0x134EC0
20 |
21 | audio_sample_bank_table:
22 | { type: NAUDIO:V1:AUDIO_TABLE, format: SAMPLE, offset: 0xC1460, symbol: gSampleBankTableInit }
23 |
24 | audio_seq_table:
25 | { type: NAUDIO:V1:AUDIO_TABLE, format: SEQUENCE, offset: 0xC14A0, symbol: gSeqTableInit }
26 |
27 | audio_soundfont_table:
28 | { type: NAUDIO:V1:AUDIO_TABLE, format: SOUNDFONT, offset: 0xC18D0, symbol: gSoundFontTableInit }
29 |
30 | audio_seq_font_table:
31 | { type: ARRAY, count: 283, array_type: u8, offset: 0xC1AF0, symbol: gSeqFontTableInit }
--------------------------------------------------------------------------------
/assets/yaml/eu/rev0/ast_audio.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | force: true
3 | header:
4 | code:
5 | - '#include "sys.h"'
6 | - '#include "sf64audio_provisional.h"'
7 |
8 | audio_setup:
9 | type: NAUDIO:V1:AUDIO_SETUP
10 | driver: SF64
11 | audio_seq:
12 | size: 0x47390
13 | offset: 0xE0BC0
14 | audio_bank:
15 | size: 0x1F290
16 | offset: 0x127F50
17 | audio_table:
18 | size: 0x685D00
19 | offset: 0x1471E0
20 |
21 | audio_sample_bank_table:
22 | { type: NAUDIO:V1:AUDIO_TABLE, format: SAMPLE, offset: 0xC4D20, symbol: gSampleBankTableInit }
23 |
24 | audio_seq_table:
25 | { type: NAUDIO:V1:AUDIO_TABLE, format: SEQUENCE, offset: 0xC4D70, symbol: gSeqTableInit }
26 |
27 | audio_soundfont_table:
28 | { type: NAUDIO:V1:AUDIO_TABLE, format: SOUNDFONT, offset: 0xC51B0, symbol: gSoundFontTableInit }
29 |
30 | audio_seq_font_table:
31 | { type: ARRAY, count: 288, array_type: u8, offset: 0xC53E0, symbol: gSeqFontTableInit }
--------------------------------------------------------------------------------
/assets/yaml/jp/rev0/ast_audio.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | force: true
3 | header:
4 | code:
5 | - '#include "sys.h"'
6 | - '#include "sf64audio_provisional.h"'
7 |
8 | audio_setup:
9 | type: NAUDIO:V1:AUDIO_SETUP
10 | driver: SF64
11 | audio_seq:
12 | size: 0x3AFD0
13 | offset: 0xE9950
14 | audio_bank:
15 | size: 0x1F120
16 | offset: 0x124920
17 | audio_table:
18 | size: 0x700C20
19 | offset: 0x143A40
20 |
21 | audio_sample_bank_table:
22 | { type: NAUDIO:V1:AUDIO_TABLE, format: SAMPLE, offset: 0xC1360, symbol: gSampleBankTableInit }
23 |
24 | audio_seq_table:
25 | { type: NAUDIO:V1:AUDIO_TABLE, format: SEQUENCE, offset: 0xC13B0, symbol: gSeqTableInit }
26 |
27 | audio_soundfont_table:
28 | { type: NAUDIO:V1:AUDIO_TABLE, format: SOUNDFONT, offset: 0xC17E0, symbol: gSoundFontTableInit }
29 |
30 | audio_seq_font_table:
31 | { type: ARRAY, count: 283, array_type: u8, offset: 0xC1A00, symbol: gSeqFontTableInit }
--------------------------------------------------------------------------------
/assets/yaml/us/rev0/ast_audio.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | header:
3 | code:
4 | - '#include "sys.h"'
5 | - '#include "sf64audio_provisional.h"'
6 |
7 | audio_setup:
8 | type: NAUDIO:V1:AUDIO_SETUP
9 | driver: SF64
10 | audio_seq:
11 | size: 0x3ACF0
12 | offset: 0xDA030
13 | audio_bank:
14 | size: 0x1E020
15 | offset: 0x114D20
16 | audio_table:
17 | size: 0x73C580
18 | offset: 0x132D40
19 |
20 | audio_sample_bank_table:
21 | { type: NAUDIO:V1:AUDIO_TABLE, format: SAMPLE, offset: 0xBFD90, symbol: gSampleBankTableInit }
22 |
23 | audio_seq_table:
24 | { type: NAUDIO:V1:AUDIO_TABLE, format: SEQUENCE, offset: 0xBFDE0, symbol: gSeqTableInit }
25 |
26 | audio_soundfont_table:
27 | { type: NAUDIO:V1:AUDIO_TABLE, format: SOUNDFONT, offset: 0xC0210, symbol: gSoundFontTableInit }
28 |
29 | audio_seq_font_table:
30 | { type: ARRAY, count: 283, array_type: u8, offset: 0xC0430, symbol: gSeqFontTableInit }
--------------------------------------------------------------------------------
/assets/yaml/us/rev0/ast_ending_award_back.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x08, 0xD63A90]
4 | header:
5 | code:
6 | - '#include "assets/ast_ending_award_back.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | ending_award_back:
12 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 270, offset: 0x8000000, symbol: gEndingAwardBack }
13 |
14 |
--------------------------------------------------------------------------------
/assets/yaml/us/rev0/ast_ending_award_front.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x08, 0xD3EA10]
4 | header:
5 | code:
6 | - '#include "assets/ast_ending_award_front.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | ending_award_front:
12 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 240, offset: 0x8000000, symbol: gEndingAwardFront }
--------------------------------------------------------------------------------
/assets/yaml/us/rev0/ast_ending_expert.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x08, 0xD8D520]
4 | header:
5 | code:
6 | - '#include "assets/ast_ending_expert.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | ending_expert_reward:
12 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 240, offset: 0x8000000, symbol: gEndingExpertReward }
13 |
14 | ending_normal_reward:
15 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 240, offset: 0x8025080, symbol: gEndingNormalReward }
--------------------------------------------------------------------------------
/assets/yaml/us/rev0/ast_logo.yml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x0F, 0xD20710]
4 | header:
5 | code:
6 | - '#include "assets/ast_logo.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | nintendo_logo:
12 | type: TEXTURE
13 | offset: 0xF000000
14 | format: IA8
15 | width: 128
16 | height: 74
17 | ctype: u8
18 | symbol: gNintendoLogo
--------------------------------------------------------------------------------
/assets/yaml/us/rev0/ast_warp_zone.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x07, 0xBF5D50]
4 | header:
5 | code:
6 | - '#include "assets/ast_warp_zone.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | aWzSxEnemy1DL:
12 | { type: GFX, offset: 0x7000000, symbol: aWzSxEnemy1DL }
13 |
14 | aWzGateDL:
15 | { type: GFX, offset: 0x7000280, symbol: aWzGateDL }
16 |
17 | aWzMeteor2DL:
18 | { type: GFX, offset: 0x70008F0, symbol: aWzMeteor2DL }
19 |
20 | D_WZ_7000260:
21 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 4, height: 4, offset: 0x7000260, symbol: D_WZ_7000260 }
22 |
23 | D_WZ_7000A30:
24 | { type: TEXTURE, ctype: u8, format: CI4, width: 32, height: 32, offset: 0x7000A30, symbol: D_WZ_7000A30, tlut: 0x7000C30 }
25 |
26 | D_WZ_7000C30:
27 | { type: TEXTURE, ctype: u16, format: TLUT, colors: 8, offset: 0x7000C30, symbol: D_WZ_7000C30 }
28 |
29 | aWzPillar1DL:
30 | { type: GFX, offset: 0x7000C40, symbol: aWzPillar1DL }
31 |
32 | aWzMeteor1DL:
33 | { type: GFX, offset: 0x7000E80, symbol: aWzMeteor1DL }
34 |
35 | aWzPillar2DL:
36 | { type: GFX, offset: 0x70010E0, symbol: aWzPillar2DL }
37 |
38 | D_WZ_7001540:
39 | { type: GFX, offset: 0x7001540, symbol: D_WZ_7001540 }
40 |
41 | D_WZ_70015D0:
42 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 32, height: 32, offset: 0x70015D0, symbol: D_WZ_70015D0 }
--------------------------------------------------------------------------------
/assets/yaml/us/rev1/ast_audio.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | force: true
3 | header:
4 | code:
5 | - '#include "sys.h"'
6 | - '#include "sf64audio_provisional.h"'
7 |
8 | audio_setup:
9 | type: NAUDIO:V1:AUDIO_SETUP
10 | driver: SF64
11 | audio_seq:
12 | size: 0x3ACF0
13 | offset: 0xDEA20
14 | audio_bank:
15 | size: 0x1E020
16 | offset: 0x119710
17 | audio_table:
18 | size: 0x73C580
19 | offset: 0x137730
20 |
21 | audio_sample_bank_table:
22 | { type: NAUDIO:V1:AUDIO_TABLE, format: SAMPLE, offset: 0xC4210, symbol: gSampleBankTableInit }
23 |
24 | audio_seq_table:
25 | { type: NAUDIO:V1:AUDIO_TABLE, format: SEQUENCE, offset: 0xC4260, symbol: gSeqTableInit }
26 |
27 | audio_soundfont_table:
28 | { type: NAUDIO:V1:AUDIO_TABLE, format: SOUNDFONT, offset: 0xC4690, symbol: gSoundFontTableInit }
29 |
30 | audio_seq_font_table:
31 | { type: ARRAY, count: 283, array_type: u8, offset: 0xC48B0, symbol: gSeqFontTableInit }
--------------------------------------------------------------------------------
/assets/yaml/us/rev1/ast_ending_award_back.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x08, 0xD68480]
4 | header:
5 | code:
6 | - '#include "assets/ast_ending_award_back.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | ending_award_back:
12 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 270, offset: 0x8000000, symbol: gEndingAwardBack }
13 |
14 |
--------------------------------------------------------------------------------
/assets/yaml/us/rev1/ast_ending_award_front.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x08, 0xD43400]
4 | header:
5 | code:
6 | - '#include "assets/ast_ending_award_front.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | ending_award_front:
12 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 240, offset: 0x8000000, symbol: gEndingAwardFront }
--------------------------------------------------------------------------------
/assets/yaml/us/rev1/ast_ending_expert.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x08, 0xD91F10]
4 | header:
5 | code:
6 | - '#include "assets/ast_ending_expert.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | ending_expert_reward:
12 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 240, offset: 0x8000000, symbol: gEndingExpertReward }
13 |
14 | ending_normal_reward:
15 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 316, height: 240, offset: 0x8025080, symbol: gEndingNormalReward }
--------------------------------------------------------------------------------
/assets/yaml/us/rev1/ast_logo.yml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x0F, 0xD25100]
4 | header:
5 | code:
6 | - '#include "assets/ast_logo.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | nintendo_logo:
12 | type: TEXTURE
13 | offset: 0xF000000
14 | format: IA8
15 | width: 128
16 | height: 74
17 | ctype: u8
18 | symbol: gNintendoLogo
--------------------------------------------------------------------------------
/assets/yaml/us/rev1/ast_warp_zone.yaml:
--------------------------------------------------------------------------------
1 | :config:
2 | segments:
3 | - [0x07, 0xBFA740]
4 | header:
5 | code:
6 | - '#include "assets/ast_warp_zone.h"'
7 | header:
8 | - '#include "gfx.h"'
9 | - '#include "sf64object.h"'
10 |
11 | aWzSxEnemy1DL:
12 | { type: GFX, offset: 0x7000000, symbol: aWzSxEnemy1DL }
13 |
14 | aWzGateDL:
15 | { type: GFX, offset: 0x7000280, symbol: aWzGateDL }
16 |
17 | aWzMeteor2DL:
18 | { type: GFX, offset: 0x70008F0, symbol: aWzMeteor2DL }
19 |
20 | D_WZ_7000260:
21 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 4, height: 4, offset: 0x7000260, symbol: D_WZ_7000260 }
22 |
23 | D_WZ_7000A30:
24 | { type: TEXTURE, ctype: u8, format: CI4, width: 32, height: 32, offset: 0x7000A30, symbol: D_WZ_7000A30, tlut: 0x7000C30 }
25 |
26 | D_WZ_7000C30:
27 | { type: TEXTURE, ctype: u16, format: TLUT, colors: 8, offset: 0x7000C30, symbol: D_WZ_7000C30 }
28 |
29 | aWzPillar1DL:
30 | { type: GFX, offset: 0x7000C40, symbol: aWzPillar1DL }
31 |
32 | aWzMeteor1DL:
33 | { type: GFX, offset: 0x7000E80, symbol: aWzMeteor1DL }
34 |
35 | aWzPillar2DL:
36 | { type: GFX, offset: 0x70010E0, symbol: aWzPillar2DL }
37 |
38 | D_WZ_7001540:
39 | { type: GFX, offset: 0x7001540, symbol: D_WZ_7001540 }
40 |
41 | D_WZ_70015D0:
42 | { type: TEXTURE, ctype: u16, format: RGBA16, width: 32, height: 32, offset: 0x70015D0, symbol: D_WZ_70015D0 }
--------------------------------------------------------------------------------
/cmake/configure-packaging.cmake:
--------------------------------------------------------------------------------
1 | set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
2 | set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
3 | set(CPACK_COMPONENTS_ALL "Starship")
4 |
5 | if (CPACK_GENERATOR STREQUAL "External")
6 | list(APPEND CPACK_COMPONENTS_ALL "extractor" "appimage")
7 | endif()
8 |
9 | if (CPACK_GENERATOR MATCHES "DEB|RPM")
10 | # https://unix.stackexchange.com/a/11552/254512
11 | set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/ship/bin")#/${CMAKE_PROJECT_VERSION}")
12 | set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY 0)
13 | elseif (CPACK_GENERATOR MATCHES "ZIP")
14 | set(CPACK_PACKAGING_INSTALL_PREFIX "")
15 | endif()
16 |
17 | if (CPACK_GENERATOR MATCHES "External")
18 | set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
19 | SET(CPACK_MONOLITHIC_INSTALL 1)
20 | set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/bin")
21 | endif()
22 |
23 | if (CPACK_GENERATOR MATCHES "Bundle")
24 | set(CPACK_BUNDLE_NAME "Starship")
25 | set(CPACK_BUNDLE_PLIST "macosx/Info.plist")
26 | set(CPACK_BUNDLE_ICON "macosx/Starship.icns")
27 | # set(CPACK_BUNDLE_STARTUP_COMMAND "macosx/Starship-macos.sh")
28 | set(CPACK_BUNDLE_APPLE_CERT_APP "-")
29 | endif()
--------------------------------------------------------------------------------
/cmake/modules/FindOgg.cmake:
--------------------------------------------------------------------------------
1 | # - Find ogg
2 | # Find the native ogg includes and libraries
3 | #
4 | # OGG_INCLUDE_DIRS - where to find ogg.h, etc.
5 | # OGG_LIBRARIES - List of libraries when using ogg.
6 | # OGG_FOUND - True if ogg found.
7 |
8 | if (OGG_INCLUDE_DIR)
9 | # Already in cache, be silent
10 | set(OGG_FIND_QUIETLY TRUE)
11 | endif ()
12 |
13 | find_package (PkgConfig QUIET)
14 | pkg_check_modules (PC_OGG QUIET ogg>=1.3.0)
15 |
16 | set (OGG_VERSION ${PC_OGG_VERSION})
17 |
18 | find_path (OGG_INCLUDE_DIR ogg/ogg.h
19 | HINTS
20 | ${PC_OGG_INCLUDEDIR}
21 | ${PC_OGG_INCLUDE_DIRS}
22 | ${OGG_ROOT}
23 | )
24 | # MSVC built ogg may be named ogg_static.
25 | # The provided project files name the library with the lib prefix.
26 | find_library (OGG_LIBRARY
27 | NAMES
28 | ogg
29 | ogg_static
30 | libogg
31 | libogg_static
32 | HINTS
33 | ${PC_OGG_LIBDIR}
34 | ${PC_OGG_LIBRARY_DIRS}
35 | ${OGG_ROOT}
36 | )
37 | # Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
38 | # to TRUE if all listed variables are TRUE.
39 | include (FindPackageHandleStandardArgs)
40 | find_package_handle_standard_args (Ogg
41 | REQUIRED_VARS
42 | OGG_LIBRARY
43 | OGG_INCLUDE_DIR
44 | VERSION_VAR
45 | OGG_VERSION
46 | )
47 |
48 | if (OGG_FOUND)
49 | set (OGG_LIBRARIES ${OGG_LIBRARY})
50 | set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
51 |
52 | if(NOT TARGET Ogg::ogg)
53 | add_library(Ogg::ogg UNKNOWN IMPORTED)
54 | set_target_properties(Ogg::ogg PROPERTIES
55 | INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
56 | IMPORTED_LOCATION "${OGG_LIBRARIES}"
57 | )
58 | endif ()
59 | endif ()
60 |
61 | mark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY)
--------------------------------------------------------------------------------
/cmake/modules/FindPulseAudio.cmake:
--------------------------------------------------------------------------------
1 | # - Find PulseAudio includes and libraries
2 | #
3 | # PULSEAUDIO_FOUND - True if PULSEAUDIO_INCLUDE_DIR &
4 | # PULSEAUDIO_LIBRARY are found
5 | #
6 | # PULSEAUDIO_INCLUDE_DIR - where to find pulse/pulseaudio.h, etc.
7 | # PULSEAUDIO_LIBRARY - the pulse library
8 | # PULSEAUDIO_VERSION_STRING - the version of PulseAudio found
9 | #
10 |
11 | find_path(PULSEAUDIO_INCLUDE_DIR
12 | NAMES pulse/pulseaudio.h
13 | DOC "The PulseAudio include directory"
14 | )
15 |
16 | find_library(PULSEAUDIO_LIBRARY
17 | NAMES pulse
18 | DOC "The PulseAudio library"
19 | )
20 |
21 | if(PULSEAUDIO_INCLUDE_DIR AND EXISTS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h")
22 | file(STRINGS "${PULSEAUDIO_INCLUDE_DIR}/pulse/version.h" pulse_version_str
23 | REGEX "^#define[\t ]+pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)")
24 |
25 | string(REGEX REPLACE "^.*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*$" "\\1"
26 | PULSEAUDIO_VERSION_STRING "${pulse_version_str}")
27 | unset(pulse_version_str)
28 | endif()
29 |
30 | include(FindPackageHandleStandardArgs)
31 | find_package_handle_standard_args(PulseAudio
32 | REQUIRED_VARS PULSEAUDIO_LIBRARY PULSEAUDIO_INCLUDE_DIR
33 | VERSION_VAR PULSEAUDIO_VERSION_STRING
34 | )
35 |
--------------------------------------------------------------------------------
/cmake/modules/FindlibUsb.cmake:
--------------------------------------------------------------------------------
1 | if (MSVC)
2 | set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/VS2019/MS64/static")
3 |
4 | # check if we're using something else than 64bit..
5 | if (NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
6 | set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/VS2019/MS32/static")
7 | endif()
8 | endif()
9 |
10 | if (MINGW)
11 | set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/MinGW64/static")
12 | # check if we're using something else than 64bit..
13 | if (NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
14 | set(WINDOWS_LIBUSB_PATH "$ENV{LIBUSB_PATH}/MinGW32/static")
15 | endif()
16 | endif()
17 |
18 | find_library (LIBUSB_LIBRARY
19 | NAMES libusb libusb-1.0 usb-1.0
20 | PATHS "/usr/lib" "/usr/local/lib/" "${WINDOWS_LIBUSB_PATH}")
21 |
22 | find_path (LIBUSB_INCLUDEDIR
23 | NAMES libusb.h libusb-1.0.h
24 | PATHS "/usr/local/include/" "$ENV{LIBUSB_PATH}/include/libusb-1.0"
25 | PATH_SUFFIXES "include" "libusb" "libusb-1.0")
26 |
27 | include(FindPackageHandleStandardArgs)
28 |
29 | find_package_handle_standard_args(libUsb DEFAULT_MSG
30 | LIBUSB_LIBRARY
31 | LIBUSB_INCLUDEDIR)
32 |
33 | if (LIBUSB_FOUND AND NOT TARGET libUsb::libUsb)
34 | add_library(libUsb::libUsb STATIC IMPORTED)
35 | set_target_properties(
36 | libUsb::libUsb
37 | PROPERTIES
38 | INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDEDIR}"
39 | IMPORTED_LOCATION "${LIBUSB_LIBRARY}")
40 | if (MSVC OR MINGW)
41 | set_target_properties(
42 | libUsb::libUsb
43 | PROPERTIES
44 | IMPORTED_IMPLIB "${LIBUSB_LIBRARY}"
45 | )
46 | endif()
47 | endif()
48 |
49 |
--------------------------------------------------------------------------------
/cmake/toolchain-x86_64-w64-mingw32.cmake:
--------------------------------------------------------------------------------
1 | set (CMAKE_SYSTEM_NAME Windows)
2 | set(CMAKE_SYSTEM_PROCESSOR x86_64)
3 |
4 | # specify the cross compiler
5 | set (CMAKE_C_COMPILER x86_64-w64-mingw32-gcc CACHE STRING "The C compiler to use")
6 | set (CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++ CACHE STRING "The C++ compiler to use")
7 |
8 | # where is the target environment
9 | set (CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
10 |
11 | # search for programs in the build host directories
12 | set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
13 | # for libraries and headers in the target directories
14 | set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
15 | set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
16 | set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
17 |
18 | # set the resource compiler (RHBZ #652435)
19 | set (CMAKE_RC_COMPILER windres)
20 | set (CMAKE_MC_COMPILER windmc)
21 |
22 | # override boost thread component suffix as mingw-w64-boost is compiled with threadapi=win32
23 | set (Boost_THREADAPI win32)
24 |
25 | set (CMAKE_AR:FILEPATH x86_64-w64-mingw32-ar)
26 | set (CMAKE_RANLIB:FILEPATH x86_64-w64-mingw32-ranlib)
--------------------------------------------------------------------------------
/docs/poweredbylus.darkmode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/docs/poweredbylus.darkmode.png
--------------------------------------------------------------------------------
/docs/poweredbylus.lightmode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/docs/poweredbylus.lightmode.png
--------------------------------------------------------------------------------
/include/PR/assert.h:
--------------------------------------------------------------------------------
1 | #ifndef __ASSERT_H__
2 | #define __ASSERT_H__
3 |
4 | #ifdef NDEBUG
5 | #undef assert
6 | #define assert(EX) ((void)0)
7 | #else
8 | extern void __assert(const char *, const char *, int);
9 | #define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__))
10 | #endif /* NDEBUG */
11 |
12 | #endif /* !__ASSERT_H__ */
13 |
--------------------------------------------------------------------------------
/include/PR/guint.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | * *
3 | * Copyright (C) 1994, Silicon Graphics, Inc. *
4 | * *
5 | * These coded instructions, statements, and computer programs contain *
6 | * unpublished proprietary information of Silicon Graphics, Inc., and *
7 | * are protected by Federal copyright law. They may not be disclosed *
8 | * to third parties or copied or duplicated in any form, in whole or *
9 | * in part, without the prior written consent of Silicon Graphics, Inc. *
10 | * *
11 | **************************************************************************/
12 |
13 | #include "PR/mbi.h"
14 | #include "PR/gu.h"
15 |
16 | typedef union
17 | {
18 | struct
19 | {
20 | unsigned int hi;
21 | unsigned int lo;
22 | } word;
23 |
24 | double d;
25 | } du;
26 |
27 | typedef union
28 | {
29 | unsigned int i;
30 | float f;
31 | } fu;
32 |
33 | #ifndef __GL_GL_H__
34 |
35 | typedef float Matrix[4][4];
36 |
37 | #endif
38 |
39 | #define ROUND(d) (int)(((d) >= 0.0) ? ((d) + 0.5) : ((d) - 0.5))
40 | #define ABS(d) ((d) > 0) ? (d) : -(d)
41 |
42 | extern float __libm_qnan_f;
43 |
--------------------------------------------------------------------------------
/include/PR/rmon.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | * *
3 | * Copyright (C) 1995, Silicon Graphics, Inc. *
4 | * *
5 | * These coded instructions, statements, and computer programs contain *
6 | * unpublished proprietary information of Silicon Graphics, Inc., and *
7 | * are protected by Federal copyright law. They may not be disclosed *
8 | * to third parties or copied or duplicated in any form, in whole or *
9 | * in part, without the prior written consent of Silicon Graphics, Inc. *
10 | * *
11 | **************************************************************************/
12 |
13 | /**************************************************************************
14 | *
15 | * $Revision: 1.6 $
16 | * $Date: 1997/02/11 08:30:08 $
17 | * $Source: /disk6/Master/cvsmdev2/PR/include/rmon.h,v $
18 | *
19 | **************************************************************************/
20 |
21 | #ifndef _RMON_H_
22 | #define _RMON_H_
23 |
24 | #ifdef _LANGUAGE_C_PLUS_PLUS
25 | extern "C" {
26 | #endif
27 |
28 | #include
29 | #define RMON_DBG_BUF_SIZE 2048
30 | #define RMON_STACKSIZE 0x1000
31 |
32 | extern void rmonMain( void * );
33 | extern void rmonPrintf( const char *, ... );
34 |
35 | #ifdef _LANGUAGE_C_PLUS_PLUS
36 | }
37 | #endif
38 |
39 | #endif /* !_OS_H */
40 |
--------------------------------------------------------------------------------
/include/PR/xstdio.h:
--------------------------------------------------------------------------------
1 | #ifndef _XSTDIO_H
2 | #define _XSTDIO_H
3 | #include
4 | #include
5 |
6 | #define FLAGS_SPACE 1
7 | #define FLAGS_PLUS 2
8 | #define FLAGS_MINUS 4
9 | #define FLAGS_HASH 8
10 | #define FLAGS_ZERO 16
11 | typedef char *outfun(char*,const char*,size_t);
12 |
13 | int _Printf(outfun prout, char *arg, const char *fmt, va_list args);
14 | void _Litob(_Pft *args, char type);
15 | void _Ldtob(_Pft* px, char code);
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/include/alignment.h:
--------------------------------------------------------------------------------
1 | #ifndef ALIGNMENT_H
2 | #define ALIGNMENT_H
3 |
4 | #define ALIGN8(val) (((val) + 7) & ~7)
5 | #define ALIGN16(val) (((val) + 0xF) & ~0xF)
6 | #define ALIGN32(val) (((val) + 0x1F) & ~0x1F)
7 | #define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
8 | #define ALIGN256(val) (((val) + 0xFF) & ~0xFF)
9 |
10 | #define ALIGN16_ALT(val) (((val) & ~0xF) + 0x10)
11 |
12 | #ifdef __GNUC__
13 | #define ALIGNED8 __attribute__ ((aligned (8)))
14 | #else
15 | #define ALIGNED8
16 | #endif
17 |
18 | #ifdef __sgi /* IDO compiler */
19 | #define ALIGNOF(x) __builtin_alignof(x)
20 | #elif (__STDC_VERSION__ >= 201112L) /* C11 */
21 | #define ALIGNOF(x) _Alignof(x)
22 | #else /* __GNUC__ */
23 | #define ALIGNOF(x) __alignof__(x)
24 | #endif
25 |
26 | #define ALIGN_MASK(n) (~((n) - 1))
27 |
28 | #define ALIGNOF_MASK(x) ALIGN_MASK(ALIGNOF(x))
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/include/assets/ast_ending_award_back.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 |
6 | static const ALIGN_ASSET(2) char gEndingAwardBack[] = "__OTR__ast_ending_award_back/ending_award_back";
7 |
8 |
--------------------------------------------------------------------------------
/include/assets/ast_ending_award_front.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 |
6 | static const ALIGN_ASSET(2) char gEndingAwardFront[] = "__OTR__ast_ending_award_front/ending_award_front";
7 |
8 |
--------------------------------------------------------------------------------
/include/assets/ast_ending_expert.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 |
6 | static const ALIGN_ASSET(2) char gEndingExpertReward[] = "__OTR__ast_ending_expert/ending_expert_reward";
7 |
8 | static const ALIGN_ASSET(2) char gEndingNormalReward[] = "__OTR__ast_ending_expert/ending_normal_reward";
9 |
10 |
--------------------------------------------------------------------------------
/include/assets/ast_logo.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 |
6 | static const ALIGN_ASSET(2) char gNintendoLogo[] = "__OTR__ast_logo/nintendo_logo";
7 |
8 |
--------------------------------------------------------------------------------
/include/assets/namefix.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | for subdir, dirs, files in os.walk('.'):
4 | for file in files:
5 | with open(file, 'r') as header:
6 | htxt = header.read()
7 |
8 | name = str.upper(file[4:-2])
9 | print(name)
10 | htxt = htxt.replace("FIX.", name)
11 | print(htxt)
12 | with open(file, 'w') as header:
13 | header.write(htxt)
14 |
--------------------------------------------------------------------------------
/include/buffers.h:
--------------------------------------------------------------------------------
1 | #ifndef BUFFERS_H
2 | #define BUFFERS_H
3 |
4 | #include "gfx.h"
5 |
6 | extern u64 gDramStack[];
7 | extern u8 gOSYieldData[];
8 | extern FrameBuffer gZBuffer; // z buffer
9 | extern u8 gTaskOutputBuffer[];
10 | extern u8 gAudioHeap[];
11 | extern u16 gTextureRenderBuffer[];
12 | extern u16 gFillBuffer[];
13 | extern FrameBuffer gFrameBuffers[]; // 8038F800
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/include/common.h:
--------------------------------------------------------------------------------
1 | #ifndef COMMON_H
2 | #define COMMON_H
3 |
4 | typedef signed char s8;
5 | typedef signed short s16;
6 | typedef signed int s32;
7 | typedef signed long long s64;
8 | typedef unsigned char u8;
9 | typedef unsigned short u16;
10 | typedef unsigned int u32;
11 | typedef unsigned long long u64;
12 | typedef float f32;
13 |
14 | #define true 1
15 | #define false 0
16 | #define bool s32
17 |
18 | #define NULL 0
19 |
20 | double fabsf(double f);
21 | #pragma intrinsic(fabsf)
22 |
23 |
24 | #endif
25 |
26 |
--------------------------------------------------------------------------------
/include/dbgdefs.h:
--------------------------------------------------------------------------------
1 | #ifndef _DBGDEFS_H__
2 | #define _DBGDEFS_H__
3 |
4 | typedef int TVid;
5 | typedef unsigned short TVushort;
6 | typedef char TVuchar;
7 |
8 | #endif
9 |
--------------------------------------------------------------------------------
/include/debug.h:
--------------------------------------------------------------------------------
1 | #ifndef DEBUG_H
2 | #define DEBUG_H
3 |
4 | #define gEXMatrixGroupDecomposed(...)
5 | #define gEXMatrixGroupDecomposedNormal(...)
6 | #define gEXPopMatrixGroup(...)
7 |
8 | #define DEBUG_SPEED_CONTROL 1
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/include/fox_record.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Used to reproduce recordings made from real N64 hardware
3 | * to accurately reproduce Cutscenes at the correct speed.
4 | * These recordings adjust gVisPerFrame during runtime to produce
5 | * the same behaviour as the original game.
6 | */
7 | #ifndef N64_RECORD_H
8 | #define N64_RECORD_H
9 |
10 | #include "global.h"
11 |
12 | typedef struct Record {
13 | u8 vis;
14 | u16 frame;
15 | } Record;
16 |
17 | extern u8 gCarrierCutsceneRecord[200];
18 |
19 | void UpdateVisPerFrameFromRecording(u8* record, s32 maxFrames);
20 | void UpdateVisPerFrameFromRecording2(Record* record, s32 maxFrames);
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/include/gfx_dimensions.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | /*
3 |
4 | This file is for ports that want to enable widescreen.
5 | The idea is that SCREEN_WIDTH and SCREEN_HEIGHT are still hardcoded to 320 and 240, and that
6 | x=0 lies at where a 4:3 left edge would be. On 16:9 widescreen, the left edge is hence at -53.33.
7 |
8 | To get better accuracy, consider using floats instead of shorts for coordinates in Vertex and Matrix structures.
9 |
10 | The conversion to integers above is for RECT commands which naturally only accept integer values.
11 | Note that RECT commands must be enhanced to support negative coordinates with this modification.
12 |
13 | */
14 | #include "port/Engine.h"
15 | #include
16 |
17 | #define GFX_DIMENSIONS_ASPECT_RATIO GameEngine_GetAspectRatio()
18 | #define GFX_DIMENSIONS_FROM_LEFT_EDGE(v) (SCREEN_WIDTH / 2 - SCREEN_HEIGHT / 2 * GFX_DIMENSIONS_ASPECT_RATIO + (v))
19 | #define GFX_DIMENSIONS_FROM_RIGHT_EDGE(v) (SCREEN_WIDTH / 2 + SCREEN_HEIGHT / 2 * GFX_DIMENSIONS_ASPECT_RATIO - (v))
20 | #define GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(v) ((int)floorf(GFX_DIMENSIONS_FROM_LEFT_EDGE(v)))
21 | #define GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(v) ((int)ceilf(GFX_DIMENSIONS_FROM_RIGHT_EDGE(v)))
22 | // If screen is taller than it is wide, radius should be equal to SCREEN_HEIGHT since we scale horizontally
23 | #define GFX_DIMENSIONS_FULL_RADIUS (SCREEN_HEIGHT * (GFX_DIMENSIONS_ASPECT_RATIO > 1 ? GFX_DIMENSIONS_ASPECT_RATIO : 1))
24 | #define GFX_FULL_WIDTH GFX_DIMENSIONS_FROM_RIGHT_EDGE(0)
--------------------------------------------------------------------------------
/include/global.h:
--------------------------------------------------------------------------------
1 | #ifndef GLOBAL_H
2 | #define GLOBAL_H
3 |
4 | #include "sys.h"
5 | #include "debug.h"
6 |
7 | typedef enum OverlayCalls {
8 | /* 90 */ OVLCALL_FO_CS_COMPLETE = 90,
9 | /* 91 */ OVLCALL_BO_BASE_UPDATE,
10 | /* 92 */ OVLCALL_BO_BASE_DRAW,
11 | /* 93 */ OVLCALL_BO_BASE_SHIELD_UPDATE,
12 | /* 94 */ OVLCALL_BO_BASE_SHIELD_DRAW,
13 | /* 95 */ OVLCALL_BO_SHIELD_REACTOR_UPDATE,
14 | /* 96 */ OVLCALL_BO_SHIELD_REACTOR_DRAW,
15 | /* 97 */ OVLCALL_BO_LASER_CANNON_UPDATE,
16 | /* 98 */ OVLCALL_BO_LASER_CANNON_DRAW,
17 | /* 103 */ OVLCALL_TITLE_UPDATE = 103,
18 | /* 104 */ OVLCALL_TITLE_DRAW,
19 | /* 105 */ OVLCALL_MAP_UPDATE,
20 | /* 106 */ OVLCALL_MAP_DRAW,
21 | /* 107 */ OVLCALL_OPTION_UPDATE,
22 | /* 108 */ OVLCALL_OPTION_DRAW,
23 | /* 109 */ OVLCALL_GAME_OVER_UPDATE,
24 | /* 110 */ OVLCALL_UNKMAP_DRAW,
25 | } OverlayCalls;
26 |
27 | #include "sf64context.h"
28 | #include "sf64audio_external.h"
29 | #include "functions.h"
30 | #include "variables.h"
31 | #include "sf64context.h"
32 | #include "sf64mesg.h"
33 | #include "assets/ast_radio.h"
34 | #include "sf64object.h"
35 | #include "sf64level.h"
36 | #include "sf64event.h"
37 | #include "sf64player.h"
38 | #include "i1.h"
39 | #include "i2.h"
40 | #include "i3.h"
41 | #include "i4.h"
42 | #include "i5.h"
43 | #include "i6.h"
44 | #include "libc/math.h"
45 | #include "assets/ast_common.h"
46 | #include "gfx_dimensions.h"
47 | #include "port/interpolation/FrameInterpolation.h"
48 | #include
49 |
50 |
51 |
52 | #endif // GLOBAL_H
53 |
--------------------------------------------------------------------------------
/include/hit64.h:
--------------------------------------------------------------------------------
1 | #ifndef HIT64_H
2 | #define HIT64_H
3 |
4 | void Hit64_Main(void);
5 |
6 | #endif
7 |
--------------------------------------------------------------------------------
/include/hud.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 |
6 | static const ALIGN_ASSET(2) char sBoostGaugeArrow0[] = "__OTR__assets/textures/hud/sBoostGaugeArrow0";
7 | static const ALIGN_ASSET(2) char sBoostGaugeArrow1[] = "__OTR__assets/textures/hud/sBoostGaugeArrow1";
8 | static const ALIGN_ASSET(2) char sBoostGaugeArrow2[] = "__OTR__assets/textures/hud/sBoostGaugeArrow2";
9 | static const ALIGN_ASSET(2) char sBoostGaugeArrow3[] = "__OTR__assets/textures/hud/sBoostGaugeArrow3";
10 | static const ALIGN_ASSET(2) char sBoostGaugeArrow4[] = "__OTR__assets/textures/hud/sBoostGaugeArrow4";
11 | static const ALIGN_ASSET(2) char sBoostGaugeArrow5[] = "__OTR__assets/textures/hud/sBoostGaugeArrow5";
12 | static const ALIGN_ASSET(2) char sBoostGaugeArrow6[] = "__OTR__assets/textures/hud/sBoostGaugeArrow6";
13 | static const ALIGN_ASSET(2) char sBoostGaugeArrow7[] = "__OTR__assets/textures/hud/sBoostGaugeArrow7";
14 | static const ALIGN_ASSET(2) char sBoostGaugeArrow8[] = "__OTR__assets/textures/hud/sBoostGaugeArrow8";
--------------------------------------------------------------------------------
/include/i2.h:
--------------------------------------------------------------------------------
1 | #ifndef I2_H
2 | #define I2_H
3 |
4 | #include "libc/stdbool.h"
5 | #include "sf64object.h"
6 | #include "sf64thread.h"
7 | #include "sf64player.h"
8 | #include "sf64mesg.h"
9 |
10 | void Meteo_LevelStart(Player*);
11 | void Meteo_LevelComplete(Player*);
12 | void Meteo_8018ED9C(Actor*);
13 | void SectorX_LevelStart(Player*);
14 | void SectorX_LevelComplete(Player*);
15 |
16 | void OvlI2_CallFunction(s32, void*);
17 | void Meteo_80187B08(Actor *);
18 | void Meteo_MeCrusher_Init(Boss *);
19 | void Meteo_Effect346_Spawn(Actor *);
20 |
21 | void Meteo_MeMeteor1_Update(MeMeteor1*);
22 | void Meteo_MeMeteor2_Update(MeMeteor2*);
23 | void Meteo_MeLaserCannon1_Update(MeLaserCannon1*);
24 | void Meteo_MeLaserCannon2_Update(MeLaserCannon2*);
25 | void Meteo_MeCrusherShield_Update(Boss*);
26 | void Meteo_MeCrusherShield_Draw(Boss*);
27 | void Meteo_Effect369_Update(Effect*);
28 | void Meteo_Effect370_Update(Effect*);
29 | void Meteo_Effect371_Update(Effect*);
30 | void Meteo_MeCrusher_Update(Boss*);
31 | void Meteo_MeCrusher_Draw(Boss*);
32 | void Meteo_MeteorShower_Update(Actor*);
33 | void Meteo_MeMeteorShower1_Draw(Actor*);
34 | void Meteo_MeMeteorShower2_Draw(Actor*);
35 | void Meteo_MeMeteorShower3_Draw(Actor*);
36 | void Meteo_Effect370_Draw(Effect*);
37 | void Meteo_Effect369_Draw(Effect*);
38 | void Meteo_Effect371_Draw(Effect*);
39 | void SectorX_SxSlippy_Update(Actor*);
40 | void SectorX_SxSlippy_Draw(Actor*);
41 | void SectorX_SxSpyborgLeftArm_Update(Boss*);
42 | void SectorX_SxSpyborgRightArm_Update(Boss*);
43 | void SectorX_SxSpyborgLeftArm_Draw(Boss*);
44 | void SectorX_SxSpyborgRightArm_Draw(Boss*);
45 | void SectorX_SxSpyborg_Update(Boss*);
46 | void SectorX_SxSpyborg_Draw(Boss*);
47 |
48 | #endif
49 |
--------------------------------------------------------------------------------
/include/libc/math.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBC_MATH_H
2 | #define LIBC_MATH_H
3 |
4 | #include
5 | #include
6 |
7 | #define M_PI 3.14159265358979323846f
8 | #define M_DTOR (M_PI / 180.0f)
9 | #define M_RTOD (180.0f / M_PI)
10 | #define M_SQRT2 1.41421356237309504880f
11 | #define M_SQRT1_2 0.70710678118654752440f /* 1/sqrt(2) */
12 | #define FLT_MAX 340282346638528859811704183484516925440.0f
13 | #define SHT_MAX 32767.0f
14 | #define SHT_MINV (1.0f / SHT_MAX)
15 |
16 | typedef union {
17 | struct {
18 | u32 hi;
19 | u32 lo;
20 | } word;
21 |
22 | f64 d;
23 | } du;
24 |
25 | typedef union {
26 | u32 i;
27 | f32 f;
28 | } fu;
29 |
30 | #define __floorf floorf
31 | #define __floor floor
32 | #define __lfloorf lfloorf
33 | #define __lfloor lfloor
34 | #define __ceilf ceilf
35 | #define __ceil ceil
36 | #define __lceilf lceilf
37 | #define __lceil lceil
38 | #define __truncf truncf
39 | #define __trunc trunc
40 | #define __ltruncf ltruncf
41 | #define __ltrunc ltrunc
42 | #define __roundf roundf
43 | #define __round round
44 | #define __lroundf lroundf
45 | #define __lround lround
46 | #define __nearbyintf nearbyintf
47 | #define __nearbyint nearbyint
48 | #define __lnearbyintf lnearbyintf
49 | #define __lnearbyint lnearbyint
50 |
51 | #ifdef __cplusplus
52 | extern "C" {
53 | f32 __sinf(f32) throw();
54 | f32 __cosf(f32) throw();
55 | }
56 | #else
57 | f32 __sinf(f32);
58 | f32 __cosf(f32);
59 | #endif
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/include/libc/stdbool.h:
--------------------------------------------------------------------------------
1 | #define LIBC_STDBOOL_H
2 | #ifndef LIBC_STDBOOL_H
3 | #define LIBC_STDBOOL_H
4 |
5 | #include "PR/ultratypes.h"
6 |
7 | #define __bool_true_false_are_defined 1
8 |
9 | #ifndef __cplusplus
10 |
11 | typedef int bool;
12 | #define false 0
13 | #define true 1
14 |
15 | #endif /* __cplusplus */
16 |
17 | #endif /* STDBOOL */
18 |
--------------------------------------------------------------------------------
/include/libc/stddef.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBC_STDDEF_H
2 | #define LIBC_STDDEF_H
3 |
4 | #include
5 |
6 | typedef s32 ptrdiff_t;
7 |
8 | #ifdef __GNUC__
9 | #define offsetof(structure, member) __builtin_offsetof (structure, member)
10 | #else
11 | #define offsetof(structure, member) ((size_t)&(((structure*)0)->member))
12 | #endif
13 |
14 | #endif /* STDDEF_H */
15 |
--------------------------------------------------------------------------------
/include/libc/stdint.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBC_STDINT_H
2 | #define LIBC_STDINT_H
3 |
4 | #include
5 |
6 | typedef s32 intptr_t;
7 | typedef u32 uintptr_t;
8 |
9 | #define INT8_MIN (-0x80)
10 | #define INT16_MIN (-0x8000)
11 | #define INT32_MIN (-0x80000000)
12 | #define INT64_MIN (-0x8000000000000000)
13 |
14 | #define INT8_MAX 0x7F
15 | #define INT16_MAX 0x7FFF
16 | #define INT32_MAX 0x7FFFFFFF
17 | #define INT64_MAX 0x7FFFFFFFFFFFFFFF
18 |
19 | #define UINT8_MAX 0xFF
20 | #define UINT16_MAX 0xFFFF
21 | #define UINT32_MAX 0xFFFFFFFF
22 | #define UINT64_MAX 0xFFFFFFFFFFFFFFFF
23 |
24 | #define INTPTR_MIN (-0x80000000)
25 | #define INTPTR_MAX 0x7FFFFFFF
26 | #define UINTPTR_MAX 0xFFFFFFFF
27 |
28 |
29 | #endif /* STDINT_H */
30 |
--------------------------------------------------------------------------------
/include/libc/stdlib.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBC_STDLIB_H
2 | #define LIBC_STDLIB_H
3 |
4 | #include "stddef.h"
5 |
6 | typedef struct {
7 | /* 0x0 */ int quot;
8 | /* 0x4 */ int rem;
9 | } div_t;
10 |
11 | typedef struct {
12 | /* 0x0 */ long quot;
13 | /* 0x4 */ long rem;
14 | } ldiv_t;
15 |
16 | typedef struct {
17 | /* 0x0 */ long long quot;
18 | /* 0x8 */ long long rem;
19 | } lldiv_t;
20 |
21 | typedef int ssize_t;
22 |
23 | typedef long wchar_t;
24 |
25 | ldiv_t ldiv(long numer, long denom);
26 | lldiv_t lldiv(long long numer, long long denom);
27 |
28 | #endif /* STDLIB_H */
29 |
--------------------------------------------------------------------------------
/include/libc/string.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBC_STRING_H
2 | #define LIBC_STRING_H
3 |
4 | #include "stddef.h"
5 |
6 |
7 | const char* strchr(const char* s, int c);
8 | size_t strlen(const char* s);
9 | void* memcpy(void* s1, const void* s2, size_t n);
10 |
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/include/osint.h:
--------------------------------------------------------------------------------
1 | #ifndef _OSINT_H
2 | #define _OSINT_H
3 | #include "PR/os_internal.h"
4 | typedef struct __OSEventState
5 | {
6 | OSMesgQueue *messageQueue;
7 | OSMesg message;
8 | } __OSEventState;
9 | extern struct __osThreadTail
10 | {
11 | OSThread *next;
12 | OSPri priority;
13 | } __osThreadTail;
14 |
15 | //maybe should be in exceptasm.h?
16 | extern void __osEnqueueAndYield(OSThread **);
17 | extern void __osDequeueThread(OSThread **, OSThread *);
18 | extern void __osEnqueueThread(OSThread **, OSThread *);
19 | extern OSThread *__osPopThread(OSThread **);
20 | extern void __osDispatchThread(void);
21 | extern void __osCleanupThread(void);
22 |
23 | extern void __osSetTimerIntr(OSTime);
24 | extern OSTime __osInsertTimer(OSTimer *);
25 | extern void __osTimerInterrupt(void);
26 | extern u32 __osProbeTLB(void *);
27 | extern int __osSpDeviceBusy(void);
28 |
29 | extern OSThread *__osRunningThread;
30 | extern OSThread *__osActiveQueue;
31 | extern OSThread *__osFaultedThread;
32 | extern OSThread *__osRunQueue;
33 |
34 | extern OSTimer *__osTimerList;
35 | extern OSTimer __osBaseTimer;
36 | extern OSTime __osCurrentTime;
37 | extern u32 __osBaseCounter;
38 | extern u32 __osViIntrCount;
39 | extern u32 __osTimerCounter;
40 | extern u32 __osShutdown;
41 |
42 | extern OSMesgQueue __osProfTimerQ;
43 | extern OSProf *__osProfileList;
44 | extern OSProf *__osProfileListEnd;
45 | extern u32 __osProfileOverflowBin;
46 |
47 | extern __OSEventState __osEventStateTab[];
48 |
49 |
50 | extern void __osTimerServicesInit(void);
51 | extern s32 __osAiDeviceBusy(void);
52 | extern int __osDpDeviceBusy(void);
53 |
54 | #ifndef _FINALROM
55 | extern void* __printfunc;
56 | #endif
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------
/include/prevent_bss_reordering2.h:
--------------------------------------------------------------------------------
1 | #ifndef PREVENT_BSS_REORDERING2_H
2 | #define PREVENT_BSS_REORDERING2_H
3 |
4 | /**
5 | * See the explanation at prevent_bss_reordering.h
6 | *
7 | * Instead of producing 64 dummy declarations, this header only produces 32
8 | * dummy declarations
9 | */
10 |
11 | struct Dummy100 { int x; };
12 | struct Dummy101 { int x; };
13 | struct Dummy102 { int x; };
14 | struct Dummy103 { int x; };
15 | struct Dummy104 { int x; };
16 | struct Dummy105 { int x; };
17 | struct Dummy106 { int x; };
18 | struct Dummy107 { int x; };
19 | struct Dummy108 { int x; };
20 | struct Dummy109 { int x; };
21 | struct Dummy110 { int x; };
22 | struct Dummy111 { int x; };
23 | struct Dummy112 { int x; };
24 | struct Dummy113 { int x; };
25 | struct Dummy114 { int x; };
26 | struct Dummy115 { int x; };
27 | struct Dummy116 { int x; };
28 | struct Dummy117 { int x; };
29 | struct Dummy118 { int x; };
30 | struct Dummy119 { int x; };
31 | struct Dummy120 { int x; };
32 | struct Dummy121 { int x; };
33 | struct Dummy122 { int x; };
34 | struct Dummy123 { int x; };
35 | struct Dummy124 { int x; };
36 | struct Dummy125 { int x; };
37 | struct Dummy126 { int x; };
38 | struct Dummy127 { int x; };
39 | struct Dummy128 { int x; };
40 | struct Dummy129 { int x; };
41 | struct Dummy130 { int x; };
42 | struct Dummy131 { int x; };
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/include/prevent_bss_reordering3.h:
--------------------------------------------------------------------------------
1 | #ifndef PREVENT_BSS_REORDERING3_H
2 | #define PREVENT_BSS_REORDERING3_H
3 |
4 | /**
5 | * See the explanation at prevent_bss_reordering.h
6 | *
7 | * Instead of producing 64 dummy declarations, this header only produces 32
8 | * dummy declarations
9 | */
10 |
11 | struct Dummy200 { int x; };
12 | struct Dummy201 { int x; };
13 | struct Dummy202 { int x; };
14 | struct Dummy203 { int x; };
15 | struct Dummy204 { int x; };
16 | struct Dummy205 { int x; };
17 | struct Dummy206 { int x; };
18 | struct Dummy207 { int x; };
19 | struct Dummy208 { int x; };
20 | struct Dummy209 { int x; };
21 | struct Dummy210 { int x; };
22 | struct Dummy211 { int x; };
23 | struct Dummy212 { int x; };
24 | struct Dummy213 { int x; };
25 | struct Dummy214 { int x; };
26 | struct Dummy215 { int x; };
27 |
28 | #endif
29 |
--------------------------------------------------------------------------------
/include/sf64_tagging.h:
--------------------------------------------------------------------------------
1 | #ifndef SF64_TAGGING
2 | #define SF64_TAGGING
3 |
4 | /* For dynamic actors */
5 | #define TAG_ADDRESS(ptr) ((u32) (ptr) & 0x0FFFFFFF)
6 |
7 | /*
8 | X XXX XX XX
9 | TYPE ID INDEX CUSTOM
10 | */
11 | #define TAG_OBJ(ptr) (((((ptr)->obj.id) << 16) & 0x0FFF0000) | ((((ptr)->index) << 8) & 0x0000FF00))
12 |
13 | /* Actor Types */
14 | #define TAG_ACTOR(actor) ((u32) (0x10000000 | (TAG_OBJ(actor))))
15 | #define TAG_ACTOR_EVENT(actor) ((u32) (0x20000000 | (TAG_OBJ(actor))))
16 | #define TAG_ACTOR_EVENT_COMMON(actor) ((u32) (0x90000000 | (TAG_OBJ(actor))))
17 | #define TAG_BOSS(boss) ((u32) (0x30000000 | (TAG_OBJ(boss))))
18 | #define TAG_SCENERY(scenery) ((u32) (0x40000000 | (TAG_OBJ(scenery))))
19 | #define TAG_SCENERY_360(scenery360) ((u32) (0x50000000 | (TAG_ADDRESS(scenery360))))
20 | #define TAG_EFFECT(effect) ((u32) (0x60000000 | (TAG_OBJ(effect))))
21 | #define TAG_ITEM(item) ((u32) (0x70000000 | (TAG_OBJ(item))))
22 | #define TAG_PLAYER_SHOT(shot) ((u32) (0xC0000000 | (TAG_OBJ(shot))))
23 |
24 | /* Skeletons */
25 | #define TAG_LIMB_ADDRESS(ptr, data) ((((u32) (ptr) << 16) & 0xFFFF0000) | ((u32) (data) & 0x0000FFFF))
26 | #define TAG_LIMB(limb, data) ((u32) (0x80000000 | (TAG_LIMB_ADDRESS(limb, data))))
27 |
28 | /* Others */
29 | #define TAG_ARWING_SKEL(arwing) (0xB0000000 | (((u32) (arwing) << 16) & 0x0FFF0000))
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/include/siint.h:
--------------------------------------------------------------------------------
1 | #ifndef _SIINT_H
2 | #define _SIINT_H
3 |
4 | #include "PR/os_internal.h"
5 | #include "PR/rcp.h"
6 |
7 | extern s32 __osEepromRead16K;
8 | extern u8 __osPfsInodeCacheBank;
9 |
10 | void __osSiGetAccess(void);
11 | void __osSiRelAccess(void);
12 | int __osSiDeviceBusy(void);
13 | void __osSiCreateAccessQueue(void);
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/linker_scripts/jp/rev0/symbol_addrs_overlays.txt:
--------------------------------------------------------------------------------
1 | OvlI1_CallFunction = 0x8017E7A0;//segment:ovl_i1
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/logo.png
--------------------------------------------------------------------------------
/nx-logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/nx-logo.jpg
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow0
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow1
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow2
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow3
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow4
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow5
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow6:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow6
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow7:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow7
--------------------------------------------------------------------------------
/port/assets/textures/hud/sBoostGaugeArrow8:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HarbourMasters/Starship/5b88c42f65689a6da9bfb5f4a0254846710155ad/port/assets/textures/hud/sBoostGaugeArrow8
--------------------------------------------------------------------------------
/properties.h.in:
--------------------------------------------------------------------------------
1 |
2 | #define VER_FILEVERSION @CMAKE_PROJECT_VERSION_MAJOR@, @CMAKE_PROJECT_VERSION_MINOR@, @CMAKE_PROJECT_VERSION_PATCH@, 0
3 | #define VER_FILEVERSION_STR "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@\0"
4 |
5 | #define VER_PRODUCTVERSION @CMAKE_PROJECT_VERSION_MAJOR@, @CMAKE_PROJECT_VERSION_MINOR@, @CMAKE_PROJECT_VERSION_PATCH@, 0
6 | #define VER_PRODUCTVERSION_str "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@\0"
7 |
8 | #define VER_COMPANYNAME_STR "@PROJECT_TEAM@\0"
9 | #define VER_PRODUCTNAME_STR "Starship\0"
10 |
11 | #define VER_INTERNALNAME_STR "@PROJECT_NAME@\0"
12 | #define VER_ORIGINALFILENAME_STR "@PROJECT_NAME@.exe\0"
13 |
14 | #define VER_FILEDESCRIPTION_STR "Starship - @PROJECT_BUILD_NAME@\0"
15 |
--------------------------------------------------------------------------------
/src/buffers.c:
--------------------------------------------------------------------------------
1 | #include "sys.h"
2 |
3 | u8 gOSYieldData[OS_YIELD_DATA_SIZE];
4 | FrameBuffer gZBuffer; // z buffer
5 | u8 gTaskOutputBuffer[0x30000];
6 | u8 gAudioHeap[0x15FC00];
7 | u16 gTextureRenderBuffer[0x3C40];
8 | u16 gFillBuffer[3 * SCREEN_WIDTH];
9 | FrameBuffer gFrameBuffers[3];
10 |
--------------------------------------------------------------------------------
/src/driverominit.c:
--------------------------------------------------------------------------------
1 | #include "sys.h"
2 |
3 | OSPiHandle* osDriveRomInit(void) {
4 | }
5 |
--------------------------------------------------------------------------------
/src/engine/fox_blur.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | /*
4 | * File: fox_blur.c
5 | * System: Blur
6 | * Description: Some unused blurring code.
7 | */
8 |
9 | void func_blur_800846F0(FrameBuffer* arg0) {
10 | s32 i;
11 | s32 j;
12 | u16* var_v0;
13 | s32 sp60[5];
14 | s32 sp4C[5];
15 | s32 sp38[5];
16 |
17 | for (i = 0; i < gSysFrameCount % SCREEN_HEIGHT; i++) {
18 | var_v0 = SCREEN_WIDTH * i + arg0->data;
19 | for (j = 0; j < gSysFrameCount % SCREEN_WIDTH; j++, var_v0++) {
20 | sp60[1] = RGBA16_RED(var_v0[0]);
21 | sp4C[1] = RGBA16_GRN(var_v0[0]);
22 | sp38[1] = RGBA16_BLU(var_v0[0]);
23 |
24 | sp60[2] = RGBA16_RED(var_v0[1]);
25 | sp4C[2] = RGBA16_GRN(var_v0[1]);
26 | sp38[2] = RGBA16_BLU(var_v0[1]);
27 |
28 | sp60[3] = RGBA16_RED(var_v0[SCREEN_WIDTH]);
29 | sp4C[3] = RGBA16_GRN(var_v0[SCREEN_WIDTH]);
30 | sp38[3] = RGBA16_BLU(var_v0[SCREEN_WIDTH]);
31 |
32 | sp60[4] = RGBA16_RED(var_v0[SCREEN_WIDTH + 1]);
33 | sp4C[4] = RGBA16_GRN(var_v0[SCREEN_WIDTH + 1]);
34 | sp38[4] = RGBA16_BLU(var_v0[SCREEN_WIDTH + 1]);
35 |
36 | sp60[0] = (sp60[1] + sp60[2] + sp60[3] + sp60[4]) / 4;
37 | sp4C[0] = (sp4C[1] + sp4C[2] + sp4C[3] + sp4C[4]) / 4;
38 | sp38[0] = (sp38[1] + sp38[2] + sp38[3] + sp38[4]) / 4;
39 |
40 | var_v0[0] = (sp60[0] << 11) | (sp4C[0] << 6) | (sp38[0] << 1);
41 | }
42 | }
43 | osWritebackDCacheAll();
44 | }
45 |
--------------------------------------------------------------------------------
/src/engine/fox_edata.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | #include "fox_edata_info.c"
4 |
5 | f32* D_edata_800CF964[] = { NULL }; // Likely a scrapped array of scenery shadow boxes
6 |
7 | void Ve1Wall1_Draw(Ve1Wall1* this) {
8 | RCP_SetupDL_57(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
9 | Matrix_RotateY(gGfxMatrix, M_PI, MTXF_APPLY);
10 | Matrix_SetGfxMtx(&gMasterDisp);
11 | gSPDisplayList(gMasterDisp++, aVe1Wall1DL);
12 | RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
13 | }
14 |
15 | void Ve1Wall2_Draw(Ve1Wall2* this) {
16 | RCP_SetupDL_57(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
17 | Matrix_RotateY(gGfxMatrix, M_PI, MTXF_APPLY);
18 | Matrix_SetGfxMtx(&gMasterDisp);
19 | gSPDisplayList(gMasterDisp++, aVe1Wall2DL);
20 | RCP_SetupDL_29(gFogRed, gFogGreen, gFogBlue, gFogAlpha, gFogNear, gFogFar);
21 | }
22 |
23 | void AndJamesTrigger_Draw(AndJamesTrigger* this) {
24 | /* Unimplemented */
25 | }
26 |
--------------------------------------------------------------------------------
/src/engine/fox_msg_palette.c:
--------------------------------------------------------------------------------
1 | #include "gfx.h"
2 |
3 | // clang-format off
4 |
5 | u16 gTextCharPalettes[4][16] = {
6 | {
7 | 0x0000, 0xFFFF, 0x0000, 0xFFFF,
8 | 0x0000, 0xFFFF, 0x0000, 0xFFFF,
9 | 0x0000, 0xFFFF, 0x0000, 0xFFFF,
10 | 0x0000, 0xFFFF, 0x0000, 0xFFFF,
11 | },
12 | {
13 | 0x0000, 0x0000, 0xFFFF, 0xFFFF,
14 | 0x0000, 0x0000, 0xFFFF, 0xFFFF,
15 | 0x0000, 0x0000, 0xFFFF, 0xFFFF,
16 | 0x0000, 0x0000, 0xFFFF, 0xFFFF,
17 | },
18 | {
19 | 0x0000, 0x0000, 0x0000, 0x0000,
20 | 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
21 | 0x0000, 0x0000, 0x0000, 0x0000,
22 | 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
23 | },
24 | {
25 | 0x0000, 0x0000, 0x0000, 0x0000,
26 | 0x0000, 0x0000, 0x0000, 0x0000,
27 | 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
28 | 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
29 | }
30 | };
31 |
32 | // clang-format on
33 |
--------------------------------------------------------------------------------
/src/engine/fox_rcp_init.c:
--------------------------------------------------------------------------------
1 | #include "gfx.h"
2 |
3 | Gfx gRcpInitDL[] = {
4 | gsDPPipeSync(),
5 | gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN |
6 | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
7 | gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
8 | gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
9 | gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH),
10 | gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 3, G_AC_NONE | G_ZS_PIXEL),
11 | gsDPSetRenderMode(G_RM_NOOP, G_RM_NOOP2),
12 | gsSPSetOtherModeHi(G_AD_NOISE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
13 | G_TD_CLAMP | G_TP_PERSP | G_CYC_FILL | G_PM_NPRIMITIVE),
14 | gsSPClipRatio(FRUSTRATIO_1),
15 | gsSPEndDisplayList(),
16 | };
17 |
--------------------------------------------------------------------------------
/src/engine/guPerspectiveF.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "libc/math.h"
4 |
5 | void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
6 | float yscale;
7 | int row;
8 | int col;
9 | guMtxIdentF(mf);
10 | fovy *= GU_PI / 180.0;
11 | yscale = __cosf(fovy / 2) / __sinf(fovy / 2);
12 | mf[0][0] = yscale / aspect;
13 | mf[1][1] = yscale;
14 | mf[2][2] = (near + far) / (near - far);
15 | mf[2][3] = -1;
16 | mf[3][2] = 2 * near * far / (near - far);
17 | mf[3][3] = 0.0f;
18 | for (row = 0; row < 4; row++) {
19 | for (col = 0; col < 4; col++) {
20 | mf[row][col] *= scale;
21 | }
22 | }
23 | if (perspNorm != NULL) {
24 | if (near + far <= 2.0) {
25 | *perspNorm = 65535;
26 | } else {
27 | *perspNorm = (double) (1 << 17) / (near + far);
28 | if (*perspNorm <= 0) {
29 | *perspNorm = 1;
30 | }
31 | }
32 | }
33 | }
34 |
35 | void guPerspective(Mtx* m, u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
36 | float mat[4][4];
37 | guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale);
38 | guMtxF2L(mat, m);
39 | }
40 |
--------------------------------------------------------------------------------
/src/libc_sprintf.c:
--------------------------------------------------------------------------------
1 | #include "sys.h"
2 |
3 | char D_800C7C80[] = "$Id: sprintf.c,v 1.5 1997/03/19 02:28:53 hayakawa Exp $";
4 |
5 | char* proutSprintf(char* dst, const char* fmt, size_t size) {
6 | return (char*) ((uintptr_t) memcpy(dst, fmt, size) + size);
7 | }
8 |
9 | // s32 vsprintf(char* dst, const char* fmt, va_list args) {
10 | // s32 ret = _Printf((outfun*) proutSprintf, dst, fmt, args);
11 | //
12 | // if (ret > -1) {
13 | // dst[ret] = 0;
14 | // }
15 | // return ret;
16 | // }
17 | //
18 | // int sprintf(char* s, const char* fmt, ...) {
19 | // s32 ret;
20 | // va_list args;
21 | // va_start(args, fmt);
22 | //
23 | // ret = _Printf((outfun*) proutSprintf, s, fmt, args);
24 | //
25 | // if (ret >= 0) {
26 | // s[ret] = 0;
27 | // }
28 | // va_end(args);
29 | //
30 | // return ret;
31 | // }
32 |
--------------------------------------------------------------------------------
/src/libultra/gcc_fix/__floatundisf.c:
--------------------------------------------------------------------------------
1 | #ifdef COMPILER_GCC
2 |
3 | typedef union DoubleFloatUnion {
4 | double d;
5 | long long int ll;
6 | unsigned long long ull;
7 | } DoubleFloatUnion;
8 |
9 | /**
10 | * Gets float32 from uint64_t.
11 | *
12 | * https://gcc.gnu.org/onlinedocs/gccint/the-gcc-low-level-runtime-library/routines-for-floating-point-emulation.html#c.__floatundisf
13 | */
14 | float __floatundisf(unsigned long long i) {
15 | register DoubleFloatUnion dull;
16 | register float ret;
17 |
18 | dull.ull = i;
19 | __asm__("cvt.s.l %0, %1" : "=f"(ret) : "f"(dull.d));
20 | if ((long) i < 0) {
21 | // cvt.s.l assumes signed input, adjust output
22 | ret += 4294967296.0f; // 2^32
23 | }
24 |
25 | return ret;
26 | }
27 | #endif
28 |
--------------------------------------------------------------------------------
/src/libultra/gu/ortho.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale) {
4 | int i;
5 | int j;
6 |
7 | guMtxIdentF(mf);
8 |
9 | mf[0][0] = 2 / (r - l);
10 | mf[1][1] = 2 / (t - b);
11 | mf[2][2] = -2 / (f - n);
12 | mf[3][0] = -(r + l) / (r - l);
13 | mf[3][1] = -(t + b) / (t - b);
14 | mf[3][2] = -(f + n) / (f - n);
15 | mf[3][3] = 1;
16 |
17 | for (i = 0; i < 4; i++) {
18 | for (j = 0; j < 4; j++) {
19 | mf[i][j] *= scale;
20 | }
21 | }
22 | }
23 |
24 | void guOrtho(Mtx* m, float l, float r, float b, float t, float n, float f, float scale) {
25 | float mf[4][4];
26 |
27 | guOrthoF(mf, l, r, b, t, n, f, scale);
28 |
29 | guMtxF2L(mf, m);
30 | }
31 |
--------------------------------------------------------------------------------
/src/libultra/gu/sqrtf.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "math.h"
3 |
4 | #ifdef COMPILER_GCC
5 | #include "src/libultra/gcc_fix/sqrtf.c.inc"
6 | #endif
7 |
8 | f32 guSqrtf(f32 value) {
9 | return sqrtf(value);
10 | }
11 |
--------------------------------------------------------------------------------
/src/libultra/host/readhost.c:
--------------------------------------------------------------------------------
1 | #ifndef _FINALROM
2 |
3 | #include "PR/os_internal.h"
4 | #include "PR/rdb.h"
5 |
6 | #include "macros.h"
7 |
8 | static int readHostInitialized = FALSE;
9 | static OSMesgQueue readHostMesgQueue ALIGNED(8);
10 | static OSMesg readHostMesgBuf[1];
11 |
12 | u32 __osRdb_Read_Data_Buf;
13 | u32 __osRdb_Read_Data_Ct;
14 |
15 | void osReadHost(void* dramAddr, u32 nbytes) {
16 | char tstr[4];
17 | u32 sent = 0;
18 |
19 | if (!readHostInitialized) {
20 | osCreateMesgQueue(&readHostMesgQueue, readHostMesgBuf, ARRLEN(readHostMesgBuf));
21 | osSetEventMesg(OS_EVENT_RDB_READ_DONE, &readHostMesgQueue, NULL);
22 | readHostInitialized = TRUE;
23 | }
24 |
25 | __osRdb_Read_Data_Buf = dramAddr;
26 | __osRdb_Read_Data_Ct = nbytes;
27 |
28 | while (sent == 0) {
29 | sent += __osRdbSend(tstr, 1, RDB_TYPE_GtoH_READY_FOR_DATA);
30 | }
31 |
32 | osRecvMesg(&readHostMesgQueue, NULL, OS_MESG_BLOCK);
33 | return;
34 | }
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/src/libultra/io/ai.c:
--------------------------------------------------------------------------------
1 | #include "stdbool.h"
2 | #include "PR/rcp.h"
3 |
4 | s32 __osAiDeviceBusy(void) {
5 | register s32 status = IO_READ(AI_STATUS_REG);
6 |
7 | if (status & AI_STATUS_FIFO_FULL) {
8 | return true;
9 | } else {
10 | return false;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/libultra/io/aigetlen.c:
--------------------------------------------------------------------------------
1 | #include "PR/rcp.h"
2 |
3 | u32 osAiGetLength() {
4 | return IO_READ(AI_LEN_REG);
5 | }
6 |
--------------------------------------------------------------------------------
/src/libultra/io/aisetfreq.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | s32 osViClock2 = 0x02E6D354;
4 |
5 | s32 osAiSetFrequency(u32 freq) {
6 | return 1;
7 |
8 | register u32 a1;
9 | register s32 a2;
10 | register float ftmp;
11 | ftmp = osViClock2 / (float) freq + .5f;
12 |
13 | a1 = ftmp;
14 |
15 | if (a1 < 0x84) {
16 | return -1;
17 | }
18 |
19 | a2 = (a1 / 66) & 0xff;
20 | if (a2 > 16) {
21 | a2 = 16;
22 | }
23 |
24 | IO_WRITE(AI_DACRATE_REG, a1 - 1);
25 | IO_WRITE(AI_BITRATE_REG, a2 - 1);
26 | IO_WRITE(AI_CONTROL_REG, AI_CONTROL_DMA_ON); // enable dma
27 | return osViClock2 / (s32) a1;
28 | }
29 |
--------------------------------------------------------------------------------
/src/libultra/io/aisetnextbuf.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "PR/rcp.h"
4 | #include "osint.h"
5 |
6 | s32 osAiSetNextBuffer(void* bufPtr, u32 size) {
7 | static u8 hdwrBugFlag = FALSE;
8 | char* bptr;
9 |
10 | #if BUILD_VERSION >= VERSION_J
11 | if (__osAiDeviceBusy()) {
12 | return -1;
13 | }
14 | #endif
15 |
16 | #ifdef _DEBUG
17 | if ((u32) bufPtr & (8 - 1)) {
18 | __osError(ERR_OSAISETNEXTBUFFER_ADDR, 1, bufPtr);
19 | return -1;
20 | }
21 |
22 | if ((u32) size & (8 - 1)) {
23 | __osError(ERR_OSAISETNEXTBUFFER_SIZE, 1, size);
24 | return -1;
25 | }
26 | #endif
27 |
28 | bptr = bufPtr;
29 |
30 | if (hdwrBugFlag) {
31 | bptr = (u8*) bufPtr - 0x2000;
32 | }
33 |
34 | if ((((u32) bufPtr + size) & 0x3fff) == 0x2000) {
35 | hdwrBugFlag = TRUE;
36 | } else {
37 | hdwrBugFlag = FALSE;
38 | }
39 |
40 | #if BUILD_VERSION < VERSION_J
41 | if (__osAiDeviceBusy()) {
42 | return -1;
43 | }
44 | #endif
45 |
46 | IO_WRITE(AI_DRAM_ADDR_REG, osVirtualToPhysical(bptr));
47 | IO_WRITE(AI_LEN_REG, size);
48 | return 0;
49 | }
50 |
--------------------------------------------------------------------------------
/src/libultra/io/conteepprobe.c:
--------------------------------------------------------------------------------
1 | #include "PR/controller.h"
2 | #include "siint.h"
3 |
4 | s32 osEepromProbe(OSMesgQueue* mq) {
5 | s32 status = 0;
6 | OSContStatus sdata;
7 |
8 | __osSiGetAccess();
9 |
10 | status = __osEepStatus(mq, &sdata);
11 | if (status == 0 && (sdata.type & 0x8000) != 0) {
12 | status = 1;
13 | } else {
14 | status = 0;
15 | }
16 |
17 | __osSiRelAccess();
18 | return status;
19 | }
20 |
--------------------------------------------------------------------------------
/src/libultra/io/contquery.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/controller.h"
3 | #include "siint.h"
4 |
5 | s32 osContStartQuery(OSMesgQueue* mq) {
6 | s32 ret = 0;
7 |
8 | __osSiGetAccess();
9 |
10 | if (__osContLastCmd != CONT_CMD_REQUEST_STATUS) {
11 | __osPackRequestData(CONT_CMD_REQUEST_STATUS);
12 | ret = __osSiRawStartDma(OS_WRITE, __osContPifRam.ramarray);
13 | osRecvMesg(mq, NULL, OS_MESG_BLOCK);
14 | }
15 |
16 | ret = __osSiRawStartDma(OS_READ, __osContPifRam.ramarray);
17 | __osContLastCmd = CONT_CMD_REQUEST_STATUS;
18 | __osSiRelAccess();
19 | return ret;
20 | }
21 |
22 | void osContGetQuery(OSContStatus* data) {
23 | u8 pattern;
24 | __osContGetInitData(&pattern, data);
25 | }
26 |
--------------------------------------------------------------------------------
/src/libultra/io/dpsetstat.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | void osDpSetStatus(u32 data) {
8 | IO_WRITE(DPC_STATUS_REG, data);
9 | }
10 |
--------------------------------------------------------------------------------
/src/libultra/io/epirawdma.c:
--------------------------------------------------------------------------------
1 | #include "piint.h"
2 | #include "PR/ultraerror.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | s32 __osEPiRawStartDma(OSPiHandle* pihandle, s32 direction, u32 devAddr, void* dramAddr, u32 size) {
8 | u32 stat;
9 | u32 domain;
10 |
11 | #ifdef _DEBUG
12 | if ((direction != OS_READ) && (direction != OS_WRITE)) {
13 | __osError(ERR_OSPIRAWSTARTDMA_DIR, 1, direction);
14 | return -1;
15 | }
16 |
17 | if (devAddr & 0x1) {
18 | __osError(ERR_OSPIRAWSTARTDMA_DEVADDR, 1, devAddr);
19 | return -1;
20 | }
21 |
22 | if ((u32) dramAddr & 0x7) {
23 | __osError(ERR_OSPIRAWSTARTDMA_ADDR, 1, dramAddr);
24 | return -1;
25 | }
26 |
27 | if (size & 0x1) {
28 | __osError(ERR_OSPIRAWSTARTDMA_SIZE, 1, size);
29 | return -1;
30 | }
31 |
32 | if ((size == 0) || (size > (16 * 1024 * 1024))) {
33 | __osError(ERR_OSPIRAWSTARTDMA_RANGE, 1, size);
34 | return -1;
35 | }
36 | #endif
37 |
38 | EPI_SYNC(pihandle, stat, domain);
39 | IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
40 | IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS(pihandle->baseAddress | devAddr));
41 |
42 | switch (direction) {
43 | case OS_READ:
44 | IO_WRITE(PI_WR_LEN_REG, size - 1);
45 | break;
46 | case OS_WRITE:
47 | IO_WRITE(PI_RD_LEN_REG, size - 1);
48 | break;
49 | default:
50 | return -1;
51 | }
52 | return 0;
53 | }
54 |
--------------------------------------------------------------------------------
/src/libultra/io/epirawread.c:
--------------------------------------------------------------------------------
1 | #include "piint.h"
2 | #include "PR/ultraerror.h"
3 | #include "PR/assert.h"
4 |
5 | // Adjust line numbers to match assert
6 | #if BUILD_VERSION < VERSION_J
7 | #line 28
8 | #endif
9 |
10 | // TODO: this comes from a header
11 | #ident "$Revision: 1.17 $"
12 |
13 | s32 __osEPiRawReadIo(OSPiHandle* pihandle, u32 devAddr, u32* data) {
14 | register u32 stat;
15 | register u32 domain;
16 |
17 | #ifdef _DEBUG
18 | if (devAddr & 0x3) {
19 | __osError(ERR_OSPIRAWREADIO, 1, devAddr);
20 | return -1;
21 | }
22 | #endif
23 | assert(data != NULL);
24 |
25 | WAIT_ON_IOBUSY(stat);
26 | *data = IO_READ(pihandle->baseAddress | devAddr);
27 |
28 | return 0;
29 | }
30 |
--------------------------------------------------------------------------------
/src/libultra/io/epirawwrite.c:
--------------------------------------------------------------------------------
1 | #include "piint.h"
2 | #include "PR/ultraerror.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | s32 __osEPiRawWriteIo(OSPiHandle* pihandle, u32 devAddr, u32 data) {
8 | register u32 stat;
9 | register u32 domain;
10 |
11 | #ifdef _DEBUG
12 | if (devAddr & 0x3) {
13 | __osError(ERR_OSPIRAWWRITEIO, 1, devAddr);
14 | return -1;
15 | }
16 | #endif
17 |
18 | WAIT_ON_IOBUSY(stat);
19 | IO_WRITE(pihandle->baseAddress | devAddr, data);
20 |
21 | return 0;
22 | }
23 |
--------------------------------------------------------------------------------
/src/libultra/io/leodiskinit.c:
--------------------------------------------------------------------------------
1 | // This file was removed in 2.0J
2 | #include "PR/os_internal.h"
3 | #include "PR/os_libc.h"
4 | #include "PR/rcp.h"
5 | #include "macros.h"
6 |
7 | OSPiHandle LeoDiskHandle ALIGNED(8);
8 | OSPiHandle* __osDiskHandle;
9 |
10 | OSPiHandle* osLeoDiskInit() {
11 | u32 saveMask;
12 |
13 | LeoDiskHandle.type = DEVICE_TYPE_64DD;
14 | LeoDiskHandle.baseAddress = PHYS_TO_K1(PI_DOM2_ADDR1);
15 | LeoDiskHandle.latency = 3;
16 | LeoDiskHandle.pulse = 6;
17 | LeoDiskHandle.pageSize = 6;
18 | LeoDiskHandle.relDuration = 2;
19 | LeoDiskHandle.domain = PI_DOMAIN2;
20 |
21 | IO_WRITE(PI_BSD_DOM2_LAT_REG, LeoDiskHandle.latency);
22 | IO_WRITE(PI_BSD_DOM2_PWD_REG, LeoDiskHandle.pulse);
23 | IO_WRITE(PI_BSD_DOM2_PGS_REG, LeoDiskHandle.pageSize);
24 | IO_WRITE(PI_BSD_DOM2_RLS_REG, LeoDiskHandle.relDuration);
25 | #if BUILD_VERSION >= VERSION_I
26 | LeoDiskHandle.speed = 0;
27 | #endif
28 |
29 | bzero(&LeoDiskHandle.transferInfo, sizeof(__OSTranxInfo));
30 |
31 | saveMask = __osDisableInt();
32 | LeoDiskHandle.next = __osPiTable;
33 | __osPiTable = &LeoDiskHandle;
34 | __osDiskHandle = &LeoDiskHandle;
35 | __osRestoreInt(saveMask);
36 |
37 | return &LeoDiskHandle;
38 | }
39 |
--------------------------------------------------------------------------------
/src/libultra/io/pfsgetstatus.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/controller.h"
3 | #include "siint.h"
4 |
5 | s32 __osPfsGetStatus(OSMesgQueue* queue, int channel) {
6 | s32 ret = 0;
7 | OSMesg dummy;
8 | u8 pattern;
9 | OSContStatus status[4];
10 |
11 | __osPfsRequestData(CONT_CMD_REQUEST_STATUS);
12 | ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
13 | osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
14 | ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
15 | osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
16 | __osPfsGetInitData(&pattern, status);
17 |
18 | if (status[channel].status & CONT_CARD_ON && status[channel].status & CONT_CARD_PULL) {
19 | return 2;
20 | }
21 | if (status[channel].errno || !(status[channel].status & CONT_CARD_ON)) {
22 | return 1;
23 | }
24 | if (status[channel].status & CONT_ADDR_CRC_ER) {
25 | return 4;
26 | }
27 | return ret;
28 | }
29 |
--------------------------------------------------------------------------------
/src/libultra/io/piacs.c:
--------------------------------------------------------------------------------
1 | #include "macros.h"
2 | #include "PR/os_internal.h"
3 |
4 | #define PI_Q_BUF_LEN 1
5 | u32 __osPiAccessQueueEnabled = 0;
6 | OSMesg piAccessBuf[PI_Q_BUF_LEN];
7 | OSMesgQueue __osPiAccessQueue ALIGNED(8);
8 |
9 | void __osPiCreateAccessQueue(void) {
10 | __osPiAccessQueueEnabled = 1;
11 | osCreateMesgQueue(&__osPiAccessQueue, piAccessBuf, PI_Q_BUF_LEN);
12 | osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK);
13 | }
14 |
15 | void __osPiGetAccess(void) {
16 | OSMesg dummyMesg;
17 | if (!__osPiAccessQueueEnabled) {
18 | __osPiCreateAccessQueue();
19 | }
20 | osRecvMesg(&__osPiAccessQueue, &dummyMesg, OS_MESG_BLOCK);
21 | }
22 |
23 | void __osPiRelAccess(void) {
24 | osSendMesg(&__osPiAccessQueue, NULL, OS_MESG_NOBLOCK);
25 | }
26 |
--------------------------------------------------------------------------------
/src/libultra/io/pidma.c:
--------------------------------------------------------------------------------
1 | #include "piint.h"
2 |
3 | s32 osPiStartDma(OSIoMesg* mb, s32 pri, s32 rw, u32 devAddr, void* dramAddr, u32 size, OSMesgQueue* piHandle) {
4 | register s32 result;
5 |
6 | if (!__osPiDevMgr.active) {
7 | return -1;
8 | }
9 |
10 | if (rw == OS_READ) {
11 | mb->hdr.type = OS_MESG_TYPE_DMAREAD;
12 | } else {
13 | mb->hdr.type = OS_MESG_TYPE_DMAWRITE;
14 | }
15 |
16 | mb->hdr.pri = pri;
17 | mb->hdr.retQueue = piHandle;
18 | mb->dramAddr = dramAddr;
19 | mb->devAddr = devAddr;
20 | mb->size = size;
21 | mb->piHandle = NULL;
22 |
23 | if (pri == OS_MESG_PRI_HIGH) {
24 | result = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK);
25 | } else {
26 | result = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK);
27 | }
28 | return result;
29 | }
30 |
--------------------------------------------------------------------------------
/src/libultra/io/pigetcmdq.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "piint.h"
3 |
4 | OSMesgQueue* osPiGetCmdQueue(void) {
5 | if (!__osPiDevMgr.active) {
6 | return NULL;
7 | } else {
8 | return __osPiDevMgr.cmdQueue;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/src/libultra/io/pirawdma.c:
--------------------------------------------------------------------------------
1 | #include "piint.h"
2 | #include "PR/ultraerror.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) {
8 | register u32 stat;
9 |
10 | #ifdef _DEBUG
11 | if ((direction != OS_READ) && (direction != OS_WRITE)) {
12 | __osError(ERR_OSPIRAWSTARTDMA_DIR, 1, direction);
13 | return -1;
14 | }
15 |
16 | if (devAddr & 0x1) {
17 | __osError(ERR_OSPIRAWSTARTDMA_DEVADDR, 1, devAddr);
18 | return -1;
19 | }
20 |
21 | if ((u32) dramAddr & 0x7) {
22 | __osError(ERR_OSPIRAWSTARTDMA_ADDR, 1, dramAddr);
23 | return -1;
24 | }
25 |
26 | if (size & 0x1) {
27 | __osError(ERR_OSPIRAWSTARTDMA_SIZE, 1, size);
28 | return -1;
29 | }
30 |
31 | if ((size == 0) || (size > (16 * 1024 * 1024))) {
32 | __osError(ERR_OSPIRAWSTARTDMA_RANGE, 1, size);
33 | return -1;
34 | }
35 | #endif
36 |
37 | WAIT_ON_IOBUSY(stat);
38 |
39 | IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
40 | IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS((u32) osRomBase | devAddr));
41 |
42 | switch (direction) {
43 | case OS_READ:
44 | IO_WRITE(PI_WR_LEN_REG, size - 1);
45 | break;
46 | case OS_WRITE:
47 | IO_WRITE(PI_RD_LEN_REG, size - 1);
48 | break;
49 | default:
50 | return -1;
51 | }
52 | return 0;
53 | }
54 |
--------------------------------------------------------------------------------
/src/libultra/io/pirawread.c:
--------------------------------------------------------------------------------
1 | #include "PR/assert.h"
2 | #include "PR/ultraerror.h"
3 | #include "piint.h"
4 |
5 | // Adjust line numbers to match assert
6 | #if BUILD_VERSION < VERSION_J
7 | #line 46
8 | #endif
9 |
10 | // TODO: this comes from a header
11 | #ident "$Revision: 1.17 $"
12 |
13 | s32 __osPiRawReadIo(u32 devAddr, u32* data) {
14 | register u32 stat;
15 |
16 | #ifdef _DEBUG
17 | if (devAddr & 0x3) {
18 | __osError(ERR_OSPIRAWREADIO, 1, devAddr);
19 | return -1;
20 | }
21 | #endif
22 |
23 | assert(data != NULL);
24 |
25 | WAIT_ON_IOBUSY(stat);
26 | *data = IO_READ((u32) osRomBase | devAddr);
27 |
28 | return 0;
29 | }
30 |
--------------------------------------------------------------------------------
/src/libultra/io/si.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "siint.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | int __osSiDeviceBusy() {
8 | register u32 stat = IO_READ(SI_STATUS_REG);
9 |
10 | if (stat & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
11 | return TRUE;
12 | } else {
13 | return FALSE;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/libultra/io/siacs.c:
--------------------------------------------------------------------------------
1 | #include "macros.h"
2 | #include "PR/os_internal.h"
3 |
4 | #define SI_Q_BUF_LEN 1
5 | OSMesg siAccessBuf[SI_Q_BUF_LEN] ALIGNED(8);
6 | OSMesgQueue __osSiAccessQueue ALIGNED(8);
7 | u32 __osSiAccessQueueEnabled = 0;
8 |
9 | void __osSiCreateAccessQueue(void) {
10 | __osSiAccessQueueEnabled = 1;
11 | osCreateMesgQueue(&__osSiAccessQueue, siAccessBuf, SI_Q_BUF_LEN);
12 | osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK);
13 | }
14 |
15 | void __osSiGetAccess(void) {
16 | OSMesg dummyMesg;
17 | if (!__osSiAccessQueueEnabled) {
18 | __osSiCreateAccessQueue();
19 | }
20 | osRecvMesg(&__osSiAccessQueue, &dummyMesg, OS_MESG_BLOCK);
21 | }
22 |
23 | void __osSiRelAccess(void) {
24 | osSendMesg(&__osSiAccessQueue, NULL, OS_MESG_NOBLOCK);
25 | }
26 |
--------------------------------------------------------------------------------
/src/libultra/io/sirawdma.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/assert.h"
3 | #include "siint.h"
4 |
5 | // Adjust line numbers to match assert
6 | #if BUILD_VERSION < VERSION_J
7 | #line 49
8 | #endif
9 |
10 | // TODO: this comes from a header
11 | #ident "$Revision: 1.17 $"
12 |
13 | s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
14 | assert(((u32) dramAddr & 0x3) == 0);
15 |
16 | #if BUILD_VERSION >= VERSION_J
17 | if (IO_READ(SI_STATUS_REG) & (SI_STATUS_DMA_BUSY | SI_STATUS_RD_BUSY)) {
18 | return -1;
19 | }
20 | #else
21 | if (__osSiDeviceBusy()) {
22 | return -1;
23 | }
24 | #endif
25 |
26 | if (direction == OS_WRITE) {
27 | osWritebackDCache(dramAddr, 64);
28 | }
29 |
30 | IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
31 |
32 | if (direction == OS_READ) {
33 | IO_WRITE(SI_PIF_ADDR_RD64B_REG, PIF_RAM_START);
34 | } else {
35 | IO_WRITE(SI_PIF_ADDR_WR64B_REG, PIF_RAM_START);
36 | }
37 |
38 | if (direction == OS_READ) {
39 | osInvalDCache(dramAddr, 64);
40 | }
41 |
42 | return 0;
43 | }
44 |
--------------------------------------------------------------------------------
/src/libultra/io/sirawread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/assert.h"
3 | #include "siint.h"
4 |
5 | // Adjust line numbers to match assert
6 | #if BUILD_VERSION < VERSION_J
7 | #line 45
8 | #endif
9 |
10 | // TODO: this comes from a header
11 | #ident "$Revision: 1.17 $"
12 |
13 | s32 __osSiRawReadIo(u32 devAddr, u32* data) {
14 | assert((devAddr & 0x3) == 0);
15 | assert(data != NULL);
16 |
17 | if (__osSiDeviceBusy()) {
18 | return -1;
19 | }
20 |
21 | *data = IO_READ(devAddr);
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/src/libultra/io/sirawwrite.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/assert.h"
3 | #include "siint.h"
4 |
5 | // Adjust line numbers to match assert
6 | #if BUILD_VERSION < VERSION_J
7 | #line 46
8 | #endif
9 |
10 | // TODO: this comes from a header
11 | #ident "$Revision: 1.17 $"
12 |
13 | s32 __osSiRawWriteIo(u32 devAddr, u32 data) {
14 | assert((devAddr & 0x3) == 0);
15 |
16 | if (__osSiDeviceBusy()) {
17 | return -1;
18 | }
19 |
20 | IO_WRITE(devAddr, data);
21 | return 0;
22 | }
23 |
--------------------------------------------------------------------------------
/src/libultra/io/sp.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 | #include "PR/sptask.h"
4 | #include "osint.h"
5 |
6 | // TODO: this comes from a header
7 | #ident "$Revision: 1.17 $"
8 |
9 | int __osSpDeviceBusy() {
10 | register u32 stat = IO_READ(SP_STATUS_REG);
11 |
12 | if (stat & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) {
13 | return TRUE;
14 | } else {
15 | return FALSE;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/libultra/io/spgetstat.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | u32 __osSpGetStatus() {
8 | return IO_READ(SP_STATUS_REG);
9 | }
10 |
--------------------------------------------------------------------------------
/src/libultra/io/sprawdma.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/assert.h"
3 | #include "PR/rcp.h"
4 | #include "osint.h"
5 |
6 | // Adjust line numbers to match assert
7 | #if BUILD_VERSION < VERSION_J
8 | #line 52
9 | #endif
10 |
11 | // TODO: this comes from a header
12 | #ident "$Revision: 1.17 $"
13 |
14 | s32 __osSpRawStartDma(s32 direction, u32 devAddr, void* dramAddr, u32 size) {
15 | assert(((u32) devAddr & 0x7) == 0);
16 | assert(((u32) dramAddr & 0x7) == 0);
17 | assert(((u32) size & 0x7) == 0);
18 |
19 | if (__osSpDeviceBusy()) {
20 | return -1;
21 | }
22 |
23 | IO_WRITE(SP_MEM_ADDR_REG, devAddr);
24 | IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
25 |
26 | if (direction == OS_READ) {
27 | IO_WRITE(SP_WR_LEN_REG, size - 1);
28 | } else {
29 | IO_WRITE(SP_RD_LEN_REG, size - 1);
30 | }
31 |
32 | return 0;
33 | }
34 |
--------------------------------------------------------------------------------
/src/libultra/io/sprawread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 | #include "PR/assert.h"
4 | #include "osint.h"
5 |
6 | // Adjust line numbers to match assert
7 | #if BUILD_VERSION < VERSION_J
8 | #line 45
9 | #endif
10 |
11 | // TODO: this comes from a header
12 | #ident "$Revision: 1.17 $"
13 |
14 | s32 __osSpRawReadIo(u32 devAddr, u32* data) {
15 | assert((devAddr & 0x3) == 0);
16 | assert(data != NULL);
17 |
18 | if (__osSpDeviceBusy()) {
19 | return -1;
20 | }
21 |
22 | *data = IO_READ(devAddr);
23 | return 0;
24 | }
25 |
--------------------------------------------------------------------------------
/src/libultra/io/sprawwrite.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 | #include "PR/assert.h"
4 | #include "osint.h"
5 |
6 | // Adjust line numbers to match assert
7 | #if BUILD_VERSION < VERSION_J
8 | #line 45
9 | #endif
10 |
11 | // TODO: this comes from a header
12 | #ident "$Revision: 1.17 $"
13 |
14 | s32 __osSpRawWriteIo(u32 devAddr, u32 data) {
15 | assert((devAddr & 0x3) == 0);
16 |
17 | if (__osSpDeviceBusy()) {
18 | return -1;
19 | }
20 |
21 | IO_WRITE(devAddr, data);
22 | return 0;
23 | }
24 |
--------------------------------------------------------------------------------
/src/libultra/io/spsetpc.c:
--------------------------------------------------------------------------------
1 | #include "PR/rcp.h"
2 |
3 | // TODO: this comes from a header
4 | #ident "$Revision: 1.17 $"
5 |
6 | s32 __osSpSetPc(u32 pc) {
7 | register u32 status = IO_READ(SP_STATUS_REG);
8 |
9 | if (!(status & SP_STATUS_HALT)) {
10 | return -1;
11 | }
12 | IO_WRITE(SP_PC_REG, pc);
13 |
14 | return 0;
15 | }
16 |
--------------------------------------------------------------------------------
/src/libultra/io/spsetstat.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | void __osSpSetStatus(u32 data) {
8 | IO_WRITE(SP_STATUS_REG, data);
9 | }
10 |
--------------------------------------------------------------------------------
/src/libultra/io/sptaskyield.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/rcp.h"
3 |
4 | void osSpTaskYield(void) {
5 | __osSpSetStatus(SP_SET_YIELD);
6 | }
7 |
--------------------------------------------------------------------------------
/src/libultra/io/sptaskyielded.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/sptask.h"
3 | #include "PR/rcp.h"
4 |
5 | OSYieldResult osSpTaskYielded(OSTask* tp) {
6 | u32 status;
7 | OSYieldResult result;
8 |
9 | status = __osSpGetStatus();
10 | result = (status & SP_STATUS_YIELDED) ? OS_TASK_YIELDED : 0;
11 |
12 | if (status & SP_STATUS_YIELD) {
13 | tp->t.flags |= result;
14 | tp->t.flags &= ~(OS_TASK_DP_WAIT);
15 | }
16 |
17 | return result;
18 | }
19 |
--------------------------------------------------------------------------------
/src/libultra/io/vi.c:
--------------------------------------------------------------------------------
1 | #include "macros.h"
2 | #include "PR/os_internal.h"
3 | #include "PR/R4300.h"
4 | #include "PR/rcp.h"
5 | #include "PR/viint.h"
6 |
7 | // TODO: this comes from a header
8 | #ident "$Revision: 1.17 $"
9 |
10 | static __OSViContext vi[2] ALIGNED(8) = { 0 };
11 | __OSViContext* __osViCurr = &vi[0];
12 | __OSViContext* __osViNext = &vi[1];
13 |
14 | void __osViInit(void) {
15 | bzero(vi, sizeof(vi));
16 | __osViCurr = &vi[0];
17 | __osViNext = &vi[1];
18 | __osViNext->retraceCount = 1;
19 | __osViCurr->retraceCount = 1;
20 | __osViNext->framep = (void*) K0BASE;
21 | __osViCurr->framep = (void*) K0BASE;
22 |
23 | if (osTvType == OS_TV_TYPE_PAL) {
24 | __osViNext->modep = &osViModePalLan1;
25 | } else if (osTvType == OS_TV_TYPE_MPAL) {
26 | __osViNext->modep = &osViModeMpalLan1;
27 | } else {
28 | __osViNext->modep = &osViModeNtscLan1;
29 | }
30 |
31 | __osViNext->state = VI_STATE_BLACK;
32 | __osViNext->control = __osViNext->modep->comRegs.ctrl;
33 |
34 | while (IO_READ(VI_CURRENT_REG) > 10) { // wait for vsync?
35 | }
36 |
37 | IO_WRITE(VI_CONTROL_REG, 0); // pixel size blank (no data, no sync)
38 | __osViSwapContext();
39 | }
40 |
--------------------------------------------------------------------------------
/src/libultra/io/viblack.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/viint.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | void osViBlack(u8 active) {
8 | register u32 saveMask = __osDisableInt();
9 |
10 | if (active) {
11 | __osViNext->state |= VI_STATE_BLACK;
12 | } else {
13 | __osViNext->state &= ~VI_STATE_BLACK;
14 | }
15 |
16 | __osRestoreInt(saveMask);
17 | }
18 |
--------------------------------------------------------------------------------
/src/libultra/io/vigetcurrcontext.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/viint.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | __OSViContext* __osViGetCurrentContext(void) {
8 | return __osViCurr;
9 | }
10 |
--------------------------------------------------------------------------------
/src/libultra/io/virepeatline.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/viint.h"
3 |
4 | // TODO: this comes from a header
5 | #ident "$Revision: 1.17 $"
6 |
7 | void osViRepeatLine(u8 active) {
8 | register u32 saveMask = __osDisableInt();
9 |
10 | if (active) {
11 | __osViNext->state |= VI_STATE_REPEATLINE;
12 | } else {
13 | __osViNext->state &= ~VI_STATE_REPEATLINE;
14 | }
15 |
16 | __osRestoreInt(saveMask);
17 | }
18 |
--------------------------------------------------------------------------------
/src/libultra/io/visetevent.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "PR/assert.h"
4 | #include "PR/viint.h"
5 |
6 | // TODO: this comes from a header
7 | #ident "$Revision: 1.17 $"
8 |
9 | void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount) {
10 | register u32 saveMask;
11 |
12 | #ifdef _DEBUG
13 | if (!__osViDevMgr.active) {
14 | __osError(ERR_OSVISETEVENT, 0);
15 | return;
16 | }
17 |
18 | assert(mq != NULL);
19 | #endif
20 |
21 | saveMask = __osDisableInt();
22 |
23 | __osViNext->msgq = mq;
24 | __osViNext->msg = m;
25 | __osViNext->retraceCount = retraceCount;
26 | __osRestoreInt(saveMask);
27 | }
28 |
--------------------------------------------------------------------------------
/src/libultra/io/visetmode.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "PR/assert.h"
4 | #include "PR/viint.h"
5 |
6 | // TODO: this comes from a header
7 | #ident "$Revision: 1.17 $"
8 |
9 | void osViSetMode(OSViMode* modep) {
10 | register u32 saveMask;
11 |
12 | #ifdef _DEBUG
13 | if (!__osViDevMgr.active) {
14 | __osError(ERR_OSVISETMODE, 0);
15 | return;
16 | }
17 |
18 | assert(modep != NULL);
19 | #endif
20 |
21 | saveMask = __osDisableInt();
22 |
23 | __osViNext->modep = modep;
24 | __osViNext->state = VI_STATE_MODE_UPDATED;
25 | __osViNext->control = __osViNext->modep->comRegs.ctrl;
26 | __osRestoreInt(saveMask);
27 | }
28 |
--------------------------------------------------------------------------------
/src/libultra/io/viswapbuf.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "PR/assert.h"
4 | #include "PR/viint.h"
5 |
6 | // TODO: this comes from a header
7 | #ident "$Revision: 1.17 $"
8 |
9 | void osViSwapBuffer(void* frameBufPtr) {
10 | u32 saveMask;
11 |
12 | #ifdef _DEBUG
13 | if (!__osViDevMgr.active) {
14 | __osError(ERR_OSVISWAPBUFFER_VIMGR, 0);
15 | return;
16 | }
17 |
18 | assert(frameBufPtr != NULL);
19 |
20 | if ((u32) frameBufPtr & 0x3f) {
21 | __osError(ERR_OSVISWAPBUFFER_ADDR, 1, frameBufPtr);
22 | return;
23 | }
24 | #endif
25 |
26 | saveMask = __osDisableInt();
27 |
28 | __osViNext->framep = frameBufPtr;
29 | __osViNext->state |= VI_STATE_BUFFER_UPDATED;
30 | __osRestoreInt(saveMask);
31 | }
32 |
--------------------------------------------------------------------------------
/src/libultra/libc/ldiv.c:
--------------------------------------------------------------------------------
1 | #include "stdlib.h"
2 |
3 | lldiv_t lldiv(long long numer, long long denom) {
4 | lldiv_t val;
5 |
6 | val.quot = numer / denom;
7 | val.rem = numer - denom * val.quot;
8 | if ((val.quot < 0) && (val.rem > 0)) {
9 | val.quot++;
10 | val.rem -= denom;
11 | }
12 |
13 | return val;
14 | }
15 |
16 | ldiv_t ldiv(long numer, long denom) {
17 | ldiv_t val;
18 |
19 | val.quot = numer / denom;
20 | val.rem = numer - denom * val.quot;
21 | if ((val.quot < 0) && (val.rem > 0)) {
22 | val.quot++;
23 | val.rem -= denom;
24 | }
25 |
26 | return val;
27 | }
28 |
--------------------------------------------------------------------------------
/src/libultra/libc/ll.c:
--------------------------------------------------------------------------------
1 | #include "mods.h"
2 |
3 | long long __ull_rshift(unsigned long long left, unsigned long long right) {
4 | return left >> right;
5 | }
6 |
7 | unsigned long long __ull_rem(unsigned long long left, unsigned long long right) {
8 | return left % right;
9 | }
10 |
11 | unsigned long long __ull_div(unsigned long long left, unsigned long long right) {
12 | return left / right;
13 | }
14 |
15 | long long __ll_lshift(long long left, long long right) {
16 | return left << right;
17 | }
18 |
19 | long long __ll_rem(long long left, unsigned long long right) {
20 | return left % right;
21 | }
22 |
23 | long long __ll_div(long long left, long long right) {
24 | return left / right;
25 | }
26 |
27 | long long __ll_mul(long long left, long long right) {
28 | return left * right;
29 | }
30 |
31 | void __ull_divremi(unsigned long long* quotient, unsigned long long* remainder, unsigned long long dividend,
32 | unsigned short divisor) {
33 | *quotient = dividend / divisor;
34 | *remainder = dividend % divisor;
35 | }
36 |
37 | long long __ll_mod(long long left, long long right) {
38 | long long rem = left % right;
39 | if (((rem < 0) && (right > 0)) || ((rem > 0) && (right < 0))) {
40 | rem += right;
41 | }
42 | return rem;
43 | }
44 |
45 | long long __ll_rshift(long long left, long long right) {
46 | return left >> right;
47 | }
48 |
49 | // IDO FIX
50 | #if MODS_FPS_COUNTER == 1
51 | float __ull_to_f(unsigned long long u) {
52 | return u;
53 | }
54 | #endif
55 |
--------------------------------------------------------------------------------
/src/libultra/libc/string.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | void* memcpy(void* s1, const void* s2, size_t n) {
4 | unsigned char* su1 = (unsigned char*) s1;
5 | const unsigned char* su2 = (const unsigned char*) s2;
6 |
7 | while (n > 0) {
8 | *su1 = *su2;
9 | su1++;
10 | su2++;
11 | n--;
12 | }
13 |
14 | return s1;
15 | }
16 |
17 | size_t strlen(const char* s) {
18 | const char* sc = s;
19 |
20 | while (*sc != '\0') {
21 | sc++;
22 | }
23 |
24 | return (size_t) (sc - s);
25 | }
26 |
27 | const char* strchr(const char* s, int c) {
28 | const unsigned char ch = c;
29 |
30 | while (*s != ch) {
31 | if (*s == '\0') {
32 | return NULL;
33 | }
34 | s++;
35 | }
36 |
37 | return s;
38 | }
39 |
--------------------------------------------------------------------------------
/src/libultra/libc/xlitob.c:
--------------------------------------------------------------------------------
1 | #include "PR/xstdio.h"
2 | #include "string.h"
3 | #include "stdlib.h"
4 |
5 | #define BUFF_LEN 0x18
6 |
7 | static char ldigs[] = "0123456789abcdef";
8 | static char udigs[] = "0123456789ABCDEF";
9 |
10 | void _Litob(_Pft* args, char type) {
11 | u8 buff[BUFF_LEN];
12 | const u8* numMap;
13 | s32 base;
14 | s32 idx;
15 | u64 num;
16 | lldiv_t quotrem;
17 |
18 | if (type == 'X') {
19 | numMap = udigs;
20 | } else {
21 | numMap = ldigs;
22 | }
23 |
24 | base = (type == 'o') ? 8 : ((type != 'x' && type != 'X') ? 10 : 16);
25 | idx = BUFF_LEN;
26 | num = args->v.ll;
27 |
28 | if ((type == 'd' || type == 'i') && args->v.ll < 0) {
29 | num = -num;
30 | }
31 |
32 | if ((num != 0) || (args->prec != 0)) {
33 | buff[--idx] = numMap[num % base];
34 | }
35 |
36 | args->v.ll = num / base;
37 |
38 | while ((args->v.ll > 0) && (idx > 0)) {
39 | quotrem = lldiv(args->v.ll, base);
40 | args->v.ll = quotrem.quot;
41 | buff[--idx] = numMap[quotrem.rem];
42 | }
43 |
44 | args->n1 = BUFF_LEN - idx;
45 |
46 | memcpy(args->s, buff + idx, args->n1);
47 |
48 | if (args->n1 < args->prec) {
49 | args->nz0 = args->prec - args->n1;
50 | }
51 |
52 | if ((args->prec < 0) && (args->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) {
53 | idx = args->width - args->n0 - args->nz0 - args->n1;
54 | if (idx > 0) {
55 | args->nz0 += idx;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/libultra/os/createmesgqueue.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 |
5 | void osCreateMesgQueue(OSMesgQueue* mq, OSMesg* msg, s32 msgCount) {
6 | #ifdef _DEBUG
7 | if (msgCount <= 0) {
8 | __osError(ERR_OSCREATEMESGQUEUE, 1, msgCount);
9 | return;
10 | }
11 | #endif
12 | mq->mtqueue = (OSThread*) &__osThreadTail.next;
13 | mq->fullqueue = (OSThread*) &__osThreadTail.next;
14 | mq->validCount = 0;
15 | mq->first = 0;
16 | mq->msgCount = msgCount;
17 | mq->msg = msg;
18 | }
19 |
--------------------------------------------------------------------------------
/src/libultra/os/createthread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/R4300.h"
3 | #include "PR/ultraerror.h"
4 | #include "osint.h"
5 |
6 | extern __OSThreadprofile_s thprof[];
7 |
8 | void osCreateThread(OSThread* t, OSId id, void (*entry)(void*), void* arg, void* sp, OSPri p) {
9 | register u32 saveMask;
10 | OSIntMask mask;
11 |
12 | #ifdef _DEBUG
13 | if ((u32) sp & 0x7) {
14 | __osError(ERR_OSCREATETHREAD_SP, 1, sp);
15 | return;
16 | }
17 |
18 | if ((p < OS_PRIORITY_IDLE) || (p > OS_PRIORITY_MAX)) {
19 | __osError(ERR_OSCREATETHREAD_PRI, 1, p);
20 | return;
21 | }
22 | #endif
23 |
24 | t->id = id;
25 | t->priority = p;
26 | t->next = NULL;
27 | t->queue = NULL;
28 | t->context.pc = (u32) entry;
29 | t->context.a0 = (s64) (s32) arg; // Double cast gets rid of compiler warning
30 | t->context.sp = (s64) (s32) sp - 16;
31 | t->context.ra = __osCleanupThread;
32 | mask = OS_IM_ALL;
33 | t->context.sr = (mask & (SR_IMASK | SR_IE)) | SR_EXL;
34 | t->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT;
35 | t->context.fpcsr = (u32) (FPCSR_FS | FPCSR_EV);
36 | t->fp = 0;
37 | t->state = OS_STATE_STOPPED;
38 | t->flags = 0;
39 |
40 | #if BUILD_VERSION >= VERSION_K
41 | #ifndef _FINALROM
42 | if (id < THPROF_IDMAX) {
43 | t->thprof = &thprof[id];
44 | } else {
45 | t->thprof = &thprof[THPROF_IDMAX - 1];
46 | }
47 | #endif
48 | #endif
49 |
50 | saveMask = __osDisableInt();
51 | t->tlnext = __osActiveQueue;
52 | __osActiveQueue = t;
53 | __osRestoreInt(saveMask);
54 | }
55 |
--------------------------------------------------------------------------------
/src/libultra/os/destroythread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "osint.h"
3 | #include "PR/os_version.h"
4 |
5 | // this is not supposed to be here, but the def check below is broken I guess.
6 | #ifdef __sgi
7 | #define __GNUC__ 0
8 | #endif
9 |
10 | void osDestroyThread(OSThread* t) {
11 | register u32 saveMask;
12 | register OSThread* pred;
13 | register OSThread* succ;
14 |
15 | saveMask = __osDisableInt();
16 |
17 | if (t == NULL) {
18 | t = __osRunningThread;
19 | } else if (t->state != OS_STATE_STOPPED) {
20 | __osDequeueThread(t->queue, t);
21 | }
22 |
23 | if (__osActiveQueue == t) {
24 | __osActiveQueue = __osActiveQueue->tlnext;
25 | } else {
26 | #if BUILD_VERSION >= VERSION_J || !defined(__GNUC__)
27 | pred = __osActiveQueue;
28 | while (pred->priority != -1) {
29 | succ = pred->tlnext;
30 | if (succ == t) {
31 | pred->tlnext = t->tlnext;
32 | break;
33 | }
34 | pred = succ;
35 | }
36 | #else
37 | pred = __osActiveQueue;
38 | succ = pred->tlnext;
39 | while (succ != NULL) {
40 | if (succ == t) {
41 | pred->tlnext = t->tlnext;
42 | break;
43 | }
44 | pred = succ;
45 | succ = pred->tlnext;
46 | }
47 | #endif
48 | }
49 |
50 | if (t == __osRunningThread) {
51 | __osDispatchThread();
52 | }
53 |
54 | __osRestoreInt(saveMask);
55 | }
56 |
--------------------------------------------------------------------------------
/src/libultra/os/getactivequeue.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "osint.h"
3 |
4 | OSThread* __osGetActiveQueue(void) {
5 | return __osActiveQueue;
6 | }
7 |
--------------------------------------------------------------------------------
/src/libultra/os/getthreadpri.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "osint.h"
3 |
4 | OSPri osGetThreadPri(OSThread* thread) {
5 | if (thread == NULL) {
6 | thread = __osRunningThread;
7 | }
8 |
9 | return thread->priority;
10 | }
11 |
--------------------------------------------------------------------------------
/src/libultra/os/gettime.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "PR/viint.h"
4 | #include "osint.h"
5 |
6 | OSTime osGetTime() {
7 | u32 tmptime;
8 | u32 elapseCount;
9 | OSTime currentCount;
10 | register u32 saveMask;
11 |
12 | #ifdef _DEBUG
13 | if (!__osViDevMgr.active) {
14 | __osError(ERR_OSGETTIME, 0);
15 | return 0;
16 | }
17 | #endif
18 |
19 | saveMask = __osDisableInt();
20 | tmptime = osGetCount();
21 | elapseCount = tmptime - __osBaseCounter;
22 | currentCount = __osCurrentTime;
23 | __osRestoreInt(saveMask);
24 | return currentCount + elapseCount;
25 | }
26 |
--------------------------------------------------------------------------------
/src/libultra/os/initrdb.c:
--------------------------------------------------------------------------------
1 | #ifndef _FINALROM
2 | #include "PR/rdb.h"
3 | #include "PR/os_internal.h"
4 |
5 | rdbPacket* __osRdb_IP6_Data;
6 | u32 __osRdb_IP6_Size;
7 | u32 __osRdb_IP6_Ct;
8 | u32 __osRdb_IP6_CurWrite;
9 | u32 __osRdb_IP6_CurSend;
10 |
11 | void osInitRdb(u8* sendBuf, u32 sendSize) {
12 | u32 mask;
13 |
14 | sendSize /= 4;
15 |
16 | if (((u32) sendBuf & 3) != 0) {
17 | sendBuf = ((u32) sendBuf & 3) + 4;
18 | sendSize--;
19 | }
20 | mask = __osDisableInt();
21 |
22 | __osRdb_IP6_Data = (rdbPacket*) sendBuf;
23 | __osRdb_IP6_Size = sendSize;
24 | __osRdb_IP6_Ct = 0;
25 | __osRdb_IP6_CurWrite = 0;
26 | __osRdb_IP6_CurSend = 0;
27 |
28 | __osRestoreInt(mask);
29 | }
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/src/libultra/os/jammesg.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 |
5 | s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag) {
6 | register u32 saveMask;
7 |
8 | #ifdef _DEBUG
9 | if ((flag != OS_MESG_NOBLOCK) && (flag != OS_MESG_BLOCK)) {
10 | __osError(ERR_OSJAMMESG, 1, flag);
11 | return -1;
12 | }
13 | #endif
14 |
15 | saveMask = __osDisableInt();
16 |
17 | while (mq->validCount >= mq->msgCount) {
18 | if (flag == OS_MESG_BLOCK) {
19 | __osRunningThread->state = OS_STATE_WAITING;
20 | __osEnqueueAndYield(&mq->fullqueue);
21 | } else {
22 | __osRestoreInt(saveMask);
23 | return -1;
24 | }
25 | }
26 |
27 | mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount;
28 | mq->msg[mq->first] = msg;
29 | mq->validCount++;
30 |
31 | if (mq->mtqueue->next != NULL) {
32 | osStartThread(__osPopThread(&mq->mtqueue));
33 | }
34 |
35 | __osRestoreInt(saveMask);
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/src/libultra/os/recvmesg.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 |
5 | s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flags) {
6 | register u32 saveMask;
7 |
8 | #ifdef _DEBUG
9 | if ((flags != OS_MESG_NOBLOCK) && (flags != OS_MESG_BLOCK)) {
10 | __osError(ERR_OSRECVMESG, 1, flags);
11 | return -1;
12 | }
13 | #endif
14 |
15 | saveMask = __osDisableInt();
16 |
17 | while (MQ_IS_EMPTY(mq)) {
18 | if (flags == OS_MESG_NOBLOCK) {
19 | __osRestoreInt(saveMask);
20 | return -1;
21 | } else {
22 | __osRunningThread->state = OS_STATE_WAITING;
23 | __osEnqueueAndYield(&mq->mtqueue);
24 | }
25 | }
26 |
27 | if (msg != NULL) {
28 | *msg = mq->msg[mq->first];
29 | }
30 |
31 | mq->first = (mq->first + 1) % mq->msgCount;
32 | mq->validCount--;
33 |
34 | if (mq->fullqueue->next != NULL) {
35 | osStartThread(__osPopThread(&mq->fullqueue));
36 | }
37 |
38 | __osRestoreInt(saveMask);
39 | return 0;
40 | }
41 |
--------------------------------------------------------------------------------
/src/libultra/os/resetglobalintmask.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 |
3 | void __osResetGlobalIntMask(OSHWIntr mask) {
4 | register u32 saveMask = __osDisableInt();
5 |
6 | __OSGlobalIntMask &= ~(mask & ~OS_IM_RCP);
7 |
8 | __osRestoreInt(saveMask);
9 | }
10 |
--------------------------------------------------------------------------------
/src/libultra/os/sendmesg.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 |
5 | s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flags) {
6 | register u32 saveMask;
7 | register s32 last;
8 |
9 | #ifdef _DEBUG
10 | if ((flags != OS_MESG_NOBLOCK) && (flags != OS_MESG_BLOCK)) {
11 | __osError(ERR_OSSENDMESG, 1, flags);
12 | return -1;
13 | }
14 | #endif
15 |
16 | saveMask = __osDisableInt();
17 |
18 | while (MQ_IS_FULL(mq)) {
19 | if (flags == OS_MESG_BLOCK) {
20 | __osRunningThread->state = OS_STATE_WAITING;
21 | __osEnqueueAndYield(&mq->fullqueue);
22 | } else {
23 | __osRestoreInt(saveMask);
24 | return -1;
25 | }
26 | }
27 |
28 | last = (mq->first + mq->validCount) % mq->msgCount;
29 | mq->msg[last] = msg;
30 | mq->validCount++;
31 |
32 | if (mq->mtqueue->next != NULL) {
33 | osStartThread(__osPopThread(&mq->mtqueue));
34 | }
35 |
36 | __osRestoreInt(saveMask);
37 | return 0;
38 | }
39 |
--------------------------------------------------------------------------------
/src/libultra/os/seteventmesg.c:
--------------------------------------------------------------------------------
1 | #include "macros.h"
2 | #include "PR/os_internal.h"
3 | #include "PR/ultraerror.h"
4 | #include "osint.h"
5 |
6 | __OSEventState __osEventStateTab[OS_NUM_EVENTS] ALIGNED(8);
7 | #if BUILD_VERSION >= VERSION_J
8 | u32 __osPreNMI = FALSE;
9 | #endif
10 |
11 | void osSetEventMesg(OSEvent event, OSMesgQueue* mq, OSMesg msg) {
12 | register u32 saveMask;
13 | __OSEventState* es;
14 |
15 | #ifdef _DEBUG
16 | if (event >= OS_NUM_EVENTS) {
17 | __osError(ERR_OSSETEVENTMESG, 1, event);
18 | return;
19 | }
20 | #endif
21 |
22 | saveMask = __osDisableInt();
23 |
24 | es = &__osEventStateTab[event];
25 |
26 | es->messageQueue = mq;
27 | es->message = msg;
28 |
29 | #if BUILD_VERSION >= VERSION_J
30 | if (event == OS_EVENT_PRENMI) {
31 | if (__osShutdown && !__osPreNMI) {
32 | osSendMesg(mq, msg, OS_MESG_NOBLOCK);
33 | }
34 | __osPreNMI = TRUE;
35 | }
36 | #endif
37 |
38 | __osRestoreInt(saveMask);
39 | }
40 |
--------------------------------------------------------------------------------
/src/libultra/os/setglobalintmask.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 |
3 | void __osSetGlobalIntMask(OSHWIntr mask) {
4 | register u32 saveMask = __osDisableInt();
5 |
6 | __OSGlobalIntMask |= mask;
7 |
8 | __osRestoreInt(saveMask);
9 | }
10 |
--------------------------------------------------------------------------------
/src/libultra/os/setthreadpri.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 |
5 | void osSetThreadPri(OSThread* t, OSPri pri) {
6 | register u32 saveMask;
7 |
8 | #ifdef _DEBUG
9 | if ((pri < OS_PRIORITY_IDLE) || (pri > OS_PRIORITY_MAX)) {
10 | __osError(ERR_OSSETTHREADPRI, 1, pri);
11 | return;
12 | }
13 | #endif
14 |
15 | saveMask = __osDisableInt();
16 |
17 | if (t == NULL) {
18 | t = __osRunningThread;
19 | }
20 |
21 | if (t->priority != pri) {
22 | t->priority = pri;
23 |
24 | if (t != __osRunningThread && t->state != OS_STATE_STOPPED) {
25 | __osDequeueThread(t->queue, t);
26 | __osEnqueueThread(t->queue, t);
27 | }
28 |
29 | if (__osRunningThread->priority < __osRunQueue->priority) {
30 | __osRunningThread->state = OS_STATE_RUNNABLE;
31 | __osEnqueueAndYield(&__osRunQueue);
32 | }
33 | }
34 |
35 | __osRestoreInt(saveMask);
36 | }
37 |
--------------------------------------------------------------------------------
/src/libultra/os/settime.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 | #include "PR/viint.h"
5 |
6 | void osSetTime(OSTime time) {
7 |
8 | #ifdef _DEBUG
9 | if (!__osViDevMgr.active) {
10 | __osError(ERR_OSSETTIME, 0);
11 | return;
12 | }
13 | #endif
14 |
15 | __osCurrentTime = time;
16 | }
17 |
--------------------------------------------------------------------------------
/src/libultra/os/settimer.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 | #include "PR/viint.h"
5 |
6 | int osSetTimer(OSTimer* t, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg) {
7 | OSTime time;
8 | #if BUILD_VERSION >= VERSION_K
9 | OSTimer* next;
10 | u32 count;
11 | u32 value;
12 | u32 saveMask;
13 | #endif
14 |
15 | #ifdef _DEBUG
16 | if (!__osViDevMgr.active) {
17 | __osError(ERR_OSSETTIMER, 0);
18 | return 0;
19 | }
20 | #endif
21 |
22 | t->next = NULL;
23 | t->prev = NULL;
24 | t->interval = interval;
25 | t->value = (countdown != 0) ? countdown : interval;
26 | t->mq = mq;
27 | t->msg = msg;
28 |
29 | #if BUILD_VERSION >= VERSION_K
30 | saveMask = __osDisableInt();
31 | if (__osTimerList->next == __osTimerList) {
32 |
33 | } else {
34 | next = __osTimerList->next;
35 | count = osGetCount();
36 | value = count - __osTimerCounter;
37 |
38 | if (value < next->value) {
39 | next->value -= value;
40 | } else {
41 | next->value = 1;
42 | }
43 | }
44 |
45 | time = __osInsertTimer(t);
46 | __osSetTimerIntr(__osTimerList->next->value);
47 | __osRestoreInt(saveMask);
48 | #else
49 | time = __osInsertTimer(t);
50 | if (__osTimerList->next == t) {
51 | __osSetTimerIntr(time);
52 | }
53 | #endif
54 |
55 | return 0;
56 | }
57 |
--------------------------------------------------------------------------------
/src/libultra/os/startthread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/ultraerror.h"
3 | #include "osint.h"
4 |
5 | void osStartThread(OSThread* t) {
6 | register u32 saveMask = __osDisableInt();
7 |
8 | switch (t->state) {
9 | case OS_STATE_WAITING:
10 | t->state = OS_STATE_RUNNABLE;
11 | __osEnqueueThread(&__osRunQueue, t);
12 | break;
13 | case OS_STATE_STOPPED:
14 | if (t->queue == NULL || t->queue == &__osRunQueue) {
15 | t->state = OS_STATE_RUNNABLE;
16 | __osEnqueueThread(&__osRunQueue, t);
17 | } else {
18 | t->state = OS_STATE_WAITING;
19 | __osEnqueueThread(t->queue, t);
20 | __osEnqueueThread(&__osRunQueue, __osPopThread(t->queue));
21 | }
22 | break;
23 | #ifdef _DEBUG
24 | default:
25 | __osError(ERR_OSSTARTTHREAD, 0);
26 | __osRestoreInt(saveMask);
27 | return;
28 | #endif
29 | }
30 |
31 | if (__osRunningThread == NULL) {
32 | __osDispatchThread();
33 | } else if (__osRunningThread->priority < __osRunQueue->priority) {
34 | __osRunningThread->state = OS_STATE_RUNNABLE;
35 | __osEnqueueAndYield(&__osRunQueue);
36 | }
37 |
38 | __osRestoreInt(saveMask);
39 | }
40 |
--------------------------------------------------------------------------------
/src/libultra/os/stopthread.c:
--------------------------------------------------------------------------------
1 | #include "osint.h"
2 |
3 | void osStopThread(OSThread* t) {
4 | register u32 saveMask = __osDisableInt();
5 | register u16 state = (t == NULL) ? OS_STATE_RUNNING : t->state;
6 |
7 | switch (state) {
8 | case OS_STATE_RUNNING:
9 | __osRunningThread->state = 1;
10 | __osEnqueueAndYield(NULL);
11 | break;
12 | case OS_STATE_RUNNABLE:
13 | case OS_STATE_WAITING:
14 | t->state = OS_STATE_STOPPED;
15 | __osDequeueThread(t->queue, t);
16 | break;
17 | }
18 | __osRestoreInt(saveMask);
19 | }
20 |
--------------------------------------------------------------------------------
/src/libultra/os/thread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "osint.h"
3 |
4 | struct __osThreadTail __osThreadTail = { NULL, -1 };
5 | OSThread* __osRunQueue = (OSThread*) &__osThreadTail;
6 | OSThread* __osActiveQueue = (OSThread*) &__osThreadTail;
7 | OSThread* __osRunningThread = { 0 };
8 | OSThread* __osFaultedThread = { 0 };
9 |
10 | void __osDequeueThread(register OSThread** queue, register OSThread* t) {
11 | register OSThread* pred;
12 | register OSThread* succ;
13 |
14 | pred = (OSThread*) queue;
15 | succ = pred->next;
16 |
17 | while (succ != NULL) {
18 | if (succ == t) {
19 | pred->next = t->next;
20 | #ifdef _DEBUG
21 | t->next = NULL;
22 | #endif
23 | return;
24 | }
25 | pred = succ;
26 | succ = pred->next;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/libultra/os/virtualtophysical.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "PR/R4300.h"
3 | #include "osint.h"
4 |
5 | u32 osVirtualToPhysical(void* addr) {
6 | if (IS_KSEG0(addr)) {
7 | return K0_TO_PHYS(addr);
8 | } else if (IS_KSEG1(addr)) {
9 | return K1_TO_PHYS(addr);
10 | } else {
11 | return __osProbeTLB(addr);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/libultra/os/yieldthread.c:
--------------------------------------------------------------------------------
1 | #include "PR/os_internal.h"
2 | #include "osint.h"
3 |
4 | void osYieldThread(void) {
5 | register u32 saveMask = __osDisableInt();
6 |
7 | __osRunningThread->state = OS_STATE_RUNNABLE;
8 | __osEnqueueAndYield(&__osRunQueue);
9 | __osRestoreInt(saveMask);
10 | }
11 |
--------------------------------------------------------------------------------
/src/libultra/vimodes/vimodempallan1.c:
--------------------------------------------------------------------------------
1 | #include "PR/os.h"
2 | #include "PR/rcp.h"
3 | #include "PR/viint.h"
4 |
5 | OSViMode osViModeMpalLan1 = {
6 | OS_VI_MPAL_LAN1, // type
7 | {
8 | // comRegs
9 | VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 |
10 | VI_CTRL_PIXEL_ADV_3, // ctrl
11 | WIDTH(320), // width
12 | BURST(57, 30, 5, 70), // burst
13 | VSYNC(525), // vSync
14 | HSYNC(3089, 4), // hSync
15 | LEAP(3097, 3098), // leap
16 | HSTART(108, 748), // hStart
17 | SCALE(2, 0), // xScale
18 | VCURRENT(0), // vCurrent
19 | },
20 | { // fldRegs
21 | {
22 | // [0]
23 | ORIGIN(640), // origin
24 | SCALE(1, 0), // yScale
25 | HSTART(37, 511), // vStart
26 | BURST(4, 2, 14, 0), // vBurst
27 | VINTR(2), // vIntr
28 | },
29 | {
30 | // [1]
31 | ORIGIN(640), // origin
32 | SCALE(1, 0), // yScale
33 | HSTART(37, 511), // vStart
34 | BURST(4, 2, 14, 0), // vBurst
35 | VINTR(2), // vIntr
36 | } },
37 | };
38 |
--------------------------------------------------------------------------------
/src/libultra/vimodes/vimodentsclan1.c:
--------------------------------------------------------------------------------
1 | #include "PR/os.h"
2 | #include "PR/rcp.h"
3 | #include "PR/viint.h"
4 |
5 | OSViMode osViModeNtscLan1 = {
6 | OS_VI_NTSC_LAN1, // type
7 | {
8 | // comRegs
9 | VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 |
10 | VI_CTRL_PIXEL_ADV_3, // ctrl
11 | WIDTH(320), // width
12 | BURST(57, 34, 5, 62), // burst
13 | VSYNC(525), // vSync
14 | HSYNC(3093, 0), // hSync
15 | LEAP(3093, 3093), // leap
16 | HSTART(108, 748), // hStart
17 | SCALE(2, 0), // xScale
18 | VCURRENT(0), // vCurrent
19 | },
20 | { // fldRegs
21 | {
22 | // [0]
23 | ORIGIN(640), // origin
24 | SCALE(1, 0), // yScale
25 | HSTART(37, 511), // vStart
26 | BURST(4, 2, 14, 0), // vBurst
27 | VINTR(2), // vIntr
28 | },
29 | {
30 | // [1]
31 | ORIGIN(640), // origin
32 | SCALE(1, 0), // yScale
33 | HSTART(37, 511), // vStart
34 | BURST(4, 2, 14, 0), // vBurst
35 | VINTR(2), // vIntr
36 | } },
37 | };
38 |
--------------------------------------------------------------------------------
/src/libultra/vimodes/vimodepallan1.c:
--------------------------------------------------------------------------------
1 | #include "PR/os.h"
2 | #include "PR/rcp.h"
3 | #include "PR/viint.h"
4 |
5 | OSViMode osViModePalLan1 = {
6 | OS_VI_PAL_LAN1, // type
7 | {
8 | // comRegs
9 | VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | VI_CTRL_ANTIALIAS_MODE_1 |
10 | VI_CTRL_PIXEL_ADV_3, // ctrl
11 | WIDTH(320), // width
12 | BURST(58, 30, 4, 69), // burst
13 | VSYNC(625), // vSync
14 | HSYNC(3177, 23), // hSync
15 | LEAP(3183, 3181), // leap
16 | HSTART(128, 768), // hStart
17 | SCALE(2, 0), // xScale
18 | VCURRENT(0), // vCurrent
19 | },
20 | { // fldRegs
21 | {
22 | // [0]
23 | ORIGIN(640), // origin
24 | SCALE(1, 0), // yScale
25 | HSTART(95, 569), // vStart
26 | BURST(107, 2, 9, 0), // vBurst
27 | VINTR(2), // vIntr
28 | },
29 | {
30 | // [1]
31 | ORIGIN(640), // origin
32 | SCALE(1, 0), // yScale
33 | HSTART(95, 569), // vStart
34 | BURST(107, 2, 9, 0), // vBurst
35 | VINTR(2), // vIntr
36 | } },
37 | };
38 |
--------------------------------------------------------------------------------
/src/mods/hit64.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 | #include "hit64.h"
3 |
4 | // gHit64SelfDestruct
5 |
6 | void Hit64_Main(void) {
7 | if (CVarGetInteger("gHit64SelfDestruct", 0) == 1) {
8 | Player* player = &gPlayer[0];
9 |
10 | if (gControllerPress[0].button & D_JPAD) {
11 | player->shields = 0;
12 | Player_ApplyDamage(player, 0, 10000);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/overlays/ovl_i1/fox_i1.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | s32 D_i1_801997D0 = 0;
4 |
5 | s32 D_i1_8019B6C0;
6 |
7 | void OvlI1_CallFunction(s32 mode, void* ptr) {
8 | }
9 |
--------------------------------------------------------------------------------
/src/overlays/ovl_i2/fox_i2.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | UNK_TYPE D_i2_80195D70;
4 |
5 | s32 D_i2_80195420 = 0;
6 |
7 | void OvlI2_CallFunction(s32 mode, void* ptr) {
8 | }
9 |
--------------------------------------------------------------------------------
/src/overlays/ovl_i3/fox_i3.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | s32 D_i3_801BECA0 = 0;
4 | s32 D_i3_801C2240;
5 |
6 | void OvlI3_CallFunction(s32 mode, void* ptr) {
7 | }
8 |
--------------------------------------------------------------------------------
/src/overlays/ovl_i4/fox_i4.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | void Fortuna_LevelComplete(Player*);
4 | void Bolse_BoLaserCannon_Update(Boss*);
5 | void Bolse_BoLaserCannon_Draw(BoLaserCannon*);
6 | void Bolse_BoShieldReactor_Update(BoShieldReactor*);
7 | void Bolse_BoShieldReactor_Draw(Boss*);
8 | void Bolse_BoBase_Update(Actor*);
9 | void Bolse_BoBase_Draw(Actor*);
10 | void Bolse_BoBaseShield_Update(Actor*);
11 | void Bolse_BoBaseShield_Draw(Actor*);
12 |
13 | UNK_TYPE D_i4_801A03C0;
14 | s32 D_i4_8019EDD0 = 0;
15 |
16 | void OvlI4_CallFunction(u32 mode, void* ptr) {
17 | switch (mode) {
18 | case OVLCALL_FO_CS_COMPLETE:
19 | Fortuna_LevelComplete(ptr);
20 | break;
21 | case OVLCALL_BO_BASE_UPDATE:
22 | Bolse_BoBase_Update(ptr);
23 | break;
24 | case OVLCALL_BO_BASE_DRAW:
25 | Bolse_BoBase_Draw(ptr);
26 | break;
27 | case OVLCALL_BO_BASE_SHIELD_UPDATE:
28 | Bolse_BoBaseShield_Update(ptr);
29 | break;
30 | case OVLCALL_BO_BASE_SHIELD_DRAW:
31 | Bolse_BoBaseShield_Draw(ptr);
32 | break;
33 | case OVLCALL_BO_SHIELD_REACTOR_UPDATE:
34 | Bolse_BoShieldReactor_Update(ptr);
35 | break;
36 | case OVLCALL_BO_SHIELD_REACTOR_DRAW:
37 | Bolse_BoShieldReactor_Draw(ptr);
38 | break;
39 | case OVLCALL_BO_LASER_CANNON_UPDATE:
40 | Bolse_BoLaserCannon_Update(ptr);
41 | break;
42 | case OVLCALL_BO_LASER_CANNON_DRAW:
43 | Bolse_BoLaserCannon_Draw(ptr);
44 | default:
45 | PRINTF("i4 指定外!\n"); // Not specified!
46 | break;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/overlays/ovl_i5/fox_i5.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | UNK_TYPE D_i5_801BBEE0;
4 | s32 D_i5_801B7290 = 0;
5 |
6 | void OvlI5_CallFunction(u32 mode, void* ptr) {
7 | PRINTF("i5 指定外!\n"); // i5 not specified!
8 | }
9 |
--------------------------------------------------------------------------------
/src/overlays/ovl_i6/fox_i6.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 |
3 | UNK_TYPE D_i6_801A7F30;
4 | s32 D_i6_801A6750 = 0;
5 |
6 | void OvlI6_CallFunction(u32 mode, void* ptr) {
7 | PRINTF("i6 指定外!\n");
8 | }
9 |
--------------------------------------------------------------------------------
/src/overlays/ovl_menu/fox_i_menu.c:
--------------------------------------------------------------------------------
1 | #include "fox_title.h"
2 | #include "global.h"
3 | #include "port/interpolation/FrameInterpolation.h"
4 |
5 | void Title_Main(void);
6 | void Title_Draw(void);
7 | void Option_Main(void);
8 | void Option_Entry_Draw(void);
9 | void Map_GameOver(void);
10 | void Map_8019E8C8(void);
11 | void Map_Main(void);
12 | void Map_Draw(void);
13 |
14 | s32 D_menu_801B7BA0;
15 | s32 D_menu_801AD9F0 = 0;
16 |
17 | extern void Title_8018F77C(void);
18 |
19 | void OvlMenu_CallFunction(u32 mode, void* ptr) {
20 | switch (mode) {
21 | case OVLCALL_TITLE_UPDATE:
22 | Title_Main();
23 | break;
24 |
25 | case OVLCALL_TITLE_DRAW:
26 | Title_Draw();
27 | break;
28 |
29 | case OVLCALL_MAP_UPDATE:
30 | Map_Main();
31 | break;
32 |
33 | case OVLCALL_MAP_DRAW:
34 | FrameInterpolation_RecordOpenChild("MapDraw", 0);
35 | FrameInterpolation_RecordMarker(__FILE__, __LINE__);
36 | Map_Draw();
37 | FrameInterpolation_RecordCloseChild();
38 | break;
39 |
40 | case OVLCALL_OPTION_UPDATE:
41 | Option_Main();
42 | break;
43 |
44 | case OVLCALL_OPTION_DRAW:
45 | Option_Entry_Draw();
46 | break;
47 |
48 | case OVLCALL_GAME_OVER_UPDATE:
49 | Map_GameOver();
50 | break;
51 |
52 | case OVLCALL_UNKMAP_DRAW:
53 | Map_8019E8C8();
54 | break;
55 |
56 | case 999:
57 | Title_64Logo_Draw();
58 | break;
59 |
60 | default:
61 | break;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/overlays/ovl_unused/fox_unused.c:
--------------------------------------------------------------------------------
1 | #include "global.h"
2 | #include "assets/ast_andross.h"
3 |
4 | UNK_TYPE D_unused_801875C0;
5 |
6 | f32* D_unused_80187530[] = {
7 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, aAndAndrossHitbox,
8 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
9 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
10 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
11 | };
12 |
13 | void Unused_80187520(void) {
14 | }
15 |
--------------------------------------------------------------------------------
/src/port/Game.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include "Engine.h"
5 |
6 | extern "C" {
7 | #include
8 | void Main_SetVIMode(void);
9 | void Main_Initialize(void);
10 | void Main_ThreadEntry(void* arg);
11 | void Lib_FillScreen(u8 setFill);
12 | void Graphics_ThreadUpdate();
13 | void AudioThread_CreateTask();
14 | }
15 |
16 | extern "C"
17 | void Graphics_PushFrame(Gfx* data) {
18 | GameEngine::ProcessGfxCommands(data);
19 | }
20 |
21 | extern "C" void Timer_Update();
22 |
23 | void push_frame() {
24 | Graphics_ThreadUpdate();
25 | GameEngine::StartAudioFrame();
26 | GameEngine::Instance->StartFrame();
27 | Timer_Update();
28 | // thread5_iteration();
29 | GameEngine::EndAudioFrame();
30 | }
31 |
32 | #ifdef _WIN32
33 | int SDL_main(int argc, char **argv) {
34 | #else
35 | #if defined(__cplusplus) && defined(PLATFORM_IOS)
36 | extern "C"
37 | #endif
38 | int main(int argc, char *argv[]) {
39 | #endif
40 | GameEngine::Create();
41 | Main_SetVIMode();
42 | Lib_FillScreen(1);
43 | Main_Initialize();
44 | Main_ThreadEntry(NULL);
45 | while (WindowIsRunning()) {
46 | push_frame();
47 | }
48 | GameEngine::Instance->Destroy();
49 | return 0;
50 | }
--------------------------------------------------------------------------------
/src/port/audio/GameAudio.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | static struct {
5 | std::thread thread;
6 | std::condition_variable cv_to_thread, cv_from_thread;
7 | std::mutex mutex;
8 | bool running;
9 | bool processing;
10 | } audio;
--------------------------------------------------------------------------------
/src/port/extractor/GameExtractor.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Companion.h"
4 | #include
5 | #include
6 | #include
7 |
8 | class GameExtractor {
9 | public:
10 | static bool GenAssetFile();
11 | std::optional ValidateChecksum() const;
12 | bool SelectGameFromUI();
13 | bool GenerateOTR() const;
14 | private:
15 | fs::path mGamePath;
16 | std::vector mGameData;
17 | };
--------------------------------------------------------------------------------
/src/port/hooks/Events.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "list/EngineEvent.h"
4 | #include "list/ActorEvent.h"
5 | #include "list/ItemEvent.h"
6 | #include "list/ActionEvent.h"
--------------------------------------------------------------------------------
/src/port/hooks/list/ActionEvent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "sf64player.h"
4 | #include "port/hooks/impl/EventSystem.h"
5 |
6 | DEFINE_EVENT(PlayerActionBoostEvent, Player* player;);
7 |
8 | DEFINE_EVENT(PlayerActionBrakeEvent, Player* player;);
9 |
10 | DEFINE_EVENT(PlayerActionPreShootEvent, Player* player; LaserStrength laser;);
11 | DEFINE_EVENT(PlayerActionPostShootEvent, Player* player; PlayerShot* shot;);
12 |
13 | DEFINE_EVENT(PlayerActionPreShootChargedEvent, Player* player;);
14 | DEFINE_EVENT(PlayerActionPostShootChargedEvent, Player* player;);
15 |
16 | DEFINE_EVENT(PlayerActionPreBombEvent, Player* player;);
17 | DEFINE_EVENT(PlayerActionPostBombEvent, Player* player;);
--------------------------------------------------------------------------------
/src/port/hooks/list/ActorEvent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 | #include "port/hooks/impl/EventSystem.h"
6 |
7 | typedef enum {
8 | OBJECT_TYPE_ACTOR,
9 | OBJECT_TYPE_ACTOR_EVENT,
10 | OBJECT_TYPE_BOSS,
11 | OBJECT_TYPE_SCENERY,
12 | OBJECT_TYPE_SCENERY360,
13 | OBJECT_TYPE_SPRITE,
14 | OBJECT_TYPE_ITEM,
15 | OBJECT_TYPE_EFFECT,
16 | } ObjectEventType;
17 |
18 | DEFINE_EVENT(ObjectInitEvent,
19 | ObjectEventType type;
20 | void* object;
21 | );
22 |
23 | DEFINE_EVENT(ObjectUpdateEvent,
24 | ObjectEventType type;
25 | void* object;
26 | );
27 |
28 | DEFINE_EVENT(ObjectDrawPreSetupEvent,
29 | ObjectEventType type;
30 | void* object;
31 | );
32 |
33 | DEFINE_EVENT(ObjectDrawPostSetupEvent,
34 | ObjectEventType type;
35 | void* object;
36 | );
37 |
38 | DEFINE_EVENT(ObjectDestroyEvent,
39 | ObjectEventType type;
40 | void* object;
41 | );
--------------------------------------------------------------------------------
/src/port/hooks/list/EngineEvent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "global.h"
4 | #include "port/hooks/impl/EventSystem.h"
5 |
6 | DEFINE_EVENT(DisplayPreUpdateEvent);
7 | DEFINE_EVENT(DisplayPostUpdateEvent);
8 |
9 | DEFINE_EVENT(GamePreUpdateEvent);
10 | DEFINE_EVENT(GamePostUpdateEvent);
11 |
12 | DEFINE_EVENT(PlayUpdateEvent);
13 |
14 | DEFINE_EVENT(PlayerPreUpdateEvent, Player* player;);
15 | DEFINE_EVENT(PlayerPostUpdateEvent, Player* player;);
16 |
17 | DEFINE_EVENT(DrawRadarHUDEvent);
18 | DEFINE_EVENT(DrawRadarMarkArwingEvent, s32 colorIdx;);
19 | DEFINE_EVENT(DrawRadarMarkWolfenEvent);
20 | DEFINE_EVENT(DrawBoostGaugeHUDEvent);
21 | DEFINE_EVENT(DrawBombCounterHUDEvent);
22 | DEFINE_EVENT(DrawIncomingMsgHUDEvent);
23 | DEFINE_EVENT(PreSetupRadioMsgEvent, s32* radioRedBox;);
24 | DEFINE_EVENT(DrawGoldRingsHUDEvent);
25 | DEFINE_EVENT(DrawLivesCounterHUDEvent);
26 | DEFINE_EVENT(DrawTrainingRingPassCountHUDEvent);
27 | DEFINE_EVENT(DrawEdgeArrowsHUDEvent);
28 | DEFINE_EVENT(DrawBossHealthHUDEvent);
29 |
30 | DEFINE_EVENT(DrawGlobalHUDPreEvent);
31 | DEFINE_EVENT(DrawGlobalHUDPostEvent);
--------------------------------------------------------------------------------
/src/port/hooks/list/ItemEvent.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gfx.h"
4 | #include "sf64object.h"
5 | #include "port/hooks/impl/EventSystem.h"
6 |
7 | DEFINE_EVENT(ItemDropEvent,
8 | Item* item;
9 | );
--------------------------------------------------------------------------------
/src/port/mods/PortEnhancements.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | void PortEnhancements_Register();
8 | void PortEnhancements_Init();
9 | void PortEnhancements_Exit();
10 | #define SETUPDL_OPTIONAL(digits) \
11 | (CVarGetInteger("gHUDPointFiltering", 1) == 1 ? SETUPDL_##digits##_POINT : SETUPDL_##digits)
12 |
13 | #define SETUPDL_29_OPTIONAL SETUPDL_OPTIONAL(29)
14 | #define SETUPDL_36_OPTIONAL SETUPDL_OPTIONAL(36)
15 | #define SETUPDL_62_OPTIONAL SETUPDL_OPTIONAL(62)
16 | #define SETUPDL_63_OPTIONAL SETUPDL_OPTIONAL(63)
17 | #define SETUPDL_67_OPTIONAL SETUPDL_OPTIONAL(67)
18 | #define SETUPDL_75_OPTIONAL SETUPDL_OPTIONAL(75)
19 | #define SETUPDL_76_OPTIONAL SETUPDL_OPTIONAL(76)
20 | #define SETUPDL_77_OPTIONAL SETUPDL_OPTIONAL(77)
21 | #define SETUPDL_78_OPTIONAL SETUPDL_OPTIONAL(78)
22 | #define SETUPDL_81_OPTIONAL SETUPDL_OPTIONAL(81)
23 | #define SETUPDL_83_OPTIONAL SETUPDL_OPTIONAL(83)
24 | #define SETUPDL_85_OPTIONAL SETUPDL_OPTIONAL(85)
25 |
26 | #ifdef __cplusplus
27 | };
28 | #endif
--------------------------------------------------------------------------------
/src/port/notification/notification.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 |
5 | #include
6 | #include
7 |
8 | namespace Notification {
9 |
10 | struct Options {
11 | uint32_t id = 0;
12 | const char* itemIcon = nullptr;
13 | std::string prefix = "";
14 | ImVec4 prefixColor = ImVec4(0.5f, 0.5f, 1.0f, 1.0f);
15 | std::string message = "";
16 | ImVec4 messageColor = ImVec4(0.7f, 0.7f, 0.7f, 1.0f);
17 | std::string suffix = "";
18 | ImVec4 suffixColor = ImVec4(1.0f, 0.5f, 0.5f, 1.0f);
19 | float remainingTime = 0.0f; // Seconds
20 | };
21 |
22 | class Window : public Ship::GuiWindow {
23 | public:
24 | using GuiWindow::GuiWindow;
25 |
26 | void InitElement() override {};
27 | void DrawElement() override {};
28 | void Draw() override;
29 | void UpdateElement() override;
30 | };
31 |
32 | void Emit(Options notification);
33 |
34 | } // namespace Notification
35 | #endif // __cplusplus
36 |
--------------------------------------------------------------------------------
/src/port/patches/DisplayListPatch.cpp:
--------------------------------------------------------------------------------
1 | #include "DisplayListPatch.h"
2 | #include
3 |
4 | std::unordered_map>> patches = {
5 | // { ast_corneria_seg6_gfx_23420, {
6 | // { 23, gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, 0x003C, 0x003C) }
7 | // }}
8 | };
9 |
10 | void DisplayListPatch::Run() {
11 | SPDLOG_INFO("Applying display list patches");
12 |
13 | for(auto& entry : patches){
14 | auto data = (Gfx*) ResourceGetDataByName(entry.first);
15 | for(auto& patch : entry.second){
16 | data[patch.first] = patch.second;
17 | }
18 |
19 | SPDLOG_INFO("{} patched successfully!", entry.first);
20 | }
21 | }
--------------------------------------------------------------------------------
/src/port/patches/DisplayListPatch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | class DisplayListPatch {
3 | public:
4 | static void Run();
5 | };
6 |
--------------------------------------------------------------------------------
/src/port/resource/importers/AnimFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryAnimV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ColPolyFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "ColPolyFactory.h"
2 | #include "../type/ColPoly.h"
3 | #include "spdlog/spdlog.h"
4 |
5 | namespace SF64 {
6 | std::shared_ptr ResourceFactoryBinaryColPolyV0::ReadResource(std::shared_ptr file,
7 | std::shared_ptr initData) {
8 | if (!FileHasValidFormatAndReader(file, initData)) {
9 | return nullptr;
10 | }
11 |
12 | auto colPoly = std::make_shared(initData);
13 | auto reader = std::get>(file->Reader);
14 |
15 | auto colPolysCount = reader->ReadUInt32();
16 |
17 | SPDLOG_INFO("ColPolyCount: {}", colPolysCount);
18 |
19 | for (uint32_t i = 0; i < colPolysCount; i++) {
20 | uint16_t triX = reader->ReadUInt16();
21 | uint16_t triY = reader->ReadUInt16();
22 | uint16_t triZ = reader->ReadUInt16();
23 | Vec3s tri = {triX, triY, triZ};
24 | uint16_t normX = reader->ReadUInt16();
25 | uint16_t normY = reader->ReadUInt16();
26 | uint16_t normZ = reader->ReadUInt16();
27 | Vec3s norm = {normX, normY, normZ};
28 | uint32_t dist = reader->ReadInt32();
29 | colPoly->mColPolys.emplace_back(tri, 0, norm, 0, dist);
30 | }
31 |
32 | return colPoly;
33 | }
34 | } // namespace LUS
35 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ColPolyFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryColPolyV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/EnvSettingsFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "EnvSettingsFactory.h"
2 |
3 | #include "Context.h"
4 | #include "resourcebridge.h"
5 | #include "../type/EnvSettings.h"
6 |
7 | namespace SF64 {
8 |
9 | std::shared_ptr ResourceFactoryBinaryEnvSettingsV0::ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) {
11 | if (!FileHasValidFormatAndReader(file, initData)) {
12 | return nullptr;
13 | }
14 |
15 | auto env = std::make_shared(initData);
16 | auto reader = std::get>(file->Reader);
17 |
18 | env->mSettings.type = reader->ReadInt32();
19 | env->mSettings.unk_04 = reader->ReadInt32();
20 | env->mSettings.bgColor = reader->ReadUInt16();
21 | env->mSettings.seqId = reader->ReadUInt16();
22 | env->mSettings.fogR = reader->ReadInt32();
23 | env->mSettings.fogG = reader->ReadInt32();
24 | env->mSettings.fogB = reader->ReadInt32();
25 | env->mSettings.fogN = reader->ReadInt32();
26 | env->mSettings.fogF = reader->ReadInt32();
27 | env->mSettings.unk_20.x = reader->ReadFloat();
28 | env->mSettings.unk_20.y = reader->ReadFloat();
29 | env->mSettings.unk_20.z = reader->ReadFloat();
30 | env->mSettings.lightR = reader->ReadInt32();
31 | env->mSettings.lightG = reader->ReadInt32();
32 | env->mSettings.lightB = reader->ReadInt32();
33 | env->mSettings.ambR = reader->ReadInt32();
34 | env->mSettings.ambG = reader->ReadInt32();
35 | env->mSettings.ambB = reader->ReadInt32();
36 |
37 | return env;
38 | }
39 | } // namespace LUS
40 |
--------------------------------------------------------------------------------
/src/port/resource/importers/EnvSettingsFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryEnvSettingsV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/GenericArrayFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryGenericArrayV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/HitboxFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "HitboxFactory.h"
2 | #include "../type/Hitbox.h"
3 | #include "spdlog/spdlog.h"
4 |
5 | namespace SF64 {
6 | std::shared_ptr ResourceFactoryBinaryHitboxV0::ReadResource(std::shared_ptr file,
7 | std::shared_ptr initData) {
8 | if (!FileHasValidFormatAndReader(file, initData)) {
9 | return nullptr;
10 | }
11 |
12 | auto hitbox = std::make_shared(initData);
13 | auto reader = std::get>(file->Reader);
14 |
15 | auto count = reader->ReadUInt32();
16 |
17 | for (uint32_t i = 0; i < count; i++) {
18 | hitbox->mHitbox.push_back(reader->ReadFloat());
19 | }
20 |
21 | return hitbox;
22 | }
23 | } // namespace LUS
24 |
--------------------------------------------------------------------------------
/src/port/resource/importers/HitboxFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryHitboxV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/LimbFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "LimbFactory.h"
2 |
3 | #include "Context.h"
4 | #include "resourcebridge.h"
5 | #include "../type/Limb.h"
6 | #include "ResourceUtil.h"
7 |
8 | namespace SF64 {
9 |
10 | std::shared_ptr ResourceFactoryBinaryLimbV0::ReadResource(std::shared_ptr file,
11 | std::shared_ptr initData) {
12 | if (!FileHasValidFormatAndReader(file, initData)) {
13 | return nullptr;
14 | }
15 |
16 | auto limb = std::make_shared(initData);
17 | auto reader = std::get>(file->Reader);
18 |
19 | uint64_t dlist = reader->ReadUInt64();
20 | limb->mData.dList = LoadChild(dlist);
21 | limb->mData.trans.x = reader->ReadFloat();
22 | limb->mData.trans.y = reader->ReadFloat();
23 | limb->mData.trans.z = reader->ReadFloat();
24 |
25 | limb->mData.rot.x = reader->ReadInt16();
26 | limb->mData.rot.y = reader->ReadInt16();
27 | limb->mData.rot.z = reader->ReadInt16();
28 |
29 | limb->mData.sibling = LoadChild(reader->ReadUInt64());
30 | limb->mData.child = LoadChild(reader->ReadUInt64());
31 |
32 | return limb;
33 | }
34 | } // namespace LUS
35 |
--------------------------------------------------------------------------------
/src/port/resource/importers/LimbFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryLimbV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/MessageFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "MessageFactory.h"
2 | #include "../type/Message.h"
3 | #include "spdlog/spdlog.h"
4 |
5 | namespace SF64 {
6 | std::shared_ptr ResourceFactoryBinaryMessageV0::ReadResource(std::shared_ptr file,
7 | std::shared_ptr initData) {
8 | if (!FileHasValidFormatAndReader(file, initData)) {
9 | return nullptr;
10 | }
11 |
12 | auto msg = std::make_shared(initData);
13 | auto reader = std::get>(file->Reader);
14 |
15 | auto size = reader->ReadUInt32();
16 |
17 | for (uint32_t i = 0; i < size; i++) {
18 | msg->mMessage.push_back(reader->ReadUInt16());
19 | }
20 |
21 | return msg;
22 | }
23 | } // namespace LUS
24 |
--------------------------------------------------------------------------------
/src/port/resource/importers/MessageFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryMessageV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/MessageLookupFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "MessageLookupFactory.h"
2 | #include "../type/Message.h"
3 | #include "spdlog/spdlog.h"
4 | #include "resourcebridge.h"
5 | #include "ResourceUtil.h"
6 |
7 | namespace SF64 {
8 | std::shared_ptr ResourceFactoryBinaryMessageLookupV0::ReadResource(std::shared_ptr file,
9 | std::shared_ptr initData) {
10 | if (!FileHasValidFormatAndReader(file, initData)) {
11 | return nullptr;
12 | }
13 |
14 | auto table = std::make_shared(initData);
15 | auto reader = std::get>(file->Reader);
16 | auto count = reader->ReadUInt32();
17 |
18 | for (uint32_t i = 0; i < count - 1; i++) {
19 | auto id = reader->ReadInt32();
20 | auto crc = reader->ReadUInt64();
21 |
22 | uint16_t* ptr = LoadChild(crc);
23 | const char* name = ResourceGetNameByCrc(crc);
24 | table->mLookupTable.push_back({ id, ptr, strdup(name) });
25 | }
26 |
27 | return table;
28 | }
29 | } // namespace LUS
30 |
--------------------------------------------------------------------------------
/src/port/resource/importers/MessageLookupFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryMessageLookupV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ObjectInitFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "ObjectInitFactory.h"
2 |
3 | #include "Context.h"
4 | #include "resourcebridge.h"
5 | #include "../type/ObjectInit.h"
6 |
7 | namespace SF64 {
8 |
9 | std::shared_ptr ResourceFactoryBinaryObjectInitV0::ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) {
11 | if (!FileHasValidFormatAndReader(file, initData)) {
12 | return nullptr;
13 | }
14 |
15 | auto obj = std::make_shared(initData);
16 | auto reader = std::get>(file->Reader);
17 | auto count = reader->ReadUInt32();
18 |
19 | for(size_t i = 0; i < count; i++) {
20 | ObjectInitData data;
21 | data.zPos1 = reader->ReadFloat();
22 | data.zPos2 = reader->ReadInt16();
23 | data.xPos = reader->ReadInt16();
24 | data.yPos = reader->ReadInt16();
25 | data.rot.x = reader->ReadInt16();
26 | data.rot.y = reader->ReadInt16();
27 | data.rot.z = reader->ReadInt16();
28 | data.id = reader->ReadInt16();
29 | obj->mObjects.push_back(data);
30 | }
31 |
32 | return obj;
33 | }
34 | } // namespace LUS
35 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ObjectInitFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryObjectInitV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ResourceUtil.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "resourcebridge.h"
4 | #include "ResourceManager.h"
5 | #include "Context.h"
6 |
7 | namespace SF64 {
8 | template T LoadChild(uint64_t crc) {
9 | if (crc == 0) {
10 | return nullptr;
11 | }
12 | auto path = ResourceGetNameByCrc(crc);
13 | if (path == nullptr) {
14 | return nullptr;
15 | }
16 | auto asset = Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(path);
17 | return asset != nullptr ? static_cast(asset->GetRawPointer()) : nullptr;
18 | }
19 | }
--------------------------------------------------------------------------------
/src/port/resource/importers/ScriptCommandFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "ScriptCommandFactory.h"
2 | #include "../type/Script.h"
3 | #include "spdlog/spdlog.h"
4 | #include "ResourceUtil.h"
5 |
6 | namespace SF64 {
7 | std::shared_ptr ResourceFactoryBinaryScriptCMDV0::ReadResource(std::shared_ptr file,
8 | std::shared_ptr initData) {
9 | if (!FileHasValidFormatAndReader(file, initData)) {
10 | return nullptr;
11 | }
12 |
13 | auto cmds = std::make_shared(initData);
14 | auto reader = std::get>(file->Reader);
15 |
16 | auto size = reader->ReadUInt32();
17 |
18 | for (uint32_t i = 0; i < size * 2; i++) {
19 | cmds->mCommands.push_back(reader->ReadUInt16());
20 | }
21 |
22 | return cmds;
23 | }
24 | } // namespace LUS
25 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ScriptCommandFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Resource.h"
4 | #include "ResourceFactoryBinary.h"
5 |
6 | namespace SF64 {
7 | class ResourceFactoryBinaryScriptCMDV0 : public Ship::ResourceFactoryBinary {
8 | public:
9 | std::shared_ptr ReadResource(std::shared_ptr file,
10 | std::shared_ptr initData) override;
11 | };
12 | }; // namespace LUS
13 |
--------------------------------------------------------------------------------
/src/port/resource/importers/ScriptFactory.cpp:
--------------------------------------------------------------------------------
1 | #include "ScriptFactory.h"
2 | #include "../type/Script.h"
3 | #include "spdlog/spdlog.h"
4 | #include "ResourceUtil.h"
5 |
6 | namespace SF64 {
7 | std::shared_ptr ResourceFactoryBinaryScriptV0::ReadResource(std::shared_ptr file,
8 | std::shared_ptr initData) {
9 | if (!FileHasValidFormatAndReader(file, initData)) {
10 | return nullptr;
11 | }
12 |
13 | auto script = std::make_shared