forked from libretro/mupen64plus-libretro-nx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsp_dump.cpp
90 lines (72 loc) · 1.47 KB
/
rsp_dump.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "rsp_dump.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <assert.h>
static FILE *file;
static bool in_trace;
void rsp_open_trace(const char *path)
{
file = fopen(path, "wb");
fwrite("RSPDUMP1", 1, 8, file);
}
void rsp_close_trace(void)
{
if (file)
{
fwrite("EOF ", 1, 8, file);
fclose(file);
}
file = nullptr;
}
void rsp_dump_begin_trace(void)
{
if (!file)
return;
fwrite("BEGIN ", 1, 8, file);
in_trace = true;
}
int rsp_dump_recording_trace(void)
{
return in_trace;
}
void rsp_dump_end_trace(void)
{
if (!file)
return;
fwrite("END ", 1, 8, file);
in_trace = false;
}
void rsp_dump_block(const char *tag, const void *data, size_t size)
{
if (!file)
return;
uint32_t size_data = size;
assert(strlen(tag) == 8);
fwrite(tag, 1, strlen(tag), file);
fwrite(&size_data, sizeof(size_data), 1, file);
fwrite(data, size, 1, file);
}
void rsp_dump_begin_read_dma(void)
{
if (!file)
return;
fwrite("BEGINDMA", 1, 8, file);
}
void rsp_dump_poke_mem(unsigned base, const void *data, size_t size)
{
if (!file)
return;
uint32_t size_data = size;
uint32_t base_data = base;
fwrite("POKE ", 1, 8, file);
fwrite(&base_data, sizeof(base_data), 1, file);
fwrite(&size_data, sizeof(size_data), 1, file);
fwrite(data, size, 1, file);
}
void rsp_dump_end_read_dma(void)
{
if (!file)
return;
fwrite("ENDDMA ", 1, 8, file);
}