1212#define MAX_COMPONENTS 16
1313
1414/* *
15- * A peripheral represents a device that contains emulated components, including
16- * processors, memory units, video producers, audio producers, and input consumers.
17- *
18- * Each peripheral must to describe the components it contains and the system
19- * ROMs it needs.
15+ * A peripheral represents a device that contains emulated hardware components, including
16+ * processors and memory units. Each processor or memory unit may optionally also be a
17+ * video producer, audio producer, and/or input consumer. However, some input consumers are
18+ * neither processors or memory units.
2019 */
2120class Peripheral
2221{
2322 public:
23+ /* *
24+ * Gets the name of this peripheral.
25+ *
26+ * @return the peripheral name
27+ */
2428 const char * GetName () { return peripheralName; }
29+
30+ /* *
31+ * Gets the short name of this peripheral.
32+ *
33+ * @return the short peripheral name
34+ */
2535 const char * GetShortName () { return peripheralShortName; }
2636
27- void AddProcessor (Processor*);
37+ /* *
38+ * Adds a processor to this peripheral.
39+ *
40+ * @param processor the processor to add
41+ */
42+ void AddProcessor (Processor* processor);
43+
44+ /* *
45+ * Gets the number of processors in this peripheral.
46+ *
47+ * @return the number of processors
48+ */
2849 UINT16 GetProcessorCount ();
29- Processor* GetProcessor (UINT16 i);
3050
31- void AddRAM (RAM*);
51+ /* *
52+ * Gets a pointer to the processor indicated by an index.
53+ *
54+ * @param index the index of the processor to return
55+ * @return a pointer to the processor
56+ */
57+ Processor* GetProcessor (UINT16 index);
58+
59+ /* *
60+ * Adds a RAM unit to this peripheral.
61+ *
62+ * @param ram the RAM unit to add
63+ */
64+ void AddRAM (RAM* ram);
65+
66+ /* *
67+ * Gets the number of RAM units in this peripheral.
68+ *
69+ * @return the number of RAM units
70+ */
3271 UINT16 GetRAMCount ();
33- RAM* GetRAM (UINT16 i);
3472
35- void AddROM (ROM*);
73+ /* *
74+ * Gets a pointer to the RAM unit indicated by an index.
75+ *
76+ * @param index the index of the RAM unit to return
77+ * @return a pointer to the RAM unit
78+ */
79+ RAM* GetRAM (UINT16 index);
80+
81+ /* *
82+ * Adds a ROM unit to this peripheral.
83+ *
84+ * @param rom the ROM unit to add
85+ */
86+ void AddROM (ROM* rom);
87+
88+ /* *
89+ * Gets the number of ROM units in this peripheral.
90+ *
91+ * @return the number of ROM units
92+ */
3693 UINT16 GetROMCount ();
37- ROM* GetROM (UINT16 i);
3894
39- void AddVideoProducer (VideoProducer*);
95+ /* *
96+ * Gets a pointer to the ROM unit indicated by an index.
97+ *
98+ * @param index the index of the ROM unit to return
99+ * @return a pointer to the ROM unit
100+ */
101+ ROM* GetROM (UINT16 index);
102+
103+ /* *
104+ * Adds a video producer to this peripheral.
105+ *
106+ * @param vp the video producer to add
107+ */
108+ void AddVideoProducer (VideoProducer* vp);
109+
110+ /* *
111+ * Gets the number of video producers in this peripheral.
112+ *
113+ * @return the number of video producers
114+ */
40115 UINT16 GetVideoProducerCount ();
41- VideoProducer* GetVideoProducer (UINT16 i);
42116
43- void AddAudioProducer (AudioProducer*);
117+ /* *
118+ * Gets a pointer to the video producer indicated by an index.
119+ *
120+ * @param index the index of the video producer to return
121+ * @return a pointer to the video producer
122+ */
123+ VideoProducer* GetVideoProducer (UINT16 index);
124+
125+ /* *
126+ * Adds an audio producer to this peripheral.
127+ *
128+ * @param ap the audio producer to add
129+ */
130+ void AddAudioProducer (AudioProducer* ap);
131+
132+ /* *
133+ * Gets the number of audio producers in this peripheral.
134+ *
135+ * @return the number of audio producers
136+ */
44137 UINT16 GetAudioProducerCount ();
45- AudioProducer* GetAudioProducer (UINT16 i);
46138
139+ /* *
140+ * Gets a pointer to the audio producer indicated by an index.
141+ *
142+ * @param index the index of the audio producer to return
143+ * @return a pointer to the audio producer
144+ */
145+ AudioProducer* GetAudioProducer (UINT16 index);
146+
147+ /* *
148+ * Adds an input consumer to this peripheral.
149+ *
150+ * @param ic the input consumer to add
151+ */
47152 void AddInputConsumer (InputConsumer*);
153+
154+ /* *
155+ * Gets the number of input consumers in this peripheral.
156+ *
157+ * @return the number of input consumers
158+ */
48159 UINT16 GetInputConsumerCount ();
49- InputConsumer* GetInputConsumer (UINT16 i);
160+
161+ /* *
162+ * Gets a pointer to the input consumer indicated by an index.
163+ *
164+ * @param index the index of the input consumer to return
165+ * @return a pointer to the input consumer
166+ */
167+ InputConsumer* GetInputConsumer (UINT16 index);
50168
51169 protected:
170+ /* *
171+ * Constructs a peripheral.
172+ *
173+ * @param name the name of the peripheral
174+ * @param shortName the short name of the peripheral
175+ */
52176 Peripheral (const CHAR* name, const CHAR* shortName)
53177 : processorCount(0 ),
54178 videoProducerCount (0 ),
@@ -58,23 +182,30 @@ class Peripheral
58182 romCount(0 ),
59183 peripheralName(NULL ),
60184 peripheralShortName(NULL )
61- {
62- if (name) {
63- peripheralName = new CHAR[strlen (name)+1 ];
64- strcpy (peripheralName, name);
65- }
66- if (shortName) {
67- peripheralShortName = new CHAR[strlen (shortName)+1 ];
68- strcpy (peripheralShortName, shortName);
69- }
185+ {
186+ if (name) {
187+ peripheralName = new CHAR[strlen (name)+1 ];
188+ strcpy (peripheralName, name);
70189 }
190+ if (shortName) {
191+ peripheralShortName = new CHAR[strlen (shortName)+1 ];
192+ strcpy (peripheralShortName, shortName);
193+ }
194+ }
195+
196+ /* *
197+ * Destroys the peripheral.
198+ */
71199 ~Peripheral ()
72200 {
73201 delete[] peripheralShortName;
74202 delete[] peripheralName;
75203 }
76204
77- // rip exposes peripheral name as mutable, so we leave it protected here
205+ /* *
206+ * The peripheral name. The Rip class exposes the periphal name as mutable, so we leave
207+ * it exposed as protected access here. This will probably change in the future.
208+ */
78209 char * peripheralName;
79210
80211 private:
0 commit comments