libElysianVMU 1.6.0
Full-featured, accurate, cross-platform library emulating the Dreamcast's Visual Memory Unit
Loading...
Searching...
No Matches
evmu_device.h
Go to the documentation of this file.
1/*! \file
2 * \brief EvmuDevice top-level emulated entity
3 *
4 * EvmuDevice encompasses everything that a single Visual Memory
5 * Unit/System entails, emulating the Sanyo Potato IC.
6 *
7 * \author 2023 Falco Girgis
8 * \copyright MIT License
9 */
10
11#ifndef EVMU_DEVICE_H
12#define EVMU_DEVICE_H
13
14#include "../types/evmu_ibehavior.h"
15#include "../hw/evmu_ram.h"
16#include "../hw/evmu_cpu.h"
17#include "../hw/evmu_clock.h"
18#include "../hw/evmu_rom.h"
19#include "../hw/evmu_pic.h"
20#include "../hw/evmu_flash.h"
21#include "../hw/evmu_lcd.h"
22#include "../hw/evmu_battery.h"
23#include "../hw/evmu_wram.h"
24#include "../hw/evmu_buzzer.h"
25#include "../hw/evmu_gamepad.h"
26#include "../hw/evmu_timers.h"
27#include "../fs/evmu_fat.h"
28#include "../fs/evmu_file_manager.h"
29
30/*! \name Type System
31 * \brief Type UUID and cast operators
32 * @{
33 */
34#define EVMU_DEVICE_TYPE (GBL_TYPEID(EvmuDevice)) //!< UUID for the EvmuDevice type
35#define EVMU_DEVICE(self) (GBL_CAST(EvmuDevice, self)) //!< Cast GblInstance to EvmuDevice
36#define EVMU_DEVICE_CLASS(klass) (GBL_CLASS_CAST(EvmuDevice, klass)) //!< Cast GblClass to EvmuDeviceClass
37#define EVMU_DEVICE_GET_CLASS(self) (GBL_CLASSOF(EvmuDevice, self)) //!< Get EvmuDeviceClass from GblInstance
38//! @}
39
40#define GBL_SELF_TYPE EvmuDevice
41
42GBL_DECLS_BEGIN
43
44/*! \struct EvmuDeviceClass
45 * \extends GblObjectClass
46 * \implements EvmuIBehaviorClass
47 * \brief GblClass structure for EvmuDevice
48 *
49 * This class contains no public members.
50 *
51 * \sa EvmuDevice
52 */
53GBL_CLASS_DERIVE_EMPTY(EvmuDevice, GblObject, EvmuIBehavior)
54
55/*! \struct EvmuDevice
56 * \extends GblObject
57 * \implements EvmuIBehavior
58 * \brief GblInstance structure for VMU Devices
59 *
60 * This structure models the top-level Potato IC, whose
61 * components are accessible as EvmuPeripherals attached
62 * to the device.
63 *
64 * \sa EvmuDeviceClass
65 */
66GBL_INSTANCE_DERIVE(EvmuDevice, GblObject)
67 EvmuRam* pRam; //!< EvmuRam Peripheral
68 EvmuCpu* pCpu; //!< EvmuCpu Peripheral
69 EvmuClock* pClock; //!< EvmuClock Peripheral
70 EvmuPic* pPic; //!< EvmuPic Peripheral
71 EvmuRom* pRom; //!< EvmuRom Peripheral
72 EvmuWram* pWram; //!< EvmuWram Peripheral
73 EvmuLcd* pLcd; //!< EvmuLcd Peripheral
74 EvmuBuzzer* pBuzzer; //!< EvmuBuzzer Peripheral
75 EvmuBattery* pBattery; //!< EvmuBattery Peripheral
76 EvmuGamepad* pGamepad; //!< EvmuGamepad Peripheral
77 EvmuTimers* pTimers; //!< EvmuTimers Peripheral
78 union {
79 EvmuFlash* pFlash; //!< EvmuFlash Peripheral
80 EvmuFat* pFat; //!< EvmuFat Peripheral
81 EvmuFileManager* pFileMgr; //!< EvmuFileSystem Peripheral
82 };
83GBL_INSTANCE_END
84
85//! \cond
86GBL_PROPERTIES(EvmuDevice,
87 (memory, GBL_GENERIC, (READ), EVMU_RAM_TYPE),
88 (cpu, GBL_GENERIC, (READ), EVMU_CPU_TYPE),
89 (clock, GBL_GENERIC, (READ), EVMU_CLOCK_TYPE),
90 (pic, GBL_GENERIC, (READ), EVMU_PIC_TYPE),
91 (rom, GBL_GENERIC, (READ), EVMU_ROM_TYPE),
92 (flash, GBL_GENERIC, (READ), EVMU_FLASH_TYPE),
93 (wram, GBL_GENERIC, (READ), EVMU_WRAM_TYPE),
94 (lcd, GBL_GENERIC, (READ), EVMU_LCD_TYPE),
95 (buzzer, GBL_GENERIC, (READ), EVMU_BUZZER_TYPE),
96 (battery, GBL_GENERIC, (READ), EVMU_BATTERY_TYPE),
97 (gamepad, GBL_GENERIC, (READ), EVMU_GAMEPAD_TYPE),
98 (timers, GBL_GENERIC, (READ), EVMU_TIMERS_TYPE),
99 (fat, GBL_GENERIC, (READ), EVMU_FAT_TYPE)
100)
101//! \endcond
102
103//! Returns the GblType UUID associated with EvmuDevice
105//! Creates an EvmuDevice instance and returns a pointer to it
106EVMU_EXPORT EvmuDevice* EvmuDevice_create (void) GBL_NOEXCEPT;
107//! Increments the reference counter for the given device, returning a pointer to it
108EVMU_EXPORT EvmuDevice* EvmuDevice_ref (GBL_CSELF) GBL_NOEXCEPT;
109//! Decrements and returns the reference count of the given EvmuDevice, destructing it at 0
111
112/*! \name Peripherals
113 * \brief Methods for managing peripheral components
114 * \relatesalso EvmuDevice
115 * @{
116 */
117//! Returns the number of EvmuPeripheral GblObject children attached to the given device instance
118EVMU_EXPORT size_t EvmuDevice_peripheralCount (GBL_CSELF) GBL_NOEXCEPT;
119//! Finds a child EvmuPeripheral child attached to the given device, returning a pointer to it or NULL if not found
120EVMU_EXPORT EvmuPeripheral* EvmuDevice_findPeripheral (GBL_CSELF, const char* pName) GBL_NOEXCEPT;
121//! Returns the child EvmuPeripheral attached to the given device at the provided \p index
122EVMU_EXPORT EvmuPeripheral* EvmuDevice_peripheral (GBL_CSELF, size_t index) GBL_NOEXCEPT;
123//! @}
124
125GBL_DECLS_END
126
127#undef GBL_SELF_TYPE
128
129#endif // EVMU_DEVICE_H
#define EVMU_EXPORT
Define used for adding attributes to export public symbols.
Definition evmu_api.h:18
#define EVMU_BATTERY_TYPE
GblType UUID for EvmuBattery.
#define EVMU_BUZZER_TYPE
GblType UUID for GblBuzzer.
Definition evmu_buzzer.h:40
#define EVMU_CLOCK_TYPE
Type UUID for EvmuClock.
Definition evmu_clock.h:19
#define EVMU_CPU_TYPE
Type UUID for EvmuCpu.
Definition evmu_cpu.h:32
GblType EvmuDevice_type(void)
Returns the GblType UUID associated with EvmuDevice.
GblRefCount EvmuDevice_unref(EvmuDevice *pSelf)
Decrements and returns the reference count of the given EvmuDevice, destructing it at 0.
EvmuDevice * EvmuDevice_create(void)
Creates an EvmuDevice instance and returns a pointer to it.
EvmuDevice * EvmuDevice_ref(const EvmuDevice *pSelf)
Increments the reference counter for the given device, returning a pointer to it.
#define EVMU_FAT_TYPE
UUID for EvmuFat type.
Definition evmu_fat.h:45
#define EVMU_FLASH_TYPE
Type UUID for EvmuFlash.
Definition evmu_flash.h:39
#define EVMU_GAMEPAD_TYPE
GblType UUID for EvmuGamepad.
#define EVMU_LCD_TYPE
Type UUID for EvmuLcd.
Definition evmu_lcd.h:32
#define EVMU_PIC_TYPE
Type UUID for EvmuPic.
Definition evmu_pic.h:25
#define EVMU_RAM_TYPE
Type UUID for EvmuRam.
Definition evmu_ram.h:22
#define EVMU_ROM_TYPE
Type UUID for EvmuRom.
Definition evmu_rom.h:31
#define EVMU_TIMERS_TYPE
Type UUID for EvmuTimers.
Definition evmu_timers.h:24
#define EVMU_WRAM_TYPE
Type UUID for EvmuWram.
Definition evmu_wram.h:18
#define GBL_PROPERTIES(object,...)
uint16_t GblRefCount
uintptr_t GblType
GblInstance structure for VMU Devices.
Definition evmu_device.h:66
EvmuFlash * pFlash
EvmuFlash Peripheral.
Definition evmu_device.h:79
EvmuClock * pClock
EvmuClock Peripheral.
Definition evmu_device.h:69
EvmuGamepad * pGamepad
EvmuGamepad Peripheral.
Definition evmu_device.h:76
EvmuPeripheral * EvmuDevice_findPeripheral(const EvmuDevice *pSelf, const char *pName)
Finds a child EvmuPeripheral child attached to the given device, returning a pointer to it or NULL if...
EvmuWram * pWram
EvmuWram Peripheral.
Definition evmu_device.h:72
EvmuFat * pFat
EvmuFat Peripheral.
Definition evmu_device.h:80
EvmuRom * pRom
EvmuRom Peripheral.
Definition evmu_device.h:71
EvmuTimers * pTimers
EvmuTimers Peripheral.
Definition evmu_device.h:77
EvmuPeripheral * EvmuDevice_peripheral(const EvmuDevice *pSelf, size_t index)
Returns the child EvmuPeripheral attached to the given device at the provided index.
EvmuCpu * pCpu
EvmuCpu Peripheral.
Definition evmu_device.h:68
size_t EvmuDevice_peripheralCount(const EvmuDevice *pSelf)
Returns the number of EvmuPeripheral GblObject children attached to the given device instance.
EvmuRam * pRam
EvmuRam Peripheral.
Definition evmu_device.h:67
EvmuFileManager * pFileMgr
EvmuFileSystem Peripheral.
Definition evmu_device.h:81
EvmuPic * pPic
EvmuPic Peripheral.
Definition evmu_device.h:70
EvmuBattery * pBattery
EvmuBattery Peripheral.
Definition evmu_device.h:75
EvmuLcd * pLcd
EvmuLcd Peripheral.
Definition evmu_device.h:73
EvmuBuzzer * pBuzzer
EvmuBuzzer Peripheral.
Definition evmu_device.h:74
#define GBL_CLASS_CAST(cType, klass)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)