diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fb008f5..73001e48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,7 @@ jobs: pip install Pillow sudo dpkg --add-architecture i386 sudo apt update - sudo apt install -y make gcc-multilib g++-multilib libsdl1.2-dev:i386 libasound2-plugins:i386 libjack-dev:i386 + sudo apt install -y make pkgconf gcc-multilib g++-multilib libsdl1.2-dev:i386 libasound2-plugins:i386 libjack-dev:i386 - name: Build DEB working-directory: projects @@ -106,6 +106,85 @@ jobs: tag_name: ${{ steps.extract_tag.outputs.tag_name }} files: ./projects/*.zip + build-x86: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install required libraries + run: | + python -m pip install --upgrade pip + pip install Pillow + sudo dpkg --add-architecture i386 + sudo apt update + sudo apt install -y make pkgconf gcc-multilib g++-multilib libsdl2-dev:i386 libasound2-plugins:i386 libjack-dev:i386 + + - name: Build X86 + working-directory: projects + run: make PLATFORM=X86 + + - name: Package build + working-directory: projects + run: | + curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/1.0.zip + unzip lgpt-resources.zip + mv lgpt-resources-1.0/*/ ./resources/packaging + rm -rf lgpt-resources* + ./resources/packaging/lgpt_package.sh + + - name: Extract Git tag name + id: extract_tag + run: echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}" + env: + GITHUB_REF: ${{ github.ref }} + + - name: Upload build release + uses: softprops/action-gh-release@v2 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ steps.extract_tag.outputs.tag_name }} + files: ./projects/*.zip + + build-x64: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install required libraries + run: | + python -m pip install --upgrade pip + pip install Pillow + sudo apt update + sudo apt install -y make pkgconf libsdl2-dev libasound2-plugins libjack-dev + + - name: Build X64 + working-directory: projects + run: make PLATFORM=X64 + + - name: Package build + working-directory: projects + run: | + curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/1.0.zip + unzip lgpt-resources.zip + mv lgpt-resources-1.0/*/ ./resources/packaging + rm -rf lgpt-resources* + ./resources/packaging/lgpt_package.sh + + - name: Extract Git tag name + id: extract_tag + run: echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}" + env: + GITHUB_REF: ${{ github.ref }} + + - name: Upload build release + uses: softprops/action-gh-release@v2 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ steps.extract_tag.outputs.tag_name }} + files: ./projects/*.zip + build-psp: runs-on: ubuntu-latest env: @@ -232,7 +311,7 @@ jobs: tag_name: ${{ steps.extract_tag.outputs.tag_name }} files: ./projects/*.zip - build-rg35xx: + build-garlic: runs-on: ubuntu-latest steps: @@ -241,18 +320,18 @@ jobs: - name: Clone and build LGPT run: | + ln -s /home/runner/work/LittleGPTracker/LittleGPTracker workspace docker run -d --name rg35xx-container -v "$(pwd)/workspace:/root/workspace" aveferrum/rg35xx-toolchain sleep infinity docker exec rg35xx-container bash -c " apt update && apt install -y python3 python3-pillow - git clone https://github.com/djdiskmachine/LittleGPTracker.git - cd LittleGPTracker/projects - make PLATFORM=RG35XX + cd projects + make PLATFORM=GARLIC " - sudo chmod -R 777 ./workspace/LittleGPTracker/projects - sudo chown -R root:root ./workspace/LittleGPTracker/projects + sudo chmod -R 777 ./workspace/projects + sudo chown -R root:root ./workspace/projects - name: Package build - working-directory: ./workspace/LittleGPTracker/projects + working-directory: ./workspace/projects run: | curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/1.0.zip unzip lgpt-resources.zip @@ -271,4 +350,86 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} tag_name: ${{ steps.extract_tag.outputs.tag_name }} - files: ./workspace/LittleGPTracker/projects/*.zip + files: ./workspace/projects/*.zip + + build-garlicplus: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Garlic Plus toolchain + run: | + python -m pip install --upgrade pip + pip install Pillow + wget -O /tmp/rg35xxplus-toolchain.tar.xz https://github.com/simotek/union-rg35xxplus-toolchain/releases/download/20240830/rg35xxplus-toolchain.tar.xz + mkdir /opt/rg35xxplus-toolchain + tar -xvf /tmp/rg35xxplus-toolchain.tar.xz -C /opt/rg35xxplus-toolchain --strip-components=1 + + - name: Build Garlic Plus + working-directory: projects + run: make PLATFORM=GARLICPLUS + + - name: Package build + working-directory: projects + run: | + curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/1.0.zip + unzip lgpt-resources.zip + mv lgpt-resources-1.0/*/ ./resources/packaging + rm -rf lgpt-resources* + ./resources/packaging/lgpt_package.sh + + - name: Extract Git tag name + id: extract_tag + run: echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}" + env: + GITHUB_REF: ${{ github.ref }} + + - name: Upload build release + uses: softprops/action-gh-release@v2 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ steps.extract_tag.outputs.tag_name }} + files: ./projects/*.zip + + build-rg35xxplus: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install rg35xx Stock Toolchain + run: | + python -m pip install --upgrade pip + pip install Pillow + wget -O /tmp/rg35xx-plus-aarch64-SDL2-SDK-0.1.0.tar.xz https://github.com/simotek/rg35xx-plus-aarch64-SDL2-SDK/releases/download/0.1.0/rg35xx-plus-aarch64-SDL2-SDK-0.1.0.tar.xz + mkdir /opt/rg35xx-plus-aarch64-SDL2-SDK-0.1.0 + tar -xvf /tmp/rg35xx-plus-aarch64-SDL2-SDK-0.1.0.tar.xz -C /opt/rg35xx-plus-aarch64-SDL2-SDK-0.1.0 --strip-components=1 + + - name: Build rg35xx Stock + working-directory: projects + run: make PLATFORM=RG35XXPLUS + + - name: Package build + working-directory: projects + run: | + curl -L -o lgpt-resources.zip https://github.com/djdiskmachine/lgpt-resources/archive/refs/tags/1.0.zip + unzip lgpt-resources.zip + mv lgpt-resources-1.0/*/ ./resources/packaging + rm -rf lgpt-resources* + ./resources/packaging/lgpt_package.sh + + - name: Extract Git tag name + id: extract_tag + run: echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}" + env: + GITHUB_REF: ${{ github.ref }} + + - name: Upload build release + uses: softprops/action-gh-release@v2 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ steps.extract_tag.outputs.tag_name }} + files: ./projects/*.zip diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 63224ceb..a2ab45b8 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -58,3 +58,22 @@ jobs: working-directory: projects run: | make PLATFORM=MIYOO + + x64: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install required libraries + run: | + python -m pip install --upgrade pip + pip install Pillow + sudo apt update + sudo apt install -y make pkgconf libsdl2-dev libasound2-plugins libjack-dev + + - name: Build X64 + working-directory: projects + run: | + make PLATFORM=X64 diff --git a/projects/Makefile b/projects/Makefile index f7ebfa4c..2cb29bbf 100644 --- a/projects/Makefile +++ b/projects/Makefile @@ -17,181 +17,186 @@ TITLE := lgpt NAME := LittleGPTracker ICON := lgpt_icon.bmp - #--------------------------------------------------------------------------------- # Directory definitions #--------------------------------------------------------------------------------- -NDSDIRS := . \ - ../sources/Adapters/NDS/FileSystem \ - ../sources/Adapters/NDS/System \ - ../sources/Adapters/NDS/Main \ - ../sources/Adapters/Dummy/Midi \ - ../sources/Adapters/NDS/Sound \ - ../sources/Adapters/NDS/UI +COMMONDIRS := \ + ../sources/System/Console \ + ../sources/System/io \ + ../sources/Services/Midi \ + ../sources/Services/Time \ + ../sources/Services/Controllers \ + ../sources/System/FileSystem \ + ../sources/System/Timer \ + ../sources/System/Errors \ + ../sources/UIFramework/Framework \ + ../sources/UIFramework/BasicDatas \ + ../sources/UIFramework/SimpleBaseClasses \ + ../sources/UIFramework/Interfaces \ + ../sources/Application \ + ../sources/Application/Controllers \ + ../sources/Application/Commands \ + ../sources/Application/Audio \ + ../sources/Application/Views \ + ../sources/Application/Views/ModalDialogs \ + ../sources/Application/Views/BaseClasses \ + ../sources/Application/Model \ + ../sources/Application/Utils \ + ../sources/Application/Player \ + ../sources/Application/Mixer \ + ../sources/Application/Instruments \ + ../sources/Application/Persistency \ + ../sources/Foundation \ + ../sources/Services/Audio \ + ../sources/Foundation/Services \ + ../sources/Foundation/Variables \ + ../sources/Externals/Compression \ + ../sources/Externals/Soundfont \ + ../sources/Externals/TinyXML +#--------------------------------------------------------------------------------- +# Linux +#--------------------------------------------------------------------------------- + +LINUXDIRS := \ + ../sources/Adapters/LINUX/Main \ + ../sources/Adapters/LINUX/System \ + ../sources/Adapters/Unix/FileSystem \ + ../sources/Adapters/Unix/Process \ + ../sources/System/Process + +DBDIRS := \ + ../sources/Adapters/DEB/Main \ + ../sources/Adapters/DEB/System \ + ../sources/Adapters/Unix/FileSystem \ + ../sources/Adapters/Unix/Process \ + ../sources/System/Process + +DUMMYMIDIDIRS := \ + ../sources/Adapters/Dummy/Midi + +JACKDIRS := \ + ../sources/Adapters/Jack/Audio\ + ../sources/Adapters/Jack/Midi\ + ../sources/Adapters/Jack/Client + +RTAUDIODIRS := \ + ../sources/Adapters/RTAudio\ + ../sources/Externals/RTAudio + +RTMIDIDIRS := \ + ../sources/Adapters/RTMidi\ + ../sources/Externals/RtMidi + +SDLDIRS := \ + ../sources/Adapters/SDL/Timer\ + ../sources/Adapters/SDL/GUI + +SDL2DIRS := \ + ../sources/Adapters/SDL2/Timer \ + ../sources/Adapters/SDL2/GUI + +SDLAUDIODIRS := \ + ../sources/Adapters/SDL/Audio + +SDL2AUDIODIRS := \ + ../sources/Adapters/SDL2/Audio + +BEAGLEBOARDDIRS := $(LINUXDIRS) $(DUMMYMIDIDIRS) $(RTAUDIODIRS) $(SDLDIRS) +DEBDIRS := $(DBDIRS) $(JACKDIRS) $(RTAUDIODIRS) $(RTMIDIDIRS) $(SDLDIRS) +RASPIDIRS := $(LINUXDIRS) $(JACKDIRS) $(RTAUDIODIRS) $(RTMIDIDIRS) $(SDLDIRS) +RG35XXPLUSDIRS := $(LINUXDIRS) $(DUMMYMIDIDIRS) $(SDL2DIRS) $(SDL2AUDIODIRS) +STEAMDIRS := $(LINUXDIRS) $(JACKDIRS) $(RTAUDIODIRS) $(RTMIDIDIRS) $(SDLDIRS) +#X64DIRS := $(LINUXDIRS) $(RTMIDIDIRS) $(SDL2DIRS) $(SDL2AUDIODIRS) +X64DIRS := $(LINUXDIRS) $(DUMMYMIDIDIRS) $(SDL2DIRS) $(SDL2AUDIODIRS) +X86DIRS := $(LINUXDIRS) $(DUMMYMIDIDIRS) $(SDL2DIRS) $(SDL2AUDIODIRS) +#--------------------------------------------------------------------------------- +# Consoles/Embedded +#--------------------------------------------------------------------------------- -DEBDIRS := ../sources/Adapters/Unix/FileSystem \ - ../sources/Adapters/DEB/Main \ - ../sources/Adapters/Unix/Process \ - ../sources/System/Process \ - ../sources/Externals/RTAudio \ - ../sources/Externals/RtMidi \ - ../sources/Adapters/DEB/System \ - ../sources/Adapters/Jack/Audio\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/Jack/Client\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/RTAudio\ - ../sources/Adapters/RTMidi\ - ../sources/Adapters/SDL/Timer\ - ../sources/Adapters/SDL/GUI - -BEAGLEBOARDDIRS := ../sources/Adapters/Unix/FileSystem \ - ../sources/Adapters/DEB/Main \ - ../sources/Adapters/Unix/Process \ - ../sources/System/Process \ - ../sources/Externals/RTAudio \ - ../sources/Adapters/DEB/System \ - ../sources/Adapters/Dummy/Midi \ - ../sources/Adapters/Jack/Audio\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/Jack/Client\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/RTAudio\ - ../sources/Adapters/SDL/Timer\ - ../sources/Adapters/SDL/GUI - -RASPIDIRS := ../sources/Adapters/Unix/FileSystem \ - ../sources/Adapters/DEB/Main\ - ../sources/Adapters/Unix/Process\ - ../sources/System/Process\ - ../sources/Externals/RTAudio\ - ../sources/Externals/RtMidi\ - ../sources/Adapters/DEB/System\ - ../sources/Adapters/Jack/Audio\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/Jack/Client\ - ../sources/Adapters/RTAudio\ - ../sources/Adapters/RTMidi\ - ../sources/Adapters/SDL/Timer\ - ../sources/Adapters/SDL/GUI - -STEAMDIRS := ../sources/Adapters/Unix/FileSystem \ - ../sources/Adapters/DEB/Main\ - ../sources/Adapters/Unix/Process\ - ../sources/System/Process\ - ../sources/Externals/RTAudio\ - ../sources/Externals/RtMidi\ - ../sources/Adapters/DEB/System\ - ../sources/Adapters/Jack/Audio\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/Jack/Client\ - ../sources/Adapters/Jack/Midi\ - ../sources/Adapters/RTAudio\ - ../sources/Adapters/RTMidi\ - ../sources/Adapters/SDL/Timer\ - ../sources/Adapters/SDL/GUI - -GP2XDIRS := . \ - ../sources/Adapters/GP2X/Main \ - ../sources/Adapters/GP2X/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/GP2X/System \ - ../sources/Adapters/GP2X/Midi \ - ../sources/Adapters/GP2X/Audio \ - ../sources/Adapters/SDL/GUI\ - ../sources/Adapters/SDL/Timer - -CAANOODIRS := . \ - ../sources/Adapters/CAANOO/Main \ - ../sources/Adapters/Unix/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/CAANOO/System \ - ../sources/Adapters/CAANOO/Midi \ - ../sources/Adapters/CAANOO/Audio \ - ../sources/Adapters/SDL/GUI\ - ../sources/Adapters/SDL/Timer - -DINGOODIRS := . \ - ../sources/Adapters/DINGOO/Main \ - ../sources/Adapters/Unix/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/DINGOO/System \ - ../sources/Adapters/DINGOO/Midi \ - ../sources/Adapters/Dummy/Midi \ - ../sources/Adapters/DINGOO/Audio \ - ../sources/Adapters/SDL/Audio \ - ../sources/Adapters/SDL/Process \ - ../sources/Adapters/SDL/GUI \ - ../sources/Adapters/SDL/Timer - -RS97DIRS := . \ - ../sources/Adapters/DINGOO/Main \ - ../sources/Adapters/Unix/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/DINGOO/System \ - ../sources/Adapters/DINGOO/Midi \ - ../sources/Adapters/DINGOO/Audio \ - ../sources/Adapters/SDL/Audio \ - ../sources/Adapters/SDL/Process \ - ../sources/Adapters/SDL/GUI \ - ../sources/Adapters/SDL/Timer +CAANOODIRS := \ + . \ + ../sources/Adapters/CAANOO/Main \ + ../sources/Adapters/Unix/FileSystem \ + ../sources/System/Process \ + ../sources/Adapters/Unix/Process \ + ../sources/Adapters/CAANOO/System \ + ../sources/Adapters/CAANOO/Midi \ + ../sources/Adapters/CAANOO/Audio \ + ../sources/Adapters/SDL/GUI\ + ../sources/Adapters/SDL/Timer + +DINGUXDIRS := \ + . \ + ../sources/Adapters/DINGOO/Main \ + ../sources/Adapters/Unix/FileSystem \ + ../sources/System/Process \ + ../sources/Adapters/Unix/Process \ + ../sources/Adapters/DINGOO/System \ + ../sources/Adapters/DINGOO/Midi \ + ../sources/Adapters/DINGOO/Audio \ + ../sources/Adapters/SDL/Audio \ + ../sources/Adapters/SDL/Process \ + ../sources/Adapters/SDL/GUI \ + ../sources/Adapters/SDL/Timer + +DINGUXAUDIODIRS := \ + ../sources/Adapters/DINGOO/Midi \ + ../sources/Adapters/DINGOO/Audio -BITTBOYDIRS := . \ - ../sources/Adapters/DINGOO/Main \ - ../sources/Adapters/Unix/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/DINGOO/System \ - ../sources/Adapters/DINGOO/Midi \ - ../sources/Adapters/DINGOO/Audio \ - ../sources/Adapters/SDL/Audio \ - ../sources/Adapters/SDL/Process \ - ../sources/Adapters/SDL/GUI \ - ../sources/Adapters/SDL/Timer - -MIYOODIRS := . \ - ../sources/Adapters/DINGOO/Main \ - ../sources/Adapters/Unix/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/DINGOO/System \ - ../sources/Adapters/Dummy/Midi \ - ../sources/Adapters/SDL/Audio \ - ../sources/Adapters/SDL/Process \ - ../sources/Adapters/SDL/GUI \ - ../sources/Adapters/SDL/Timer - -RG35XXDIRS := . \ - ../sources/Adapters/DINGOO/Main \ - ../sources/Adapters/Unix/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/Unix/Process \ - ../sources/Adapters/DINGOO/System \ - ../sources/Adapters/SDL/Audio \ - ../sources/Adapters/SDL/Process \ - ../sources/Adapters/SDL/GUI \ - ../sources/Adapters/SDL/Timer\ - ../sources/Adapters/Dummy/Midi -# ../sources/Adapters/RTMidi \ # Disabled for now -# ../sources/Externals/RtMidi - -PSPDIRS := . \ - ../sources/Adapters/PSP/Main \ - ../sources/Adapters/PSP/FileSystem \ - ../sources/System/Process \ - ../sources/Adapters/PSP/System \ - ../sources/Adapters/Dummy/Midi \ - ../sources/Adapters/SDL/Process \ - ../sources/Adapters/SDL/Audio\ - ../sources/Adapters/SDL/GUI\ - ../sources/Adapters/SDL/Timer +DUMMYMIDIDIRS := \ + ../sources/Adapters/Dummy/Midi + +BITTBOYDIRS := $(DINGUXDIRS) $(DINGUXAUDIODIRS) +DINGOODIRS := $(DINGUXDIRS) $(DINGUXAUDIODIRS) $(DUMMYMIDIDIRS) +MIYOODIRS := $(DINGUXDIRS) $(DUMMYMIDIDIRS) +GARLICDIRS := $(MIYOODIRS) +GARLICPLUSDIRS := $(GARLICDIRS) +RS97DIRS := $(DINGUXDIRS) $(DINGUXAUDIODIRS) + +GP2XDIRS := \ + . \ + ../sources/Adapters/GP2X/Main \ + ../sources/Adapters/GP2X/FileSystem \ + ../sources/System/Process \ + ../sources/Adapters/Unix/Process \ + ../sources/Adapters/GP2X/System \ + ../sources/Adapters/GP2X/Midi \ + ../sources/Adapters/GP2X/Audio \ + ../sources/Adapters/SDL/GUI \ + ../sources/Adapters/SDL/Timer + +GP32DIRS := \ + .\ + ../sources/Adapters/GP32FileSystem \ + ../sources/Adapters/GP32Midi \ + ../sources/Adapters/GP32/Main \ + ../sources/Adapters/GP32System \ + ../sources/Adapters/GP32Timer \ + ../sources/Adapters/GP32UI + +NDSDIRS := \ + . \ + ../sources/Adapters/NDS/FileSystem \ + ../sources/Adapters/NDS/System \ + ../sources/Adapters/NDS/Main \ + ../sources/Adapters/Dummy/Midi \ + ../sources/Adapters/NDS/Sound \ + ../sources/Adapters/NDS/UI + +PSPDIRS := \ + . \ + ../sources/Adapters/PSP/Main \ + ../sources/Adapters/PSP/FileSystem \ + ../sources/System/Process \ + ../sources/Adapters/PSP/System \ + ../sources/Adapters/Dummy/Midi \ + ../sources/Adapters/SDL/Process \ + ../sources/Adapters/SDL/Audio \ + ../sources/Adapters/SDL/GUI \ + ../sources/Adapters/SDL/Timer GP32DIRS := .\ ../sources/Adapters/GP32FileSystem \ @@ -202,323 +207,255 @@ GP32DIRS := .\ ../sources/Adapters/GP32UI W32DIRS := .\ - ../sources/Adapters/W32FileSystem \ - ../sources/Adapters/W32Midi \ - ../sources/Adapters/W32Sound \ - ../sources/Adapters/WSDLSystem \ - ../sources/Adapters/WSDLUI \ - ../sources/Adapters/SDL/Input \ - ../sources/Adapters/W32/Main \ - ../sources/Adapters/W32/Process \ - ../sources/Adapters/W32/Audio \ - ../sources/System/Process - -COMMONDIRS := ../sources/System/Console \ - ../sources/System/io \ - ../sources/Services/Midi \ - ../sources/Services/Time \ - ../sources/Services/Controllers \ - ../sources/System/FileSystem \ - ../sources/System/Timer \ - ../sources/System/Errors \ - ../sources/UIFramework/Framework \ - ../sources/UIFramework/BasicDatas \ - ../sources/UIFramework/SimpleBaseClasses \ - ../sources/UIFramework/Interfaces \ - ../sources/Application \ - ../sources/Application/Controllers \ - ../sources/Application/Commands \ - ../sources/Application/Audio \ - ../sources/Application/Views \ - ../sources/Application/Views/ModalDialogs \ - ../sources/Application/Views/BaseClasses \ - ../sources/Application/Model \ - ../sources/Application/Utils \ - ../sources/Application/Player \ - ../sources/Application/Mixer \ - ../sources/Application/Instruments \ - ../sources/Application/Persistency \ - ../sources/Foundation \ - ../sources/Services/Audio \ - ../sources/Foundation/Services \ - ../sources/Foundation/Variables \ - ../sources/Externals/Compression \ - ../sources/Externals/Soundfont \ - ../sources/Externals/TinyXML + ../sources/Adapters/W32FileSystem \ + ../sources/Adapters/W32Midi \ + ../sources/Adapters/W32Sound \ + ../sources/Adapters/WSDLSystem \ + ../sources/Adapters/WSDLUI \ + ../sources/Adapters/SDL/Input \ + ../sources/Adapters/W32/Main \ + ../sources/Adapters/W32/Process \ + ../sources/Adapters/W32/Audio \ + ../sources/System/Process #--------------------------------------------------------------------------------- # files definition #--------------------------------------------------------------------------------- -DINGOOFILES := GPSDLMain.o \ - UnixFileSystem.o \ - DummyMidi.o \ - DINGOOAudio.o \ - Process.o \ - UnixProcess.o \ - SDLAudioDriver.o \ - DINGOOAudioDriver.o \ - DINGOOSystem.o \ - DINGOOEventQueue.o \ - SDLProcess.o \ - SDLTimer.o \ - GUIFactory.o \ - SDLEventManager.o \ - SDLGUIWindowImp.o - -RS97FILES := GPSDLMain.o \ - UnixFileSystem.o \ - DINGOOAudio.o \ - Process.o \ - UnixProcess.o \ +COMMONFILES := \ + Logger.o Trace.o Result.o Status.o Config.o \ + Timer.o FileSystem.o \ + SysMutex.o TimeService.o \ + MidiOutDevice.o MidiInDevice.o MidiService.o Groove.o \ + MidiChannel.o MidiInMerger.o \ + GUIEvent.o GUIRect.o \ + EventManager.o GUIWindow.o \ + Channel.o Mixer.o \ + ControlRoom.o \ + MultiChannelAdapter.o \ + CommandDispatcher.o \ + ApplicationCommandDispatcher.o \ + EventDispatcher.o \ + ControllerService.o \ + ButtonControllerSource.o \ + KeyboardControllerSource.o \ + JoystickControllerSource.o \ + HatControllerSource.o \ + ControllerSource.o \ + ControlNode.o \ + I_GUIWindowImp.o \ + Application.o AppWindow.o SelectProjectDialog.o \ + NewProjectDialog.o \ + ImportSampleDialog.o \ + MixerView.o NullView.o \ + SongView.o ChainView.o PhraseView.o ViewData.o ConsoleView.o ProjectView.o InstrumentView.o UIController.o \ + View.o ModalView.o FieldView.o UIField.o UIIntField.o \ + UIIntVarOffField.o UIIntVarField.o ViewEvent.o I_Action.o\ + UITempoField.o UIActionField.o \ + MessageBox.o \ + GrooveView.o UINoteVarField.o UIBigHexVarField.o \ + SRPUpdaters.o UIStaticField.o \ + Song.o Chain.o Phrase.o Project.o \ + char.o n_assert.o fixed.o wildcard.o \ + SyncMaster.o TablePlayback.o Player.o \ + Table.o TableView.o\ + InstrumentBank.o WavFileWriter.o WavFile.o MidiInstrument.o Filters.o SampleVariable.o SampleInstrument.o SamplePool.o CommandList.o \ + PersistencyService.o Persistent.o \ + Observable.o SingletonRegistry.o \ + Audio.o AudioMixer.o AudioOutDriver.o AudioDriver.o \ + AudioOut.o \ + DummyAudioOut.o PlayerChannel.o AudioFileStreamer.o \ + MixBus.o \ + MixerService.o PlayerMixer.o \ + Service.o ServiceRegistry.o SubService.o \ + Variable.o VariableContainer.o WatchedVariable.o \ + SoundFontPreset.o SoundFontManager.o SoundFontSample.o \ + ENAB.o HYDRA.o OMEGA.o RIFF.o SFDETECT.o SFLOOKUP.o SFNAV.o SFREADER.o WIN_MEM.o \ + HexBuffers.o lz.o \ + tinyxmlparser.o tinyxml.o tinyxmlerror.o tinystr.o Tiny2NosStub.o + +#--------------------------------------------------------------------------------- +# Linux +#--------------------------------------------------------------------------------- + +LINUXFILES := \ + UnixFileSystem.o \ + LINUXMain.o \ + LINUXSystem.o \ + GUIFactory.o \ + SDLGUIWindowImp.o \ + SDLEventManager.o \ + Process.o \ + UnixProcess.o \ + SDLTimer.o + +DBFILES := \ + UnixFileSystem.o \ + DEBmain.o \ + DEBSystem.o \ + GUIFactory.o \ + SDLGUIWindowImp.o \ + SDLEventManager.o \ + Process.o \ + UnixProcess.o \ + SDLTimer.o + +DUMMYMIDIFILES := \ + DummyMidi.o + +RTAUDIOFILES := \ + RTAudioDriver.o \ + RTAudioStub.o \ + RtAudio.o + +RTMIDIFILES := \ + RtMidi.o \ + RTMidiService.o \ + RTMidiOutDevice.o \ + RTMidiInDevice.o + +JACKFILES := \ + JackAudioDriver.o \ + JackClient.o \ + JackAudio.o + +SDLAUDIOFILES := \ SDLAudioDriver.o \ - DINGOOAudioDriver.o \ - BITTBOYSystem.o \ - DINGOOEventQueue.o \ - SDLProcess.o \ - SDLTimer.o \ - GUIFactory.o \ - SDLEventManager.o \ - BITTBOYSerialMidiDevice.o \ - BITTBOYMidiService.o \ - SDLGUIWindowImp.o + SDLAudio.o -BITTBOYFILES := GPSDLMain.o \ - UnixFileSystem.o \ - DINGOOAudio.o \ - Process.o \ - UnixProcess.o \ - SDLAudioDriver.o \ - DINGOOAudioDriver.o \ - BITTBOYSystem.o \ - DINGOOEventQueue.o \ - SDLProcess.o \ - SDLTimer.o \ - GUIFactory.o \ - SDLEventManager.o \ - BITTBOYSerialMidiDevice.o \ - BITTBOYMidiService.o \ - SDLGUIWindowImp.o - -MIYOOFILES := GPSDLMain.o \ - UnixFileSystem.o \ - SDLAudio.o \ - Process.o \ - UnixProcess.o \ - SDLAudioDriver.o \ - MIYOOSystem.o \ - DINGOOEventQueue.o \ - SDLProcess.o \ - SDLTimer.o \ - GUIFactory.o \ - SDLEventManager.o \ - DummyMidi.o \ - SDLGUIWindowImp.o - -RG35XXFILES := GPSDLMain.o \ - UnixFileSystem.o \ - SDLAudio.o \ - Process.o \ - UnixProcess.o \ - SDLAudioDriver.o \ - MIYOOSystem.o \ - DINGOOEventQueue.o \ - SDLProcess.o \ - SDLTimer.o \ - GUIFactory.o \ - SDLEventManager.o \ - DummyMidi.o \ - SDLGUIWindowImp.o -# RtMidi.o \ #Disabled for now -# RTMidiService.o \ -# RTMidiOutDevice.o \ -# RTMidiInDevice.o \ - -PSPFILES := PSPmain.o \ - PSPFileSystem.o \ - Process.o \ - DummyMidi.o \ - GUIFactory.o \ - SDLGUIWindowImp.o \ - SDLEventManager.o \ - SDLAudioDriver.o \ - SDLAudio.o \ - SDLProcess.o \ - SDLTimer.o \ - PSPSystem.o +DEBFILES := $(DBFILES) $(RTAUDIOFILES) $(RTMIDIFILES) $(JACKFILES) +BEAGLEBOARDFILES := $(LINUXFILES) $(DUMMYMIDIFILES) +RASPIFILES := $(LINUXFILES) $(RTAUDIOFILES) $(RTMIDIFILES) $(JACKFILES) +RG35XXPLUSFILES := $(LINUXFILES) $(SDLAUDIOFILES) $(DUMMYMIDIFILES) +STEAMFILES := $(LINUXFILES) $(RTAUDIOFILES) $(RTMIDIFILES) $(JACKFILES) +#X64FILES := $(LINUXFILES) $(RTMIDIFILES) $(SDLAUDIOFILES) +X64FILES := $(LINUXFILES) $(SDLAUDIOFILES) $(DUMMYMIDIFILES) +X86FILES := $(LINUXFILES) $(SDLAUDIOFILES) $(DUMMYMIDIFILES) + +#--------------------------------------------------------------------------------- +# Consoles/Embedded +#--------------------------------------------------------------------------------- + +CAANOOFILES := \ + CAANOOSDLMain.o \ + UnixFileSystem.o \ + CAANOOMidiService.o \ + CAANOOSerialMidiDevice.o \ + CAANOOAudio.o \ + Process.o \ + UnixProcess.o \ + CAANOOAudioDriver.o \ + CAANOOSystem.o \ + CAANOOEventQueue.o \ + gpmemcpy.o \ + gpmemset.o \ + SDLTimer.o \ + GUIFactory.o \ + SDLEventManager.o \ + SDLGUIWindowImp.o + +GP2XFILES := \ + GPSDLMain.o \ + GP2XFileSystem.o \ + GP2XMidiService.o \ + GP2XSerialMidiDevice.o \ + GP2XAudio.o \ + Process.o \ + UnixProcess.o \ + GP2XAudioDriver.o \ + GP2XSystem.o \ + GP2XEventQueue.o \ + gpmemcpy.o \ + gpmemset.o \ + SDLTimer.o \ + GUIFactory.o \ + SDLEventManager.o \ + SDLGUIWindowImp.o + +DINGUXFILES := \ + DINGOOEventQueue.o \ + GPSDLMain.o \ + GUIFactory.o \ + Process.o \ + SDLAudioDriver.o \ + SDLEventManager.o \ + SDLGUIWindowImp.o \ + SDLProcess.o \ + SDLTimer.o \ + UnixFileSystem.o \ + UnixProcess.o + +DINGOOFILES := \ + $(DINGUXFILES) \ + DummyMidi.o \ + DINGOOAudio.o \ + DINGOOAudioDriver.o \ + DINGOOSystem.o + +RS97FILES := \ + $(DINGUXFILES) \ + DINGOOAudio.o \ + DINGOOAudioDriver.o \ + BITTBOYSystem.o \ + BITTBOYSerialMidiDevice.o \ + BITTBOYMidiService.o + +BITTBOYFILES := \ + $(DINGUXFILES) \ + DINGOOAudio.o \ + DINGOOAudioDriver.o \ + BITTBOYSystem.o \ + BITTBOYSerialMidiDevice.o \ + BITTBOYMidiService.o + +MIYOOFILES := \ + $(DINGUXFILES) \ + DummyMidi.o \ + MIYOOSystem.o \ + SDLAudio.o + +GARLICFILES = $(MIYOOFILES) +GARLICPLUSFILES = $(GARLICFILES) + +NDSFILES := \ + NDSmain.o \ + NDSFileSystem.o \ + DummyMidi.o \ + NDSSound.o \ + NDSSystem.o \ + GUIFactory.o \ + NDSGUIWindowImp.o + +PSPFILES := \ + PSPmain.o \ + PSPFileSystem.o \ + Process.o \ + DummyMidi.o \ + GUIFactory.o \ + SDLGUIWindowImp.o \ + SDLEventManager.o \ + SDLAudioDriver.o \ + SDLAudio.o \ + SDLProcess.o \ + SDLTimer.o \ + PSPSystem.o -DEBFILES := UnixFileSystem.o \ - DEBmain.o \ - DEBSystem.o \ - GUIFactory.o \ - SDLGUIWindowImp.o \ - SDLEventManager.o \ - Process.o \ - UnixProcess.o \ - RTAudioDriver.o \ - RTAudioStub.o \ - RtAudio.o\ - RtMidi.o\ - RTMidiService.o\ - RTMidiOutDevice.o\ - RTMidiInDevice.o\ - SDLTimer.o \ - JackAudioDriver.o \ - JackClient.o \ - JackAudio.o - -BEAGLEBOARDFILES := UnixFileSystem.o \ - DEBmain.o \ - DEBSystem.o \ - GUIFactory.o \ - SDLGUIWindowImp.o \ - SDLEventManager.o \ - Process.o \ - UnixProcess.o \ - DummyMidi.o \ - RTAudioDriver.o \ - RTAudioStub.o \ - RtAudio.o\ - SDLTimer.o - -RASPIFILES := UnixFileSystem.o \ - DEBmain.o \ - DEBSystem.o \ - GUIFactory.o \ - SDLGUIWindowImp.o \ - SDLEventManager.o \ - Process.o \ - UnixProcess.o \ - RTAudioDriver.o \ - RTAudioStub.o \ - RtAudio.o\ - RtMidi.o\ - RTMidiService.o\ - RTMidiOutDevice.o\ - RTMidiInDevice.o\ - SDLTimer.o \ - JackAudioDriver.o \ - JackClient.o \ - JackAudio.o - -STEAMFILES := UnixFileSystem.o \ - DEBmain.o \ - DEBSystem.o \ - GUIFactory.o \ - SDLGUIWindowImp.o \ - SDLEventManager.o \ - Process.o \ - UnixProcess.o \ - RTAudioDriver.o \ - RTAudioStub.o \ - RtAudio.o\ - RtMidi.o\ - RTMidiService.o\ - RTMidiOutDevice.o\ - RTMidiInDevice.o\ - SDLTimer.o \ - JackAudioDriver.o \ - JackClient.o \ - JackAudio.o - -NDSFILES := NDSmain.o \ - NDSFileSystem.o \ - DummyMidi.o \ - NDSSound.o \ - NDSSystem.o \ - GUIFactory.o NDSGUIWindowImp.o - -W32FILES := WSDLmain.o \ - W32FileSystem.o \ - W32Midi.o \ - W32AudioDriver.o \ - WSDLSystem.o \ - SDLInput.o \ - Process.o \ - W32Process.o \ - W32Audio.o \ - GUIFactory.o WSDLGUIWindowImp.o - -GP2XFILES := GPSDLMain.o \ - GP2XFileSystem.o \ - GP2XMidiService.o \ - GP2XSerialMidiDevice.o \ - GP2XAudio.o \ - Process.o \ - UnixProcess.o \ - GP2XAudioDriver.o \ - GP2XSystem.o \ - GP2XEventQueue.o \ - gpmemcpy.o \ - gpmemset.o \ - SDLTimer.o \ - GUIFactory.o SDLEventManager.o SDLGUIWindowImp.o - -CAANOOFILES := CAANOOSDLMain.o \ - UnixFileSystem.o \ - CAANOOMidiService.o \ - CAANOOSerialMidiDevice.o \ - CAANOOAudio.o \ - Process.o \ - UnixProcess.o \ - CAANOOAudioDriver.o \ - CAANOOSystem.o \ - CAANOOEventQueue.o \ - gpmemcpy.o \ - gpmemset.o \ - SDLTimer.o \ - GUIFactory.o SDLEventManager.o SDLGUIWindowImp.o - -COMMONFILES := Logger.o Trace.o Result.o Status.o Config.o \ - Timer.o FileSystem.o \ - SysMutex.o TimeService.o \ - MidiOutDevice.o MidiInDevice.o MidiService.o Groove.o \ - MidiChannel.o MidiInMerger.o \ - GUIEvent.o GUIRect.o \ - EventManager.o GUIWindow.o \ - Channel.o Mixer.o \ - ControlRoom.o \ - MultiChannelAdapter.o \ - CommandDispatcher.o \ - ApplicationCommandDispatcher.o \ - EventDispatcher.o \ - ControllerService.o \ - ButtonControllerSource.o \ - KeyboardControllerSource.o \ - JoystickControllerSource.o \ - HatControllerSource.o \ - ControllerSource.o \ - ControlNode.o \ - I_GUIWindowImp.o \ - Application.o AppWindow.o SelectProjectDialog.o \ - NewProjectDialog.o \ - ImportSampleDialog.o \ - MixerView.o NullView.o \ - SongView.o ChainView.o PhraseView.o ViewData.o ConsoleView.o ProjectView.o InstrumentView.o UIController.o \ - View.o ModalView.o FieldView.o UIField.o UIIntField.o \ - UIIntVarOffField.o UIIntVarField.o ViewEvent.o I_Action.o\ - UITempoField.o UIActionField.o \ - MessageBox.o \ - GrooveView.o UINoteVarField.o UIBigHexVarField.o \ - SRPUpdaters.o UIStaticField.o \ - Song.o Chain.o Phrase.o Project.o \ - char.o n_assert.o fixed.o wildcard.o \ - SyncMaster.o TablePlayback.o Player.o \ - Table.o TableView.o\ - InstrumentBank.o WavFileWriter.o WavFile.o MidiInstrument.o Filters.o SampleVariable.o SampleInstrument.o SamplePool.o CommandList.o \ - PersistencyService.o Persistent.o \ - Observable.o SingletonRegistry.o \ - Audio.o AudioMixer.o AudioOutDriver.o AudioDriver.o \ - AudioOut.o \ - DummyAudioOut.o PlayerChannel.o AudioFileStreamer.o \ - MixBus.o \ - MixerService.o PlayerMixer.o \ - Service.o ServiceRegistry.o SubService.o \ - Variable.o VariableContainer.o WatchedVariable.o \ - SoundFontPreset.o SoundFontManager.o SoundFontSample.o \ - ENAB.o HYDRA.o OMEGA.o RIFF.o SFDETECT.o SFLOOKUP.o SFNAV.o SFREADER.o WIN_MEM.o \ - HexBuffers.o lz.o \ - tinyxmlparser.o tinyxml.o tinyxmlerror.o tinystr.o Tiny2NosStub.o \ +#--------------------------------------------------------------------------------- +# Windows +#--------------------------------------------------------------------------------- + +W32FILES := \ + WSDLmain.o \ + W32FileSystem.o \ + W32Midi.o \ + W32AudioDriver.o \ + WSDLSystem.o \ + SDLInput.o \ + Process.o \ + W32Process.o \ + W32Audio.o \ + GUIFactory.o \ + WSDLGUIWindowImp.o #--------------------------------------------------------------------------------- # TARGET is the name of the output @@ -530,14 +467,14 @@ COMMONFILES := Logger.o Trace.o Result.o Status.o Config.o \ TARGET := $(TITLE) BUILD := build$(PLATFORM) SOURCES := $($(PLATFORM)DIRS) $(COMMONDIRS) - INCLUDES := - #--------------------------------------------------------------------------------- # path to tools - this can be deleted if you set the path in windows #--------------------------------------------------------------------------------- + export PATH := $(DEVKITARM)/bin:$(PATH) + #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- @@ -547,8 +484,6 @@ export PATH := $(DEVKITARM)/bin:$(PATH) # include and lib #--------------------------------------------------------------------------------- - - #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional # rules for different file extensions @@ -557,38 +492,39 @@ ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- export OUTPUT := $(CURDIR)/$(TARGET) - export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C #--------------------------------------------------------------------------------- -export LD := $(CXX) +export LD := $(CXX) export OFILES := $(COMMONFILES) $($(PLATFORM)FILES) export OBJS := $(OFILES) -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ +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 #--------------------------------------------------------------------------------- + $(BUILD): python3 ../sources/Resources/mkfont.py ../sources/Resources/$(FONT) ../sources/Resources/font.h @[ -d $@ ] || mkdir -p $@ @make --no-print-directory -C $(BUILD) -f $(PWD)/Makefile #--------------------------------------------------------------------------------- + clean: @echo clean ... @rm -fr $(OUTPUT).$(EXTENSION) $(BUILD) *.elf *.gxb *.fxe *.gdb - #--------------------------------------------------------------------------------- + else DEPENDS := $(OFILES:.o=.d) @@ -619,10 +555,8 @@ $(OUTPUT).deb-exe : $(OFILES) $(OUTPUT).beagle-exe : $(OFILES) $(LD) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) - -include $(DEPENDS) - #--------------------------------------------------------------------------------------- endif #--------------------------------------------------------------------------------------- diff --git a/projects/Makefile.DEB b/projects/Makefile.DEB index 246f44f9..66cda35c 100644 --- a/projects/Makefile.DEB +++ b/projects/Makefile.DEB @@ -1,15 +1,30 @@ -include $(PWD)/rules_base -LDFLAGS := -m32 -%.deb-exe: $(OFILES) - $(CXX) $(LDFLAGS) $@ $(OFILES) $(LIBS) +# config +DEFINES := \ + -DCPP_MEMORY \ + -D_DEBUG \ + -D__LINUX_ALSA__ \ + -D__LINUX_ALSASEQ__ -CFLAGS := -m32 -O3 -DCPP_MEMORY -Wall -I/usr/local/include -I$(PWD)/../sources -D__LINUX_ALSA__ -D__LINUX_ALSASEQ__ -D_DEBUG -LIBS := -O3 -L/local/lib -Wl,-rpath,/usr/local/lib -lasound -lSDL -ljack -lpthread +ALSA_CFLAGS := $(shell i686-linux-gnu-pkg-config alsa --cflags) +ALSA_LIBS := $(shell i686-linux-gnu-pkg-config alsa --libs) +JACK_CFLAGS := $(shell i686-linux-gnu-pkg-config jack --cflags) +JACK_LIBS := $(shell i686-linux-gnu-pkg-config jack --libs) +SDL_CFLAGS := $(shell i686-linux-gnu-pkg-config sdl --cflags) +SDL_LIBS := $(shell i686-linux-gnu-pkg-config sdl --libs) +# optimization +OPT_FLAGS := -O3 -m32 #For debugging -#LIBS := -g -L/local/lib -Wl,-rpath,/usr/local/lib -lasound -lSDL -ljack -lpthread -#CFLAGS := -g -m32 -DCPP_MEMORY -Wall -I/usr/local/include -I$(PWD)/../sources -D__LINUX_ALSA__ -D__LINUX_ALSASEQ__ - +# OPT_FLAGS := -g -m32 +INCLUDES := -I/usr/local/include $(ALSA_CFLAGS) $(JACK_CFLAGS) $(SDL_CFLAGS) -I$(PWD)/../sources +CFLAGS := $(OPT_FLAGS) $(DEFINES) $(INCLUDES) -Wall CXXFLAGS:= $(CFLAGS) +LIBS := -O3 -L/local/lib -Wl,-rpath,/usr/local/lib $(ALSA_LIBS) $(JACK_LIBS) $(SDL_LIBS) +LDFLAGS := -m32 + EXTENSION:= deb-exe + +%.deb-exe: $(OFILES) + $(CXX) $(LDFLAGS) $@ $(OFILES) $(LIBS) diff --git a/projects/Makefile.RG35XX b/projects/Makefile.GARLIC similarity index 74% rename from projects/Makefile.RG35XX rename to projects/Makefile.GARLIC index 9a3ca9a2..cc658479 100644 --- a/projects/Makefile.RG35XX +++ b/projects/Makefile.GARLIC @@ -1,34 +1,35 @@ -include $(PWD)/rules_base STRIP = $(CROSS_COMPILE)strip -%.elf: $(OFILES) - $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) - @$(STRIP) $@ +DEFINES := \ + -DBUFFERED \ + -DCPP_MEMORY \ + -D_NDEBUG \ + -DHAVE_STDINT_H \ + -D_NO_JACK_ DEVKIT = /opt/miyoo/ CROSS_COMPILE=$(DEVKIT)bin/arm-miyoo-linux-uclibcgnueabi- -PLATFORM := RG35XX - CC = $(CROSS_COMPILE)gcc CXX = $(CROSS_COMPILE)g++ +TOOLPATH=$(DEVKIT)/usr/bin SYSROOT := $(shell $(CROSS_COMPILE)gcc --print-sysroot) + SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags) SDL_LIBS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs) -DEFINES = -DHAVE_STDINT_H -D_NDEBUG -D_NO_JACK_ -I$(PWD)/../sources -DCPP_MEMORY $(SDL_CFLAGS) $(SDL_LIBS) -DBUFFERED -INCLUDES = -Iinclude $(SDL_CFLAGS) +# optimization OPT_FLAGS = -O3 -Ofast -fdata-sections -fdata-sections -fno-common -fno-PIC -flto -marm -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard - -OUTPUT = ../lgpt-rg35xx - -TOOLPATH=$(DEVKIT)/usr/bin -PREFIX := arm-linux-gnueabihf- - +PREFIX := arm-linux-gnueabihf- +INCLUDES:= -Iinclude $(SDL_CFLAGS) -I$(PWD)/../sources CFLAGS := $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -Wall CXXFLAGS:= $(CFLAGS) -std=gnu++03 - -EXTENSION:= elf - -LIBS := -lSDL -lSDL_mixer -lpthread +LIBS := $(SDL_LIBS) -lpthread LIBDIRS := $(DEKVIT)/usr/lib LIBDIRS += $(DEKVIT)/usr/include +OUTPUT := ../lgpt-garlic +EXTENSION:= elf + +%.elf: $(OFILES) + $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) + @$(STRIP) $@ diff --git a/projects/Makefile.GARLICPLUS b/projects/Makefile.GARLICPLUS new file mode 100644 index 00000000..f6f68156 --- /dev/null +++ b/projects/Makefile.GARLICPLUS @@ -0,0 +1,39 @@ +-include $(PWD)/rules_base +STRIP = $(CROSS_COMPILE)strip + +export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/opt/rg35xxplus-toolchain/usr/lib + +DEFINES := \ + -DBUFFERED \ + -DCPP_MEMORY \ + -D_NDEBUG \ + -DHAVE_STDINT_H \ + -D_NO_JACK_ + +# compiled using the https://github.com/shauninman/union-rg35xxplus-toolchain + +DEVKIT = /opt/rg35xxplus-toolchain/ +CROSS_COMPILE=$(DEVKIT)/usr/bin/arm-buildroot-linux-gnueabihf- +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +TOOLPATH=$(DEVKIT)/usr/bin +SYSROOT := $(shell $(CROSS_COMPILE)gcc --print-sysroot) + +SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags) +SDL_LIBS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs) + +# optimization +OPT_FLAGS = -O3 -Ofast -fdata-sections -fdata-sections -fno-common -fno-PIC -flto -marm -mtune=cortex-a53 -mfpu=neon-vfpv4 -mfloat-abi=hard +PREFIX := arm-linux-gnueabihf- +INCLUDES = -Iinclude $(SDL_CFLAGS) -I$(PWD)/../sources +CFLAGS := $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -Wall +CXXFLAGS:= $(CFLAGS) -std=gnu++03 +LIBS := -lSDL -lpthread +LIBDIRS := $(DEKVIT)/usr/lib +LIBDIRS += $(DEKVIT)/usr/include +OUTPUT = ../lgpt-garlicplus +EXTENSION:= elf + +%.elf: $(OFILES) + $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) + @$(STRIP) $@ diff --git a/projects/Makefile.RG35XXPLUS b/projects/Makefile.RG35XXPLUS new file mode 100644 index 00000000..97d10508 --- /dev/null +++ b/projects/Makefile.RG35XXPLUS @@ -0,0 +1,34 @@ +-include $(PWD)/rules_base + +# config +DEFINES := \ + -D_64BIT \ + -DBUFFERED \ + -DCPP_MEMORY \ + -DHAVE_STDINT_H \ + -D_NDEBUG \ + -D_NO_JACK_ \ + -DSDL2 \ + -DSDLAUDIO \ + -DDUMMYMIDI + +DEVKIT := /opt/rg35xx-plus-aarch64-SDL2-SDK-0.1.0/ +CROSS_COMPILE:=$(DEVKIT)bin/aarch64-none-linux-gnu- +TRIPLET:=aarch64-linux-gnu +CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ +TOOLPATH=$(DEVKIT)/usr/bin + +SDL_CFLAGS := -I/$(SYSROOT)/include -D_REENTRANT +SDL_LIBS := -lSDL2 + +OPT_FLAGS = -O3 -mlittle-endian -mabi=lp64 -march=armv8-a+crypto+crc -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -fstack-clash-protection -dumpbase +INCLUDES = -Iinclude $(SDL_CFLAGS) -I$(DEVKIT)/$(TRIPLET)/include -I$(DEVKIT)/$(TRIPLET)/include/c++/11/ -I$(PWD)/../sources +CFLAGS := $(DEFINES) $(INCLUDES) $(OPT_FLAGS) -Wall +CXXFLAGS:= $(CFLAGS) -std=gnu++03 +LIBS := -Wl,-rpath-link,$(DEVKIT)/$(TRIPLET)/lib -Wl,-rpath-link,$(DEVKIT)/$(TRIPLET)/lib/pulseaudio $(SDL_LIBS) -lpthread +OUTPUT = ../lgpt-rg35xxplus +EXTENSION:= elf + +%.elf: $(OFILES) + $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) diff --git a/projects/Makefile.X64 b/projects/Makefile.X64 new file mode 100644 index 00000000..7fadf8c5 --- /dev/null +++ b/projects/Makefile.X64 @@ -0,0 +1,33 @@ +-include $(PWD)/rules_base + +# config +DEFINES := \ + -D_64BIT \ + -DCPP_MEMORY \ + -D__LINUX_ALSA__ \ + -D__LINUX_ALSASEQ__ \ + -DSDL2 \ + -DSDLAUDIO \ + -DDUMMYMIDI + +ALSA_CFLAGS := $(shell pkg-config alsa --cflags) +ALSA_LIBS := $(shell pkg-config alsa --libs) +JACK_CFLAGS := $(shell pkg-config jack --cflags) +JACK_LIBS := $(shell pkg-config jack --libs) +SDL_CFLAGS := $(shell pkg-config sdl2 --cflags) +SDL_LIBS := $(shell pkg-config sdl2 --libs) + +# optimization +OPT_FLAGS := -O3 +#For debugging +OPT_FLAGS := -g +INCLUDES := $(ALSA_CFLAGS) $(JACK_CFLAGS) $(SDL_CFLAGS) -I$(PWD)/../sources +CFLAGS := $(OPT_FLAGS) $(DEFINES) $(INCLUDES) -Wall +CXXFLAGS := $(CFLAGS) -std=gnu++03 +LIBS := $(ALSA_LIBS) $(JACK_LIBS) $(SDL_LIBS) +OUTPUT := ../lgpt +EXTENSION := x64 + +# build rule +%.x64: $(OFILES) + $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) diff --git a/projects/Makefile.X86 b/projects/Makefile.X86 new file mode 100644 index 00000000..669d616b --- /dev/null +++ b/projects/Makefile.X86 @@ -0,0 +1,33 @@ +-include $(PWD)/rules_base + +# config +DEFINES := \ + -DCPP_MEMORY \ + -D__LINUX_ALSA__ \ + -D__LINUX_ALSASEQ__ \ + -DSDL2 \ + -DSDLAUDIO \ + -DDUMMYMIDI + +ALSA_CFLAGS := $(shell i686-linux-gnu-pkg-config alsa --cflags) +ALSA_LIBS := $(shell i686-linux-gnu-pkg-config alsa --libs) +JACK_CFLAGS := $(shell i686-linux-gnu-pkg-config jack --cflags) +JACK_LIBS := $(shell i686-linux-gnu-pkg-config jack --libs) +SDL_CFLAGS := $(shell i686-linux-gnu-pkg-config sdl2 --cflags) +SDL_LIBS := $(shell i686-linux-gnu-pkg-config sdl2 --libs) + +# optimization +OPT_FLAGS := -O3 -m32 +#For debugging +#OPT_FLAGS := -g -m32 +INCLUDES := $(ALSA_CFLAGS) $(JACK_CFLAGS) $(SDL_CFLAGS) -I$(PWD)/../sources +CFLAGS := $(OPT_FLAGS) $(DEFINES) $(INCLUDES) -Wall +CXXFLAGS := $(CFLAGS) +LIBS := $(ALSA_LIBS) $(JACK_LIBS) $(SDL_LIBS) +LDFLAGS := -m32 +OUTPUT = ../lgpt +EXTENSION := x86 + +# build rule +%.x86: $(OFILES) + $(CXX) $(LDFLAGS) -o $@ $(OFILES) $(LIBS) diff --git a/projects/README.md b/projects/README.md index fc97122e..955f7e65 100644 --- a/projects/README.md +++ b/projects/README.md @@ -12,7 +12,7 @@ using nano ~/.bashrc, add export PSPDEV=~/pspdev export PATH=$PATH:$PSPDEV/bin - at the end, then + at the end, then source ~/.bashrc Build with: make PLATFORM=PSP @@ -27,6 +27,22 @@ Build with: make PLATFORM=DEB + +##### X64: Compile under Linux + Required libs: + sudo apt install -y git make libsdl2 libasound2-plugins libjack-dev python3 python3-pillow + + Build with: + make PLATFORM=X64 + +##### X86: Compile under Linux + This builds a 32bit version of the X64 SDL2 port + Required libs: + sudo dpkg --add-architecture i386 && sudo apt update + sudo apt install -y git make gcc-multilib g++-multilib libsdl2-dev:i386 libasound2-plugins:i386 libjack-dev:i386 python3 python3-pillow + + Build with: + make PLATFORM=X86 ##### RASPI: Compile under Linux Required libs: @@ -61,12 +77,33 @@ Build with: make PLATFORM=RS97 -##### RG35XX: Compile in edemirkans toolchain docker +##### GARLIC: Compile in edemirkans toolchain docker + For older Anbernic RG35XX Devices running GarlicOS clone: https://github.com/edemirkan/rg35xx-toolchain enter docker: make shell Build with: apt install -y python3 python3-pillow - make PLATFORM=RG35XX + make PLATFORM=GARLIC +##### GARLICPLUS: Compile in shauninman toolchain docker + For newer Anbernic RG35XX Platform devices (SP, Plus, H, 2024) + running either Garlic or muOS + clone: + https://github.com/shauninman/union-rg35xxplus-toolchain + enter docker: + make shell + Build with: + make PLATFORM=GARLICPLUS + +##### RG35XXPLUS: Compile with simotek toolchain + For newer Anbernic RG35XX Platform devices (SP, Plus, H, 2024) + running the latest 64bit stock or stock modified firmware. + download: + https://github.com/simotek/rg35xx-plus-aarch64-SDL2-SDK/releases/download/0.1.0/rg35xx-plus-aarch64-SDL2-SDK-0.1.0.tar.xz + extract: + cd /opt + tar -xf rg35xx-plus-aarch64-SDL2-SDK-0.1.0.tar.xz + Build with: + make PLATFORM=RG35XXPLUS diff --git a/projects/resources/RG35XX/INSTALL_HOW_TO.txt b/projects/resources/GARLIC/INSTALL_HOW_TO.txt similarity index 100% rename from projects/resources/RG35XX/INSTALL_HOW_TO.txt rename to projects/resources/GARLIC/INSTALL_HOW_TO.txt diff --git a/projects/resources/RG35XX/LittleGPTracker.png b/projects/resources/GARLIC/LittleGPTracker.png similarity index 100% rename from projects/resources/RG35XX/LittleGPTracker.png rename to projects/resources/GARLIC/LittleGPTracker.png diff --git a/projects/resources/RG35XX/LittleGPTracker.sh b/projects/resources/GARLIC/LittleGPTracker.sh similarity index 100% rename from projects/resources/RG35XX/LittleGPTracker.sh rename to projects/resources/GARLIC/LittleGPTracker.sh diff --git a/projects/resources/RG35XX/config.xml b/projects/resources/GARLIC/config.xml similarity index 100% rename from projects/resources/RG35XX/config.xml rename to projects/resources/GARLIC/config.xml diff --git a/projects/resources/RG35XX/j2k.so b/projects/resources/GARLIC/j2k.so similarity index 100% rename from projects/resources/RG35XX/j2k.so rename to projects/resources/GARLIC/j2k.so diff --git a/projects/resources/GARLICPLUS/README.md b/projects/resources/GARLICPLUS/README.md new file mode 100644 index 00000000..60ca4047 --- /dev/null +++ b/projects/resources/GARLICPLUS/README.md @@ -0,0 +1,22 @@ +# Garlic OS + +## Installation + +1. Copy lgpt-rg35xxplus.elf, config.xml, samplelib, lgpt_BETA to /SdCard/Roms/APPS/lgpt/ +2. Copy LittleGPTracker.png to /SdCard/Roms/Imgs/ +3. Copy garlicos/LittleGPTracker.sh to /SdCard/Roms/ + +## Usage + +Open "Consoles -> Apps -> LittleGPTracker". + +# muOS + +## Installation + +1. Copy lgpt-rg35xxplus.elf, config.xml, samplelib, lgpt_BETA to /mnt/mmc/MUOS/application/.lgpt/ +3. Copy muos/LittleGPTracker.sh to /mnt/mmc/MUOS/application/ + +## Usage + +Open "Applications -> LittleGPTracker". diff --git a/projects/resources/GARLICPLUS/config.json b/projects/resources/GARLICPLUS/config.json new file mode 100644 index 00000000..b0a167b6 --- /dev/null +++ b/projects/resources/GARLICPLUS/config.json @@ -0,0 +1,6 @@ +{ + "label": "LittleGPTracker", + "icon": "lgpt.png", + "launch": "launch.sh", + "description": "16bit sample-based tracker" +} diff --git a/projects/resources/GARLICPLUS/config.xml b/projects/resources/GARLICPLUS/config.xml new file mode 100644 index 00000000..21d43983 --- /dev/null +++ b/projects/resources/GARLICPLUS/config.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/projects/resources/GARLICPLUS/garlicos/LittleGPTracker.sh b/projects/resources/GARLICPLUS/garlicos/LittleGPTracker.sh new file mode 100755 index 00000000..f82c0450 --- /dev/null +++ b/projects/resources/GARLICPLUS/garlicos/LittleGPTracker.sh @@ -0,0 +1,6 @@ +#!/bin/sh +progdir=$(dirname "$0")/lgpt +cd $progdir +HOME=$progdir +LD_LIBRARY_PATH=$PROGDIR:$LD_LIBRARY_PATH ./lgpt-rg35xxplus.elf > ./lgpt.log +sync diff --git a/projects/resources/GARLICPLUS/lgpt.png b/projects/resources/GARLICPLUS/lgpt.png new file mode 100644 index 00000000..3ee4d69a Binary files /dev/null and b/projects/resources/GARLICPLUS/lgpt.png differ diff --git a/projects/resources/GARLICPLUS/mapping.xml b/projects/resources/GARLICPLUS/mapping.xml new file mode 100644 index 00000000..d1dea475 --- /dev/null +++ b/projects/resources/GARLICPLUS/mapping.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/projects/resources/GARLICPLUS/muos/LittleGPTracker.sh b/projects/resources/GARLICPLUS/muos/LittleGPTracker.sh new file mode 100644 index 00000000..85588804 --- /dev/null +++ b/projects/resources/GARLICPLUS/muos/LittleGPTracker.sh @@ -0,0 +1,15 @@ +#!/bin/sh +echo app >/tmp/act_go + +. /opt/muos/script/var/device/storage.sh + +export LD_LIBRARY_PATH=/usr/lib32 + +PROGDIR="$DC_STO_ROM_MOUNT/MUOS/application/.lgpt" +cd $PROGDIR +HOME=$PROGDIR + +echo "lgpt" >/tmp/fg_proc + +LD_LIBRARY_PATH=$PROGDIR:$LD_LIBRARY_PATH ./lgpt-rg35xxplus.elf &> lgpt.log +sync diff --git a/projects/resources/RG35XXPLUS/INSTALL_HOW_TO.txt b/projects/resources/RG35XXPLUS/INSTALL_HOW_TO.txt new file mode 100644 index 00000000..9f40be6b --- /dev/null +++ b/projects/resources/RG35XXPLUS/INSTALL_HOW_TO.txt @@ -0,0 +1,13 @@ +Installation: +1. Ensure you have the latest rg35xx Stock firmware from below or the latest "Stock Modified firmware", this build requires the 64bit OS + * https://win.anbernic.com/download/318.html (RG35XXPLUS-EN-240712 or later) +2. Copy the following files, note `/mnt/mmc/Roms/` is the path when the SD-Card is mounted in the device. When viewing from your computer it will just be a partition with a `Roms` Directory + a. lgpt-rg35xxplus.elf, config.xml, samplelib, mapping.xml to `/mnt/mmc/Roms/APPS/lgpt/` + b. Copy LittleGPTracker.png to /mnt/mmc/Roms/APPS/lgpt/Imgs/ + c. Copy LittleGPTracker.sh to /mnt/mmc/Roms/APPS/lgpt/ + + +Usage: +on the "Stock OS" open "App Center -> APPS -> LittleGPTracker". + + diff --git a/projects/resources/RG35XXPLUS/LittleGPTracker.png b/projects/resources/RG35XXPLUS/LittleGPTracker.png new file mode 100644 index 00000000..3ee4d69a Binary files /dev/null and b/projects/resources/RG35XXPLUS/LittleGPTracker.png differ diff --git a/projects/resources/RG35XXPLUS/LittleGPTracker.sh b/projects/resources/RG35XXPLUS/LittleGPTracker.sh new file mode 100644 index 00000000..c064d0e5 --- /dev/null +++ b/projects/resources/RG35XXPLUS/LittleGPTracker.sh @@ -0,0 +1,6 @@ +#!/bin/sh +progdir=$(dirname "$0")/lgpt +cd $progdir +HOME=$progdir +./lgpt-rg35xxplus.elf &> log.txt +sync diff --git a/projects/resources/RG35XXPLUS/config.xml b/projects/resources/RG35XXPLUS/config.xml new file mode 100644 index 00000000..cea9fe0a --- /dev/null +++ b/projects/resources/RG35XXPLUS/config.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/resources/RG35XXPLUS/mapping.xml b/projects/resources/RG35XXPLUS/mapping.xml new file mode 100644 index 00000000..bb6436b3 --- /dev/null +++ b/projects/resources/RG35XXPLUS/mapping.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/projects/resources/X64/config.xml b/projects/resources/X64/config.xml new file mode 100644 index 00000000..f47f24e5 --- /dev/null +++ b/projects/resources/X64/config.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + diff --git a/projects/resources/X64/mapping.xml b/projects/resources/X64/mapping.xml new file mode 100644 index 00000000..ab5d37e3 --- /dev/null +++ b/projects/resources/X64/mapping.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/resources/X86/config.xml b/projects/resources/X86/config.xml new file mode 100644 index 00000000..f47f24e5 --- /dev/null +++ b/projects/resources/X86/config.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + diff --git a/projects/resources/X86/mapping.xml b/projects/resources/X86/mapping.xml new file mode 100644 index 00000000..ab5d37e3 --- /dev/null +++ b/projects/resources/X86/mapping.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/resources/packaging/lgpt_package.sh b/projects/resources/packaging/lgpt_package.sh index 45cd390f..801a0ed2 100755 --- a/projects/resources/packaging/lgpt_package.sh +++ b/projects/resources/packaging/lgpt_package.sh @@ -16,7 +16,7 @@ collect_resources() { #1PLATFORM #2lgpt.*-exe echo "-=-=Packaging $PACKAGE=-=-" CONTENTS="./resources/$1/*" CONTENTS+=" $(find -iname $2)" - if [ "$1" == "PSP" ] || [ "$1" == "RG35XX" ]; then # All files go in the root folder + if [ "$1" == "PSP" ] || [ "$1" == "GARLIC" ] || [ "$1" == "RG35XXPLUS" ]; then # All files go in the root folder zip -9 $PACKAGE -j $CONTENTS else # all the others go in the bin mkdir bin ; cp $CONTENTS bin @@ -33,11 +33,15 @@ collect_resources() { #1PLATFORM #2lgpt.*-exe collect_resources PSP EBOOT.PBP collect_resources DEB lgpt.deb-exe +collect_resources X64 lgpt.x64 +collect_resources X86 lgpt.x86 collect_resources MIYOO lgpt-miyoo.elf collect_resources W32 lgpt-W32.exe collect_resources RASPI lgpt.rpi-exe collect_resources CHIP lgpt.chip-exe collect_resources BITTBOY lgpt-bittboy.elf -collect_resources RG35XX lgpt-rg35xx.elf +collect_resources GARLIC lgpt-garlic.elf +collect_resources GARLICPLUS lgpt-garlicplus.elf +collect_resources RG35XXPLUS lgpt-rg35xxplus.elf # collect_resources RS97 lgpt.dge -# collect_resources STEAM lgpt.steam-exe \ No newline at end of file +# collect_resources STEAM lgpt.steam-exe diff --git a/sources/Adapters/CAANOO/System/CAANOOSystem.cpp b/sources/Adapters/CAANOO/System/CAANOOSystem.cpp index 05866b21..e6bdc2e9 100644 --- a/sources/Adapters/CAANOO/System/CAANOOSystem.cpp +++ b/sources/Adapters/CAANOO/System/CAANOOSystem.cpp @@ -103,7 +103,9 @@ void GPSDLSystem::Boot(int argc,char **argv) { return; } +#ifndef SDL2 SDL_EnableUNICODE(1); +#endif atexit(SDL_Quit); diff --git a/sources/Adapters/DINGOO/System/BITTBOYSystem.cpp b/sources/Adapters/DINGOO/System/BITTBOYSystem.cpp index b17a3c7f..d29ba099 100644 --- a/sources/Adapters/DINGOO/System/BITTBOYSystem.cpp +++ b/sources/Adapters/DINGOO/System/BITTBOYSystem.cpp @@ -89,7 +89,9 @@ void GPSDLSystem::Boot(int argc,char **argv) { return; } - SDL_EnableUNICODE(1); +#ifndef SDL2 + SDL_EnableUNICODE(1); +#endif atexit(SDL_Quit); diff --git a/sources/Adapters/DINGOO/System/DINGOOSystem.cpp b/sources/Adapters/DINGOO/System/DINGOOSystem.cpp index 30a7fbf5..45b83dca 100644 --- a/sources/Adapters/DINGOO/System/DINGOOSystem.cpp +++ b/sources/Adapters/DINGOO/System/DINGOOSystem.cpp @@ -86,7 +86,9 @@ void GPSDLSystem::Boot(int argc,char **argv) { return; } - SDL_EnableUNICODE(1); +#ifndef SDL2 + SDL_EnableUNICODE(1); +#endif atexit(SDL_Quit); diff --git a/sources/Adapters/DINGOO/System/MIYOOSystem.cpp b/sources/Adapters/DINGOO/System/MIYOOSystem.cpp index ca0a24b1..b786e426 100644 --- a/sources/Adapters/DINGOO/System/MIYOOSystem.cpp +++ b/sources/Adapters/DINGOO/System/MIYOOSystem.cpp @@ -79,7 +79,9 @@ void GPSDLSystem::Boot(int argc,char **argv) { if (SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) < 0) { return; } +#ifndef SDL2 SDL_EnableUNICODE(1); +#endif atexit(SDL_Quit); eventManager_ = I_GUIWindowFactory::GetInstance() -> GetEventManager(); diff --git a/sources/Adapters/LINUX/Main/LINUXMain.cpp b/sources/Adapters/LINUX/Main/LINUXMain.cpp new file mode 100644 index 00000000..2891417a --- /dev/null +++ b/sources/Adapters/LINUX/Main/LINUXMain.cpp @@ -0,0 +1,20 @@ +#include +#include "Adapters/LINUX/System/LINUXSystem.h" +#include "Adapters/SDL2/GUI/SDLGUIWindowImp.h" +#include "Application/Application.h" +/* + * generic entrypoint for linux based targets + */ +int main(int argc,char *argv[]) { + LINUXSystem::Boot(argc,argv); + + SDLCreateWindowParams params; + params.title="littlegptracker"; + params.cacheFonts_=true; + + Application::GetInstance()->Init(params); + + return LINUXSystem::MainLoop(); +} + +void _assert() {}; diff --git a/sources/Adapters/LINUX/System/LINUXSystem.cpp b/sources/Adapters/LINUX/System/LINUXSystem.cpp new file mode 100644 index 00000000..39031ff1 --- /dev/null +++ b/sources/Adapters/LINUX/System/LINUXSystem.cpp @@ -0,0 +1,231 @@ +#include "LINUXSystem.h" +#include +#include +#include +#include +#include "Adapters/SDL2/GUI/GUIFactory.h" +#include "Adapters/SDL2/GUI/SDLEventManager.h" +#include "Adapters/SDL2/GUI/SDLGUIWindowImp.h" +#include "Adapters/SDL2/Timer/SDLTimer.h" +#include "Adapters/Unix/FileSystem/UnixFileSystem.h" +#include "Adapters/Unix/Process/UnixProcess.h" +#include "Application/Controllers/ControlRoom.h" +#include "Application/Commands/NodeList.h" +#include "Application/Model/Config.h" +#include "System/Console/Logger.h" + +#ifdef DUMMYMIDI +#include "Adapters/Dummy/Midi/DummyMidi.h" +#endif + +#ifdef JACKAUDIO +#include "Adapters/Jack/Audio/JackAudio.h" +#include "Adapters/Jack/Client/JackClient.h" +#endif + +#ifdef JACKMIDI +#include "Adapters/Jack/Midi/JackMidiService.h" +#endif + +#ifdef RTAUDIO +#include "Adapters/RTAudio/RTAudioStub.h" +#endif + +#ifdef RTMIDI +#include "Adapters/RTMidi/RTMidiService.h" +#endif + +#ifdef SDLAUDIO +#include "Adapters/SDL2/Audio/SDLAudio.h" +#endif + +EventManager *LINUXSystem::eventManager_ = NULL; +static int secbase = 0; + +/* + * starts the main loop + */ +int LINUXSystem::MainLoop() { + eventManager_->InstallMappings(); + return eventManager_->MainLoop() ; +}; + +/* + * initializes the application + */ +void LINUXSystem::Boot(int argc,char **argv) { + + SDL_setenv((char *)"SDL_VIDEO_X11_WMCLASS",(char *)"LittleGPTracker",1) ; + + // Install System + System::Install(new LINUXSystem()); + + // Install FileSystem + FileSystem::Install(new UnixFileSystem()); + + // Install aliases + char buff[1024]; + ssize_t len = ::readlink("/proc/self/exe",buff,sizeof(buff)-1); + if (len != -1) + { + buff[len] = 0; + } + else + { + strcpy(buff,"."); + } + Path::SetAlias("bin",dirname(buff)) ; + Path::SetAlias("root",".") ; + + // always use stdout, user can capture in launch script + Trace::GetInstance()->SetLogger(*(new StdOutLogger())); + + // Process arguments + Config::GetInstance()->ProcessArguments(argc,argv) ; + + // Install GUI Factory + I_GUIWindowFactory::Install(new GUIFactory()) ; + + // Install Timers + TimerService::GetInstance()->Install(new SDLTimerService()) ; + +#ifdef JACKAUDIO + Trace::Log("System","Installing JACK audio") ; + Audio::Install(new JackAudio(AudioSettings hints)); +#endif + +#ifdef RTAUDIO + Trace::Log("System","Installing RT audio") ; + AudioSettings hints ; + hints.bufferSize_= 256 ; + hints.preBufferCount_=2 ; + Audio::Install(new RTAudioStub(hints)) ; +#endif + +#ifdef SDLAUDIO + Trace::Log("System","Installing SDL audio") ; + AudioSettings hint; + hint.bufferSize_ = 1024; + hint.preBufferCount_ = 8; + Audio::Install(new SDLAudio(hint)); +#endif + +#ifdef DUMMYMIDI + Trace::Log("System","Installing DUMMY MIDI") ; + MidiService::Install(new DummyMidi()); +#endif + +#ifdef JACKMIDI + Trace::Log("System","Installing JACK MIDI") ; + MidiService::Install(new JackMidiService()) ; +#endif + +#ifdef RTMIDI + Trace::Log("System","Installing RT MIDI") ; + MidiService::Install(new RTMidiService()) ; +#endif + + // Install Threads + SysProcessFactory::Install(new UnixProcessFactory()); + + if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) < 0 ) { + return; + } + SDL_ShowCursor(SDL_DISABLE); + + atexit(SDL_Quit); + + eventManager_ = I_GUIWindowFactory::GetInstance()->GetEventManager(); + eventManager_ -> Init(); +}; + +void LINUXSystem::Shutdown() {}; + +/* + * get current time for status display + */ +unsigned long LINUXSystem::GetClock() { + struct timeval tp; + + gettimeofday(&tp, NULL); + if (!secbase) { + secbase = tp.tv_sec; + return long(tp.tv_usec/1000.0); + } + return long((tp.tv_sec - secbase)*1000 + tp.tv_usec/1000.0); +} + +/* + * wraps sleep, guess we never sleep! + */ +void LINUXSystem::Sleep(int millisec) { + //if (millisec>0) + //::Sleep(millisec) ; +} + +/* + * wraps malloc + */ +void *LINUXSystem::Malloc(unsigned size) { + void *ptr=malloc(size) ; + //Trace::Debug("alloc:%x (%d)",ptr,size) ; + return ptr ; +} + +/* + * wraps free + */ +void LINUXSystem::Free(void *ptr) { + free(ptr); +} + +/* + * wraps memset + */ +void LINUXSystem::Memset(void *addr,char val,int size) { +#ifdef _64BIT + unsigned int ad = (intptr_t)addr; +#else + unsigned int ad=(unsigned int)addr; +#endif + if (((ad&0x3)==0)&&((size&0x3)==0)) { // Are we 4-byte aligned ? + unsigned int intVal=0; + for (int i=0;i<4;i++) { + intVal=(intVal<<8)+val; + } + unsigned int *dst=(unsigned int *)addr; + size_t intSize=size>>2 ; + + for (unsigned int i=0;iPostQuitMessage() ; +}; + +/* + * get memory usage, guess it's infinite + */ +unsigned int LINUXSystem::GetMemoryUsage() { return 0; }; diff --git a/sources/Adapters/LINUX/System/LINUXSystem.h b/sources/Adapters/LINUX/System/LINUXSystem.h new file mode 100644 index 00000000..42f86834 --- /dev/null +++ b/sources/Adapters/LINUX/System/LINUXSystem.h @@ -0,0 +1,36 @@ +#ifndef _LINUX_SYSTEM_H_ +#define _LINUX_SYSTEM_H_ + +#include +#include "System/System/System.h" +#include "UIFramework/SimpleBaseClasses/EventManager.h" + +class LINUXSystem: public System { +public: + static void Boot(int argc,char **argv); + static void Shutdown(); + static int MainLoop(); + +public: // System implementation + virtual unsigned long GetClock(); + virtual void Sleep(int millisec); + virtual void *Malloc(unsigned size); + virtual void Free(void *); + virtual void Memset(void *addr,char val,int size); + virtual void *Memcpy(void *s1, const void *s2, int n); + virtual void AddUserLog(const char *); + virtual int GetBatteryLevel() { return -1 ; }; + virtual void PostQuitMessage(); + virtual unsigned int GetMemoryUsage(); + +protected: // Additional + static unsigned short getButtonMask(SDL_Event&); + static void readConfig(); + static void checkKey(int ,const char *,const char *[]); +private: + static int keyRepeat_; + static int keyDelay_; + static bool finished_; + static EventManager *eventManager_; +}; +#endif diff --git a/sources/Adapters/PSP/System/PSPSystem.cpp b/sources/Adapters/PSP/System/PSPSystem.cpp index 0d5c3327..2f6c9124 100644 --- a/sources/Adapters/PSP/System/PSPSystem.cpp +++ b/sources/Adapters/PSP/System/PSPSystem.cpp @@ -74,8 +74,10 @@ void PSPSystem::Boot(int argc,char **argv) { if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_TIMER) < 0 ) { return; } - SDL_EnableUNICODE(1); - SDL_ShowCursor(SDL_DISABLE); +#ifndef SDL2 + SDL_EnableUNICODE(1); +#endif + SDL_ShowCursor(SDL_DISABLE); atexit(SDL_Quit); diff --git a/sources/Adapters/RTAudio/RTAudioDriver.cpp b/sources/Adapters/RTAudio/RTAudioDriver.cpp index b82e0f76..92789f9e 100644 --- a/sources/Adapters/RTAudio/RTAudioDriver.cpp +++ b/sources/Adapters/RTAudio/RTAudioDriver.cpp @@ -104,7 +104,11 @@ bool RTAudioDriver::InitDriver() { // Allocates a rotating sound buffer unalignedMain_=(char *)SYS_MALLOC(fragSize_+SOUND_BUFFER_MAX) ; // Make sure the buffer is aligned +#ifdef _64BIT + mainBuffer_ = (char *)unalignedMain_; +#else mainBuffer_=(char *)((((int)unalignedMain_)+1)&(0xFFFFFFFC)) ; +#endif // Create mini blank buffer in case of underruns diff --git a/sources/Adapters/RTMidi/RTMidiOutDevice.cpp b/sources/Adapters/RTMidi/RTMidiOutDevice.cpp index 75ca2af6..328b27ab 100644 --- a/sources/Adapters/RTMidi/RTMidiOutDevice.cpp +++ b/sources/Adapters/RTMidi/RTMidiOutDevice.cpp @@ -6,8 +6,8 @@ RTMidiOutDevice::RTMidiOutDevice(RtMidiOut &out,int index,const char *name): MidiOutDevice(name), rtMidiOut_(out), - running_(false), - index_(index) + index_(index), + running_(false) { } ; diff --git a/sources/Adapters/RTMidi/RTMidiService.cpp b/sources/Adapters/RTMidi/RTMidiService.cpp index 63782fac..722ee591 100644 --- a/sources/Adapters/RTMidi/RTMidiService.cpp +++ b/sources/Adapters/RTMidi/RTMidiService.cpp @@ -1,4 +1,3 @@ - #include "RTMidiService.h" #include "RTMidiOutDevice.h" #include "RTMidiInDevice.h" @@ -8,15 +7,14 @@ //static void CALLBACK MidiFlushProc(UINT uiID, UINT uiMsg, DWORD // dwUser, DWORD dw1, DWORD dw2) { // -// W32MidiService *msvc=(W32MidiService *)dwUser ; -// msvc->Flush() ; -//} ; - +// W32MidiService *msvc=(W32MidiService *)dwUser; +// msvc->Flush(); +//}; RTMidiService::RTMidiService() { - const char *delay=Config::GetInstance()->GetValue("MIDIDELAY") ; + const char *delay = Config::GetInstance()->GetValue("MIDIDELAY"); if (delay) { - midiDelay_=atoi(delay) ; + midiDelay_=atoi(delay); } else { midiDelay_=0; } @@ -24,66 +22,54 @@ RTMidiService::RTMidiService() { // RtMidiIn constructor try { rtMidiIn_ = new RtMidiIn(); - } - catch ( RtError &error ) { - Trace::Error("Couldn't get RtMidiIn object") ; - rtMidiIn_=0 ; - Trace::Error(error.getMessageString()); + } catch ( RtError &error ) { + Trace::Log("RtMidiService", "Couldn't get RtMidiIn object"); + rtMidiIn_=0; + Trace::Log("RtMidiService", error.getMessageString()); } // RtMidiOut constructor try { rtMidiOut_ = new RtMidiOut(); + } catch ( RtError &error ) { + Trace::Log("RtMidiService", "Couldn't get RtMidiOut object"); + rtMidiOut_=0; + Trace::Log("RtMidiService", error.getMessageString()); } - catch ( RtError &error ) { - Trace::Error("Couldn't get RtMidiOut object") ; - rtMidiOut_=0 ; - Trace::Error(error.getMessageString()); - } - -} ; +}; RTMidiService::~RTMidiService() { -} ; - -void RTMidiService::buildDriverList() {// Here we just loop over existing Midi out and create a midi device for each of them. - - // Let's enumerate midi ins - - - // Check inputs. +}; +/* + * here we just loop over existing midi out and create a midi device for each of them + */ +void RTMidiService::buildDriverList() { + // check inputs unsigned int nPorts = (rtMidiIn_)?rtMidiIn_->getPortCount():0; - Trace::Log("MIDI","%d input port(s)",nPorts) ; - - for (uint i=0; igetPortName(i); - RTMidiInDevice *in=new RTMidiInDevice(i,portName.c_str()) ; - Trace::Log("MIDI"," %s",portName.c_str()) ; - inList_.Insert(in) ; + RTMidiInDevice *in = new RTMidiInDevice(i, portName.c_str()); + Trace::Log("RTMidiService", " %s", portName.c_str()); + inList_.Insert(in); } catch (RtError &error) { - Trace::Error(error.getMessageString()); + Trace::Log("RTMidiService", error.getMessageString()); } } - // Now check outputs. - + // check outputs nPorts = (rtMidiOut_)?rtMidiOut_->getPortCount():0; - Trace::Log("MIDI","%d output port(s)",nPorts) ; - for (uint i=0; igetPortName(i); - RTMidiOutDevice *out=new RTMidiOutDevice(*rtMidiOut_,i,portName.c_str()) ; - Trace::Log("MIDI"," %s",portName.c_str()) ; - Insert(out) ; - } - catch (RtError &error) - { - Trace::Error(error.getMessageString()); + RTMidiOutDevice *out = new RTMidiOutDevice(*rtMidiOut_,i,portName.c_str()); + Trace::Log("RTMidiService", " %s", portName.c_str()); + Insert(out); + } catch (RtError &error) { + Trace::Log("RTMidiService", error.getMessageString()); } } } - diff --git a/sources/Adapters/SDL/Audio/SDLAudioDriver.cpp b/sources/Adapters/SDL/Audio/SDLAudioDriver.cpp index e0aae34a..1fb2cbc3 100644 --- a/sources/Adapters/SDL/Audio/SDLAudioDriver.cpp +++ b/sources/Adapters/SDL/Audio/SDLAudioDriver.cpp @@ -77,7 +77,11 @@ bool SDLAudioDriver::InitDriver() { // Allocates a rotating sound buffer unalignedMain_=(char *)SYS_MALLOC(fragSize_+SOUND_BUFFER_MAX) ; // Make sure the buffer is aligned +#ifdef _64BIT + mainBuffer_=(char *)unalignedMain_; +#else mainBuffer_=(char *)((((int)unalignedMain_)+1)&(0xFFFFFFFC)) ; +#endif Trace::Log("AUDIO","%s successfully opened with %d samples",bufferName,fragSize_/4 ) ; @@ -115,6 +119,7 @@ bool SDLAudioDriver::StartDriver() { for (int i=0;iAdvancePlayQueue(); } if (settings_.preBufferCount_==0) { thread_->Notify() ; @@ -160,6 +165,7 @@ void SDLAudioDriver::OnChunkDone(Uint8 *stream,int len) { memcpy(mainBuffer_+bufferSize_-bufferPos_, pool_[poolPlayPosition_].buffer_,pool_[poolPlayPosition_].size_); + MidiService::GetInstance()->Flush() ; // Adapt buffer variables bufferSize_=bufferSize_-bufferPos_+pool_[poolPlayPosition_].size_ ; diff --git a/sources/Adapters/SDL2/Audio/SDLAudio.cpp b/sources/Adapters/SDL2/Audio/SDLAudio.cpp new file mode 100644 index 00000000..79d92088 --- /dev/null +++ b/sources/Adapters/SDL2/Audio/SDLAudio.cpp @@ -0,0 +1,39 @@ + +#include "SDLAudio.h" +#include "SDLAudioDriver.h" +#include "Services/Audio/AudioOutDriver.h" + +SDLAudio::SDLAudio(AudioSettings &hints):Audio(hints) { + hints_=hints; +} + +SDLAudio::~SDLAudio() { +} + +void SDLAudio::Init() { + AudioSettings settings ; + settings.audioAPI_=GetAudioAPI(); + + settings.bufferSize_=GetAudioBufferSize() ; + settings.preBufferCount_=GetAudioPreBufferCount() ; + + + SDLAudioDriver *drv=new SDLAudioDriver(settings) ; + AudioOut *out=new AudioOutDriver(*drv) ; + Insert(out) ; +} ; + +void SDLAudio::Close() { + IteratorPtrit(GetIterator()) ; + for (it->Begin();!it->IsDone();it->Next()) { + AudioOut ¤t=it->CurrentItem() ; + current.Close() ; + } +} ; + +int SDLAudio::GetMixerVolume() { + return 100 ; +} ; + +void SDLAudio::SetMixerVolume(int volume) { +} ; diff --git a/sources/Adapters/SDL2/Audio/SDLAudio.h b/sources/Adapters/SDL2/Audio/SDLAudio.h new file mode 100644 index 00000000..b178b848 --- /dev/null +++ b/sources/Adapters/SDL2/Audio/SDLAudio.h @@ -0,0 +1,17 @@ +#ifndef _SDL_AUDIO_H_ +#define _SDL_AUDIO_H_ + +#include "Services/Audio/Audio.h" + +class SDLAudio: public Audio { +public: + SDLAudio(AudioSettings &hints) ; // Allow for different default size for different platform + ~SDLAudio() ; + virtual void Init() ; + virtual void Close() ; + virtual int GetMixerVolume() ; + virtual void SetMixerVolume(int volume) ; +private: + AudioSettings hints_ ; +}; +#endif diff --git a/sources/Adapters/SDL2/Audio/SDLAudioDriver.cpp b/sources/Adapters/SDL2/Audio/SDLAudioDriver.cpp new file mode 100644 index 00000000..7b065bef --- /dev/null +++ b/sources/Adapters/SDL2/Audio/SDLAudioDriver.cpp @@ -0,0 +1,198 @@ +#include "SDLAudioDriver.h" +#include "Services/Midi/MidiService.h" +#include "Services/Time/TimeService.h" +#include "System/Console/Trace.h" +#include "System/System/System.h" + +void sdl_callback(void *userdata, Uint8 *stream, int len) { + SDLAudioDriver *sound=(SDLAudioDriver *)userdata ; + sound->OnChunkDone(stream,len) ; +} ; + +SDLAudioDriverThread::SDLAudioDriverThread(SDLAudioDriver *driver) { + semaphore_=SysSemaphore::Create(0,4) ; + driver_=driver ; +} ; + +bool SDLAudioDriverThread::Execute() { + while (!shouldTerminate()) { + semaphore_->Wait() ; + driver_->OnNewBufferNeeded(); + } ; + SysSemaphore *semaphore=semaphore_ ; + semaphore_=0 ; + delete semaphore ; + return true ; +} ; + +void SDLAudioDriverThread::Notify() { + if (semaphore_) { + semaphore_->Post() ; + } +} ; + +void SDLAudioDriverThread::RequestTermination() { + SysThread::RequestTermination() ; + // post to be sure we're not locked + semaphore_->Post() ; + // Wait for thread to finish + SDL_Delay(10) ; +} + +//------------------------------------------------------------------------------------------------- + +SDLAudioDriver::SDLAudioDriver(AudioSettings &settings):AudioDriver(settings), + unalignedMain_(0), + miniBlank_(0) +{ + isPlaying_=false ; + thread_=0 ; +} + +SDLAudioDriver::~SDLAudioDriver() { +} + +struct SDL_AudioSpec input ; +struct SDL_AudioSpec returned ; + +bool SDLAudioDriver::InitDriver() { + + //set sound + input.freq=44100 ; + input.format=AUDIO_S16SYS ; + input.channels=2 ; + input.callback=sdl_callback ; + input.samples=settings_.bufferSize_ ; + input.userdata=this ; + + // On my machine this wasn't working. + // SDL_AudioDeviceID deviceId = SDL_OpenAudioDevice(NULL,0,&input,&returned,0); + // The above may return 0 meaning an error or success. + int ret = SDL_OpenAudio(&input,&returned); + if ( ret != 0 ) + { + Trace::Error("Couldn't open sdl audio: %s\n", SDL_GetError()); + return false ; + } + const char * driverName = SDL_GetCurrentAudioDriver() ; + + fragSize_=returned.size ; + // Allocates a rotating sound buffer + unalignedMain_=(char *)SYS_MALLOC(fragSize_+SOUND_BUFFER_MAX) ; + // Make sure the buffer is aligned +#ifdef _64BIT + mainBuffer_=(char *)unalignedMain_; +#else + mainBuffer_=(char *)((((int)unalignedMain_)+1)&(0xFFFFFFFC)) ; +#endif + + Trace::Log("AUDIO","%s successfully opened with %d samples",driverName,fragSize_/4 ) ; + + // Create mini blank buffer in case of underruns + + miniBlank_=(char *)malloc(fragSize_) ; + SYS_MEMSET(miniBlank_,0,fragSize_) ; + + return true ; +} ; + +void SDLAudioDriver::CloseDriver() { + + if (miniBlank_) { + SYS_FREE(miniBlank_) ; + miniBlank_=0 ; + } + + if (unalignedMain_) { + SYS_FREE (unalignedMain_) ; + unalignedMain_=0 ; + } ; + SDL_CloseAudio(); +} ; + +bool SDLAudioDriver::StartDriver() { + + thread_=new SDLAudioDriverThread(this) ; + thread_->Start() ; + + short blank[4000] ; + SYS_MEMSET(blank,0,4000) ; + bufferPos_=0 ; + bufferSize_=0 ; + + for (int i=0;iAdvancePlayQueue(); + } + if (settings_.preBufferCount_==0) { + thread_->Notify() ; + } + + SDL_PauseAudio(0); + startTime_=SDL_GetTicks() ; + + return 1 ; +} ; + +void SDLAudioDriver::StopDriver() { + if (thread_) { + thread_->RequestTermination() ; + SysThread *thread=thread_ ; + thread_=0 ; + SDL_PauseAudio(1); + delete thread ; + } ; +} ; + +double SDLAudioDriver::GetStreamTime() { + return (SDL_GetTicks()-startTime_)/1000.0 ; +} + +void SDLAudioDriver::OnChunkDone(Uint8 *stream,int len) { + + // Look if we have enough data in main buffer + + while (bufferSize_-bufferPos_Flush() ; + // Adapt buffer variables + + bufferSize_=bufferSize_-bufferPos_+pool_[poolPlayPosition_].size_ ; + bufferPos_=0 ; + + SYS_FREE( pool_[poolPlayPosition_].buffer_) ; + + pool_[poolPlayPosition_].buffer_=0 ; + poolPlayPosition_=(poolPlayPosition_+1)%SOUND_BUFFER_COUNT ; + if (thread_) thread_->Notify() ; + + } + } + // Now dump audio to the device + + SYS_MEMCPY(stream,(short *)(mainBuffer_+bufferPos_), len); + onAudioBufferTick(); + bufferPos_+=len ; +} + +int SDLAudioDriver::GetPlayedBufferPercentage() { +// return 100-(bufferSize_-bufferPos_-fragSize_)*100/(bufferSize_-fragSize_) ; + return 0 ; +} ; + + + diff --git a/sources/Adapters/SDL2/Audio/SDLAudioDriver.h b/sources/Adapters/SDL2/Audio/SDLAudioDriver.h new file mode 100644 index 00000000..6df6d530 --- /dev/null +++ b/sources/Adapters/SDL2/Audio/SDLAudioDriver.h @@ -0,0 +1,51 @@ +#ifndef _SDL_SOUND_H_ +#define _SDL_SOUND_H_ + +#include "Services/Audio/AudioDriver.h" +#include +#include "System/Process/Process.h" + +class SDLAudioDriver ; + +class SDLAudioDriverThread: public SysThread { +public: + SDLAudioDriverThread(SDLAudioDriver *driver) ; + virtual ~SDLAudioDriverThread() {} ; + virtual bool Execute() ; + virtual void RequestTermination() ; + void Notify() ; +private: + SDLAudioDriver *driver_ ; + SysSemaphore *semaphore_ ; +} ; + +class SDLAudioDriver:public AudioDriver { +public: + SDLAudioDriver(AudioSettings &settings) ; + virtual ~SDLAudioDriver() ; + + // Sound implementation + virtual bool InitDriver() ; + virtual void CloseDriver(); + virtual bool StartDriver() ; + virtual void StopDriver(); + virtual int GetPlayedBufferPercentage() ; + virtual int GetSampleRate() { return 44100 ; } ; + virtual bool Interlaced() { return true ; } ; + virtual double GetStreamTime() ; + // Additional + void OnChunkDone(Uint8 *stream,int len) ; + +private: + int fragSize_ ; // Actual fragsize used by the driver + char *unalignedMain_ ; + char *mainBuffer_ ; + char *miniBlank_ ; + int bufferPos_ ; + int bufferSize_ ; + SDLAudioDriverThread *thread_ ; + Uint32 startTime_ ; +} ; + + +#endif diff --git a/sources/Adapters/SDL2/GUI/GUIFactory.cpp b/sources/Adapters/SDL2/GUI/GUIFactory.cpp new file mode 100644 index 00000000..4f19eed3 --- /dev/null +++ b/sources/Adapters/SDL2/GUI/GUIFactory.cpp @@ -0,0 +1,18 @@ +#include "GUIFactory.h" +#include "SDLGUIWindowImp.h" +#include "SDLEventManager.h" +#ifndef _USE_NCURSES_ + + +GUIFactory::GUIFactory() { +} ; + + +I_GUIWindowImp &GUIFactory::CreateWindowImp(GUICreateWindowParams &p) { + return *(new SDLGUIWindowImp(p)) ; +} + +EventManager *GUIFactory::GetEventManager() { + return SDLEventManager::GetInstance() ; +} +#endif diff --git a/sources/Adapters/SDL2/GUI/GUIFactory.h b/sources/Adapters/SDL2/GUI/GUIFactory.h new file mode 100644 index 00000000..5a484731 --- /dev/null +++ b/sources/Adapters/SDL2/GUI/GUIFactory.h @@ -0,0 +1,18 @@ +#ifndef SDL_GUI_FACTORY_H_ +#define SDL_GUI_FACTORY_H_ + +#ifndef _USE_NCURSES_ + +#include "UIFramework/Interfaces/I_GUIWindowFactory.h" + +class GUIFactory: public I_GUIWindowFactory { + +public: + GUIFactory() ; + virtual I_GUIWindowImp &CreateWindowImp(GUICreateWindowParams &) ; + virtual EventManager *GetEventManager() ; + +} ; + +#endif +#endif diff --git a/sources/Adapters/SDL2/GUI/SDLEventManager.cpp b/sources/Adapters/SDL2/GUI/SDLEventManager.cpp new file mode 100644 index 00000000..0c035b7e --- /dev/null +++ b/sources/Adapters/SDL2/GUI/SDLEventManager.cpp @@ -0,0 +1,171 @@ + +#include "SDLEventManager.h" +#include "Application/Application.h" +#include "Application/Model/Config.h" +#include "System/Console/Trace.h" +#include "UIFramework/BasicDatas/GUIEvent.h" +#include "SDLGUIWindowImp.h" +bool SDLEventManager::finished_=false ; +bool SDLEventManager::dumpEvent_=false ; + +SDLEventManager::SDLEventManager() +{ +} + +SDLEventManager::~SDLEventManager() +{ +} + +bool SDLEventManager::Init() +{ + EventManager::Init() ; + + if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_TIMER) < 0 ) + { + return false; + } + + SDL_ShowCursor(SDL_DISABLE); + + atexit(SDL_Quit) ; + + SDL_InitSubSystem(SDL_INIT_JOYSTICK); + + int joyCount=SDL_NumJoysticks() ; + joyCount=(joyCount>MAX_JOY_COUNT)?MAX_JOY_COUNT:joyCount ; + + keyboardCS_=new KeyboardControllerSource("keyboard") ; + const char *dumpIt=Config::GetInstance()->GetValue("DUMPEVENT") ; + if ((dumpIt)&&(!strcmp(dumpIt,"YES"))) + { + dumpEvent_=true ; + } + + for (int i=0;iGetWindow() ; + SDLGUIWindowImp *sdlWindow=(SDLGUIWindowImp *)appWindow->GetImpWindow() ; + while (!finished_) + { + SDL_Event event; + if (SDL_WaitEvent(&event)) + { + switch (event.type) { + case SDL_KEYDOWN: + if (dumpEvent_) + { + Trace::Log("EVENT","key(%s:%d):%d",SDL_GetScancodeName(event.key.keysym.scancode),event.key.keysym.scancode,1) ; + } + keyboardCS_->SetKey((int)event.key.keysym.scancode,true) ; + break ; + + case SDL_KEYUP: + if (dumpEvent_) + { + Trace::Log("EVENT","key(%s:%d):%d",SDL_GetScancodeName(event.key.keysym.scancode),event.key.keysym.scancode,0) ; + } + keyboardCS_->SetKey((int)event.key.keysym.scancode,false) ; + break ; + + + case SDL_JOYBUTTONDOWN: + buttonCS_[event.jbutton.which]->SetButton(event.jbutton.button,true) ; + break ; + case SDL_JOYBUTTONUP: + if (dumpEvent_) { + Trace::Log("EVENT","but(%d):%d",event.button.which,event.jbutton.button) ; + } + buttonCS_[event.jbutton.which]->SetButton(event.jbutton.button,false) ; + break ; + case SDL_JOYAXISMOTION: + if (dumpEvent_) { + Trace::Log("EVENT","joy(%d)::%d=%d",event.jaxis.which,event.jaxis.axis,event.jaxis.value) ; + } + joystickCS_[event.jaxis.which]->SetAxis(event.jaxis.axis,float(event.jaxis.value)/32767.0f) ; + break ; + case SDL_JOYHATMOTION: + if (dumpEvent_) + { + for (int i=0;i<4;i++) + { + int mask = 1<SetHat(event.jhat.hat,event.jhat.value) ; + break ; + case SDL_JOYBALLMOTION: + if (dumpEvent_) + { + Trace::Log("EVENT","ball(%d)::%d=(%d,%d)",event.jball.which,event.jball.ball,event.jball.xrel,event.jball.yrel) ; + } + break ; + } + + switch (event.type) + { + + case SDL_QUIT: + sdlWindow->ProcessQuit() ; + break ; + case SDL_WINDOWEVENT: + switch (event.window.event) + { + case SDL_WINDOWEVENT_EXPOSED: + case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_SIZE_CHANGED: + sdlWindow->ProcessExpose() ; + break; + } + break ; + case SDL_USEREVENT: + sdlWindow->ProcessUserEvent(event) ; + break ; + } + } + } + return 0 ; +} ; + + + +void SDLEventManager::PostQuitMessage() +{ + Trace::Log("EVENT","SDEM:PostQuitMessage()") ; + finished_=true ; +} ; + + +int SDLEventManager::GetKeyCode(const char *key) +{ + return SDL_GetScancodeFromName(key); +} diff --git a/sources/Adapters/SDL2/GUI/SDLEventManager.h b/sources/Adapters/SDL2/GUI/SDLEventManager.h new file mode 100644 index 00000000..6ed26991 --- /dev/null +++ b/sources/Adapters/SDL2/GUI/SDLEventManager.h @@ -0,0 +1,35 @@ +#ifndef _SDL_EVENT_MANAGER_ +#define _SDL_EVENT_MANAGER_ + +#include +#include +#include "Foundation/T_Singleton.h" +#include "Services/Controllers/ButtonControllerSource.h" +#include "Services/Controllers/HatControllerSource.h" +#include "Services/Controllers/JoystickControllerSource.h" +#include "Services/Controllers/KeyboardControllerSource.h" +#include "UIFramework/SimpleBaseClasses/EventManager.h" + +#define MAX_JOY_COUNT 4 + + + +class SDLEventManager: public T_Singleton,public EventManager { +public: + SDLEventManager() ; + ~SDLEventManager() ; + virtual bool Init() ; + virtual int MainLoop() ; + virtual void PostQuitMessage() ; + virtual int GetKeyCode(const char *name) ; + +private: + static bool finished_ ; + static bool dumpEvent_ ; + SDL_Joystick *joystick_[MAX_JOY_COUNT]; + ButtonControllerSource *buttonCS_[MAX_JOY_COUNT] ; + JoystickControllerSource *joystickCS_[MAX_JOY_COUNT] ; + HatControllerSource *hatCS_[MAX_JOY_COUNT] ; + KeyboardControllerSource *keyboardCS_ ; +} ; +#endif diff --git a/sources/Adapters/SDL2/GUI/SDLGUIWindowImp.cpp b/sources/Adapters/SDL2/GUI/SDLGUIWindowImp.cpp new file mode 100644 index 00000000..5ca6cdbf --- /dev/null +++ b/sources/Adapters/SDL2/GUI/SDLGUIWindowImp.cpp @@ -0,0 +1,543 @@ +#include "SDLGUIWindowImp.h" +#include +#include +#include "Application/Model/Config.h" +#include "Application/Utils/char.h" +#include "System/Console/n_assert.h" +#include "System/Console/Trace.h" +#include "System/System/System.h" +#include "UIFramework/BasicDatas/GUIEvent.h" +#include "UIFramework/SimpleBaseClasses/GUIWindow.h" + +SDLGUIWindowImp *instance_ ; + +unsigned short appWidth=320 ; +unsigned short appHeight=240 ; + +SDLGUIWindowImp::SDLGUIWindowImp(GUICreateWindowParams &p) +{ + + SDLCreateWindowParams &sdlP=(SDLCreateWindowParams &)p; + cacheFonts_=sdlP.cacheFonts_ ; + framebuffer_=sdlP.framebuffer_ ; + + // By default if we are not running a framebuffer device + // we assumed it's windowed + + windowed_ = !framebuffer_; + + + SDL_DisplayMode displayMode; + + // SDL Prioritises screens so just take the first for now. + int displayModeRet = SDL_GetDisplayMode(0, 0, &displayMode); + NAssert(displayModeRet != 0); + + #if defined(PLATFORM_PSP) + int screenWidth = 480; + int screenHeight = 272; + windowed_ = false; + #elif defined(RS97) + int screenWidth = 320; + int screenHeight = 240; + windowed_ = false; + #else + int screenWidth = displayMode.w; + int screenHeight = displayMode.h; + #endif + + #if defined(RS97) + /* Pick the best bitdepth for the RS97 as it will select 32 as its default, even though that's slow */ + bitDepth_ = 16; + #else + bitDepth_ = SDL_BITSPERPIXEL(displayMode.format); + #endif + + const char * driverName = SDL_GetVideoDriver(0); + + Trace::Log("DISPLAY","Using driver %s. Screen (%d,%d) Bpp:%d",driverName,screenWidth,screenHeight,bitDepth_); + + bool fullscreen=false ; + + const char *fullscreenValue=Config::GetInstance()->GetValue("FULLSCREEN") ; + if ((fullscreenValue)&&(!strcmp(fullscreenValue,"YES"))) + { + fullscreen=true ; + } + + if (!strcmp(driverName, "fbcon")) + { + framebuffer_ = true; + windowed_ = false; + } + + #ifdef PLATFORM_PSP + mult_ = 1; + #else + int multFromSize=MIN(screenHeight/appHeight,screenWidth/appWidth); + const char *mult=Config::GetInstance()->GetValue("SCREENMULT") ; + if (mult) + { + mult_=atoi(mult); + } + else + { + if (framebuffer_) + { + mult_ = multFromSize; + } + else + { + mult_ = 1; + } + } + #endif + // Create a window that is the requested size + + screenRect_._topLeft._x=0; + screenRect_._topLeft._y=0; + screenRect_._bottomRight._x=windowed_?appWidth*mult_:screenWidth; + screenRect_._bottomRight._y=windowed_?appHeight*mult_:screenHeight; + + Trace::Log("DISPLAY","Creating SDL Window (%d,%d)",screenRect_.Width(), screenRect_.Height()); + window_ = SDL_CreateWindow("LittleGPTracker",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED, + screenRect_.Width(),screenRect_.Height(),fullscreen?SDL_WINDOW_FULLSCREEN:SDL_WINDOW_SHOWN); + NAssert(window_) ; + + // Compute the x & y offset to locate our app window + + appAnchorX_=(screenRect_.Width()-appWidth*mult_)/2 ; + appAnchorY_=(screenRect_.Height()-appHeight*mult_)/2 ; + + SDL_SetWindowIcon(window_, SDL_LoadBMP("lgpt_icon.bmp")); + surface_ = SDL_GetWindowSurface(window_); + + NAssert(surface_) ; + + Uint32 rmask, gmask, bmask, amask; + +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; +#else + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = 0xff000000; +#endif + + instance_=this ; + currentColor_=0; + backgroundColor_=0 ; + SDL_ShowCursor(SDL_DISABLE); + + + if (cacheFonts_) + { + Trace::Log("DISPLAY","Preparing fonts") ; + prepareFonts() ; + } + updateCount_=0 ; +} ; + +SDLGUIWindowImp::~SDLGUIWindowImp() { + +} + +#define FONT_WIDTH 1024 +#define FONT_COUNT 127 +static const unsigned char font[]= { + #include "Resources/font.h" +}; + +static SDL_Surface *fonts[FONT_COUNT] ; + +void SDLGUIWindowImp::prepareFullFonts() +{ + Trace::Log("DISPLAY","Preparing full font cache") ; + Uint32 rmask, gmask, bmask, amask; + +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; +#else + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = 0xff000000; +#endif + + for (int i=0;iformat->BytesPerPixel ; + unsigned char *bgPtr=(unsigned char *)&backgroundColor_ ; + unsigned char *fgPtr=(unsigned char *)&foregroundColor_ ; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + bgPtr+=(4-pixelSize) ; + fgPtr+=(4-pixelSize) ; +#endif + const unsigned char *src=font+i*8 ; + unsigned char *dest=(unsigned char *)fonts[i]->pixels; + for (int y = 0; y < 8; y++) + { + for (int n=0;npitch-8*pixelSize*mult_ ; + } + if (y<7) src+=FONT_WIDTH ; + } + SDL_UnlockSurface(fonts[i]) ; + }; + }; +} + +void SDLGUIWindowImp::prepareFonts() +{ + + Trace::Log("DISPLAY","Preparing font cache") ; + Config *config=Config::GetInstance() ; + + unsigned char r,g,b ; + const char *value=config->GetValue("BACKGROUND") ; + if (value) + { + char2hex(value,&r) ; + char2hex(value+2,&g) ; + char2hex(value+4,&b) ; + } + else + { + r=0xF1 ; + g=0xF1 ; + b=0x96 ; + } + backgroundColor_=SDL_MapRGB(surface_->format, r,g,b) ; + + value=config->GetValue("FOREGROUND") ; + if (value) + { + char2hex(value,&r) ; + char2hex(value+2,&g) ; + char2hex(value+4,&b) ; + } + else + { + r=0x77 ; + g=0x6B ; + b=0x56 ; + } + foregroundColor_=SDL_MapRGB(surface_->format, r,g,b) ; + + prepareFullFonts() ; +} + +void SDLGUIWindowImp::DrawChar(const char c, GUIPoint &pos, GUITextProperties &p) +{ + int xx,yy; + transform(pos, &xx, &yy); + + if ((xx<0) || (yy<0)) return; + if ((xx>=screenRect_._bottomRight._x) || (yy>=screenRect_._bottomRight._y)) + return ; + if ((!framebuffer_)&&(updateCount_x=xx ; + area->y=yy ; + area->h=8*mult_ ; + area->w=8*mult_ ; + } + + if (((cacheFonts_)&&(currentColor_==foregroundColor_)&&(!p.invert_))) { + + SDL_Rect srcRect ; + srcRect.x=0 ; + srcRect.y=0 ; + srcRect.w=8*mult_ ; + srcRect.h=8*mult_ ; + + SDL_Rect dstRect ; + dstRect.x=xx ; + dstRect.y=yy ; + dstRect.w=8*mult_ ; + dstRect.h=8*mult_ ; + + unsigned int fontID=c ; + if (fontIDformat->BytesPerPixel ; + unsigned char *bgPtr=(unsigned char *)&backgroundColor_ ; + unsigned char *fgPtr=(unsigned char *)¤tColor_ ; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + bgPtr+=(4-pixelSize) ; + fgPtr+=(4-pixelSize) ; +#endif + const unsigned char *src=font+c*8 ; + unsigned char *dest=((unsigned char *)surface_->pixels) + (yy*surface_->pitch) + xx*pixelSize; + + for (int y = 0; y < 8; y++) { + for (int n=0;npitch-8*pixelSize*mult_ ; + } + if (y<7) src+=FONT_WIDTH ; + } + + } +} + +void SDLGUIWindowImp::transform(const GUIRect &srcRect,SDL_Rect *dstRect) +{ + dstRect->x = srcRect.Left() * mult_ + appAnchorX_; + dstRect->y = srcRect.Top() * mult_ + appAnchorY_; + dstRect->w = srcRect.Width() * mult_ ; + dstRect->h = srcRect.Height() * mult_ ; +} + +void SDLGUIWindowImp::transform(const GUIPoint &srcPoint, int *x, int *y) +{ + *x=appAnchorX_ + srcPoint._x*mult_ ; + *y=appAnchorY_ + srcPoint._y*mult_ ; +} + +void SDLGUIWindowImp::DrawString(const char *string,GUIPoint &pos,GUITextProperties &p,bool overlay) +{ + + int len=int(strlen(string)) ; + int xx,yy; + transform(pos, &xx , &yy); + + if ((!framebuffer_)&&(updateCount_x=xx ; + area->y=yy ; + area->h=8*mult_ ; + area->w=len*8*mult_ ; + } + + for (int l=0;lformat->BytesPerPixel ; + unsigned char *bgPtr=(unsigned char *)&backgroundColor_ ; + unsigned char *fgPtr=(unsigned char *)¤tColor_ ; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + bgPtr+=(4-pixelSize) ; + fgPtr+=(4-pixelSize) ; +#endif + const unsigned char *src=font+(string[l]*8) ; + unsigned char *dest=((unsigned char *)surface_->pixels) + (yy*surface_->pitch) + xx*pixelSize; + + for (int y = 0; y < 8; y++) { + for (int n=0;npitch-8*pixelSize*mult_ ; + } + if (y<7) src+=FONT_WIDTH ; + } + + } + xx+=8*mult_ ; + } +} + +void SDLGUIWindowImp::DrawRect(GUIRect &r) +{ + SDL_Rect rect; + transform(r, &rect); + SDL_FillRect(surface_, &rect,currentColor_) ; +} ; + +void SDLGUIWindowImp::Clear(GUIColor &c,bool overlay) +{ + SDL_Rect rect; + rect.x = 0; + rect.y = 0; + rect.w = screenRect_.Width(); + rect.h = screenRect_.Height(); + + backgroundColor_=SDL_MapRGB(surface_->format,c._r&0xFF,c._g&0xFF,c._b&0xFF); + SDL_FillRect(surface_, &rect,backgroundColor_) ; + + if (!framebuffer_) + { + SDL_Rect *area=updateRects_; + area->x=rect.x ; + area->y=rect.y ; + area->w=rect.w ; + area->h=rect.h ; + updateCount_=1 ; + } +} + +void SDLGUIWindowImp::ClearRect(GUIRect &r) +{ + SDL_Rect rect; + transform(r, &rect); + SDL_FillRect(surface_, &rect,backgroundColor_) ; +} + +// To the app we might have a smaller window +// than the effective one (PSP) + +GUIRect SDLGUIWindowImp::GetRect() +{ + return GUIRect(0,0,appWidth,appHeight) ; +} + +// Pushback a SDL event to specify screen has to be redrawn. + +void SDLGUIWindowImp::Invalidate() +{ + // Todo: SL: Haven't found a good replacement here yet + SDL_Event event ; + event.type=SDL_WINDOWEVENT ; + event.window.event = SDL_WINDOWEVENT_EXPOSED; + SDL_PushEvent(&event) ; +} + +void SDLGUIWindowImp::SetColor(GUIColor &c) +{ + currentColor_=SDL_MapRGB(surface_->format,c._r&0xFF,c._g&0xFF,c._b&0xFF); +} + +void SDLGUIWindowImp::Lock() +{ + if (framebuffer_) + { + return; + } + + if (SDL_MUSTLOCK(surface_)) + { + SDL_LockSurface(surface_) ; + } +} + +void SDLGUIWindowImp::Unlock() +{ + if (framebuffer_) + { + return; + } + + if (SDL_MUSTLOCK(surface_)) + { + SDL_UnlockSurface(surface_) ; + } +} + +void SDLGUIWindowImp::Flush() +{ + // blit partial updates on resource constrained platforms + if ((!framebuffer_)&&(updateCount_!=0)) + { + if (updateCount_Update() ; +} + +void SDLGUIWindowImp::ProcessQuit() +{ + GUIPoint p; + GUIEvent e(p,ET_SYSQUIT) ; + _window->DispatchEvent(e) ; +} ; + +void SDLGUIWindowImp::PushEvent(GUIEvent &event) +{ + SDL_Event sdlevent ; + sdlevent.type=SDL_USEREVENT ; + sdlevent.user.data1=&event ; + SDL_PushEvent(&sdlevent) ; +} ; + +void SDLGUIWindowImp::ProcessUserEvent(SDL_Event &event) +{ + GUIEvent *guiEvent=(GUIEvent *)event.user.data1 ; + _window->DispatchEvent(*guiEvent) ; + delete(guiEvent) ; +} diff --git a/sources/Adapters/SDL2/GUI/SDLGUIWindowImp.h b/sources/Adapters/SDL2/GUI/SDLGUIWindowImp.h new file mode 100644 index 00000000..956348de --- /dev/null +++ b/sources/Adapters/SDL2/GUI/SDLGUIWindowImp.h @@ -0,0 +1,69 @@ +#ifndef SDL_GUI_WINDOW_H_ +#define SDL_GUI_WINDOW_H_ + +#include "UIFramework/Interfaces/I_GUIWindowImp.h" +#include + +bool ProcessDEBEvent(SDL_Event &event) ; +void ProcessButtonChange(unsigned short,unsigned short) ; + +#define MAX_OVERLAYS 250 + +struct SDLCreateWindowParams: public GUICreateWindowParams { + SDLCreateWindowParams():cacheFonts_(true),framebuffer_(false) {} ; + bool cacheFonts_ ; + bool framebuffer_ ; +} ; + +class SDLGUIWindowImp: public I_GUIWindowImp { + +public: + + SDLGUIWindowImp(GUICreateWindowParams &p) ; + virtual ~SDLGUIWindowImp() ; + +public: // I_GUIWindowImp implementation + + virtual void SetColor(GUIColor &) ; + virtual void DrawRect(GUIRect &) ; + virtual void DrawChar(const char c,GUIPoint &pos,GUITextProperties &); + virtual void DrawString(const char *string,GUIPoint &pos,GUITextProperties &,bool overlay=false); + virtual GUIRect GetRect() ; + virtual void Invalidate() ; + virtual void Flush(); + virtual void Lock() ; + virtual void Unlock() ; + virtual void Clear(GUIColor &, bool overlay=false) ; + virtual void ClearRect(GUIRect &) ; + virtual void PushEvent(GUIEvent &event) ; + +public: // Added functionality + void ProcessExpose() ; + void ProcessQuit() ; + void ProcessUserEvent(SDL_Event &event) ; +protected: + void prepareFonts() ; + void prepareFullFonts() ; + void prepareBPP1Fonts() ; + void transform(const GUIRect &srcRect,SDL_Rect *dstRect); + void transform(const GUIPoint &srcPoint, int *x, int *y); + +private: + SDL_Window *window_; + SDL_Surface *surface_; +// SDL_Surface *offscreen_ ; + GUIRect screenRect_ ; + unsigned int currentColor_ ; + unsigned int backgroundColor_ ; + unsigned int foregroundColor_ ; + int bitDepth_ ; + bool cacheFonts_ ; + bool framebuffer_ ; + bool windowed_; + SDL_Rect updateRects_[MAX_OVERLAYS] ; + int updateCount_ ; + int appAnchorX_ ; + int appAnchorY_ ; + int mult_ ; +} ; +#endif diff --git a/sources/Adapters/SDL2/Input/SDLInput.cpp b/sources/Adapters/SDL2/Input/SDLInput.cpp new file mode 100644 index 00000000..2c3641b1 --- /dev/null +++ b/sources/Adapters/SDL2/Input/SDLInput.cpp @@ -0,0 +1,203 @@ + +#include "SDLInput.h" +#include "Application/Model/Config.h" + +#ifndef PLATOFM_BITTBOY +int keyMapping[]={ + SDLK_a, + SDLK_s, + SDLK_LEFT, + SDLK_RIGHT, + SDLK_UP, + SDLK_DOWN, + SDLK_RCTRL, + SDLK_LCTRL, + SDLK_SPACE +} ; +#endif + +int eventMapping[]={ + SDLI_BUTTON_A, + SDLI_BUTTON_B, + SDLI_BUTTON_LEFT, + SDLI_BUTTON_RIGHT, + SDLI_BUTTON_UP, + SDLI_BUTTON_DOWN, + SDLI_BUTTON_L, + SDLI_BUTTON_R, + SDLI_BUTTON_START +} ; + +enum MappingType { + MT_KEY, + MT_JOYBUTTON, + MT_JOYHAT, + MT_JOYAXES +} ; + +int keyMappingType[9] ; + + +SDLInput::SDLInput() { + + // open first joystick if available + + if(SDL_NumJoysticks()>0){ + // Open joystick + joystick_=SDL_JoystickOpen(0); + Trace::Debug("Number of axis:%d",SDL_JoystickNumAxes(joystick_)) ; + Trace::Debug("Number of buttons:%d",SDL_JoystickNumButtons(joystick_)) ; + Trace::Debug("Number of hats:%d",SDL_JoystickNumHats(joystick_)) ; + } else { + joystick_=0 ; + } ; + Trace::Debug("Joystick: %s",joystick_?"opened":"not found") ; + + // initialises default mapping table + for (int i=0;i<9;i++) { + keyMappingType[i]=MT_KEY ; + } ; +} ; + +void SDLInput::ReadConfig() { + + mapKey(0,"KEY_A") ; + mapKey(1,"KEY_B") ; + mapKey(2,"KEY_LEFT") ; + mapKey(3,"KEY_RIGHT") ; + mapKey(4,"KEY_UP") ; + mapKey(5,"KEY_DOWN") ; + mapKey(6,"KEY_LSHOULDER") ; + mapKey(7,"KEY_RSHOULDER") ; + mapKey(8,"KEY_START") ; +} + +void SDLInput::mapKey(int index,const char *keyname) { + + Config *config=Config::GetInstance() ; + + // Read the configuration file and look if we got a definition + const char *key=config->GetValue(keyname) ; + if (key) { + // we found a key, let's find which type it is + + MappingType type=MT_KEY ; + if (key[3]==':') { + if (tolower(key[0])=='b') { // button + type=MT_JOYBUTTON ; + } + if (tolower(key[0])=='h') { // hat + type=MT_JOYHAT ; + } + if (tolower(key[0])=='j') { // joy + type=MT_JOYAXES ; + } + } ; + + keyMappingType[index]=type ; + switch(type) { + case MT_KEY: + for (int i=0;itrigger) { + mask|=eventMapping[i] ; + } + } + } + break ; + default: + break ; + } ; + } + return mask ; +} ; + diff --git a/sources/Adapters/SDL2/Input/SDLInput.h b/sources/Adapters/SDL2/Input/SDLInput.h new file mode 100644 index 00000000..7ce7b838 --- /dev/null +++ b/sources/Adapters/SDL2/Input/SDLInput.h @@ -0,0 +1,35 @@ + +#ifndef _SDL_INPUT_H_ +#define _SDL_INPUT_H_ + +#include "Externals/SDL/SDL.h" +#include "Foundation/T_Singleton.h" + +#define SDLI_BUTTON_A 0x1 +#define SDLI_BUTTON_B 0x2 +#define SDLI_BUTTON_LEFT 0x4 +#define SDLI_BUTTON_RIGHT 0x8 +#define SDLI_BUTTON_UP 0x10 +#define SDLI_BUTTON_DOWN 0x20 +#define SDLI_BUTTON_L 0x40 +#define SDLI_BUTTON_R 0x80 +#define SDLI_BUTTON_START 0x100 +#define SDLI_BUTTON_SELECT 0x200 + + +class SDLInput: public T_Singleton { +public: + SDLInput() ; + void ReadConfig(); + unsigned short GetButtonMask() ; + +private: + void mapKey(int index,const char *keyname) ; + + SDL_Joystick *joystick_; + + const char *keyname_[SDL_NUM_SCANCODES] ; + +} ; + +#endif diff --git a/sources/Adapters/SDL2/Process/SDLProcess.cpp b/sources/Adapters/SDL2/Process/SDLProcess.cpp new file mode 100644 index 00000000..90719c30 --- /dev/null +++ b/sources/Adapters/SDL2/Process/SDLProcess.cpp @@ -0,0 +1,54 @@ + +#include "SDLProcess.h" +#include + +int _SDLStartThread(void *argp) { + SysThread *play=(SysThread *)argp ; + play->startExecution() ; + return 0 ; +} + +bool SDLProcessFactory::BeginThread(SysThread& thread) { + SDL_CreateThread(_SDLStartThread,&thread); + return true ; +} + +SysSemaphore *SDLProcessFactory::CreateNewSemaphore(int initialcount, int maxcount) { + return new SDLSysSemaphore(initialcount,maxcount) ; +} ; + +SDLSysSemaphore::SDLSysSemaphore(int initialcount,int maxcount) { + handle_=SDL_CreateSemaphore(0) ; +} ; + +SDLSysSemaphore::~SDLSysSemaphore() { + handle_=0 ; +} ; + +SysSemaphoreResult SDLSysSemaphore::Wait() { + if (!handle_) { + return SSR_INVALID ; + } ; + return (SysSemaphoreResult)SDL_SemWait(handle_) ; +} ; + +SysSemaphoreResult SDLSysSemaphore::TryWait() { + if (!handle_) { + return SSR_INVALID ; + } ; + return (SysSemaphoreResult)0; +} + +SysSemaphoreResult SDLSysSemaphore::WaitTimeout(unsigned long timeout) { + if (!handle_) { + return SSR_INVALID ; + } ; + return (SysSemaphoreResult)0; +} ; + +SysSemaphoreResult SDLSysSemaphore::Post() { + if (!handle_) { + return SSR_INVALID ; + } ; + return (SysSemaphoreResult)SDL_SemPost(handle_) ; +} ; diff --git a/sources/Adapters/SDL2/Process/SDLProcess.h b/sources/Adapters/SDL2/Process/SDLProcess.h new file mode 100644 index 00000000..18744f73 --- /dev/null +++ b/sources/Adapters/SDL2/Process/SDLProcess.h @@ -0,0 +1,23 @@ +#ifndef _SDL_PROCESS_H_ +#define _SDL_PROCESS_H_ + +#include "System/Process/Process.h" +#include + +class SDLProcessFactory:public SysProcessFactory { + bool BeginThread(SysThread &) ; + virtual SysSemaphore *CreateNewSemaphore(int initialcount = 0, int maxcount = 0) ; +} ; + +class SDLSysSemaphore:public SysSemaphore { +public: + SDLSysSemaphore(int initialcount = 0, int maxcount = 0) ; + virtual ~SDLSysSemaphore() ; + virtual SysSemaphoreResult Wait() ; + virtual SysSemaphoreResult TryWait() ; + virtual SysSemaphoreResult WaitTimeout(unsigned long) ; + virtual SysSemaphoreResult Post() ; +private: + SDL_sem *handle_ ; +} ; +#endif diff --git a/sources/Adapters/SDL2/Timer/SDLTimer.cpp b/sources/Adapters/SDL2/Timer/SDLTimer.cpp new file mode 100644 index 00000000..bf3031dc --- /dev/null +++ b/sources/Adapters/SDL2/Timer/SDLTimer.cpp @@ -0,0 +1,73 @@ + +#include "SDLTimer.h" +#include "System/Console/n_assert.h" +#include "System/Console/Trace.h" +#include "System/System/System.h" + +Uint32 SDLTimerCallback(Uint32 interval, void* param) { + SDLTimer *timer=(SDLTimer *)param ; + return timer->OnTimerTick() ; +} ; + +Uint32 SDLTriggerCallback(Uint32 interval, void* param) { + timerCallback tc=(timerCallback)param ; + (*tc)() ; + return 0 ; +} ; + +SDLTimer::SDLTimer() { + period_=-1 ; + timer_=0 ; + running_=false ; +} ; + +SDLTimer::~SDLTimer() { +} + +void SDLTimer::SetPeriod(float msec) { + period_=int(msec) ; + offset_=0 ; +} ; + +bool SDLTimer::Start() { + if (period_>0) { + offset_=period_ ; + Uint32 newcb=int(offset_) ; + offset_-=newcb ; + timer_=SDL_AddTimer(newcb,SDLTimerCallback,this); + lastTick_=System::GetInstance()->GetClock() ; + running_=true ; + } + return (timer_!=0) ; +} ; + +void SDLTimer::Stop() { + SDL_RemoveTimer(timer_) ; + timer_=0 ; + running_=false ; +} ; + +float SDLTimer::GetPeriod() { + return period_ ; +} ; + +Uint32 SDLTimer::OnTimerTick() { + Uint32 newcb=0 ; + if (running_) { + SetChanged() ; + NotifyObservers() ; + offset_+=period_ ; + newcb=int(offset_) ; + offset_-=newcb ; + NAssert(newcb>0) ; + } + return newcb ; +} ; + +I_Timer *SDLTimerService::CreateTimer() { + return new SDLTimer() ; +} ; + +void SDLTimerService::TriggerCallback(int msec,timerCallback cb) { + SDL_AddTimer(msec,SDLTriggerCallback,(void *)cb); +} diff --git a/sources/Adapters/SDL2/Timer/SDLTimer.h b/sources/Adapters/SDL2/Timer/SDLTimer.h new file mode 100644 index 00000000..5366cb38 --- /dev/null +++ b/sources/Adapters/SDL2/Timer/SDLTimer.h @@ -0,0 +1,32 @@ +#ifndef _SDL_TIMER_H_ +#define _SDL_TIMER_H_ + +#include +#include "System/Timer/Timer.h" + +class SDLTimer: public I_Timer { +public: + SDLTimer() ; + virtual ~SDLTimer() ; + virtual void SetPeriod(float msec) ; + virtual bool Start() ; + virtual void Stop() ; + virtual float GetPeriod() ; + Uint32 OnTimerTick() ; + +private: + float period_ ; + float offset_ ; // Float offset taking into account + // period is an int + SDL_TimerID timer_ ; // NULL if not running + long lastTick_ ; + bool running_ ; +} ; + +class SDLTimerService: public TimerService { +public: + virtual I_Timer *CreateTimer() ; // Returns a timer + virtual void TriggerCallback(int msec,timerCallback cb) ; +}; + +#endif diff --git a/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp b/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp index e1c678d9..c4a38950 100644 --- a/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp +++ b/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp @@ -4,7 +4,11 @@ #include #include #include +#ifdef _64BIT +#include +#else #include +#endif #include #include #include @@ -133,7 +137,9 @@ long UnixFile::Tell() { } ; void UnixFile::Close() { fflush(file_) ; +#ifndef _64BIT fsync(fileno(file_)) ; +#endif fclose(file_) ; } ; diff --git a/sources/Application/Commands/EventDispatcher.cpp b/sources/Application/Commands/EventDispatcher.cpp index 268692ab..113bc46b 100644 --- a/sources/Application/Commands/EventDispatcher.cpp +++ b/sources/Application/Commands/EventDispatcher.cpp @@ -1,7 +1,11 @@ #include "EventDispatcher.h" -#include "System/Console/Trace.h" +#ifdef SDL2 +#include +#else +#include +#endif #include "Application/Model/Config.h" -#include "SDL/SDL.h" +#include "System/Console/Trace.h" int EventDispatcher::keyRepeat_=30 ; int EventDispatcher::keyDelay_=500 ; diff --git a/sources/Application/Instruments/SampleInstrument.cpp b/sources/Application/Instruments/SampleInstrument.cpp index 74f4816d..7368f8fc 100644 --- a/sources/Application/Instruments/SampleInstrument.cpp +++ b/sources/Application/Instruments/SampleInstrument.cpp @@ -809,7 +809,11 @@ bool SampleInstrument::Render(int channel,fixed *buffer,int size,bool updateTick { if (useDirtyDownsampling_) { +#ifdef _64BIT + i1 =(short *)(((long)input)&dsMask); +#else i1 =(short *)(((unsigned int)input)&dsMask); +#endif } else { diff --git a/sources/Application/Instruments/SoundFontManager.cpp b/sources/Application/Instruments/SoundFontManager.cpp index 8d794f61..0acec549 100644 --- a/sources/Application/Instruments/SoundFontManager.cpp +++ b/sources/Application/Instruments/SoundFontManager.cpp @@ -2,6 +2,10 @@ #include "System/System/System.h" #include "System/FileSystem/FileSystem.h" +#ifdef _64BIT +#include +#endif + SoundFontManager::SoundFontManager() { } ; @@ -62,7 +66,11 @@ sfBankID SoundFontManager::LoadBank(const char *path) { current.dwEnd=(current.dwEnd-current.dwStart) ; current.dwStartloop=(current.dwStartloop-current.dwStart) ; current.dwEndloop=(current.dwEndloop-current.dwStart) ; +#ifdef _64BIT + current.dwStart=(intptr_t)buffer ; +#else current.dwStart=(DWORD)buffer ; +#endif sampleData_.push_back(buffer) ; } @@ -70,4 +78,4 @@ sfBankID SoundFontManager::LoadBank(const char *path) { SAFE_DELETE(fin) ; return id ; -} ; \ No newline at end of file +} ; diff --git a/sources/Application/Mixer/MixerService.cpp b/sources/Application/Mixer/MixerService.cpp index fcd1cc61..82a7f1bc 100644 --- a/sources/Application/Mixer/MixerService.cpp +++ b/sources/Application/Mixer/MixerService.cpp @@ -32,66 +32,63 @@ MixerService::MixerService(): MixerService::~MixerService() { } ; +/* + * initializes the mixer service, config changes depending if we're in sequencer or render mode + */ bool MixerService::Init() { - - out_=0 ; - - // Create the output depending on rendering mode - + // create the output depending on rendering mode + out_ = 0; switch (mode_) { case MSM_FILE: case MSM_FILESPLIT: - out_=new DummyAudioOut() ; + out_ = new DummyAudioOut(); break; default: - Audio *audio=Audio::GetInstance() ; - out_=audio->GetFirst() ; - break ; + Audio *audio = Audio::GetInstance(); + out_ = audio->GetFirst(); + break; } - bool result=false ; - for (int i=0;iInit(); + if (result) { + out_->Insert(master_); + } - result=out_->Init() ; - if (result) { - out_->Insert(master_) ; - } - - switch(mode_) { - case MSM_AUDIO: - break ; - case MSM_FILERT: - case MSM_FILE: - out_->SetFileRenderer("project:mixdown.wav") ; + switch(mode_) { + case MSM_AUDIO: break ; - case MSM_FILESPLITRT: - case MSM_FILESPLIT: - for (int i=0;iAddObserver(*MidiService::GetInstance()); + case MSM_FILERT: + case MSM_FILE: + out_->SetFileRenderer("project:mixdown.wav"); + break; + case MSM_FILESPLITRT: + case MSM_FILESPLIT: + for (int i=0;iAddObserver(*MidiService::GetInstance()); } - sync_=SDL_CreateMutex() ; - NAssert(sync_) ; + sync_=SDL_CreateMutex(); + NAssert(sync_); - if (result) - { - Trace::Debug("Out initialized") ; - } else { - Trace::Debug("Failed to get output") ; - } - return (result) ; -} ; + if (result) { + Trace::Log("MixerService", "output initialized"); + } else { + Trace::Log("MixerService", "failed to initialize output"); + } + return (result); +}; void MixerService::Close() { if (out_) { diff --git a/sources/Application/Mixer/MixerService.h b/sources/Application/Mixer/MixerService.h index 2fddaf77..4e819404 100644 --- a/sources/Application/Mixer/MixerService.h +++ b/sources/Application/Mixer/MixerService.h @@ -1,13 +1,17 @@ #ifndef _MIXER_SERVICE_H_ #define _MIXER_SERVICE_H_ -#include "Foundation/T_Singleton.h" +#ifdef SDL2 +#include +#else +#include +#endif +#include "Application/Commands/CommandDispatcher.h" // Would be better done externally and call an API here #include "Foundation/Observable.h" +#include "Foundation/T_Singleton.h" #include "Services/Audio/AudioMixer.h" #include "Services/Audio/AudioOut.h" -#include "Application/Commands/CommandDispatcher.h" // Would be better done externally and call an API here #include "MixBus.h" -#include "SDL/SDL.h" enum MixerServiceMode { MSM_AUDIO, diff --git a/sources/Application/Views/BaseClasses/UIActionField.cpp b/sources/Application/Views/BaseClasses/UIActionField.cpp index ea1fbee9..7bf3d732 100644 --- a/sources/Application/Views/BaseClasses/UIActionField.cpp +++ b/sources/Application/Views/BaseClasses/UIActionField.cpp @@ -31,7 +31,11 @@ void UIActionField::Draw(GUIWindow &w, int offset) { void UIActionField::OnClick() { SetChanged() ; +#ifdef _64BIT + NotifyObservers((I_ObservableData *) &fourcc_); +#else NotifyObservers((I_ObservableData *)fourcc_) ; +#endif } ; const char *UIActionField::GetString() { diff --git a/sources/Application/Views/BaseClasses/UITempoField.cpp b/sources/Application/Views/BaseClasses/UITempoField.cpp index ead33b3a..8ce009e3 100644 --- a/sources/Application/Views/BaseClasses/UITempoField.cpp +++ b/sources/Application/Views/BaseClasses/UITempoField.cpp @@ -24,7 +24,11 @@ void UITempoField::OnBClick() { void UITempoField::Update(Observable &,I_ObservableData *data) { SetChanged() ; +#ifdef _64BIT + NotifyObservers((I_ObservableData *) &action_); +#else NotifyObservers((I_ObservableData *)action_) ; +#endif } void UITempoField::ProcessArrow(unsigned short mask) { diff --git a/sources/Application/Views/ProjectView.cpp b/sources/Application/Views/ProjectView.cpp index de45660c..b4d656dd 100644 --- a/sources/Application/Views/ProjectView.cpp +++ b/sources/Application/Views/ProjectView.cpp @@ -202,7 +202,11 @@ void ProjectView::Update(Observable &,I_ObservableData *data) { return ; } +# ifdef _64BIT + int fourcc=*((int*)data); +#else int fourcc=(unsigned int)data ; +#endif UIField *focus=GetFocus() ; if (fourcc!=ACTION_TEMPO_CHANGED) { diff --git a/sources/Application/Views/SongView.h b/sources/Application/Views/SongView.h index 2724294a..1791c7a1 100644 --- a/sources/Application/Views/SongView.h +++ b/sources/Application/Views/SongView.h @@ -3,7 +3,11 @@ #define _SONG_VIEW_H_ #include "BaseClasses/View.h" +#ifdef SDL2 +#include +#else #include +#endif class SongView ; diff --git a/sources/Services/Controllers/KeyboardControllerSource.h b/sources/Services/Controllers/KeyboardControllerSource.h index 9824a3bc..e22e2b71 100644 --- a/sources/Services/Controllers/KeyboardControllerSource.h +++ b/sources/Services/Controllers/KeyboardControllerSource.h @@ -3,7 +3,12 @@ #include "ControllerSource.h" +#ifdef SDL2 +// SDL_NUM_SCANCODES is currently 512 +#define MAX_KEY 512 +#else #define MAX_KEY 400 +#endif class KeyboardControllerSource: public ControllerSource { public: diff --git a/sources/Services/Midi/MidiService.cpp b/sources/Services/Midi/MidiService.cpp index d305343b..d456804a 100644 --- a/sources/Services/Midi/MidiService.cpp +++ b/sources/Services/Midi/MidiService.cpp @@ -4,6 +4,7 @@ #include "System/Timer/Timer.h" #include "Application/Model/Config.h" #include "Services/Audio/AudioDriver.h" +#include "System/Console/Trace.h" #ifdef SendMessage #undef SendMessage @@ -16,156 +17,147 @@ MidiService::MidiService(): sendSync_(true) { for (int i=0;i(true) ; - } - - const char *delay = Config::GetInstance()->GetValue("MIDIDELAY") ; - midiDelay_ = delay?atoi(delay):1 ; - - const char *sendSync = Config::GetInstance()->GetValue("MIDISENDSYNC") ; - if (sendSync) - { - sendSync_ = (strcmp(sendSync,"YES")==0) ; + queues_[i]=new T_SimpleList(true); } -} ; + const char *delay = Config::GetInstance()->GetValue("MIDIDELAY"); + midiDelay_ = delay?atoi(delay):1; + + const char *sendSync = Config::GetInstance()->GetValue("MIDISENDSYNC"); + if (sendSync) { + sendSync_ = (strcmp(sendSync,"YES")==0); + } +}; MidiService::~MidiService() { - Close() ; -} ; + Close(); +}; bool MidiService::Init() { - Empty() ; + Empty(); inList_.Empty(); - buildDriverList() ; + buildDriverList(); // Add a merger for the input - merger_=new MidiInMerger() ; - IteratorPtrit(inList_.GetIterator()) ; - for (it->Begin();!it->IsDone();it->Next()) { - MidiInDevice ¤t=it->CurrentItem() ; - merger_->Insert(current) ; + merger_=new MidiInMerger(); + IteratorPtrit(inList_.GetIterator()); + for (it->Begin();!it->IsDone();it->Next()) { + MidiInDevice ¤t=it->CurrentItem(); + merger_->Insert(current); } - return true ; -} ; + return true; +}; void MidiService::Close() { - Stop() ; -} ; + Stop(); +}; I_Iterator *MidiService::GetInIterator() { - return inList_.GetIterator() ; -} ; + return inList_.GetIterator(); +}; void MidiService::SelectDevice(const std::string &name) { - deviceName_=name ; -} ; + deviceName_ = name; +}; bool MidiService::Start() { - currentPlayQueue_=0 ; - currentOutQueue_=0 ; - return true ; + currentPlayQueue_ = 0; + currentOutQueue_ = 0; + return true; } ; void MidiService::Stop() { - stopDevice() ; + stopDevice(); } ; void MidiService::QueueMessage(MidiMessage &m) { - if (device_) - { - T_SimpleList *queue=queues_[currentPlayQueue_] ; - MidiMessage *ms=new MidiMessage(m.status_,m.data1_,m.data2_) ; - queue->Insert(ms) ; - } -} ; + if (device_) { + T_SimpleList *queue=queues_[currentPlayQueue_]; + MidiMessage *ms=new MidiMessage(m.status_,m.data1_,m.data2_); + queue->Insert(ms); + } +}; + +void MidiService::Trigger() { + AdvancePlayQueue(); -void MidiService::Trigger() -{ - AdvancePlayQueue(); - if (device_&&sendSync_) { - SyncMaster *sm=SyncMaster::GetInstance() ; + SyncMaster *sm=SyncMaster::GetInstance(); if (sm->MidiSlice()) { MidiMessage msg; msg.status_ = 0xF8; QueueMessage(msg); } - } } -void MidiService::AdvancePlayQueue() -{ - currentPlayQueue_=(currentPlayQueue_+1)%MIDI_MAX_BUFFERS ; - T_SimpleList *queue=queues_[currentPlayQueue_] ; - queue->Empty() ; +void MidiService::AdvancePlayQueue() { + currentPlayQueue_=(currentPlayQueue_+1)%MIDI_MAX_BUFFERS; + T_SimpleList *queue=queues_[currentPlayQueue_]; + queue->Empty(); } -void MidiService::Update(Observable &o,I_ObservableData *d) -{ +void MidiService::Update(Observable &o,I_ObservableData *d) { AudioDriver::Event *event=(AudioDriver::Event *)d; - if (event->type_ == AudioDriver::Event::ADET_DRIVERTICK) - { + if (event->type_ == AudioDriver::Event::ADET_DRIVERTICK) { onAudioTick(); } -} +}; -void MidiService::onAudioTick() -{ - if (tickToFlush_>0) - { - if (--tickToFlush_ ==0) - { - flushOutQueue(); - } - } +void MidiService::onAudioTick() { + if (tickToFlush_>0) { + if (--tickToFlush_ ==0) { + flushOutQueue(); + } + } } void MidiService::Flush() { + tickToFlush_ = midiDelay_; + if (tickToFlush_ == 0) { + flushOutQueue(); + } +}; - tickToFlush_ = midiDelay_ ; - if (tickToFlush_ == 0) - { - flushOutQueue(); - } -} ; - -void MidiService::flushOutQueue() -{ +void MidiService::flushOutQueue() { // Move queue positions - currentOutQueue_=(currentOutQueue_+1)%MIDI_MAX_BUFFERS ; - T_SimpleList *flushQueue=queues_[currentOutQueue_] ; + currentOutQueue_ = (currentOutQueue_+1) % MIDI_MAX_BUFFERS; + T_SimpleList *flushQueue=queues_[currentOutQueue_]; if (device_) { // Send whatever is on the out queue - device_->SendQueue(*flushQueue) ; + device_->SendQueue(*flushQueue); } - flushQueue->Empty() ; + flushQueue->Empty(); } +/* + * starts midi device + */ void MidiService::startDevice() { - - // look for the device - IteratorPtrit(GetIterator()) ; - for (it->Begin();!it->IsDone();it->Next()) { - MidiOutDevice ¤t=it->CurrentItem() ; - if (!strcmp(deviceName_.c_str(),current.GetName())) { + + for (it->Begin(); !it->IsDone(); it->Next()) { + MidiOutDevice ¤t = it->CurrentItem(); + if (!strcmp(deviceName_.c_str(), current.GetName())) { if (current.Init()) { if (current.Start()) { - device_=¤t ; + Trace::Log("MidiService", "midi device %s started", deviceName_.c_str()); + device_ = ¤t; } else { - current.Close() ; + Trace::Log("MidiService", "midi device %s failed to start", deviceName_.c_str()); + current.Close(); } } - break ; + break; } } +}; -} ; - +/* + * closes midi device + */ void MidiService::stopDevice() { if (device_) { device_->Stop() ; @@ -174,29 +166,32 @@ void MidiService::stopDevice() { device_=0 ; } ; +/* + * starts midi device when playback starts + */ void MidiService::OnPlayerStart() { - if (deviceName_.size()!=0) { - stopDevice() ; - startDevice() ; - deviceName_="" ; - } + stopDevice(); + startDevice(); + deviceName_=""; + } else { + startDevice(); + } - if (sendSync_) - { + if (sendSync_) { MidiMessage msg ; msg.status_=0xFA ; QueueMessage(msg) ; - } }; +/* + * queues midi stop message when player stops + */ void MidiService::OnPlayerStop() { - - if (sendSync_) - { + if (sendSync_) { MidiMessage msg ; msg.status_=0xFC ; QueueMessage(msg) ; } -} ; +}; diff --git a/sources/Services/Time/TimeService.cpp b/sources/Services/Time/TimeService.cpp index 45a00dca..56b1f883 100644 --- a/sources/Services/Time/TimeService.cpp +++ b/sources/Services/Time/TimeService.cpp @@ -1,6 +1,10 @@ #include "TimeService.h" +#ifdef SDL2 +#include +#else +#include +#endif #include "System/System/System.h" -#include "SDL/SDL.h" /*Date::Date() { } ; @@ -43,4 +47,4 @@ Time TimeService::GetTime() { void TimeService::Sleep(int msecs) { SDL_Delay(msecs) ; -} ; \ No newline at end of file +} ; diff --git a/sources/System/Console/Trace.cpp b/sources/System/Console/Trace.cpp index 30d6971a..d18a7ba8 100644 --- a/sources/System/Console/Trace.cpp +++ b/sources/System/Console/Trace.cpp @@ -38,16 +38,19 @@ Trace::Logger *Trace::SetLogger(Trace::Logger& logger) //------------------------------------------------------------------------------ +#ifdef _64BIT +void Trace::VLog(const char* category, const char *fmt, va_list& args) +#else void Trace::VLog(const char* category, const char *fmt, const va_list& args) +#endif { char buffer[4096] ; sprintf(buffer, "[%s] ",category); char *ptr = buffer+strlen(buffer); - vsprintf(ptr,fmt,args ); + vsprintf(ptr, fmt, args); GetInstance()->AddLine(buffer) ; - } //------------------------------------------------------------------------------ diff --git a/sources/System/Console/Trace.h b/sources/System/Console/Trace.h index 761d527b..c62bb7e8 100644 --- a/sources/System/Console/Trace.h +++ b/sources/System/Console/Trace.h @@ -32,7 +32,11 @@ class Trace: public T_Singleton { Trace::Logger *SetLogger(Trace::Logger&); protected: +#ifdef _64BIT + static void VLog(const char* category, const char *fmt, va_list& args); +#else static void VLog(const char* category, const char *fmt, const va_list& args); +#endif private: Trace::Logger* logger_; } ; diff --git a/sources/System/Process/SysMutex.h b/sources/System/Process/SysMutex.h index f79cea3e..c5720fd7 100644 --- a/sources/System/Process/SysMutex.h +++ b/sources/System/Process/SysMutex.h @@ -7,7 +7,11 @@ * */ +#ifdef SDL2 +#include +#else #include +#endif class SysMutex { public: @@ -25,4 +29,4 @@ class SysMutexLocker { ~SysMutexLocker() ; private: SysMutex *mutex_ ; -} ; \ No newline at end of file +} ;