33
44#include < cstdio>
55
6- #include " rsp_vu.hpp"
76#include " recomp.h"
7+ #include " rsp_vu.hpp"
88#include " ultramodern/ultra64.h"
99
1010// TODO: Move these to recomp namespace?
@@ -17,69 +17,64 @@ enum class RspExitReason {
1717 Unsupported
1818};
1919
20- using RspUcodeFunc = RspExitReason(uint8_t * rdram);
20+ using RspUcodeFunc = RspExitReason(uint8_t * rdram);
2121
2222extern uint8_t dmem[];
2323extern uint16_t rspReciprocals[512 ];
2424extern uint16_t rspInverseSquareRoots[512 ];
2525
26- #define RSP_MEM_B (offset, addr ) \
27- (*reinterpret_cast <int8_t *>(dmem + (0xFFF & (((offset) + (addr)) ^ 3 ))))
26+ #define RSP_MEM_B (offset, addr ) (*reinterpret_cast <int8_t *>(dmem + (0xFFF & (((offset) + (addr)) ^ 3 ))))
2827
29- #define RSP_MEM_BU (offset, addr ) \
30- (*reinterpret_cast <uint8_t *>(dmem + (0xFFF & (((offset) + (addr)) ^ 3 ))))
28+ #define RSP_MEM_BU (offset, addr ) (*reinterpret_cast <uint8_t *>(dmem + (0xFFF & (((offset) + (addr)) ^ 3 ))))
3129
3230static inline uint32_t RSP_MEM_W_LOAD (uint32_t offset, uint32_t addr) {
3331 uint32_t out;
3432 for (int i = 0 ; i < 4 ; i++) {
35- reinterpret_cast <uint8_t *>(&out)[i ^ 3 ] = RSP_MEM_BU (offset + i, addr);
33+ reinterpret_cast <uint8_t *>(&out)[i ^ 3 ] = RSP_MEM_BU (offset + i, addr);
3634 }
3735 return out;
3836}
3937
4038static inline void RSP_MEM_W_STORE (uint32_t offset, uint32_t addr, uint32_t val) {
4139 for (int i = 0 ; i < 4 ; i++) {
42- RSP_MEM_BU (offset + i, addr) = reinterpret_cast <uint8_t *>(&val)[i ^ 3 ];
40+ RSP_MEM_BU (offset + i, addr) = reinterpret_cast <uint8_t *>(&val)[i ^ 3 ];
4341 }
4442}
4543
4644static inline uint32_t RSP_MEM_HU_LOAD (uint32_t offset, uint32_t addr) {
4745 uint16_t out;
4846 for (int i = 0 ; i < 2 ; i++) {
49- reinterpret_cast <uint8_t *>(&out)[(i + 2 ) ^ 3 ] = RSP_MEM_BU (offset + i, addr);
47+ reinterpret_cast <uint8_t *>(&out)[(i + 2 ) ^ 3 ] = RSP_MEM_BU (offset + i, addr);
5048 }
5149 return out;
5250}
5351
5452static inline uint32_t RSP_MEM_H_LOAD (uint32_t offset, uint32_t addr) {
5553 int16_t out;
5654 for (int i = 0 ; i < 2 ; i++) {
57- reinterpret_cast <uint8_t *>(&out)[(i + 2 ) ^ 3 ] = RSP_MEM_BU (offset + i, addr);
55+ reinterpret_cast <uint8_t *>(&out)[(i + 2 ) ^ 3 ] = RSP_MEM_BU (offset + i, addr);
5856 }
5957 return out;
6058}
6159
6260static inline void RSP_MEM_H_STORE (uint32_t offset, uint32_t addr, uint32_t val) {
6361 for (int i = 0 ; i < 2 ; i++) {
64- RSP_MEM_BU (offset + i, addr) = reinterpret_cast <uint8_t *>(&val)[(i + 2 ) ^ 3 ];
62+ RSP_MEM_BU (offset + i, addr) = reinterpret_cast <uint8_t *>(&val)[(i + 2 ) ^ 3 ];
6563 }
6664}
6765
68- #define RSP_ADD32 (a, b ) \
69- ((int32_t )((a) + (b)))
66+ #define RSP_ADD32 (a, b ) ((int32_t )((a) + (b)))
7067
71- #define RSP_SUB32 (a, b ) \
72- ((int32_t )((a) - (b)))
68+ #define RSP_SUB32 (a, b ) ((int32_t )((a) - (b)))
7369
74- #define RSP_SIGNED (val ) \
75- ((int32_t )(val))
70+ #define RSP_SIGNED (val ) ((int32_t )(val))
7671
7772#define SET_DMA_DMEM (dmem_addr ) dma_dmem_address = (dmem_addr)
7873#define SET_DMA_DRAM (dram_addr ) dma_dram_address = (dram_addr)
7974#define DO_DMA_READ (rd_len ) dma_rdram_to_dmem(rdram, dma_dmem_address, dma_dram_address, (rd_len))
8075#define DO_DMA_WRITE (wr_len ) dma_dmem_to_rdram(rdram, dma_dmem_address, dma_dram_address, (wr_len))
8176
82- static inline void dma_rdram_to_dmem (uint8_t * rdram, uint32_t dmem_addr, uint32_t dram_addr, uint32_t rd_len) {
77+ static inline void dma_rdram_to_dmem (uint8_t * rdram, uint32_t dmem_addr, uint32_t dram_addr, uint32_t rd_len) {
8378 rd_len += 1 ; // Read length is inclusive
8479 dram_addr &= 0xFFFFF8 ;
8580 assert (dmem_addr + rd_len <= 0x1000 );
@@ -88,7 +83,7 @@ static inline void dma_rdram_to_dmem(uint8_t* rdram, uint32_t dmem_addr, uint32_
8883 }
8984}
9085
91- static inline void dma_dmem_to_rdram (uint8_t * rdram, uint32_t dmem_addr, uint32_t dram_addr, uint32_t wr_len) {
86+ static inline void dma_dmem_to_rdram (uint8_t * rdram, uint32_t dmem_addr, uint32_t dram_addr, uint32_t wr_len) {
9287 wr_len += 1 ; // Write length is inclusive
9388 dram_addr &= 0xFFFFF8 ;
9489 assert (dmem_addr + wr_len <= 0x1000 );
@@ -100,24 +95,26 @@ static inline void dma_dmem_to_rdram(uint8_t* rdram, uint32_t dmem_addr, uint32_
10095namespace recomp {
10196 namespace rsp {
10297 struct callbacks_t {
103- using get_rsp_microcode_t = RspUcodeFunc*(const OSTask* task);
98+ using get_rsp_microcode_t = RspUcodeFunc *(const OSTask * task);
10499
105100 /* *
106101 * Return a function pointer to the corresponding RSP microcode function for the given `task_type`.
107102 *
108- * The full OSTask (`task` parameter) is passed in case the `task_type` number is not enough information to distinguish out the exact microcode function.
103+ * The full OSTask (`task` parameter) is passed in case the `task_type` number is not enough information to distinguish out the
104+ * exact microcode function.
109105 *
110- * This function is allowed to return `nullptr` if no microcode matches the specified task. In this case a message will be printed to stderr and the program will exit.
106+ * This function is allowed to return `nullptr` if no microcode matches the specified task. In this case a message will be
107+ * printed to stderr and the program will exit.
111108 */
112- get_rsp_microcode_t * get_rsp_microcode;
109+ get_rsp_microcode_t * get_rsp_microcode;
113110 };
114111
115112 void set_callbacks (const callbacks_t & callbacks);
116113
117114 void constants_init ();
118115
119- bool run_task (uint8_t * rdram, const OSTask* task);
120- }
121- }
116+ bool run_task (uint8_t * rdram, const OSTask * task);
117+ } // namespace rsp
118+ } // namespace recomp
122119
123120#endif
0 commit comments