Nintendo switch support (#935)

* Moved gfx effects to the gpu and removed loadtexbyname on some textures

* Readded empty if

* Added nintendo switch support

* Fixed compilation errors and window closing issue on linux

* Fixed kaleido on 64 bit

* Fixed audio on nintendo switch

* Implemented performance mode switcher

* Added suggestions from pr review

* Fixed ftruncate errors

* Fixed compilation errors

* Added missing include rule

* Fixed libstorm path

* Removed ftruncate extern to use a correct posix version

* Merge branch 'develop' from HarbourMasters into znx (#3)

* Add Support for macOS (#441)

* Fixed soh filters

* add more makefile changes

* almost ready

* more updates

* update

* update

* Update Makefiles to handle both platforms

* Allow for overriding the CXX and CC executables

* Restore original structure while supporting custom CXX flags

* Remove some platform specific libs

* Dynamic target name

* Make X11 paths package-agnostic

* Remove changes to `gfx_opengl.cpp`

* Use OpenGL2 on MacOS instead of OpenGL3

* make it actually render something

* render at least the first texture, still need to figure out the second
one

* Let’s use OpenGL 3 again

* maybe this works to get the right texture? link's eyes still look off a bit

* did this work?

* set the platform to macos

* actual numbers are right, but logic is ugly XXX/TODO, i know

* add zlib to ldflags for ZAPDUtils

* A bit of cleanup

* Revert unneeded changes

* Remove GL_CHECK

* Fix issues with z64 branch

* use an std::map instead of a giant array

* three point filter fix (#2)

* Fix mac compilation

* fix audio for 64 bit

* revert audio heap size, keep bigger pools

* Add more Apple specific checks to our modifications

* Add building instructions for macOS

* Remove unecessary step from building instructions

* Add missing SDL2 & GLEW to Linux LDLIBS

* Update BUILDING.md

Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Update soh/.gitignore to include other arch binaries

Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Use right platform name for debugging window

Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Fix stormlib on macos (arm64)

* Simplify some of the ifdef checks

* Revert an older no longer necessary fix

* Remove remaining unecessary deviations

* Update building instructions after StormLib changes

* Feature: Use OpenGL 4.1 (#1)

* Further tweak the BUILDING

* Tidy up

* reword -j message

* Add Jenkins CI Support (#2)

* Fix type issues

* add target <appbundle> and <filledappbundle>

add makefile targets to create an .app
`filledappbundle` creates the target with the .otr included

this should perhaps be moved to Application Support though

* pull gcc's rpath from otool output

* move make target to the end so it's not default

* Add Jenkins and make exe in par with other platforms

* Actually save build artefacts

* Fix artefact path

* Remove x11 mentions and linking (not used)

* Update building instructions for generating app

* use appsupport directory

* Add new app icon

* Update target to match macOS types

* Update more audio types

* fix null deref in Audio_PlayFanfare

* Remove old import from z64

* address final nit with apple ifdefs

Co-authored-by: KiritoDev <36680385+KiritoDv@users.noreply.github.com>
Co-authored-by: Jeffrey Crowell <github@crowell.biz>
Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>

* Move macOS to parallel stage

* fix linux crash

* Ignore all named saves

Necessary after new save format

* DPad items

* Move UI location arrays from static to global to accomodate customizable UI

* FIX: Increased the maximum actor limit for draw distance

Fix issue #529

* FIX: Remove duplicates of gNewDrops from the enhancements menu

* Get rid of erroneous int casts

* casts jya_cobra's shadowTexture pointer to uintptr_t instead of s32.

* Fix ability to assign equipment you don't own

* Fix title cards for market potion shop and bombchu shop

* Invalidate message item icon texture before drawing

* Add margins for dpad

* Fixed some instances where the original OOT save is erroneously preserved or recreated, leading to another conversion next time you launched the game

* Headphones setting in game should now work.
Resolves #13

* Map Select name fixes

* Change Power to Upgrades

* Rename Soh* files

* Update names

* Add more files

* Add more files

* Add toggles for disabling heart drops and random drops (#507)

* Adds toggles for disabling random drops and fixed heart drops

* Changed the "No Fixed Heart Drops" toggle to the more useful "No Random Heart Drops" toggle

* Adds an explanation that the no heart drops option is similar to Hero Mode

* Moved difficulty options into their own sub-menu
Moved time saver options into their own sub-menu
Moved clutter reducing options into their own sub-menu

* fixed the tag name of mweep speed

* Moved Skip Text to Experimental

* Fix testing masks of DPad

* Fix audio, boot commands, and save staes.

* add menu from https://github.com/PurpleHato/Shipwright/tree/ResetMenu

* implement reset

* Update README.md

* command on mac

* special char doesn't work with default imgui font

* change name based on PR comment

* missed a couple spots

* change sunset in save editor so dampe is out

* Update to latest `docking` imgui (#582)

* Update to latest `docking` imgui

commit: 67410d53f739b6a0df138e2252f0e5136b42062f

* Fix modified import for SDL

* Update imgui_impl_sdl.cpp

* Add Imgui include path for better imports

* Controller Navigation Fix-Up (#544)

* Controller Navigation Fix-Up

* [MISC] Fix typo

* Use Macro for __FILE__ & __LINE__ when possible (#559)

* First batch some overlay

* Almost all overlay

* effect & gamestate

* kaleido stuffs

* more overlay

* more left over from code folder

* remaining hardcoded line and file

* Open & Close _DISP __FILE__ & __LINE__ clean up

* Some if (1) {} remove

* LOG_xxxx __FILE__ , __LINE__ cleaned

* ASSERT macro __FILE__ __LINE__

* mtx without line/file in functions

* " if (1) {} " & "if (0) {}" and tab/white place

* LogUtils as macro

* GameState_, GameAlloc_, SystemArena_ & ZeldaArena_

* Revert "GameState_, GameAlloc_, SystemArena_ & ZeldaArena_"

This reverts commit 0d85caaf7e.

* Like last commit but as macro

* Fix matrix not using macros

* use function not macro

* DebugArena_* functions
GameAlloc_MallocDebug
BgCheck_PosErrorCheck as macros
removed issues with ; in macro file

* MM Bunny Hood enhancements: no age restrictions & wear across entrances (#560)

* Remove age restriction on MM Bunny Hood

* Handle mask slot changing; init Link wearing mask

* Reset mask state after selling

* Use unordered maps in some hot paths (#566)

* Use unordered maps in some hot paths

* Address PR comments

* Cheat: Infinite Epona Boost (#577)

* Cheat: Infinite Epona Boost

* Edit for readability

* update pulseaudio for 44.1khz audio (#587)

* use pulseaudio defaults

* spaces/tabs

* pulseaudio values tuned for n64 audio at 44.1khz

* update tlength

* remove one hardcoded samplerate

Co-authored-by: briaguya <briaguya@alice>

* Restoration Item Sliders (#595)

* Allows players to set custom restoration values for potions and milk

* Fixed a dumb oversight

* implemented fairy sliders

* use ini window resolution (#410)

* use ini window resolution

* use arguments for directx window size

* default 640x480 not 320x240

* kick off a build

* and revert

* default config 640x480 not 320x240

* add todo

Co-authored-by: briaguya <briaguya@alice>

* 3D Drops & Projectiles update (#548)

* Fix remaining rupee and keys

* fix tabs -> spaces

* more fix about tabs -> spaces

* Better up <-> down mouvement for hearts

* remove useless comment

* Cosmetics menu rework (#589)

* -

* DPad/some margin fix(left side)

* various ImGui stuff and fixes

* disabled kaleido menu (non working)

* fix win being dumb

* same for C btn this time

* Fix windows build

* Beating hearts fix

* Default win size and some placement fix

* Fix Dpad Ammo & C notes, Kaleido, white dog

* some texts fix and tab move

* Add stone of agony, some fixes and build correctly

* precise item place with Dpad

* Gamecube -> GameCube

Co-authored-by: Baoulettes <iMacWin10>

* [CI] Create an Appimage for 64bit builds (#570)

* [CI] Create AppImage file

* [CI] Updated Jenkinsfile

* [MISC] fix indentation

* [MISC] Fix indentation

* [MISC] Fix indentation

* [CI] 7z appimage and readme

* [CI] AppImage icon file (#597)

* [CI] Add patchelf

* [BUILD] Include Hi-Res icon

* Fix portability use of std::clamp (#596)

* Add N64 weird frames and OOB Bombchus cvars (#602)

* Add gN64WeirdFrames and gBombchuOOB cvars

* Rename gBombchuOOB to gBombchusOOB

* Fix pipeline

* [BUILD] Do not strip ZAPD (#598)

* [BUILD] Do not strip ZAPD

* [BUILD] Reuse Icon Asset

* [APPIMAGE] Handle paths with spaces

* [macos] Distribute optimized builds (#599)

* Cosmetics texts fixes (#604)

* branch init + few fixes

* Reset button

* Several texts fixes and default color to GameCube

* space issues

* some more extra space that was not needed.

* space yes last time ...

* Arrows being able to be rainbow some more texts fixes

* more texts fixes

* c-buttons some plurial fix

* Fixes bug in demo effect due to removed display list set.

* King dodongo room crash (#613)

* first attempt

* force camera setting to be at least 0 (dirty!)

* -

* reverted something to just include fix

* Invalidate text box icon before drawing (#607)

* [APPIMAGE] Set lib path for ZAPD (#611)

* New drop runtime fix (#614)

* inital rework

* fixed default rotation for 2D sprites

* fix tab/space issues

* Fix Ganon's Castle title cards (#606)

* Checkered room crash workaround (#615)

* Increase poly and vertex count for dyna actors

* Add TODO

* Only apply fix in Forest Temple

* Enable globally

* Match case of 'Shipwright' in Linux build (#619)

* Fix 0xabababab crash (#617)

* Unconditionally setup the normal skybox

* Only call Skybox_Setup once ever

* Equipment upgrade text fix and any pause slot enhancement fix (#620)

* Fix upgrade name text not rendering

* Use cvar and don't render equip help for empty item slots

* Fix rendering logic

* Fix incorrect item name rendered for one frame

* Reorder comparison

* Remove extra indent

* Remove accidental changes

* ImGui grammer, consistency, and clarity fixes (#625)

* ImGui grammer, consistency, and clarity fixes

Co-Authored-By: Stormghetti <56653191+Stormghetti@users.noreply.github.com>

* Adds more new lines for users on smaller displays

Co-Authored-By: Stormghetti <56653191+Stormghetti@users.noreply.github.com>

Co-authored-by: Stormghetti <56653191+Stormghetti@users.noreply.github.com>

* New drops shadows & rotation fixes (#627)

* fixes

* forgot to add heart pieces in rotation logic

* Dodongo's Cavern blue warp crash fix (#622)

* Doodong's Cavern blue warp crash fix

* >= not >

* Don't waste a line of space

* add support for clang compiler (#592)

* hacks to align strings for clang... wow just wow

* start work to getting built with clang

* fix issues with struct constructors, all builds, doesn't link still

* fix some narrowing issues that clang complains about

* fix compliation of zapd

* fix null deref in VersionInfo

* builds with clang

* make stringbuilding use StringHelper instead of addition

* fix linking

* add CLANG SHIP overlay on clang built versions

* doesn't need to be volatile

* mark unknown strings as extern

* rename some stuff

* can't align extern

* hopefully fix compilation for everythign

* expandtab

* allow setting LD

* Revert "allow setting LD"

This reverts commit 711aba6db2.

maybe to use lld it should be a LDFLAG?

* -Wno-deprecated-declarations is required for newer versions of clang

on macOS 13 beta sdk, the version of apple clang requires this

* Add jenkins support for clang

* Forward CXX flags to stormlib compilation

* Move GCC only flags to check

* use exports to set multiarch setup

* Fix Jenkins forever

* use make instead of cmake --build

add some flags to build with clang-11 as well

* address review coments

- rework extraction to allow multi thread
- misc readability cleanup

* update makefile to add WARN on linux+clang

Co-authored-by: David Chavez <david@dcvz.io>

* Fix develop

* Fixes grey screen issue + tooltip for 2 handed shield

* Don't close controller after SDL has quit (#642)

* Don't close controller after SDL has quit

* Don't check if controller can rumble if null

* Fixes Barinade's set whenever boss fight is reloaded (#639)

* Reimplements unused Barinade reset function.

* Removes the Jellyfish from Barinade's body on reset.

* add the ability to pull graves during the day (#637)

* change max internal res multiplier to 3x, use float and % instead of int (#638)

* change max internal res multiplier to 3x, use float and % instead of int

* Update libultraship/libultraship/ImGuiImpl.cpp

Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>

* Fixes crash on Biggoron trade failure screen wipe

Resolves #621

* fixes center docking (#652)

* testing out item replacement (#416)

* skip learning song of storms

* don't set flag when getting goron tunic as child

* Initiates prelude check when master sword unloads.

Not quite how N64 rando does it but so far it's the only way I've found to make it trigger without also triggering the time travel again.

* Stops Shadow Temple lore prompts from appearing in rando.

* Skips cutscene of royal tomb explosion in rando.

Explosion sound doesn't play correctly and I think the debris appears in the wrong place, but the functionality is here.

* Improves visual of exploding gravestone.

* Adds some comments explaining the rando differences

* Skip ruto text box in jabu blue warp

For rando

* skip intro cutscene in dodongo's cavern

* load spoiler files on boot, fix spoilerfile existing check when making new saves

* name entry dropped spoiler logic

* make sure to actually init the cvar

* no chime on load

* uncomment

* Skip ganondrof cutscene

Skip to scream part of the death animation, skipping the text boxes etc. For rando

* Update z_boss_ganondrof.c

* skip owl flight cutscenes in rando

* Fixes skipped text so it only applies to shadow temple.

Earlier fix inadvertently applied to some other text as well, changed logic so that only specified sceneNums and textIds can have this enabled, and text skipped by sceneNum can have the skip overriden by textId if needed. Currently there are no overrides so the textId section of the logic is commented out to avoid compilation errors.

* Adds a default to the switch case statements that leaves the randoSkipText variable unchanged, just in case.

* TEST: Text for item

* Adding ganon flavor text

* ADD: AMMO Count

* format ganon text/hint text

* Autoskip the tower cutscene if settings call for tower collapse.

* ganon hint text logic

* Improved prelude after time travel fix

* swapped the sizes between ganon hint text and ganon text, as they were set to the wrong things.

* this is all i did

* not the cleanest code ever but it's working

* ADD: GS Count

* ADD: Wallter (crash for now)

* TWEAK: Wallet check

* FIX: Use DrawItem instread of DrawUpgrade... b-baka!

* Fixes some vanilla bugs introduced by rando code.

* Added cutscene skip for zelda escaping

Using the debug cutscene skipping function. Also added a conditional so the bridge doesn't spawn closed when cutscene is ready to trigger

* ADD: X Spacing + Placeholders for song

* ADD: default case for items

* TWEAK: Spacing

* FIX: Light Arrow

* ADD: Ammo Option

* use groups instead

* ADD: More spacing logic

* songs and names

* TWEAK: Color on wallet

* colors

* Added flags cutscene before nabooru fight

* ADD: ChromaKey text

* First attempt skip cs after nabooru defeat

* Better implementation for specific rando cutscene skips

* use pulseaudio defaults

* spaces/tabs

* move color push/pop to stop crash

* make the colors work again

* the real bottle fix

* pulseaudio values tuned for n64 audio at 44.1khz

* update tlength

* remove one hardcoded samplerate

* Cleaned up and fixed zelda escape skip

The if statement is a freaking monster, but unless we want to skip more cutscenes in the same way later, this is the most compact way of doing it that I know of.

* Revert one line to match original

nothing functional

* another hint line that breaks autonewline logic

* don't autospawn epona if we don't have the song/ocarina

* Trying to use iron knuckle death effects

not working yet

* Streamlined OoT cutscene skip for future additions

Also cleaned up if statement in general

* Made if statement more readable

Also added clarity for what cutscene was skipped

* Fixed typo in comment

* Janky nabooru defeat cs skip

* altar text formatting (gonna need help shortening some of the french ones)

* more altar text formatting

* english altar text formatting complete

* make gtg blocking guard check for card not bridge

* FIX: Typo!

* FIX: Uppercases

* FIX: Typo

* TWEAK: Alter + some names

* TWEAK: More caps!

* ADD: Missing string

TWEAK more uppercases and namefixe
s

* Hide nabooru death by covering her in flames

* bandaid fix for death crash issue

* Twinrova defeat cs skip

Skips the animation and manually calls the function to show the "beam" around the sisters

* fix crash

* fix caps to match

* fix great fairy reward mashing/shielding issue

* TWEAK : Typo clé to Clé

* TWEAK: Some Altar hints

TWEAK: Some capitals

* TWEAK: Unmatching text + some cap again

* TWEAK: More tweaks

* fix build

* remove extra json.hpp, add hint

* Update randomizer_item_tracker.cpp

* TWEAK: Double Defense with RedParticles instead of white

* make sure we don't optimize out the check to ensure a spoilerfile exists

* vanilla ganon boss key hint formatting

* TWEAK: FR- better way of the hero text

* fix

* and again

* Initializes dungeonsDone items in gSaveContext to 0.

* Replaces sizeof calculation with a NUM_DUNGEONS constant.

* Fixes Saria's Gift on the LW Bridge from getting killed when holding shield.

* More airtight fix for Saria's Gift on the Bridge.

* Lifts one of the conditions in the if statement a little higher to prevent unnecessary lookups of getItemId.

* Invalidate text box icon before drawing

* Fixes the case where Saria's gift is an Ice Trap.

We still get the Ice Trap once, but never again. This does mean you can now hold R while walking in to avoid the ice trap, but everything else seems to work fine.

* Initial commit

Might need changing when we change the settings in the future

* Fixes Door of Time opening cutscene after warping with prelude.

* Initial waterfall skip

Very rudimentary way of doing things but it seems to work so 🤷

* inital rework

* fixed default rotation for 2D sprites

* fix tab/space issues

* 3d drops rando merge fix again

* Allows Impa to appear in the Lullaby check post drawbridge escape.

* Changes Ganon's Trials Count setting to a checkbox

The checkbox is whether or not to skip all of them. Leaving the box unchecked will mean doing all of them. Eventually this will be switched back to a slider once we implement the logic for which trials start out completed.

* Sets all Ganon's Trials to incomplete in new saves.

Fixes https://github.com/briaguya-ai/rando-issue-tracker/issues/131

* fix castle guards when oot throw cutscene has already played in rando

* Properly removes the beams when trials are cleared.

* Removes Question Mark from Skip Ganon's Trials UI.

* Adds a todo comment about when to change back to slider.

* make deku seeds check for bullet bag

* Various tweaks

TWEAK: Altar Text
TWEAK: Hint names
TWEAK: Replace more problematic œ to oe

* upgrade ocarina on both child and adult equips

* FIX: Jabu Item

* update equipped hookshot/longshot when obtained as other age

* add hint

* don't give the bgs check without the claim check

* Skips Darunia Cutscene in Fire Temple

* Added a TODO note about not skipping the cutscene.

There is a setting we will want to have eventually that will require this cutscene to not be skipped since it is used during a glitch.

* remove todo

* restore fast ocarina option in imgui that was lost in merge

* Fixes grey screen issue + tooltip for 2 handed shield

* update to use dg instead of g for textures in item tracker

* TWEAK: Default color for cosmetic RAND button was not the corect one

* fix texture crash, remove unused item tracker code

* don't open mask shop until we get zelda's letter

* Update README.md

* Prevents "correct" chime under incorrect conditions.

* Fixes typo in conditional and adds "bonk" sound effect.

"Bonk" sound is NA_SE_SY_OCARINA_ERROR and it plays when conditions for the Door of Time have not been met after playing Song of Time. This is only possible in rando's "Intended" Door of Time option, in which the Ocarina of Time and all 3 spritual stones are required to open the door, instead of the vanilla requirements of just having the song of time.

* remove modify dpad equips toggle, replace with checks for dpad menu

* remove extra check

* add ability to hold c-up to assign to dpad when dpad menuing is enabled

* disable d-pad navigation on item menu when holding c-up to equip

* dpad+c-up stuff for equipment menu

* ADD: Checbox for songs colors

* TWEAK: RandoColors for normal songs

* kind of quick and dirty but it works

* TWEAK: Clarity of the tooltip

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Dog <5172592+Dog@users.noreply.github.com>
Co-authored-by: Vague Rant <vaguerant@users.noreply.github.com>
Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>

* Cosmetics hotfixes (#640)

* Initial branch creation

* Revert Main Game so it do not conflict later

* should fix window build, made namespace for Cosmetics

* forgot to edit one title

* Ability to add hidden window (usefull for Rainbow)
Fix building issues

* Line break, unused bool remove

* add descriptive todo for death crash bandaid (#655)

Co-authored-by: briaguya <briaguya@alice>

* Removed legacy audio mode and fixed ganon sound bug (#657)

* Free Camera (#337)

* wip free cam

* Almost done, needs collision still

* Added free cam behind cvar

* added WIP collision

* Fixed & implemented "Manual mode" from WW & TP

* Fixed camera not rotating when Link is moving

* fixed initialized camera rotation

* Fixed camera getting stuck + made it smoother

* reduced deadzone

* fixed epona camera height + added WW z-target free camera

* Adjusted player camera height & fixed fov

* Fixed camera roll

* fixed fov when moving the camera while in z-target

* Camera resets to Auto when going through doors or changing maps

* Fixed building

* touch

* more touch work

* Added WIP mouse support to the free cam

* gui stuff

* fixed building

* fixed building error

* ok fixed building for real this time

* oops

* Fix compilation issues

* removed mouse stuff that magically appeared in this branch

* smoothed out stick values & removed remains of mouse support

* re-added manual camera when pressing Z

* reduced minimum Y position of camera

* Addressed dcsv's nitpicks

* part 2

* oops

Co-authored-by: David Chavez <david@dcvz.io>

* Rando: Allows Malon's Item Check to be obtained by pulling out the Ocarina. [FIXED PR] (#672)

* Fixes using the Ocarina to get the check from Malon.

Still some cleanup to do here. For some reason the player can shield before receiving the check. It doesn't set the flag if the player does that so they can still try again, but would prefer a different solution if possible.

* Prevents Shielding from blocking the Item_Give from happening.

* Code Cleanup and comments explaining the new rando flow.

* Removes inventory check when pulling out Ocarina

This allows OI to properly give the check, which is important for Glitched logic later down the line. Talking to Malon still requires the Ocarina in your inventory.

* Prevents non-malon textboxes from triggering the check.

Also adds a comment explaining the condtional for getting the check from talking to Malon since it got pretty long.

* Actually fixes checking for text boxes.

* Relocates a comment for improved clarity.

* Fix Rando Water Temple Softlock (#665)

We use 3DS logic to generate item placement, but didn't have this specific door in Water Temple unlocked from the beginning like 3DS does.

This meant that if people took specific paths through the temple, they could softlock themselves by missing a key.

* Rando: GtG and carpenter prompts skip (#663)

* Skip gtg and carpenter prompt

For rando. Tested and just works.

* Fixed missing break

* Hide debug overlay behind gDebugEnabled (#660)

* Introduce App Directory Path (#572)

* Introduce app directory path concept

* macos: Remove hacky way of using applicaiton directory

* Update the new SaveManager

* Address stack user after return

* Remove unecessary property

* Use std::string for filepath

* Improve clang specific detections

* Use new path system for imgui files

* Improve helper for getting relative paths

* fix hidden wnd (#744)

* Split damage multiplication into its own PR (#656)

* Split damage multiplication into its own PR

* Found a more elegant implementation of the powers char*[]

* Fixes Maps, Compasses, and Boss Keys in Vanilla. (#751)

* .xiF slebaL

* Update Keese labels

* Fixed soundfont issues

* Skip warp song cutscenes in rando (#664)

Does it by skipping to the last part of the cutscene data. Tested on all songs, both adult and child.

* don't spawn blocking mido after we've already shown him the sword/shield (#675)

Co-authored-by: briaguya <briaguya@alice>

* Controller Configuration UI and JSON Config (#760)

* Initial controller hud ui

* Reverted fbdemo changes

* Moved config to json and implemented controller config

* fix build on linux, gitignore new config file

* fix build

* Fix compilation and file directory paths

* Call save on cvar save

* Fixed cvar loading and added deck slots to the config

* Changed control deck port 0 to use a physical device by default

* Added gyro and rumble & fixed loading errors

* Save config on toggle menubar

* fix linux build

* Fixed drift calculation

* Controller config now saves when pressing F1

* Removed ExitGame hook from ImGuiImpl

* Moved mappings to a map

* Added GetKeyName

* untranslate scancodes

* Fixed hud layout on keyboard device

* Fixed keyboard read on hud

* Fixed crash when reloading controllers

* Removed ConfigFile and changed file extension

* Changed Dummy to Disconnected and fixed filters

* Removed function leftover

* Changed ControllerHud to InputEditor

Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: David Chavez <david@dcvz.io>

* Enough! My ship sails in the morning.

* Fixed menubar items position (#763)

* Fixed menubar items position

* Reverted tooltip tab position

* Fixes macOS randomizer functionality with App Directory (#761)

* Fixes macOS randomizer functionality with App Directory

* Fix windows build

* Update soh/soh/Enhancements/randomizer/3drando/rando_main.cpp

* Update soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp

* Revert band-aid fix

Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>

* Fix migration cvar deletion path (#765)

* Various controller fixes (#771)

* Fix controller

* Also fix rumble strength being a bool

* Remove ControllerHud.cpp

* Downgrade platform toolset back to previous version

* Fix gyro

* Fix bug that makes binding axes difficult and clear buttons before reading

* Exaggerate gyro display and adjust stick binding threshold

* Initialize drift thresholds

* git subrepo push soh

subrepo:
  subdir:   "soh"
  merged:   "75ccbade8"
upstream:
  origin:   "https://github.com/HarbourMasters/soh.git"
  branch:   "master"
  commit:   "75ccbade8"
git-subrepo:
  version:  "0.4.1"
  origin:   "???"
  commit:   "???"

* One more change from PR review

* Fix some paths

* Fix merge conflict messup

* More merge conflict fixes

* And another conflict fix

* And another fix

* Remove reference to removed build files

* Add full path to switch cmake

Co-authored-by: David Chavez <david@dcvz.io>
Co-authored-by: KiritoDev <36680385+KiritoDv@users.noreply.github.com>
Co-authored-by: Jeffrey Crowell <github@crowell.biz>
Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>
Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: rozlette <Rozelette@users.noreply.github.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
Co-authored-by: vaguerant <vaguerant@users.noreply.github.com>
Co-authored-by: earthcrafterman <banddstudios@gmail.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com>
Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
Co-authored-by: modestposer <modestposer@gmail.com>
Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
Co-authored-by: Stormghetti <56653191+Stormghetti@users.noreply.github.com>
Co-authored-by: Sirius902 <3645979-Sirius902@users.noreply.gitlab.com>
Co-authored-by: MelonSpeedruns <melonspeedruns@outlook.com>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: Dog <5172592+Dog@users.noreply.github.com>
Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>
Co-authored-by: ChristopherJTrent <ChristopherJTrent@outlook.com>
Co-authored-by: agamache <aaroncgamache@gmail.com>
Co-authored-by: M4xw <m4x@m4xw.net>

* Fixed switch compilation

* Fixed responsive on switch imgui

* Remove config save hook

* Added physical slots into controller name

* Add `ifdef` for switch specific code

* Add `ifdef` for switch specific code

* Added applet mode detection

* Replaced homebrew icon

* Fixed randomness on applet mode view

* Fixed clkrst initialization

* Switch profiles cleanup

* Cleaned code based on dcvz comments

* Remove unused hooks in Mercury

* Fixed compilation

* Use IMGUI_IMPL_OPENGL_LOADER_CUSTOM

* Fix up StormLib modifications

* Handle touch events at ImGui/SDL level

* Enable opening menu with -

* Load Nintendo Switch font

* Updates to window initiation

* Handle virtual keyboard via SDL

* Print OTR missing message to screen

* Rename makefile for Switch

* Some more additional fixes

* Branch creation plus edit

Changed ItemWidth & made label invisible (else issues)
Added a submit button next to the text field

* Removed set_texture_filter on imgui draw

* Readded nintendo switch font

* Fixed randomizer crash

* Fix issue with strdup windows

* [SWITCH] Update Jenkins file (#9)

* [SWITCH] Update Jenkins file

* [SWITCH] Dockerfile.switch

Can be combined with other Dockerfile

* [SWITCH] Add entrypoint file

* Update Jenkinsfile

* [SWITCH] Dockerfile mtab link 

link `/proc/self/mounts /etc/mtab`

Co-authored-by: David Chavez <david@dcvz.io>

* Cleaned code based on PR comments

* Fixed switch compilation

* Cleaned full texture cache instead of doing it per char

* Randomizer only saves when its not a vanilla save

* Disabled input when menubar is opened

* Removed return from SetupFont

* Cleaned code based on comments

* Cleaned up random texts on switch error screen

* Killed

* Removed debug and changed compilation flags

Co-authored-by: KiritoDv <nohomoboi01@gmail.com>
Co-authored-by: Felipe Guaycuru <guaycuru@gmail.com>
Co-authored-by: David Chavez <david@dcvz.io>
Co-authored-by: Jeffrey Crowell <github@crowell.biz>
Co-authored-by: BountyChocolate123456 <101743444+BountyChocolate123456@users.noreply.github.com>
Co-authored-by: sholdee <102821812+sholdee@users.noreply.github.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: rozlette <Rozelette@users.noreply.github.com>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
Co-authored-by: vaguerant <vaguerant@users.noreply.github.com>
Co-authored-by: earthcrafterman <banddstudios@gmail.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
Co-authored-by: qurious-pixel <62252937+qurious-pixel@users.noreply.github.com>
Co-authored-by: Baoulettes <perlouzerie@hotmail.fr>
Co-authored-by: Sirius902 <10891979+Sirius902@users.noreply.github.com>
Co-authored-by: modestposer <modestposer@gmail.com>
Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
Co-authored-by: Stormghetti <56653191+Stormghetti@users.noreply.github.com>
Co-authored-by: Sirius902 <3645979-Sirius902@users.noreply.gitlab.com>
Co-authored-by: MelonSpeedruns <melonspeedruns@outlook.com>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: Dog <5172592+Dog@users.noreply.github.com>
Co-authored-by: Nicholas Estelami <NEstelami@users.noreply.github.com>
Co-authored-by: ChristopherJTrent <ChristopherJTrent@outlook.com>
Co-authored-by: agamache <aaroncgamache@gmail.com>
Co-authored-by: M4xw <m4x@m4xw.net>
This commit is contained in:
KiritoDev 2022-07-25 20:11:53 -05:00 committed by GitHub
parent 3fc783b832
commit 5f718932e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 1504 additions and 157 deletions

11
.ci/switch/buildswitch.bash Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
cp -av /usr/local/lib/libSDL2* /lib/x86_64-linux-gnu/
git config --global --add safe.directory /soh
make setup -C soh -j$(nproc) OPTFLAGS=-O2 DEBUG=0 CC="gcc" CXX="g++"
/opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -B StormLib/build-switch -S StormLib -DCMAKE_INSTALL_PREFIX=/opt/devkitpro/portlibs/switch/
make -C StormLib/build-switch -j$(nproc)
make install -C StormLib/build-switch
make -f Makefile.switch -j$(nproc) OPTFLAGS=-O2 DEBUG=0

7
.gitignore vendored
View File

@ -407,6 +407,13 @@ oot.otr
shipofharkinian.ini
shipofharkinian.json
# Switch Stuff
*.nro
*.nacp
ZAPDTR/ZAPDUtils/lib/*
!/soh/icon.jpg
# Xcode
xcuserdata/
*.xcconfig

58
Dockerfile.switch Normal file
View File

@ -0,0 +1,58 @@
FROM ubuntu:20.04 as build
ENV LANG C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
ENV GCCVER=10
RUN \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
binutils \
gcc-10 \
g++-10 \
p7zip-full \
python3 \
make \
cmake \
curl \
git \
lld \
wget \
libsdl2-dev \
zlib1g-dev \
libbz2-dev \
libpng-dev \
libgles2-mesa-dev && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCCVER} 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCCVER} 10
RUN git clone https://github.com/Perlmint/glew-cmake.git && \
cmake glew-cmake && \
make -j$(nproc) && \
make install ARCH64=true
ENV SDL2VER=2.0.22
RUN curl -sLO https://libsdl.org/release/SDL2-${SDL2VER}.tar.gz && \
tar -xzf SDL2-${SDL2VER}.tar.gz && \
cd SDL2-${SDL2VER} && \
./configure --build=x86_64-linux-gnu && \
make && make install && \
rm ../SDL2-${SDL2VER}.tar.gz
RUN \
ln -sf /proc/self/mounts /etc/mtab && \
mkdir -p /usr/local/share/keyring/ && \
wget -O /usr/local/share/keyring/devkitpro-pub.gpg https://apt.devkitpro.org/devkitpro-pub.gpg && \
echo "deb [signed-by=/usr/local/share/keyring/devkitpro-pub.gpg] https://apt.devkitpro.org stable main" > /etc/apt/sources.list.d/devkitpro.list && \
apt-get update -y && \
apt-get install -y devkitpro-pacman && \
yes | dkp-pacman -Syu switch-dev switch-portlibs --noconfirm
ENV DEVKITPRO=/opt/devkitpro
ENV DEVKITARM=/opt/devkitpro/devkitARM
ENV DEVKITPPC=/opt/devkitpro/devkitPPC
ENV PATH=$PATH:/opt/devkitpro/portlibs/switch/bin/
RUN mkdir /soh
WORKDIR /soh

44
Jenkinsfile vendored
View File

@ -106,9 +106,9 @@ pipeline {
mv OTRGui/build/assets build/
mv ZAPDTR/ZAPD.out build/assets/extractor/
mv README.md readme.txt
docker exec sohcont appimage/appimage.sh
7z a soh-linux.7z SOH-Linux.AppImage readme.txt
'''
@ -158,7 +158,47 @@ pipeline {
}
}
}
stage ('Build Switch') {
options {
timeout(time: 20)
}
agent {
label "SoH-Linux-Builders"
}
steps {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: scm.extensions,
userRemoteConfigs: scm.userRemoteConfigs
])
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh '''
cp ../../ZELOOTD.z64 OTRExporter/baserom_non_mq.z64
docker build . -t sohswitch -f Dockerfile.switch
docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash
docker exec sohcont .ci/switch/buildswitch.bash
mv soh/soh.nro .
mv README.md readme.txt
7z a soh-switch.7z soh.nro readme.txt
'''
}
sh 'sudo docker container stop sohcont'
archiveArtifacts artifacts: 'soh-switch.7z', followSymlinks: false, onlyIfSuccessful: true
}
post {
always {
step([$class: 'WsCleanup']) // Clean workspace
}
}
}
}
}
}
}

36
Makefile.switch Normal file
View File

@ -0,0 +1,36 @@
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------
export SOH_TOP_DIR := $(CURDIR)
.PHONY: all clean ZAPDUtils libultraship soh StormLib
all: soh
@echo "Done!"
ZAPDUtils:
@echo "Building $@..."
@$(MAKE) --no-print-directory -C $(CURDIR)/ZAPDTR/ZAPDUtils -f $(CURDIR)/ZAPDTR/ZAPDUtils/Makefile.switch
StormLib:
@echo "Building $@..."
LDFLAGS="" ${DEVKITPRO}/portlibs/switch/bin/aarch64-none-elf-cmake -DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/Switch.cmake -DCMAKE_BUILD_TYPE=Release -B $(CURDIR)/StormLib/nxbuild -S $(CURDIR)/StormLib
@$(MAKE) --no-print-directory -C $(CURDIR)/StormLib/nxbuild -f $(CURDIR)/StormLib/nxbuild/Makefile
libultraship: StormLib ZAPDUtils
@echo "Building $@..."
@$(MAKE) --no-print-directory -C $(CURDIR)/libultraship -f $(CURDIR)/libultraship/Makefile.switch
soh: libultraship
@echo "Building $@..."
@$(MAKE) --no-print-directory -C $(CURDIR)/soh -f $(CURDIR)/soh/Makefile.switch
otr:
@echo "Building $@..."
@$(MAKE) --no-print-directory -C $(CURDIR)/soh -f $(CURDIR)/soh/Makefile setup
clean:
@$(MAKE) --no-print-directory -C $(CURDIR)/ZAPDTR/ZAPDUtils -f $(CURDIR)/ZAPDTR/ZAPDUtils/Makefile.switch clean
@$(MAKE) --no-print-directory -C $(CURDIR)/libultraship -f $(CURDIR)/libultraship/Makefile.switch clean
@$(MAKE) --no-print-directory -C $(CURDIR)/soh -f $(CURDIR)/soh/Makefile.switch clean

View File

@ -65,12 +65,6 @@
<ClCompile Include="VersionInfo.cpp" />
<ClCompile Include="VtxExporter.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>

1
StormLib/.gitignore vendored
View File

@ -140,6 +140,7 @@ Desktop.ini
*.egg-info
dist
build
nxbuild
eggs
parts
bin

View File

@ -323,6 +323,11 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DO_LARGEFILE=0 -Dstat64=stat -Dlstat64=lstat -Dlseek64=lseek -Doff64_t=off_t -Dfstat64=fstat -Dftruncate64=ftruncate")
endif()
if(NOT WIN32 AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
# Enable POSIX extensions such as `readlink` and `ftruncate`.
add_definitions(-D_POSIX_C_SOURCE=200809L)
endif()
add_library(${LIBRARY_NAME} ${LIB_TYPE} ${SRC_FILES} ${SRC_ADDITIONAL_FILES} ${STORM_DEF_FILES})
if(WIN32)
set_target_properties(${LIBRARY_NAME} PROPERTIES OUTPUT_NAME "StormLib")

View File

@ -95,7 +95,7 @@
#define PKEXPORT
#ifndef __SYS_ZLIB
#ifndef __SYS_ZLIB
#define __SYS_ZLIB
#endif

View File

@ -359,12 +359,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\OTRExporter\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\..\OTRExporter\packages\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.1.2.8.8\build\native\zlib.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />

View File

@ -0,0 +1,171 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.json
# - config.json
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
TARGET := ZAPDUtils
BUILD := build
SOURCES := Utils
DATA :=
INCLUDES :=
#-------------------------------------------------------------------------------
# source files
#-------------------------------------------------------------------------------
SOURCEFILES_C :=
SOURCEFILES_CPP :=
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions -std=gnu++20
CFLAGS += -std=gnu11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lnx
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach sf,$(SOURCEFILES_C),$(CURDIR)/$(dir $(sf))) \
$(foreach sf,$(SOURCEFILES_CPP),$(CURDIR)/$(dir $(sf)))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) \
$(foreach f,$(SOURCEFILES_C),$(notdir $(f)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) \
$(foreach f,$(SOURCEFILES_CPP),$(notdir $(f)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
lib:
@[ -d $@ ] || mkdir -p $@
$(BUILD) : lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.switch
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -rf build lib
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
$(OFILES_SRC) : $(HFILES)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -186,12 +186,6 @@
<ClCompile Include="Utils\MemoryStream.cpp" />
<ClCompile Include="Utils\StringHelper.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -9,6 +9,7 @@ UNAME := $(shell uname)
ASAN ?= 0
DEBUG ?= 1
OPTFLAGS ?= -O0
X11 ?= 0
LTO ?= 0
# flag to save whether the compiler being used is clang or gcc by checking CXX --version
@ -49,6 +50,11 @@ CPPFLAGS := -MMD
MMFLAGS := -Wno-deprecated-declarations -ObjC++ -fobjc-weak -fobjc-arc
ifeq ($(X11), 1)
CXXFLAGS += -DX11_SUPPORTED
CFLAGS += -DX11_SUPPORTED
endif
# if not using clang, ask clang to use gcc standard library
ifneq ($(CXX_IS_CLANG),1)
STD_ISYSTEM=$(shell ${CXX} -xc++ -E -v - < /dev/null 2>&1 | grep "> search starts here" -A2 | tail -n 2 | head -n 1)

View File

@ -0,0 +1,192 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.json
# - config.json
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
TARGET := ultraship
BUILD := build
SOURCES := \
libultraship/Factories \
libultraship/Lib/Fast3D \
libultraship/Lib/ImGui \
libultraship/Lib/Mercury \
libultraship
DATA :=
INCLUDES := \
../ZAPDTR/ZAPDUtils \
../StormLib/src \
libultraship/Lib/Fast3D/U64 \
libultraship/Lib/ImGui \
libultraship/Lib/spdlog \
libultraship/Lib/spdlog/include \
libultraship
#-------------------------------------------------------------------------------
# source files
#-------------------------------------------------------------------------------
SOURCEFILES_C := \
libultraship/mixer.c \
libultraship/Lib/stb/stb_impl.c \
SOURCEFILES_CPP := \
libultraship/Lib/ImGui/backends/imgui_impl_opengl3.cpp \
libultraship/Lib/ImGui/backends/imgui_impl_sdl.cpp \
libultraship/Lib/StrHash64.cpp \
libultraship/Lib/tinyxml2/tinyxml2.cpp
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE -ffast-math -O3
CFLAGS := -Wall -ffunction-sections \
$(ARCH) $(DEFINES) \
-DSPDLOG_NO_THREAD_ID \
-DSTBI_NO_THREAD_LOCALS
CFLAGS += $(INCLUDE) -D__SWITCH__ -DENABLE_OPENGL
CXXFLAGS := $(CFLAGS) -std=gnu++20
CFLAGS += -std=gnu11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lnx
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach sf,$(SOURCEFILES_C),$(CURDIR)/$(dir $(sf))) \
$(foreach sf,$(SOURCEFILES_CPP),$(CURDIR)/$(dir $(sf)))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) \
$(foreach f,$(SOURCEFILES_C),$(notdir $(f)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) \
$(foreach f,$(SOURCEFILES_CPP),$(notdir $(f)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
lib:
@[ -d $@ ] || mkdir -p $@
$(BUILD) : lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.switch
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -rf build lib
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
$(OFILES_SRC) : $(HFILES)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -6,6 +6,10 @@
#include "Lib/StrHash64.h"
#include <filesystem>
#ifdef __SWITCH__
#include "SwitchImpl.h"
#endif
namespace Ship {
Archive::Archive(const std::string& MainPath, bool enableWriting) : Archive(MainPath, "", enableWriting)
{
@ -68,7 +72,7 @@ namespace Ship {
//}
if (!attempt) {
printf("({%i}) Failed to open file {%s} from mpq archive {%s}", GetLastError(), filePath.c_str(), MainPath.c_str());
SPDLOG_ERROR("({}) Failed to open file {} from mpq archive {}.", GetLastError(), filePath.c_str(), MainPath.c_str());
std::unique_lock<std::mutex> Lock(FileToLoad->FileLoadMutex);
FileToLoad->bHasLoadError = true;
return FileToLoad;
@ -327,13 +331,21 @@ namespace Ship {
#ifdef _WIN32
std::wstring wfullPath = std::filesystem::absolute(MainPath).wstring();
#endif
#if defined(__SWITCH__)
std::string fullPath = MainPath;
#else
std::string fullPath = std::filesystem::absolute(MainPath).string();
#endif
#ifdef _WIN32
if (!SFileOpenArchive(wfullPath.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) {
#else
if (!SFileOpenArchive(fullPath.c_str(), 0, enableWriting ? 0 : MPQ_OPEN_READ_ONLY, &mpqHandle)) {
#endif
#ifdef __SWITCH__
Switch::ThrowMissingOTR(fullPath);
#endif
SPDLOG_ERROR("({}) Failed to open main mpq file {}.", GetLastError(), fullPath.c_str());
return false;
}
@ -362,7 +374,11 @@ namespace Ship {
bool Archive::LoadPatchMPQ(const std::string& path) {
HANDLE patchHandle = NULL;
#if defined(__SWITCH__)
std::string fullPath = path;
#else
std::string fullPath = std::filesystem::absolute(path).string();
#endif
if (mpqHandles.contains(fullPath)) {
return true;
}

View File

@ -98,20 +98,14 @@ void Console::Update() {
}
}
extern "C" uint8_t __enableGameInput;
void Console::Draw() {
bool input_focus = false;
__enableGameInput = true;
if (!this->opened) return;
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
ImGui::Begin("Console", nullptr, ImGuiWindowFlags_NoFocusOnAppearing);
const ImVec2 pos = ImGui::GetWindowPos();
const ImVec2 size = ImGui::GetWindowSize();
__enableGameInput = !ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows);
// SohImGui::ShowCursor(ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows | ImGuiHoveredFlags_RectOnly), SohImGui::Dialogues::dConsole);
// Renders autocomplete window
@ -230,8 +224,8 @@ void Console::Draw() {
// Renders input textfield
constexpr ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackEdit |
ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory;
ImGui::PushItemWidth(-1);
if(ImGui::InputTextWithHint("CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) {
ImGui::PushItemWidth(-53);
if(ImGui::InputTextWithHint("##CMDInput", ">", this->InputBuffer, MAX_BUFFER_SIZE, flags, &Console::CallbackStub, this)) {
input_focus = true;
if(this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' ')
this->Dispatch(std::string(this->InputBuffer));
@ -250,6 +244,13 @@ void Console::Draw() {
}
}
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetContentRegionAvail().x - 50);
if(ImGui::Button("Submit") && !input_focus && this->InputBuffer[0] != '\0' && this->InputBuffer[0] != ' '){
this->Dispatch(std::string(this->InputBuffer));
memset(this->InputBuffer, 0, MAX_BUFFER_SIZE);
}
ImGui::SetItemDefaultFocus();
if (input_focus) ImGui::SetKeyboardFocusHere(-1);
ImGui::PopItemWidth();

View File

@ -14,7 +14,7 @@ extern "C" CVar* CVar_Get(const char* name) {
return (it != cvars.end()) ? it->second.get() : nullptr;
}
extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue) {
extern "C" int32_t CVar_GetS32(const char* name, int32_t defaultValue) {
CVar* cvar = CVar_Get(name);
if (cvar) {
@ -47,7 +47,7 @@ extern "C" const char* CVar_GetString(const char* name, const char* defaultValue
return defaultValue;
}
extern "C" void CVar_SetS32(const char* name, s32 value) {
extern "C" void CVar_SetS32(const char* name, int32_t value) {
auto& cvar = cvars[name];
if (!cvar) {
cvar = std::make_unique<CVar>();
@ -74,7 +74,7 @@ extern "C" void CVar_SetString(const char* name, const char* value) {
cvar->value.valueStr = ImStrdup(value);
}
extern "C" void CVar_RegisterS32(const char* name, s32 defaultValue) {
extern "C" void CVar_RegisterS32(const char* name, int32_t defaultValue) {
if (!CVar_Get(name))
CVar_SetS32(name, defaultValue);
}

View File

@ -1,7 +1,7 @@
#ifndef _CVAR_H
#define _CVAR_H
#include <PR/ultra64/gbi.h>
#include <stdint.h>
typedef enum CVarType { CVAR_TYPE_S32, CVAR_TYPE_FLOAT, CVAR_TYPE_STRING } CVarType;
@ -10,7 +10,7 @@ typedef struct CVar {
CVarType type;
union {
s32 valueS32;
int32_t valueS32;
float valueFloat;
const char* valueStr;
} value;
@ -23,13 +23,13 @@ extern "C"
//#include <ultra64.h>
CVar* CVar_Get(const char* name);
s32 CVar_GetS32(const char* name, s32 defaultValue);
int32_t CVar_GetS32(const char* name, int32_t defaultValue);
float CVar_GetFloat(const char* name, float defaultValue);
const char* CVar_GetString(const char* name, const char* defaultValue);
void CVar_SetS32(const char* name, s32 value);
void CVar_SetS32(const char* name, int32_t value);
void CVar_SetString(const char* name, const char* value);
void CVar_RegisterS32(const char* name, s32 defaultValue);
void CVar_RegisterS32(const char* name, int32_t defaultValue);
void CVar_RegisterFloat(const char* name, float defaultValue);
void CVar_RegisterString(const char* name, const char* defaultValue);

View File

@ -9,6 +9,7 @@ namespace SohUtils {
void saveEnvironmentVar(const std::string& key, const std::string& value) {
environmentVars[key] = value;
}
std::string getEnvironmentVar(const std::string& key) {
return environmentVars[key];
}

View File

@ -38,5 +38,5 @@ namespace Ship {
void LoadFont(const std::string& name, const std::string& path, float fontSize);
};
static bool OverlayCommand(const std::vector<std::string>& args);
bool OverlayCommand(const std::vector<std::string>& args);
}

View File

@ -10,6 +10,8 @@
#include "ModManager.h"
#ifdef __APPLE__
#include "OSXFolderManager.h"
#elif defined(__SWITCH__)
#include "SwitchImpl.h"
#endif
namespace Ship {
@ -72,11 +74,16 @@ namespace Ship {
{
#ifdef _WIN32
MessageBox(nullptr, L"Main OTR file not found!", L"Uh oh", MB_OK);
#elif defined(__SWITCH__)
printf("Main OTR file not found!\n");
#else
SPDLOG_ERROR("Main OTR file not found!");
#endif
exit(1);
}
#ifdef __SWITCH__
Ship::Switch::Init(PostInitPhase);
#endif
INSTANCE = new ModManager(ResMan);
INSTANCE->Init();
}

View File

@ -27,6 +27,16 @@
#include "Lib/spdlog/include/spdlog/common.h"
#include "Utils/StringHelper.h"
#if __APPLE__
#include <SDL_hints.h>
#else
#include <SDL2/SDL_hints.h>
#endif
#ifdef __SWITCH__
#include "SwitchImpl.h"
#endif
#ifdef ENABLE_OPENGL
#include "Lib/ImGui/backends/imgui_impl_opengl3.h"
#include "Lib/ImGui/backends/imgui_impl_sdl.h"
@ -127,6 +137,7 @@ namespace SohImGui {
void ImGuiWMInit() {
switch (impl.backend) {
case Backend::SDL:
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1");
ImGui_ImplSDL2_InitForOpenGL(static_cast<SDL_Window*>(impl.sdl.window), impl.sdl.context);
break;
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
@ -339,10 +350,17 @@ namespace SohImGui {
io = &ImGui::GetIO();
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable;
io->Fonts->AddFontDefault();
#ifdef __SWITCH__
Ship::Switch::SetupFont(io->Fonts);
#endif
lastBackendID = GetBackendID(GlobalCtx2::GetInstance()->GetConfig());
if (CVar_GetS32("gOpenMenuBar", 0) != 1) {
#ifdef __SWITCH__
SohImGui::overlay->TextDrawNotification(30.0f, true, "Press - to access enhancements menu");
#else
SohImGui::overlay->TextDrawNotification(30.0f, true, "Press F1 to access enhancements menu");
#endif
}
auto imguiIniPath = Ship::GlobalCtx2::GetPathRelativeToAppDirectory("imgui.ini");
@ -358,6 +376,9 @@ namespace SohImGui {
controller->Init();
ImGuiWMInit();
ImGuiBackendInit();
#ifdef __SWITCH__
ImGui::GetStyle().ScaleAllSizes(2);
#endif
ModInternal::RegisterHook<ModInternal::GfxInit>([] {
if (GlobalCtx2::GetInstance()->GetWindow()->IsFullscreen())
@ -386,7 +407,10 @@ namespace SohImGui {
CVar_SetS32("gNewSeedGenerated", 0);
CVar_SetS32("gNewFileDropped", 0);
CVar_SetString("gDroppedFile", "None");
// Game::SaveSettings();
#ifdef __SWITCH__
Switch::ApplyOverclock();
#endif
}
void Update(EventImpl event) {
@ -734,7 +758,7 @@ namespace SohImGui {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(ImVec2(wnd->GetCurrentWidth(), wnd->GetCurrentHeight()));
ImGui::SetNextWindowSize(ImVec2((int) wnd->GetCurrentWidth(), (int) wnd->GetCurrentHeight()));
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
@ -757,7 +781,7 @@ namespace SohImGui {
ImGui::DockSpace(dockId, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_NoDockingInCentralNode);
if (ImGui::IsKeyPressed(TOGGLE_BTN)) {
if (ImGui::IsKeyPressed(TOGGLE_BTN) || ImGui::IsKeyPressed(TOGGLE_PAD_BTN)) {
bool menu_bar = CVar_GetS32("gOpenMenuBar", 0);
CVar_SetS32("gOpenMenuBar", !menu_bar);
needs_save = true;
@ -791,8 +815,13 @@ namespace SohImGui {
if (ImGui::BeginMenuBar()) {
if (DefaultAssets.contains("Game_Icon")) {
#ifdef __SWITCH__
ImVec2 iconSize = ImVec2(20.0f, 20.0f);
#else
ImVec2 iconSize = ImVec2(16.0f, 16.0f);
#endif
ImGui::SetCursorPos(ImVec2(5, 2.5f));
ImGui::Image(GetTextureByID(DefaultAssets["Game_Icon"]->textureId), ImVec2(16.0f, 16.0f));
ImGui::Image(GetTextureByID(DefaultAssets["Game_Icon"]->textureId), iconSize);
ImGui::SameLine();
ImGui::SetCursorPos(ImVec2(25, 0));
}
@ -931,8 +960,6 @@ namespace SohImGui {
EXPERIMENTAL();
ImGui::Text("Texture Filter (Needs reload)");
EnhancementCombobox("gTextureFilter", filters, 3, 0);
GfxRenderingAPI* gapi = gfx_get_current_rendering_api();
gapi->set_texture_filter((FilteringMode)CVar_GetS32("gTextureFilter", 0));
overlay->DrawSettings();
ImGui::EndMenu();
}
@ -1235,8 +1262,16 @@ namespace SohImGui {
const char* fps_cvar = "gInterpolationFPS";
{
int val = CVar_GetS32(fps_cvar, 20);
val = MAX(MIN(val, 250), 20);
#ifdef __SWITCH__
int minFps = 20;
int maxFps = 60;
#else
int minFps = 20;
int maxFps = 250;
#endif
int val = CVar_GetS32(fps_cvar, minFps);
val = MAX(MIN(val, maxFps), 20);
int fps = val;
if (fps == 20)
@ -1258,7 +1293,7 @@ namespace SohImGui {
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
if (ImGui::SliderInt("##FPSInterpolation", &val, 20, 250, "", ImGuiSliderFlags_AlwaysClamp))
if (ImGui::SliderInt("##FPSInterpolation", &val, minFps, maxFps, "", ImGuiSliderFlags_AlwaysClamp))
{
if (val > 250)
{
@ -1316,6 +1351,23 @@ namespace SohImGui {
EnhancementCheckbox("Free Camera", "gFreeCamera");
Tooltip("Enables camera control\nNote: You must remap C buttons off of\nthe right stick in the controller\nconfig menu, and map the camera stick\nto the right stick.");
#ifdef __SWITCH__
int slot = CVar_GetS32("gSwitchPerfMode", (int)SwitchProfiles::STOCK);
ImGui::Text("Switch performance mode");
if (ImGui::BeginCombo("##perf", SWITCH_CPU_PROFILES[slot])) {
for (int sId = 0; sId <= SwitchProfiles::POWERSAVINGM3; sId++) {
if (ImGui::Selectable(SWITCH_CPU_PROFILES[sId], sId == slot)) {
INFO("Profile:: %s", SWITCH_CPU_PROFILES[sId]);
CVar_SetS32("gSwitchPerfMode", sId);
Switch::ApplyOverclock();
needs_save = true;
}
}
ImGui::EndCombo();
}
#endif
ImGui::EndMenu();
}
@ -1430,6 +1482,8 @@ namespace SohImGui {
ImGui::Text("Platform: Windows");
#elif __APPLE__
ImGui::Text("Platform: macOS");
#elif defined(__SWITCH__)
ImGui::Text("Platform: Nintendo Switch");
#else
ImGui::Text("Platform: Linux");
#endif

View File

@ -9,7 +9,6 @@
namespace Ship {
extern "C" uint8_t __enableGameInput;
#define SEPARATION() ImGui::Dummy(ImVec2(0, 5))
void InputEditor::Init() {
@ -116,7 +115,11 @@ namespace Ship {
DrawButton("Z", BTN_Z);
DrawButton("START", BTN_START);
SEPARATION();
#ifdef __SWITCH__
SohImGui::EndGroupPanel(IsKeyboard ? 7.0f : 56.0f);
#else
SohImGui::EndGroupPanel(IsKeyboard ? 7.0f : 48.0f);
#endif
ImGui::SameLine();
SohImGui::BeginGroupPanel("Digital Pad", ImVec2(150, 20));
DrawButton("Up", BTN_DUP);
@ -124,7 +127,11 @@ namespace Ship {
DrawButton("Left", BTN_DLEFT);
DrawButton("Right", BTN_DRIGHT);
SEPARATION();
#ifdef __SWITCH__
SohImGui::EndGroupPanel(IsKeyboard ? 53.0f : 122.0f);
#else
SohImGui::EndGroupPanel(IsKeyboard ? 53.0f : 94.0f);
#endif
ImGui::SameLine();
SohImGui::BeginGroupPanel("Analog Stick", ImVec2(150, 20));
DrawButton("Up", BTN_STICKUP);
@ -148,7 +155,11 @@ namespace Ship {
} else {
ImGui::Dummy(ImVec2(0, 6));
}
SohImGui::EndGroupPanel(IsKeyboard ? 52.0f : 24.0f);
#ifdef __SWITCH__
SohImGui::EndGroupPanel(IsKeyboard ? 52.0f : 52.0f);
#else
SohImGui::EndGroupPanel(IsKeyboard ? 52.0f : 24.0f);
#endif
ImGui::SameLine();
if (!IsKeyboard) {
@ -174,44 +185,52 @@ namespace Ship {
ImGui::InputFloat("##MSensitivity", &profile.Thresholds[SENSITIVITY], 1.0f, 0.0f, "%.0f");
ImGui::PopItemWidth();
ImGui::EndChild();
#ifdef __SWITCH__
SohImGui::EndGroupPanel(43.0f);
#else
SohImGui::EndGroupPanel(14.0f);
#endif
}
if(Backend->CanGyro()) {
ImGui::SameLine();
SohImGui::BeginGroupPanel("Gyro Options", ImVec2(175, 20));
float cursorX = ImGui::GetCursorPosX() + 5;
ImGui::SetCursorPosX(cursorX);
ImGui::Checkbox("Enable Gyro", &profile.UseGyro);
ImGui::SetCursorPosX(cursorX);
ImGui::Text("Gyro Sensitivity: %d%%", static_cast<int>(100.0f * profile.Thresholds[GYRO_SENSITIVITY]));
ImGui::PushItemWidth(135.0f);
ImGui::SetCursorPosX(cursorX);
ImGui::SliderFloat("##GSensitivity", &profile.Thresholds[GYRO_SENSITIVITY], 0.0f, 1.0f, "");
ImGui::PopItemWidth();
ImGui::Dummy(ImVec2(0, 1));
ImGui::SetCursorPosX(cursorX);
if (ImGui::Button("Recalibrate Gyro##RGyro")) {
profile.Thresholds[DRIFT_X] = 0.0f;
profile.Thresholds[DRIFT_Y] = 0.0f;
}
ImGui::SetCursorPosX(cursorX);
DrawVirtualStick("##GyroPreview", ImVec2(-10.0f * Backend->wGyroY, 10.0f * Backend->wGyroX));
float cursorX = ImGui::GetCursorPosX() + 5;
ImGui::SetCursorPosX(cursorX);
ImGui::Checkbox("Enable Gyro", &profile.UseGyro);
ImGui::SetCursorPosX(cursorX);
ImGui::Text("Gyro Sensitivity: %d%%", static_cast<int>(100.0f * profile.Thresholds[GYRO_SENSITIVITY]));
ImGui::PushItemWidth(135.0f);
ImGui::SetCursorPosX(cursorX);
ImGui::SliderFloat("##GSensitivity", &profile.Thresholds[GYRO_SENSITIVITY], 0.0f, 1.0f, "");
ImGui::PopItemWidth();
ImGui::Dummy(ImVec2(0, 1));
ImGui::SetCursorPosX(cursorX);
if (ImGui::Button("Recalibrate Gyro##RGyro")) {
profile.Thresholds[DRIFT_X] = 0.0f;
profile.Thresholds[DRIFT_Y] = 0.0f;
}
ImGui::SetCursorPosX(cursorX);
DrawVirtualStick("##GyroPreview", ImVec2(-10.0f * Backend->wGyroY, 10.0f * Backend->wGyroX));
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
ImGui::BeginChild("##GyInput", ImVec2(90, 85), false);
ImGui::Text("Drift X");
ImGui::PushItemWidth(80);
ImGui::InputFloat("##GDriftX", &profile.Thresholds[DRIFT_X], 1.0f, 0.0f, "%.1f");
ImGui::PopItemWidth();
ImGui::Text("Drift Y");
ImGui::PushItemWidth(80);
ImGui::InputFloat("##GDriftY", &profile.Thresholds[DRIFT_Y], 1.0f, 0.0f, "%.1f");
ImGui::PopItemWidth();
ImGui::EndChild();
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 5);
ImGui::BeginChild("##GyInput", ImVec2(90, 85), false);
ImGui::Text("Drift X");
ImGui::PushItemWidth(80);
ImGui::InputFloat("##GDriftX", &profile.Thresholds[DRIFT_X], 1.0f, 0.0f, "%.1f");
ImGui::PopItemWidth();
ImGui::Text("Drift Y");
ImGui::PushItemWidth(80);
ImGui::InputFloat("##GDriftY", &profile.Thresholds[DRIFT_Y], 1.0f, 0.0f, "%.1f");
ImGui::PopItemWidth();
ImGui::EndChild();
#ifdef __SWITCH__
SohImGui::EndGroupPanel(46.0f);
#else
SohImGui::EndGroupPanel(14.0f);
#endif
}
ImGui::SameLine();
@ -227,7 +246,11 @@ namespace Ship {
SohImGui::EndGroupPanel();
ImGui::SetCursorPosX(cursor.x);
#ifdef __SWITCH__
ImGui::SetCursorPosY(cursor.y + 167);
#else
ImGui::SetCursorPosY(cursor.y + 120);
#endif
SohImGui::BeginGroupPanel("Options", ImVec2(158, 20));
float cursorX = ImGui::GetCursorPosX() + 5;
ImGui::SetCursorPosX(cursorX);
@ -245,16 +268,21 @@ namespace Ship {
}
void InputEditor::DrawHud() {
__enableGameInput = true;
if (!this->Opened) {
BtnReading = -1;
CVar_SetS32("gControllerConfigurationEnabled", 0);
return;
}
ImGui::SetNextWindowSizeConstraints(ImVec2(641, 250), ImVec2(1200, 290));
#ifdef __SWITCH__
ImVec2 minSize = ImVec2(641, 250);
ImVec2 maxSize = ImVec2(2200, 505);
#else
ImVec2 minSize = ImVec2(641, 250);
ImVec2 maxSize = ImVec2(1200, 290);
#endif
ImGui::SetNextWindowSizeConstraints(minSize, maxSize);
//OTRTODO: Disable this stupid workaround ( ReadRawPress() only works when the window is on the main viewport )
ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
ImGui::Begin("Controller Configuration", &this->Opened, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize);

View File

@ -1,4 +1,4 @@
#ifdef __linux__
#if defined(__linux__) && defined(X11_SUPPORTED)
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
@ -156,6 +156,7 @@ static struct {
Atom atom_wm_delete_window;
bool is_fullscreen;
bool is_running = true;
void (*on_fullscreen_changed)(bool is_now_fullscreen);
int keymap[256];
@ -399,7 +400,7 @@ static void gfx_glx_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo
}
static void gfx_glx_main_loop(void (*run_one_game_iter)(void)) {
while (1) {
while (glx.is_running) {
run_one_game_iter();
}
}
@ -440,7 +441,7 @@ static void gfx_glx_handle_events(void) {
}
}
if (xev.type == ClientMessage && (Atom)xev.xclient.data.l[0] == glx.atom_wm_delete_window) {
exit(0);
glx.is_running = false;
}
}
}

View File

@ -31,6 +31,9 @@
#elif __APPLE__
#include <SDL.h>
#include <GL/glew.h>
#elif __SWITCH__
#include <SDL2/SDL.h>
#include <glad/glad.h>
#else
#include <SDL2/SDL.h>
#include <GL/glew.h>
@ -643,6 +646,10 @@ static void gfx_opengl_upload_texture(const uint8_t *rgba32_buf, uint32_t width,
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba32_buf);
}
#ifdef __SWITCH__
#define GL_MIRROR_CLAMP_TO_EDGE 0x8743
#endif
static uint32_t gfx_cm_to_opengl(uint32_t val) {
switch (val) {
case G_TX_NOMIRROR | G_TX_CLAMP:
@ -710,9 +717,9 @@ static void gfx_opengl_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_
}
static void gfx_opengl_init(void) {
//#if FOR_WINDOWS
#ifndef __SWITCH__
glewInit();
//#endif
#endif
glGenBuffers(1, &opengl_vbo);
glBindBuffer(GL_ARRAY_BUFFER, opengl_vbo);
@ -840,9 +847,7 @@ void gfx_opengl_start_draw_to_framebuffer(int fb_id, float noise_scale) {
if (noise_scale != 0.0f) {
current_noise_scale = 1.0f / noise_scale;
}
glBindFramebuffer(GL_FRAMEBUFFER, fb.fbo);
current_framebuffer = fb_id;
}

View File

@ -1206,8 +1206,8 @@ static void gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t vtx3_idx, bo
rdp.viewport_or_scissor_changed = false;
}
uint64_t cc_id = rdp.combine_mode;
uint64_t cc_id = rdp.combine_mode;
bool use_alpha = (rdp.other_mode_l & (3 << 20)) == (G_BL_CLR_MEM << 20) && (rdp.other_mode_l & (3 << 16)) == (G_BL_1MA << 16);
bool use_fog = (rdp.other_mode_l >> 30) == G_BL_CLR_FOG;
bool texture_edge = (rdp.other_mode_l & CVG_X_ALPHA) == CVG_X_ALPHA;

View File

@ -15,6 +15,11 @@
#include "SDL_opengl.h"
#elif __APPLE__
#include <SDL.h>
#elif __SWITCH__
#include <SDL2/SDL.h>
#include <switch.h>
#include <glad/glad.h>
#include "../../SwitchImpl.h"
#else
#include <SDL2/SDL.h>
#define GL_GLEXT_PROTOTYPES 1
@ -42,6 +47,7 @@ static int vsync_enabled = 0;
static int window_width = DESIRED_SCREEN_WIDTH;
static int window_height = DESIRED_SCREEN_HEIGHT;
static bool fullscreen_state;
static bool is_running = true;
static void (*on_fullscreen_changed_callback)(bool is_now_fullscreen);
static bool (*on_key_down_callback)(int scancode);
static bool (*on_key_up_callback)(int scancode);
@ -146,31 +152,43 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen, uint32
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
#elif defined(__SWITCH__)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#endif
#ifdef _WIN32
timer = CreateWaitableTimer(nullptr, false, nullptr);
#endif
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
char title[512];
int len = sprintf(title, "%s (%s)", game_name, GFX_API_NAME);
window_width = width;
window_height = height;
#ifdef __SWITCH__
// For Switch we need to set the window width before creating the window
Ship::Switch::GetDisplaySize(&window_width, &window_height);
#endif
wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
#ifndef __SWITCH__
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
if (start_in_fullscreen) {
set_fullscreen(true, false);
}
#endif
ctx = SDL_GL_CreateContext(wnd);
#ifdef __SWITCH__
if(!gladLoadGLLoader(SDL_GL_GetProcAddress)){
printf("Failed to initialize glad\n");
}
#endif
SDL_GL_SetSwapInterval(1);
SohImGui::WindowImpl window_impl;
@ -211,14 +229,21 @@ static void gfx_sdl_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo
}
static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) {
while (1)
{
#ifdef __SWITCH__
while(Ship::Switch::IsRunning()) {
#else
while(is_running) {
#endif
run_one_game_iter();
}
#ifdef __SWITCH__
Ship::Switch::Exit();
#endif
ModInternal::ExecuteHooks<ModInternal::ExitGame>();
}
static void gfx_sdl_get_dimensions(uint32_t *width, uint32_t *height) {
*width = window_width;
*width = window_width;
*height = window_height;
}
@ -271,7 +296,11 @@ static void gfx_sdl_handle_events(void) {
#endif
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
#ifdef __SWITCH__
Ship::Switch::GetDisplaySize(&window_width, &window_height);
#else
SDL_GL_GetDrawableSize(wnd, &window_width, &window_height);
#endif
}
break;
case SDL_DROPFILE:
@ -303,7 +332,7 @@ static inline void sync_framerate_with_timer(void) {
const int64_t next = previous_time + 10 * FRAME_INTERVAL_US_NUMERATOR / FRAME_INTERVAL_US_DENOMINATOR;
const int64_t left = next - t;
if (left > 0) {
#if defined __linux__ || defined __APPLE__
#ifndef _WIN32
const timespec spec = { 0, left * 100 };
nanosleep(&spec, nullptr);
#else

View File

@ -132,6 +132,10 @@
#else
#include <GLES3/gl3.h> // Use GL ES 3
#endif
#elif defined(__SWITCH__)
#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#define GL_GLEXT_PROTOTYPES 1
#include <glad/glad.h>
#elif !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
// Helper libraries are often used for this purpose! Here we are using our own minimal custom loader based on gl3w.

View File

@ -65,6 +65,7 @@
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_internal.h"
// SDL
// (the multi-viewports feature requires SDL features supported from SDL 2.0.4+. SDL 2.0.5+ is highly recommended)
@ -77,7 +78,7 @@
#include <SDL2/SDL_syswm.h>
#endif
#if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__)
#if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) && !defined(__amigaos4__) && !defined(__SWITCH__)
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1
#else
#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0
@ -105,6 +106,7 @@ struct ImGui_ImplSDL2_Data
char* ClipboardTextData;
bool MouseCanUseGlobalState;
bool UseVulkan;
bool ShowingVirtualKeyboard;
ImGui_ImplSDL2_Data() { memset((void*)this, 0, sizeof(*this)); }
};
@ -269,6 +271,23 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
{
ImGuiIO& io = ImGui::GetIO();
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
ImGuiInputTextState* state = ImGui::GetInputTextState(ImGui::GetActiveID());
#ifdef __SWITCH__
if (io.WantTextInput) {
if (!bd->ShowingVirtualKeyboard) {
state->ClearText();
bd->ShowingVirtualKeyboard = true;
SDL_StartTextInput();
}
} else {
if (bd->ShowingVirtualKeyboard) {
bd->ShowingVirtualKeyboard = false;
SDL_StopTextInput();
}
}
#endif
switch (event->type)
{
@ -411,6 +430,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
// Our mouse update function expect PlatformHandle to be filled for the main viewport
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
main_viewport->PlatformHandle = (void*)window;
#if defined(_WIN32) || defined(__APPLE__)
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(window, &info))
@ -421,6 +441,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
main_viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
#endif
}
#endif
// Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
// Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
@ -583,8 +604,11 @@ static void ImGui_ImplSDL2_UpdateMouseCursor()
static void ImGui_ImplSDL2_UpdateGamepads()
{
ImGuiIO& io = ImGui::GetIO();
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
return;
// Remove this check because we always want to be able to trigger the menu via controller
// The ImGuiConfigFlags_NavEnableGamepad is still separately used by ImGui for enabling imgui navigation
// if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
// return;
// Get gamepad
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
@ -600,10 +624,17 @@ static void ImGui_ImplSDL2_UpdateGamepads()
const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value.
MAP_BUTTON(ImGuiKey_GamepadStart, SDL_CONTROLLER_BUTTON_START);
MAP_BUTTON(ImGuiKey_GamepadBack, SDL_CONTROLLER_BUTTON_BACK);
#ifdef __SWITCH__
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_B); // Xbox A, PS Cross
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_A); // Xbox B, PS Circle
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_Y); // Xbox X, PS Square
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_X); // Xbox Y, PS Triangle
#else
MAP_BUTTON(ImGuiKey_GamepadFaceDown, SDL_CONTROLLER_BUTTON_A); // Xbox A, PS Cross
MAP_BUTTON(ImGuiKey_GamepadFaceRight, SDL_CONTROLLER_BUTTON_B); // Xbox B, PS Circle
MAP_BUTTON(ImGuiKey_GamepadFaceLeft, SDL_CONTROLLER_BUTTON_X); // Xbox X, PS Square
MAP_BUTTON(ImGuiKey_GamepadFaceUp, SDL_CONTROLLER_BUTTON_Y); // Xbox Y, PS Triangle
#endif
MAP_BUTTON(ImGuiKey_GamepadDpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
MAP_BUTTON(ImGuiKey_GamepadDpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
MAP_BUTTON(ImGuiKey_GamepadDpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP);
@ -757,6 +788,7 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
SDL_GL_MakeCurrent(vd->Window, backup_context);
viewport->PlatformHandle = (void*)vd->Window;
#if defined(_WIN32) || defined(__APPLE__)
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(vd->Window, &info))
@ -767,6 +799,7 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
#endif
}
#endif
}
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)

View File

@ -4,6 +4,10 @@
#include "Window.h"
#include <Utils/StringHelper.h>
#ifdef _MSC_VER
#define strdup _strdup
#endif
extern "C" uint8_t __osMaxControllers;
namespace Ship {
@ -25,11 +29,16 @@ namespace Ship {
char GuidBuf[33];
SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(physicalSlot), GuidBuf, sizeof(GuidBuf));
GUID = std::string(GuidBuf);
Cont = NewCont;
wCamX = 0;
wCamY = 0;
#ifdef __SWITCH__
GUID = StringHelper::Sprintf("%s:%d", GuidBuf, physicalSlot);
ControllerName = StringHelper::Sprintf("%s #%d", SDL_GameControllerNameForIndex(physicalSlot), physicalSlot + 1);
#else
GUID = std::string(GuidBuf);
ControllerName = std::string(SDL_GameControllerNameForIndex(physicalSlot));
#endif
return true;
}
@ -441,7 +450,7 @@ namespace Ship {
}
const char* SDLController::GetControllerName() {
return SDL_GameControllerNameForIndex(physicalSlot);
return strdup(ControllerName.c_str());
}
void SDLController::CreateDefaultBinding(int32_t slot) {

View File

@ -31,6 +31,7 @@ namespace Ship {
void CreateDefaultBinding(int32_t slot) override;
private:
std::string ControllerName = "Unknown";
SDL_GameController* Cont;
int physicalSlot;
bool supportsGyro;

View File

@ -0,0 +1,286 @@
#ifdef __SWITCH__
#include "SwitchImpl.h"
#include <switch.h>
#include <SDL2/SDL.h>
#include "SwitchPerformanceProfiles.h"
#include "Cvar.h"
#include "Hooks.h"
extern "C" s32 CVar_GetS32(const char* name, s32 defaultValue);
extern "C" void CVar_SetS32(const char* name, s32 value);
#define DOCKED_MODE 1
#define HANDHELD_MODE 0
static AppletHookCookie applet_hook_cookie;
static bool isRunning = true;
static bool hasFocus = true;
void DetectAppletMode();
static void on_applet_hook(AppletHookType hook, void *param);
void Ship::Switch::Init(SwitchPhase phase){
switch(phase){
case PreInitPhase:
DetectAppletMode();
break;
case PostInitPhase:
appletInitializeGamePlayRecording();
#ifdef DEBUG
socketInitializeDefault();
nxlinkStdio();
#endif
appletSetGamePlayRecordingState(true);
appletHook(&applet_hook_cookie, on_applet_hook, NULL);
appletSetFocusHandlingMode(AppletFocusHandlingMode_NoSuspend);
if (!hosversionBefore(8, 0, 0)) {
clkrstInitialize();
}
break;
}
}
void Ship::Switch::Exit(){
#ifdef DEBUG
socketExit();
#endif
clkrstExit();
appletSetGamePlayRecordingState(false);
}
void Ship::Switch::SetupFont(ImFontAtlas* fonts) {
plInitialize(PlServiceType_System);
static PlFontData stdFontData, extFontData;
PlFontData fonts_std;
PlFontData fonts_ext;
plGetSharedFontByType(&fonts_std, PlSharedFontType_Standard);
plGetSharedFontByType(&fonts_ext, PlSharedFontType_NintendoExt);
ImFontConfig config;
config.FontDataOwnedByAtlas = false;
strcpy(config.Name, "Nintendo Standard");
fonts->AddFontFromMemoryTTF (fonts_std.address, fonts_std.size, 24.0f, &config, fonts->GetGlyphRangesCyrillic());
strcpy(config.Name, "Nintendo Ext");
static const ImWchar ranges[] =
{
0xE000, 0xE06B,
0xE070, 0xE07E,
0xE080, 0xE099,
0xE0A0, 0xE0BA,
0xE0C0, 0xE0D6,
0xE0E0, 0xE0F5,
0xE100, 0xE105,
0xE110, 0xE116,
0xE121, 0xE12C,
0xE130, 0xE13C,
0xE140, 0xE14D,
0xE150, 0xE153,
0,
};
fonts->AddFontFromMemoryTTF (fonts_ext.address, fonts_ext.size, 24.0f, &config, ranges);
fonts->Build ();
plExit();
}
bool Ship::Switch::IsRunning(){
return isRunning;
}
void Ship::Switch::GetDisplaySize(int *width, int *height) {
switch (appletGetOperationMode()) {
case DOCKED_MODE:
*width = 1920;
*height = 1080;
break;
case HANDHELD_MODE:
*width = 1280;
*height = 720;
break;
}
}
void Ship::Switch::ApplyOverclock(void) {
SwitchProfiles perfMode = (SwitchProfiles) CVar_GetS32("gSwitchPerfMode", (int) Ship::MAXIMUM);
if (perfMode >= 0 && perfMode <= Ship::POWERSAVINGM3) {
if (hosversionBefore(8, 0, 0)) {
pcvSetClockRate(PcvModule_CpuBus, SWITCH_CPU_SPEEDS_VALUES[ perfMode ]);
} else {
ClkrstSession session = {0};
clkrstOpenSession(&session, PcvModuleId_CpuBus, 3);
clkrstSetClockRate(&session, SWITCH_CPU_SPEEDS_VALUES[ perfMode ]);
clkrstCloseSession(&session);
}
}
}
struct Star {
SDL_Rect* rect;
float speed;
int layer;
int8_t color[3];
};
std::vector<Star*> stars;
void Ship::Switch::PrintErrorMessageToScreen(const char *str, ...) {
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return;
int width, height;
Uint64 now, last, deltaTime;
GetDisplaySize(&width, &height);
SDL_Window* win = SDL_CreateWindow("Switch-Error", 0, 0, width, height, 0);
SDL_Renderer* renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
va_list args;
va_start(args, str);
vprintf(str, args);
va_end(args);
int layers = 9;
for(int layer = 0; layer < layers; layer++) {
for(int i = 0; i < 100; i++) {
srand(time(0));
int brightness = 50 - layer * (rand() * 5);
SDL_Rect rect;
rect.x = rand() % width;
rect.y = i*i;
rect.w = rand() % 20;
rect.h = rand() % 20;
stars.push_back(new Star{
&rect,
0.03f,
layer,
{
120 + brightness,
120 + brightness,
120 + brightness
}
});
}
}
while(appletMainLoop()){
SDL_Event e;
if ( SDL_PollEvent(&e) ) {
if (e.type == SDL_QUIT)
break;
}
last = now;
now = SDL_GetPerformanceCounter();
deltaTime = (double)((now - last) * 1000 / (double) SDL_GetPerformanceFrequency() );
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
for(int i = 0; i < stars.size(); i++){
Star* star = stars[i];
if(star->rect->x >= width){
star->rect->x = -star->rect->w;
}
star->rect->x += 1;
// star->rect->y += (cos((star->rect->x / star->layer)) * .9f ) / 16;
SDL_SetRenderDrawColor(renderer, star->color[0], star->color[1], star->color[2], 255);
SDL_RenderFillRect( renderer, star->rect );
}
SDL_RenderPresent(renderer);
SDL_Delay(0);
}
}
static void on_applet_hook(AppletHookType hook, void *param) {
AppletFocusState focus_state;
/* Exit request */
switch (hook) {
case AppletHookType_OnExitRequest:
isRunning = false;
break;
/* Focus state*/
case AppletHookType_OnFocusState:
focus_state = appletGetFocusState();
hasFocus = focus_state == AppletFocusState_InFocus;
if (!hasFocus) {
if (hosversionBefore(8, 0, 0)) {
pcvSetClockRate(PcvModule_CpuBus, SWITCH_CPU_SPEEDS_VALUES[ Ship::STOCK ]);
} else {
ClkrstSession session = {0};
clkrstOpenSession(&session, PcvModuleId_CpuBus, 3);
clkrstSetClockRate(&session, SWITCH_CPU_SPEEDS_VALUES[ Ship::STOCK ]);
clkrstCloseSession(&session);
}
} else
Ship::Switch::ApplyOverclock();
break;
/* Performance mode */
case AppletHookType_OnPerformanceMode:
Ship::Switch::ApplyOverclock();
break;
default: break;
}
}
const char* RandomTexts[] = {
"Psst, don't forget to blame Melon",
"Potsanity when?",
"Why are you acting so random?",
"Enough! My ship sails in the morning",
"Do you want 2 or 7 of those?",
"Lamp oil, rope, bombs you want it, it's yours my friend as long as you have enough rupees",
"You can build it yourself",
"Descargar para android",
"Made with <3 by the Harbour Masters!",
"They say that Kenix is not a developer",
"Squadala we're off",
"They say one once saw an equals not get set equals",
"This is the port all true gamers dock at"
"Enhancements? Times Savers? Cheats? You want them? They're yours my friend!",
"They say you gotta have the BIIIIG salad",
"They say Louis stopped working on the imports so he can focus on the exports",
"They say ZAPD is good software",
};
void DetectAppletMode() {
AppletType at = appletGetAppletType();
if (at == AppletType_Application || at == AppletType_SystemApplication)
return;
srand(time(0));
Ship::Switch::PrintErrorMessageToScreen(
"\x1b[2;2HYou've launched the Ship while in Applet mode."
"\x1b[4;2HPlease relaunch while in full-memory mode."
"\x1b[5;2HHold R when opening any game to enter HBMenu."
"\x1b[44;2H%s."
, RandomTexts[rand() % 25]);
}
void Ship::Switch::ThrowMissingOTR(std::string OTRPath){
Ship::Switch::PrintErrorMessageToScreen(
"\x1b[2;2HYou've launched the Ship without the OTR file."
"\x1b[4;2HPlease relaunch making sure %s exists."
"\x1b[44;2H%s."
, OTRPath.c_str(), RandomTexts[rand() % 25]);
}
#endif

View File

@ -0,0 +1,36 @@
#pragma once
#include <cstdint>
#include <string>
#include "Lib/ImGui/imgui.h"
#include "SwitchPerformanceProfiles.h"
namespace Ship {
enum SwitchProfiles {
MAXIMUM,
HIGH,
BOOST,
STOCK,
POWERSAVINGM1,
POWERSAVINGM2,
POWERSAVINGM3
};
enum SwitchPhase {
PreInitPhase,
PostInitPhase
};
class Switch {
public:
static void Init(SwitchPhase phase);
static void Exit();
static void SetupFont(ImFontAtlas* fonts);
static bool IsRunning();
static void GetDisplaySize(int *width, int *height);
static void ApplyOverclock();
static void ThrowMissingOTR(std::string OTRPath);
static void PrintErrorMessageToScreen(const char *str, ...);
};
};

View File

@ -0,0 +1,21 @@
#pragma once
static const char *SWITCH_CPU_PROFILES[] = {
"Maximum Performance",
"High Performance",
"Boost Performance",
"Stock Performance",
"Powersaving Mode 1",
"Powersaving Mode 2",
"Powersaving Mode 3",
};
static unsigned SWITCH_CPU_SPEEDS_VALUES[] = {
1785000000,
1581000000,
1224000000,
1020000000,
918000000,
816000000,
714000000
};

View File

@ -28,6 +28,7 @@
#include <chrono>
#include "Hooks.h"
#include "Console.h"
#include "Cvar.h"
#include <iostream>
@ -35,7 +36,6 @@ extern "C" {
struct OSMesgQueue;
uint8_t __osMaxControllers = MAXCONTROLLERS;
uint8_t __enableGameInput = 1;
int32_t osContInit(OSMesgQueue* mq, uint8_t* controllerBits, OSContStatus* status) {
*controllerBits = 0;
@ -45,6 +45,7 @@ extern "C" {
exit(EXIT_FAILURE);
}
#ifndef __SWITCH__
const char* controllerDb = "gamecontrollerdb.txt";
int mappingsAdded = SDL_GameControllerAddMappingsFromFile(controllerDb);
if (mappingsAdded >= 0) {
@ -52,6 +53,7 @@ extern "C" {
} else {
SPDLOG_ERROR("Failed add SDL game controller mappings from \"{}\" ({})", controllerDb, SDL_GetError());
}
#endif
Ship::Window::ControllerApi->Init(controllerBits);
@ -72,7 +74,7 @@ extern "C" {
pad->gyro_x = 0;
pad->gyro_y = 0;
if (__enableGameInput) {
if (!CVar_GetS32("gOpenMenuBar", 0)) {
Ship::Window::ControllerApi->WriteToPad(pad);
}
@ -302,7 +304,6 @@ namespace Ship {
void Window::MainLoop(void (*MainFunction)(void)) {
WmApi->main_loop(MainFunction);
}
bool Window::KeyUp(int32_t dwScancode) {
std::shared_ptr<Mercury> pConf = GlobalCtx2::GetInstance()->GetConfig();
@ -314,7 +315,7 @@ namespace Ship {
//if (dwScancode == Ship::stoi(Conf["KEYBOARD SHORTCUTS"]["KEY_CONSOLE"])) {
// ToggleConsole();
//}
lastScancode = -1;
bool bIsProcessed = false;

View File

@ -22,7 +22,7 @@ void SetWindowManager(struct GfxWindowManagerAPI** WmApi, struct GfxRenderingAPI
// First set default
#ifdef ENABLE_OPENGL
*RenderingApi = &gfx_opengl_api;
#if defined(__linux__)
#if defined(__linux__) && defined(X11_SUPPORTED)
// LINUX_TODO:
// *WmApi = &gfx_glx;
*WmApi = &gfx_sdl;
@ -51,7 +51,7 @@ void SetWindowManager(struct GfxWindowManagerAPI** WmApi, struct GfxRenderingAPI
*RenderingApi = &gfx_opengl_api;
*WmApi = &gfx_sdl;
}
#ifdef __linux__
#if defined(__linux__) && defined(X11_SUPPORTED)
if (gfx_backend == "glx") {
*RenderingApi = &gfx_opengl_api;
*WmApi = &gfx_glx;

View File

@ -450,12 +450,6 @@
<ClInclude Include="SDLController.h" />
<ClInclude Include="WindowShim.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OTRGui\build\ZERO_CHECK.vcxproj">
<Project>{02d10590-9542-3f55-aaf8-6055677e2a2a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -179,7 +179,7 @@ all:
$(MAKE) $(TARGET)
setup:
cd ../OTRExporter && python3 extract_baserom.py
cd ../OTRExporter
$(MAKE) mpq
mpq:

280
soh/Makefile.switch Normal file
View File

@ -0,0 +1,280 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.json
# - config.json
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := switch
DATA :=
INCLUDES := \
. \
assets \
build \
include \
src \
../ZAPDTR/ZAPDUtils \
../libultraship/libultraship \
../libultraship/libultraship/Lib/spdlog/include \
../libultraship/libultraship/Lib/Fast3D/U64 \
../libultraship/libultraship/Lib/Fast3D/U64/PR
#-------------------------------------------------------------------------------
# source files
#-------------------------------------------------------------------------------
SOURCEFILES_C := \
$(shell find soh -type f -name "*.c") \
$(shell find src/boot -type f -name "*.c") \
$(shell find src/buffers -type f -name "*.c") \
$(shell find src/code -type f -name "*.c") \
$(shell find src/overlays -type f -name "*.c") \
src/libultra/gu/coss.c \
src/libultra/gu/guLookAt.c \
src/libultra/gu/guLookAtHilite.c \
src/libultra/gu/guPerspectiveF.c \
src/libultra/gu/guPosition.c \
src/libultra/gu/guS2DInitBg.c \
src/libultra/gu/ortho.c \
src/libultra/gu/rotate.c \
src/libultra/gu/sins.c \
src/libultra/gu/sintable.c \
src/libultra/libc/sprintf.c
SOURCEFILES_CPP := \
$(shell find soh -type f -name "*.cpp")
#---------------------------------------------------------------------------------
# app info
#---------------------------------------------------------------------------------
APP_TITLE := Ship of Harkinian
APP_AUTHOR := Harbour Masters
APP_VERSION := Rachael-Alfa
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE -ffast-math -O3
CFLAGS := -ffunction-sections \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__ \
-DSPDLOG_NO_THREAD_ID \
-DSTBI_NO_THREAD_LOCALS \
`sdl2-config --cflags`
CXXFLAGS := $(CFLAGS) -std=gnu++20 -fpermissive
CFLAGS += -std=gnu11
# disable some warnings
CFLAGS += -Wno-incompatible-pointer-types -Wno-int-conversion \
-Wno-builtin-declaration-mismatch -Wno-implicit-function-declaration \
-Wno-stringop-overflow -Wno-discarded-qualifiers -Wno-switch-unreachable
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
STATIC_LIBS := $(SOH_TOP_DIR)/libultraship/lib/libultraship.a \
$(SOH_TOP_DIR)/ZAPDTR/ZAPDUtils/lib/libZAPDUtils.a \
$(SOH_TOP_DIR)/ZAPDTR/ZAPDUtils/lib/libZAPDUtils.a \
$(SOH_TOP_DIR)/StormLib/nxbuild/libstorm.a \
LIBS := -L$(SOH_TOP_DIR)/StormLib/nxbuild/ -lultraship -lZAPDUtils -lstorm -lz -lbz2 -lnx -lglad -lglapi -ldrm_nouveau -lm `sdl2-config --libs`
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX) $(SOH_TOP_DIR)/StormLib/nxbuild $(SOH_TOP_DIR)/libultraship $(SOH_TOP_DIR)/ZAPDTR/ZAPDUtils
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach sf,$(SOURCEFILES_C),$(CURDIR)/$(dir $(sf))) \
$(foreach sf,$(SOURCEFILES_CPP),$(CURDIR)/$(dir $(sf)))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) \
$(foreach f,$(SOURCEFILES_C),$(notdir $(f)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) \
$(foreach f,$(SOURCEFILES_CPP),$(notdir $(f)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(CONFIG_JSON)),)
jsons := $(wildcard *.json)
ifneq (,$(findstring $(TARGET).json,$(jsons)))
export APP_JSON := $(TOPDIR)/$(TARGET).json
else
ifneq (,$(findstring config.json,$(jsons)))
export APP_JSON := $(TOPDIR)/config.json
endif
endif
else
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
endif
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.jpg)
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
else
ifneq (,$(findstring icon.jpg,$(icons)))
export APP_ICON := $(TOPDIR)/icon.jpg
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_ICON)),)
export NROFLAGS += --icon=$(APP_ICON)
endif
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.switch
#---------------------------------------------------------------------------------
clean:
@echo clean ...
ifeq ($(strip $(APP_JSON)),)
@rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
else
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(APP_JSON)),)
all : $(OUTPUT).nro
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf
endif
else
all : $(OUTPUT).nsp
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
$(OUTPUT).nso : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES) \
$(STATIC_LIBS)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

BIN
soh/icon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -60,7 +60,7 @@ void Locale_ResetRegion(void);
u32 func_80001F48(void);
u32 func_80001F8C(void);
u32 Locale_IsRegionNative(void);
#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__SWITCH__)
void __assert(const char* exp, const char* file, s32 line);
#endif
void isPrintfInit(void);
@ -1872,7 +1872,7 @@ void FaultDrawer_SetCharPad(s8, s8);
void FaultDrawer_SetCursor(s32, s32);
void FaultDrawer_FillScreen();
void* FaultDrawer_FormatStringFunc(void*, const char*, u32);
void FaultDrawer_VPrintf(const char*, char*);
void FaultDrawer_VPrintf(const char*, va_list);
void FaultDrawer_Printf(const char*, ...);
void FaultDrawer_DrawText(s32, s32, const char*, ...);
void FaultDrawer_SetDrawerFB(void*, u16, u16);

View File

@ -783,6 +783,8 @@ typedef struct {
/* 0x0E */ u8 ttl; // duration after which the DMA can be discarded
} SampleDma; // size = 0x10
#include <PR/ultra64/abi.h>
typedef struct {
/* 0x0000 */ char unk_0000;
/* 0x0001 */ s8 numSynthesisReverbs;

View File

@ -44,11 +44,6 @@ void BootCommands_ParseBootArgs(s32 argc, char** argv)
}
}
}
for (i = 0; i < argc; i++)
DebugArena_Free(argv[i]);
//DebugArena_Free(argv);
}
/*

View File

@ -8,6 +8,7 @@
#include <map>
#include <string>
#include <Cvar.h>
#include <PR/ultra64/types.h>
/**
* Colors variables
@ -93,10 +94,10 @@ const char* RainbowColorCvarList[] = {
"gCCRupeePrim", "gCCKeysPrim", "gDog1Col", "gDog2Col", "gCCVSOAPrim",
"gKeese1_Ef_Prim","gKeese2_Ef_Prim","gKeese1_Ef_Env","gKeese2_Ef_Env",
"gDF_Col", "gDF_Env",
"gNL_Diamond_Col", "gNL_Diamond_Env", "gNL_Orb_Col", "gNL_Orb_Env",
"gNL_Diamond_Col", "gNL_Diamond_Env", "gNL_Orb_Col", "gNL_Orb_Env",
"gTrailCol", "gCharged1Col", "gCharged1ColEnv", "gCharged2Col", "gCharged2ColEnv",
"gCCFileChoosePrim", "gCCFileChooseTextPrim", "gCCEquipmentsPrim", "gCCItemsPrim",
"gCCMapsPrim", "gCCQuestsPrim", "gCCSavePrim", "gCCGameoverPrim",
"gCCMapsPrim", "gCCQuestsPrim", "gCCSavePrim", "gCCGameoverPrim",
};
const char* MarginCvarList[] {
"gHearts", "gMagicBar", "gVSOA", "gBBtn", "gABtn", "gStartBtn",

View File

@ -10,6 +10,7 @@
#define NOGDI
#define WIN32_LEAN_AND_MEAN
#include <GlobalCtx2.h>
#include <PR/ultra64/types.h>
#define TICKS_PER_SEC 268123480.0

View File

@ -300,7 +300,7 @@ static void WriteLocation(
// node->SetAttribute("price", price);
// }
// if (!location->IsAddedToPool()) {
// #ifdef ENABLE_DEBUG
// #ifdef ENABLE_DEBUG
// node->SetAttribute("not-added", true);
// #endif
// }
@ -673,7 +673,7 @@ static void WriteHints(int language) {
static void WriteAllLocations(int language) {
for (const uint32_t key : allLocations) {
ItemLocation* location = Location(key);
switch (language) {
case 0:
default:
@ -725,7 +725,7 @@ const char* SpoilerLog_Write(int language) {
WriteHints(language);
//WriteShuffledEntrances(spoilerLog);
WriteAllLocations(language);
if (!std::filesystem::exists(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"))) {
std::filesystem::create_directory(Ship::GlobalCtx2::GetPathRelativeToAppDirectory("Randomizer"));
}

View File

@ -51,6 +51,10 @@
#include <SDL2/SDL_scancode.h>
#endif
#ifdef __SWITCH__
#include "SwitchImpl.h"
#endif
#include <Audio.h>
OTRGlobals* OTRGlobals::Instance;
@ -104,6 +108,9 @@ extern "C" void OTRExtScanner() {
}
extern "C" void InitOTR() {
#ifdef __SWITCH__
Ship::Switch::Init(Ship::PreInitPhase);
#endif
OTRGlobals::Instance = new OTRGlobals();
SaveManager::Instance = new SaveManager();
auto t = OTRGlobals::Instance->context->GetResourceManager()->LoadFile("version");
@ -225,6 +232,7 @@ extern "C" void Graph_StartFrame() {
// C->C++ Bridge
extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
#ifndef __SWITCH__
if (!audio.initialized) {
audio.initialized = true;
std::thread([]() {
@ -251,19 +259,16 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
#define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 )
#define NUM_AUDIO_CHANNELS 2
int samples_left = AudioPlayer_Buffered();
u32 num_audio_samples = samples_left < AudioPlayer_GetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
// printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
// 3 is the maximum authentic frame divisor.
s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3];
for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples);
}
//for (uint32_t i = 0; i < 2 * num_audio_samples; i++) {
// audio_buffer[i] = Rand_Next() & 0xFF;
//}
// printf("Audio samples before submitting: %d\n", audio_api->buffered());
AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE));
audio.processing = false;
@ -276,8 +281,9 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
std::unique_lock<std::mutex> Lock(audio.mutex);
audio.processing = true;
}
audio.cv_to_thread.notify_one();
#endif
audio.cv_to_thread.notify_one();
std::vector<std::unordered_map<Mtx*, MtxF>> mtx_replacements;
int target_fps = CVar_GetS32("gInterpolationFPS", 20);
static int last_fps;
@ -318,12 +324,14 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
last_fps = fps;
last_update_rate = R_UPDATE_RATE;
#ifndef __SWITCH__
{
std::unique_lock<std::mutex> Lock(audio.mutex);
while (audio.processing) {
audio.cv_from_thread.wait(Lock);
}
}
#endif
// OTRTODO: FIGURE OUT END FRAME POINT
/* if (OTRGlobals::Instance->context->GetWindow()->lastScancode != -1)
@ -1412,7 +1420,7 @@ extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBuff
price = 40;
break;
}
switch (language) {
switch (language) {
case 0: default:
scrubText += 0x12; // add the sound
scrubText += 0x38; // sound id
@ -1467,7 +1475,7 @@ extern "C" int CopyScrubMessage(u16 scrubTextId, char* buffer, const int maxBuff
scrubText += 0xA3; // message id
break;
}
return CopyStringToCharBuffer(scrubText, buffer, maxBufferSize);
}
@ -1488,7 +1496,7 @@ extern "C" int Randomizer_CopyGanonHintText(char* buffer, const int maxBufferSiz
}
extern "C" int Randomizer_CopyHintFromCheck(RandomizerCheck check, char* buffer, const int maxBufferSize) {
// we don't want to make a copy of the std::string returned from GetHintFromCheck
// we don't want to make a copy of the std::string returned from GetHintFromCheck
// so we're just going to let RVO take care of it
const std::string& hintText = OTRGlobals::Instance->gRandomizer->GetHintFromCheck(check);
return CopyStringToCharBuffer(hintText, buffer, maxBufferSize);

View File

@ -49,6 +49,8 @@ SaveManager::SaveManager() {
}
void SaveManager::LoadRandomizerVersion1() {
if(!CVar_GetS32("gRandomizer", 0)) return;
for (int i = 0; i < ARRAY_COUNT(gSaveContext.itemLocations); i++) {
SaveManager::Instance->LoadData("get" + std::to_string(i), gSaveContext.itemLocations[i].get);
SaveManager::Instance->LoadData("check" + std::to_string(i), gSaveContext.itemLocations[i].check);
@ -88,6 +90,9 @@ void SaveManager::LoadRandomizerVersion1() {
}
void SaveManager::SaveRandomizer() {
if(!gSaveContext.n64ddFlag) return;
for (int i = 0; i < ARRAY_COUNT(gSaveContext.itemLocations); i++) {
SaveManager::Instance->SaveData("get" + std::to_string(i), gSaveContext.itemLocations[i].get);
SaveManager::Instance->SaveData("check" + std::to_string(i), gSaveContext.itemLocations[i].check);
@ -170,7 +175,7 @@ void SaveManager::Init() {
} else {
CreateDefaultGlobal();
}
// Load files to initialize metadata
for (int fileNum = 0; fileNum < MaxFiles; fileNum++) {
if (std::filesystem::exists(GetFileName(fileNum))) {
@ -906,7 +911,7 @@ void SaveManager::LoadArray(const std::string& name, const size_t size, LoadArra
}
currentJsonContext = saveJsonContext;
}
void SaveManager::LoadStruct(const std::string& name, LoadStructFunc func) {
// Create an empty struct and set it as the current load context, then call the function that loads the struct.

View File

@ -1,5 +1,6 @@
#include "global.h"
#ifndef __SWITCH__
void __assert(const char* exp, const char* file, s32 line) {
char msg[256];
@ -7,3 +8,4 @@ void __assert(const char* exp, const char* file, s32 line) {
sprintf(msg, "ASSERT: %s:%d(%d)", file, line, osGetThreadId(NULL));
Fault_AddHungupAndCrashImpl(msg, exp);
}
#endif

View File

@ -265,16 +265,14 @@ void* FaultDrawer_FormatStringFunc(void* arg, const char* str, u32 count) {
return arg;
}
void FaultDrawer_VPrintf(const char* str, char* args) { // va_list
void FaultDrawer_VPrintf(const char* str, va_list args) { // va_list
_Printf(FaultDrawer_FormatStringFunc, (char*)&sFaultDrawerStruct, str, args);
}
void FaultDrawer_Printf(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
FaultDrawer_VPrintf(fmt, args);
va_end(args);
}
@ -284,7 +282,6 @@ void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) {
FaultDrawer_SetCursor(x, y);
FaultDrawer_VPrintf(fmt, args);
va_end(args);
}

View File

@ -481,6 +481,22 @@ static void RunFrame()
uint64_t ticksA, ticksB;
ticksA = GetPerfCounter();
#ifdef __SWITCH__
#define SAMPLES_HIGH 752
#define SAMPLES_LOW 720
#define AUDIO_FRAMES_PER_UPDATE (R_UPDATE_RATE > 0 ? R_UPDATE_RATE : 1 )
#define NUM_AUDIO_CHANNELS 2
int samples_left = AudioPlayer_Buffered();
u32 num_audio_samples = samples_left < AudioPlayer_GetDesiredBuffered() ? SAMPLES_HIGH : SAMPLES_LOW;
s16 audio_buffer[SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 3];
for (int i = 0; i < AUDIO_FRAMES_PER_UPDATE; i++) {
AudioMgr_CreateNextAudioBuffer(audio_buffer + i * (num_audio_samples * NUM_AUDIO_CHANNELS), num_audio_samples);
}
AudioPlayer_Play((u8*)audio_buffer, num_audio_samples * (sizeof(int16_t) * NUM_AUDIO_CHANNELS * AUDIO_FRAMES_PER_UPDATE));
#endif
Graph_StartFrame();
// TODO: Workaround for rumble being too long. Implement os thread functions.

View File

@ -41,8 +41,6 @@ void main(int argc, char** argv)
GameConsole_Init();
InitOTR();
BootCommands_Init();
BootCommands_ParseBootArgs(argc - 1, (char**)&argv[1]);
Main(0);
}

View File

@ -111,7 +111,7 @@ void Message_ResetOcarinaNoteState(void) {
sOcarinaNoteCEnvR = 10;
sOcarinaNoteCEnvG = 10;
sOcarinaNoteCEnvB = 10;
if (CVar_GetS32("gHudColors", 1) == 0) {
if (CVar_GetS32("gHudColors", 1) == 0) {
sOcarinaNoteAPrimR = 80;
sOcarinaNoteAPrimG = 150;
sOcarinaNoteAPrimB = 255;
@ -240,8 +240,6 @@ void Message_DrawTextChar(GlobalContext* globalCtx, void* textureImage, Gfx** p)
s16 x = msgCtx->textPosX;
s16 y = msgCtx->textPosY;
gSPInvalidateTexCache(gfx++, textureImage);
gDPPipeSync(gfx++);
sCharTexSize = (R_TEXT_CHAR_SCALE / 100.0f) * 16.0f;
@ -1229,6 +1227,8 @@ void Message_Decode(GlobalContext* globalCtx) {
MessageContext* msgCtx = &globalCtx->msgCtx;
Font* font = &globalCtx->msgCtx.font;
gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, NULL);
globalCtx->msgCtx.textDelayTimer = 0;
globalCtx->msgCtx.textUnskippable = globalCtx->msgCtx.textDelay = globalCtx->msgCtx.textDelayTimer = 0;
sTextFade = false;
@ -1624,6 +1624,7 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) {
}
sMessageHasSetSfx = D_8014B2F4 = sTextboxSkipped = sTextIsCredits = 0;
gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, NULL);
if (textId >= 0x0500 && textId < 0x0600) { // text ids 0500 to 0600 are reserved for credits
sTextIsCredits = true;
@ -1793,7 +1794,7 @@ void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* actor) {
// so we need to switch the order of these lines
if (gSaveContext.n64ddFlag && textId == 0x2053) {
msgCtx->talkActor = actor;
Message_OpenText(globalCtx, textId);
Message_OpenText(globalCtx, textId);
} else {
Message_OpenText(globalCtx, textId);
msgCtx->talkActor = actor;
@ -2114,7 +2115,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) {
if(CBtnB_2 > 255){CBtnB_2=255;};
s16 sOcarinaNoteCPrimColors_CUSTOM[][3] = {
{ CBtnR, CBtnG, CBtnB }, //Unified
{ CBtnR_2, CBtnG_2, CBtnB_2 },
{ CBtnR_2, CBtnG_2, CBtnB_2 },
{ CBtnRL, CBtnGL, CBtnBL }, //Left
{ CBtnRD, CBtnGD, CBtnBD }, //Down
{ CBtnRR, CBtnGR, CBtnBR }, //Right
@ -2704,15 +2705,15 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) {
Message_ContinueTextbox(globalCtx, msgCtx->lastPlayedSong + 0x893); // You played [song name]
Message_Decode(globalCtx);
msgCtx->msgMode = MSGMODE_DISPLAY_SONG_PLAYED_TEXT;
if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME
if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME
|| globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS ||
globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) {
msgCtx->stateTimer = 20;
} else {
msgCtx->stateTimer = 1;
}
Message_DrawText(globalCtx, &gfx);
break;
case MSGMODE_DISPLAY_SONG_PLAYED_TEXT:

5
soh/switch/pathconf.c Normal file
View File

@ -0,0 +1,5 @@
#include <unistd.h>
long pathconf(const char *path, int name) {
return -1;
}