Skip to content

Commit

Permalink
Adds C bridges to LUS C++ code to their own files. Additionally organ…
Browse files Browse the repository at this point in the history
…izes headers for more organic includes. (#29)

* Removes unused extern definition for __osMaxControllers in SDLController.cpp

* Moves libultraship functions to their own files.

* Headers are now moved to include and adds bridge functions for basic LUS functionality.

* Updates PulseAudioPlayer to have our naming convenstions and runs clang-format.

* Updates clang-tidy headers.

* Moves GameOverlay to menu directory.

* Fixing naming conventions in PulseAudioPlayer.

* Fixes clang-tidy errors in ResourceMgr.

* Fixes include of GameOverlay.h

* GameOverlay screen dimensions are now protected access.

* Fixes gbi.h includes.

* AudioPlayer.doInit -> AudioPlayer.DoInit

* Excluding os.h from clang-tidy

* Include stddef.h in libultraship.h for size_t

* Includes studded.h in AudioPlayer.h for size_t

* Includes stddef.h in audioplayerbridge.h for size_t

* Removes unnecessary includes in LUS.h

* Libultra types now includes stddef which brings a long size_t for all platforms.
  • Loading branch information
Kenix3 authored Nov 17, 2022
1 parent 751f719 commit 8525451
Show file tree
Hide file tree
Showing 75 changed files with 817 additions and 1,018 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CheckOptions:
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: g }
- { key: readability-identifier-naming.MethodCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.LocalVariableCase, value: camelBack }
- { key: readability-identifier-naming.ParameterCase, value: camelBack }
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tidy-format-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
mkdir clang-tidy-result
- name: Analyze
run: |
git diff -U0 HEAD^ -- 'src' 'include' ':!include/abi.h' ':!include/color.h' ':!include/UltraController.h' ':!src/graphic/Fast3D/*' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml
git diff -U0 HEAD^ -- 'src' 'include' ':!include/color.h' ':!include/libultra/*' ':!src/core/libultra/*' ':!src/graphic/Fast3D/*' | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml
- name: Save PR metadata
run: |
echo ${{ github.event.number }} > clang-tidy-result/pr-id.txt
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ cmake --build build
## To build on Windows
```
& 'C:\Program Files\CMake\bin\cmake' --build .\build\x64
```
```

## Running clang-format
```
find src include -name "*.cpp" -o -name "*.h" | sed 's| |\\ |g' | xargs clang-format-12 -i
```
9 changes: 9 additions & 0 deletions include/bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _BRIDGE_H_
#define _BRIDGE_H_

#include "core/bridge/resourcebridge.h"
#include "core/bridge/audioplayerbridge.h"
#include "core/bridge/controldeckbridge.h"
#include "core/bridge/windowbridge.h"

#endif
30 changes: 30 additions & 0 deletions include/libultra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef _ULTRA64_H_
#define _ULTRA64_H_

#include "libultra/abi.h"
#include "libultra/controller.h"
#include "libultra/convert.h"
#include "libultra/exception.h"
#include "libultra/gbi.h"
#include "libultra/gs2dex.h"
#include "libultra/gu.h"
#include "libultra/hardware.h"
#include "libultra/internal.h"
#include "libultra/interrupt.h"
#include "libultra/mbi.h"
#include "libultra/message.h"
#include "libultra/motor.h"
#include "libultra/pfs.h"
#include "libultra/pi.h"
#include "libultra/printf.h"
#include "libultra/r4300.h"
#include "libultra/rcp.h"
#include "libultra/rdp.h"
#include "libultra/rsp.h"
#include "libultra/sptask.h"
#include "libultra/thread.h"
#include "libultra/time.h"
#include "libultra/types.h"
#include "libultra/vi.h"

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define ULTRA64_TYPES_H

#include <stdint.h>
#include <stddef.h>

typedef signed char s8;
typedef unsigned char u8;
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions include/libultraship.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _LIBULTRASHIP_H_
#define _LIBULTRASHIP_H_

#include "libultra.h"
#include "bridge.h"
#include "color.h"
#include "misc/Cvar.h"

#endif
34 changes: 27 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ endif()

set(Source_Files__Audio
${CMAKE_CURRENT_SOURCE_DIR}/audio/AudioPlayer.h
${CMAKE_CURRENT_SOURCE_DIR}/audio/AudioPlayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/audio/mixer.h
${CMAKE_CURRENT_SOURCE_DIR}/audio/mixer.c
${CMAKE_CURRENT_SOURCE_DIR}/audio/SDLAudioPlayer.h
${CMAKE_CURRENT_SOURCE_DIR}/audio/SDLAudioPlayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/audio/PulseAudioPlayer.h
${CMAKE_CURRENT_SOURCE_DIR}/audio/PulseAudioPlayer.cpp
)

if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand Down Expand Up @@ -89,7 +92,28 @@ set(Source_Files__Core
)

source_group("Core" FILES ${Source_Files__Core})
target_sources(libultraship PRIVATE ${Source_Files__Core})

set(Source_Files__Core__Libultra
${CMAKE_CURRENT_SOURCE_DIR}/core/libultra/os.h
${CMAKE_CURRENT_SOURCE_DIR}/core/libultra/os.cpp
)

source_group("Core\\libultra" FILES ${Source_Files__Core__Libultra})

set(Source_Files__Core__Bridge
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/resourcebridge.h
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/resourcebridge.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/windowbridge.h
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/windowbridge.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/audioplayerbridge.h
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/audioplayerbridge.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/controldeckbridge.h
${CMAKE_CURRENT_SOURCE_DIR}/core/bridge/controldeckbridge.cpp
)

source_group("Core\\Bridge" FILES ${Source_Files__Core__Bridge})

target_sources(libultraship PRIVATE ${Source_Files__Core} ${Source_Files__Core__Libultra} ${Source_Files__Core__Bridge})

#=================== Debug ===================

Expand Down Expand Up @@ -127,6 +151,8 @@ set(Source_Files__Menu
${CMAKE_CURRENT_SOURCE_DIR}/menu/ImGuiImpl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/menu/InputEditor.h
${CMAKE_CURRENT_SOURCE_DIR}/menu/InputEditor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/menu/GameOverlay.cpp
${CMAKE_CURRENT_SOURCE_DIR}/menu/GameOverlay.h
)

source_group("Menu" FILES ${Source_Files__Menu})
Expand Down Expand Up @@ -207,8 +233,6 @@ set(Source_Files__Resource__Factory
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/CutsceneFactory.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/DisplayListFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/DisplayListFactory.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/MaterialFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/MaterialFactory.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/MtxFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/MtxFactory.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/factory/SoH/PathFactory.cpp
Expand Down Expand Up @@ -247,10 +271,6 @@ set(Source_Files__Resource__Types
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/Cutscene.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/DisplayList.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/DisplayList.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/GameOverlay.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/GameOverlay.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/Material.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/Material.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/Matrix.cpp
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/Matrix.h
${CMAKE_CURRENT_SOURCE_DIR}/resource/types/Model.cpp
Expand Down
15 changes: 15 additions & 0 deletions src/audio/AudioPlayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "AudioPlayer.h"

namespace Ship {
AudioPlayer::AudioPlayer() : mInitialized(false){};

bool AudioPlayer::Init(void) {
mInitialized = DoInit();
return IsInitialized();
}

bool AudioPlayer::IsInitialized(void) {
return mInitialized;
}

} // namespace Ship
16 changes: 13 additions & 3 deletions src/audio/AudioPlayer.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
#pragma once
#include "stdint.h"
#include "stddef.h"

namespace Ship {
class AudioPlayer {

public:
AudioPlayer(){};
AudioPlayer();

virtual bool Init(void) = 0;
bool Init(void);
virtual int Buffered(void) = 0;
virtual int GetDesiredBuffered(void) = 0;
virtual void Play(const uint8_t* buf, uint32_t len) = 0;
virtual void Play(const uint8_t* buf, size_t len) = 0;

bool IsInitialized(void);

constexpr int GetSampleRate() const {
return 44100;
}

protected:
virtual bool DoInit(void) = 0;

private:
bool mInitialized;
};
} // namespace Ship

Expand Down
Loading

0 comments on commit 8525451

Please sign in to comment.