Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/chip/spc7110/spc7110.hpp
2 views
1
//SPC7110 emulator - version 0.05 (2011-06-27)
2
//Copyright (c) 2008-2011, byuu and neviksti
3
4
class SPC7110 {
5
public:
6
uint8* rtc; //[20];
7
unsigned data_rom_offset;
8
9
void init();
10
void load();
11
void unload();
12
void power();
13
void reset();
14
15
unsigned datarom_addr(unsigned addr);
16
17
unsigned data_pointer();
18
unsigned data_adjust();
19
unsigned data_increment();
20
void set_data_pointer(unsigned addr);
21
void set_data_adjust(unsigned addr);
22
23
void update_time(int offset = 0);
24
time_t create_time();
25
26
uint8 mmio_read(unsigned addr);
27
void mmio_write(unsigned addr, uint8 data);
28
29
uint8 mcu_read(unsigned addr);
30
void mcu_write(unsigned addr, uint8 data);
31
32
uint8 dcu_read(unsigned);
33
void dcu_write(unsigned, uint8);
34
35
uint8 ram_read(unsigned addr);
36
void ram_write(unsigned addr, uint8 data);
37
38
//spc7110decomp
39
void decomp_init();
40
uint8 decomp_read();
41
42
void serialize(serializer&);
43
SPC7110();
44
~SPC7110();
45
void initialize();
46
47
private:
48
//==================
49
//decompression unit
50
//==================
51
uint8 r4801; //compression table low
52
uint8 r4802; //compression table high
53
uint8 r4803; //compression table bank
54
uint8 r4804; //compression table index
55
uint8 r4805; //decompression buffer index low
56
uint8 r4806; //decompression buffer index high
57
uint8 r4807; //???
58
uint8 r4808; //???
59
uint8 r4809; //compression length low
60
uint8 r480a; //compression length high
61
uint8 r480b; //decompression control register
62
uint8 r480c; //decompression status
63
64
#include "decomp.hpp"
65
Decomp decomp;
66
67
//==============
68
//data port unit
69
//==============
70
uint8 r4811; //data pointer low
71
uint8 r4812; //data pointer high
72
uint8 r4813; //data pointer bank
73
uint8 r4814; //data adjust low
74
uint8 r4815; //data adjust high
75
uint8 r4816; //data increment low
76
uint8 r4817; //data increment high
77
uint8 r4818; //data port control register
78
79
uint8 r481x;
80
81
bool r4814_latch;
82
bool r4815_latch;
83
84
//=========
85
//math unit
86
//=========
87
uint8 r4820; //16-bit multiplicand B0, 32-bit dividend B0
88
uint8 r4821; //16-bit multiplicand B1, 32-bit dividend B1
89
uint8 r4822; //32-bit dividend B2
90
uint8 r4823; //32-bit dividend B3
91
uint8 r4824; //16-bit multiplier B0
92
uint8 r4825; //16-bit multiplier B1
93
uint8 r4826; //16-bit divisor B0
94
uint8 r4827; //16-bit divisor B1
95
uint8 r4828; //32-bit product B0, 32-bit quotient B0
96
uint8 r4829; //32-bit product B1, 32-bit quotient B1
97
uint8 r482a; //32-bit product B2, 32-bit quotient B2
98
uint8 r482b; //32-bit product B3, 32-bit quotient B3
99
uint8 r482c; //16-bit remainder B0
100
uint8 r482d; //16-bit remainder B1
101
uint8 r482e; //math control register
102
uint8 r482f; //math status
103
104
//===================
105
//memory mapping unit
106
//===================
107
uint8 r4830; //SRAM write enable
108
uint8 r4831; //$[d0-df]:[0000-ffff] mapping
109
uint8 r4832; //$[e0-ef]:[0000-ffff] mapping
110
uint8 r4833; //$[f0-ff]:[0000-ffff] mapping
111
uint8 r4834; //???
112
113
unsigned dx_offset;
114
unsigned ex_offset;
115
unsigned fx_offset;
116
117
//====================
118
//real-time clock unit
119
//====================
120
uint8 r4840; //RTC latch
121
uint8 r4841; //RTC index/data port
122
uint8 r4842; //RTC status
123
124
enum RTC_State { RTCS_Inactive, RTCS_ModeSelect, RTCS_IndexSelect, RTCS_Write };
125
enum RTC_Mode { RTCM_Linear = 0x03, RTCM_Indexed = 0x0c };
126
unsigned rtc_state;
127
unsigned rtc_mode;
128
unsigned rtc_index;
129
130
static const unsigned months[12];
131
};
132
133
extern SPC7110 spc7110;
134
135