Skip to content

Commit ffc02dd

Browse files
committed
Format librecomp
1 parent 716f786 commit ffc02dd

23 files changed

+306
-267
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#ifdef __GNUC__
2-
#pragma GCC diagnostic ignored "-Wunused-variable"
3-
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
2+
# pragma GCC diagnostic ignored "-Wunused-variable"
3+
# pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
44
#endif

librecomp/include/recomp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef __RECOMP_H__
22
#define __RECOMP_H__
33

4-
#include <stdlib.h>
5-
#include <stdint.h>
6-
#include <math.h>
74
#include <assert.h>
5+
#include <math.h>
6+
#include <stdint.h>
7+
#include <stdlib.h>
88

99
typedef uint64_t gpr;
1010

librecomp/include/recomp_game.h

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef __RECOMP_GAME__
22
#define __RECOMP_GAME__
33

4-
#include <vector>
54
#include <filesystem>
5+
#include <vector>
66

77
#include "recomp.h"
88
#include "rsp.h"
@@ -21,29 +21,36 @@ namespace recomp {
2121

2222
std::u8string stored_filename() const;
2323
};
24-
enum class RomValidationError {
25-
Good,
26-
FailedToOpen,
27-
NotARom,
28-
IncorrectRom,
29-
NotYet,
30-
IncorrectVersion,
31-
OtherError
32-
};
33-
void register_config_path(std::filesystem::path path);
34-
bool register_game(const recomp::GameEntry& entry);
35-
void register_patch(const char* patch, std::size_t size);
36-
void check_all_stored_roms();
37-
bool load_stored_rom(std::u8string& game_id);
38-
RomValidationError select_rom(const std::filesystem::path& rom_path, std::u8string& game_id);
39-
bool is_rom_valid(std::u8string& game_id);
40-
bool is_rom_loaded();
41-
void set_rom_contents(std::vector<uint8_t>&& new_rom);
42-
void do_rom_read(uint8_t* rdram, gpr ram_address, uint32_t physical_addr, size_t num_bytes);
43-
void do_rom_pio(uint8_t* rdram, gpr ram_address, uint32_t physical_addr);
44-
void start(ultramodern::WindowHandle window_handle, const recomp::rsp::callbacks_t& rsp_callbacks, const ultramodern::audio_callbacks_t& audio_callbacks, const ultramodern::input_callbacks_t& input_callbacks, const ultramodern::gfx_callbacks_t& gfx_callbacks, const ultramodern::events::callbacks_t& thread_callbacks, const ultramodern::error_handling::callbacks_t& error_handling_callbacks_);
45-
void start_game(const std::u8string& game_id);
46-
std::u8string current_game_id();
47-
}
24+
enum class RomValidationError {
25+
Good,
26+
FailedToOpen,
27+
NotARom,
28+
IncorrectRom,
29+
NotYet,
30+
IncorrectVersion,
31+
OtherError
32+
};
33+
34+
void register_config_path(std::filesystem::path path);
35+
bool register_game(const recomp::GameEntry& entry);
36+
void register_patch(const char* patch, std::size_t size);
37+
void check_all_stored_roms();
38+
bool load_stored_rom(std::u8string& game_id);
39+
RomValidationError select_rom(const std::filesystem::path& rom_path, std::u8string& game_id);
40+
bool is_rom_valid(std::u8string& game_id);
41+
bool is_rom_loaded();
42+
void set_rom_contents(std::vector<uint8_t>&& new_rom);
43+
void do_rom_read(uint8_t* rdram, gpr ram_address, uint32_t physical_addr, size_t num_bytes);
44+
void do_rom_pio(uint8_t* rdram, gpr ram_address, uint32_t physical_addr);
45+
46+
void start(
47+
ultramodern::WindowHandle window_handle, const recomp::rsp::callbacks_t& rsp_callbacks,
48+
const ultramodern::audio_callbacks_t& audio_callbacks, const ultramodern::input_callbacks_t& input_callbacks,
49+
const ultramodern::gfx_callbacks_t& gfx_callbacks, const ultramodern::events::callbacks_t& thread_callbacks,
50+
const ultramodern::error_handling::callbacks_t& error_handling_callbacks_);
51+
void start_game(const std::u8string& game_id);
52+
53+
std::u8string current_game_id();
54+
} // namespace recomp
4855

4956
#endif

librecomp/include/recomp_helpers.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ T _arg(uint8_t* rdram, recomp_context* ctx) {
1515
}
1616
else {
1717
// static_assert in else workaround
18-
[] <bool flag = false>() {
18+
[]<bool flag = false>() {
1919
static_assert(flag, "Floats in a2/a3 not supported");
20-
}();
20+
}
21+
();
2122
}
2223
}
2324
else if constexpr (std::is_pointer_v<T>) {
24-
static_assert (!std::is_pointer_v<std::remove_pointer_t<T>>, "Double pointers not supported");
25+
static_assert(!std::is_pointer_v<std::remove_pointer_t<T>>, "Double pointers not supported");
2526
return TO_PTR(std::remove_pointer_t<T>, raw_arg);
2627
}
2728
else if constexpr (std::is_integral_v<T>) {
@@ -30,13 +31,14 @@ T _arg(uint8_t* rdram, recomp_context* ctx) {
3031
}
3132
else {
3233
// static_assert in else workaround
33-
[] <bool flag = false>() {
34+
[]<bool flag = false>() {
3435
static_assert(flag, "Unsupported type");
35-
}();
36+
}
37+
();
3638
}
3739
}
3840

39-
template <typename T>
41+
template<typename T>
4042
void _return(recomp_context* ctx, T val) {
4143
static_assert(sizeof(T) <= 4 && "Only 32-bit value returns supported currently");
4244
if (std::is_same_v<T, float>) {

librecomp/include/recomp_overlays.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __RECOMP_OVERLAYS_H__
33

44
#include <cstdint>
5+
56
#include "sections.h"
67

78
namespace recomp {
@@ -19,7 +20,7 @@ namespace recomp {
1920
void register_overlays(const overlay_section_table_data_t& sections, const overlays_by_index_t& overlays);
2021
void register_patch_section(SectionTableEntry* code_sections);
2122
void load_patch_functions();
22-
};
23+
}; // namespace recomp
2324

2425
extern "C" void load_overlays(uint32_t rom, int32_t ram_addr, uint32_t size);
2526
extern "C" void unload_overlays(int32_t ram_addr, uint32_t size);

librecomp/include/rsp.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
#include <cstdio>
55

6-
#include "rsp_vu.h"
76
#include "recomp.h"
7+
#include "rsp_vu.h"
8+
89
#include "ultramodern/ultra64.h"
910

1011
// TODO: Move these to recomp namespace?
@@ -23,11 +24,9 @@ extern uint8_t dmem[];
2324
extern uint16_t rspReciprocals[512];
2425
extern uint16_t rspInverseSquareRoots[512];
2526

26-
#define RSP_MEM_B(offset, addr) \
27-
(*reinterpret_cast<int8_t*>(dmem + (0xFFF & (((offset) + (addr)) ^ 3))))
27+
#define RSP_MEM_B(offset, addr) (*reinterpret_cast<int8_t*>(dmem + (0xFFF & (((offset) + (addr)) ^ 3))))
2828

29-
#define RSP_MEM_BU(offset, addr) \
30-
(*reinterpret_cast<uint8_t*>(dmem + (0xFFF & (((offset) + (addr)) ^ 3))))
29+
#define RSP_MEM_BU(offset, addr) (*reinterpret_cast<uint8_t*>(dmem + (0xFFF & (((offset) + (addr)) ^ 3))))
3130

3231
static inline uint32_t RSP_MEM_W_LOAD(uint32_t offset, uint32_t addr) {
3332
uint32_t out;
@@ -65,14 +64,11 @@ static inline void RSP_MEM_H_STORE(uint32_t offset, uint32_t addr, uint32_t val)
6564
}
6665
}
6766

68-
#define RSP_ADD32(a, b) \
69-
((int32_t)((a) + (b)))
67+
#define RSP_ADD32(a, b) ((int32_t)((a) + (b)))
7068

71-
#define RSP_SUB32(a, b) \
72-
((int32_t)((a) - (b)))
69+
#define RSP_SUB32(a, b) ((int32_t)((a) - (b)))
7370

74-
#define RSP_SIGNED(val) \
75-
((int32_t)(val))
71+
#define RSP_SIGNED(val) ((int32_t)(val))
7672

7773
#define SET_DMA_DMEM(dmem_addr) dma_dmem_address = (dmem_addr)
7874
#define SET_DMA_DRAM(dram_addr) dma_dram_address = (dram_addr)
@@ -105,9 +101,11 @@ namespace recomp {
105101
/**
106102
* Return a function pointer to the corresponding RSP microcode function for the given `task_type`.
107103
*
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.
104+
* The full OSTask (`task` parameter) is passed in case the `task_type` number is not enough information to distinguish out the
105+
* exact microcode function.
109106
*
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.
107+
* This function is allowed to return `nullptr` if no microcode matches the specified task. In this case a message will be
108+
* printed to stderr and the program will exit.
111109
*/
112110
get_rsp_microcode_t* get_rsp_microcode;
113111
};
@@ -117,7 +115,7 @@ namespace recomp {
117115
void constants_init();
118116

119117
bool run_task(uint8_t* rdram, const OSTask* task);
120-
}
121-
}
118+
} // namespace rsp
119+
} // namespace recomp
122120

123121
#endif

librecomp/include/sections.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __SECTIONS_H__
33

44
#include <stdint.h>
5+
56
#include "recomp.h"
67

78
#define ARRLEN(x) (sizeof(x) / sizeof((x)[0]))
@@ -15,7 +16,7 @@ typedef struct {
1516
uint32_t rom_addr;
1617
uint32_t ram_addr;
1718
uint32_t size;
18-
FuncEntry *funcs;
19+
FuncEntry* funcs;
1920
size_t num_funcs;
2021
size_t index;
2122
} SectionTableEntry;

librecomp/src/ai.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
extern "C" void osAiSetFrequency_recomp(uint8_t* rdram, recomp_context* ctx) {
1010
uint32_t freq = ctx->r4;
1111
// This makes actual audio frequency more accurate to console, but may not be desirable
12-
//uint32_t dacRate = (uint32_t)(((float)VI_NTSC_CLOCK / freq) + 0.5f);
13-
//freq = VI_NTSC_CLOCK / dacRate;
12+
// uint32_t dacRate = (uint32_t)(((float)VI_NTSC_CLOCK / freq) + 0.5f);
13+
// freq = VI_NTSC_CLOCK / dacRate;
1414
ctx->r2 = freq;
1515
ultramodern::set_audio_frequency(freq);
1616
}

librecomp/src/cont.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#include <ultramodern/ultramodern.hpp>
1+
#include "ultramodern/ultramodern.hpp"
2+
23
#include "recomp_helpers.h"
34

45
static ultramodern::input_callbacks_t input_callbacks;
@@ -18,7 +19,9 @@ extern "C" void recomp_measure_latency(uint8_t* rdram, recomp_context* ctx) {
1819
}
1920

2021
void ultramodern::measure_input_latency() {
21-
// printf("Delta: %ld micros\n", std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - input_poll_time));
22+
#if 0
23+
// printf("Delta: %ld micros\n", std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - input_poll_time));
24+
#endif
2225
}
2326

2427
void set_input_callbacks(const ultramodern::input_callbacks_t& callbacks) {
@@ -36,8 +39,8 @@ extern "C" void osContInit_recomp(uint8_t* rdram, recomp_context* ctx) {
3639

3740
// Mark controller 0 as present
3841
MEM_H(0, status) = 0x0005; // type: CONT_TYPE_NORMAL (from joybus)
39-
MEM_B(2, status) = 0x00; // status: 0 (from joybus)
40-
MEM_B(3, status) = 0x00; // errno: 0 (from libultra)
42+
MEM_B(2, status) = 0x00; // status: 0 (from joybus)
43+
MEM_B(3, status) = 0x00; // errno: 0 (from libultra)
4144

4245
max_controllers = 4;
4346

@@ -85,17 +88,17 @@ extern "C" void osContGetReadData_recomp(uint8_t* rdram, recomp_context* ctx) {
8588
}
8689
}
8790

88-
extern "C" void osContStartQuery_recomp(uint8_t * rdram, recomp_context * ctx) {
91+
extern "C" void osContStartQuery_recomp(uint8_t* rdram, recomp_context* ctx) {
8992
ultramodern::send_si_message(rdram);
9093
}
9194

92-
extern "C" void osContGetQuery_recomp(uint8_t * rdram, recomp_context * ctx) {
95+
extern "C" void osContGetQuery_recomp(uint8_t* rdram, recomp_context* ctx) {
9396
PTR(void) status = _arg<0, PTR(void)>(rdram, ctx);
9497

9598
// Mark controller 0 as present
9699
MEM_H(0, status) = 0x0005; // type: CONT_TYPE_NORMAL (from joybus)
97-
MEM_B(2, status) = 0x01; // status: 0x01 (from joybus, indicates that a pak is plugged into the controller)
98-
MEM_B(3, status) = 0x00; // errno: 0 (from libultra)
100+
MEM_B(2, status) = 0x01; // status: 0x01 (from joybus, indicates that a pak is plugged into the controller)
101+
MEM_B(3, status) = 0x00; // errno: 0 (from libultra)
99102

100103
// Mark controllers 1-3 as not connected
101104
for (size_t controller = 1; controller < max_controllers; controller++) {

librecomp/src/eep.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "recomp.h"
2-
#include <ultramodern/ultra64.h>
2+
3+
#include "ultramodern/ultra64.h"
34

45
void save_write(RDRAM_ARG PTR(void) rdram_address, uint32_t offset, uint32_t count);
56
void save_read(RDRAM_ARG PTR(void) rdram_address, uint32_t offset, uint32_t count);
@@ -15,7 +16,7 @@ extern "C" void osEepromProbe_recomp(uint8_t* rdram, recomp_context* ctx) {
1516
}
1617

1718
extern "C" void osEepromWrite_recomp(uint8_t* rdram, recomp_context* ctx) {
18-
assert(false);// ctx->r2 = 8; // CONT_NO_RESPONSE_ERROR
19+
assert(false); // ctx->r2 = 8; // CONT_NO_RESPONSE_ERROR
1920
}
2021

2122
extern "C" void osEepromLongWrite_recomp(uint8_t* rdram, recomp_context* ctx) {
@@ -32,7 +33,7 @@ extern "C" void osEepromLongWrite_recomp(uint8_t* rdram, recomp_context* ctx) {
3233
}
3334

3435
extern "C" void osEepromRead_recomp(uint8_t* rdram, recomp_context* ctx) {
35-
assert(false);// ctx->r2 = 8; // CONT_NO_RESPONSE_ERROR
36+
assert(false); // ctx->r2 = 8; // CONT_NO_RESPONSE_ERROR
3637
}
3738

3839
extern "C" void osEepromLongRead_recomp(uint8_t* rdram, recomp_context* ctx) {

0 commit comments

Comments
 (0)