├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── platforms
├── macosx
│ └── Geardrive
│ │ ├── .dep.inc
│ │ └── Geardrive.pro
└── qt-shared
│ ├── About.ui
│ ├── InputSettings.ui
│ ├── MainWindow.ui
│ ├── SoundSettings.ui
│ ├── VideoSettings.ui
│ ├── about.cpp
│ ├── about.h
│ ├── emulator.cpp
│ ├── emulator.h
│ ├── gl_frame.cpp
│ ├── gl_frame.h
│ ├── input_settings.cpp
│ ├── input_settings.h
│ ├── main.cpp
│ ├── main_window.cpp
│ ├── main_window.h
│ ├── render_thread.cpp
│ ├── render_thread.h
│ ├── sound_settings.cpp
│ ├── sound_settings.h
│ ├── video_settings.cpp
│ └── video_settings.h
└── src
├── GZ80
├── gz80_core.cpp
├── gz80_core.h
├── gz80_core_inl.h
├── gz80_definitions.h
├── gz80_eight_bit_register.h
├── gz80_ioports_interface.h
├── gz80_memory_interface.h
├── gz80_opcode_cb_names.h
├── gz80_opcode_daa.h
├── gz80_opcode_dd_names.h
├── gz80_opcode_ddcb_names.h
├── gz80_opcode_ed_names.h
├── gz80_opcode_fd_names.h
├── gz80_opcode_fdcb_names.h
├── gz80_opcode_names.h
├── gz80_opcode_timing.h
├── gz80_opcode_xx_names.h
├── gz80_opcodes.cpp
├── gz80_opcodes_cb.cpp
├── gz80_opcodes_ed.cpp
└── gz80_sixteen_bit_register.h
├── audio.cpp
├── audio.h
├── cartridge.cpp
├── cartridge.h
├── definitions.h
├── geardrive.h
├── geardrive_core.cpp
├── geardrive_core.h
├── input.cpp
├── input.h
├── miniz
└── miniz.c
├── video.cpp
└── video.h
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: drhelius
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Netbeans files
2 | dist/
3 | build/
4 | private/
5 |
6 | # Mac files
7 | *.DS_Store
8 |
9 | # Visual Studio files
10 | ipch/
11 | [Oo]bj
12 | [Bb]in
13 | *.[Cc]ache
14 | *.obj
15 | *.o
16 | *.exe
17 | *.exp
18 | *.pdb
19 | *.dll
20 | *.user
21 | *.aps
22 | *.pch
23 | *.sdf
24 | *.opensdf
25 | *.vspscc
26 | *_i.c
27 | *_p.c
28 | *.ncb
29 | *.suo
30 | *.tlb
31 | *.tlh
32 | *.bak
33 | *.ilk
34 | *.log
35 | *.zip
36 | *[Dd]ebug*/
37 | *.lib
38 | *.sbr
39 | *.app
40 | Thumbs.db
41 | *[Rr]elease*/
42 | [Tt]est[Rr]esults/
43 | _UpgradeReport_Files/
44 | _ReSharper.*/
45 | desktop.ini
46 |
47 | # Misc files
48 | *.txt
49 | *.ini
50 | *.cfg
51 | *.gen
52 | *.md
53 | *.bin
54 | *.zip
55 | *.geardrive
56 |
57 | # Qt Ignores
58 | moc_*.cpp
59 | qt-Debug.mk
60 | qt-Release.mk
61 | ui_*.h
62 | .qmake.stash
63 | qrc_*.cpp
64 |
65 | #Xcode
66 | *.xcuserstate
67 | xcuserdata/
68 | *.xcexplist
69 | *.xcsettings
70 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Geardrive (currently in development)
2 | =======
3 | Copyright © 2014 by Ignacio Sanchez
4 |
5 | ----------
6 | [](https://travis-ci.org/drhelius/Gearnes)
7 |
8 | *This is a work in progress project, not intended to be used right now.*
9 |
10 | Geardrive is a Sega Genesis / Mega Drive emulator written in C++ that runs on iOS, Raspberry Pi, Mac, Windows and Linux.
11 |
12 | Follow me on Twitter for updates: http://twitter.com/drhelius
13 |
14 | ----------
15 |
16 | Features
17 | --------
18 | - Highly accurate Z80 core.
19 | - Integrated disassembler. It can dump the full disassembled memory to a text file or access it in real time.
20 | - Compressed rom support (ZIP deflate).
21 | - Multi platform. Runs on Windows, Linux, Mac OS X, Raspberry Pi and iOS.
22 |
23 | Accuracy Tests
24 | --------------
25 |
26 | Geardrive Z80 core passes all tests in Zexall, including undocumented instructions and behaviours.
27 |
28 | License
29 | -------
30 |
31 | Geardrive - Sega Genesis / Mega Drive Emulator
32 |
33 | Copyright (C) 2014 Ignacio Sanchez
34 |
35 | This program is free software: you can redistribute it and/or modify
36 | it under the terms of the GNU General Public License as published by
37 | the Free Software Foundation, either version 3 of the License, or
38 | any later version.
39 |
40 | This program is distributed in the hope that it will be useful,
41 | but WITHOUT ANY WARRANTY; without even the implied warranty of
42 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 | GNU General Public License for more details.
44 |
45 | You should have received a copy of the GNU General Public License
46 | along with this program. If not, see http://www.gnu.org/licenses/
47 |
48 |
--------------------------------------------------------------------------------
/platforms/macosx/Geardrive/.dep.inc:
--------------------------------------------------------------------------------
1 | # This code depends on make tool being used
2 | DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
3 | ifneq (${DEPFILES},)
4 | include ${DEPFILES}
5 | endif
6 |
--------------------------------------------------------------------------------
/platforms/macosx/Geardrive/Geardrive.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2015-03-20T18:16:12
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | QT += opengl
12 |
13 | TARGET = Geardrive
14 | TEMPLATE = app
15 |
16 | INCLUDEPATH += /usr/local/include
17 | DEPENDPATH += /usr/local/lib
18 |
19 | LIBS += -L/usr/local/lib -lSDL2main -lSDL2
20 |
21 | SOURCES += \
22 | ../../qt-shared/about.cpp \
23 | ../../qt-shared/emulator.cpp \
24 | ../../qt-shared/gl_frame.cpp \
25 | ../../qt-shared/input_settings.cpp \
26 | ../../qt-shared/main_window.cpp \
27 | ../../qt-shared/main.cpp \
28 | ../../qt-shared/render_thread.cpp \
29 | ../../qt-shared/sound_settings.cpp \
30 | ../../qt-shared/video_settings.cpp \
31 | ../../../src/GZ80/gz80_core.cpp \
32 | ../../../src/GZ80/gz80_opcodes.cpp \
33 | ../../../src/GZ80/gz80_opcodes_cb.cpp \
34 | ../../../src/GZ80/gz80_opcodes_ed.cpp \
35 | ../../../src/audio.cpp \
36 | ../../../src/cartridge.cpp \
37 | ../../../src/geardrive_core.cpp \
38 | ../../../src/input.cpp \
39 | ../../../src/video.cpp \
40 | ../../../src/miniz/miniz.c
41 |
42 | HEADERS += \
43 | ../../qt-shared/about.h \
44 | ../../qt-shared/emulator.h \
45 | ../../qt-shared/gl_frame.h \
46 | ../../qt-shared/input_settings.h \
47 | ../../qt-shared/main_window.h \
48 | ../../qt-shared/render_thread.h \
49 | ../../qt-shared/sound_settings.h \
50 | ../../qt-shared/video_settings.h \
51 | ../../../src/GZ80/gz80_core.h \
52 | ../../../src/GZ80/gz80_core_inl.h \
53 | ../../../src/GZ80/gz80_definitions.h \
54 | ../../../src/GZ80/gz80_eight_bit_register.h \
55 | ../../../src/GZ80/gz80_ioports_interface.h \
56 | ../../../src/GZ80/gz80_memory_interface.h \
57 | ../../../src/GZ80/gz80_opcode_cb_names.h \
58 | ../../../src/GZ80/gz80_opcode_daa.h \
59 | ../../../src/GZ80/gz80_opcode_dd_names.h \
60 | ../../../src/GZ80/gz80_opcode_ddcb_names.h \
61 | ../../../src/GZ80/gz80_opcode_ed_names.h \
62 | ../../../src/GZ80/gz80_opcode_fd_names.h \
63 | ../../../src/GZ80/gz80_opcode_fdcb_names.h \
64 | ../../../src/GZ80/gz80_opcode_names.h \
65 | ../../../src/GZ80/gz80_opcode_timing.h \
66 | ../../../src/GZ80/gz80_opcode_xx_names.h \
67 | ../../../src/GZ80/gz80_sixteen_bit_register.h \
68 | ../../../src/audio.h \
69 | ../../../src/cartridge.h \
70 | ../../../src/definitions.h \
71 | ../../../src/geardrive.h \
72 | ../../../src/geardrive_core.h \
73 | ../../../src/input.h \
74 | ../../../src/video.h
75 |
76 | FORMS += \
77 | ../../qt-shared/About.ui \
78 | ../../qt-shared/InputSettings.ui \
79 | ../../qt-shared/MainWindow.ui \
80 | ../../qt-shared/SoundSettings.ui \
81 | ../../qt-shared/VideoSettings.ui
82 |
--------------------------------------------------------------------------------
/platforms/qt-shared/About.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | About
4 |
5 |
6 |
7 | 0
8 | 0
9 | 752
10 | 284
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 10
21 | 731
22 | 261
23 |
24 |
25 |
26 | <html><head/><body><p align="center"><span style=" font-size:16pt; font-weight:600;">Geardrive</span></p><p align="center"><span style=" text-decoration: underline;">Copyright © 2014 by Ignacio Sanchez</span><br/><br/>Geardrive is a Sega Genesis / Mega Drive emulator written in C++.</p><p align="center">The emulator is focused on readability of source code with very high compatibility.</p><p align="center">A lot of effort has gone into this in order to follow OOP and keep it as simple as possible.</p><p><br/></p><p><span style=" font-weight:600;">Official web site: </span><a href="https://github.com/drhelius/Geardrive"><span style=" text-decoration: underline; color:#0000ff;">github.com/drhelius/Geardrive</span></a></p><p><span style=" font-weight:600;">Author website</span>: <a href="http://www.ignaciosanchezgines.com"><span style=" text-decoration: underline; color:#0000ff;">www.ignaciosanchezgines.com</span></a></p></body></html>
27 |
28 |
29 | Qt::RichText
30 |
31 |
32 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
33 |
34 |
35 | true
36 |
37 |
38 |
39 |
40 |
41 | 500
42 | 210
43 | 161
44 | 41
45 |
46 |
47 |
48 | OK
49 |
50 |
51 |
52 |
53 |
54 |
55 | okButton
56 | clicked()
57 | About
58 | accept()
59 |
60 |
61 | 278
62 | 253
63 |
64 |
65 | 96
66 | 254
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/platforms/qt-shared/InputSettings.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | InputSettings
4 |
5 |
6 | Qt::WindowModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 412
13 | 374
14 |
15 |
16 |
17 | Input Settings
18 |
19 |
20 | true
21 |
22 |
23 |
24 |
25 | 50
26 | 330
27 | 341
28 | 32
29 |
30 |
31 |
32 | Qt::Horizontal
33 |
34 |
35 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
36 |
37 |
38 |
39 |
40 |
41 | 10
42 | 10
43 | 391
44 | 141
45 |
46 |
47 |
48 | Player 1
49 |
50 |
51 |
52 |
53 | 270
54 | 20
55 | 111
56 | 22
57 |
58 |
59 |
60 |
61 |
62 |
63 | 10
64 | 20
65 | 62
66 | 16
67 |
68 |
69 |
70 | Up:
71 |
72 |
73 |
74 |
75 |
76 | 70
77 | 20
78 | 111
79 | 22
80 |
81 |
82 |
83 | false
84 |
85 |
86 |
87 |
88 |
89 | 70
90 | 80
91 | 111
92 | 22
93 |
94 |
95 |
96 |
97 |
98 |
99 | 70
100 | 110
101 | 111
102 | 22
103 |
104 |
105 |
106 |
107 |
108 |
109 | 10
110 | 50
111 | 62
112 | 16
113 |
114 |
115 |
116 | Right:
117 |
118 |
119 |
120 |
121 |
122 | 70
123 | 50
124 | 111
125 | 22
126 |
127 |
128 |
129 |
130 |
131 |
132 | 270
133 | 50
134 | 111
135 | 22
136 |
137 |
138 |
139 |
140 |
141 |
142 | 210
143 | 20
144 | 62
145 | 16
146 |
147 |
148 |
149 | 1:
150 |
151 |
152 |
153 |
154 |
155 | 270
156 | 80
157 | 111
158 | 22
159 |
160 |
161 |
162 |
163 |
164 |
165 | 10
166 | 110
167 | 62
168 | 16
169 |
170 |
171 |
172 | Left:
173 |
174 |
175 |
176 |
177 |
178 | 210
179 | 50
180 | 62
181 | 16
182 |
183 |
184 |
185 | 2:
186 |
187 |
188 |
189 |
190 |
191 | 10
192 | 80
193 | 62
194 | 16
195 |
196 |
197 |
198 | Down:
199 |
200 |
201 |
202 |
203 |
204 | 210
205 | 80
206 | 62
207 | 16
208 |
209 |
210 |
211 | Start:
212 |
213 |
214 |
215 |
216 |
217 |
218 | 10
219 | 160
220 | 391
221 | 141
222 |
223 |
224 |
225 | Player 2
226 |
227 |
228 |
229 |
230 | 270
231 | 20
232 | 111
233 | 22
234 |
235 |
236 |
237 |
238 |
239 |
240 | 10
241 | 20
242 | 62
243 | 16
244 |
245 |
246 |
247 | Up:
248 |
249 |
250 |
251 |
252 |
253 | 70
254 | 20
255 | 111
256 | 22
257 |
258 |
259 |
260 | false
261 |
262 |
263 |
264 |
265 |
266 | 70
267 | 80
268 | 111
269 | 22
270 |
271 |
272 |
273 |
274 |
275 |
276 | 70
277 | 110
278 | 111
279 | 22
280 |
281 |
282 |
283 |
284 |
285 |
286 | 10
287 | 50
288 | 62
289 | 16
290 |
291 |
292 |
293 | Right:
294 |
295 |
296 |
297 |
298 |
299 | 70
300 | 50
301 | 111
302 | 22
303 |
304 |
305 |
306 |
307 |
308 |
309 | 270
310 | 50
311 | 111
312 | 22
313 |
314 |
315 |
316 |
317 |
318 |
319 | 210
320 | 20
321 | 62
322 | 16
323 |
324 |
325 |
326 | 1:
327 |
328 |
329 |
330 |
331 |
332 | 10
333 | 110
334 | 62
335 | 16
336 |
337 |
338 |
339 | Left:
340 |
341 |
342 |
343 |
344 |
345 | 210
346 | 50
347 | 62
348 | 16
349 |
350 |
351 |
352 | 2:
353 |
354 |
355 |
356 |
357 |
358 | 10
359 | 80
360 | 62
361 | 16
362 |
363 |
364 |
365 | Down:
366 |
367 |
368 |
369 |
370 |
371 | lineEditUp
372 | lineEditRight
373 | lineEditDown
374 | lineEditLeft
375 | lineEdit1
376 | lineEdit2
377 | lineEditStart
378 | buttonBox
379 |
380 |
381 |
382 |
383 | buttonBox
384 | accepted()
385 | InputSettings
386 | SaveKeys()
387 |
388 |
389 | 248
390 | 254
391 |
392 |
393 | 157
394 | 274
395 |
396 |
397 |
398 |
399 | buttonBox
400 | rejected()
401 | InputSettings
402 | RestoreKeys()
403 |
404 |
405 | 316
406 | 260
407 |
408 |
409 | 286
410 | 274
411 |
412 |
413 |
414 |
415 |
416 | SaveKeys()
417 | RestoreKeys()
418 |
419 |
420 |
--------------------------------------------------------------------------------
/platforms/qt-shared/SoundSettings.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | SoundSettings
4 |
5 |
6 | Qt::WindowModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 439
13 | 120
14 |
15 |
16 |
17 | Sound Settings
18 |
19 |
20 | true
21 |
22 |
23 |
24 |
25 | 150
26 | 70
27 | 251
28 | 32
29 |
30 |
31 |
32 | Qt::Horizontal
33 |
34 |
35 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
36 |
37 |
38 |
39 |
40 |
41 | 310
42 | 15
43 | 111
44 | 22
45 |
46 |
47 |
48 |
49 |
50 |
51 | 210
52 | 17
53 | 121
54 | 21
55 |
56 |
57 |
58 | Sample Rate:
59 |
60 |
61 |
62 |
63 |
64 | 30
65 | 20
66 | 141
67 | 17
68 |
69 |
70 |
71 | Sound Enabled
72 |
73 |
74 |
75 |
76 |
77 |
78 | buttonBox
79 | accepted()
80 | SoundSettings
81 | PressedOK()
82 |
83 |
84 | 248
85 | 254
86 |
87 |
88 | 157
89 | 274
90 |
91 |
92 |
93 |
94 | buttonBox
95 | rejected()
96 | SoundSettings
97 | PressedCancel()
98 |
99 |
100 | 316
101 | 260
102 |
103 |
104 | 286
105 | 274
106 |
107 |
108 |
109 |
110 |
111 | PressedOK()
112 | PressedCancel()
113 |
114 |
115 |
--------------------------------------------------------------------------------
/platforms/qt-shared/VideoSettings.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | VideoSettings
4 |
5 |
6 | Qt::NonModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 324
13 | 128
14 |
15 |
16 |
17 | Video Settings
18 |
19 |
20 | false
21 |
22 |
23 |
24 |
25 | 20
26 | 70
27 | 291
28 | 32
29 |
30 |
31 |
32 | Qt::Horizontal
33 |
34 |
35 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
36 |
37 |
38 |
39 |
40 |
41 | 30
42 | 30
43 | 161
44 | 20
45 |
46 |
47 |
48 | Bilinear Filtering
49 |
50 |
51 |
52 |
53 |
54 |
55 | buttonBox
56 | accepted()
57 | VideoSettings
58 | PressedOK()
59 |
60 |
61 | 248
62 | 254
63 |
64 |
65 | 157
66 | 274
67 |
68 |
69 |
70 |
71 | buttonBox
72 | rejected()
73 | VideoSettings
74 | PressedCancel()
75 |
76 |
77 | 316
78 | 260
79 |
80 |
81 | 286
82 | 274
83 |
84 |
85 |
86 |
87 |
88 | PressedOK()
89 | PressedCancel()
90 | Color1()
91 | Color2()
92 | Color3()
93 | Color4()
94 |
95 |
96 |
--------------------------------------------------------------------------------
/platforms/qt-shared/about.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "about.h"
21 |
22 | About::About()
23 | {
24 | widget_.setupUi(this);
25 | }
26 |
27 | About::~About()
28 | {
29 | }
30 |
--------------------------------------------------------------------------------
/platforms/qt-shared/about.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_ABOUT_H_
21 | #define GD_ABOUT_H_
22 |
23 | #include "ui_About.h"
24 |
25 | class About : public QDialog
26 | {
27 | Q_OBJECT
28 |
29 | public:
30 | About();
31 | ~About();
32 |
33 | private:
34 | Ui::About widget_;
35 | };
36 |
37 | #endif // GD_ABOUT_H_
38 |
--------------------------------------------------------------------------------
/platforms/qt-shared/emulator.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "emulator.h"
21 |
22 | Emulator::Emulator()
23 | {
24 | InitPointer(gearsystem_core_);
25 | }
26 |
27 | Emulator::~Emulator()
28 | {
29 | SafeDelete(gearsystem_core_);
30 | }
31 |
32 | void Emulator::Init()
33 | {
34 | gearsystem_core_ = new GeardriveCore();
35 | gearsystem_core_->Init();
36 | }
37 |
38 | void Emulator::LoadRom(const char* path)
39 | {
40 | mutex_.lock();
41 | gearsystem_core_->SaveRam();
42 | gearsystem_core_->LoadROM(path);
43 | gearsystem_core_->LoadRam();
44 | mutex_.unlock();
45 | }
46 |
47 | void Emulator::RunToVBlank(GD_Color* frame_buffer)
48 | {
49 | mutex_.lock();
50 | gearsystem_core_->RunToVBlank(frame_buffer);
51 | mutex_.unlock();
52 | }
53 |
54 | void Emulator::KeyPressed(GD_Joypads joypad, GD_Keys key)
55 | {
56 | mutex_.lock();
57 | gearsystem_core_->KeyPressed(joypad, key);
58 | mutex_.unlock();
59 | }
60 |
61 | void Emulator::KeyReleased(GD_Joypads joypad, GD_Keys key)
62 | {
63 | mutex_.lock();
64 | gearsystem_core_->KeyReleased(joypad, key);
65 | mutex_.unlock();
66 | }
67 |
68 | void Emulator::Pause()
69 | {
70 | mutex_.lock();
71 | gearsystem_core_->Pause(true);
72 | mutex_.unlock();
73 | }
74 |
75 | void Emulator::Resume()
76 | {
77 | mutex_.lock();
78 | gearsystem_core_->Pause(false);
79 | mutex_.unlock();
80 | }
81 |
82 | bool Emulator::IsPaused()
83 | {
84 | mutex_.lock();
85 | bool paused = gearsystem_core_->IsPaused();
86 | mutex_.unlock();
87 | return paused;
88 | }
89 |
90 | void Emulator::Reset()
91 | {
92 | mutex_.lock();
93 | gearsystem_core_->SaveRam();
94 | gearsystem_core_->ResetROM();
95 | gearsystem_core_->LoadRam();
96 | mutex_.unlock();
97 | }
98 |
99 | void Emulator::MemoryDump()
100 | {
101 | // m_Mutex.lock();
102 | // m_pGearsystemCore->GetMemory()->MemoryDump("memdump.txt");
103 | // m_Mutex.unlock();
104 | }
105 |
106 | void Emulator::SetSoundSettings(bool enabled, int rate)
107 | {
108 | mutex_.lock();
109 | gearsystem_core_->EnableSound(enabled);
110 | gearsystem_core_->SetSoundSampleRate(rate);
111 | mutex_.unlock();
112 | }
113 |
114 | void Emulator::SaveRam()
115 | {
116 | mutex_.lock();
117 | gearsystem_core_->SaveRam();
118 | mutex_.unlock();
119 | }
120 |
--------------------------------------------------------------------------------
/platforms/qt-shared/emulator.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_EMULATOR_H_
21 | #define GD_EMULATOR_H_
22 |
23 | #include
24 | #include "../../../src/geardrive.h"
25 |
26 | class Emulator
27 | {
28 | public:
29 | Emulator();
30 | ~Emulator();
31 | void Init();
32 | void RunToVBlank(GD_Color* frame_buffer);
33 | void LoadRom(const char* path);
34 | void KeyPressed(GD_Joypads joypad, GD_Keys key);
35 | void KeyReleased(GD_Joypads joypad, GD_Keys key);
36 | void Pause();
37 | void Resume();
38 | bool IsPaused();
39 | void Reset();
40 | void MemoryDump();
41 | void SetSoundSettings(bool enabled, int rate);
42 | void SaveRam();
43 |
44 | private:
45 | GeardriveCore* gearsystem_core_;
46 | QMutex mutex_;
47 | };
48 |
49 | #endif // GD_EMULATOR_H_
50 |
51 |
--------------------------------------------------------------------------------
/platforms/qt-shared/gl_frame.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "gl_frame.h"
21 |
22 | #include
23 | #include
24 |
25 | GLFrame::GLFrame(QWidget *parent) : QGLWidget(parent), render_thread_(this)
26 | {
27 | setAutoBufferSwap(false);
28 | }
29 |
30 | GLFrame::~GLFrame()
31 | {
32 | }
33 |
34 | void GLFrame::InitRenderThread(Emulator* emulator)
35 | {
36 | doneCurrent();
37 | context()->moveToThread(&render_thread_);
38 | render_thread_.SetEmulator(emulator);
39 | render_thread_.start();
40 | }
41 |
42 | void GLFrame::StopRenderThread()
43 | {
44 | render_thread_.Stop();
45 | render_thread_.wait();
46 | }
47 |
48 | void GLFrame::PauseRenderThread()
49 | {
50 | render_thread_.Pause();
51 | }
52 |
53 | void GLFrame::ResumeRenderThread()
54 | {
55 | render_thread_.Resume();
56 | }
57 |
58 | bool GLFrame::IsRunningRenderThread()
59 | {
60 | return render_thread_.IsRunningEmulator();
61 | }
62 |
63 | void GLFrame::resizeEvent(QResizeEvent *evt)
64 | {
65 | render_thread_.ResizeViewport(evt->size());
66 | }
67 |
68 | void GLFrame::paintEvent(QPaintEvent *)
69 | {
70 | // Do nothing. Let the thread do the work
71 | }
72 |
73 | void GLFrame::closeEvent(QCloseEvent *evt)
74 | {
75 | StopRenderThread();
76 | QGLWidget::closeEvent(evt);
77 | }
78 |
79 | void GLFrame::SetBilinearFiletering(bool enabled)
80 | {
81 | render_thread_.SetBilinearFiletering(enabled);
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/platforms/qt-shared/gl_frame.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_GLFRAME_H_
21 | #define GD_GLFRAME_H_
22 |
23 | #ifndef __APPLE__
24 | #include
25 | #endif
26 | #include
27 | #include "../../src/geardrive.h"
28 | #include "render_thread.h"
29 |
30 | class Emulator;
31 |
32 | class GLFrame : public QGLWidget
33 | {
34 | Q_OBJECT
35 |
36 | public:
37 | explicit GLFrame(QWidget *parent = 0);
38 | ~GLFrame();
39 | void InitRenderThread(Emulator* emulator);
40 | void StopRenderThread();
41 | void PauseRenderThread();
42 | void ResumeRenderThread();
43 | bool IsRunningRenderThread();
44 | void SetBilinearFiletering(bool enabled);
45 |
46 | protected:
47 | void closeEvent(QCloseEvent *evt);
48 | void resizeEvent(QResizeEvent *evt);
49 | void paintEvent(QPaintEvent *);
50 |
51 | private:
52 | RenderThread render_thread_;
53 | };
54 |
55 | #endif // GD_GLFRAME_H_
56 |
--------------------------------------------------------------------------------
/platforms/qt-shared/input_settings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "input_settings.h"
21 |
22 | #include
23 | #include "gl_frame.h"
24 |
25 | InputSettings::InputSettings(GLFrame* gl_frame)
26 | {
27 | gl_frame_ = gl_frame;
28 | widget.setupUi(this);
29 | widget.lineEditUp->installEventFilter(this);
30 | widget.lineEditRight->installEventFilter(this);
31 | widget.lineEditDown->installEventFilter(this);
32 | widget.lineEditLeft->installEventFilter(this);
33 | widget.lineEdit1->installEventFilter(this);
34 | widget.lineEdit2->installEventFilter(this);
35 | widget.lineEditStart->installEventFilter(this);
36 | }
37 |
38 | InputSettings::~InputSettings()
39 | {
40 | }
41 |
42 | int InputSettings::GetKey(int key)
43 | {
44 | for (int i = 0; i < 7; i++)
45 | {
46 | if (keys_[i].keyCode == key)
47 | return i;
48 | }
49 | return -1;
50 | }
51 |
52 | void InputSettings::SaveKeys()
53 | {
54 | for (int i = 0; i < 7; i++)
55 | {
56 | keys_[i].keyCode = temp_keys_[i].keyCode;
57 | strcpy(keys_[i].text, temp_keys_[i].text);
58 | }
59 | gl_frame_->ResumeRenderThread();
60 | this->accept();
61 | }
62 |
63 | void InputSettings::RestoreKeys()
64 | {
65 | for (int i = 0; i < 8; i++)
66 | {
67 | temp_keys_[i].keyCode = keys_[i].keyCode;
68 | strcpy(temp_keys_[i].text, keys_[i].text);
69 | }
70 | widget.lineEditUp->setText(keys_[0].text);
71 | widget.lineEditRight->setText(keys_[1].text);
72 | widget.lineEditDown->setText(keys_[2].text);
73 | widget.lineEditLeft->setText(keys_[3].text);
74 | widget.lineEdit1->setText(keys_[4].text);
75 | widget.lineEdit2->setText(keys_[5].text);
76 | widget.lineEditStart->setText(keys_[6].text);
77 | gl_frame_->ResumeRenderThread();
78 | this->reject();
79 | }
80 |
81 | bool InputSettings::eventFilter(QObject* obj, QEvent *event)
82 | {
83 | if (event->type() == QEvent::KeyPress)
84 | {
85 | QKeyEvent* key_event = static_cast (event);
86 |
87 | char text[32];
88 |
89 | if (strcmp(obj->metaObject()->className(), "QLineEdit") == 0)
90 | {
91 | PrintKey(*key_event, text);
92 | QLineEdit* line_edit = static_cast (obj);
93 | line_edit->setText(text);
94 |
95 | if (obj == widget.lineEditUp)
96 | {
97 | temp_keys_[0].keyCode = key_event->key();
98 | strcpy(temp_keys_[0].text, text);
99 | }
100 | else if (obj == widget.lineEditRight)
101 | {
102 | temp_keys_[1].keyCode = key_event->key();
103 | strcpy(temp_keys_[1].text, text);
104 | }
105 | else if (obj == widget.lineEditDown)
106 | {
107 | temp_keys_[2].keyCode = key_event->key();
108 | strcpy(temp_keys_[2].text, text);
109 | }
110 | else if (obj == widget.lineEditLeft)
111 | {
112 | temp_keys_[3].keyCode = key_event->key();
113 | strcpy(temp_keys_[3].text, text);
114 | }
115 | else if (obj == widget.lineEdit1)
116 | {
117 | temp_keys_[4].keyCode = key_event->key();
118 | strcpy(temp_keys_[4].text, text);
119 | }
120 | else if (obj == widget.lineEdit2)
121 | {
122 | temp_keys_[5].keyCode = key_event->key();
123 | strcpy(temp_keys_[5].text, text);
124 | }
125 | else if (obj == widget.lineEditStart)
126 | {
127 | temp_keys_[6].keyCode = key_event->key();
128 | strcpy(temp_keys_[6].text, text);
129 | }
130 |
131 | return true;
132 | }
133 | }
134 |
135 | return QDialog::eventFilter(obj, event);
136 | }
137 |
138 | void InputSettings::PrintKey(QKeyEvent& event, char* buffer)
139 | {
140 | switch (event.key())
141 | {
142 | case Qt::Key_Control:
143 | strcpy(buffer, "CONTROL");
144 | break;
145 | case Qt::Key_Alt:
146 | strcpy(buffer, "ALT");
147 | break;
148 | case Qt::Key_Enter:
149 | strcpy(buffer, "ENTER");
150 | break;
151 | case Qt::Key_Shift:
152 | strcpy(buffer, "SHIFT");
153 | break;
154 | case Qt::Key_Backspace:
155 | strcpy(buffer, "BACKSPACE");
156 | break;
157 | case Qt::Key_Up:
158 | strcpy(buffer, "UP");
159 | break;
160 | case Qt::Key_Left:
161 | strcpy(buffer, "LEFT");
162 | break;
163 | case Qt::Key_Right:
164 | strcpy(buffer, "RIGHT");
165 | break;
166 | case Qt::Key_Down:
167 | strcpy(buffer, "DOWN");
168 | break;
169 | case Qt::Key_Return:
170 | strcpy(buffer, "RETURN");
171 | break;
172 | case Qt::Key_Space:
173 | strcpy(buffer, "SPACE");
174 | break;
175 | case Qt::Key_Tab:
176 | strcpy(buffer, "TAB");
177 | break;
178 | case Qt::Key_Home:
179 | strcpy(buffer, "HOME");
180 | break;
181 | case Qt::Key_End:
182 | strcpy(buffer, "END");
183 | break;
184 | case Qt::Key_PageUp:
185 | strcpy(buffer, "PAGE UP");
186 | break;
187 | case Qt::Key_PageDown:
188 | strcpy(buffer, "PAGE DOWN");
189 | break;
190 | case Qt::Key_Insert:
191 | strcpy(buffer, "INSERT");
192 | break;
193 | case Qt::Key_Delete:
194 | strcpy(buffer, "DELETE");
195 | break;
196 | default:
197 | strcpy(buffer, event.text().toUpper().toLatin1());
198 | }
199 | }
200 |
201 | void InputSettings::SaveSettings(QSettings& settings)
202 | {
203 | settings.setValue("KeyUP", keys_[0].keyCode);
204 | settings.setValue("KeyRIGHT", keys_[1].keyCode);
205 | settings.setValue("KeyDOWN", keys_[2].keyCode);
206 | settings.setValue("KeyLEFT", keys_[3].keyCode);
207 | settings.setValue("KeyA", keys_[4].keyCode);
208 | settings.setValue("KeyB", keys_[5].keyCode);
209 | settings.setValue("KeySTART", keys_[6].keyCode);
210 |
211 | settings.setValue("KeyNameUP", keys_[0].text);
212 | settings.setValue("KeyNameRIGHT", keys_[1].text);
213 | settings.setValue("KeyNameDOWN", keys_[2].text);
214 | settings.setValue("KeyNameLEFT", keys_[3].text);
215 | settings.setValue("KeyNameA", keys_[4].text);
216 | settings.setValue("KeyNameB", keys_[5].text);
217 | settings.setValue("KeyNameSTART", keys_[6].text);
218 | }
219 |
220 | void InputSettings::LoadSettings(QSettings& settings)
221 | {
222 | keys_[0].keyCode = settings.value("KeyUP", Qt::Key_Up).toInt();
223 | keys_[1].keyCode = settings.value("KeyRIGHT", Qt::Key_Right).toInt();
224 | keys_[2].keyCode = settings.value("KeyDOWN", Qt::Key_Down).toInt();
225 | keys_[3].keyCode = settings.value("KeyLEFT", Qt::Key_Left).toInt();
226 | keys_[4].keyCode = settings.value("KeyA", Qt::Key_S).toInt();
227 | keys_[5].keyCode = settings.value("KeyB", Qt::Key_A).toInt();
228 | keys_[6].keyCode = settings.value("KeySTART", Qt::Key_Return).toInt();
229 |
230 | strcpy(keys_[0].text, settings.value("KeyNameUP", "UP").toString().toLatin1().constData());
231 | strcpy(keys_[1].text, settings.value("KeyNameRIGHT", "RIGHT").toString().toLatin1().constData());
232 | strcpy(keys_[2].text, settings.value("KeyNameDOWN", "DOWN").toString().toLatin1().constData());
233 | strcpy(keys_[3].text, settings.value("KeyNameLEFT", "LEFT").toString().toLatin1().constData());
234 | strcpy(keys_[4].text, settings.value("KeyNameA", "S").toString().toLatin1().constData());
235 | strcpy(keys_[5].text, settings.value("KeyNameB", "A").toString().toLatin1().constData());
236 | strcpy(keys_[6].text, settings.value("KeyNameSTART", "RETURN").toString().toLatin1().constData());
237 |
238 | widget.lineEditUp->setText(keys_[0].text);
239 | widget.lineEditRight->setText(keys_[1].text);
240 | widget.lineEditDown->setText(keys_[2].text);
241 | widget.lineEditLeft->setText(keys_[3].text);
242 | widget.lineEdit1->setText(keys_[4].text);
243 | widget.lineEdit2->setText(keys_[5].text);
244 | widget.lineEditStart->setText(keys_[6].text);
245 |
246 | for (int i = 0; i < 7; i++)
247 | {
248 | temp_keys_[i].keyCode = keys_[i].keyCode;
249 | strcpy(temp_keys_[i].text, keys_[i].text);
250 | }
251 | }
252 |
--------------------------------------------------------------------------------
/platforms/qt-shared/input_settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_INPUTSETTINGS_H_
21 | #define GD_INPUTSETTINGS_H_
22 |
23 | #include
24 | #include "ui_InputSettings.h"
25 |
26 | struct stCustomKey
27 | {
28 | int keyCode;
29 | char text[32];
30 | };
31 |
32 | class GLFrame;
33 |
34 | class InputSettings : public QDialog
35 | {
36 | Q_OBJECT
37 |
38 | public:
39 | InputSettings(GLFrame* gl_frame_);
40 | ~InputSettings();
41 | bool eventFilter(QObject* obj, QEvent* event);
42 | int GetKey(int key);
43 | void SaveSettings(QSettings& settings);
44 | void LoadSettings(QSettings& settings);
45 |
46 | public slots:
47 | void SaveKeys();
48 | void RestoreKeys();
49 |
50 | private:
51 | void PrintKey(QKeyEvent& event, char* buffer);
52 |
53 | private:
54 | Ui::InputSettings widget;
55 | stCustomKey keys_[7];
56 | stCustomKey temp_keys_[7];
57 | GLFrame* gl_frame_;
58 | };
59 |
60 | #endif // GD_INPUTSETTINGS_H_
61 |
--------------------------------------------------------------------------------
/platforms/qt-shared/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include
21 | #include "main_window.h"
22 | #ifdef Q_WS_X11
23 | #include
24 | #endif
25 |
26 | int main(int argc, char *argv[])
27 | {
28 | #ifdef Q_WS_X11
29 | XInitThreads();
30 | #endif
31 | QApplication application(argc, argv);
32 | MainWindow window;
33 | window.show();
34 | return application.exec();
35 | }
36 |
--------------------------------------------------------------------------------
/platforms/qt-shared/main_window.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "main_window.h"
21 |
22 | #include
23 | #include
24 | #include
25 | #include "ui_MainWindow.h"
26 | #include "gl_frame.h"
27 | #include "emulator.h"
28 | #include "input_settings.h"
29 | #include "sound_settings.h"
30 | #include "video_settings.h"
31 | #include "about.h"
32 |
33 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
34 | {
35 | qApp->installEventFilter(this);
36 | fullscreen_ = false;
37 | screen_size_ = 2;
38 |
39 | menu_pressed_[0] = menu_pressed_[1] = menu_pressed_[2] = false;
40 | ui_ = new Ui::MainWindow();
41 | ui_->setupUi(this);
42 |
43 | this->addAction(ui_->actionFullscreen);
44 | this->addAction(ui_->actionReset);
45 | this->addAction(ui_->actionPause);
46 | this->addAction(ui_->actionSave_State);
47 | this->addAction(ui_->actionLoad_State);
48 |
49 | this->setWindowTitle(GEARDRIVE_TITLE);
50 |
51 | exit_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this);
52 | exit_shortcut_->setContext(Qt::ApplicationShortcut);
53 | QObject::connect(exit_shortcut_, SIGNAL(activated()), this, SLOT(Exit()));
54 |
55 |
56 | QObject::connect(ui_->menuGame_Boy, SIGNAL(aboutToShow()), this, SLOT(MenuGameBoyPressed()));
57 | QObject::connect(ui_->menuGame_Boy, SIGNAL(aboutToHide()), this, SLOT(MenuGameBoyReleased()));
58 | QObject::connect(ui_->menuDebug, SIGNAL(aboutToShow()), this, SLOT(MenuDebugPressed()));
59 | QObject::connect(ui_->menuDebug, SIGNAL(aboutToHide()), this, SLOT(MenuDebugReleased()));
60 | QObject::connect(ui_->menuSettings, SIGNAL(aboutToShow()), this, SLOT(MenuSettingsPressed()));
61 | QObject::connect(ui_->menuSettings, SIGNAL(aboutToHide()), this, SLOT(MenuSettingsReleased()));
62 |
63 | ui_->actionX_1->setData(1);
64 | ui_->actionX_2->setData(2);
65 | ui_->actionX_3->setData(3);
66 | ui_->actionX_4->setData(4);
67 | ui_->actionX_5->setData(5);
68 |
69 | emulator_ = new Emulator();
70 | emulator_->Init();
71 |
72 | QGLFormat format;
73 | format.setSwapInterval(1);
74 | QGLFormat::setDefaultFormat(format);
75 |
76 | gl_frame_ = new GLFrame();
77 | ResizeWindow(screen_size_);
78 | setCentralWidget(gl_frame_);
79 |
80 | input_settings_ = new InputSettings(gl_frame_);
81 |
82 | sound_settings_ = new SoundSettings(gl_frame_, emulator_);
83 |
84 | video_settings_ = new VideoSettings(gl_frame_, emulator_);
85 |
86 | about_ = new About();
87 |
88 | QPalette palette = this->palette();
89 | palette.setColor(this->backgroundRole(), Qt::black);
90 | this->setPalette(palette);
91 |
92 | LoadSettings();
93 |
94 | gl_frame_->InitRenderThread(emulator_);
95 | }
96 |
97 | MainWindow::~MainWindow()
98 | {
99 | SaveSettings();
100 |
101 | SafeDelete(about_);
102 | SafeDelete(exit_shortcut_);
103 | SafeDelete(emulator_);
104 | SafeDelete(gl_frame_);
105 | SafeDelete(input_settings_);
106 | SafeDelete(sound_settings_);
107 | SafeDelete(ui_);
108 | }
109 |
110 | void MainWindow::Exit()
111 | {
112 | #ifdef DEBUG_SYSTEM
113 | emulator_->MemoryDump();
114 | #endif
115 | this->close();
116 | }
117 |
118 | void MainWindow::MenuGameBoyLoadROM()
119 | {
120 | gl_frame_->PauseRenderThread();
121 |
122 | QString file_name = QFileDialog::getOpenFileName(
123 | this,
124 | tr("Load ROM"),
125 | QDir::currentPath(),
126 | tr("Master System / Game Gear ROM files (*.sms *.gg *.zip);;All files (*.*)"));
127 |
128 | if (!file_name.isNull())
129 | {
130 | emulator_->LoadRom(file_name.toUtf8().data());
131 | ui_->actionPause->setChecked(false);
132 | }
133 |
134 | setFocus();
135 | activateWindow();
136 |
137 | gl_frame_->ResumeRenderThread();
138 | }
139 |
140 | void MainWindow::MenuGameBoyPause()
141 | {
142 | if (emulator_->IsPaused())
143 | emulator_->Resume();
144 | else
145 | emulator_->Pause();
146 | }
147 |
148 | void MainWindow::MenuGameBoyReset()
149 | {
150 | ui_->actionPause->setChecked(false);
151 | emulator_->Reset();
152 | }
153 |
154 | void MainWindow::MenuGameBoySelectStateSlot()
155 | {
156 | }
157 |
158 | void MainWindow::MenuGameBoySaveState()
159 | {
160 | }
161 |
162 | void MainWindow::MenuGameBoyLoadState()
163 | {
164 | }
165 |
166 | void MainWindow::MenuGameBoySaveStateAs()
167 | {
168 | }
169 |
170 | void MainWindow::MenuGameBoyLoadStateFrom()
171 | {
172 | }
173 |
174 | void MainWindow::MenuSettingsInput()
175 | {
176 | gl_frame_->PauseRenderThread();
177 | input_settings_->show();
178 | }
179 |
180 | void MainWindow::MenuSettingsVideo()
181 | {
182 | gl_frame_->PauseRenderThread();
183 | video_settings_->show();
184 | }
185 |
186 | void MainWindow::MenuSettingsSound()
187 | {
188 | gl_frame_->PauseRenderThread();
189 | sound_settings_->show();
190 | }
191 |
192 | void MainWindow::MenuSettingsWindowSize(QAction* action)
193 | {
194 | ui_->actionX_1->setChecked(false);
195 | ui_->actionX_2->setChecked(false);
196 | ui_->actionX_3->setChecked(false);
197 | ui_->actionX_4->setChecked(false);
198 | ui_->actionX_5->setChecked(false);
199 | action->setChecked(true);
200 | screen_size_ = action->data().toInt();
201 | ResizeWindow(screen_size_);
202 | }
203 |
204 | void MainWindow::MenuSettingsFullscreen()
205 | {
206 | if (fullscreen_)
207 | {
208 | fullscreen_ = false;
209 | this->showNormal();
210 | ui_->menubar->show();
211 | ResizeWindow(screen_size_);
212 | gl_frame_->move(0, 0);
213 | }
214 | else
215 | {
216 | fullscreen_ = true;
217 |
218 | this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
219 | this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
220 | this->setMinimumSize(0, 0);
221 | this->showFullScreen();
222 |
223 | ui_->menubar->hide();
224 |
225 | int current_width = qApp->desktop()->size().width();
226 | int current_height = qApp->desktop()->size().height();
227 |
228 | int scaling_factor = current_height / GD_GEN_HEIGHT;
229 |
230 | gl_frame_->setMaximumSize(GD_GEN_WIDTH * scaling_factor, GD_GEN_HEIGHT * scaling_factor);
231 | gl_frame_->setMinimumSize(GD_GEN_WIDTH * scaling_factor, GD_GEN_HEIGHT * scaling_factor);
232 |
233 | int offset_x = (current_width - (GD_GEN_WIDTH * scaling_factor)) / 2;
234 | int offset_y = (current_height - (GD_GEN_HEIGHT * scaling_factor)) / 2;
235 | gl_frame_->setGeometry(offset_x, offset_y, GD_GEN_WIDTH * scaling_factor, GD_GEN_HEIGHT * scaling_factor);
236 | }
237 |
238 | setFocus();
239 | activateWindow();
240 | }
241 |
242 | void MainWindow::MenuSettingsForceDMG()
243 | {
244 | }
245 |
246 | void MainWindow::MenuDebugDisassembler()
247 | {
248 | }
249 |
250 | void MainWindow::MenuDebugOAM()
251 | {
252 | }
253 |
254 | void MainWindow::MenuDebugMap()
255 | {
256 | }
257 |
258 | void MainWindow::MenuDebugPalette()
259 | {
260 | }
261 |
262 | void MainWindow::MenuAbout()
263 | {
264 | about_->setModal(true);
265 | about_->show();
266 | }
267 |
268 | void MainWindow::MenuGameBoyPressed()
269 | {
270 | menu_pressed_[0] = true;
271 | gl_frame_->PauseRenderThread();
272 | }
273 |
274 | void MainWindow::MenuGameBoyReleased()
275 | {
276 | menu_pressed_[0] = false;
277 | MenuReleased();
278 | }
279 |
280 | void MainWindow::MenuSettingsPressed()
281 | {
282 | menu_pressed_[1] = true;
283 | gl_frame_->PauseRenderThread();
284 | }
285 |
286 | void MainWindow::MenuSettingsReleased()
287 | {
288 | menu_pressed_[1] = false;
289 | MenuReleased();
290 | }
291 |
292 | void MainWindow::MenuDebugPressed()
293 | {
294 | menu_pressed_[2] = true;
295 | gl_frame_->PauseRenderThread();
296 | }
297 |
298 | void MainWindow::MenuDebugReleased()
299 | {
300 | menu_pressed_[2] = false;
301 | MenuReleased();
302 | }
303 |
304 | void MainWindow::MenuReleased()
305 | {
306 | for (int i = 0; i < 3; i++)
307 | {
308 | if (menu_pressed_[i])
309 | return;
310 | }
311 | gl_frame_->ResumeRenderThread();
312 | }
313 |
314 | void MainWindow::closeEvent(QCloseEvent *evt)
315 | {
316 | gl_frame_->StopRenderThread();
317 | QMainWindow::closeEvent(evt);
318 | }
319 |
320 | void MainWindow::keyPressEvent(QKeyEvent* e)
321 | {
322 | if (!e->isAutoRepeat())
323 | {
324 | GD_Joypads joypad = kJoypad1;
325 | switch (input_settings_->GetKey(e->key()))
326 | {
327 | case 0:
328 | emulator_->KeyPressed(joypad, kKeyUp);
329 | break;
330 | case 3:
331 | emulator_->KeyPressed(joypad, kKeyLeft);
332 | break;
333 | case 1:
334 | emulator_->KeyPressed(joypad, kKeyRight);
335 | break;
336 | case 2:
337 | emulator_->KeyPressed(joypad, kKeyDown);
338 | break;
339 | case 6:
340 | emulator_->KeyPressed(joypad, kKeyStart);
341 | break;
342 | case 5:
343 | emulator_->KeyPressed(joypad, kKeyA);
344 | break;
345 | case 4:
346 | emulator_->KeyPressed(joypad, kKeyB);
347 | break;
348 | default:
349 | break;
350 | }
351 | }
352 | }
353 |
354 | void MainWindow::keyReleaseEvent(QKeyEvent* e)
355 | {
356 | if (!e->isAutoRepeat())
357 | {
358 | GD_Joypads joypad = kJoypad1;
359 | switch (input_settings_->GetKey(e->key()))
360 | {
361 | case 0:
362 | emulator_->KeyReleased(joypad, kKeyUp);
363 | break;
364 | case 3:
365 | emulator_->KeyReleased(joypad, kKeyLeft);
366 | break;
367 | case 1:
368 | emulator_->KeyReleased(joypad, kKeyRight);
369 | break;
370 | case 2:
371 | emulator_->KeyReleased(joypad, kKeyDown);
372 | break;
373 | case 6:
374 | emulator_->KeyReleased(joypad, kKeyStart);
375 | break;
376 | case 5:
377 | emulator_->KeyReleased(joypad, kKeyA);
378 | break;
379 | case 4:
380 | emulator_->KeyReleased(joypad, kKeyB);
381 | break;
382 | default:
383 | break;
384 | }
385 | }
386 | }
387 |
388 | void MainWindow::ResizeWindow(int factor)
389 | {
390 | screen_size_ = factor;
391 | gl_frame_->setMaximumSize(GD_GEN_WIDTH * factor, GD_GEN_HEIGHT * factor);
392 | gl_frame_->setMinimumSize(GD_GEN_WIDTH * factor, GD_GEN_HEIGHT * factor);
393 | }
394 |
395 | bool MainWindow::eventFilter(QObject * watched, QEvent * event)
396 | {
397 | if (event->type() == QEvent::ApplicationActivate)
398 | {
399 | gl_frame_->ResumeRenderThread();
400 | }
401 | else if (event->type() == QEvent::ApplicationDeactivate)
402 | {
403 | gl_frame_->PauseRenderThread();
404 | }
405 |
406 | return QMainWindow::eventFilter(watched, event);
407 | }
408 |
409 | bool MainWindow::event(QEvent *ev)
410 | {
411 | if (ev->type() == QEvent::LayoutRequest)
412 | {
413 | if (!fullscreen_)
414 | {
415 | this->setMaximumSize(sizeHint());
416 | this->setMinimumSize(sizeHint());
417 | this->resize(sizeHint());
418 | }
419 | }
420 |
421 | return QMainWindow::event(ev);
422 | }
423 |
424 | void MainWindow::LoadSettings()
425 | {
426 | QSettings settings("gearsystem.ini", QSettings::IniFormat);
427 |
428 | settings.beginGroup("Gearsystem");
429 | screen_size_ = settings.value("ScreenSize", 2).toInt();
430 |
431 | switch (screen_size_)
432 | {
433 | case 1:
434 | MenuSettingsWindowSize(ui_->actionX_1);
435 | break;
436 | case 2:
437 | MenuSettingsWindowSize(ui_->actionX_2);
438 | break;
439 | case 3:
440 | MenuSettingsWindowSize(ui_->actionX_3);
441 | break;
442 | case 4:
443 | MenuSettingsWindowSize(ui_->actionX_4);
444 | break;
445 | case 5:
446 | MenuSettingsWindowSize(ui_->actionX_5);
447 | break;
448 | }
449 |
450 | fullscreen_ = !settings.value("FullScreen", false).toBool();
451 |
452 | MenuSettingsFullscreen();
453 |
454 | ui_->actionForce_Game_Boy_DMG->setChecked(settings.value("ForceDMG", false).toBool());
455 | settings.endGroup();
456 |
457 | settings.beginGroup("Input");
458 | input_settings_->LoadSettings(settings);
459 | settings.endGroup();
460 | settings.beginGroup("Video");
461 | video_settings_->LoadSettings(settings);
462 | settings.endGroup();
463 | settings.beginGroup("Sound");
464 | sound_settings_->LoadSettings(settings);
465 | settings.endGroup();
466 | }
467 |
468 | void MainWindow::SaveSettings()
469 | {
470 | QSettings settings("gearsystem.ini", QSettings::IniFormat);
471 |
472 | settings.beginGroup("Gearsystem");
473 | settings.setValue("ScreenSize", screen_size_);
474 | settings.setValue("FullScreen", fullscreen_);
475 | settings.setValue("ForceDMG", ui_->actionForce_Game_Boy_DMG->isChecked());
476 | settings.endGroup();
477 |
478 | settings.beginGroup("Input");
479 | input_settings_->SaveSettings(settings);
480 | settings.endGroup();
481 | settings.beginGroup("Video");
482 | video_settings_->SaveSettings(settings);
483 | settings.endGroup();
484 | settings.beginGroup("Sound");
485 | sound_settings_->SaveSettings(settings);
486 | settings.endGroup();
487 |
488 | emulator_->SaveRam();
489 | }
490 |
491 |
--------------------------------------------------------------------------------
/platforms/qt-shared/main_window.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_MAINWINDOW_H_
21 | #define GD_MAINWINDOW_H_
22 |
23 | #include
24 | #include
25 | #include
26 | #include "../../src/geardrive.h"
27 |
28 | class GLFrame;
29 | class Emulator;
30 | class InputSettings;
31 | class SoundSettings;
32 | class VideoSettings;
33 | class About;
34 |
35 | namespace Ui
36 | {
37 | class MainWindow;
38 | }
39 |
40 | class MainWindow : public QMainWindow
41 | {
42 | Q_OBJECT
43 |
44 | public:
45 | explicit MainWindow(QWidget *parent = 0);
46 | ~MainWindow();
47 | bool event(QEvent *ev);
48 | bool eventFilter(QObject * watched, QEvent * event);
49 |
50 | public slots:
51 | void Exit();
52 | void MenuGameBoyLoadROM();
53 | void MenuGameBoyPause();
54 | void MenuGameBoyReset();
55 | void MenuGameBoySelectStateSlot();
56 | void MenuGameBoySaveState();
57 | void MenuGameBoyLoadState();
58 | void MenuGameBoySaveStateAs();
59 | void MenuGameBoyLoadStateFrom();
60 | void MenuSettingsInput();
61 | void MenuSettingsVideo();
62 | void MenuSettingsSound();
63 | void MenuSettingsWindowSize(QAction* action);
64 | void MenuSettingsFullscreen();
65 | void MenuSettingsForceDMG();
66 | void MenuDebugDisassembler();
67 | void MenuDebugOAM();
68 | void MenuDebugMap();
69 | void MenuDebugPalette();
70 | void MenuAbout();
71 | void MenuGameBoyPressed();
72 | void MenuGameBoyReleased();
73 | void MenuSettingsPressed();
74 | void MenuSettingsReleased();
75 | void MenuDebugPressed();
76 | void MenuDebugReleased();
77 |
78 | protected:
79 | void closeEvent(QCloseEvent *evt);
80 | void keyPressEvent(QKeyEvent* e);
81 | void keyReleaseEvent(QKeyEvent* e);
82 | void MenuReleased();
83 | void ResizeWindow(int factor);
84 |
85 | private:
86 | void LoadSettings();
87 | void SaveSettings();
88 |
89 | private:
90 | Ui::MainWindow *ui_;
91 | GLFrame *gl_frame_;
92 | Emulator* emulator_;
93 | bool menu_pressed_[3];
94 | int screen_size_;
95 | bool fullscreen_;
96 | QShortcut* exit_shortcut_;
97 | InputSettings* input_settings_;
98 | SoundSettings* sound_settings_;
99 | VideoSettings* video_settings_;
100 | About* about_;
101 | };
102 |
103 | #endif // GD_MAINWINDOW_H_
104 |
--------------------------------------------------------------------------------
/platforms/qt-shared/render_thread.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "render_thread.h"
21 |
22 | #include "gl_frame.h"
23 | #include "emulator.h"
24 |
25 | RenderThread::RenderThread(GLFrame* gl_frame) : QThread(), gl_frame_(gl_frame)
26 | {
27 | paused_ = false;
28 | do_actual_rendering_ = true;
29 | frame_buffer_ = new GD_Color[GD_GEN_WIDTH * GD_GEN_HEIGHT];
30 | width_ = 0;
31 | height_ = 0;
32 | InitPointer(emulator_);
33 | filtering_ = false;
34 | resize_event_ = false;
35 | texture_ = 0;
36 | }
37 |
38 | RenderThread::~RenderThread()
39 | {
40 | }
41 |
42 | void RenderThread::ResizeViewport(const QSize &size)
43 | {
44 | width_ = size.width();
45 | height_ = size.height();
46 | resize_event_ = true;
47 | }
48 |
49 | void RenderThread::Stop()
50 | {
51 | do_actual_rendering_ = false;
52 | }
53 |
54 | void RenderThread::Pause()
55 | {
56 | paused_ = true;
57 | }
58 |
59 | void RenderThread::Resume()
60 | {
61 | paused_ = false;
62 | }
63 |
64 | bool RenderThread::IsRunningEmulator()
65 | {
66 | return do_actual_rendering_;
67 | }
68 |
69 | void RenderThread::SetEmulator(Emulator* emulator)
70 | {
71 | emulator_ = emulator;
72 | }
73 |
74 | void RenderThread::run()
75 | {
76 | gl_frame_->makeCurrent();
77 |
78 | Init();
79 |
80 | while (do_actual_rendering_)
81 | {
82 | if (!paused_)
83 | {
84 | emulator_->RunToVBlank(frame_buffer_);
85 |
86 | if (resize_event_)
87 | {
88 | resize_event_ = false;
89 | }
90 |
91 | RenderFrame();
92 |
93 | gl_frame_->swapBuffers();
94 | }
95 | }
96 |
97 | SafeDeleteArray(frame_buffer_);
98 | glDeleteTextures(1, &texture_);
99 | }
100 |
101 | void RenderThread::Init()
102 | {
103 | for (int y = 0; y < GD_GEN_HEIGHT; ++y)
104 | {
105 | for (int x = 0; x < GD_GEN_WIDTH; ++x)
106 | {
107 | int pixel = (y * GD_GEN_WIDTH) + x;
108 | frame_buffer_[pixel].red = frame_buffer_[pixel].green =
109 | frame_buffer_[pixel].blue = 0x00;
110 | frame_buffer_[pixel].alpha = 0xFF;
111 | }
112 | }
113 |
114 | #ifndef __APPLE__
115 | GLenum err = glewInit();
116 | if (GLEW_OK != err)
117 | {
118 | /* Problem: glewInit failed, something is seriously wrong. */
119 | Log("GLEW Error: %s\n", glewGetErrorString(err));
120 | }
121 | Log("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
122 | #endif
123 |
124 | glGenTextures(1, &texture_);
125 |
126 | glEnable(GL_TEXTURE_2D);
127 | glBindTexture(GL_TEXTURE_2D, texture_);
128 | SetupTexture((void*) frame_buffer_);
129 | }
130 |
131 | void RenderThread::SetupTexture(void* data)
132 | {
133 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, GD_GEN_WIDTH, GD_GEN_HEIGHT, 0,
134 | GL_RGBA, GL_UNSIGNED_BYTE, (void*) data);
135 |
136 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
137 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
138 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
139 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
140 | }
141 |
142 | void RenderThread::RenderFrame()
143 | {
144 | glBindFramebuffer(GL_FRAMEBUFFER, 0);
145 | glBindTexture(GL_TEXTURE_2D, texture_);
146 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, GD_GEN_WIDTH, GD_GEN_HEIGHT,
147 | GL_RGBA, GL_UNSIGNED_BYTE, (void*) frame_buffer_);
148 | if (filtering_)
149 | {
150 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
151 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
152 | }
153 | else
154 | {
155 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
156 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
157 | }
158 | RenderQuad(width_, height_);
159 | }
160 |
161 | void RenderThread::RenderQuad(int viewport_width, int viewport_height)
162 | {
163 | glMatrixMode(GL_PROJECTION);
164 | glLoadIdentity();
165 | gluOrtho2D(0, viewport_width, viewport_height, 0);
166 | glMatrixMode(GL_MODELVIEW);
167 | glViewport(0, 0, viewport_width, viewport_height);
168 |
169 | glBegin(GL_QUADS);
170 | glTexCoord2d(0.0, 0.0);
171 | glVertex2d(0.0, 0.0);
172 | glTexCoord2d(1.0, 0.0);
173 | glVertex2d(viewport_width, 0.0);
174 | glTexCoord2d(1.0, 1.0);
175 | glVertex2d(viewport_width, viewport_height);
176 | glTexCoord2d(0.0, 1.0);
177 | glVertex2d(0.0, viewport_height);
178 | glEnd();
179 | }
180 |
181 | void RenderThread::SetBilinearFiletering(bool enabled)
182 | {
183 | filtering_ = enabled;
184 | }
185 |
186 |
--------------------------------------------------------------------------------
/platforms/qt-shared/render_thread.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_RENDERTHREAD_H_
21 | #define GD_RENDERTHREAD_H_
22 |
23 | #ifdef __APPLE__
24 | #include
25 | #include
26 | #else
27 | #include
28 | #endif
29 | #include
30 | #include "../../src/geardrive.h"
31 |
32 | class Emulator;
33 | class GLFrame;
34 | class QSize;
35 |
36 | class RenderThread : public QThread
37 | {
38 | Q_OBJECT
39 |
40 | public:
41 | explicit RenderThread(GLFrame* gl_frame = 0);
42 | virtual ~RenderThread();
43 | void ResizeViewport(const QSize& size);
44 | void run();
45 | void Stop();
46 | void Pause();
47 | void Resume();
48 | void SetEmulator(Emulator* emulator);
49 | bool IsRunningEmulator();
50 | void SetBilinearFiletering(bool enabled);
51 |
52 | protected:
53 | void Init();
54 | void RenderFrame();
55 | void RenderQuad(int viewport_width, int viewport_height);
56 | void SetupTexture(void* data);
57 |
58 | private:
59 | bool do_actual_rendering_;
60 | bool paused_;
61 | int width_;
62 | int height_;
63 | GLFrame* gl_frame_;
64 | Emulator* emulator_;
65 | GD_Color* frame_buffer_;
66 | bool filtering_;
67 | bool resize_event_;
68 | GLuint texture_;
69 | };
70 |
71 | #endif // GD_RENDERTHREAD_H_
72 |
--------------------------------------------------------------------------------
/platforms/qt-shared/sound_settings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "sound_settings.h"
21 |
22 | #include "gl_frame.h"
23 | #include "emulator.h"
24 |
25 | SoundSettings::SoundSettings(GLFrame* gl_frame, Emulator* emulator)
26 | {
27 | rate_ = 1;
28 | enabled_ = true;
29 | gl_frame_ = gl_frame;
30 | emulator_ = emulator;
31 | widget.setupUi(this);
32 |
33 | widget.comboBoxSampleRate->addItem("48000");
34 | widget.comboBoxSampleRate->addItem("44100");
35 | widget.comboBoxSampleRate->addItem("22050");
36 |
37 | widget.comboBoxSampleRate->setCurrentIndex(rate_);
38 | widget.checkBoxSoundEnabled->setChecked(enabled_);
39 | }
40 |
41 | SoundSettings::~SoundSettings()
42 | {
43 | }
44 |
45 | void SoundSettings::PressedOK()
46 | {
47 | rate_ = widget.comboBoxSampleRate->currentIndex();
48 | enabled_ = widget.checkBoxSoundEnabled->isChecked();
49 |
50 | int sampleRate = 0;
51 | switch (rate_)
52 | {
53 | case 0:
54 | sampleRate = 48000;
55 | break;
56 | case 1:
57 | sampleRate = 44100;
58 | break;
59 | case 2:
60 | sampleRate = 22050;
61 | break;
62 | default:
63 | sampleRate = 44100;
64 | }
65 |
66 | emulator_->SetSoundSettings(enabled_, sampleRate);
67 | gl_frame_->ResumeRenderThread();
68 | this->accept();
69 | }
70 |
71 | void SoundSettings::PressedCancel()
72 | {
73 | widget.comboBoxSampleRate->setCurrentIndex(rate_);
74 | widget.checkBoxSoundEnabled->setChecked(enabled_);
75 | gl_frame_->ResumeRenderThread();
76 | this->reject();
77 | }
78 |
79 | void SoundSettings::SaveSettings(QSettings& settings)
80 | {
81 | settings.setValue("SampleRate", rate_);
82 | settings.setValue("SoundEnabled", enabled_);
83 | }
84 |
85 | void SoundSettings::LoadSettings(QSettings& settings)
86 | {
87 | rate_ = settings.value("SampleRate", 1).toInt();
88 | enabled_ = settings.value("SoundEnabled", true).toBool();
89 | widget.comboBoxSampleRate->setCurrentIndex(rate_);
90 | widget.checkBoxSoundEnabled->setChecked(enabled_);
91 |
92 | int sampleRate = 0;
93 | switch (rate_)
94 | {
95 | case 0:
96 | sampleRate = 48000;
97 | break;
98 | case 1:
99 | sampleRate = 44100;
100 | break;
101 | case 2:
102 | sampleRate = 22050;
103 | break;
104 | default:
105 | sampleRate = 44100;
106 | }
107 |
108 | emulator_->SetSoundSettings(enabled_, sampleRate);
109 | }
110 |
--------------------------------------------------------------------------------
/platforms/qt-shared/sound_settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_SOUNDSETTINGS_H_
21 | #define GD_SOUNDSETTINGS_H_
22 |
23 | #include
24 | #include "ui_SoundSettings.h"
25 |
26 | class GLFrame;
27 | class Emulator;
28 |
29 | class SoundSettings : public QDialog
30 | {
31 | Q_OBJECT
32 |
33 | public:
34 | SoundSettings(GLFrame* gl_frame, Emulator* emulator);
35 | ~SoundSettings();
36 | void SaveSettings(QSettings& settings);
37 | void LoadSettings(QSettings& settings);
38 |
39 | public slots:
40 | void PressedOK();
41 | void PressedCancel();
42 |
43 | private:
44 | Ui::SoundSettings widget;
45 | GLFrame* gl_frame_;
46 | Emulator* emulator_;
47 | int rate_;
48 | bool enabled_;
49 | };
50 |
51 | #endif // GD_SOUNDSETTINGS_H_
52 |
--------------------------------------------------------------------------------
/platforms/qt-shared/video_settings.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "video_settings.h"
21 |
22 | #include
23 | #include "gl_frame.h"
24 | #include "emulator.h"
25 | #include "main_window.h"
26 |
27 | VideoSettings::VideoSettings(GLFrame* pGLFrame, Emulator* pEmulator)
28 | {
29 | widget.setupUi(this);
30 | emulator_ = pEmulator;
31 | gl_frame_ = pGLFrame;
32 | }
33 |
34 | VideoSettings::~VideoSettings()
35 | {
36 | }
37 |
38 | void VideoSettings::PressedOK()
39 | {
40 | gl_frame_->SetBilinearFiletering(widget.checkBoxFilter->isChecked());
41 | gl_frame_->ResumeRenderThread();
42 | this->accept();
43 | }
44 |
45 | void VideoSettings::PressedCancel()
46 | {
47 | gl_frame_->ResumeRenderThread();
48 | this->reject();
49 | }
50 |
51 | void VideoSettings::SaveSettings(QSettings& settings)
52 | {
53 | settings.setValue("BilinearFiltering", widget.checkBoxFilter->isChecked());
54 | }
55 |
56 | void VideoSettings::LoadSettings(QSettings& settings)
57 | {
58 | widget.checkBoxFilter->setChecked(settings.value("BilinearFiltering", false).toBool());
59 | gl_frame_->SetBilinearFiletering(widget.checkBoxFilter->isChecked());
60 | }
61 |
--------------------------------------------------------------------------------
/platforms/qt-shared/video_settings.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_VIDEOSETTINGS_H_
21 | #define GD_VIDEOSETTINGS_H_
22 |
23 | #include
24 | #include "ui_VideoSettings.h"
25 |
26 | class GLFrame;
27 | class Emulator;
28 | class QColorDialog;
29 |
30 | class VideoSettings : public QDialog
31 | {
32 | Q_OBJECT
33 |
34 | public:
35 | VideoSettings(GLFrame* gl_frame, Emulator* emulator);
36 | ~VideoSettings();
37 | void SaveSettings(QSettings& settings);
38 | void LoadSettings(QSettings& settings);
39 |
40 | public slots:
41 | void PressedOK();
42 | void PressedCancel();
43 |
44 | private:
45 | Ui::VideoSettings widget;
46 | Emulator* emulator_;
47 | GLFrame* gl_frame_;
48 | };
49 |
50 | #endif // GD_VIDEOSETTINGS_H_
51 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_definitions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_DEFINITIONS_H_
21 | #define GZ80_DEFINITIONS_H_
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | #define GZ80_DEBUG 1
32 |
33 | #ifdef GZ80_DEBUG
34 | #define GZ80_DISASM 1
35 | #endif
36 |
37 | namespace gz80
38 | {
39 |
40 | typedef uint8_t u8;
41 | typedef int8_t s8;
42 | typedef uint16_t u16;
43 | typedef int16_t s16;
44 | typedef uint32_t u32;
45 | typedef int32_t s32;
46 | typedef uint64_t u64;
47 | typedef int64_t s64;
48 |
49 | #define SafeDelete(pointer) if(pointer != NULL) {delete pointer; pointer = NULL;}
50 | #define SafeDeleteArray(pointer) if(pointer != NULL) {delete [] pointer; pointer = NULL;}
51 |
52 | #define InitPointer(pointer) ((pointer) = NULL)
53 | #define IsValidPointer(pointer) ((pointer) != NULL)
54 |
55 | #define FLAG_CARRY 0x01
56 | #define FLAG_NEGATIVE 0x02
57 | #define FLAG_PARITY 0x04
58 | #define FLAG_X 0x08
59 | #define FLAG_HALF 0x10
60 | #define FLAG_Y 0x20
61 | #define FLAG_ZERO 0x40
62 | #define FLAG_SIGN 0x80
63 | #define FLAG_NONE 0
64 |
65 | #ifdef GZ80_DEBUG
66 | #define Log(msg, ...) (LogImpl(msg, ##__VA_ARGS__))
67 | #else
68 | #define Log(msg, ...)
69 | #endif
70 |
71 | inline void LogImpl(const char* const msg, ...)
72 | {
73 | static int count = 1;
74 | char szBuf[512];
75 | va_list args;
76 | va_start(args, msg);
77 | vsprintf(szBuf, msg, args);
78 | va_end(args);
79 | printf("%d: %s\n", count, szBuf);
80 | count++;
81 | }
82 |
83 | inline u8 SetBit(const u8 value, const u8 bit)
84 | {
85 | return value | (0x01 << bit);
86 | }
87 |
88 | inline u8 UnsetBit(const u8 value, const u8 bit)
89 | {
90 | return value & (~(0x01 << bit));
91 | }
92 |
93 | inline bool IsSetBit(const u8 value, const u8 bit)
94 | {
95 | return (value & (0x01 << bit)) != 0;
96 | }
97 |
98 | inline u8 FlipBit(const u8 value, const u8 bit)
99 | {
100 | return value ^ (0x01 << bit);
101 | }
102 |
103 | } // namespace gz80
104 |
105 | #endif // GZ80_DEFINITIONS_H_
106 |
107 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_eight_bit_register.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_EIGHTBITREGISTER_H_
21 | #define GZ80_EIGHTBITREGISTER_H_
22 |
23 | #include "gz80_definitions.h"
24 |
25 | namespace gz80
26 | {
27 |
28 | class EightBitRegister
29 | {
30 | public:
31 | EightBitRegister() : value_(0) { }
32 | void SetValue(u8 value);
33 | u8 GetValue() const;
34 | void Increment();
35 | void Decrement();
36 |
37 | private:
38 | u8 value_;
39 | };
40 |
41 |
42 | inline void EightBitRegister::SetValue(u8 value)
43 | {
44 | this->value_ = value;
45 | }
46 |
47 | inline u8 EightBitRegister::GetValue() const
48 | {
49 | return value_;
50 | }
51 |
52 | inline void EightBitRegister::Increment()
53 | {
54 | value_++;
55 | }
56 |
57 | inline void EightBitRegister::Decrement()
58 | {
59 | value_--;
60 | }
61 |
62 | } // namespace gz80
63 |
64 | #endif // GZ80_EIGHTBITREGISTER_H_
65 |
66 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_ioports_interface.h:
--------------------------------------------------------------------------------
1 | #ifndef GD_Z80_IOPORTS_INTERFACE_H_
2 | #define GD_Z80_IOPORTS_INTERFACE_H_
3 |
4 | #include "gz80_definitions.h"
5 |
6 | namespace gz80
7 | {
8 |
9 | class IOPortsInterface
10 | {
11 | public:
12 | IOPortsInterface() {};
13 | virtual ~IOPortsInterface();
14 | virtual u8 Input(u8 port) = 0;
15 | virtual void Output(u8 port, u8 value) = 0;
16 | };
17 |
18 | } // namespace gz80
19 |
20 | #endif // GD_Z80_IOPORTS_INTERFACE_H_
21 |
22 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_memory_interface.h:
--------------------------------------------------------------------------------
1 | #ifndef GZ80_MEMORYINTERFACE_H_
2 | #define GZ80_MEMORYINTERFACE_H_
3 |
4 | #include "gz80_definitions.h"
5 |
6 | namespace gz80
7 | {
8 |
9 | class MemoryInterface
10 | {
11 | public:
12 | MemoryInterface() {};
13 | virtual ~MemoryInterface();
14 | virtual u8 Read(u16 address) = 0;
15 | virtual void Write(u16 address, u8 value) = 0;
16 | virtual void Disassemble(u16 address, const char* disassembled_string) = 0;
17 | virtual bool IsDisassembled(u16 address) = 0;
18 | };
19 |
20 | } // namespace gz80
21 |
22 | #endif // GZ80_MEMORYINTERFACE_H_
23 |
24 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_cb_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODECBNAMES_H_
21 | #define GZ80_OPCODECBNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeCBNames[256] = {
29 | "RLC B",
30 | "RLC C",
31 | "RLC D",
32 | "RLC E",
33 | "RLC H",
34 | "RLC L",
35 | "RLC (HL)",
36 | "RLC A",
37 | "RRC B",
38 | "RRC C",
39 | "RRC D",
40 | "RRC E",
41 | "RRC H",
42 | "RRC L",
43 | "RRC (HL)",
44 | "RRC A",
45 |
46 | "RL B",
47 | "RL C",
48 | "RL D",
49 | "RL E",
50 | "RL H",
51 | "RL L ",
52 | "RL (HL)",
53 | "RL A",
54 | "RR B",
55 | "RR C",
56 | "RR D",
57 | "RR E",
58 | "RR H",
59 | "RR L",
60 | "RR (HL)",
61 | "RR A",
62 |
63 | "SLA B",
64 | "SLA C",
65 | "SLA D",
66 | "SLA E",
67 | "SLA H",
68 | "SLA L",
69 | "SLA (HL)",
70 | "SLA A",
71 | "SRA B",
72 | "SRA C",
73 | "SRA D",
74 | "SRA E",
75 | "SRA H",
76 | "SRA L",
77 | "SRA (HL)",
78 | "SRA A",
79 |
80 | "SLL B",
81 | "SLL C",
82 | "SLL D",
83 | "SLL E",
84 | "SLL H",
85 | "SLL L",
86 | "SLL (HL)",
87 | "SLL A",
88 | "SRL B",
89 | "SRL C",
90 | "SRL D",
91 | "SRL E",
92 | "SRL H",
93 | "SRL L",
94 | "SRL (HL)",
95 | "SRL A",
96 |
97 | "BIT 0 B",
98 | "BIT 0 C",
99 | "BIT 0 D",
100 | "BIT 0 E",
101 | "BIT 0 H",
102 | "BIT 0 L",
103 | "BIT 0 (HL)",
104 | "BIT 0 A",
105 | "BIT 1 B",
106 | "BIT 1 C",
107 | "BIT 1 D",
108 | "BIT 1 E",
109 | "BIT 1 H",
110 | "BIT 1 L",
111 | "BIT 1 (HL)",
112 | "BIT 1 A",
113 |
114 | "BIT 2 B",
115 | "BIT 2 C",
116 | "BIT 2 D",
117 | "BIT 2 E",
118 | "BIT 2 H",
119 | "BIT 2 L",
120 | "BIT 2 (HL)",
121 | "BIT 2 A",
122 | "BIT 3 B",
123 | "BIT 3 C",
124 | "BIT 3 D",
125 | "BIT 3 E",
126 | "BIT 3 H",
127 | "BIT 3 L",
128 | "BIT 3 (HL)",
129 | "BIT 3 A",
130 |
131 | "BIT 4 B",
132 | "BIT 4 C",
133 | "BIT 4 D",
134 | "BIT 4 E",
135 | "BIT 4 H",
136 | "BIT 4 L",
137 | "BIT 4 (HL)",
138 | "BIT 4 A",
139 | "BIT 5 B",
140 | "BIT 5 C",
141 | "BIT 5 D",
142 | "BIT 5 E",
143 | "BIT 5 H",
144 | "BIT 5 L",
145 | "BIT 5 (HL)",
146 | "BIT 5 A",
147 |
148 | "BIT 6 B",
149 | "BIT 6 C",
150 | "BIT 6 D",
151 | "BIT 6 E",
152 | "BIT 6 H",
153 | "BIT 6 L",
154 | "BIT 6 (HL)",
155 | "BIT 6 A",
156 | "BIT 7 B",
157 | "BIT 7 C",
158 | "BIT 7 D",
159 | "BIT 7 E",
160 | "BIT 7 H",
161 | "BIT 7 L",
162 | "BIT 7 (HL)",
163 | "BIT 7 A",
164 |
165 | "RES 0 B",
166 | "RES 0 C",
167 | "RES 0 D",
168 | "RES 0 E",
169 | "RES 0 H",
170 | "RES 0 L",
171 | "RES 0 (HL)",
172 | "RES 0 A",
173 | "RES 1 B",
174 | "RES 1 C",
175 | "RES 1 D",
176 | "RES 1 E",
177 | "RES 1 H",
178 | "RES 1 L",
179 | "RES 1 (HL)",
180 | "RES 1 A",
181 |
182 | "RES 2 B",
183 | "RES 2 C",
184 | "RES 2 D",
185 | "RES 2 E",
186 | "RES 2 H",
187 | "RES 2 L",
188 | "RES 2 (HL)",
189 | "RES 2 A",
190 | "RES 3 B",
191 | "RES 3 C",
192 | "RES 3 D",
193 | "RES 3 E",
194 | "RES 3 H",
195 | "RES 3 L",
196 | "RES 3 (HL)",
197 | "RES 3 A",
198 |
199 | "RES 4 B",
200 | "RES 4 C",
201 | "RES 4 D",
202 | "RES 4 E",
203 | "RES 4 H",
204 | "RES 4 L",
205 | "RES 4 (HL)",
206 | "RES 4 A",
207 | "RES 5 B",
208 | "RES 5 C",
209 | "RES 5 D",
210 | "RES 5 E",
211 | "RES 5 H",
212 | "RES 5 L",
213 | "RES 5 (HL)",
214 | "RES 5 A",
215 |
216 | "RES 6 B",
217 | "RES 6 C",
218 | "RES 6 D",
219 | "RES 6 E",
220 | "RES 6 H",
221 | "RES 6 L",
222 | "RES 6 (HL)",
223 | "RES 6 A",
224 | "RES 7 B",
225 | "RES 7 C",
226 | "RES 7 D",
227 | "RES 7 E",
228 | "RES 7 H",
229 | "RES 7 L",
230 | "RES 7 (HL)",
231 | "RES 7 A",
232 |
233 | "SET 0 B",
234 | "SET 0 C",
235 | "SET 0 D",
236 | "SET 0 E",
237 | "SET 0 H",
238 | "SET 0 L",
239 | "SET 0 (HL)",
240 | "SET 0 A",
241 | "SET 1 B",
242 | "SET 1 C",
243 | "SET 1 D",
244 | "SET 1 E",
245 | "SET 1 H",
246 | "SET 1 L",
247 | "SET 1 (HL)",
248 | "SET 1 A",
249 |
250 | "SET 2 B",
251 | "SET 2 C",
252 | "SET 2 D",
253 | "SET 2 E",
254 | "SET 2 H",
255 | "SET 2 L",
256 | "SET 2 (HL)",
257 | "SET 2 A",
258 | "SET 3 B",
259 | "SET 3 C",
260 | "SET 3 D",
261 | "SET 3 E",
262 | "SET 3 H",
263 | "SET 3 L",
264 | "SET 3 (HL)",
265 | "SET 3 A",
266 |
267 | "SET 4 B",
268 | "SET 4 C",
269 | "SET 4 D",
270 | "SET 4 E",
271 | "SET 4 H",
272 | "SET 4 L",
273 | "SET 4 (HL)",
274 | "SET 4 A",
275 | "SET 5 B",
276 | "SET 5 C",
277 | "SET 5 D",
278 | "SET 5 E",
279 | "SET 5 H",
280 | "SET 5 L",
281 | "SET 5 (HL)",
282 | "SET 5 A",
283 |
284 | "SET 6 B",
285 | "SET 6 C",
286 | "SET 6 D",
287 | "SET 6 E",
288 | "SET 6 H",
289 | "SET 6 L",
290 | "SET 6 (HL)",
291 | "SET 6 A",
292 | "SET 7 B",
293 | "SET 7 C",
294 | "SET 7 D",
295 | "SET 7 E",
296 | "SET 7 H",
297 | "SET 7 L",
298 | "SET 7 (HL)",
299 | "SET 7 A"
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODECBNAMES_H_
307 |
308 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_dd_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODEDDNAMES_H_
21 | #define GZ80_OPCODEDDNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeDDNames[256] = {
29 | "NOP",
30 | "LD BC,nn",
31 | "LD (BC),A",
32 | "INC BC",
33 | "INC B",
34 | "DEC B",
35 | "LD B,n",
36 | "RLCA",
37 | "EX AF,AF'",
38 | "ADD IX,BC",
39 | "LD A,(BC)",
40 | "DEC BC",
41 | "INC C",
42 | "DEC C",
43 | "LD C,n",
44 | "RRCA",
45 |
46 | "DJNZ (PC+e)",
47 | "LD DE,nn",
48 | "LD (DE),A",
49 | "INC DE",
50 | "INC D",
51 | "DEC D",
52 | "LD D,n",
53 | "RLA",
54 | "JR n",
55 | "ADD IX,DE",
56 | "LD A,(DE)",
57 | "DEC DE",
58 | "INC E",
59 | "DEC E",
60 | "LD E,n",
61 | "RRA",
62 |
63 | "JR NZ,n",
64 | "LD IX,nn",
65 | "LD (nn),IX",
66 | "INC IX",
67 | "INC IXh (UNDOCUMENTED)",
68 | "DEC IXh (UNDOCUMENTED)",
69 | "LD IXh,n (UNDOCUMENTED)",
70 | "DAA",
71 | "JR Z,n",
72 | "ADD IX,IX",
73 | "LD IX,(nn)",
74 | "DEC IX",
75 | "INC IXl (UNDOCUMENTED)",
76 | "DEC IXl (UNDOCUMENTED)",
77 | "LD IXl,n (UNDOCUMENTED)",
78 | "CPL",
79 |
80 | "JR NC,n",
81 | "LD SP,nn",
82 | "LD (nn),A",
83 | "INC SP",
84 | "INC (IX+d)",
85 | "DEC (IX+d)",
86 | "LD (IX+d),n",
87 | "SCF",
88 | "JR C,n",
89 | "ADD IX,SP",
90 | "LD A,(nn)",
91 | "DEC SP",
92 | "INC A",
93 | "DEC A",
94 | "LDA,n",
95 | "CCF",
96 |
97 | "LD B,B",
98 | "LD B,C",
99 | "LD B,D",
100 | "LD B,E",
101 | "LD B,IXh (UNDOCUMENTED)",
102 | "LD B,IXl (UNDOCUMENTED)",
103 | "LD B,(IX+d)",
104 | "LD B,A",
105 | "LD C,B",
106 | "LD C,C",
107 | "LD C,D",
108 | "LD C,E",
109 | "LD C,IXh (UNDOCUMENTED)",
110 | "LD C,IXl (UNDOCUMENTED)",
111 | "LD C,(IX+d)",
112 | "LD C,A",
113 |
114 | "LD D,B",
115 | "LD D,C",
116 | "LD D,D",
117 | "LD D,E",
118 | "LD D,IXh (UNDOCUMENTED)",
119 | "LD D,IXl (UNDOCUMENTED)",
120 | "LD D,(IX+d)",
121 | "LD D,A",
122 | "LD E,B",
123 | "LD E,C",
124 | "LD E,D",
125 | "LD E,E",
126 | "LD E,IXh (UNDOCUMENTED)",
127 | "LD E,IXl (UNDOCUMENTED)",
128 | "LD E,(IX+d)",
129 | "LD E,A",
130 |
131 | "LD IXh,B (UNDOCUMENTED)",
132 | "LD IXh,C (UNDOCUMENTED)",
133 | "LD IXh,D (UNDOCUMENTED)",
134 | "LD IXh,E (UNDOCUMENTED)",
135 | "LD IXh,IXh (UNDOCUMENTED)",
136 | "LD IXh,IXl (UNDOCUMENTED)",
137 | "LD H,(IX+d)",
138 | "LD IXh,A (UNDOCUMENTED)",
139 | "LD IXl,B (UNDOCUMENTED)",
140 | "LD IXl,C (UNDOCUMENTED)",
141 | "LD IXl,D (UNDOCUMENTED)",
142 | "LD IXl,E (UNDOCUMENTED)",
143 | "LD IXl,IXh (UNDOCUMENTED)",
144 | "LD IXl,IXl (UNDOCUMENTED)",
145 | "LD L,(IX+d)",
146 | "LD IXl,A (UNDOCUMENTED)",
147 |
148 | "LD (IX+d),B",
149 | "LD (IX+d),C",
150 | "LD (IX+d),D",
151 | "LD (IX+d),E",
152 | "LD (IX+d),H",
153 | "LD (IX+d),L",
154 | "HALT",
155 | "LD (IX+d),A",
156 | "LD A,B",
157 | "LD A,C",
158 | "LD A,D",
159 | "LD A,E",
160 | "LD A,IXh (UNDOCUMENTED)",
161 | "LD A,IXl (UNDOCUMENTED)",
162 | "LD A,(IX+d)",
163 | "LD A,A",
164 |
165 | "ADD A,B",
166 | "ADD A,C",
167 | "ADD A,D",
168 | "ADD A,E",
169 | "ADD A,IXh (UNDOCUMENTED)",
170 | "ADD A,IXl (UNDOCUMENTED)",
171 | "ADD A,(IX+d)",
172 | "ADD A,A",
173 | "ADC A,B",
174 | "ADC A,C",
175 | "ADC A,D",
176 | "ADC A,E",
177 | "ADC A,IXh (UNDOCUMENTED)",
178 | "ADC A,IXl (UNDOCUMENTED)",
179 | "ADC A,(IX+d)",
180 | "ADC A,A",
181 |
182 | "SUB B",
183 | "SUB C",
184 | "SUB D",
185 | "SUB E",
186 | "SUB IXh (UNDOCUMENTED)",
187 | "SUB IXl (UNDOCUMENTED)",
188 | "SUB (IX+d)",
189 | "SUB A",
190 | "SBC A,B",
191 | "SBC A,C",
192 | "SBC A,D",
193 | "SBC A,E",
194 | "SBC A,IXh (UNDOCUMENTED)",
195 | "SBC A,IXl (UNDOCUMENTED)",
196 | "SBC A,(IX+d)",
197 | "SBC A,A",
198 |
199 | "AND B",
200 | "AND C",
201 | "AND D",
202 | "AND E",
203 | "AND IXh (UNDOCUMENTED)",
204 | "AND IXl (UNDOCUMENTED)",
205 | "AND (IX+d)",
206 | "AND A",
207 | "XOR B",
208 | "XOR C",
209 | "XOR D",
210 | "XOR E",
211 | "XOR IXh (UNDOCUMENTED)",
212 | "XOR IXl (UNDOCUMENTED)",
213 | "XOR (IX+d)",
214 | "XOR A",
215 |
216 | "OR B",
217 | "OR C",
218 | "OR D",
219 | "OR E",
220 | "OR IXh (UNDOCUMENTED)",
221 | "OR IXl (UNDOCUMENTED)",
222 | "OR (IX+d)",
223 | "OR A",
224 | "CP B",
225 | "CP C",
226 | "CP D",
227 | "CP E",
228 | "CP IXh (UNDOCUMENTED)",
229 | "CP IXl (UNDOCUMENTED)",
230 | "CP (IX+d)",
231 | "CP A",
232 |
233 | "RET NZ",
234 | "POP BC",
235 | "JP NZ,nn",
236 | "JP nn",
237 | "CALL NZ,nn",
238 | "PUSH BC",
239 | "ADD A,n",
240 | "RST ",
241 | "RET Z",
242 | "RET",
243 | "JP Z,nn",
244 | "CB PREFIX",
245 | "CALL Z,nn",
246 | "CALL nn",
247 | "ADC A,n",
248 | "RST 08H",
249 |
250 | "RET NC",
251 | "POP DE",
252 | "JP NC,nn",
253 | "OUT (n),A",
254 | "CALL NC,nn",
255 | "PUSH DE",
256 | "SUB n",
257 | "RST 10H",
258 | "RET C",
259 | "EXX",
260 | "JP C,nn",
261 | "IN A,(n)",
262 | "CALL C,nn",
263 | "DD PREFIX",
264 | "SBC A,n",
265 | "RST 18H",
266 |
267 | "RET PO",
268 | "POP IX",
269 | "JP PO,nn",
270 | "EX (SP),IX",
271 | "CALL PO,nn",
272 | "PUSH IX",
273 | "AND n",
274 | "RST 20H",
275 | "RET PE",
276 | "JP (IX)",
277 | "JP PE,nn",
278 | "EX DE,HL",
279 | "CALL PE,nn",
280 | "ED PREFIX",
281 | "XOR n",
282 | "RST 28H",
283 |
284 | "RET P",
285 | "POP AF",
286 | "JP P,nn",
287 | "DI",
288 | "CALL P,nn",
289 | "PUSH AF",
290 | "OR n",
291 | "RST 30H",
292 | "RET M",
293 | "LD SP,IX",
294 | "JP M,nn",
295 | "EI",
296 | "CALL M,nn",
297 | "FD PREFIX",
298 | "CP n",
299 | "RST 38H"
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODEDDNAMES_H_
307 |
308 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_ddcb_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODEDDCBNAMES_H_
21 | #define GZ80_OPCODEDDCBNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeDDCBNames[256] = {
29 | "RLC (IX+d),B (UNDOCUMENTED)",
30 | "RLC (IX+d),C (UNDOCUMENTED)",
31 | "RLC (IX+d),D (UNDOCUMENTED)",
32 | "RLC (IX+d),E (UNDOCUMENTED)",
33 | "RLC (IX+d),H (UNDOCUMENTED)",
34 | "RLC (IX+d),L (UNDOCUMENTED)",
35 | "RLC (IX+d)",
36 | "RLC (IX+d),A (UNDOCUMENTED)",
37 | "RRC (IX+d),B (UNDOCUMENTED)",
38 | "RRC (IX+d),C (UNDOCUMENTED)",
39 | "RRC (IX+d),D (UNDOCUMENTED)",
40 | "RRC (IX+d),E (UNDOCUMENTED)",
41 | "RRC (IX+d),H (UNDOCUMENTED)",
42 | "RRC (IX+d),L (UNDOCUMENTED)",
43 | "RRC (IX+d)",
44 | "RRC (IX+d),A (UNDOCUMENTED)",
45 |
46 | "RL (IX+d),B (UNDOCUMENTED)",
47 | "RL (IX+d),C (UNDOCUMENTED)",
48 | "RL (IX+d),D (UNDOCUMENTED)",
49 | "RL (IX+d),E (UNDOCUMENTED)",
50 | "RL (IX+d),H (UNDOCUMENTED)",
51 | "RL (IX+d),L (UNDOCUMENTED)",
52 | "RL (IX+d)",
53 | "RL (IX+d),A (UNDOCUMENTED)",
54 | "RR (IX+d),B (UNDOCUMENTED)",
55 | "RR (IX+d),C (UNDOCUMENTED)",
56 | "RR (IX+d),D (UNDOCUMENTED)",
57 | "RR (IX+d),E (UNDOCUMENTED)",
58 | "RR (IX+d),H (UNDOCUMENTED)",
59 | "RR (IX+d),L (UNDOCUMENTED)",
60 | "RR (IX+d)",
61 | "RR (IX+d),A (UNDOCUMENTED)",
62 |
63 | "SLA (IX+d),B (UNDOCUMENTED)",
64 | "SLA (IX+d),C (UNDOCUMENTED)",
65 | "SLA (IX+d),D (UNDOCUMENTED)",
66 | "SLA (IX+d),E (UNDOCUMENTED)",
67 | "SLA (IX+d),H (UNDOCUMENTED)",
68 | "SLA (IX+d),L (UNDOCUMENTED)",
69 | "SLA (IX+d)",
70 | "SLA (IX+d),A (UNDOCUMENTED)",
71 | "SRA (IX+d),B (UNDOCUMENTED)",
72 | "SRA (IX+d),C (UNDOCUMENTED)",
73 | "SRA (IX+d),D (UNDOCUMENTED)",
74 | "SRA (IX+d),E (UNDOCUMENTED)",
75 | "SRA (IX+d),H (UNDOCUMENTED)",
76 | "SRA (IX+d),L (UNDOCUMENTED)",
77 | "SRA (IX+d)",
78 | "SRA (IX+d),A (UNDOCUMENTED)",
79 |
80 | "SLL (IX+d),B (UNDOCUMENTED)",
81 | "SLL (IX+d),C (UNDOCUMENTED)",
82 | "SLL (IX+d),D (UNDOCUMENTED)",
83 | "SLL (IX+d),E (UNDOCUMENTED)",
84 | "SLL (IX+d),H (UNDOCUMENTED)",
85 | "SLL (IX+d),L (UNDOCUMENTED)",
86 | "SLL (IX+d) (UNDOCUMENTED)",
87 | "SLL (IX+d),A (UNDOCUMENTED)",
88 | "SRL (IX+d),B (UNDOCUMENTED)",
89 | "SRL (IX+d),C (UNDOCUMENTED)",
90 | "SRL (IX+d),D (UNDOCUMENTED)",
91 | "SRL (IX+d),E (UNDOCUMENTED)",
92 | "SRL (IX+d),H (UNDOCUMENTED)",
93 | "SRL (IX+d),L (UNDOCUMENTED)",
94 | "SRL (IX+d)",
95 | "SRL (IX+d),A (UNDOCUMENTED)",
96 |
97 | "BIT 0,(IX+d) (UNDOCUMENTED)",
98 | "BIT 0,(IX+d) (UNDOCUMENTED)",
99 | "BIT 0,(IX+d) (UNDOCUMENTED)",
100 | "BIT 0,(IX+d) (UNDOCUMENTED)",
101 | "BIT 0,(IX+d) (UNDOCUMENTED)",
102 | "BIT 0,(IX+d) (UNDOCUMENTED)",
103 | "BIT 0,(IX+d)",
104 | "BIT 0,(IX+d) (UNDOCUMENTED)",
105 | "BIT 1,(IX+d) (UNDOCUMENTED)",
106 | "BIT 1,(IX+d) (UNDOCUMENTED)",
107 | "BIT 1,(IX+d) (UNDOCUMENTED)",
108 | "BIT 1,(IX+d) (UNDOCUMENTED)",
109 | "BIT 1,(IX+d) (UNDOCUMENTED)",
110 | "BIT 1,(IX+d) (UNDOCUMENTED)",
111 | "BIT 1,(IX+d)",
112 | "BIT 1,(IX+d) (UNDOCUMENTED)",
113 |
114 | "BIT 2,(IX+d) (UNDOCUMENTED)",
115 | "BIT 2,(IX+d) (UNDOCUMENTED)",
116 | "BIT 2,(IX+d) (UNDOCUMENTED)",
117 | "BIT 2,(IX+d) (UNDOCUMENTED)",
118 | "BIT 2,(IX+d) (UNDOCUMENTED)",
119 | "BIT 2,(IX+d) (UNDOCUMENTED)",
120 | "BIT 2,(IX+d)",
121 | "BIT 2,(IX+d) (UNDOCUMENTED)",
122 | "BIT 3,(IX+d) (UNDOCUMENTED)",
123 | "BIT 3,(IX+d) (UNDOCUMENTED)",
124 | "BIT 3,(IX+d) (UNDOCUMENTED)",
125 | "BIT 3,(IX+d) (UNDOCUMENTED)",
126 | "BIT 3,(IX+d) (UNDOCUMENTED)",
127 | "BIT 3,(IX+d) (UNDOCUMENTED)",
128 | "BIT 3,(IX+d)",
129 | "BIT 3,(IX+d) (UNDOCUMENTED)",
130 |
131 | "BIT 4,(IX+d) (UNDOCUMENTED)",
132 | "BIT 4,(IX+d) (UNDOCUMENTED)",
133 | "BIT 4,(IX+d) (UNDOCUMENTED)",
134 | "BIT 4,(IX+d) (UNDOCUMENTED)",
135 | "BIT 4,(IX+d) (UNDOCUMENTED)",
136 | "BIT 4,(IX+d) (UNDOCUMENTED)",
137 | "BIT 4,(IX+d)",
138 | "BIT 4,(IX+d) (UNDOCUMENTED)",
139 | "BIT 5,(IX+d) (UNDOCUMENTED)",
140 | "BIT 5,(IX+d) (UNDOCUMENTED)",
141 | "BIT 5,(IX+d) (UNDOCUMENTED)",
142 | "BIT 5,(IX+d) (UNDOCUMENTED)",
143 | "BIT 5,(IX+d) (UNDOCUMENTED)",
144 | "BIT 5,(IX+d) (UNDOCUMENTED)",
145 | "BIT 5,(IX+d)",
146 | "BIT 5,(IX+d) (UNDOCUMENTED)",
147 |
148 | "BIT 6,(IX+d) (UNDOCUMENTED)",
149 | "BIT 6,(IX+d) (UNDOCUMENTED)",
150 | "BIT 6,(IX+d) (UNDOCUMENTED)",
151 | "BIT 6,(IX+d) (UNDOCUMENTED)",
152 | "BIT 6,(IX+d) (UNDOCUMENTED)",
153 | "BIT 6,(IX+d) (UNDOCUMENTED)",
154 | "BIT 6,(IX+d)",
155 | "BIT 6,(IX+d) (UNDOCUMENTED)",
156 | "BIT 7,(IX+d) (UNDOCUMENTED)",
157 | "BIT 7,(IX+d) (UNDOCUMENTED)",
158 | "BIT 7,(IX+d) (UNDOCUMENTED)",
159 | "BIT 7,(IX+d) (UNDOCUMENTED)",
160 | "BIT 7,(IX+d) (UNDOCUMENTED)",
161 | "BIT 7,(IX+d) (UNDOCUMENTED)",
162 | "BIT 7,(IX+d)",
163 | "BIT 7,(IX+d) (UNDOCUMENTED)",
164 |
165 | "RES 0,(IX+d),B (UNDOCUMENTED)",
166 | "RES 0,(IX+d),C (UNDOCUMENTED)",
167 | "RES 0,(IX+d),D (UNDOCUMENTED)",
168 | "RES 0,(IX+d),E (UNDOCUMENTED)",
169 | "RES 0,(IX+d),H (UNDOCUMENTED)",
170 | "RES 0,(IX+d),L (UNDOCUMENTED)",
171 | "RES 0,(IX+d)",
172 | "RES 0,(IX+d),A (UNDOCUMENTED)",
173 | "RES 1,(IX+d),B (UNDOCUMENTED)",
174 | "RES 1,(IX+d),C (UNDOCUMENTED)",
175 | "RES 1,(IX+d),D (UNDOCUMENTED)",
176 | "RES 1,(IX+d),E (UNDOCUMENTED)",
177 | "RES 1,(IX+d),H (UNDOCUMENTED)",
178 | "RES 1,(IX+d),L (UNDOCUMENTED)",
179 | "RES 1,(IX+d)",
180 | "RES 1,(IX+d),A (UNDOCUMENTED)",
181 |
182 | "RES 2,(IX+d),B (UNDOCUMENTED)",
183 | "RES 2,(IX+d),C (UNDOCUMENTED)",
184 | "RES 2,(IX+d),D (UNDOCUMENTED)",
185 | "RES 2,(IX+d),E (UNDOCUMENTED)",
186 | "RES 2,(IX+d),H (UNDOCUMENTED)",
187 | "RES 2,(IX+d),L (UNDOCUMENTED)",
188 | "RES 2,(IX+d)",
189 | "RES 2,(IX+d),A (UNDOCUMENTED)",
190 | "RES 3,(IX+d),B (UNDOCUMENTED)",
191 | "RES 3,(IX+d),C (UNDOCUMENTED)",
192 | "RES 3,(IX+d),D (UNDOCUMENTED)",
193 | "RES 3,(IX+d),E (UNDOCUMENTED)",
194 | "RES 3,(IX+d),H (UNDOCUMENTED)",
195 | "RES 3,(IX+d),L (UNDOCUMENTED)",
196 | "RES 3,(IX+d)",
197 | "RES 3,(IX+d),A (UNDOCUMENTED)",
198 |
199 | "RES 4,(IX+d),B (UNDOCUMENTED)",
200 | "RES 4,(IX+d),C (UNDOCUMENTED)",
201 | "RES 4,(IX+d),D (UNDOCUMENTED)",
202 | "RES 4,(IX+d),E (UNDOCUMENTED)",
203 | "RES 4,(IX+d),H (UNDOCUMENTED)",
204 | "RES 4,(IX+d),L (UNDOCUMENTED)",
205 | "RES 4,(IX+d)",
206 | "RES 4,(IX+d),A (UNDOCUMENTED)",
207 | "RES 5,(IX+d),B (UNDOCUMENTED)",
208 | "RES 5,(IX+d),C (UNDOCUMENTED)",
209 | "RES 5,(IX+d),D (UNDOCUMENTED)",
210 | "RES 5,(IX+d),E (UNDOCUMENTED)",
211 | "RES 5,(IX+d),H (UNDOCUMENTED)",
212 | "RES 5,(IX+d),L (UNDOCUMENTED)",
213 | "RES 5,(IX+d)",
214 | "RES 5,(IX+d),A (UNDOCUMENTED)",
215 |
216 | "RES 6,(IX+d),B (UNDOCUMENTED)",
217 | "RES 6,(IX+d),C (UNDOCUMENTED)",
218 | "RES 6,(IX+d),D (UNDOCUMENTED)",
219 | "RES 6,(IX+d),E (UNDOCUMENTED)",
220 | "RES 6,(IX+d),H (UNDOCUMENTED)",
221 | "RES 6,(IX+d),L (UNDOCUMENTED)",
222 | "RES 6,(IX+d)",
223 | "RES 6,(IX+d),A (UNDOCUMENTED)",
224 | "RES 7,(IX+d),B (UNDOCUMENTED)",
225 | "RES 7,(IX+d),C (UNDOCUMENTED)",
226 | "RES 7,(IX+d),D (UNDOCUMENTED)",
227 | "RES 7,(IX+d),E (UNDOCUMENTED)",
228 | "RES 7,(IX+d),H (UNDOCUMENTED)",
229 | "RES 7,(IX+d),L (UNDOCUMENTED)",
230 | "RES 7,(IX+d)",
231 | "RES 7,(IX+d),A (UNDOCUMENTED)",
232 |
233 | "SET 0,(IX+d),B (UNDOCUMENTED)",
234 | "SET 0,(IX+d),C (UNDOCUMENTED)",
235 | "SET 0,(IX+d),D (UNDOCUMENTED)",
236 | "SET 0,(IX+d),E (UNDOCUMENTED)",
237 | "SET 0,(IX+d),H (UNDOCUMENTED)",
238 | "SET 0,(IX+d),L (UNDOCUMENTED)",
239 | "SET 0,(IX+d)",
240 | "SET 0,(IX+d),A (UNDOCUMENTED)",
241 | "SET 1,(IX+d),B (UNDOCUMENTED)",
242 | "SET 1,(IX+d),C (UNDOCUMENTED)",
243 | "SET 1,(IX+d),D (UNDOCUMENTED)",
244 | "SET 1,(IX+d),E (UNDOCUMENTED)",
245 | "SET 1,(IX+d),H (UNDOCUMENTED)",
246 | "SET 1,(IX+d),L (UNDOCUMENTED)",
247 | "SET 1,(IX+d)",
248 | "SET 1,(IX+d),A (UNDOCUMENTED)",
249 |
250 | "SET 2,(IX+d),B (UNDOCUMENTED)",
251 | "SET 2,(IX+d),C (UNDOCUMENTED)",
252 | "SET 2,(IX+d),D (UNDOCUMENTED)",
253 | "SET 2,(IX+d),E (UNDOCUMENTED)",
254 | "SET 2,(IX+d),H (UNDOCUMENTED)",
255 | "SET 2,(IX+d),L (UNDOCUMENTED)",
256 | "SET 2,(IX+d)",
257 | "SET 2,(IX+d),A (UNDOCUMENTED)",
258 | "SET 3,(IX+d),B (UNDOCUMENTED)",
259 | "SET 3,(IX+d),C (UNDOCUMENTED)",
260 | "SET 3,(IX+d),D (UNDOCUMENTED)",
261 | "SET 3,(IX+d),E (UNDOCUMENTED)",
262 | "SET 3,(IX+d),H (UNDOCUMENTED)",
263 | "SET 3,(IX+d),L (UNDOCUMENTED)",
264 | "SET 3,(IX+d)",
265 | "SET 3,(IX+d),A (UNDOCUMENTED)",
266 |
267 | "SET 4,(IX+d),B (UNDOCUMENTED)",
268 | "SET 4,(IX+d),C (UNDOCUMENTED)",
269 | "SET 4,(IX+d),D (UNDOCUMENTED)",
270 | "SET 4,(IX+d),E (UNDOCUMENTED)",
271 | "SET 4,(IX+d),H (UNDOCUMENTED)",
272 | "SET 4,(IX+d),L (UNDOCUMENTED)",
273 | "SET 4,(IX+d)",
274 | "SET 4,(IX+d),A (UNDOCUMENTED)",
275 | "SET 5,(IX+d),B (UNDOCUMENTED)",
276 | "SET 5,(IX+d),C (UNDOCUMENTED)",
277 | "SET 5,(IX+d),D (UNDOCUMENTED)",
278 | "SET 5,(IX+d),E (UNDOCUMENTED)",
279 | "SET 5,(IX+d),H (UNDOCUMENTED)",
280 | "SET 5,(IX+d),L (UNDOCUMENTED)",
281 | "SET 5,(IX+d)",
282 | "SET 5,(IX+d),A (UNDOCUMENTED)",
283 |
284 | "SET 6,(IX+d),B (UNDOCUMENTED)",
285 | "SET 6,(IX+d),C (UNDOCUMENTED)",
286 | "SET 6,(IX+d),D (UNDOCUMENTED)",
287 | "SET 6,(IX+d),E (UNDOCUMENTED)",
288 | "SET 6,(IX+d),H (UNDOCUMENTED)",
289 | "SET 6,(IX+d),L (UNDOCUMENTED)",
290 | "SET 6,(IX+d)",
291 | "SET 6,(IX+d),A (UNDOCUMENTED)",
292 | "SET 7,(IX+d),B (UNDOCUMENTED)",
293 | "SET 7,(IX+d),C (UNDOCUMENTED)",
294 | "SET 7,(IX+d),D (UNDOCUMENTED)",
295 | "SET 7,(IX+d),E (UNDOCUMENTED)",
296 | "SET 7,(IX+d),H (UNDOCUMENTED)",
297 | "SET 7,(IX+d),L (UNDOCUMENTED)",
298 | "SET 7,(IX+d)",
299 | "SET 7,(IX+d),A (UNDOCUMENTED)"
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODEDDCBNAMES_H_
307 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_ed_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODEEDNAMES_H_
21 | #define GZ80_OPCODEEDNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeEDNames[256] = {
29 | "INVALID",
30 | "INVALID",
31 | "INVALID",
32 | "INVALID",
33 | "INVALID",
34 | "INVALID",
35 | "INVALID",
36 | "INVALID",
37 | "INVALID",
38 | "INVALID",
39 | "INVALID",
40 | "INVALID",
41 | "INVALID",
42 | "INVALID",
43 | "INVALID",
44 | "INVALID",
45 |
46 | "INVALID",
47 | "INVALID",
48 | "INVALID",
49 | "INVALID",
50 | "INVALID",
51 | "INVALID",
52 | "INVALID",
53 | "INVALID",
54 | "INVALID",
55 | "INVALID",
56 | "INVALID",
57 | "INVALID",
58 | "INVALID",
59 | "INVALID",
60 | "INVALID",
61 | "INVALID",
62 |
63 | "INVALID",
64 | "INVALID",
65 | "INVALID",
66 | "INVALID",
67 | "INVALID",
68 | "INVALID",
69 | "INVALID",
70 | "INVALID",
71 | "INVALID",
72 | "INVALID",
73 | "INVALID",
74 | "INVALID",
75 | "INVALID",
76 | "INVALID",
77 | "INVALID",
78 | "INVALID",
79 |
80 | "INVALID",
81 | "INVALID",
82 | "INVALID",
83 | "INVALID",
84 | "INVALID",
85 | "INVALID",
86 | "INVALID",
87 | "INVALID",
88 | "INVALID",
89 | "INVALID",
90 | "INVALID",
91 | "INVALID",
92 | "INVALID",
93 | "INVALID",
94 | "INVALID",
95 | "INVALID",
96 |
97 | "IN B,(C)",
98 | "OUT (C),B",
99 | "SBC HL,BC",
100 | "LD (nn),BC",
101 | "NEG",
102 | "RETN",
103 | "IM 0",
104 | "LD I,A",
105 | "IN C,(C)",
106 | "OUT (C),C",
107 | "ADC HL,BC",
108 | "LD BC,(nn)",
109 | "NEG*",
110 | "RETI",
111 | "IM 0*",
112 | "LD R,A",
113 |
114 | "IN D,(C)",
115 | "OUT (C),D",
116 | "SBC HL,DE",
117 | "LD (nn),DE",
118 | "NEG*",
119 | "RETN*",
120 | "IM 1",
121 | "LD A,I",
122 | "IN E,(C)",
123 | "OUT (C),E",
124 | "ADC HL,DE",
125 | "LD DE,(nn)",
126 | "NEG*",
127 | "RETN*",
128 | "IM 2",
129 | "LD A,R",
130 |
131 | "IN H,(C)",
132 | "OUT (C),H",
133 | "SBC HL,HL",
134 | "LD (nn),HL",
135 | "NEG*",
136 | "RETN*",
137 | "IM 0*",
138 | "RRD",
139 | "IN L,(C)",
140 | "OUT (C),L",
141 | "ADC HL,HL",
142 | "LD HL,(nn)",
143 | "NEG*",
144 | "RETN*",
145 | "IM 0*",
146 | "RLD",
147 |
148 | "IN F,(C)*",
149 | "OUT (C),0*",
150 | "SBC HL,SP",
151 | "LD (nn),SP",
152 | "NEG*",
153 | "RETN*",
154 | "IM 1*",
155 | "INVALID",
156 | "IN A,(C)",
157 | "OUT (C),A",
158 | "ADC HL,SP",
159 | "LD SP,(nn)",
160 | "NEG*",
161 | "RETN*",
162 | "IM 2*",
163 | "INVALID",
164 |
165 | "INVALID",
166 | "INVALID",
167 | "INVALID",
168 | "INVALID",
169 | "INVALID",
170 | "INVALID",
171 | "INVALID",
172 | "INVALID",
173 | "INVALID",
174 | "INVALID",
175 | "INVALID",
176 | "INVALID",
177 | "INVALID",
178 | "INVALID",
179 | "INVALID",
180 | "INVALID",
181 |
182 | "INVALID",
183 | "INVALID",
184 | "INVALID",
185 | "INVALID",
186 | "INVALID",
187 | "INVALID",
188 | "INVALID",
189 | "INVALID",
190 | "INVALID",
191 | "INVALID",
192 | "INVALID",
193 | "INVALID",
194 | "INVALID",
195 | "INVALID",
196 | "INVALID",
197 | "INVALID",
198 |
199 | "LDI",
200 | "CPI",
201 | "INI",
202 | "OUTI",
203 | "INVALID",
204 | "INVALID",
205 | "INVALID",
206 | "INVALID",
207 | "LDD",
208 | "CPD",
209 | "IND",
210 | "OUTD",
211 | "INVALID",
212 | "INVALID",
213 | "INVALID",
214 | "INVALID",
215 |
216 | "LDIR",
217 | "CPIR",
218 | "INIR",
219 | "OTIR",
220 | "INVALID",
221 | "INVALID",
222 | "INVALID",
223 | "INVALID",
224 | "LDDR",
225 | "CPDR",
226 | "INDR",
227 | "OTDR",
228 | "INVALID",
229 | "INVALID",
230 | "INVALID",
231 | "INVALID",
232 |
233 | "INVALID",
234 | "INVALID",
235 | "INVALID",
236 | "INVALID",
237 | "INVALID",
238 | "INVALID",
239 | "INVALID",
240 | "INVALID",
241 | "INVALID",
242 | "INVALID",
243 | "INVALID",
244 | "INVALID",
245 | "INVALID",
246 | "INVALID",
247 | "INVALID",
248 | "INVALID",
249 |
250 | "INVALID",
251 | "INVALID",
252 | "INVALID",
253 | "INVALID",
254 | "INVALID",
255 | "INVALID",
256 | "INVALID",
257 | "INVALID",
258 | "INVALID",
259 | "INVALID",
260 | "INVALID",
261 | "INVALID",
262 | "INVALID",
263 | "INVALID",
264 | "INVALID",
265 | "INVALID",
266 |
267 | "INVALID",
268 | "INVALID",
269 | "INVALID",
270 | "INVALID",
271 | "INVALID",
272 | "INVALID",
273 | "INVALID",
274 | "INVALID",
275 | "INVALID",
276 | "INVALID",
277 | "INVALID",
278 | "INVALID",
279 | "INVALID",
280 | "INVALID",
281 | "INVALID",
282 | "INVALID",
283 |
284 | "INVALID",
285 | "INVALID",
286 | "INVALID",
287 | "INVALID",
288 | "INVALID",
289 | "INVALID",
290 | "INVALID",
291 | "INVALID",
292 | "INVALID",
293 | "INVALID",
294 | "INVALID",
295 | "INVALID",
296 | "INVALID",
297 | "INVALID",
298 | "INVALID",
299 | "INVALID",
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODEEDNAMES_H_
307 |
308 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_fd_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODEFDNAMES_H_
21 | #define GZ80_OPCODEFDNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeFDNames[256] = {
29 | "NOP",
30 | "LD BC,nn",
31 | "LD (BC),A",
32 | "INC BC",
33 | "INC B",
34 | "DEC B",
35 | "LD B,n",
36 | "RLCA",
37 | "EX AF,AF'",
38 | "ADD IY,BC",
39 | "LD A,(BC)",
40 | "DEC BC",
41 | "INC C",
42 | "DEC C",
43 | "LD C,n",
44 | "RRCA",
45 |
46 | "DJNZ (PC+e)",
47 | "LD DE,nn",
48 | "LD (DE),A",
49 | "INC DE",
50 | "INC D",
51 | "DEC D",
52 | "LD D,n",
53 | "RLA",
54 | "JR n",
55 | "ADD IY,DE",
56 | "LD A,(DE)",
57 | "DEC DE",
58 | "INC E",
59 | "DEC E",
60 | "LD E,n",
61 | "RRA",
62 |
63 | "JR NZ,n",
64 | "LD IY,nn",
65 | "LD (nn),IY",
66 | "INC IY",
67 | "INC IYh (UNDOCUMENTED)",
68 | "DEC IYh (UNDOCUMENTED)",
69 | "LD IYh,n (UNDOCUMENTED)",
70 | "DAA",
71 | "JR Z,n",
72 | "ADD IY,IY",
73 | "LD IY,(nn)",
74 | "DEC IY",
75 | "INC IYl (UNDOCUMENTED)",
76 | "DEC IYl (UNDOCUMENTED)",
77 | "LD IYl,n (UNDOCUMENTED)",
78 | "CPL",
79 |
80 | "JR NC,n",
81 | "LD SP,nn",
82 | "LD (nn),A",
83 | "INC SP",
84 | "INC (IY+d)",
85 | "DEC (IY+d)",
86 | "LD (IY+d),n",
87 | "SCF",
88 | "JR C,n",
89 | "ADD IY,SP",
90 | "LD A,(nn)",
91 | "DEC SP",
92 | "INC A",
93 | "DEC A",
94 | "LDA,n",
95 | "CCF",
96 |
97 | "LD B,B",
98 | "LD B,C",
99 | "LD B,D",
100 | "LD B,E",
101 | "LD B,IYh (UNDOCUMENTED)",
102 | "LD B,IYl (UNDOCUMENTED)",
103 | "LD B,(IY+d)",
104 | "LD B,A",
105 | "LD C,B",
106 | "LD C,C",
107 | "LD C,D",
108 | "LD C,E",
109 | "LD C,IYh (UNDOCUMENTED)",
110 | "LD C,IYl (UNDOCUMENTED)",
111 | "LD C,(IY+d)",
112 | "LD C,A",
113 |
114 | "LD D,B",
115 | "LD D,C",
116 | "LD D,D",
117 | "LD D,E",
118 | "LD D,IYh (UNDOCUMENTED)",
119 | "LD D,IYl (UNDOCUMENTED)",
120 | "LD D,(IY+d)",
121 | "LD D,A",
122 | "LD E,B",
123 | "LD E,C",
124 | "LD E,D",
125 | "LD E,E",
126 | "LD E,IYh (UNDOCUMENTED)",
127 | "LD E,IYl (UNDOCUMENTED)",
128 | "LD E,(IY+d)",
129 | "LD E,A",
130 |
131 | "LD IYh,B (UNDOCUMENTED)",
132 | "LD IYh,C (UNDOCUMENTED)",
133 | "LD IYh,D (UNDOCUMENTED)",
134 | "LD IYh,E (UNDOCUMENTED)",
135 | "LD IYh,IYh (UNDOCUMENTED)",
136 | "LD IYh,IYl (UNDOCUMENTED)",
137 | "LD H,(IY+d)",
138 | "LD IYh,A (UNDOCUMENTED)",
139 | "LD IYl,B (UNDOCUMENTED)",
140 | "LD IYl,C (UNDOCUMENTED)",
141 | "LD IYl,D (UNDOCUMENTED)",
142 | "LD IYl,E (UNDOCUMENTED)",
143 | "LD IYl,IYh (UNDOCUMENTED)",
144 | "LD IYl,IYl (UNDOCUMENTED)",
145 | "LD L,(IY+d)",
146 | "LD IYl,A (UNDOCUMENTED)",
147 |
148 | "LD (IY+d),B",
149 | "LD (IY+d),C",
150 | "LD (IY+d),D",
151 | "LD (IY+d),E",
152 | "LD (IY+d),H",
153 | "LD (IY+d),L",
154 | "HALT",
155 | "LD (IY+d),A",
156 | "LD A,B",
157 | "LD A,C",
158 | "LD A,D",
159 | "LD A,E",
160 | "LD A,IYh (UNDOCUMENTED)",
161 | "LD A,IYl (UNDOCUMENTED)",
162 | "LD A,(IY+d)",
163 | "LD A,A",
164 |
165 | "ADD A,B",
166 | "ADD A,C",
167 | "ADD A,D",
168 | "ADD A,E",
169 | "ADD A,IYh (UNDOCUMENTED)",
170 | "ADD A,IYl (UNDOCUMENTED)",
171 | "ADD A,(IY+d)",
172 | "ADD A,A",
173 | "ADC A,B",
174 | "ADC A,C",
175 | "ADC A,D",
176 | "ADC A,E",
177 | "ADC A,IYh (UNDOCUMENTED)",
178 | "ADC A,IYl (UNDOCUMENTED)",
179 | "ADC A,(IY+d)",
180 | "ADC A,A",
181 |
182 | "SUB B",
183 | "SUB C",
184 | "SUB D",
185 | "SUB E",
186 | "SUB IYh (UNDOCUMENTED)",
187 | "SUB IYl (UNDOCUMENTED)",
188 | "SUB (IY+d)",
189 | "SUB A",
190 | "SBC A,B",
191 | "SBC A,C",
192 | "SBC A,D",
193 | "SBC A,E",
194 | "SBC A,IYh (UNDOCUMENTED)",
195 | "SBC A,IYl (UNDOCUMENTED)",
196 | "SBC A,(IY+d)",
197 | "SBC A,A",
198 |
199 | "AND B",
200 | "AND C",
201 | "AND D",
202 | "AND E",
203 | "AND IYh (UNDOCUMENTED)",
204 | "AND IYl (UNDOCUMENTED)",
205 | "AND (IY+d)",
206 | "AND A",
207 | "XOR B",
208 | "XOR C",
209 | "XOR D",
210 | "XOR E",
211 | "XOR IYh (UNDOCUMENTED)",
212 | "XOR IYl (UNDOCUMENTED)",
213 | "XOR (IY+d)",
214 | "XOR A",
215 |
216 | "OR B",
217 | "OR C",
218 | "OR D",
219 | "OR E",
220 | "OR IYh (UNDOCUMENTED)",
221 | "OR IYl (UNDOCUMENTED)",
222 | "OR (IY+d)",
223 | "OR A",
224 | "CP B",
225 | "CP C",
226 | "CP D",
227 | "CP E",
228 | "CP IYh (UNDOCUMENTED)",
229 | "CP IYl (UNDOCUMENTED)",
230 | "CP (IY+d)",
231 | "CP A",
232 |
233 | "RET NZ",
234 | "POP BC",
235 | "JP NZ,nn",
236 | "JP nn",
237 | "CALL NZ,nn",
238 | "PUSH BC",
239 | "ADD A,n",
240 | "RST ",
241 | "RET Z",
242 | "RET",
243 | "JP Z,nn",
244 | "CB PREFIX",
245 | "CALL Z,nn",
246 | "CALL nn",
247 | "ADC A,n",
248 | "RST 08H",
249 |
250 | "RET NC",
251 | "POP DE",
252 | "JP NC,nn",
253 | "OUT (n),A",
254 | "CALL NC,nn",
255 | "PUSH DE",
256 | "SUB n",
257 | "RST 10H",
258 | "RET C",
259 | "EXX",
260 | "JP C,nn",
261 | "IN A,(n)",
262 | "CALL C,nn",
263 | "DD PREFIX",
264 | "SBC A,n",
265 | "RST 18H",
266 |
267 | "RET PO",
268 | "POP IY",
269 | "JP PO,nn",
270 | "EX (SP),IY",
271 | "CALL PO,nn",
272 | "PUSH IY",
273 | "AND n",
274 | "RST 20H",
275 | "RET PE",
276 | "JP (IY)",
277 | "JP PE,nn",
278 | "EX DE,HL",
279 | "CALL PE,nn",
280 | "ED PREFIX",
281 | "XOR n",
282 | "RST 28H",
283 |
284 | "RET P",
285 | "POP AF",
286 | "JP P,nn",
287 | "DI",
288 | "CALL P,nn",
289 | "PUSH AF",
290 | "OR n",
291 | "RST 30H",
292 | "RET M",
293 | "LD SP,IY",
294 | "JP M,nn",
295 | "EI",
296 | "CALL M,nn",
297 | "FD PREFIX",
298 | "CP n",
299 | "RST 38H"
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODEFDNAMES_H_
307 |
308 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_fdcb_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODEFDCBNAMES_H_
21 | #define GZ80_OPCODEFDCBNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeFDCBNames[256] = {
29 | "RLC (IY+d),B (UNDOCUMENTED)",
30 | "RLC (IY+d),C (UNDOCUMENTED)",
31 | "RLC (IY+d),D (UNDOCUMENTED)",
32 | "RLC (IY+d),E (UNDOCUMENTED)",
33 | "RLC (IY+d),H (UNDOCUMENTED)",
34 | "RLC (IY+d),L (UNDOCUMENTED)",
35 | "RLC (IY+d)",
36 | "RLC (IY+d),A (UNDOCUMENTED)",
37 | "RRC (IY+d),B (UNDOCUMENTED)",
38 | "RRC (IY+d),C (UNDOCUMENTED)",
39 | "RRC (IY+d),D (UNDOCUMENTED)",
40 | "RRC (IY+d),E (UNDOCUMENTED)",
41 | "RRC (IY+d),H (UNDOCUMENTED)",
42 | "RRC (IY+d),L (UNDOCUMENTED)",
43 | "RRC (IY+d)",
44 | "RRC (IY+d),A (UNDOCUMENTED)",
45 |
46 | "RL (IY+d),B (UNDOCUMENTED)",
47 | "RL (IY+d),C (UNDOCUMENTED)",
48 | "RL (IY+d),D (UNDOCUMENTED)",
49 | "RL (IY+d),E (UNDOCUMENTED)",
50 | "RL (IY+d),H (UNDOCUMENTED)",
51 | "RL (IY+d),L (UNDOCUMENTED)",
52 | "RL (IY+d)",
53 | "RL (IY+d),A (UNDOCUMENTED)",
54 | "RR (IY+d),B (UNDOCUMENTED)",
55 | "RR (IY+d),C (UNDOCUMENTED)",
56 | "RR (IY+d),D (UNDOCUMENTED)",
57 | "RR (IY+d),E (UNDOCUMENTED)",
58 | "RR (IY+d),H (UNDOCUMENTED)",
59 | "RR (IY+d),L (UNDOCUMENTED)",
60 | "RR (IY+d)",
61 | "RR (IY+d),A (UNDOCUMENTED)",
62 |
63 | "SLA (IY+d),B (UNDOCUMENTED)",
64 | "SLA (IY+d),C (UNDOCUMENTED)",
65 | "SLA (IY+d),D (UNDOCUMENTED)",
66 | "SLA (IY+d),E (UNDOCUMENTED)",
67 | "SLA (IY+d),H (UNDOCUMENTED)",
68 | "SLA (IY+d),L (UNDOCUMENTED)",
69 | "SLA (IY+d)",
70 | "SLA (IY+d),A (UNDOCUMENTED)",
71 | "SRA (IY+d),B (UNDOCUMENTED)",
72 | "SRA (IY+d),C (UNDOCUMENTED)",
73 | "SRA (IY+d),D (UNDOCUMENTED)",
74 | "SRA (IY+d),E (UNDOCUMENTED)",
75 | "SRA (IY+d),H (UNDOCUMENTED)",
76 | "SRA (IY+d),L (UNDOCUMENTED)",
77 | "SRA (IY+d)",
78 | "SRA (IY+d),A (UNDOCUMENTED)",
79 |
80 | "SLL (IY+d),B (UNDOCUMENTED)",
81 | "SLL (IY+d),C (UNDOCUMENTED)",
82 | "SLL (IY+d),D (UNDOCUMENTED)",
83 | "SLL (IY+d),E (UNDOCUMENTED)",
84 | "SLL (IY+d),H (UNDOCUMENTED)",
85 | "SLL (IY+d),L (UNDOCUMENTED)",
86 | "SLL (IY+d) (UNDOCUMENTED)",
87 | "SLL (IY+d),A (UNDOCUMENTED)",
88 | "SRL (IY+d),B (UNDOCUMENTED)",
89 | "SRL (IY+d),C (UNDOCUMENTED)",
90 | "SRL (IY+d),D (UNDOCUMENTED)",
91 | "SRL (IY+d),E (UNDOCUMENTED)",
92 | "SRL (IY+d),H (UNDOCUMENTED)",
93 | "SRL (IY+d),L (UNDOCUMENTED)",
94 | "SRL (IY+d)",
95 | "SRL (IY+d),A (UNDOCUMENTED)",
96 |
97 | "BIT 0,(IY+d) (UNDOCUMENTED)",
98 | "BIT 0,(IY+d) (UNDOCUMENTED)",
99 | "BIT 0,(IY+d) (UNDOCUMENTED)",
100 | "BIT 0,(IY+d) (UNDOCUMENTED)",
101 | "BIT 0,(IY+d) (UNDOCUMENTED)",
102 | "BIT 0,(IY+d) (UNDOCUMENTED)",
103 | "BIT 0,(IY+d)",
104 | "BIT 0,(IY+d) (UNDOCUMENTED)",
105 | "BIT 1,(IY+d) (UNDOCUMENTED)",
106 | "BIT 1,(IY+d) (UNDOCUMENTED)",
107 | "BIT 1,(IY+d) (UNDOCUMENTED)",
108 | "BIT 1,(IY+d) (UNDOCUMENTED)",
109 | "BIT 1,(IY+d) (UNDOCUMENTED)",
110 | "BIT 1,(IY+d) (UNDOCUMENTED)",
111 | "BIT 1,(IY+d)",
112 | "BIT 1,(IY+d) (UNDOCUMENTED)",
113 |
114 | "BIT 2,(IY+d) (UNDOCUMENTED)",
115 | "BIT 2,(IY+d) (UNDOCUMENTED)",
116 | "BIT 2,(IY+d) (UNDOCUMENTED)",
117 | "BIT 2,(IY+d) (UNDOCUMENTED)",
118 | "BIT 2,(IY+d) (UNDOCUMENTED)",
119 | "BIT 2,(IY+d) (UNDOCUMENTED)",
120 | "BIT 2,(IY+d)",
121 | "BIT 2,(IY+d) (UNDOCUMENTED)",
122 | "BIT 3,(IY+d) (UNDOCUMENTED)",
123 | "BIT 3,(IY+d) (UNDOCUMENTED)",
124 | "BIT 3,(IY+d) (UNDOCUMENTED)",
125 | "BIT 3,(IY+d) (UNDOCUMENTED)",
126 | "BIT 3,(IY+d) (UNDOCUMENTED)",
127 | "BIT 3,(IY+d) (UNDOCUMENTED)",
128 | "BIT 3,(IY+d)",
129 | "BIT 3,(IY+d) (UNDOCUMENTED)",
130 |
131 | "BIT 4,(IY+d) (UNDOCUMENTED)",
132 | "BIT 4,(IY+d) (UNDOCUMENTED)",
133 | "BIT 4,(IY+d) (UNDOCUMENTED)",
134 | "BIT 4,(IY+d) (UNDOCUMENTED)",
135 | "BIT 4,(IY+d) (UNDOCUMENTED)",
136 | "BIT 4,(IY+d) (UNDOCUMENTED)",
137 | "BIT 4,(IY+d)",
138 | "BIT 4,(IY+d) (UNDOCUMENTED)",
139 | "BIT 5,(IY+d) (UNDOCUMENTED)",
140 | "BIT 5,(IY+d) (UNDOCUMENTED)",
141 | "BIT 5,(IY+d) (UNDOCUMENTED)",
142 | "BIT 5,(IY+d) (UNDOCUMENTED)",
143 | "BIT 5,(IY+d) (UNDOCUMENTED)",
144 | "BIT 5,(IY+d) (UNDOCUMENTED)",
145 | "BIT 5,(IY+d)",
146 | "BIT 5,(IY+d) (UNDOCUMENTED)",
147 |
148 | "BIT 6,(IY+d) (UNDOCUMENTED)",
149 | "BIT 6,(IY+d) (UNDOCUMENTED)",
150 | "BIT 6,(IY+d) (UNDOCUMENTED)",
151 | "BIT 6,(IY+d) (UNDOCUMENTED)",
152 | "BIT 6,(IY+d) (UNDOCUMENTED)",
153 | "BIT 6,(IY+d) (UNDOCUMENTED)",
154 | "BIT 6,(IY+d)",
155 | "BIT 6,(IY+d) (UNDOCUMENTED)",
156 | "BIT 7,(IY+d) (UNDOCUMENTED)",
157 | "BIT 7,(IY+d) (UNDOCUMENTED)",
158 | "BIT 7,(IY+d) (UNDOCUMENTED)",
159 | "BIT 7,(IY+d) (UNDOCUMENTED)",
160 | "BIT 7,(IY+d) (UNDOCUMENTED)",
161 | "BIT 7,(IY+d) (UNDOCUMENTED)",
162 | "BIT 7,(IY+d)",
163 | "BIT 7,(IY+d) (UNDOCUMENTED)",
164 |
165 | "RES 0,(IY+d),B (UNDOCUMENTED)",
166 | "RES 0,(IY+d),C (UNDOCUMENTED)",
167 | "RES 0,(IY+d),D (UNDOCUMENTED)",
168 | "RES 0,(IY+d),E (UNDOCUMENTED)",
169 | "RES 0,(IY+d),H (UNDOCUMENTED)",
170 | "RES 0,(IY+d),L (UNDOCUMENTED)",
171 | "RES 0,(IY+d)",
172 | "RES 0,(IY+d),A (UNDOCUMENTED)",
173 | "RES 1,(IY+d),B (UNDOCUMENTED)",
174 | "RES 1,(IY+d),C (UNDOCUMENTED)",
175 | "RES 1,(IY+d),D (UNDOCUMENTED)",
176 | "RES 1,(IY+d),E (UNDOCUMENTED)",
177 | "RES 1,(IY+d),H (UNDOCUMENTED)",
178 | "RES 1,(IY+d),L (UNDOCUMENTED)",
179 | "RES 1,(IY+d)",
180 | "RES 1,(IY+d),A (UNDOCUMENTED)",
181 |
182 | "RES 2,(IY+d),B (UNDOCUMENTED)",
183 | "RES 2,(IY+d),C (UNDOCUMENTED)",
184 | "RES 2,(IY+d),D (UNDOCUMENTED)",
185 | "RES 2,(IY+d),E (UNDOCUMENTED)",
186 | "RES 2,(IY+d),H (UNDOCUMENTED)",
187 | "RES 2,(IY+d),L (UNDOCUMENTED)",
188 | "RES 2,(IY+d)",
189 | "RES 2,(IY+d),A (UNDOCUMENTED)",
190 | "RES 3,(IY+d),B (UNDOCUMENTED)",
191 | "RES 3,(IY+d),C (UNDOCUMENTED)",
192 | "RES 3,(IY+d),D (UNDOCUMENTED)",
193 | "RES 3,(IY+d),E (UNDOCUMENTED)",
194 | "RES 3,(IY+d),H (UNDOCUMENTED)",
195 | "RES 3,(IY+d),L (UNDOCUMENTED)",
196 | "RES 3,(IY+d)",
197 | "RES 3,(IY+d),A (UNDOCUMENTED)",
198 |
199 | "RES 4,(IY+d),B (UNDOCUMENTED)",
200 | "RES 4,(IY+d),C (UNDOCUMENTED)",
201 | "RES 4,(IY+d),D (UNDOCUMENTED)",
202 | "RES 4,(IY+d),E (UNDOCUMENTED)",
203 | "RES 4,(IY+d),H (UNDOCUMENTED)",
204 | "RES 4,(IY+d),L (UNDOCUMENTED)",
205 | "RES 4,(IY+d)",
206 | "RES 4,(IY+d),A (UNDOCUMENTED)",
207 | "RES 5,(IY+d),B (UNDOCUMENTED)",
208 | "RES 5,(IY+d),C (UNDOCUMENTED)",
209 | "RES 5,(IY+d),D (UNDOCUMENTED)",
210 | "RES 5,(IY+d),E (UNDOCUMENTED)",
211 | "RES 5,(IY+d),H (UNDOCUMENTED)",
212 | "RES 5,(IY+d),L (UNDOCUMENTED)",
213 | "RES 5,(IY+d)",
214 | "RES 5,(IY+d),A (UNDOCUMENTED)",
215 |
216 | "RES 6,(IY+d),B (UNDOCUMENTED)",
217 | "RES 6,(IY+d),C (UNDOCUMENTED)",
218 | "RES 6,(IY+d),D (UNDOCUMENTED)",
219 | "RES 6,(IY+d),E (UNDOCUMENTED)",
220 | "RES 6,(IY+d),H (UNDOCUMENTED)",
221 | "RES 6,(IY+d),L (UNDOCUMENTED)",
222 | "RES 6,(IY+d)",
223 | "RES 6,(IY+d),A (UNDOCUMENTED)",
224 | "RES 7,(IY+d),B (UNDOCUMENTED)",
225 | "RES 7,(IY+d),C (UNDOCUMENTED)",
226 | "RES 7,(IY+d),D (UNDOCUMENTED)",
227 | "RES 7,(IY+d),E (UNDOCUMENTED)",
228 | "RES 7,(IY+d),H (UNDOCUMENTED)",
229 | "RES 7,(IY+d),L (UNDOCUMENTED)",
230 | "RES 7,(IY+d)",
231 | "RES 7,(IY+d),A (UNDOCUMENTED)",
232 |
233 | "SET 0,(IY+d),B (UNDOCUMENTED)",
234 | "SET 0,(IY+d),C (UNDOCUMENTED)",
235 | "SET 0,(IY+d),D (UNDOCUMENTED)",
236 | "SET 0,(IY+d),E (UNDOCUMENTED)",
237 | "SET 0,(IY+d),H (UNDOCUMENTED)",
238 | "SET 0,(IY+d),L (UNDOCUMENTED)",
239 | "SET 0,(IY+d)",
240 | "SET 0,(IY+d),A (UNDOCUMENTED)",
241 | "SET 1,(IY+d),B (UNDOCUMENTED)",
242 | "SET 1,(IY+d),C (UNDOCUMENTED)",
243 | "SET 1,(IY+d),D (UNDOCUMENTED)",
244 | "SET 1,(IY+d),E (UNDOCUMENTED)",
245 | "SET 1,(IY+d),H (UNDOCUMENTED)",
246 | "SET 1,(IY+d),L (UNDOCUMENTED)",
247 | "SET 1,(IY+d)",
248 | "SET 1,(IY+d),A (UNDOCUMENTED)",
249 |
250 | "SET 2,(IY+d),B (UNDOCUMENTED)",
251 | "SET 2,(IY+d),C (UNDOCUMENTED)",
252 | "SET 2,(IY+d),D (UNDOCUMENTED)",
253 | "SET 2,(IY+d),E (UNDOCUMENTED)",
254 | "SET 2,(IY+d),H (UNDOCUMENTED)",
255 | "SET 2,(IY+d),L (UNDOCUMENTED)",
256 | "SET 2,(IY+d)",
257 | "SET 2,(IY+d),A (UNDOCUMENTED)",
258 | "SET 3,(IY+d),B (UNDOCUMENTED)",
259 | "SET 3,(IY+d),C (UNDOCUMENTED)",
260 | "SET 3,(IY+d),D (UNDOCUMENTED)",
261 | "SET 3,(IY+d),E (UNDOCUMENTED)",
262 | "SET 3,(IY+d),H (UNDOCUMENTED)",
263 | "SET 3,(IY+d),L (UNDOCUMENTED)",
264 | "SET 3,(IY+d)",
265 | "SET 3,(IY+d),A (UNDOCUMENTED)",
266 |
267 | "SET 4,(IY+d),B (UNDOCUMENTED)",
268 | "SET 4,(IY+d),C (UNDOCUMENTED)",
269 | "SET 4,(IY+d),D (UNDOCUMENTED)",
270 | "SET 4,(IY+d),E (UNDOCUMENTED)",
271 | "SET 4,(IY+d),H (UNDOCUMENTED)",
272 | "SET 4,(IY+d),L (UNDOCUMENTED)",
273 | "SET 4,(IY+d)",
274 | "SET 4,(IY+d),A (UNDOCUMENTED)",
275 | "SET 5,(IY+d),B (UNDOCUMENTED)",
276 | "SET 5,(IY+d),C (UNDOCUMENTED)",
277 | "SET 5,(IY+d),D (UNDOCUMENTED)",
278 | "SET 5,(IY+d),E (UNDOCUMENTED)",
279 | "SET 5,(IY+d),H (UNDOCUMENTED)",
280 | "SET 5,(IY+d),L (UNDOCUMENTED)",
281 | "SET 5,(IY+d)",
282 | "SET 5,(IY+d),A (UNDOCUMENTED)",
283 |
284 | "SET 6,(IY+d),B (UNDOCUMENTED)",
285 | "SET 6,(IY+d),C (UNDOCUMENTED)",
286 | "SET 6,(IY+d),D (UNDOCUMENTED)",
287 | "SET 6,(IY+d),E (UNDOCUMENTED)",
288 | "SET 6,(IY+d),H (UNDOCUMENTED)",
289 | "SET 6,(IY+d),L (UNDOCUMENTED)",
290 | "SET 6,(IY+d)",
291 | "SET 6,(IY+d),A (UNDOCUMENTED)",
292 | "SET 7,(IY+d),B (UNDOCUMENTED)",
293 | "SET 7,(IY+d),C (UNDOCUMENTED)",
294 | "SET 7,(IY+d),D (UNDOCUMENTED)",
295 | "SET 7,(IY+d),E (UNDOCUMENTED)",
296 | "SET 7,(IY+d),H (UNDOCUMENTED)",
297 | "SET 7,(IY+d),L (UNDOCUMENTED)",
298 | "SET 7,(IY+d)",
299 | "SET 7,(IY+d),A (UNDOCUMENTED)"
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODEFDCBNAMES_H_
307 |
308 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODENAMES_H_
21 | #define GZ80_OPCODENAMES_H_
22 |
23 | #include "gz80_opcode_xx_names.h"
24 | #include "gz80_opcode_cb_names.h"
25 | #include "gz80_opcode_ed_names.h"
26 | #include "gz80_opcode_dd_names.h"
27 | #include "gz80_opcode_fd_names.h"
28 | #include "gz80_opcode_ddcb_names.h"
29 | #include "gz80_opcode_fdcb_names.h"
30 |
31 | #endif // GZ80_OPCODENAMES_H_
32 |
33 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_timing.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODETIMING_H_
21 | #define GZ80_OPCODETIMING_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | const u8 kOPCodeTStates[256] =
27 | {
28 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
29 | /* 0x00 */ 4,10, 7, 6, 4, 4, 7, 4, 4,11, 7, 6, 4, 4, 7, 4,
30 | /* 0x10 */ 8,10, 7, 6, 4, 4, 7, 4,12,11, 7, 6, 4, 4, 7, 4,
31 | /* 0x20 */ 7,10,16, 6, 4, 4, 7, 4, 7,11,16, 6, 4, 4, 7, 4,
32 | /* 0x30 */ 7,10,13, 6,11,11,10, 4, 7,11,13, 6, 4, 4, 7, 4,
33 | /* 0x40 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
34 | /* 0x50 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
35 | /* 0x60 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
36 | /* 0x70 */ 7, 7, 7, 7, 7, 7, 4, 7, 4, 4, 4, 4, 4, 4, 7, 4,
37 | /* 0x80 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
38 | /* 0x90 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
39 | /* 0xA0 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
40 | /* 0xB0 */ 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
41 | /* 0xC0 */ 5,10,10,10,10,11, 7,11, 5,10,10, 0,10,17, 7,11,
42 | /* 0xD0 */ 5,10,10,11,10,11, 7,11, 5, 4,10,11,10, 0, 7,11,
43 | /* 0xE0 */ 5,10,10,19,10,11, 7,11, 5, 4,10, 4,10, 0, 7,11,
44 | /* 0xF0 */ 5,10,10, 4,10,11, 7,11, 5, 6,10, 4,10, 0, 7,11
45 | };
46 |
47 | const u8 kOPCodeTStatesBranched[256] =
48 | {
49 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
50 | /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51 | /* 0x10 */ 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52 | /* 0x20 */ 5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
53 | /* 0x30 */ 5, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
54 | /* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55 | /* 0x50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 | /* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 | /* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 | /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59 | /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60 | /* 0xA0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
61 | /* 0xB0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
62 | /* 0xC0 */ 6, 0, 0, 0, 7, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0,
63 | /* 0xD0 */ 6, 0, 0, 0, 7, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0,
64 | /* 0xE0 */ 6, 0, 0, 0, 7, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0,
65 | /* 0xF0 */ 6, 0, 0, 0, 7, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0
66 | };
67 |
68 | const u8 kOPCodeCBTStates[256] =
69 | {
70 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
71 | /* 0x00 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
72 | /* 0x10 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
73 | /* 0x20 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
74 | /* 0x30 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
75 | /* 0x40 */ 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,
76 | /* 0x50 */ 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,
77 | /* 0x60 */ 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,
78 | /* 0x70 */ 8, 8, 8, 8, 8, 8,12, 8, 8, 8, 8, 8, 8, 8,12, 8,
79 | /* 0x80 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
80 | /* 0x90 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
81 | /* 0xA0 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
82 | /* 0xB0 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
83 | /* 0xC0 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
84 | /* 0xD0 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
85 | /* 0xE0 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8,
86 | /* 0xF0 */ 8, 8, 8, 8, 8, 8,15, 8, 8, 8, 8, 8, 8, 8,15, 8
87 | };
88 |
89 | const u8 kOPCodeEDTStates[256] =
90 | {
91 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
92 | /* 0x00 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
93 | /* 0x10 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
94 | /* 0x20 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
95 | /* 0x30 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
96 | /* 0x40 */ 12,12,15,20, 8,14, 8, 9,12,12,15,20, 8,14, 8, 9,
97 | /* 0x50 */ 12,12,15,20, 8,14, 8, 9,12,12,15,20, 8,14, 8, 9,
98 | /* 0x60 */ 12,12,15,20, 8,14, 8,18,12,12,15,20, 8,14, 8,18,
99 | /* 0x70 */ 12,12,15,20, 8,14, 8, 8,12,12,15,20, 8,14, 8, 8,
100 | /* 0x80 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
101 | /* 0x90 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
102 | /* 0xA0 */ 16,16,16,16, 8, 8, 8, 8,16,16,16,16, 8, 8, 8, 8,
103 | /* 0xB0 */ 16,16,16,16, 8, 8, 8, 8,16,16,16,16, 8, 8, 8, 8,
104 | /* 0xC0 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
105 | /* 0xD0 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
106 | /* 0xE0 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
107 | /* 0xF0 */ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
108 | };
109 |
110 | const u8 kOPCodeXYTStates[256] =
111 | {
112 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
113 | /* 0x00 */ 4+4,10+4, 7+4, 6+4, 4+4, 4+4, 7+4, 4+4, 4+4,11+4, 7+4, 6+4, 4+4, 4+4, 7+4, 4+4,
114 | /* 0x10 */ 8+4,10+4, 7+4, 6+4, 4+4, 4+4, 7+4, 4+4,12+4,11+4, 7+4, 6+4, 4+4, 4+4, 7+4, 4+4,
115 | /* 0x20 */ 7+4,10+4,16+4, 6+4, 4+4, 4+4, 7+4, 4+4, 7+4,11+4,16+4, 6+4, 4+4, 4+4, 7+4, 4+4,
116 | /* 0x30 */ 7+4,10+4,13+4, 6+4, 23 , 23 , 19 , 4+4, 7+4,11+4,13+4, 6+4, 4+4, 4+4, 7+4, 4+4,
117 | /* 0x40 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
118 | /* 0x50 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
119 | /* 0x60 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
120 | /* 0x70 */ 19 , 19 , 19 , 19 , 19 , 19 , 4+4, 19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
121 | /* 0x80 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
122 | /* 0x90 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
123 | /* 0xA0 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
124 | /* 0xB0 */ 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4, 4+4, 4+4, 4+4, 4+4, 4+4, 4+4,19 , 4+4,
125 | /* 0xC0 */ 5+4,10+4,10+4,10+4,10+4,11+4, 7+4,11+4, 5+4,10+4,10+4, 0 ,10+4,17+4, 7+4,11+4,
126 | /* 0xD0 */ 5+4,10+4,10+4,11+4,10+4,11+4, 7+4,11+4, 5+4, 4+4,10+4,11+4,10+4, 4 , 7+4,11+4,
127 | /* 0xE0 */ 5+4,10+4,10+4,19+4,10+4,11+4, 7+4,11+4, 5+4, 4+4,10+4, 4+4,10+4, 4 , 7+4,11+4,
128 | /* 0xF0 */ 5+4,10+4,10+4, 4+4,10+4,11+4, 7+4,11+4, 5+4, 6+4,10+4, 4+4,10+4, 4 , 7+4,11+4
129 | };
130 |
131 | const u8 kOPCodeXYCBTStates[256] =
132 | {
133 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
134 | /* 0x00 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
135 | /* 0x10 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
136 | /* 0x20 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
137 | /* 0x30 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
138 | /* 0x40 */ 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
139 | /* 0x50 */ 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
140 | /* 0x60 */ 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
141 | /* 0x70 */ 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
142 | /* 0x80 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
143 | /* 0x90 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
144 | /* 0xA0 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
145 | /* 0xB0 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
146 | /* 0xC0 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
147 | /* 0xD0 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
148 | /* 0xE0 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
149 | /* 0xF0 */ 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23
150 | };
151 |
152 | } // namespace gz80
153 |
154 | #endif // GZ80_OPCODETIMING_H_
155 |
156 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcode_xx_names.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_OPCODEXXNAMES_H_
21 | #define GZ80_OPCODEXXNAMES_H_
22 |
23 | namespace gz80
24 | {
25 |
26 | #ifdef GZ80_DISASM
27 |
28 | static const char* kOPCodeNames[256] = {
29 | "NOP",
30 | "LD BC,nn",
31 | "LD (BC),A",
32 | "INC BC",
33 | "INC B",
34 | "DEC B",
35 | "LD B,n",
36 | "RLCA",
37 | "EX AF,AF'",
38 | "ADD HL,BC",
39 | "LD A,(BC)",
40 | "DEC BC",
41 | "INC C",
42 | "DEC C",
43 | "LD C,n",
44 | "RRCA",
45 |
46 | "DJNZ (PC+e)",
47 | "LD DE,nn",
48 | "LD (DE),A",
49 | "INC DE",
50 | "INC D",
51 | "DEC D",
52 | "LD D,n",
53 | "RLA",
54 | "JR n",
55 | "ADD HL,DE",
56 | "LD A,(DE)",
57 | "DEC DE",
58 | "INC E",
59 | "DEC E",
60 | "LD E,n",
61 | "RRA",
62 |
63 | "JR NZ,n",
64 | "LD HL,nn",
65 | "LD (nn),HL",
66 | "INC HL",
67 | "INC H",
68 | "DEC H",
69 | "LD H,n",
70 | "DAA",
71 | "JR Z,n",
72 | "ADD HL,HL",
73 | "LD HL,(nn)",
74 | "DEC HL",
75 | "INC L",
76 | "DEC L",
77 | "LD L,n",
78 | "CPL",
79 |
80 | "JR NC,n",
81 | "LD SP,nn",
82 | "LD (nn),A",
83 | "INC SP",
84 | "INC (HL)",
85 | "DEC (HL)",
86 | "LD (HL),n",
87 | "SCF",
88 | "JR C,n",
89 | "ADD HL,SP",
90 | "LD A,(nn)",
91 | "DEC SP",
92 | "INC A",
93 | "DEC A",
94 | "LD A,n",
95 | "CCF",
96 |
97 | "LD B,B",
98 | "LD B,C",
99 | "LD B,D",
100 | "LD B,E",
101 | "LD B,H",
102 | "LD B,L",
103 | "LD B,(HL)",
104 | "LD B,A",
105 | "LD C,B",
106 | "LD C,C",
107 | "LD C,D",
108 | "LD C,E",
109 | "LD C,H",
110 | "LD C,L",
111 | "LD C,(HL)",
112 | "LD C,A",
113 |
114 | "LD D,B",
115 | "LD D,C",
116 | "LD D,D",
117 | "LD D,E",
118 | "LD D,H",
119 | "LD D,L",
120 | "LD D,(HL)",
121 | "LD D,A",
122 | "LD E,B",
123 | "LD E,C",
124 | "LD E,D",
125 | "LD E,E",
126 | "LD E,H",
127 | "LD E,L",
128 | "LD E,(HL)",
129 | "LD E,A",
130 |
131 | "LD H,B",
132 | "LD H,C",
133 | "LD H,D",
134 | "LD H,E",
135 | "LD H,H",
136 | "LD H,L",
137 | "LD H,(HL)",
138 | "LD H,A",
139 | "LD L,B",
140 | "LD L,C",
141 | "LD L,D",
142 | "LD L,E",
143 | "LD L,H",
144 | "LD L,L",
145 | "LD L,(HL)",
146 | "LD L,A",
147 |
148 | "LD (HL),B",
149 | "LD (HL),C",
150 | "LD (HL),D",
151 | "LD (HL),E",
152 | "LD (HL),H",
153 | "LD (HL),L",
154 | "HALT",
155 | "LD (HL),A",
156 | "LD A,B",
157 | "LD A,C",
158 | "LD A,D",
159 | "LD A,E",
160 | "LD A,H",
161 | "LD A,L",
162 | "LD A,(HL)",
163 | "LD A,A",
164 |
165 | "ADD A,B",
166 | "ADD A,C",
167 | "ADD A,D",
168 | "ADD A,E",
169 | "ADD A,H",
170 | "ADD A,L",
171 | "ADD A,(HL)",
172 | "ADD A,A",
173 | "ADC A,B",
174 | "ADC A,C",
175 | "ADC A,D",
176 | "ADC A,E",
177 | "ADC A,H",
178 | "ADC A,L",
179 | "ADC A,(HL)",
180 | "ADC A,A",
181 |
182 | "SUB B",
183 | "SUB C",
184 | "SUB D",
185 | "SUB E",
186 | "SUB H",
187 | "SUB L",
188 | "SUB (HL)",
189 | "SUB A",
190 | "SBC A,B",
191 | "SBC A,C",
192 | "SBC A,D",
193 | "SBC A,E",
194 | "SBC A,H",
195 | "SBC A,L",
196 | "SBC A,(HL)",
197 | "SBC A,A",
198 |
199 | "AND B",
200 | "AND C",
201 | "AND D",
202 | "AND E",
203 | "AND H",
204 | "AND L",
205 | "AND (HL)",
206 | "AND A",
207 | "XOR B",
208 | "XOR C",
209 | "XOR D",
210 | "XOR E",
211 | "XOR H",
212 | "XOR L",
213 | "XOR (HL)",
214 | "XOR A",
215 |
216 | "OR B",
217 | "OR C",
218 | "OR D",
219 | "OR E",
220 | "OR H",
221 | "OR L",
222 | "OR (HL)",
223 | "OR A",
224 | "CP B",
225 | "CP C",
226 | "CP D",
227 | "CP E",
228 | "CP H",
229 | "CP L",
230 | "CP (HL)",
231 | "CP A",
232 |
233 | "RET NZ",
234 | "POP BC",
235 | "JP NZ,nn",
236 | "JP nn",
237 | "CALL NZ,nn",
238 | "PUSH BC",
239 | "ADD A,n",
240 | "RST ",
241 | "RET Z",
242 | "RET",
243 | "JP Z,nn",
244 | "CB PREFIX",
245 | "CALL Z,nn",
246 | "CALL nn",
247 | "ADC A,n",
248 | "RST 08H",
249 |
250 | "RET NC",
251 | "POP DE",
252 | "JP NC,nn",
253 | "OUT (n),A",
254 | "CALL NC,nn",
255 | "PUSH DE",
256 | "SUB n",
257 | "RST 10H",
258 | "RET C",
259 | "EXX",
260 | "JP C,nn",
261 | "IN A,(n)",
262 | "CALL C,nn",
263 | "DD PREFIX",
264 | "SBC A,n",
265 | "RST 18H",
266 |
267 | "RET PO",
268 | "POP HL",
269 | "JP PO,nn",
270 | "EX (SP),HL",
271 | "CALL PO,nn",
272 | "PUSH HL",
273 | "AND n",
274 | "RST 20H",
275 | "RET PE",
276 | "JP (HL)",
277 | "JP PE,nn",
278 | "EX DE,HL",
279 | "CALL PE,nn",
280 | "ED PREFIX",
281 | "XOR n",
282 | "RST 28H",
283 |
284 | "RET P",
285 | "POP AF",
286 | "JP P,nn",
287 | "DI",
288 | "CALL P,nn",
289 | "PUSH AF",
290 | "OR n",
291 | "RST 30H",
292 | "RET M",
293 | "LD SP,HL",
294 | "JP M,nn",
295 | "EI",
296 | "CALL M,nn",
297 | "FD PREFIX",
298 | "CP n",
299 | "RST 38H"
300 | };
301 |
302 | #endif
303 |
304 | } // namespace gz80
305 |
306 | #endif // GZ80_OPCODEXXNAMES_H_
307 |
308 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_opcodes_ed.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "gz80_core.h"
21 |
22 | namespace gz80
23 | {
24 |
25 | void GZ80::OPCodeED0x40()
26 | {
27 | // IN B,(C)
28 | OPCodes_IN_C(BC_.GetHighRegister());
29 | }
30 |
31 | void GZ80::OPCodeED0x41()
32 | {
33 | // OUT (C),B
34 | OPCodes_OUT_C(BC_.GetHighRegister());
35 | }
36 |
37 | void GZ80::OPCodeED0x42()
38 | {
39 | // SBC HL,BC
40 | OPCodes_SBC_HL(BC_.GetValue());
41 | }
42 |
43 | void GZ80::OPCodeED0x43()
44 | {
45 | // LD (nn),BC
46 | OPCodes_LD_nn_dd(&BC_);
47 | }
48 |
49 | void GZ80::OPCodeED0x44()
50 | {
51 | // NEG
52 | u8 value = AF_.GetHigh();
53 | AF_.SetHigh(0x00);
54 | OPCodes_SUB(value);
55 | }
56 |
57 | void GZ80::OPCodeED0x45()
58 | {
59 | // RETN
60 | OPCodes_RET();
61 | iff1_ = iff2_;
62 | }
63 |
64 | void GZ80::OPCodeED0x46()
65 | {
66 | // IM 0
67 | SetInterruptMode(0);
68 | }
69 |
70 | void GZ80::OPCodeED0x47()
71 | {
72 | // LD I,A
73 | OPCodes_LD(&I_, AF_.GetHigh());
74 | }
75 |
76 | void GZ80::OPCodeED0x48()
77 | {
78 | // IN C,(C)
79 | OPCodes_IN_C(BC_.GetLowRegister());
80 | }
81 |
82 | void GZ80::OPCodeED0x49()
83 | {
84 | // OUT (C),C
85 | OPCodes_OUT_C(BC_.GetLowRegister());
86 | }
87 |
88 | void GZ80::OPCodeED0x4A()
89 | {
90 | // ADC HL,BC
91 | OPCodes_ADC_HL(BC_.GetValue());
92 | }
93 |
94 | void GZ80::OPCodeED0x4B()
95 | {
96 | // LD BC,(nn)
97 | OPCodes_LD_dd_nn(&BC_);
98 | }
99 |
100 | void GZ80::OPCodeED0x4C()
101 | {
102 | // NEG*
103 | UndocumentedOPCode();
104 | OPCodeED0x44();
105 | }
106 |
107 | void GZ80::OPCodeED0x4D()
108 | {
109 | // RETI
110 | OPCodes_RET();
111 | iff1_ = iff2_;
112 | }
113 |
114 | void GZ80::OPCodeED0x4E()
115 | {
116 | // IM 0*
117 | UndocumentedOPCode();
118 | OPCodeED0x46();
119 | }
120 |
121 | void GZ80::OPCodeED0x4F()
122 | {
123 | // LD R,A
124 | OPCodes_LD(&R_, AF_.GetHigh());
125 | }
126 |
127 | void GZ80::OPCodeED0x50()
128 | {
129 | // IN D,(C)
130 | OPCodes_IN_C(DE_.GetHighRegister());
131 | }
132 |
133 | void GZ80::OPCodeED0x51()
134 | {
135 | // OUT (C),D
136 | OPCodes_OUT_C(DE_.GetHighRegister());
137 | }
138 |
139 | void GZ80::OPCodeED0x52()
140 | {
141 | // SBC HL,DE
142 | OPCodes_SBC_HL(DE_.GetValue());
143 | }
144 |
145 | void GZ80::OPCodeED0x53()
146 | {
147 | // LD (nn),DE
148 | OPCodes_LD_nn_dd(&DE_);
149 | }
150 |
151 | void GZ80::OPCodeED0x54()
152 | {
153 | // NEG*
154 | UndocumentedOPCode();
155 | OPCodeED0x44();
156 | }
157 |
158 | void GZ80::OPCodeED0x55()
159 | {
160 | // RETN*
161 | UndocumentedOPCode();
162 | OPCodeED0x45();
163 | }
164 |
165 | void GZ80::OPCodeED0x56()
166 | {
167 | // IM 1
168 | SetInterruptMode(1);
169 | }
170 |
171 | void GZ80::OPCodeED0x57()
172 | {
173 | // LD A,I
174 | u8 value = I_.GetValue();
175 | OPCodes_LD(AF_.GetHighRegister(), value);
176 | ToggleSignFlagFromResult(value);
177 | ToggleZeroFlagFromResult(value);
178 | ToggleXYFlagsFromResult(value);
179 | ClearFlag(FLAG_HALF);
180 | ClearFlag(FLAG_NEGATIVE);
181 | if (iff2_)
182 | ToggleFlag(FLAG_PARITY);
183 | else
184 | ClearFlag(FLAG_PARITY);
185 | }
186 |
187 | void GZ80::OPCodeED0x58()
188 | {
189 | // IN E,(C)
190 | OPCodes_IN_C(DE_.GetLowRegister());
191 | }
192 |
193 | void GZ80::OPCodeED0x59()
194 | {
195 | // OUT (C),E
196 | OPCodes_OUT_C(DE_.GetLowRegister());
197 | }
198 |
199 | void GZ80::OPCodeED0x5A()
200 | {
201 | // ADC HL,DE
202 | OPCodes_ADC_HL(DE_.GetValue());
203 | }
204 |
205 | void GZ80::OPCodeED0x5B()
206 | {
207 | // LD DE,(nn)
208 | OPCodes_LD_dd_nn(&DE_);
209 | }
210 |
211 | void GZ80::OPCodeED0x5C()
212 | {
213 | // NEG*
214 | UndocumentedOPCode();
215 | OPCodeED0x44();
216 | }
217 |
218 | void GZ80::OPCodeED0x5D()
219 | {
220 | // RETN*
221 | UndocumentedOPCode();
222 | OPCodeED0x45();
223 | }
224 |
225 | void GZ80::OPCodeED0x5E()
226 | {
227 | // IM 2
228 | SetInterruptMode(2);
229 | }
230 |
231 | void GZ80::OPCodeED0x5F()
232 | {
233 | // LD A,R
234 | u8 value = R_.GetValue();
235 | OPCodes_LD(AF_.GetHighRegister(), value);
236 | ToggleSignFlagFromResult(value);
237 | ToggleZeroFlagFromResult(value);
238 | ToggleXYFlagsFromResult(value);
239 | ClearFlag(FLAG_HALF);
240 | ClearFlag(FLAG_NEGATIVE);
241 | if (iff2_)
242 | ToggleFlag(FLAG_PARITY);
243 | else
244 | ClearFlag(FLAG_PARITY);
245 | }
246 |
247 | void GZ80::OPCodeED0x60()
248 | {
249 | // IN H,(C)
250 | OPCodes_IN_C(HL_.GetHighRegister());
251 | }
252 |
253 | void GZ80::OPCodeED0x61()
254 | {
255 | // OUT (C),H
256 | OPCodes_OUT_C(HL_.GetHighRegister());
257 | }
258 |
259 | void GZ80::OPCodeED0x62()
260 | {
261 | // SBC HL,HL
262 | OPCodes_SBC_HL(HL_.GetValue());
263 | }
264 |
265 | void GZ80::OPCodeED0x63()
266 | {
267 | // LD (nn),HL
268 | OPCodes_LD_nn_dd(&HL_);
269 | }
270 |
271 | void GZ80::OPCodeED0x64()
272 | {
273 | // NEG*
274 | UndocumentedOPCode();
275 | OPCodeED0x44();
276 | }
277 |
278 | void GZ80::OPCodeED0x65()
279 | {
280 | // RETN*
281 | UndocumentedOPCode();
282 | OPCodeED0x45();
283 | }
284 |
285 | void GZ80::OPCodeED0x66()
286 | {
287 | // IM 0*
288 | UndocumentedOPCode();
289 | OPCodeED0x46();
290 | }
291 |
292 | void GZ80::OPCodeED0x67()
293 | {
294 | // RRD
295 | u16 address = HL_.GetValue();
296 | u8 value = memory_impl_->Read(address);
297 | u8 result = (AF_.GetHigh() & 0xF0) | (value & 0x0F);
298 | memory_impl_->Write(address, ((AF_.GetHigh() << 4) & 0xF0) | ((value >> 4) & 0x0F));
299 | AF_.SetHigh(result);
300 | IsSetFlag(FLAG_CARRY) ? SetFlag(FLAG_CARRY) : ClearAllFlags();
301 | ToggleZeroFlagFromResult(result);
302 | ToggleSignFlagFromResult(result);
303 | ToggleParityFlagFromResult(result);
304 | ToggleXYFlagsFromResult(result);
305 | XY_.SetValue(address + 1);
306 | }
307 |
308 | void GZ80::OPCodeED0x68()
309 | {
310 | // IN L,(C)
311 | OPCodes_IN_C(HL_.GetLowRegister());
312 | }
313 |
314 | void GZ80::OPCodeED0x69()
315 | {
316 | // OUT (C),L
317 | OPCodes_OUT_C(HL_.GetLowRegister());
318 | }
319 |
320 | void GZ80::OPCodeED0x6A()
321 | {
322 | // ADC HL,HL
323 | OPCodes_ADC_HL(HL_.GetValue());
324 | }
325 |
326 | void GZ80::OPCodeED0x6B()
327 | {
328 | // LD HL,(nn)
329 | OPCodes_LD_dd_nn(&HL_);
330 | }
331 |
332 | void GZ80::OPCodeED0x6C()
333 | {
334 | // NEG*
335 | UndocumentedOPCode();
336 | OPCodeED0x44();
337 | }
338 |
339 | void GZ80::OPCodeED0x6D()
340 | {
341 | // RETN*
342 | UndocumentedOPCode();
343 | OPCodeED0x45();
344 | }
345 |
346 | void GZ80::OPCodeED0x6E()
347 | {
348 | // IM 0*
349 | UndocumentedOPCode();
350 | OPCodeED0x46();
351 | }
352 |
353 | void GZ80::OPCodeED0x6F()
354 | {
355 | // RLD
356 | u16 address = HL_.GetValue();
357 | u8 value = memory_impl_->Read(address);
358 | u8 result = (AF_.GetHigh() & 0xF0) | ((value >> 4) & 0x0F);
359 | memory_impl_->Write(address, ((value << 4) & 0xF0) | (AF_.GetHigh() & 0x0F));
360 | AF_.SetHigh(result);
361 | IsSetFlag(FLAG_CARRY) ? SetFlag(FLAG_CARRY) : ClearAllFlags();
362 | ToggleZeroFlagFromResult(result);
363 | ToggleSignFlagFromResult(result);
364 | ToggleParityFlagFromResult(result);
365 | ToggleXYFlagsFromResult(result);
366 | XY_.SetValue(address + 1);
367 | }
368 |
369 | void GZ80::OPCodeED0x70()
370 | {
371 | // IN F,(C)*
372 | UndocumentedOPCode();
373 | OPCodes_IN_C(NULL);
374 | }
375 |
376 | void GZ80::OPCodeED0x71()
377 | {
378 | // OUT (C),0*
379 | UndocumentedOPCode();
380 | io_ports_impl_->Output(BC_.GetLow(), 0);
381 | }
382 |
383 | void GZ80::OPCodeED0x72()
384 | {
385 | // SBC HL,SP
386 | OPCodes_SBC_HL(SP_.GetValue());
387 | }
388 |
389 | void GZ80::OPCodeED0x73()
390 | {
391 | // LD (nn),SP
392 | OPCodes_LD_nn_dd(&SP_);
393 | }
394 |
395 | void GZ80::OPCodeED0x74()
396 | {
397 | // NEG*
398 | UndocumentedOPCode();
399 | OPCodeED0x44();
400 | }
401 |
402 | void GZ80::OPCodeED0x75()
403 | {
404 | // RETN*
405 | UndocumentedOPCode();
406 | OPCodeED0x45();
407 | }
408 |
409 | void GZ80::OPCodeED0x76()
410 | {
411 | // IM 1*
412 | UndocumentedOPCode();
413 | OPCodeED0x56();
414 | }
415 |
416 | void GZ80::OPCodeED0x78()
417 | {
418 | // IN A,(C)
419 | OPCodes_IN_C(AF_.GetHighRegister());
420 | XY_.SetValue(BC_.GetValue() + 1);
421 | }
422 |
423 | void GZ80::OPCodeED0x79()
424 | {
425 | // OUT (C),A
426 | OPCodes_OUT_C(AF_.GetHighRegister());
427 | XY_.SetValue(BC_.GetValue() + 1);
428 | }
429 |
430 | void GZ80::OPCodeED0x7A()
431 | {
432 | // ADC HL,SP
433 | OPCodes_ADC_HL(SP_.GetValue());
434 | }
435 |
436 | void GZ80::OPCodeED0x7B()
437 | {
438 | // LD SP,(nn)
439 | OPCodes_LD_dd_nn(&SP_);
440 | }
441 |
442 | void GZ80::OPCodeED0x7C()
443 | {
444 | // NEG*
445 | UndocumentedOPCode();
446 | OPCodeED0x44();
447 | }
448 |
449 | void GZ80::OPCodeED0x7D()
450 | {
451 | // RETN*
452 | UndocumentedOPCode();
453 | OPCodeED0x45();
454 | }
455 |
456 | void GZ80::OPCodeED0x7E()
457 | {
458 | // IM 2*
459 | UndocumentedOPCode();
460 | OPCodeED0x5E();
461 | }
462 |
463 | void GZ80::OPCodeED0xA0()
464 | {
465 | // LDI
466 | OPCodes_LDI();
467 | }
468 |
469 | void GZ80::OPCodeED0xA1()
470 | {
471 | // CPI
472 | OPCodes_CPI();
473 | }
474 |
475 | void GZ80::OPCodeED0xA2()
476 | {
477 | // INI
478 | OPCodes_INI();
479 | }
480 |
481 | void GZ80::OPCodeED0xA3()
482 | {
483 | // OUTI
484 | OPCodes_OUTI();
485 | }
486 |
487 | void GZ80::OPCodeED0xA8()
488 | {
489 | // LDD
490 | OPCodes_LDD();
491 | }
492 |
493 | void GZ80::OPCodeED0xA9()
494 | {
495 | // CPD
496 | OPCodes_CPD();
497 | }
498 |
499 | void GZ80::OPCodeED0xAA()
500 | {
501 | // IND
502 | OPCodes_IND();
503 | }
504 |
505 | void GZ80::OPCodeED0xAB()
506 | {
507 | // OUTD
508 | OPCodes_OUTD();
509 | }
510 |
511 | void GZ80::OPCodeED0xB0()
512 | {
513 | // LDIR
514 | OPCodes_LDI();
515 | if (BC_.GetValue() != 0)
516 | {
517 | PC_.Decrement();
518 | PC_.Decrement();
519 | XY_.SetValue(PC_.GetValue() + 1);
520 | t_states_ += 5;
521 | }
522 | }
523 |
524 | void GZ80::OPCodeED0xB1()
525 | {
526 | // CPIR
527 | OPCodes_CPI();
528 | if ((BC_.GetValue() != 0) && !IsSetFlag(FLAG_ZERO))
529 | {
530 | PC_.Decrement();
531 | PC_.Decrement();
532 | XY_.SetValue(PC_.GetValue() + 1);
533 | t_states_ += 5;
534 | }
535 | }
536 |
537 | void GZ80::OPCodeED0xB2()
538 | {
539 | // INIR
540 | OPCodes_INI();
541 | if (BC_.GetHigh() != 0)
542 | {
543 | PC_.Decrement();
544 | PC_.Decrement();
545 | t_states_ += 5;
546 | }
547 | }
548 |
549 | void GZ80::OPCodeED0xB3()
550 | {
551 | // OTIR
552 | OPCodes_OUTI();
553 | if (BC_.GetHigh() != 0)
554 | {
555 | PC_.Decrement();
556 | PC_.Decrement();
557 | t_states_ += 5;
558 | }
559 | }
560 |
561 | void GZ80::OPCodeED0xB8()
562 | {
563 | // LDDR
564 | OPCodes_LDD();
565 | if (BC_.GetValue() != 0)
566 | {
567 | PC_.Decrement();
568 | PC_.Decrement();
569 | XY_.SetValue(PC_.GetValue() + 1);
570 | t_states_ += 5;
571 | }
572 | }
573 |
574 | void GZ80::OPCodeED0xB9()
575 | {
576 | // CPDR
577 | OPCodes_CPD();
578 | if ((BC_.GetValue() != 0) && !IsSetFlag(FLAG_ZERO))
579 | {
580 | PC_.Decrement();
581 | PC_.Decrement();
582 | XY_.SetValue(PC_.GetValue() + 1);
583 | t_states_ += 5;
584 | }
585 | }
586 |
587 | void GZ80::OPCodeED0xBA()
588 | {
589 | // INDR
590 | OPCodes_IND();
591 | if (BC_.GetHigh() != 0)
592 | {
593 | PC_.Decrement();
594 | PC_.Decrement();
595 | t_states_ += 5;
596 | }
597 | }
598 |
599 | void GZ80::OPCodeED0xBB()
600 | {
601 | // OTDR
602 | OPCodes_OUTD();
603 | if (BC_.GetHigh() != 0)
604 | {
605 | PC_.Decrement();
606 | PC_.Decrement();
607 | t_states_ += 5;
608 | }
609 | }
610 |
611 | } // namespace gz80
612 |
--------------------------------------------------------------------------------
/src/GZ80/gz80_sixteen_bit_register.h:
--------------------------------------------------------------------------------
1 | /*
2 | * GZ80 - Zilog Z80 Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GZ80_SIXTEENBITREGISTER_H_
21 | #define GZ80_SIXTEENBITREGISTER_H_
22 |
23 | #include "gz80_definitions.h"
24 | #include "gz80_eight_bit_register.h"
25 |
26 | namespace gz80
27 | {
28 |
29 | class SixteenBitRegister
30 | {
31 | public:
32 |
33 | SixteenBitRegister() { }
34 | void SetLow(u8 low);
35 | u8 GetLow() const;
36 | void SetHigh(u8 high);
37 | u8 GetHigh() const;
38 | EightBitRegister* GetHighRegister();
39 | EightBitRegister* GetLowRegister();
40 | void SetValue(u16 value);
41 | u16 GetValue() const;
42 | void Increment();
43 | void Decrement();
44 |
45 | private:
46 | EightBitRegister high_;
47 | EightBitRegister low_;
48 | };
49 |
50 | inline void SixteenBitRegister::SetLow(u8 low)
51 | {
52 | this->low_.SetValue(low);
53 | }
54 |
55 | inline u8 SixteenBitRegister::GetLow() const
56 | {
57 | return low_.GetValue();
58 | }
59 |
60 | inline void SixteenBitRegister::SetHigh(u8 high)
61 | {
62 | this->high_.SetValue(high);
63 | }
64 |
65 | inline u8 SixteenBitRegister::GetHigh() const
66 | {
67 | return high_.GetValue();
68 | }
69 |
70 | inline EightBitRegister* SixteenBitRegister::GetHighRegister()
71 | {
72 | return &high_;
73 | }
74 |
75 | inline EightBitRegister* SixteenBitRegister::GetLowRegister()
76 | {
77 | return &low_;
78 | }
79 |
80 | inline void SixteenBitRegister::SetValue(u16 value)
81 | {
82 | low_.SetValue(static_cast (value));
83 | high_.SetValue(static_cast (value >> 8));
84 | }
85 |
86 | inline u16 SixteenBitRegister::GetValue() const
87 | {
88 | u8 high = high_.GetValue();
89 | u8 low = low_.GetValue();
90 | return (high << 8) | low;
91 | }
92 |
93 | inline void SixteenBitRegister::Increment()
94 | {
95 | u16 value = this->GetValue();
96 | value++;
97 | this->SetValue(value);
98 | }
99 |
100 | inline void SixteenBitRegister::Decrement()
101 | {
102 | u16 value = this->GetValue();
103 | value--;
104 | this->SetValue(value);
105 | }
106 |
107 | } // namespace gz80
108 |
109 | #endif // GZ80_SIXTEENBITREGISTER_H_
110 |
111 |
--------------------------------------------------------------------------------
/src/audio.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "audio.h"
21 | //#include "Memory.h"
22 | //#include "audio/Sound_Queue.h"
23 | //#include "audio/Sms_Apu.h"
24 |
25 | Audio::Audio()
26 | {
27 | enabled_ = true;
28 | // m_Time = 0;
29 | // m_iSampleRate = 44100;
30 | // InitPointer(m_pApu);
31 | // InitPointer(m_pBuffer);
32 | // InitPointer(m_pSound);
33 | // InitPointer(m_pSampleBuffer);
34 | }
35 |
36 | Audio::~Audio()
37 | {
38 | // SafeDelete(m_pApu);
39 | // SafeDelete(m_pBuffer);
40 | // SafeDelete(m_pSound);
41 | // SafeDeleteArray(m_pSampleBuffer);
42 | }
43 |
44 | void Audio::Init()
45 | {
46 | // if (SDL_Init(SDL_INIT_AUDIO) < 0)
47 | // {
48 | // Log("--> ** SDL Audio not initialized");
49 | // }
50 | //
51 | // atexit(SDL_Quit);
52 | //
53 | // m_pSampleBuffer = new blip_sample_t[kSampleBufferSize];
54 | //
55 | // m_pApu = new Sms_Apu();
56 | // m_pBuffer = new Stereo_Buffer();
57 | // m_pSound = new Sound_Queue();
58 | //
59 | // // Clock rate for NTSC is 3579545, 3559545 to avoid sttutering at 60hz
60 | // // Clock rate for PAL is 3546893
61 | // m_pBuffer->clock_rate(3559545);
62 | // m_pBuffer->set_sample_rate(m_iSampleRate);
63 | //
64 | // m_pApu->treble_eq(-15.0);
65 | // m_pBuffer->bass_freq(100);
66 | //
67 | // m_pApu->output(m_pBuffer->center(), m_pBuffer->left(), m_pBuffer->right());
68 | //
69 | // m_pSound->start(m_iSampleRate, 2);
70 | }
71 |
72 | void Audio::Reset()
73 | {
74 | enabled_ = true;
75 | // m_pApu->reset();
76 | // m_pBuffer->clear();
77 | // m_Time = 0;
78 | }
79 |
80 | void Audio::Enable(bool enabled)
81 | {
82 | enabled_ = enabled;
83 | }
84 |
85 | bool Audio::IsEnabled() const
86 | {
87 | return enabled_;
88 | }
89 |
90 | void Audio::SetSampleRate(int rate)
91 | {
92 | // if (rate != m_iSampleRate)
93 | // {
94 | // m_iSampleRate = rate;
95 | // m_pBuffer->set_sample_rate(m_iSampleRate);
96 | // m_pSound->stop();
97 | // m_pSound->start(m_iSampleRate, 2);
98 | // }
99 | }
100 |
101 | void Audio::WriteAudioRegister(u8 value)
102 | {
103 | // m_pApu->write_data(m_Time, value);
104 | }
105 |
106 | void Audio::WriteGGStereoRegister(u8 value)
107 | {
108 | // m_pApu->write_ggstereo(m_Time, value);
109 | }
110 |
111 | void Audio::EndFrame()
112 | {
113 | // m_pApu->end_frame(m_Time);
114 | // m_pBuffer->end_frame(m_Time);
115 | // m_Time = 0;
116 | //
117 | // if (m_pBuffer->samples_avail() >= kSampleBufferSize)
118 | // {
119 | // long count = m_pBuffer->read_samples(m_pSampleBuffer, kSampleBufferSize);
120 | // if (m_bEnabled)
121 | // {
122 | // m_pSound->write(m_pSampleBuffer, count);
123 | // }
124 | // }
125 | }
126 |
127 | void Audio::Tick(unsigned int clock_cycles)
128 | {
129 | // m_Time += clockCycles;
130 | }
131 |
--------------------------------------------------------------------------------
/src/audio.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_AUDIO_H_
21 | #define GD_AUDIO_H_
22 |
23 | #include "definitions.h"
24 | //#include "audio/Multi_Buffer.h"
25 |
26 | //class Sms_Apu;
27 | //class Sound_Queue;
28 |
29 | class Audio
30 | {
31 | public:
32 | Audio();
33 | ~Audio();
34 | void Init();
35 | void Reset();
36 | void Enable(bool enabled);
37 | bool IsEnabled() const;
38 | void SetSampleRate(int rate);
39 | void WriteAudioRegister(u8 value);
40 | void WriteGGStereoRegister(u8 value);
41 | void EndFrame();
42 | void Tick(unsigned int clock_cycles);
43 |
44 | private:
45 | bool enabled_;
46 | // Sms_Apu* m_pApu;
47 | // Stereo_Buffer* m_pBuffer;
48 | // long m_Time;
49 | // Sound_Queue* m_pSound;
50 | // int m_iSampleRate;
51 | // blip_sample_t* m_pSampleBuffer;
52 | };
53 |
54 | const long kSampleBufferSize = 8192;
55 |
56 | #endif // GD_AUDIO_H_
57 |
--------------------------------------------------------------------------------
/src/cartridge.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include
21 | #include
22 | #include "cartridge.h"
23 | #include "miniz/miniz.c"
24 |
25 |
26 | Cartridge::Cartridge()
27 | {
28 | InitPointer(m_pROM);
29 | m_iROMSize = 0;
30 | m_Type = CartridgeNotSupported;
31 | m_Zone = CartridgeUnknownZone;
32 | m_bValidROM = false;
33 | m_bReady = false;
34 | m_szFilePath[0] = 0;
35 | m_szFileName[0] = 0;
36 | m_iROMBankCount = 0;
37 | m_bGameGear = false;
38 | m_bPAL = false;
39 | m_bRAMWithoutBattery = false;
40 | }
41 |
42 | Cartridge::~Cartridge()
43 | {
44 | SafeDeleteArray(m_pROM);
45 | }
46 |
47 | void Cartridge::Init()
48 | {
49 | Reset();
50 | }
51 |
52 | void Cartridge::Reset()
53 | {
54 | SafeDeleteArray(m_pROM);
55 | m_iROMSize = 0;
56 | m_Type = CartridgeNotSupported;
57 | m_Zone = CartridgeUnknownZone;
58 | m_bValidROM = false;
59 | m_bReady = false;
60 | m_szFilePath[0] = 0;
61 | m_szFileName[0] = 0;
62 | m_iROMBankCount = 0;
63 | m_bGameGear = false;
64 | m_bPAL = false;
65 | m_bRAMWithoutBattery = false;
66 | }
67 |
68 | bool Cartridge::IsGameGear() const
69 | {
70 | return m_bGameGear;
71 | }
72 |
73 | bool Cartridge::IsPAL() const
74 | {
75 | return m_bPAL;
76 | }
77 |
78 | bool Cartridge::IsValidROM() const
79 | {
80 | return m_bValidROM;
81 | }
82 |
83 | bool Cartridge::IsReady() const
84 | {
85 | return m_bReady;
86 | }
87 | bool Cartridge::HasRAMWithoutBattery() const
88 | {
89 | return m_bRAMWithoutBattery;
90 | }
91 |
92 | Cartridge::CartridgeTypes Cartridge::GetType() const
93 | {
94 | return m_Type;
95 | }
96 |
97 | Cartridge::CartridgeZones Cartridge::GetZone() const
98 | {
99 | return m_Zone;
100 | }
101 |
102 | void Cartridge::ForzeZone(Cartridge::CartridgeZones zone)
103 | {
104 | m_Zone = zone;
105 | }
106 |
107 | int Cartridge::GetROMSize() const
108 | {
109 | return m_iROMSize;
110 | }
111 |
112 | int Cartridge::GetROMBankCount() const
113 | {
114 | return m_iROMBankCount;
115 | }
116 |
117 | const char* Cartridge::GetFilePath() const
118 | {
119 | return m_szFilePath;
120 | }
121 |
122 | const char* Cartridge::GetFileName() const
123 | {
124 | return m_szFileName;
125 | }
126 |
127 | u8* Cartridge::GetROM() const
128 | {
129 | return m_pROM;
130 | }
131 |
132 | bool Cartridge::LoadFromZipFile(const u8* buffer, int size)
133 | {
134 | using namespace std;
135 |
136 | mz_zip_archive zip_archive;
137 | mz_bool status;
138 | memset(&zip_archive, 0, sizeof (zip_archive));
139 |
140 | status = mz_zip_reader_init_mem(&zip_archive, (void*) buffer, size, 0);
141 | if (!status)
142 | {
143 | Log("mz_zip_reader_init_mem() failed!");
144 | return false;
145 | }
146 |
147 | for (unsigned int i = 0; i < mz_zip_reader_get_num_files(&zip_archive); i++)
148 | {
149 | mz_zip_archive_file_stat file_stat;
150 | if (!mz_zip_reader_file_stat(&zip_archive, i, &file_stat))
151 | {
152 | Log("mz_zip_reader_file_stat() failed!");
153 | mz_zip_reader_end(&zip_archive);
154 | return false;
155 | }
156 |
157 | Log("ZIP Content - Filename: \"%s\", Comment: \"%s\", Uncompressed size: %u, Compressed size: %u", file_stat.m_filename, file_stat.m_comment, (unsigned int) file_stat.m_uncomp_size, (unsigned int) file_stat.m_comp_size);
158 |
159 | string fn((const char*) file_stat.m_filename);
160 | transform(fn.begin(), fn.end(), fn.begin(), (int(*)(int)) tolower);
161 | string extension = fn.substr(fn.find_last_of(".") + 1);
162 |
163 | if ((extension == "sms") || (extension == "gg"))
164 | {
165 | m_bGameGear = (extension == "gg");
166 |
167 | void *p;
168 | size_t uncomp_size;
169 |
170 | p = mz_zip_reader_extract_file_to_heap(&zip_archive, file_stat.m_filename, &uncomp_size, 0);
171 | if (!p)
172 | {
173 | Log("mz_zip_reader_extract_file_to_heap() failed!");
174 | mz_zip_reader_end(&zip_archive);
175 | return false;
176 | }
177 |
178 | bool ok = LoadFromBuffer((const u8*) p, uncomp_size);
179 |
180 | free(p);
181 | mz_zip_reader_end(&zip_archive);
182 |
183 | return ok;
184 | }
185 | }
186 | return false;
187 | }
188 |
189 | bool Cartridge::LoadFromFile(const char* path)
190 | {
191 | using namespace std;
192 |
193 | Log("Loading %s...", path);
194 |
195 | Reset();
196 |
197 | strcpy(m_szFilePath, path);
198 |
199 | std::string pathstr(path);
200 | std::string filename;
201 |
202 | size_t pos = pathstr.find_last_of("\\");
203 | if (pos != std::string::npos)
204 | {
205 | filename.assign(pathstr.begin() + pos + 1, pathstr.end());
206 | }
207 | else
208 | {
209 | pos = pathstr.find_last_of("/");
210 | if (pos != std::string::npos)
211 | {
212 | filename.assign(pathstr.begin() + pos + 1, pathstr.end());
213 | }
214 | else
215 | {
216 | filename = pathstr;
217 | }
218 | }
219 |
220 | strcpy(m_szFileName, filename.c_str());
221 |
222 | ifstream file(path, ios::in | ios::binary | ios::ate);
223 |
224 | if (file.is_open())
225 | {
226 | int size = static_cast (file.tellg());
227 | char* memblock = new char[size];
228 | file.seekg(0, ios::beg);
229 | file.read(memblock, size);
230 | file.close();
231 |
232 | string fn(path);
233 | transform(fn.begin(), fn.end(), fn.begin(), (int(*)(int)) tolower);
234 | string extension = fn.substr(fn.find_last_of(".") + 1);
235 |
236 | if (extension == "zip")
237 | {
238 | Log("Loading from ZIP...");
239 | m_bReady = LoadFromZipFile(reinterpret_cast (memblock), size);
240 | }
241 | else
242 | {
243 | m_bGameGear = (extension == "gg");
244 | m_bReady = LoadFromBuffer(reinterpret_cast (memblock), size);
245 | }
246 |
247 | if (m_bReady)
248 | {
249 | Log("ROM loaded", path);
250 | }
251 | else
252 | {
253 | Log("There was a problem loading the memory for file %s...", path);
254 | }
255 |
256 | SafeDeleteArray(memblock);
257 | }
258 | else
259 | {
260 | Log("There was a problem loading the file %s...", path);
261 | m_bReady = false;
262 | }
263 |
264 | if (!m_bReady)
265 | {
266 | Reset();
267 | }
268 |
269 | return m_bReady;
270 | }
271 |
272 | bool Cartridge::LoadFromBuffer(const u8* buffer, int size)
273 | {
274 | if (IsValidPointer(buffer))
275 | {
276 | // Some ROMs have 512 Byte File Headers
277 | if ((size % 1024) == 512)
278 | {
279 | buffer += 512;
280 | size -= 512;
281 | Log("Invalid size found. ROM trimmed to %d bytes", size);
282 | }
283 | // Unkown size
284 | else if ((size % 1024) != 0)
285 | {
286 | Log("Invalid size found. %d bytes", size);
287 | return false;
288 | }
289 |
290 | m_iROMSize = size;
291 | m_pROM = new u8[m_iROMSize];
292 | memcpy(m_pROM, buffer, m_iROMSize);
293 |
294 | u32 crc;
295 |
296 | return GatherMetadata(crc);
297 | }
298 | else
299 | return false;
300 | }
301 |
302 | unsigned int Cartridge::Pow2Ceil(u16 n)
303 | {
304 | --n;
305 | n |= n >> 1;
306 | n |= n >> 2;
307 | n |= n >> 4;
308 | n |= n >> 8;
309 | ++n;
310 | return n;
311 | }
312 |
313 | bool Cartridge::TestValidROM(u16 location)
314 | {
315 | if (location + 0x10 > m_iROMSize)
316 | return false;
317 |
318 | char tmrsega[9] = {0};
319 | tmrsega[8] = 0;
320 |
321 | for (int i = 0; i < 8; i++)
322 | {
323 | tmrsega[i] = m_pROM[location + i];
324 | }
325 |
326 | return (strcmp(tmrsega, "TMR SEGA") == 0);
327 | }
328 |
329 | bool Cartridge::GatherMetadata(u32 crc)
330 | {
331 | u16 headerLocation = 0x7FF0;
332 | m_bValidROM = true;
333 |
334 | if (!TestValidROM(headerLocation))
335 | {
336 | headerLocation = 0x1FF0;
337 | if (!TestValidROM(headerLocation))
338 | {
339 | headerLocation = 0x3FF0;
340 | if (!TestValidROM(headerLocation))
341 | {
342 | m_bValidROM = false;
343 | }
344 | }
345 | }
346 |
347 | if (m_bValidROM)
348 | {
349 | Log("ROM is Valid. Header found at: %X", headerLocation);
350 | }
351 | else
352 | {
353 | Log("ROM is NOT Valid. No header found");
354 | }
355 |
356 | u8 zone = (m_pROM[headerLocation + 0x0F] >> 4) & 0x0F;
357 |
358 | switch (zone)
359 | {
360 | case 3:
361 | {
362 | m_Zone = CartridgeJapanSMS;
363 | Log("Cartridge zone is SMS Japan");
364 | break;
365 | }
366 | case 4:
367 | {
368 | m_Zone = CartridgeExportSMS;
369 | Log("Cartridge zone is SMS Export");
370 | break;
371 | }
372 | case 5:
373 | {
374 | m_Zone = CartridgeJapanGG;
375 | m_bGameGear = true;
376 | Log("Cartridge zone is GG Japan");
377 | break;
378 | }
379 | case 6:
380 | {
381 | m_Zone = CartridgeExportGG;
382 | m_bGameGear = true;
383 | Log("Cartridge zone is GG Export");
384 | break;
385 | }
386 | case 7:
387 | {
388 | m_Zone = CartridgeInternationalGG;
389 | m_bGameGear = true;
390 | Log("Cartridge zone is GG International");
391 | break;
392 | }
393 | default:
394 | {
395 | m_Zone = CartridgeUnknownZone;
396 | Log("Unknown cartridge zone");
397 | break;
398 | }
399 | }
400 |
401 | m_iROMBankCount = std::max(Pow2Ceil(m_iROMSize / 0x4000), 1u);
402 |
403 | Log("ROM Size: %d KB", m_iROMSize / 1024);
404 | Log("ROM Bank Count: %d", m_iROMBankCount);
405 |
406 | if (m_iROMSize <= 0xC000)
407 | {
408 | // size <= 48KB
409 | m_Type = Cartridge::CartridgeRomOnlyMapper;
410 | }
411 | else
412 | {
413 | m_Type = Cartridge::CartridgeSegaMapper;
414 | }
415 |
416 | switch (m_Type)
417 | {
418 | case Cartridge::CartridgeRomOnlyMapper:
419 | Log("NO mapper found");
420 | break;
421 | case Cartridge::CartridgeSegaMapper:
422 | Log("SEGA mapper found");
423 | break;
424 | case Cartridge::CartridgeCodemastersMapper:
425 | Log("Codemasters mapper found");
426 | break;
427 | case Cartridge::CartridgeNotSupported:
428 | Log("Cartridge not supported!!");
429 | break;
430 | default:
431 | Log("ERROR with cartridge type!!");
432 | break;
433 | }
434 |
435 | if (m_bGameGear)
436 | {
437 | Log("Game Gear cartridge identified");
438 | }
439 |
440 | return (m_Type != CartridgeNotSupported);
441 | }
442 |
--------------------------------------------------------------------------------
/src/cartridge.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_CARTRIDGE_H_
21 | #define GD_CARTRIDGE_H_
22 |
23 | #include "definitions.h"
24 |
25 | class Cartridge
26 | {
27 | public:
28 | enum CartridgeTypes
29 | {
30 | CartridgeRomOnlyMapper,
31 | CartridgeSegaMapper,
32 | CartridgeCodemastersMapper,
33 | CartridgeNotSupported
34 | };
35 | enum CartridgeZones
36 | {
37 | CartridgeJapanSMS,
38 | CartridgeExportSMS,
39 | CartridgeJapanGG,
40 | CartridgeExportGG,
41 | CartridgeInternationalGG,
42 | CartridgeUnknownZone
43 | };
44 |
45 | public:
46 | Cartridge();
47 | ~Cartridge();
48 | void Init();
49 | void Reset();
50 | bool IsGameGear() const;
51 | bool IsPAL() const;
52 | bool IsValidROM() const;
53 | bool IsReady() const;
54 | bool HasRAMWithoutBattery() const;
55 | CartridgeTypes GetType() const;
56 | CartridgeZones GetZone() const;
57 | void ForzeZone(CartridgeZones zone);
58 | int GetROMSize() const;
59 | int GetROMBankCount() const;
60 | const char* GetFilePath() const;
61 | const char* GetFileName() const;
62 | u8* GetROM() const;
63 | bool LoadFromFile(const char* path);
64 | bool LoadFromBuffer(const u8* buffer, int size);
65 |
66 | private:
67 | unsigned int Pow2Ceil(u16 n);
68 | bool GatherMetadata(u32 crc);
69 | bool LoadFromZipFile(const u8* buffer, int size);
70 | bool TestValidROM(u16 location);
71 |
72 | private:
73 | u8* m_pROM;
74 | int m_iROMSize;
75 | CartridgeTypes m_Type;
76 | CartridgeZones m_Zone;
77 | bool m_bValidROM;
78 | bool m_bReady;
79 | char m_szFilePath[512];
80 | char m_szFileName[512];
81 | int m_iROMBankCount;
82 | bool m_bGameGear;
83 | bool m_bPAL;
84 | bool m_bRAMWithoutBattery;
85 | };
86 |
87 | #endif // GD_CARTRIDGE_H_
88 |
--------------------------------------------------------------------------------
/src/definitions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_DEFINITIONS_H_
21 | #define GD_DEFINITIONS_H_
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | #define DEBUG_GEARDRIVE 1
32 |
33 | #ifdef DEBUG_GEARDRIVE
34 | #define DISASM_GEARDRIVE 1
35 | #endif
36 |
37 | #define GEARDRIVE_TITLE "Geardrive 1.0"
38 | #define GEARDRIVE_VERSION 1.0
39 |
40 | #ifdef _WIN32
41 | #define BLARGG_USE_NAMESPACE 1
42 | #endif
43 |
44 | #define SafeDelete(pointer) if(pointer != NULL) {delete pointer; pointer = NULL;}
45 | #define SafeDeleteArray(pointer) if(pointer != NULL) {delete [] pointer; pointer = NULL;}
46 |
47 | #define InitPointer(pointer) ((pointer) = NULL)
48 | #define IsValidPointer(pointer) ((pointer) != NULL)
49 |
50 | typedef uint8_t u8;
51 | typedef int8_t s8;
52 | typedef uint16_t u16;
53 | typedef int16_t s16;
54 | typedef uint32_t u32;
55 | typedef int32_t s32;
56 | typedef uint64_t u64;
57 | typedef int64_t s64;
58 |
59 | #ifdef DEBUG_GEARDRIVE
60 | #define Log(msg, ...) (LogImpl(msg, ##__VA_ARGS__))
61 | #else
62 | #define Log(msg, ...)
63 | #endif
64 |
65 | inline void LogImpl(const char* const msg, ...)
66 | {
67 | static int count = 1;
68 | char szBuf[512];
69 | va_list args;
70 | va_start(args, msg);
71 | vsprintf(szBuf, msg, args);
72 | va_end(args);
73 | printf("%d: %s\n", count, szBuf);
74 | count++;
75 | }
76 |
77 | inline u8 SetBit(const u8 value, const u8 bit)
78 | {
79 | return value | (0x01 << bit);
80 | }
81 |
82 | inline u8 UnsetBit(const u8 value, const u8 bit)
83 | {
84 | return value & (~(0x01 << bit));
85 | }
86 |
87 | inline bool IsSetBit(const u8 value, const u8 bit)
88 | {
89 | return (value & (0x01 << bit)) != 0;
90 | }
91 |
92 | inline u8 FlipBit(const u8 value, const u8 bit)
93 | {
94 | return value ^ (0x01 << bit);
95 | }
96 |
97 | #endif // GD_DEFINITIONS_H_
98 |
99 |
--------------------------------------------------------------------------------
/src/geardrive.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_GEARDRIVE_H_
21 | #define GD_GEARDRIVE_H_
22 |
23 | #include "definitions.h"
24 | #include "geardrive_core.h"
25 | #include "cartridge.h"
26 | #include "video.h"
27 | #include "input.h"
28 |
29 | #endif // GD_GEARDRIVE_H_
30 |
31 |
--------------------------------------------------------------------------------
/src/geardrive_core.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "geardrive_core.h"
21 | //#include "Memory.h"
22 | //#include "Processor.h"
23 | #include "audio.h"
24 | #include "video.h"
25 | #include "input.h"
26 | #include "cartridge.h"
27 | //#include "MemoryRule.h"
28 | //#include "SegaMemoryRule.h"
29 | //#include "CodemastersMemoryRule.h"
30 | //#include "RomOnlyMemoryRule.h"
31 | //#include "SmsIOPorts.h"
32 | //#include "GameGearIOPorts.h"
33 |
34 | GeardriveCore::GeardriveCore()
35 | {
36 | // InitPointer(m_pMemory);
37 | // InitPointer(m_pProcessor);
38 | InitPointer(audio_);
39 | InitPointer(video_);
40 | InitPointer(input_);
41 | InitPointer(cartridge_);
42 | // InitPointer(m_pSegaMemoryRule);
43 | // InitPointer(m_pCodemastersMemoryRule);
44 | // InitPointer(m_pRomOnlyMemoryRule);
45 | // InitPointer(m_pSmsIOPorts);
46 | // InitPointer(m_pGameGearIOPorts);
47 | paused_ = true;
48 | }
49 |
50 | GeardriveCore::~GeardriveCore()
51 | {
52 | #ifdef DEBUG_GEARSYSTEM
53 | if (cartridge_->IsReady())
54 | {
55 | Log("Saving Memory Dump...");
56 |
57 | using namespace std;
58 |
59 | char path[512];
60 |
61 | strcpy(path, cartridge_->GetFilePath());
62 | strcat(path, ".dump");
63 |
64 | m_pMemory->MemoryDump(path);
65 |
66 | Log("Memory Dump Saved");
67 | }
68 | #endif
69 |
70 | // SafeDelete(m_pGameGearIOPorts);
71 | // SafeDelete(m_pSmsIOPorts);
72 | // SafeDelete(m_pRomOnlyMemoryRule);
73 | // SafeDelete(m_pCodemastersMemoryRule);
74 | // SafeDelete(m_pSegaMemoryRule);
75 | SafeDelete(cartridge_);
76 | SafeDelete(input_);
77 | SafeDelete(video_);
78 | SafeDelete(audio_);
79 | // SafeDelete(m_pProcessor);
80 | // SafeDelete(m_pMemory);
81 | }
82 |
83 | void GeardriveCore::Init()
84 | {
85 | Log("-=:: GEARDRIVE %1.1f ::=-", GEARDRIVE_VERSION);
86 |
87 | // m_pMemory = new Memory();
88 | // m_pProcessor = new Processor(m_pMemory);
89 | audio_ = new Audio();
90 | video_ = new Video();
91 | input_ = new Input();
92 | cartridge_ = new Cartridge();
93 | // m_pSmsIOPorts = new SmsIOPorts(audio_, video_, input_, m_pCartridge);
94 | // m_pGameGearIOPorts = new GameGearIOPorts(audio_, video_, input_, m_pCartridge);
95 | //
96 | // m_pMemory->Init();
97 | // m_pProcessor->Init();
98 | audio_->Init();
99 | video_->Init();
100 | input_->Init();
101 | cartridge_->Init();
102 |
103 | InitMemoryRules();
104 | }
105 |
106 | void GeardriveCore::RunToVBlank(GD_Color* frame_Buffer)
107 | {
108 | if (!paused_ && cartridge_->IsReady())
109 | {
110 | bool vblank = false;
111 | while (!vblank)
112 | {
113 | unsigned int clock_cycles = 0;
114 | // unsigned int clockCycles = m_pProcessor->Tick();
115 | vblank = video_->Tick(clock_cycles, frame_Buffer);
116 | audio_->Tick(clock_cycles);
117 | input_->Tick(clock_cycles);
118 | }
119 | audio_->EndFrame();
120 | }
121 | }
122 |
123 | bool GeardriveCore::LoadROM(const char* path)
124 | {
125 | #ifdef DEBUG_GEARSYSTEM
126 | if (cartridge_->IsReady())
127 | {
128 | Log("Saving Memory Dump...");
129 |
130 | using namespace std;
131 |
132 | char dmp_path[512];
133 |
134 | strcpy(dmp_path, cartridge_->GetFilePath());
135 | strcat(dmp_path, ".dump");
136 |
137 | m_pMemory->MemoryDump(dmp_path);
138 |
139 | Log("Memory Dump Saved");
140 | }
141 | #endif
142 |
143 | bool loaded = cartridge_->LoadFromFile(path);
144 | if (loaded)
145 | {
146 | Reset();
147 | // m_pMemory->LoadSlotsFromROM(m_pCartridge->GetROM(), m_pCartridge->GetROMSize());
148 | bool romTypeOK = AddMemoryRules();
149 |
150 | if (!romTypeOK)
151 | {
152 | Log("There was a problem with the cartridge header. File: %s...", path);
153 | }
154 |
155 | return romTypeOK;
156 | }
157 | else
158 | return false;
159 | }
160 |
161 | //Memory* GearsystemCore::GetMemory()
162 | //{
163 | // return m_pMemory;
164 | //}
165 |
166 | Cartridge* GeardriveCore::GetCartridge()
167 | {
168 | return cartridge_;
169 | }
170 |
171 | void GeardriveCore::KeyPressed(GD_Joypads joypad, GD_Keys key)
172 | {
173 | input_->KeyPressed(joypad, key);
174 | }
175 |
176 | void GeardriveCore::KeyReleased(GD_Joypads joypad, GD_Keys key)
177 | {
178 | input_->KeyReleased(joypad, key);
179 | }
180 |
181 | void GeardriveCore::Pause(bool paused)
182 | {
183 | if (paused)
184 | {
185 | Log("Geardrive PAUSED");
186 | }
187 | else
188 | {
189 | Log("Geardrive RESUMED");
190 | }
191 | paused_ = paused;
192 | }
193 |
194 | bool GeardriveCore::IsPaused()
195 | {
196 | return paused_;
197 | }
198 |
199 | void GeardriveCore::ResetROM()
200 | {
201 | if (cartridge_->IsReady())
202 | {
203 | Log("Geardrive RESET");
204 | Reset();
205 | // m_pMemory->LoadSlotsFromROM(m_pCartridge->GetROM(), m_pCartridge->GetROMSize());
206 | AddMemoryRules();
207 | }
208 | }
209 |
210 | void GeardriveCore::EnableSound(bool enabled)
211 | {
212 | if (enabled)
213 | {
214 | Log("Geardrive sound ENABLED");
215 | }
216 | else
217 | {
218 | Log("Geardrive sound DISABLED");
219 | }
220 | audio_->Enable(enabled);
221 | }
222 |
223 | void GeardriveCore::SetSoundSampleRate(int rate)
224 | {
225 | Log("Geardrive sound sample rate: %d", rate);
226 | audio_->SetSampleRate(rate);
227 | }
228 |
229 | void GeardriveCore::SaveRam()
230 | {
231 | SaveRam(NULL);
232 | }
233 |
234 | void GeardriveCore::SaveRam(const char* path)
235 | {
236 | // if (m_pCartridge->IsReady() && IsValidPointer(m_pMemory->GetCurrentRule()) && m_pMemory->GetCurrentRule()->PersistedRAM())
237 | // {
238 | // Log("Saving RAM...");
239 | //
240 | // using namespace std;
241 | //
242 | // char path[512];
243 | //
244 | // if (IsValidPointer(szPath))
245 | // {
246 | // strcpy(path, szPath);
247 | // strcat(path, "/");
248 | // strcat(path, m_pCartridge->GetFileName());
249 | // }
250 | // else
251 | // {
252 | // strcpy(path, m_pCartridge->GetFilePath());
253 | // }
254 | //
255 | // strcat(path, ".gearsystem");
256 | //
257 | // Log("Save file: %s", path);
258 | //
259 | // ofstream file(path, ios::out | ios::binary);
260 | //
261 | // m_pMemory->GetCurrentRule()->SaveRam(file);
262 | //
263 | // Log("RAM saved");
264 | // }
265 | }
266 |
267 | void GeardriveCore::LoadRam()
268 | {
269 | LoadRam(NULL);
270 | }
271 |
272 | void GeardriveCore::LoadRam(const char* path)
273 | {
274 | // if (m_pCartridge->IsReady() && IsValidPointer(m_pMemory->GetCurrentRule()))
275 | // {
276 | // Log("Loading RAM...");
277 | //
278 | // using namespace std;
279 | //
280 | // char path[512];
281 | //
282 | // if (IsValidPointer(szPath))
283 | // {
284 | // strcpy(path, szPath);
285 | // strcat(path, "/");
286 | // strcat(path, m_pCartridge->GetFileName());
287 | // }
288 | // else
289 | // {
290 | // strcpy(path, m_pCartridge->GetFilePath());
291 | // }
292 | //
293 | // strcat(path, ".gearsystem");
294 | //
295 | // Log("Opening save file: %s", path);
296 | //
297 | // ifstream file(path, ios::in | ios::binary);
298 | //
299 | // if (!file.fail())
300 | // {
301 | // char signature[16];
302 | //
303 | // file.read(signature, 16);
304 | //
305 | // file.seekg(0, file.end);
306 | // s32 fileSize = (s32) file.tellg();
307 | // file.seekg(0, file.beg);
308 | //
309 | // if (m_pMemory->GetCurrentRule()->LoadRam(file, fileSize))
310 | // {
311 | // Log("RAM loaded");
312 | // }
313 | // else
314 | // {
315 | // Log("Save file size incorrect: %d", fileSize);
316 | // }
317 | // }
318 | // else
319 | // {
320 | // Log("Save file doesn't exist");
321 | // }
322 | // }
323 | }
324 |
325 | float GeardriveCore::GetVersion()
326 | {
327 | return GEARDRIVE_VERSION;
328 | }
329 |
330 | void GeardriveCore::InitMemoryRules()
331 | {
332 | // m_pCodemastersMemoryRule = new CodemastersMemoryRule(m_pMemory, m_pCartridge);
333 | // m_pSegaMemoryRule = new SegaMemoryRule(m_pMemory, m_pCartridge);
334 | // m_pRomOnlyMemoryRule = new RomOnlyMemoryRule(m_pMemory, m_pCartridge);
335 | }
336 |
337 | bool GeardriveCore::AddMemoryRules()
338 | {
339 | // Cartridge::CartridgeTypes type = m_pCartridge->GetType();
340 | //
341 | // bool notSupported = false;
342 | //
343 | // switch (type)
344 | // {
345 | // case Cartridge::CartridgeRomOnlyMapper:
346 | // m_pMemory->SetCurrentRule(m_pRomOnlyMemoryRule);
347 | // break;
348 | // case Cartridge::CartridgeSegaMapper:
349 | // m_pMemory->SetCurrentRule(m_pSegaMemoryRule);
350 | // break;
351 | // case Cartridge::CartridgeCodemastersMapper:
352 | // m_pMemory->SetCurrentRule(m_pCodemastersMemoryRule);
353 | // break;
354 | // case Cartridge::CartridgeNotSupported:
355 | // notSupported = true;
356 | // break;
357 | // default:
358 | // notSupported = true;
359 | // }
360 | //
361 | // if (m_pCartridge->IsGameGear())
362 | // {
363 | // Log("Game Gear Mode enabled");
364 | // m_pProcessor->SetIOPOrts(m_pGameGearIOPorts);
365 | // }
366 | // else
367 | // {
368 | // Log("Master System Mode enabled");
369 | // m_pProcessor->SetIOPOrts(m_pSmsIOPorts);
370 | // }
371 | //
372 | // return !notSupported;
373 | return true;
374 | }
375 |
376 | void GeardriveCore::Reset()
377 | {
378 | // m_pMemory->Reset();
379 | // m_pProcessor->Reset();
380 | audio_->Reset();
381 | video_->Reset(cartridge_->IsPAL());
382 | input_->Reset();
383 | // m_pSegaMemoryRule->Reset();
384 | // m_pCodemastersMemoryRule->Reset();
385 | // m_pRomOnlyMemoryRule->Reset();
386 | // m_pGameGearIOPorts->Reset();
387 | // m_pSmsIOPorts->Reset();
388 | paused_ = false;
389 | }
390 |
391 |
--------------------------------------------------------------------------------
/src/geardrive_core.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_GEARDRIVECORE_H_
21 | #define GD_GEARDRIVECORE_H_
22 |
23 | #include "video.h"
24 | #include "input.h"
25 |
26 | enum GD_System
27 | {
28 | kSystem_NTSC_USA,
29 | kSystem_NTSC_JAP,
30 | kSystem_PAL_EUR
31 | };
32 |
33 | //class Memory;
34 | //class Processor;
35 | class Audio;
36 | class Cartridge;
37 | //class SegaMemoryRule;
38 | //class CodemastersMemoryRule;
39 | //class RomOnlyMemoryRule;
40 | //class MemoryRule;
41 | //class SmsIOPorts;
42 | //class GameGearIOPorts;
43 |
44 | class GeardriveCore
45 | {
46 | public:
47 | GeardriveCore();
48 | ~GeardriveCore();
49 | void Init();
50 | void RunToVBlank(GD_Color* frame_buffer);
51 | bool LoadROM(const char* path);
52 | // Memory* GetMemory();
53 | Cartridge* GetCartridge();
54 | void KeyPressed(GD_Joypads joypad, GD_Keys key);
55 | void KeyReleased(GD_Joypads joypad, GD_Keys key);
56 | void Pause(bool paused);
57 | bool IsPaused();
58 | void ResetROM();
59 | void EnableSound(bool enabled);
60 | void SetSoundSampleRate(int rate);
61 | void SaveRam();
62 | void SaveRam(const char* path);
63 | void LoadRam();
64 | void LoadRam(const char* path);
65 | float GetVersion();
66 |
67 | private:
68 | void InitMemoryRules();
69 | bool AddMemoryRules();
70 | void Reset();
71 |
72 | private:
73 | // Memory* m_pMemory;
74 | // Processor* m_pProcessor;
75 | Audio* audio_;
76 | Video* video_;
77 | Input* input_;
78 | Cartridge* cartridge_;
79 | // SegaMemoryRule* m_pSegaMemoryRule;
80 | // CodemastersMemoryRule* m_pCodemastersMemoryRule;
81 | // RomOnlyMemoryRule* m_pRomOnlyMemoryRule;
82 | // SmsIOPorts* m_pSmsIOPorts;
83 | // GameGearIOPorts* m_pGameGearIOPorts;
84 | bool paused_;
85 | };
86 |
87 | #endif // GD_GEARDRIVECORE_H_
88 |
89 |
--------------------------------------------------------------------------------
/src/input.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "input.h"
21 |
22 | Input::Input()
23 | {
24 |
25 | }
26 |
27 | void Input::Init()
28 | {
29 | Reset();
30 | }
31 |
32 | void Input::Reset()
33 | {
34 |
35 | }
36 |
37 | void Input::Tick(unsigned int clock_cycles)
38 | {
39 |
40 | }
41 |
42 | void Input::KeyPressed(GD_Joypads joypad, GD_Keys key)
43 | {
44 |
45 | }
46 |
47 | void Input::KeyReleased(GD_Joypads joypad, GD_Keys key)
48 | {
49 |
50 | }
51 |
52 | void Input::Update()
53 | {
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/input.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_INPUT_H_
21 | #define GD_INPUT_H_
22 |
23 | #include "definitions.h"
24 |
25 | enum GD_Keys
26 | {
27 | kKeyUp,
28 | kKeyDown,
29 | kKeyLeft,
30 | kKeyRight,
31 | kKeyA,
32 | kKeyB,
33 | kKeyC,
34 | kKeyStart
35 | };
36 |
37 | enum GD_Joypads
38 | {
39 | kJoypad1,
40 | kJoypad2
41 | };
42 |
43 | class Input
44 | {
45 | public:
46 | Input();
47 | void Init();
48 | void Reset();
49 | void Tick(unsigned int clock_cycles);
50 | void KeyPressed(GD_Joypads joypad, GD_Keys key);
51 | void KeyReleased(GD_Joypads joypad, GD_Keys key);
52 |
53 | private:
54 | void Update();
55 | };
56 |
57 | #endif // GD_INPUT_H_
58 |
59 |
--------------------------------------------------------------------------------
/src/video.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Gearsystem - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #include "Video.h"
21 |
22 | Video::Video()
23 | {
24 |
25 | }
26 |
27 | Video::~Video()
28 | {
29 |
30 | }
31 |
32 | void Video::Init()
33 | {
34 | Reset(false);
35 | }
36 |
37 | void Video::Reset(bool is_pal)
38 | {
39 |
40 | }
41 |
42 | bool Video::Tick(unsigned int clock_cycles, GD_Color* frame_buffer)
43 | {
44 | return true;
45 | }
46 |
47 | void Video::LatchHCounter()
48 | {
49 |
50 | }
51 |
52 | u8 Video::GetVCounter()
53 | {
54 | return 0;
55 | }
56 |
57 | u8 Video::GetHCounter()
58 | {
59 | return 0;
60 | }
61 |
62 | u8 Video::GetDataPort()
63 | {
64 | return 0;
65 | }
66 |
67 | u8 Video::GetStatusFlags()
68 | {
69 | return 0;
70 | }
71 |
72 | void Video::WriteData(u8 data)
73 | {
74 |
75 | }
76 |
77 | void Video::WriteControl(u8 control)
78 | {
79 |
80 | }
81 |
82 | void Video::ScanLine(int line)
83 | {
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/video.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Geardrive - Sega Mega Drive / Genesis Emulator
3 | * Copyright (C) 2014 Ignacio Sanchez Gines
4 |
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * any later version.
9 |
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 |
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see http://www.gnu.org/licenses/
17 | *
18 | */
19 |
20 | #ifndef GD_VIDEO_H_
21 | #define GD_VIDEO_H_
22 |
23 | #include "definitions.h"
24 |
25 | #define GD_GEN_WIDTH 320
26 | #define GD_GEN_HEIGHT 224
27 | #define VDP_READ_VRAM_OPERATION 0x00
28 | #define VDP_WRITE_VRAM_OPERATION 0x01
29 | #define VDP_WRITE_REG_OPERATION 0x02
30 | #define VDP_WRITE_CRAM_OPERATION 0x03
31 |
32 | struct GD_Color
33 | {
34 | u8 red;
35 | u8 green;
36 | u8 blue;
37 | u8 alpha;
38 | };
39 |
40 | class Video
41 | {
42 | public:
43 | Video();
44 | ~Video();
45 | void Init();
46 | void Reset(bool is_pal);
47 | bool Tick(unsigned int clock_cycles, GD_Color* frame_buffer);
48 | u8 GetVCounter();
49 | u8 GetHCounter();
50 | u8 GetDataPort();
51 | u8 GetStatusFlags();
52 | void WriteData(u8 data);
53 | void WriteControl(u8 control);
54 | void LatchHCounter();
55 |
56 | private:
57 | void ScanLine(int line);
58 | };
59 |
60 | #endif // GD_VIDEO_H_
61 |
62 |
--------------------------------------------------------------------------------