Skip to content

Added some basic doc #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/BattleManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace SokuLib
{
//! @brief Represents the state of the battle between characters, but
//! not the state of the battle scene itself.
struct BattleManager {
struct BattleManager_VTABLE *vtable;
// 0x004
Expand Down
2 changes: 2 additions & 0 deletions src/BattleMode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace SokuLib
{
//! @brief Mode of the battle the player is currently in.
enum BattleMode : unsigned char {
BATTLE_MODE_STORY,
BATTLE_MODE_ARCADE,
Expand All @@ -25,6 +26,7 @@ namespace SokuLib
BATTLE_MODE_PRACTICE
};

//! @brief The submode represents the playing state.
enum BattleSubMode : unsigned char {
BATTLE_SUBMODE_PLAYING1,
BATTLE_SUBMODE_PLAYING2,
Expand Down
1 change: 1 addition & 0 deletions src/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace SokuLib
{
//! @brief The camera object used during battle.
struct Camera {
char offset_0x00[0x4];
// 0x04
Expand Down
3 changes: 3 additions & 0 deletions src/Character.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace SokuLib
{
//! @brief All playable characters.
enum Character : unsigned int {
/* 0 */ CHARACTER_REIMU,
/* 1 */ CHARACTER_MARISA,
Expand Down Expand Up @@ -57,6 +58,7 @@ namespace SokuLib
/* 34 */ CHARACTER_RAN
};

//! @brief Contains all the player information required to load by the loading thread after the character select.
struct PlayerInfo {
Character character;
unsigned char isRight;
Expand All @@ -67,6 +69,7 @@ namespace SokuLib
KeyManager *keyManager;
};

//! @brief Contains all the information required to load by the loading thread after the character select.
struct GameStartParams {
char offset_0x00[4];
unsigned char stageId;
Expand Down
8 changes: 8 additions & 0 deletions src/CharacterManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ namespace SokuLib
};

struct CharacterManager;

//! @brief An Object is any entity that exists within a battle: characters, bullets, visual effects, etc.
//! It also corresponds to v2::AnimationObject in SokuLib.
struct ObjectManager {
// 0x000
void *vtable;
Expand Down Expand Up @@ -189,12 +192,16 @@ namespace SokuLib
void doAnimation();
};

//! @brief Linked list of entities, here, specifically tied to a character subobject. An entity may hold such a
//! list for projectiles and visual effects. They are templated CObjectList<character, characterObject>
//! (i.e CObjectList<Remilia, RemiliaObject>)
struct ObjListManager {
char offset_0x00[0x58];
// ADDR_OBJPROJOFS = 0x58
LinkedList<ObjectManager> list;
};

//! @brief Object for projectiles.
struct ProjectileManager {
// 0x000
ObjectManager objectBase;
Expand All @@ -213,6 +220,7 @@ namespace SokuLib
};

//CHARACTERMGR
//! @brief Object for characters.
struct CharacterManager {
// 0x000
ObjectManager objectBase;
Expand Down
7 changes: 7 additions & 0 deletions src/FrameData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace SokuLib
{
//! @brief Represents all attack properties bound to a hitbox.
union AttackFlags {
struct {
/* 00 00 00 01 */ bool unk1: 1;
Expand Down Expand Up @@ -42,6 +43,7 @@ namespace SokuLib
unsigned int value;
};

//! @brief Represents all properties bound to a character.
union FrameFlags {
struct {
/* 00 00 00 01 */ bool stand: 1;
Expand Down Expand Up @@ -74,6 +76,7 @@ namespace SokuLib
};

#pragma pack(push, 1)
//! @brief Holds all the information tied to an Action.
struct FrameData {
// 0x00
void *VTable;
Expand Down Expand Up @@ -130,6 +133,7 @@ namespace SokuLib
};
#pragma pack(pop)

//! @brief Reads the data contained by a Framedata.
struct FrameDataReader {
// 0x00
void *VTable;
Expand Down Expand Up @@ -166,6 +170,7 @@ namespace SokuLib
float rotateX, rotateY, rotateZ;
};

//! @brief Holds all the rendering information tied to an Action.
class FrameData {
public:
enum RenderGroup : unsigned char { SPRITE = 0, TEXTURE = 1, WITHBLEND = 2 };
Expand All @@ -183,6 +188,7 @@ namespace SokuLib
virtual ~FrameData();
}; // 0x1C

//! @brief Holds the framedata held by a character.
class CharacterFrameData : public FrameData {
public:
// 0x1C
Expand Down Expand Up @@ -225,6 +231,7 @@ namespace SokuLib
virtual ~SequenceData() = default;
};

//! @brief Represents the sequence that the character is in when performing an Action.
class CharacterSequenceData {
public:
Vector<CharacterFrameData> frames;
Expand Down
4 changes: 4 additions & 0 deletions src/GameData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
#include "Player.hpp"

namespace SokuLib {

// The v2 namespace is a namespace created to prevent any breaking change for previously made mods.
namespace v2 {
//! @brief Manages all the dynamically allocated player data, events and threads.
struct GameDataManager {
// 0x00
List<std::pair<int, PlayerInfo*>> createQueue;
Expand All @@ -34,6 +37,7 @@ namespace v2 {
static GameDataManager*& instance;
}; // 0x58

//! @brief Manages all the data that is to be saved, so they can be retrieved when restarting the game.
struct SaveDataManager {
// 0x00
int unknown00;
Expand Down
7 changes: 6 additions & 1 deletion src/InputManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace SokuLib
{
//! @brief Contains the time for which all buttons were pressed. 0 means "not pressed".
//! horizontalAxis and verticalAxis can be negative to represent the opposite direction.
struct KeyInput {
int horizontalAxis;
int verticalAxis;
Expand All @@ -18,7 +20,8 @@ namespace SokuLib
int changeCard;
int spellcard;
};


//! @brief Represents which buttons were pressed keys used during character select.
struct CharacterSelectKeys {
bool up: 1;
bool down: 1;
Expand All @@ -33,6 +36,7 @@ namespace SokuLib
unsigned char padding: 6;
};

//! @brief Represents which buttons were pressed keys used during battle.
struct BattleKeys {
bool up: 1;
bool down: 1;
Expand All @@ -51,6 +55,7 @@ namespace SokuLib

//KEYMAPMGR
//CInputManagerCluster
//! @brief Manages the bindings between the hardware input and the game input.
struct KeymapManager {
void *unknown;
// isPlayer is -1 when using keyboard, 0 when using first gamepad, 1 when using second gamepad.
Expand Down
2 changes: 1 addition & 1 deletion src/KeyCombination.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef SWRSTOYS_KEYCOMBINATION_HPP
#define SWRSTOYS_KEYCOMBINATION_HPP


//! @brief Key combinations for all motion inputs.
struct KeyCombination {
/* 0x1 */ bool _236a : 1;
/* 0x2 */ bool _236b : 1;
Expand Down
1 change: 1 addition & 0 deletions src/Menus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace SokuLib
{
//! @brief All menus in the game.
enum Menu {
MENU_NONE,
MENU_CONNECT,
Expand Down
1 change: 1 addition & 0 deletions src/NetObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace SokuLib
std::vector<struct ClientInfo> g_psvClients;
};

//! @brief The NetObject handles all the packets and network-related operations.
struct NetObject {
char unknown[4];
char profile1name[32];
Expand Down
3 changes: 3 additions & 0 deletions src/Packet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

namespace SokuLib
{
// For a general understanding of Soku's network protocol, read this:
// https://github.com/delthas/touhou-protocol-docs/blob/master/protocol_123.md

extern uint8_t Soku110acRollSWRAllChars[16];
extern uint8_t Soku110acNoRollSWRAllChars[16];
extern uint8_t Soku110acNoSWRAllChars[16];
Expand Down
1 change: 1 addition & 0 deletions src/Player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace SokuLib {
namespace v2 {
//! @brief Holds all the information tied to a player during battle.
class Player : public GameObjectBase {
public:
// offset 0x34C
Expand Down
2 changes: 2 additions & 0 deletions src/Scenes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace SokuLib
{
#pragma pack(push, 1)
//! @brief All the game scenes.
enum Scene {
SCENE_LOGO,
SCENE_OPENING,
Expand Down Expand Up @@ -142,6 +143,7 @@ namespace SokuLib
int paletteUnused;
};

//! @brief The cursor used to navigate in the menus.
struct SelectCursor {
int alwaysZero;
int alwaysTwenty;
Expand Down
2 changes: 2 additions & 0 deletions src/SoundData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace SokuLib
{
//! @brief Data used to play the BGM.
class BgmData {
public:
IFileReader* reader;
Expand Down Expand Up @@ -54,6 +55,7 @@ namespace SokuLib
int bufferSize;
};

//! @brief Represents the current state of the BGM.
class BgmBuffer {
public:
String filename;
Expand Down
3 changes: 3 additions & 0 deletions src/Sprite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace SokuLib
float v;
};

//! @brief Data of the bitmap image that is loaded into the game.
class BitmapData {
public:
unsigned char bitsPerPixel = 0;
Expand Down Expand Up @@ -59,6 +60,7 @@ namespace SokuLib
virtual ~SpriteBase() = default;
};

//! @brief The sprite of any drawn object on screen.
class Sprite : public SpriteBase {
public:
Vector2f pos;
Expand Down Expand Up @@ -118,6 +120,7 @@ namespace SokuLib
void renderGray(int texId, float x, float y, float w, float h);
};

//! @brief The palette data currently used for rendering a character.
class Palette {
public:
unsigned char bitsPerPixel;
Expand Down
3 changes: 2 additions & 1 deletion src/Stage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace SokuLib
{
extern std::vector<std::string> stagesName;

//! @brief All the selectable stages.
enum Stage : unsigned char {
STAGE_HAKUREI_SHRINE_BROKEN,
STAGE_FOREST_OF_MAGIC,
Expand Down Expand Up @@ -42,7 +43,7 @@ namespace SokuLib
};

//! @brief Takes the raw stage id and restrict it in the range [0-19]
//! @param The stage id to convert
//! @param id The stage id to convert
//! @return The stage index between 0 and 19 (bounds included)
unsigned char flattenStageId(Stage id);

Expand Down
1 change: 1 addition & 0 deletions src/VTables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace SokuLib
int (T::*onRender)();
};

//! @brief vtable for each phase of a battle.
struct BattleManager_VTABLE {
BattleManager *(BattleManager::*destructor)(char unknown);
void (BattleManager::*onArenaStart)(void *param);
Expand Down
6 changes: 4 additions & 2 deletions src/Weather.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace SokuLib
{
//! @brief All weathers that can occur in a battle.
//! Note: Twilight normally only occurs in story mode.
enum Weather {
/* 0 (0x00) */ WEATHER_SUNNY,
/* 1 (0x01) */ WEATHER_DRIZZLE,
Expand All @@ -33,8 +35,8 @@ namespace SokuLib
/* 21 (0x15) */ WEATHER_CLEAR,
};

extern Weather &activeWeather;
extern Weather &displayedWeather;
extern Weather &activeWeather; // Note: Aurora is not an active weather.
extern Weather &displayedWeather; // Note: Aurora is a displayed weather.
extern unsigned short &weatherCounter;
extern void (__stdcall * const activateWeather)(int weather, char unknown);
}
Expand Down