1 | /***** |
2 | * SPC7110 emulator - version 0.03 (2008-08-10) |
3 | * Copyright (c) 2008, byuu and neviksti |
4 | * |
5 | * Permission to use, copy, modify, and/or distribute this software for any |
6 | * purpose with or without fee is hereby granted, provided that the above |
7 | * copyright notice and this permission notice appear in all copies. |
8 | * |
9 | * The software is provided "as is" and the author disclaims all warranties |
10 | * with regard to this software including all implied warranties of |
11 | * merchantibility and fitness, in no event shall the author be liable for |
12 | * any special, direct, indirect, or consequential damages or any damages |
13 | * whatsoever resulting from loss of use, data or profits, whether in an |
14 | * action of contract, negligence or other tortious action, arising out of |
15 | * or in connection with the use or performance of this software. |
16 | *****/ |
17 | |
18 | |
19 | #ifndef _SPC7110EMU_H_ |
20 | #define _SPC7110EMU_H_ |
21 | |
22 | #include "spc7110dec.h" |
23 | |
24 | class SPC7110 { |
25 | public: |
26 | void init(); |
27 | void enable(); |
28 | void power(); |
29 | void reset(); |
30 | |
31 | unsigned datarom_addr(unsigned addr); |
32 | |
33 | unsigned data_pointer(); |
34 | unsigned data_adjust(); |
35 | unsigned data_increment(); |
36 | void set_data_pointer(unsigned addr); |
37 | void set_data_adjust(unsigned addr); |
38 | |
39 | void update_time(int offset = 0); |
40 | time_t create_time(); |
41 | |
42 | uint8 mmio_read (unsigned addr); |
43 | void mmio_write(unsigned addr, uint8 data); |
44 | |
45 | uint8 read (unsigned addr); |
46 | void write(unsigned addr, uint8 data); |
47 | |
48 | //spc7110decomp |
49 | void decomp_init(); |
50 | uint8 decomp_read(); |
51 | |
52 | SPC7110(); |
53 | |
54 | //================== |
55 | //decompression unit |
56 | //================== |
57 | uint8 r4801; //compression table low |
58 | uint8 r4802; //compression table high |
59 | uint8 r4803; //compression table bank |
60 | uint8 r4804; //compression table index |
61 | uint8 r4805; //decompression buffer index low |
62 | uint8 r4806; //decompression buffer index high |
63 | uint8 r4807; //??? |
64 | uint8 r4808; //??? |
65 | uint8 r4809; //compression length low |
66 | uint8 r480a; //compression length high |
67 | uint8 r480b; //decompression control register |
68 | uint8 r480c; //decompression status |
69 | |
70 | SPC7110Decomp decomp; |
71 | |
72 | //============== |
73 | //data port unit |
74 | //============== |
75 | uint8 r4811; //data pointer low |
76 | uint8 r4812; //data pointer high |
77 | uint8 r4813; //data pointer bank |
78 | uint8 r4814; //data adjust low |
79 | uint8 r4815; //data adjust high |
80 | uint8 r4816; //data increment low |
81 | uint8 r4817; //data increment high |
82 | uint8 r4818; //data port control register |
83 | |
84 | uint8 r481x; |
85 | |
86 | bool r4814_latch; |
87 | bool r4815_latch; |
88 | |
89 | //========= |
90 | //math unit |
91 | //========= |
92 | uint8 r4820; //16-bit multiplicand B0, 32-bit dividend B0 |
93 | uint8 r4821; //16-bit multiplicand B1, 32-bit dividend B1 |
94 | uint8 r4822; //32-bit dividend B2 |
95 | uint8 r4823; //32-bit dividend B3 |
96 | uint8 r4824; //16-bit multiplier B0 |
97 | uint8 r4825; //16-bit multiplier B1 |
98 | uint8 r4826; //16-bit divisor B0 |
99 | uint8 r4827; //16-bit divisor B1 |
100 | uint8 r4828; //32-bit product B0, 32-bit quotient B0 |
101 | uint8 r4829; //32-bit product B1, 32-bit quotient B1 |
102 | uint8 r482a; //32-bit product B2, 32-bit quotient B2 |
103 | uint8 r482b; //32-bit product B3, 32-bit quotient B3 |
104 | uint8 r482c; //16-bit remainder B0 |
105 | uint8 r482d; //16-bit remainder B1 |
106 | uint8 r482e; //math control register |
107 | uint8 r482f; //math status |
108 | |
109 | //=================== |
110 | //memory mapping unit |
111 | //=================== |
112 | uint8 r4830; //SRAM write enable |
113 | uint8 r4831; //$[d0-df]:[0000-ffff] mapping |
114 | uint8 r4832; //$[e0-ef]:[0000-ffff] mapping |
115 | uint8 r4833; //$[f0-ff]:[0000-ffff] mapping |
116 | uint8 r4834; //??? |
117 | |
118 | unsigned dx_offset; |
119 | unsigned ex_offset; |
120 | unsigned fx_offset; |
121 | |
122 | //==================== |
123 | //real-time clock unit |
124 | //==================== |
125 | uint8 r4840; //RTC latch |
126 | uint8 r4841; //RTC index/data port |
127 | uint8 r4842; //RTC status |
128 | |
129 | enum RTC_State { RTCS_Inactive, RTCS_ModeSelect, RTCS_IndexSelect, RTCS_Write } rtc_state; |
130 | enum RTC_Mode { RTCM_Linear = 0x03, RTCM_Indexed = 0x0c } rtc_mode; |
131 | unsigned rtc_index; |
132 | |
133 | static const unsigned months[12]; |
134 | }; |
135 | |
136 | #endif |
137 | |