libElysianVMU 1.6.0
Full-featured, accurate, cross-platform library emulating the Dreamcast's Visual Memory Unit
Loading...
Searching...
No Matches
evmu_wram.h
Go to the documentation of this file.
1/*! \file
2 * \brief EvmuWram: Work-RAM peripheral memory API
3 * \ingroup peripherals
4 *
5 * \author 2023 Falco Girgis
6 * \copyright MIT License
7 */
8#ifndef EVMU_WRAM_H
9#define EVMU_WRAM_H
10
11#include "../types/evmu_peripheral.h"
12#include "../types/evmu_imemory.h"
13
14/*! \name Type System
15 * \brief Type UUID and cast operators
16 * @{
17 */
18#define EVMU_WRAM_TYPE (GBL_TYPEID(EvmuWram)) //!< Type UUID for EvmuWram
19#define EVMU_WRAM(self) (GBL_CAST(EvmuWram, self)) //!< Function-style cast for GblInstance
20#define EVMU_WRAM_CLASS(klass) (GBL_CLASS_CAST(EvmuWram, klass)) //!< Function-style cast for GblClass
21#define EVMU_WRAM_GET_CLASS(self) (GBL_CLASSOF(EvmuWram, self)) //!< Get EvmuWramClass from GblInstance
22//! @}
23
24#define EVMU_WRAM_NAME "wram" //!< EvmuWram GblObject name
25
26/*! \name Address Space
27 * \brief Region size and location definitions
28 *@{
29 */
30#define EVMU_WRAM_BANK_COUNT 2 //!< Number of banks in WRAM
31#define EVMU_WRAM_BANK_SIZE 256 //!< Size of each bank in WRAM
32#define EVMU_WRAM_SIZE (EVMU_WRAM_BANK_COUNT * EVMU_WRAM_BANK_SIZE) //!< Total size of WRAM (both banks)
33//! @}
34
35#define GBL_SELF_TYPE EvmuWram
36
37GBL_DECLS_BEGIN
38
39GBL_FORWARD_DECLARE_STRUCT(EvmuWram);
40
41/*! \struct EvmuWramClass
42 * \extends EvmuPeripheralClass
43 * \implements EvmuIMemoryClass
44 * \brief GblClass structure for EvmuPeripheralClass
45 *
46 * No public members.
47 *
48 * \sa EvmuWram
49 */
50GBL_CLASS_DERIVE_EMPTY(EvmuWram, EvmuPeripheral, EvmuIMemory)
51
52/*! \struct EvmuWram
53 * \extends EvmuPeripheral
54 * \implements EvmuIMemory
55 * \ingroup peripherals
56 * \brief GblInstance structure for EvmuWram
57 *
58 * No public members.
59 *
60 * \sa EvmuWramClass
61 */
62GBL_INSTANCE_DERIVE(EvmuWram, EvmuPeripheral)
63 GblBool dataChanged; //!< User toggle: will be set after a WRAM value changes, you can reset and poll for changes
64GBL_INSTANCE_END
65
66//! \cond
67GBL_PROPERTIES(EvmuWram,
68 (dataChanged, GBL_GENERIC, (READ, WRITE, OVERRIDE), GBL_BOOL_TYPE),
69 (mode, GBL_GENERIC, (READ, WRITE ), GBL_ENUM_TYPE),
70 (autoIncAddress, GBL_GENERIC, (READ, WRITE ), GBL_BOOL_TYPE),
71 (accessAddress, GBL_GENERIC, (READ, WRITE ), GBL_UINT16_TYPE),
72 (transferring, GBL_GENERIC, (READ), GBL_BOOL_TYPE)
73)
74//! \endcond
75
76//! Returns the GblType UUID associated with EvmuWram
77EVMU_EXPORT GblType EvmuWram_type (void) GBL_NOEXCEPT;
78
79/*! \name Configuration Methods
80 * \brief Methods for querying or updating configuration
81 * \relatesalso EvmuWram
82 * @{
83 */
84//! Returns the target address created by using VRMAD1 the low byte, and VRMAD2 as the bank
86//! Configures the values of VRMAD1 and VRMAD2 so that they point to the address given by \p addr
87EVMU_EXPORT EVMU_RESULT EvmuWram_setAccessAddress (GBL_SELF, EvmuAddress addr) GBL_NOEXCEPT;
88//! Returns GBL_TRUE of a Maple transfer from the Dreamcast is in progress, disallowing VMU access
90//! @}
91
92/*! \name Read/Write Accessors
93 * \brief Methods for reading and writing WRAM data
94 * \relatesalso EvmuWram
95 * @{
96 */
97//! Returns the byte value located at the given WRAM \p address
99 EvmuAddress address) GBL_NOEXCEPT;
100//! Reads \p pSize bytes from WRAM into \p pData, starting at \p address, writing back the number of bytes read
101EVMU_EXPORT EVMU_RESULT EvmuWram_readBytes (GBL_CSELF,
102 EvmuAddress address,
103 void* pData,
104 size_t* pSize) GBL_NOEXCEPT;
105//! Writes the \p byte value to the WRAM \p address
106EVMU_EXPORT EVMU_RESULT EvmuWram_writeByte (GBL_SELF,
107 EvmuAddress address,
108 EvmuWord byte) GBL_NOEXCEPT;
109//! Writes \p pSize bytes to WRAM from \p pData, starting at \p address, writing back the number of bytes written
110EVMU_EXPORT EVMU_RESULT EvmuWram_writeBytes (GBL_SELF,
111 EvmuAddress address,
112 const void* pData,
113 size_t* pSize) GBL_NOEXCEPT;
114//! @}
115
116GBL_DECLS_END
117
118#undef GBL_SELF_TYPE
119
120#endif // EVMU_WRAM_H
#define EVMU_EXPORT
Define used for adding attributes to export public symbols.
Definition evmu_api.h:18
uint8_t EvmuWord
Represents a single 8-bit CPU word.
uint32_t EvmuAddress
Represents a generic absolute address.
#define EVMU_WRAM_BANK_COUNT
Number of banks in WRAM.
Definition evmu_wram.h:30
#define EVMU_WRAM_BANK_SIZE
Size of each bank in WRAM.
Definition evmu_wram.h:31
GblType EvmuWram_type(void)
Returns the GblType UUID associated with EvmuWram.
#define GBL_ENUM_TYPE
#define GBL_UINT16_TYPE
#define GBL_BOOL_TYPE
#define GBL_PROPERTIES(object,...)
uint8_t GblBool
uintptr_t GblType
GblInstance structure for EvmuWram.
Definition evmu_wram.h:62
EvmuAddress EvmuWram_accessAddress(const EvmuWram *pSelf)
Returns the target address created by using VRMAD1 the low byte, and VRMAD2 as the bank.
EVMU_RESULT EvmuWram_readBytes(const EvmuWram *pSelf, EvmuAddress address, void *pData, size_t *pSize)
Reads pSize bytes from WRAM into pData, starting at address, writing back the number of bytes read.
GblBool EvmuWram_mapleTransferring(const EvmuWram *pSelf)
Returns GBL_TRUE of a Maple transfer from the Dreamcast is in progress, disallowing VMU access.
GblBool dataChanged
User toggle: will be set after a WRAM value changes, you can reset and poll for changes.
Definition evmu_wram.h:63
EVMU_RESULT EvmuWram_setAccessAddress(EvmuWram *pSelf, EvmuAddress addr)
Configures the values of VRMAD1 and VRMAD2 so that they point to the address given by addr.
EvmuWord EvmuWram_readByte(const EvmuWram *pSelf, EvmuAddress address)
Returns the byte value located at the given WRAM address.
EVMU_RESULT EvmuWram_writeByte(EvmuWram *pSelf, EvmuAddress address, EvmuWord byte)
Writes the byte value to the WRAM address.
EVMU_RESULT EvmuWram_writeBytes(EvmuWram *pSelf, EvmuAddress address, const void *pData, size_t *pSize)
Writes pSize bytes to WRAM from pData, starting at address, writing back the number of bytes written.
#define GBL_CLASS_CAST(cType, klass)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)