mirror of
https://github.com/InsightGit/Morpheus.git
synced 2025-06-18 16:55:41 -04:00
Finished 1.0 documentation
This commit is contained in:
parent
8cc96309e8
commit
0680e79643
@ -10,6 +10,10 @@ PROJECT_NAME = "morpheus"
|
||||
|
||||
def generate_rst_file_for_object(breathe_command: str, object_name: str, namespace_name: str, namespace_dir: str,
|
||||
file_path: str):
|
||||
if object_name == "NdsMosaicController" or object_name == "NdsBlendingController" or \
|
||||
object_name == "GbaMosaicController" or object_name == "GbaBlendingController":
|
||||
namespace_name += "::gfx"
|
||||
|
||||
with open(os.path.join(namespace_dir, f"{object_name}.rst"), 'w') as header_rst_file:
|
||||
header_rst_file.write(f"{object_name}\n")
|
||||
|
||||
@ -100,9 +104,32 @@ def identify_cpp_file_content(file_name: str) -> dict:
|
||||
return return_value
|
||||
|
||||
|
||||
def generate_utils_rst_file(header_path: str, breathe_path: str, utils_object_name: str = "utils"):
|
||||
breathe_utils_path = os.path.join(breathe_path, "classes", "morpheus", "utils")
|
||||
|
||||
os.makedirs(breathe_utils_path, exist_ok=True)
|
||||
|
||||
with open(os.path.join(breathe_utils_path, f"{utils_object_name}.rst"), 'w') as header_rst_file:
|
||||
file_path = os.path.join(header_path, f"{utils_object_name}.hpp")
|
||||
|
||||
header_rst_file.write(f"{utils_object_name}\n")
|
||||
|
||||
for i in range(len(utils_object_name)):
|
||||
header_rst_file.write("=")
|
||||
|
||||
header_rst_file.write(f"\n*Located within {file_path}*\n")
|
||||
|
||||
header_rst_file.write(f"\n.. doxygenfile:: {file_path}\n"
|
||||
f" :project: {PROJECT_NAME}\n")
|
||||
|
||||
generate_namespace_toctree(breathe_utils_path, "morpheus::utils")
|
||||
|
||||
|
||||
def generate_header_rst_files(header_path: str, breathe_path: str, root_namespace: str = "") -> list:
|
||||
print(f"header path: {header_path}")
|
||||
|
||||
generate_utils_rst_file(header_path, breathe_path)
|
||||
|
||||
for root, dirs, files in os.walk(header_path):
|
||||
for file in files:
|
||||
file_name, file_extension = os.path.splitext(file)
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef MORPHEUS_GBA_TEST_GBA_HPP
|
||||
#define MORPHEUS_GBA_TEST_GBA_HPP
|
||||
|
||||
/// Common GBA header file: Includes all needed headers for GBA Morpheus games
|
||||
|
||||
#include <morpheus/core/core.hpp>
|
||||
|
||||
#include <morpheus/gba/gba_main_loop.hpp>
|
||||
|
@ -17,17 +17,31 @@ namespace morpheus {
|
||||
namespace gfx {
|
||||
class GbaBlendingController : public morpheus::core::gfx::BlendingController {
|
||||
public:
|
||||
virtual ~GbaBlendingController() {}
|
||||
/// Destructs the GbaBlendingController object.
|
||||
~GbaBlendingController() override = default;
|
||||
protected:
|
||||
void update_blending_registers()override;
|
||||
};
|
||||
|
||||
/// \class morpheus::gba::gfx::GbaBlendingController
|
||||
/// The Game Boy Advance (GBA) implementation of
|
||||
/// morpheus::core::gfx::BlendingController. For more details about
|
||||
/// this class, consult the documentation of the aforementioned
|
||||
/// parent class.
|
||||
|
||||
class GbaMosaicController : public morpheus::core::gfx::MosaicController {
|
||||
public:
|
||||
virtual ~GbaMosaicController() {}
|
||||
/// Destructs the GbaMosaicController object.
|
||||
~GbaMosaicController() override = default;
|
||||
protected:
|
||||
void update_mosaic_register()override;
|
||||
};
|
||||
|
||||
/// \class morpheus::gba::gfx::GbaMosaicController
|
||||
/// The Game Boy Advance (GBA) implementation of
|
||||
/// morpheus::core::gfx::MosaicController. For more details about
|
||||
/// this class, consult the documentation of the aforementioned
|
||||
/// parent class.
|
||||
}
|
||||
|
||||
class GbaNoCashDebugController : public core::NoCashDebugController {
|
||||
@ -36,6 +50,12 @@ namespace morpheus {
|
||||
nocash_puts(message.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
/// \class morpheus::gba::GbaNocashDebugController
|
||||
/// Game Boy Advance (GBA) implementation of
|
||||
/// morpheus::core::NocashDebugController. For more details about
|
||||
/// this class, consult the documentation of the aforementioned parent
|
||||
/// class.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,23 +16,33 @@
|
||||
namespace morpheus {
|
||||
namespace gba {
|
||||
enum class FlashSaveSize {
|
||||
SIZE_AUTO_DETECT,
|
||||
SIZE_64_KB,
|
||||
SIZE_128_KB
|
||||
SIZE_AUTO_DETECT, ///< Auto detection of the size of the current
|
||||
///< flash chip
|
||||
SIZE_64_KB, ///< 64 kilobyte flash chips
|
||||
SIZE_128_KB ///< 128 kilobyte flash chips
|
||||
};
|
||||
|
||||
/// \enum morpheus::gba::FlashSaveSize
|
||||
/// An enum class representing the possible sizes of non-volatile flash
|
||||
/// memory on the GBA.
|
||||
|
||||
class GbaFlashSaveManager : public core::SaveManager {
|
||||
public:
|
||||
/// Constructs a GbaFlashSaveManager object with a given
|
||||
/// FlashSaveSize.
|
||||
/// \param flash_save_size The size of the non-volatile flash chip
|
||||
/// that this game will use.
|
||||
GbaFlashSaveManager(FlashSaveSize flash_save_size);
|
||||
|
||||
/// Destructs the GbaFlashSaveManager object.
|
||||
virtual ~GbaFlashSaveManager() = default;
|
||||
|
||||
bool is_successfully_mounted() const {
|
||||
bool is_successfully_mounted() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int load(unsigned char *data, unsigned int len);
|
||||
unsigned int save(const unsigned char *data, unsigned int len);
|
||||
unsigned int load(unsigned char *data, unsigned int len)override;
|
||||
unsigned int save(const unsigned char *data, unsigned int len)override;
|
||||
private:
|
||||
unsigned char *FLASH_DEVICE_REGISTER_1 = reinterpret_cast<unsigned char *>(0x0E005555);
|
||||
unsigned char *FLASH_DEVICE_REGISTER_2 = reinterpret_cast<unsigned char *>(0x0E002AAA);
|
||||
@ -49,6 +59,11 @@ namespace morpheus {
|
||||
FlashSaveSize m_flash_save_size;
|
||||
unsigned char m_manufacturer_id;
|
||||
};
|
||||
|
||||
/// \class morpheus::gba::GbaFlashSaveManager
|
||||
/// Non-volatile GBA flash chip implementation of
|
||||
/// morpheus::core::SaveManager. Saves non-volatile save data to a
|
||||
/// GBA-specific 64 or 128 kilobyte non-volatile flash chip.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,21 @@ namespace morpheus {
|
||||
|
||||
class GbaMainLoop : public core::MainLoop {
|
||||
public:
|
||||
const static int OBJ_ATTR_SIZE = sizeof(OBJ_ATTR) / 8;
|
||||
const static int OBJ_ATTR_SIZE = sizeof(OBJ_ATTR) / 8; ///< Internally
|
||||
///< used libgba
|
||||
///< size of OAM
|
||||
///< OBJ
|
||||
///< (or sprite)
|
||||
///< attributes.
|
||||
|
||||
/// Constructs the (single) GbaMainLoop object, initializing the
|
||||
/// save type and (optionally) enabling libfat support.
|
||||
/// \param save_type The current save type this MainLoop
|
||||
/// (and this Morpheus game) will use.
|
||||
/// \param enable_fat Whether to enable libfat support or not
|
||||
explicit GbaMainLoop(core::GbaSaveType save_type, bool enable_fat = false);
|
||||
|
||||
/// Destructs the GbaMainLoop object.
|
||||
virtual ~GbaMainLoop();
|
||||
|
||||
void clear_obj_vram()override;
|
||||
@ -48,9 +59,9 @@ namespace morpheus {
|
||||
void enable_background(unsigned int background_num)override;
|
||||
void enable_window(core::gfx::WindowType window_type)override;
|
||||
|
||||
[[noreturn]] core::Error game_loop() override;
|
||||
[[noreturn]] core::Error game_loop()override;
|
||||
protected:
|
||||
core::Error platform_init() override;
|
||||
core::Error platform_init()override;
|
||||
|
||||
core::InputEvent to_input_event(uint32_t inputs, uint16_t keypad_bit,
|
||||
morpheus::core::InputState input_state)override;
|
||||
@ -80,6 +91,13 @@ namespace morpheus {
|
||||
bool m_using_tte = false;
|
||||
unsigned int m_windows_to_enable = 0x0;
|
||||
};
|
||||
|
||||
/// \class morpheus::gba::GbaMainLoop
|
||||
/// The GBA implementation of morpheus::core::MainLoop, representing
|
||||
/// a GBA Morpheus game's main loop. There should only be a single
|
||||
/// GbaMainLoop over the GBA game's lifecycle, otherwise undefined
|
||||
/// behavior will occur. For more information about this class,
|
||||
/// consult the aforementioned parent class.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,10 @@ namespace morpheus {
|
||||
namespace gba {
|
||||
class GbaSramSaveManager : public morpheus::core::SaveManager {
|
||||
public:
|
||||
/// Constructs a GbaSramSaveManager object.
|
||||
GbaSramSaveManager() = default;
|
||||
|
||||
/// Destructs the GbaSramSaveManager object.
|
||||
virtual ~GbaSramSaveManager() = default;
|
||||
|
||||
bool is_successfully_mounted() const override {
|
||||
@ -29,6 +31,11 @@ namespace morpheus {
|
||||
unsigned int load(unsigned char *data, unsigned int len)override;
|
||||
unsigned int save(const unsigned char *data, unsigned int len)override;
|
||||
};
|
||||
|
||||
/// \class morpheus::gba::GbaSramSaveManager
|
||||
/// GBA FRAM/SRAM implementation of morpheus::core::SaveManager.
|
||||
/// Saves non-volatile save data to non-volatile 32 kilobyte
|
||||
/// SRAM or FRAM.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,16 @@
|
||||
namespace morpheus {
|
||||
namespace gba {
|
||||
enum class BaudRate {
|
||||
BAUD_9600,
|
||||
BAUD_38400,
|
||||
BAUD_57600,
|
||||
BAUD_115200
|
||||
BAUD_9600, ///< 9600 bits/sec
|
||||
BAUD_38400, ///< 38400 bits/sec
|
||||
BAUD_57600, ///< 57600 bits/sec
|
||||
BAUD_115200 ///< 115200 bits/sec
|
||||
};
|
||||
|
||||
/// \enum morpheus::gba::BaudRate
|
||||
/// An enum class representing a certain baud rate over GBA's serial
|
||||
/// port (aka "link cable")
|
||||
|
||||
class MultiplayerSerialCommunication;
|
||||
|
||||
static MultiplayerSerialCommunication *active_multiplayer_serial_connection;
|
||||
@ -28,12 +32,19 @@ namespace morpheus {
|
||||
|
||||
class MultiplayerSerialCommunication : public morpheus::core::CommunicationChannel {
|
||||
public:
|
||||
/// Constructs a MultiplayerSerialCommunication object, with a
|
||||
/// given BaudRate.
|
||||
/// \param baud_rate The baud rate for this multiplayer-mode serial
|
||||
/// communication channel to use
|
||||
explicit MultiplayerSerialCommunication(BaudRate baud_rate = BaudRate::BAUD_9600);
|
||||
|
||||
virtual ~MultiplayerSerialCommunication() {
|
||||
/// Destructs the MultiplayerSerialCommunication object.
|
||||
~MultiplayerSerialCommunication() override {
|
||||
active_multiplayer_serial_connection = nullptr;
|
||||
}
|
||||
|
||||
/// \return The current baud rate of this GBA multiplayer-mode
|
||||
/// serial connection.
|
||||
BaudRate get_baud_rate() const {
|
||||
return m_baud_rate;
|
||||
}
|
||||
@ -86,6 +97,15 @@ namespace morpheus {
|
||||
|
||||
bool send_data_from_queue();
|
||||
};
|
||||
|
||||
|
||||
/// \class morpheus::gba::MultiplayerSerialCommunication
|
||||
/// The GBA multiplayer-mode serial (aka "link cable") implementation
|
||||
/// of morpheus::core::CommunicationChannel, allowing bi-directional
|
||||
/// communication between GBAs useful for multiplayer games or save data
|
||||
/// transferring. This class specifically implements multiplayer-mode
|
||||
/// serial communication, as detailed on GBATek
|
||||
/// [here](https://problemkaputt.de/gbatek.htm#siomultiplayermode).
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,17 +17,27 @@ namespace morpheus {
|
||||
namespace nds {
|
||||
class DsFlashcardSaveManager : public core::SaveManager {
|
||||
public:
|
||||
/// Constructs a DsFlashcardSaveManager object with a given base
|
||||
/// path for the save file, and whether the libfat filesystem has
|
||||
/// been successfully mounted by the NdsMainLoop.
|
||||
/// \param file_system_base_path The already existing base path
|
||||
/// within the libfat filesystem to store the save file in
|
||||
/// \param successfully_mounted Whether the NdsMainLoop was
|
||||
/// successful in mounting the libfat filesystem
|
||||
explicit DsFlashcardSaveManager(std::string file_system_base_path, bool successfully_mounted) {
|
||||
m_file_system_base_path = file_system_base_path;
|
||||
m_successfully_mounted = successfully_mounted;
|
||||
}
|
||||
|
||||
/// Destructs the DsFlashcardSaveManager object.
|
||||
virtual ~DsFlashcardSaveManager() = default;
|
||||
|
||||
bool is_successfully_mounted() const override {
|
||||
return m_successfully_mounted;
|
||||
}
|
||||
|
||||
/// \return The base path within the libfat filesystem to store
|
||||
/// the save file in.
|
||||
std::string get_file_system_base_path() const {
|
||||
return m_file_system_base_path;
|
||||
}
|
||||
@ -40,13 +50,31 @@ namespace morpheus {
|
||||
return save("morpheus.sav", data, len);
|
||||
}
|
||||
|
||||
/// Loads some data from the non-volatile libfat filesystem that this
|
||||
/// save manager is using under a certain file name.
|
||||
/// \param file_name The file name of the save file
|
||||
/// \param data The data buffer to load the save data into
|
||||
/// \param len The length of the save data buffer
|
||||
/// \return The amount of bytes loaded into the data buffer
|
||||
unsigned int load(std::string file_name, unsigned char *data, unsigned int len);
|
||||
|
||||
/// Saves some data to the non-volatile libfat filesystem that this
|
||||
/// save manager is using under a certain file name.
|
||||
/// \param file_name The file name of the save file
|
||||
/// \param data The save data buffer
|
||||
/// \param len The length of the save data buffer
|
||||
/// \return The amount of bytes saved into non-volatile memory
|
||||
unsigned int save(std::string file_name, const unsigned char *data, unsigned int len);
|
||||
private:
|
||||
std::string m_file_system_base_path;
|
||||
FILE *m_save_file_pointer;
|
||||
bool m_successfully_mounted = false;
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::DsFlashcardSaveManager
|
||||
/// DLDI libfat implementation of morpheus::core::SaveManager.
|
||||
/// Saves save files (by default called morpheus.sav) to the SD card of
|
||||
/// DLDI-supported flashcards.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,8 @@ namespace morpheus {
|
||||
return m_background_size;
|
||||
}
|
||||
|
||||
/// \return Whether this
|
||||
/// \return Whether this TiledBackground is displaying on the
|
||||
/// bottom sub display (true) or the top main display (false).
|
||||
bool is_using_sub_display() const {
|
||||
return m_use_sub_display;
|
||||
}
|
||||
@ -93,12 +94,14 @@ namespace morpheus {
|
||||
void affine_state_updated()override;
|
||||
void mosaic_state_updated()override;
|
||||
|
||||
///
|
||||
/// \param background_type
|
||||
/// Initializes the current libnds background reference number
|
||||
/// with a specific libnds-defined background type.
|
||||
/// \param background_type The background type to initialize
|
||||
/// the libnds background reference number with.
|
||||
void init_background_reference_num(BgType background_type);
|
||||
|
||||
///
|
||||
/// \param size
|
||||
/// Sets the background size of this TiledBackground.
|
||||
/// \param size The new background size to set
|
||||
void set_background_size(core::gfx::TiledBackgroundSize size);
|
||||
void update_scroll()override;
|
||||
private:
|
||||
@ -112,13 +115,18 @@ namespace morpheus {
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::gfx::TiledBackground
|
||||
/// The DS implementation of the
|
||||
/// The abstract DS implementation of the
|
||||
/// morpheus::core::gfx::TiledBackgroundBase class.
|
||||
/// Note that because this class is abstract,
|
||||
/// you shouldn't directly construct it and instead
|
||||
/// should directly construct either a TiledBackground4Bpp or
|
||||
/// TiledBackground8Bpp, both of which inherit and implement this
|
||||
/// class in a BPP specific way.
|
||||
/// Represents tiled backgrounds from 32x32 tiles
|
||||
/// (or 256 px x 256 px) in size to 64x64 tiles
|
||||
/// (or 512 px x 512 px), as well as backgrounds with
|
||||
/// 8bpp (256 color) tiles or 4bpp (16 color) tiles.
|
||||
/// For larger backgrounds, pass a new TiledBackground
|
||||
/// (or 512 px x 512 px).
|
||||
/// For larger backgrounds, pass a new TiledBackground4Bpp or
|
||||
/// TiledBackground8Bpp
|
||||
/// object into morpheus::core::gfx::StreamingBackgroundBase.
|
||||
/// For more details about this class, consult the documentation
|
||||
/// of the aforementioned parent class.
|
||||
@ -126,4 +134,4 @@ namespace morpheus {
|
||||
}
|
||||
}
|
||||
|
||||
#endif //MORPHEUS_GBA_TEST_TILED_BACKGROUND_BASE_HPP
|
||||
#endif //MORPHEUS_GBA_TEST_TILED_BACKGROUND_HPP
|
||||
|
@ -12,6 +12,23 @@ namespace morpheus {
|
||||
namespace gfx {
|
||||
class TiledBackground4Bpp : public TiledBackground {
|
||||
public:
|
||||
/// Constructs a TiledBackground4Bpp.
|
||||
/// \param affine Whether this TiledBackground4Bpp is affine or
|
||||
/// not (Affine backgrounds not fully supported)
|
||||
/// \param use_sub_display Whether to display this
|
||||
/// TiledBackground4Bpp on the bottom sub display (true) or the
|
||||
/// top main display (false).
|
||||
/// \param background_num The [0-3] background number of this
|
||||
/// TiledBackground4Bpp.
|
||||
/// \param blending_controller The optional
|
||||
/// NdsBlendingController for this TiledBackground4Bpp.
|
||||
/// \param mosaic_controller The optional
|
||||
/// NdsMosaicController for this TiledBackground4Bpp.
|
||||
/// \param main_loop A pointer to the current NdsMainLoop
|
||||
/// \param cbb_num The [0-3] tile offset to load this
|
||||
/// TiledBackground4Bpp object's tile graphics data onto.
|
||||
/// \param sbb_num The [0-31] tilemap offset to load this
|
||||
/// TiledBackground4Bpp object's tilemap onto.
|
||||
explicit TiledBackground4Bpp(bool affine, bool use_sub_display, unsigned int background_num,
|
||||
NdsBlendingController *blending_controller,
|
||||
NdsMosaicController *mosaic_controller,
|
||||
@ -26,8 +43,8 @@ namespace morpheus {
|
||||
}
|
||||
}
|
||||
|
||||
/// Destructs the TiledBackground4Bpp object.
|
||||
virtual ~TiledBackground4Bpp() = default;
|
||||
|
||||
protected:
|
||||
void array_load(const unsigned int *tiles, const unsigned int tiles_len,
|
||||
const unsigned short *palette, const unsigned int pal_len,
|
||||
@ -42,6 +59,20 @@ namespace morpheus {
|
||||
void array_load(const unsigned short *tile_map, const unsigned int tile_map_len,
|
||||
core::gfx::TiledBackgroundSize size)override;
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::gfx::TiledBackground4Bpp
|
||||
/// Nintendo DS implementation of
|
||||
/// morpheus::nds::gfx::TiledBackground and
|
||||
/// morpheus::core::gfx::TiledBackgroundBase. Represents tiled
|
||||
/// (or "text" mode) backgrounds of 4bpp (or with 16 colors) that
|
||||
/// can be displayed on the bottom sub display or the top main
|
||||
/// display of the DS.
|
||||
/// Doesn't require the extended palette to be enabled or disabled
|
||||
/// to properly display the background (but still only uses the
|
||||
/// first 256 colors, still dividing it into 16 palettes of 16
|
||||
/// colors). For more details about this class, consult the
|
||||
/// documentation of the aforementioned parent and grandparent
|
||||
/// class.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,23 @@ namespace morpheus {
|
||||
namespace gfx {
|
||||
class TiledBackground8Bpp : public TiledBackground {
|
||||
public:
|
||||
/// Constructs a TiledBackground8Bpp.
|
||||
/// \param affine Whether this TiledBackground4Bpp is affine or
|
||||
/// not (Affine backgrounds not fully supported)
|
||||
/// \param use_sub_display Whether to display this
|
||||
/// TiledBackground4Bpp on the bottom sub display (true) or the
|
||||
/// top main display (false).
|
||||
/// \param background_num The [0-3] background number of this
|
||||
/// TiledBackground4Bpp.
|
||||
/// \param blending_controller The optional
|
||||
/// NdsBlendingController for this TiledBackground4Bpp.
|
||||
/// \param mosaic_controller The optional
|
||||
/// NdsMosaicController for this TiledBackground4Bpp.
|
||||
/// \param main_loop A pointer to the current NdsMainLoop
|
||||
/// \param cbb_num The [0-3] tile offset to load this
|
||||
/// TiledBackground4Bpp object's tile graphics data onto.
|
||||
/// \param sbb_num The [0-31] tilemap offset to load this
|
||||
/// TiledBackground4Bpp object's tilemap onto.
|
||||
explicit TiledBackground8Bpp(bool affine, bool use_sub_display, unsigned int background_num,
|
||||
NdsBlendingController *blending_controller,
|
||||
NdsMosaicController *mosaic_controller,
|
||||
@ -26,9 +43,27 @@ namespace morpheus {
|
||||
}
|
||||
}
|
||||
|
||||
/// Destructs the TiledBackground8Bpp object.
|
||||
virtual ~TiledBackground8Bpp() = default;
|
||||
|
||||
// Extended Palette Mode loading functions
|
||||
/// Loads grit-generated tile graphics data into this
|
||||
/// TiledBackground with a color palette when extended palette
|
||||
/// mode is enabled. If single palette mode is enabled,
|
||||
/// extended palette mode will be enabled.
|
||||
/// \param tiles The buffer of the grit-generated graphical tile
|
||||
/// data to load
|
||||
/// \param tiles_len The length of the graphical tile data
|
||||
/// buffer to load in bytes
|
||||
/// \param palette The buffer of the color palette data
|
||||
/// to load
|
||||
/// \param pal_len The length of the palette data buffer to load
|
||||
/// in bytes
|
||||
/// \param palette_id The 256-color extended palette [0-16] id
|
||||
/// to load this palette into.
|
||||
/// \param tile_map The buffer of the tilemap to load
|
||||
/// \param tile_map_len The length of the tilemap buffer to load
|
||||
/// \param size The background size to set on this TiledBackground8Bpp.
|
||||
void load_from_array(const unsigned int *tiles, const unsigned int tiles_len,
|
||||
const unsigned short *palette, const unsigned int pal_len,
|
||||
const unsigned int palette_id, const unsigned short *tile_map,
|
||||
@ -49,6 +84,20 @@ namespace morpheus {
|
||||
void array_load(const unsigned short *tile_map, const unsigned int tile_map_len,
|
||||
core::gfx::TiledBackgroundSize size)override;
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::gfx::TiledBackground8Bpp
|
||||
/// Nintendo DS implementation of
|
||||
/// morpheus::nds::gfx::TiledBackground and
|
||||
/// morpheus::core::gfx::TiledBackgroundBase. Represents tiled
|
||||
/// (or "text" mode) backgrounds of 8bpp (or with 256 colors) that
|
||||
/// can be displayed on the bottom sub display or the top main
|
||||
/// display of the DS.
|
||||
/// Can either use single palette mode, having one palette of 256
|
||||
/// colors, or extended palette mode having 16 palettes of 256
|
||||
/// colors.
|
||||
/// For more details about this class, consult the
|
||||
/// documentation of the aforementioned parent and grandparent
|
||||
/// class.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef MORPHEUS_NDS_HPP
|
||||
#define MORPHEUS_NDS_HPP
|
||||
|
||||
/// Common NDS header file: Includes all needed headers for NDS Morpheus games
|
||||
|
||||
#include <morpheus/nds/nds_main_loop.hpp>
|
||||
#include <morpheus/nds/ds_flashcard_save_manager.hpp>
|
||||
|
||||
|
@ -14,10 +14,20 @@ namespace morpheus {
|
||||
namespace gfx {
|
||||
class NdsBlendingController : public morpheus::core::gfx::BlendingController {
|
||||
public:
|
||||
/// Constructs a blending controller for the DS for either the
|
||||
/// bottom sub display or the top main display. Note: this class
|
||||
/// should not be manually constructed and should instead be
|
||||
/// retrieved through the MainLoop. See parent class
|
||||
/// morpheus::core::gfx::BlendingController documentation for
|
||||
/// more details.
|
||||
/// \param use_sub_display Whether this blending controller
|
||||
/// will control the bottom sub display (true) or the top
|
||||
/// main display (false).
|
||||
explicit NdsBlendingController(bool use_sub_display) {
|
||||
m_use_sub_display = use_sub_display;
|
||||
}
|
||||
|
||||
/// Destroys the NdsBlendingController object.
|
||||
virtual ~NdsBlendingController() = default;
|
||||
protected:
|
||||
void update_blending_registers()override;
|
||||
@ -25,18 +35,40 @@ namespace morpheus {
|
||||
bool m_use_sub_display;
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::gfx::NdsBlendingController
|
||||
/// The Nintendo DS (NDS) implementation of
|
||||
/// morpheus::core::gfx::BlendingController. For more details about
|
||||
/// this class, consult the documentation of the aforementioned
|
||||
/// parent class.
|
||||
|
||||
class NdsMosaicController : public morpheus::core::gfx::MosaicController {
|
||||
public:
|
||||
/// Constructs a mosaic controller for the DS for either the
|
||||
/// bottom sub display or the top main display. Note: this class
|
||||
/// should not be manually constructed and should instead be
|
||||
/// retrieved through the MainLoop. See parent class
|
||||
/// morpheus::core::gfx::MosaicController documentation for
|
||||
/// more details.
|
||||
/// \param use_sub_display Whether this mosaic controller
|
||||
/// will control the bottom sub display (true) or the top
|
||||
/// main display (false).
|
||||
explicit NdsMosaicController(bool use_sub_display) {
|
||||
m_use_sub_display = use_sub_display;
|
||||
}
|
||||
|
||||
/// Destroys the NdsMosaicController object.
|
||||
virtual ~NdsMosaicController() = default;
|
||||
protected:
|
||||
void update_mosaic_register()override;
|
||||
private:
|
||||
bool m_use_sub_display;
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::gfx::NdsMosaicController
|
||||
/// The Nintendo DS (NDS) implementation of
|
||||
/// morpheus::core::gfx::MosaicController. For more details about
|
||||
/// this class, consult the documentation of the aforementioned
|
||||
/// parent class.
|
||||
}
|
||||
|
||||
class NdsNoCashDebugController : public core::NoCashDebugController {
|
||||
@ -45,6 +77,12 @@ namespace morpheus {
|
||||
nocashMessage(message.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::NdsNoCashDebugController
|
||||
/// The Nintendo DS (NDS) implementation of
|
||||
/// morpheus::core::gfx::NoCashDebugController. For more details about
|
||||
/// this class, consult the documentation of the aforementioned
|
||||
/// parent class.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
namespace morpheus {
|
||||
namespace nds {
|
||||
|
||||
static constexpr uint16_t NDS_KEYPAD_BITS[] = { KEY_A, KEY_B, KEY_SELECT, KEY_START, KEY_RIGHT, KEY_LEFT,
|
||||
KEY_UP, KEY_DOWN, KEY_R, KEY_L,
|
||||
/* DS exclusive keys */
|
||||
@ -27,6 +26,7 @@ namespace morpheus {
|
||||
|
||||
class NdsMainLoop : public core::MainLoop {
|
||||
public:
|
||||
/// Constructs the (single) NdsMainLoop object.
|
||||
explicit NdsMainLoop();
|
||||
|
||||
static void reset_to_debug_print_console() {
|
||||
@ -35,10 +35,16 @@ namespace morpheus {
|
||||
}
|
||||
}
|
||||
|
||||
/// \return The BlendingController of this NdsMainLoop for the
|
||||
/// bottom sub display. (The regular get_blending_controller()
|
||||
/// returns the BlendingController for the top main display).
|
||||
core::gfx::BlendingController *get_sub_blending_controller() const {
|
||||
return m_sub_blending_controller.get();
|
||||
}
|
||||
|
||||
/// \return The MosaicController of this NdsMainLoop for the
|
||||
/// bottom sub display. (The regular get_blending_controller()
|
||||
/// returns the MosaicController for the top main display).
|
||||
core::gfx::MosaicController *get_sub_mosaic_controller() const {
|
||||
return m_sub_mosaic_controller.get();
|
||||
}
|
||||
@ -55,15 +61,25 @@ namespace morpheus {
|
||||
enable_affine(affine_mode, false);
|
||||
}
|
||||
|
||||
/// Disables affine support on either the bottom sub display or the
|
||||
/// top main display.
|
||||
/// \param use_sub_display Whether to disable the support on the
|
||||
/// bottom sub display (true) or the top main display (false)
|
||||
void disable_affine(bool use_sub_display);
|
||||
|
||||
/// Enables affine support on either the bottom sub display or the
|
||||
/// top main display.
|
||||
/// \param affine_mode The AffineMode to enable
|
||||
/// \param use_sub_display Whether to disable the support on the
|
||||
/// bottom sub display (true) or the top main display (false)
|
||||
void enable_affine(core::gfx::AffineMode affine_mode, bool use_sub_display);
|
||||
|
||||
void enable_background(unsigned int background_reference_num)override;
|
||||
void enable_window(core::gfx::WindowType window_type)override;
|
||||
|
||||
[[noreturn]] core::Error game_loop() override;
|
||||
[[noreturn]] core::Error game_loop()override;
|
||||
protected:
|
||||
core::Error platform_init() override;
|
||||
core::Error platform_init()override;
|
||||
|
||||
core::InputEvent to_input_event(uint32_t inputs, uint16_t keypad_bit,
|
||||
morpheus::core::InputState input_state)override;
|
||||
@ -80,6 +96,13 @@ namespace morpheus {
|
||||
std::unique_ptr<gfx::NdsBlendingController> m_sub_blending_controller;
|
||||
std::unique_ptr<gfx::NdsMosaicController> m_sub_mosaic_controller;
|
||||
};
|
||||
|
||||
/// \class morpheus::nds::NdsMainLoop
|
||||
/// The DS implementation of morpheus::core::MainLoop, representing
|
||||
/// a DS Morpheus game's main loop. There should only be a single
|
||||
/// NdsMainLoop over the DS game's lifecycle, otherwise undefined
|
||||
/// behavior will occur. For more information about this class,
|
||||
/// consult the aforementioned parent class.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,10 @@ namespace morpheus {
|
||||
namespace utils {
|
||||
class BackgroundTestControls : public morpheus::core::ControlReciever {
|
||||
public:
|
||||
/// Constructs a BackgroundTestControls object with a given smart
|
||||
/// pointer to a TiledBackgroundBase.
|
||||
/// \param background A smart pointer to the TiledBackgroundBase
|
||||
/// this class will control
|
||||
BackgroundTestControls(std::shared_ptr<morpheus::core::gfx::TiledBackgroundBase> background) {
|
||||
m_background = background;
|
||||
}
|
||||
@ -29,10 +33,17 @@ namespace morpheus {
|
||||
|
||||
void update(unsigned char cycle_time) override {}
|
||||
|
||||
/// Changes the current smart pointer to the TiledBackgroundBase
|
||||
/// that this class will control.
|
||||
/// \param new_background The smart pointer that this class will
|
||||
/// control
|
||||
void change_background(const std::shared_ptr<morpheus::core::gfx::TiledBackgroundBase> new_background) {
|
||||
m_background = new_background;
|
||||
}
|
||||
protected:
|
||||
/// Scrolls the background according to InputEvents feeded by
|
||||
/// input()
|
||||
/// \param input_event The InputEvent from input() to react to
|
||||
void scroll_background(morpheus::core::InputEvent input_event) {
|
||||
if(input_event.state == morpheus::core::InputState::DOWN ||
|
||||
input_event.state == morpheus::core::InputState::HELD) {
|
||||
@ -62,6 +73,17 @@ namespace morpheus {
|
||||
std::shared_ptr<morpheus::core::gfx::TiledBackgroundBase> m_background;
|
||||
};
|
||||
|
||||
/// \class morpheus::utils::BackgroundTestControls
|
||||
/// A helper class for testing background scrolling with the directional
|
||||
/// pad.
|
||||
|
||||
|
||||
/// Constructs the appropriate morpheus::core::gfx::AnimationFrame for
|
||||
/// the current platform.
|
||||
/// \param sprite_base The sprite for the AnimationFrame
|
||||
/// \param from_animation_frame The optional from_animation_frame
|
||||
/// argument for the AnimationFrame
|
||||
/// \return The appropriate AnimationFrame
|
||||
static morpheus::core::gfx::AnimationFrame *construct_appropriate_animation_frame(
|
||||
core::gfx::SpriteBase *sprite_base, core::gfx::AnimationFrame *from_animation_frame = nullptr) {
|
||||
#ifdef _GBA
|
||||
@ -77,6 +99,11 @@ namespace morpheus {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Constructs the appropriate morpheus::core::MainLoop for
|
||||
/// the current platform.
|
||||
/// \param gba_save_type The appropriate GbaSaveType used if
|
||||
/// this function constructs a GbaMainLoop
|
||||
/// \return The appropriate MainLoop
|
||||
static morpheus::core::MainLoop *construct_appropriate_main_loop(
|
||||
morpheus::core::GbaSaveType gba_save_type = morpheus::core::GbaSaveType::SRAM_32KB) {
|
||||
#ifdef _GBA
|
||||
@ -88,6 +115,14 @@ namespace morpheus {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Constructs the appropriate morpheus::core::audio::MaxModMusic for
|
||||
/// the current platform.
|
||||
/// \param sound_bank_ref_num The sound bank reference number
|
||||
/// argument of MaxModMusic
|
||||
/// \param sound_bank The sound bank pointer argument of MaxModMusic
|
||||
/// \param num_of_channels The number of audio channels to use if
|
||||
/// constructing a GbaMaxModMusic
|
||||
/// \return The appropriate MaxModMusic object
|
||||
static morpheus::core::audio::MaxModMusic *construct_appropriate_max_mod_music(
|
||||
int sound_bank_ref_num,
|
||||
void *sound_bank = nullptr,
|
||||
@ -101,6 +136,14 @@ namespace morpheus {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/// Constructs the appropriate morpheus::core::audio::MaxModSfx for
|
||||
/// the current platform.
|
||||
/// \param sound_bank_ref_num The sound bank reference number
|
||||
/// argument of MaxModSfx
|
||||
/// \param sound_bank The sound bank pointer argument of MaxModSfx
|
||||
/// \param num_of_channels The number of audio channels to use if
|
||||
/// constructing a GbaMaxModSfx
|
||||
/// \return The appropriate MaxModSfx object
|
||||
static morpheus::core::audio::MaxModSfx *construct_appropriate_max_mod_sfx(
|
||||
int sound_bank_ref_num,
|
||||
void *sound_bank = nullptr,
|
||||
@ -114,7 +157,17 @@ namespace morpheus {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// BlendingController should be platform specific blending controller
|
||||
/// Constructs the appropriate 4bpp morpheus::core::gfx::SpriteBase
|
||||
/// for the current platform.
|
||||
/// \param affine The affine argument of SpriteBase
|
||||
/// \param blending_controller The blending controller argument of
|
||||
/// SpriteBase
|
||||
/// \param mosaic_controller The mosaic controller argument of
|
||||
/// SpriteBase
|
||||
/// \param nds_use_sub_display If constructing a 4bpp sprite for the DS,
|
||||
/// should this sprite be displayed on the bottom sub display (true) or
|
||||
/// the top main display (false)
|
||||
/// \return The appropriate 4bpp SpriteBase object
|
||||
static morpheus::core::gfx::SpriteBase *construct_appropriate_sprite_4bpp(
|
||||
bool affine,
|
||||
morpheus::core::gfx::BlendingController *blending_controller,
|
||||
@ -132,6 +185,19 @@ namespace morpheus {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Constructs the appropriate 8bpp morpheus::core::gfx::SpriteBase for
|
||||
/// the current platform.
|
||||
/// \param affine The affine argument of SpriteBase
|
||||
/// \param blending_controller The blending controller argument of
|
||||
/// SpriteBase
|
||||
/// \param mosaic_controller The mosaic controller argument of
|
||||
/// SpriteBase
|
||||
/// \param nds_use_sub_display If constructing an 8bpp sprite for the
|
||||
/// DS, should this sprite be displayed on the bottom sub display (true)
|
||||
/// or the top main display (false)
|
||||
/// \param nds_use_sub_display If constructing an 8bpp sprite for the
|
||||
/// DS, should extended palette mode be enabled or disabled
|
||||
/// \return The appropriate 4bpp SpriteBase object
|
||||
static morpheus::core::gfx::SpriteBase *construct_appropriate_sprite_8bpp(
|
||||
bool affine,
|
||||
morpheus::core::gfx::BlendingController *blending_controller,
|
||||
@ -151,6 +217,17 @@ namespace morpheus {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Constructs the appropriate morpheus::core::gfx::TextBase for
|
||||
/// the current platform.
|
||||
/// \param affine The affine argument of TextBase
|
||||
/// \param background_num The background number argument of TextBase
|
||||
/// \param cbb The tile offset number argument of TextBase
|
||||
/// \param sbb The tilemap offset number argument of TextBase
|
||||
/// \param main_loop The main loop pointer argument of TextBase
|
||||
/// \param nds_use_sub_display If constructing a TextBase for the
|
||||
/// DS, should the text be displayed on the bottom sub display (true)
|
||||
/// or the top main display (false)
|
||||
/// \return The appropriate TextBase object
|
||||
static morpheus::core::gfx::TextBase *construct_appropriate_text(bool affine, unsigned int background_num,
|
||||
unsigned int cbb, unsigned int sbb,
|
||||
morpheus::core::MainLoop *main_loop,
|
||||
@ -165,6 +242,26 @@ namespace morpheus {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Constructs the appropriate 4bpp
|
||||
/// morpheus::core::gfx::TiledBackgroundBase for the current
|
||||
/// platform.
|
||||
/// \param affine The affine argument of TiledBackgroundBase
|
||||
/// \param background_num The background number argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param blending_controller The blending controller argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param mosaic_controller The mosaic controller argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param main_loop The main loop pointer argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param cbb_num The tile offset number argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param sbb_num The tilemap offset number argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param nds_use_sub_display If constructing a TiledBackgroundBase for
|
||||
/// the DS, should the background be displayed on the bottom sub display
|
||||
/// (true) or the top main display (false)
|
||||
/// \return The appropriate 4bpp TiledBackgroundBase
|
||||
static morpheus::core::gfx::TiledBackgroundBase *construct_appropriate_tiled_background_4bpp(
|
||||
bool affine, unsigned int background_num,
|
||||
morpheus::core::gfx::BlendingController *blending_controller,
|
||||
@ -185,6 +282,26 @@ namespace morpheus {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Constructs the appropriate 8bpp
|
||||
/// morpheus::core::gfx::TiledBackgroundBase for the current
|
||||
/// platform.
|
||||
/// \param affine The affine argument of TiledBackgroundBase
|
||||
/// \param background_num The background number argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param blending_controller The blending controller argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param mosaic_controller The mosaic controller argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param main_loop The main loop pointer argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param cbb_num The tile offset number argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param sbb_num The tilemap offset number argument of
|
||||
/// TiledBackgroundBase
|
||||
/// \param nds_use_sub_display If constructing a TiledBackgroundBase for
|
||||
/// the DS, should the background be displayed on the bottom sub display
|
||||
/// (true) or the top main display (false)
|
||||
/// \return The appropriate 8bpp TiledBackgroundBase
|
||||
static morpheus::core::gfx::TiledBackgroundBase *construct_appropriate_tiled_background_8bpp(
|
||||
bool affine, unsigned int background_num,
|
||||
morpheus::core::gfx::BlendingController *blending_controller,
|
||||
@ -205,6 +322,14 @@ namespace morpheus {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Constructs the appropriate morpheus::core::gfx::Window for the
|
||||
/// current platform.
|
||||
/// \param window_type The window type argument of Window
|
||||
/// \param main_loop The main loop pointer argument of Window
|
||||
/// \param nds_use_sub_display If constructing a Window for
|
||||
/// the DS, should the window be on the bottom sub display
|
||||
/// (true) or the top main display (false)
|
||||
/// \return The appropriate Window object
|
||||
static morpheus::core::gfx::Window *construct_appropriate_window(const core::gfx::WindowType window_type,
|
||||
const std::shared_ptr<core::MainLoop> main_loop,
|
||||
const bool nds_use_sub_display = false) {
|
||||
@ -215,6 +340,17 @@ namespace morpheus {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Constructs a morpheus::core::gfx::StreamingBackgroundBase with
|
||||
/// sensible defaults for the current platform.
|
||||
/// \param background_to_use The TiledBackgroundBase argument of
|
||||
/// StreamingBackgroundBase
|
||||
/// \param map_tile_update_threshold The tilemap update threshold
|
||||
/// argument of StreamingBackgroundBase
|
||||
/// \param player_position The player position argument of
|
||||
/// StreamingBackgroundBase
|
||||
/// \param enable_wrapping The enable wrapping argument of
|
||||
/// StreamingBackgroundBase
|
||||
/// \return The StreamingBackgroundBase with sensible platform defaults
|
||||
static morpheus::core::gfx::StreamingBackgroundBase *construct_appropriate_streaming_background_base(
|
||||
morpheus::core::gfx::TiledBackgroundBase *background_to_use,
|
||||
morpheus::core::gfx::Vector2 map_tile_update_threshold = morpheus::core::gfx::Vector2(0, 0),
|
||||
@ -242,6 +378,11 @@ namespace morpheus {
|
||||
player_position, enable_wrapping);
|
||||
}
|
||||
}
|
||||
|
||||
/// \file utils.hpp
|
||||
/// A file consisting mostly of helper functions constructing the
|
||||
/// appropriate implementations of Morpheus classes for code portability
|
||||
/// across the DS and the GBA.
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user