├── .gitignore
├── README.md
├── development
├── Qt Creator
│ ├── .gitignore
│ └── μZX.pro
└── Xcode
│ ├── μZX (OS X).xcodeproj
│ └── project.pbxproj
│ └── μZX (iOS).xcodeproj
│ └── project.pbxproj
├── include
└── Q
├── resources
├── OS X
│ ├── UI
│ │ ├── MachineWindow.xib
│ │ ├── PreferencesWindow.xib
│ │ ├── TapeRecorderWindow.xib
│ │ ├── Title Sheet.xib
│ │ ├── Z80 Debugger.xib
│ │ └── mZX.xib
│ ├── images
│ │ ├── Debugger.pdf
│ │ ├── Images.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── Keyboard.pdf
│ │ └── Tape.pdf
│ └── property lists
│ │ └── Info.plist
├── Qt
│ └── UI
│ │ ├── AboutDialog.ui
│ │ ├── MachineWindow.ui
│ │ ├── MainWindow.ui
│ │ └── UI.pri
├── common
│ ├── ROMs.qrc
│ ├── ROMs
│ │ ├── Inves Spectrum + (Firmware)(ROM).rom
│ │ ├── ZX Interface 1 v.1 (Firmware)(ROM).rom
│ │ ├── ZX Interface 1 v.2 (Firmware)(ROM).rom
│ │ ├── ZX Spectrum (Firmware)(ROM).rom
│ │ ├── ZX Spectrum + 128K (ES)(Firmware)(ROM 1 of 2).rom
│ │ ├── ZX Spectrum + 128K (ES)(Firmware)(ROM 2 of 2).rom
│ │ ├── ZX Spectrum + 128K (Firmware)(ROM 1 of 2).rom
│ │ ├── ZX Spectrum + 128K (Firmware)(ROM 2 of 2).rom
│ │ ├── ZX Spectrum +2 (ES)(Firmware)(ROM 1 of 2).rom
│ │ ├── ZX Spectrum +2 (ES)(Firmware)(ROM 2 of 2).rom
│ │ ├── ZX Spectrum +2 (FR)(Firmware)(ROM 1 of 2).rom
│ │ ├── ZX Spectrum +2 (FR)(Firmware)(ROM 2 of 2).rom
│ │ ├── ZX Spectrum +2 (Firmware)(ROM 1 of 2).rom
│ │ ├── ZX Spectrum +2 (Firmware)(ROM 2 of 2).rom
│ │ ├── ZX Spectrum +3 (ES)(Firmware)(ROM 1 of 4).rom
│ │ ├── ZX Spectrum +3 (ES)(Firmware)(ROM 2 of 4).rom
│ │ ├── ZX Spectrum +3 (ES)(Firmware)(ROM 3 of 4).rom
│ │ ├── ZX Spectrum +3 (ES)(Firmware)(ROM 4 of 4).rom
│ │ ├── ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 1 of 4).rom
│ │ ├── ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 2 of 4).rom
│ │ ├── ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 3 of 4).rom
│ │ ├── ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 4 of 4).rom
│ │ ├── ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 1 of 4).rom
│ │ ├── ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 2 of 4).rom
│ │ ├── ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 3 of 4).rom
│ │ └── ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 4 of 4).rom
│ ├── icons
│ │ ├── Application Icon.png
│ │ ├── Donate.png
│ │ ├── Home Page.png
│ │ ├── Menu - Audio.png
│ │ ├── Menu - CPU Debugger.png
│ │ ├── Menu - Debugger.png
│ │ ├── Menu - Edit Title.png
│ │ ├── Menu - Full Screen.png
│ │ ├── Menu - Keyboard.png
│ │ ├── Menu - Movie.png
│ │ ├── Menu - Power.png
│ │ ├── Menu - Preferences.png
│ │ ├── Menu - Save Screenshot.png
│ │ ├── Menu - Tape Recorder.png
│ │ ├── Menu - Video.png
│ │ ├── Menu - Zoom In.png
│ │ ├── Menu - Zoom Out.png
│ │ ├── Preferences Tab - Emulation.png
│ │ └── Source Code.png
│ ├── images.qrc
│ ├── images
│ │ ├── Tape Recorder Button - Pressed.png
│ │ ├── Tape Recorder Button Separator.png
│ │ ├── Tape Recorder Button.png
│ │ ├── Tape Recorder Record Button - Pressed.png
│ │ └── Tape Recorder Record Button.png
│ ├── resources.pri
│ └── shaders
│ │ ├── GLSL-ES
│ │ ├── Simple.fsh
│ │ └── Simple.vsh
│ │ └── GLSL
│ │ ├── SABR.fsh
│ │ ├── SABR.vsh
│ │ ├── Simple.fsh
│ │ └── Simple.vsh
└── iOS
│ ├── UI
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ └── MachineView.xib
│ ├── images
│ ├── Images.xcassets
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ └── Joystick.png
│ └── property lists
│ └── Info.plist
├── screenshots
├── Avenger In Game.png
├── Avenger Loading.png
├── Batman In Game.png
├── Batman Loading.png
├── Black Lamp Loading.png
├── Hydrofool In Game.png
├── Hydrofool Loading.png
├── Z Moire Run.png
├── Z Moire Source.png
├── ZX Spectrum + 128K Spanish.png
└── ZX Spectrum + 128K.png
└── sources
├── Linux
├── ALSAAudioOutputPlayer.cpp
├── ALSAAudioOutputPlayer.hpp
└── Linux.pri
├── OS X & iOS
├── CoreAudioOutputPlayer.cpp
├── CoreAudioOutputPlayer.hpp
├── GLVideoView.h
└── GLVideoView.mm
├── OS X
├── KeyCodes.h
├── KeyboardWindowController.h
├── KeyboardWindowController.m
├── MachineWindowController.h
├── MachineWindowController.mm
├── MainController.h
├── MainController.mm
├── PreferencesWindowController.h
├── PreferencesWindowController.m
├── Prefix.pch
├── TapeRecorderWindow.h
├── TapeRecorderWindow.m
├── TapeRecorderWindowController.h
├── TapeRecorderWindowController.mm
├── Window.h
├── Window.m
├── extensions
│ ├── NSView+RedCode.h
│ ├── NSView+RedCode.m
│ ├── NSWindow+RedCode.h
│ └── NSWindow+RedCode.m
└── main.m
├── Qt
├── AboutDialog.cpp
├── AboutDialog.hpp
├── GLVideoOutputView.cpp
├── GLVideoOutputView.hpp
├── MachineWindow.cpp
├── MachineWindow.hpp
├── MainWindow.cpp
├── MainWindow.hpp
├── Qt.pri
└── main.cpp
├── common
├── GLFrameBufferRenderer.cpp
├── GLFrameBufferRenderer.hpp
├── Machine.cpp
├── Machine.hpp
├── Matrix.cpp
├── Matrix.hpp
├── OpenGL.cpp
├── OpenGL.hpp
├── codecs
│ └── snapshot
│ │ ├── 89C.c
│ │ ├── ACH.c
│ │ ├── FRZ.c
│ │ ├── PLUSD.c
│ │ ├── PRG.c
│ │ ├── SIT.c
│ │ ├── SNA.c
│ │ ├── SNA.h
│ │ ├── SNP.c
│ │ └── ZX.c
├── common.pri
├── emulators
│ ├── AY-3-891x.c
│ ├── AY-3-891x.h
│ ├── MachineABI.h
│ ├── Z80.c
│ ├── Z80.h
│ ├── ZX Spectrum.c
│ ├── ZX Spectrum.h
│ └── emulators.pri
├── system.c
└── system.h
└── iOS
├── JoystickView.h
├── JoystickView.m
├── KeyboardView.h
├── KeyboardView.m
├── MachineViewController.h
├── MachineViewController.mm
├── MainController.h
├── MainController.m
├── MainViewController.h
├── MainViewController.mm
├── Prefix.pch
├── TapeRecorderView.h
├── TapeRecorderView.m
└── main.m
/.gitignore:
--------------------------------------------------------------------------------
1 | # Per-user IDE configuration files
2 | development/Xcode/μZX (OS X).xcodeproj/project.xcworkspace
3 | development/Xcode/μZX (OS X).xcodeproj/xcuserdata
4 | development/Xcode/μZX (iOS).xcodeproj/project.xcworkspace
5 | development/Xcode/μZX (iOS).xcodeproj/xcuserdata
6 | development/Qt Creator/μZX.pro.user
7 |
8 | # OS generated files
9 | .DS_Store
10 | .directory
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # μZX
2 | Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
3 | Released under the terms of the [GNU General Public License v3](http://www.gnu.org/copyleft/gpl.html).
4 |
5 | 
6 | 
7 | 
8 | 
9 | 
10 | 
11 | 
12 | 
13 | 
14 | 
15 | ### What is μZX?
16 | μZX is a ZX Spectrum emulator. It is in an early stage of development but it works.
17 |
--------------------------------------------------------------------------------
/development/Qt Creator/.gitignore:
--------------------------------------------------------------------------------
1 | μZX.pro.user
2 |
--------------------------------------------------------------------------------
/development/Qt Creator/μZX.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2014-09-24T14:37:20
4 | #
5 | #-------------------------------------------------
6 |
7 | QMAKE_CXXFLAGS += -DCPU_Z80_USE_LOCAL_HEADER
8 | QMAKE_CFLAGS += -DCPU_Z80_USE_LOCAL_HEADER
9 | INCLUDEPATH += /usr/local/include \
10 | /usr/local/include/C++
11 |
12 | QT += core opengl
13 | CONFIG += c++11
14 |
15 | greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
16 |
17 | LIBS += -lX11 -lasound
18 |
19 | ##QMAKE_CFLAGS += -march=bdver1 -O2 -pipe -fno-stack-protector
20 | ##QMAKE_CXXFLAGS += -march=bdver1 -O2 -pipe -fno-stack-protector
21 |
22 | TARGET = μZX
23 | TEMPLATE = app
24 |
25 | P_SOURCES = ../../sources
26 | P_RESOURCES = ../../resources
27 | P_RESOURCES_COMMON = $$P_RESOURCES/common
28 | P_RESOURCES_QT_UI = $$P_RESOURCES/Qt/UI
29 |
30 | INCLUDEPATH += \
31 | /usr/include/C++ \
32 | $$P_SOURCES/common \
33 | $$P_SOURCES/common/emulators \
34 | $$P_SOURCES/Linux \
35 | $$P_SOURCES/Qt \
36 |
37 | include($$P_SOURCES/common/common.pri)
38 | include($$P_SOURCES/common/emulators/emulators.pri)
39 | include($$P_SOURCES/Linux/Linux.pri)
40 | include($$P_SOURCES/Qt/Qt.pri)
41 | include($$P_RESOURCES/Qt/UI/UI.pri)
42 | include($$P_RESOURCES/common/resources.pri)
43 |
--------------------------------------------------------------------------------
/include/Q:
--------------------------------------------------------------------------------
1 | /usr/local/include/Q
--------------------------------------------------------------------------------
/resources/OS X/UI/MachineWindow.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/resources/OS X/UI/PreferencesWindow.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1060
5 | 14D136
6 | 7706
7 | 1347.57
8 | 758.70
9 |
13 |
14 | NSCustomObject
15 | NSView
16 | NSWindowTemplate
17 |
18 |
19 | com.apple.InterfaceBuilder.CocoaPlugin
20 |
21 |
25 |
26 |
29 |
32 |
35 |
56 |
57 |
58 |
59 |
60 |
61 | window
62 |
63 |
64 |
65 | 3
66 |
67 |
68 |
69 |
70 |
71 | 0
72 |
73 |
74 |
75 |
76 |
77 | -2
78 |
79 |
80 | File's Owner
81 |
82 |
83 | -1
84 |
85 |
86 | First Responder
87 |
88 |
89 | -3
90 |
91 |
92 | Application
93 |
94 |
95 | 1
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | 2
104 |
105 |
106 |
107 |
108 |
109 |
110 | com.apple.InterfaceBuilder.CocoaPlugin
111 | com.apple.InterfaceBuilder.CocoaPlugin
112 | com.apple.InterfaceBuilder.CocoaPlugin
113 | {558.5, 491}
114 | com.apple.InterfaceBuilder.CocoaPlugin
115 |
116 | com.apple.InterfaceBuilder.CocoaPlugin
117 |
118 |
119 |
120 |
121 |
122 | 3
123 |
124 |
125 | 0
126 | IBCocoaFramework
127 | YES
128 |
129 | com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3
130 |
131 |
132 | YES
133 | 3
134 |
135 |
136 |
--------------------------------------------------------------------------------
/resources/OS X/UI/TapeRecorderWindow.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
36 |
44 |
52 |
60 |
68 |
76 |
87 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/resources/OS X/images/Debugger.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/OS X/images/Debugger.pdf
--------------------------------------------------------------------------------
/resources/OS X/images/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "mac",
5 | "size" : "16x16",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "mac",
10 | "size" : "16x16",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "mac",
15 | "size" : "32x32",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "mac",
20 | "size" : "32x32",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "mac",
25 | "size" : "128x128",
26 | "scale" : "1x"
27 | },
28 | {
29 | "idiom" : "mac",
30 | "size" : "128x128",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "mac",
35 | "size" : "256x256",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "mac",
40 | "size" : "256x256",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "mac",
45 | "size" : "512x512",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "mac",
50 | "size" : "512x512",
51 | "scale" : "2x"
52 | }
53 | ],
54 | "info" : {
55 | "version" : 1,
56 | "author" : "xcode"
57 | }
58 | }
--------------------------------------------------------------------------------
/resources/OS X/images/Keyboard.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/OS X/images/Keyboard.pdf
--------------------------------------------------------------------------------
/resources/OS X/images/Tape.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/OS X/images/Tape.pdf
--------------------------------------------------------------------------------
/resources/OS X/property lists/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | com.redcode.mZX
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 0.1
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1251
25 | LSMinimumSystemVersion
26 | $(MACOSX_DEPLOYMENT_TARGET)
27 | NSHumanReadableCopyright
28 | Copyright © 2014 Manuel Sainz de Baranda y Goñi. All rights reserved.
29 | NSMainNibFile
30 | mZX
31 | NSPrincipalClass
32 | NSApplication
33 |
34 |
35 |
--------------------------------------------------------------------------------
/resources/Qt/UI/AboutDialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | AboutDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 388
11 |
12 |
13 |
14 | About μZX
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 0
23 | 204
24 | 400
25 | 18
26 |
27 |
28 |
29 |
30 | 13
31 | 75
32 | true
33 |
34 |
35 |
36 | μZX
37 |
38 |
39 | Qt::AlignHCenter|Qt::AlignTop
40 |
41 |
42 | Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
43 |
44 |
45 |
46 |
47 |
48 | 0
49 | 224
50 | 400
51 | 16
52 |
53 |
54 |
55 |
56 | 8
57 |
58 |
59 |
60 | Version 0.1 (1024)
61 |
62 |
63 | Qt::AlignCenter
64 |
65 |
66 | Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
67 |
68 |
69 |
70 |
71 |
72 | 0
73 | 264
74 | 400
75 | 26
76 |
77 |
78 |
79 |
80 | 8
81 |
82 |
83 |
84 | Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi
85 | Released under the terms of the GNU General Public License v3
86 |
87 |
88 | Qt::AlignHCenter|Qt::AlignTop
89 |
90 |
91 | Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
92 |
93 |
94 |
95 |
96 |
97 | 0
98 | 364
99 | 400
100 | 16
101 |
102 |
103 |
104 |
105 | 7
106 |
107 |
108 |
109 | Compiled on 2015-02-26 09:36 UTC with GCC v3.4.2
110 |
111 |
112 | Qt::AlignCenter
113 |
114 |
115 | Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
116 |
117 |
118 |
119 |
120 |
121 | 80
122 | 299
123 | 80
124 | 55
125 |
126 |
127 |
128 |
129 | 8
130 |
131 |
132 |
133 | PointingHandCursor
134 |
135 |
136 | Qt::LeftToRight
137 |
138 |
139 | false
140 |
141 |
142 |
143 |
144 |
145 | Sources
146 |
147 |
148 |
149 | :/icons/Source Code.png:/icons/Source Code.png
150 |
151 |
152 |
153 | 32
154 | 32
155 |
156 |
157 |
158 | Qt::ToolButtonTextUnderIcon
159 |
160 |
161 | true
162 |
163 |
164 |
165 |
166 |
167 | 160
168 | 299
169 | 80
170 | 55
171 |
172 |
173 |
174 |
175 | 8
176 |
177 |
178 |
179 | PointingHandCursor
180 |
181 |
182 | Qt::LeftToRight
183 |
184 |
185 | false
186 |
187 |
188 |
189 |
190 |
191 | Website
192 |
193 |
194 |
195 | :/icons/Home Page.png:/icons/Home Page.png
196 |
197 |
198 |
199 | 32
200 | 32
201 |
202 |
203 |
204 | Qt::ToolButtonTextUnderIcon
205 |
206 |
207 | true
208 |
209 |
210 |
211 |
212 |
213 | 240
214 | 299
215 | 80
216 | 55
217 |
218 |
219 |
220 |
221 | 8
222 |
223 |
224 |
225 | PointingHandCursor
226 |
227 |
228 | Qt::LeftToRight
229 |
230 |
231 | false
232 |
233 |
234 |
235 |
236 |
237 | Donate
238 |
239 |
240 |
241 | :/icons/Donate.png:/icons/Donate.png
242 |
243 |
244 |
245 | 36
246 | 36
247 |
248 |
249 |
250 | Qt::ToolButtonTextUnderIcon
251 |
252 |
253 | true
254 |
255 |
256 |
257 |
258 |
259 | 0
260 | 240
261 | 400
262 | 16
263 |
264 |
265 |
266 |
267 | 7
268 |
269 |
270 |
271 | Linux / Qt 4 / GTK+ 3 / OpenGL
272 |
273 |
274 | Qt::AlignHCenter|Qt::AlignTop
275 |
276 |
277 | Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse
278 |
279 |
280 |
281 |
282 |
283 | 70
284 | 10
285 | 261
286 | 181
287 |
288 |
289 |
290 |
291 |
292 |
293 | :/icons/Application Icon.png
294 |
295 |
296 | Qt::AlignCenter
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
--------------------------------------------------------------------------------
/resources/Qt/UI/MainWindow.ui:
--------------------------------------------------------------------------------
1 |
2 | MainWindow
3 |
4 |
5 |
6 | 0
7 | 0
8 | 400
9 | 300
10 |
11 |
12 |
13 | MainWindow
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/resources/Qt/UI/UI.pri:
--------------------------------------------------------------------------------
1 | FORMS += \
2 | $$P_RESOURCES_QT_UI/MainWindow.ui \
3 | $$P_RESOURCES_QT_UI/MachineWindow.ui \
4 | $$P_RESOURCES_QT_UI/AboutDialog.ui
5 |
--------------------------------------------------------------------------------
/resources/common/ROMs.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | ROMs/Inves Spectrum + (Firmware)(ROM).rom
4 | ROMs/ZX Interface 1 v.1 (Firmware)(ROM).rom
5 | ROMs/ZX Interface 1 v.2 (Firmware)(ROM).rom
6 | ROMs/ZX Spectrum (Firmware)(ROM).rom
7 | ROMs/ZX Spectrum + 128K (ES)(Firmware)(ROM 1 of 2).rom
8 | ROMs/ZX Spectrum + 128K (ES)(Firmware)(ROM 2 of 2).rom
9 | ROMs/ZX Spectrum + 128K (Firmware)(ROM 1 of 2).rom
10 | ROMs/ZX Spectrum + 128K (Firmware)(ROM 2 of 2).rom
11 | ROMs/ZX Spectrum +2 (ES)(Firmware)(ROM 1 of 2).rom
12 | ROMs/ZX Spectrum +2 (ES)(Firmware)(ROM 2 of 2).rom
13 | ROMs/ZX Spectrum +2 (Firmware)(ROM 1 of 2).rom
14 | ROMs/ZX Spectrum +2 (Firmware)(ROM 2 of 2).rom
15 | ROMs/ZX Spectrum +2 (FR)(Firmware)(ROM 1 of 2).rom
16 | ROMs/ZX Spectrum +2 (FR)(Firmware)(ROM 2 of 2).rom
17 | ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 1 of 4).rom
18 | ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 2 of 4).rom
19 | ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 3 of 4).rom
20 | ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 4 of 4).rom
21 | ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 1 of 4).rom
22 | ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 2 of 4).rom
23 | ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 3 of 4).rom
24 | ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 4 of 4).rom
25 | ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 1 of 4).rom
26 | ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 2 of 4).rom
27 | ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 3 of 4).rom
28 | ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 4 of 4).rom
29 |
30 |
31 |
--------------------------------------------------------------------------------
/resources/common/ROMs/Inves Spectrum + (Firmware)(ROM).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/Inves Spectrum + (Firmware)(ROM).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Interface 1 v.1 (Firmware)(ROM).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Interface 1 v.1 (Firmware)(ROM).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Interface 1 v.2 (Firmware)(ROM).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Interface 1 v.2 (Firmware)(ROM).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum (Firmware)(ROM).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum (Firmware)(ROM).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum + 128K (ES)(Firmware)(ROM 1 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum + 128K (ES)(Firmware)(ROM 1 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum + 128K (ES)(Firmware)(ROM 2 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum + 128K (ES)(Firmware)(ROM 2 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum + 128K (Firmware)(ROM 1 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum + 128K (Firmware)(ROM 1 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum + 128K (Firmware)(ROM 2 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum + 128K (Firmware)(ROM 2 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +2 (ES)(Firmware)(ROM 1 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +2 (ES)(Firmware)(ROM 1 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +2 (ES)(Firmware)(ROM 2 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +2 (ES)(Firmware)(ROM 2 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +2 (FR)(Firmware)(ROM 1 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +2 (FR)(Firmware)(ROM 1 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +2 (FR)(Firmware)(ROM 2 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +2 (FR)(Firmware)(ROM 2 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +2 (Firmware)(ROM 1 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +2 (Firmware)(ROM 1 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +2 (Firmware)(ROM 2 of 2).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +2 (Firmware)(ROM 2 of 2).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 1 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 1 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 2 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 2 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 3 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 3 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 4 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 (ES)(Firmware)(ROM 4 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 1 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 1 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 2 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 2 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 3 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 3 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 4 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.0 (ES)(Firmware)(ROM 4 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 1 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 1 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 2 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 2 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 3 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 3 of 4).rom
--------------------------------------------------------------------------------
/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 4 of 4).rom:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/ROMs/ZX Spectrum +3 v4.1 (ES)(Firmware)(ROM 4 of 4).rom
--------------------------------------------------------------------------------
/resources/common/icons/Application Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Application Icon.png
--------------------------------------------------------------------------------
/resources/common/icons/Donate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Donate.png
--------------------------------------------------------------------------------
/resources/common/icons/Home Page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Home Page.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Audio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Audio.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - CPU Debugger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - CPU Debugger.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Debugger.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Debugger.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Edit Title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Edit Title.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Full Screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Full Screen.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Keyboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Keyboard.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Movie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Movie.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Power.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Power.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Preferences.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Preferences.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Save Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Save Screenshot.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Tape Recorder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Tape Recorder.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Video.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Video.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Zoom In.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Zoom In.png
--------------------------------------------------------------------------------
/resources/common/icons/Menu - Zoom Out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Menu - Zoom Out.png
--------------------------------------------------------------------------------
/resources/common/icons/Preferences Tab - Emulation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Preferences Tab - Emulation.png
--------------------------------------------------------------------------------
/resources/common/icons/Source Code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/icons/Source Code.png
--------------------------------------------------------------------------------
/resources/common/images.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | icons/Source Code.png
4 | icons/Home Page.png
5 | icons/Menu - Zoom In.png
6 | icons/Menu - Zoom Out.png
7 | icons/Menu - CPU Debugger.png
8 | icons/Menu - Preferences.png
9 | icons/Menu - Power.png
10 | icons/Donate.png
11 | icons/Menu - Full Screen.png
12 | icons/Menu - Audio.png
13 | icons/Menu - Save Screenshot.png
14 | icons/Menu - Movie.png
15 | icons/Menu - Video.png
16 | icons/Application Icon.png
17 | icons/Menu - Debugger.png
18 | icons/Menu - Edit Title.png
19 | icons/Menu - Keyboard.png
20 | icons/Menu - Tape Recorder.png
21 |
22 |
23 |
--------------------------------------------------------------------------------
/resources/common/images/Tape Recorder Button - Pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/images/Tape Recorder Button - Pressed.png
--------------------------------------------------------------------------------
/resources/common/images/Tape Recorder Button Separator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/images/Tape Recorder Button Separator.png
--------------------------------------------------------------------------------
/resources/common/images/Tape Recorder Button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/images/Tape Recorder Button.png
--------------------------------------------------------------------------------
/resources/common/images/Tape Recorder Record Button - Pressed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/images/Tape Recorder Record Button - Pressed.png
--------------------------------------------------------------------------------
/resources/common/images/Tape Recorder Record Button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/common/images/Tape Recorder Record Button.png
--------------------------------------------------------------------------------
/resources/common/resources.pri:
--------------------------------------------------------------------------------
1 | RESOURCES += \
2 | $$P_RESOURCES_COMMON/images.qrc \
3 | $$P_RESOURCES_COMMON/ROMs.qrc
4 |
--------------------------------------------------------------------------------
/resources/common/shaders/GLSL-ES/Simple.fsh:
--------------------------------------------------------------------------------
1 | //#version 110
2 |
3 | uniform sampler2D texture;
4 | varying lowp vec2 texture_point;
5 |
6 | void main(void)
7 | {
8 | gl_FragColor = texture2D(texture, texture_point);
9 | }
10 |
--------------------------------------------------------------------------------
/resources/common/shaders/GLSL-ES/Simple.vsh:
--------------------------------------------------------------------------------
1 | //#version 110
2 |
3 | attribute vec2 vertex;
4 | uniform mat4 transform;
5 | varying vec2 texture_point;
6 |
7 | void main(void)
8 | {
9 | gl_Position = vec4(vertex.x, vertex.y, 0.0, 1.0) * transform;
10 | texture_point = vec2(vertex.x, -vertex.y) * vec2(0.5) + vec2(0.5);
11 | }
12 |
--------------------------------------------------------------------------------
/resources/common/shaders/GLSL/SABR.fsh:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | /* Uniforms
4 | - texture: texture sampler
5 | - textureSize: size of the texture before rendering */
6 | uniform sampler2D texture;
7 | uniform vec2 textureSize;
8 |
9 | /*
10 | Varying attributes
11 | - tc: coordinate of the texel being processed
12 | - xyp_[]_[]_[]: a packed coordinate for 3 areas within the texture
13 | */
14 | varying vec2 tc;
15 | varying vec4 xyp_1_2_3;
16 | varying vec4 xyp_5_10_15;
17 | varying vec4 xyp_6_7_8;
18 | varying vec4 xyp_9_14_9;
19 | varying vec4 xyp_11_12_13;
20 | varying vec4 xyp_16_17_18;
21 | varying vec4 xyp_21_22_23;
22 |
23 | /*
24 | Constants
25 | */
26 | /*
27 | Inequation coefficients for interpolation
28 | Equations are in the form: Ay + Bx = C
29 | 45, 30, and 60 denote the angle from x each line the cooeficient variable set builds
30 | */
31 | const vec4 Ai = vec4( 1.0, -1.0, -1.0, 1.0);
32 | const vec4 B45 = vec4( 1.0, 1.0, -1.0, -1.0);
33 | const vec4 C45 = vec4( 1.5, 0.5, -0.5, 0.5);
34 | const vec4 B30 = vec4( 0.5, 2.0, -0.5, -2.0);
35 | const vec4 C30 = vec4( 1.0, 1.0, -0.5, 0.0);
36 | const vec4 B60 = vec4( 2.0, 0.5, -2.0, -0.5);
37 | const vec4 C60 = vec4( 2.0, 0.0, -1.0, 0.5);
38 |
39 | const vec4 M45 = vec4(0.4, 0.4, 0.4, 0.4);
40 | const vec4 M30 = vec4(0.2, 0.4, 0.2, 0.4);
41 | const vec4 M60 = M30.yxwz;
42 | const vec4 Mshift = vec4(0.2);
43 |
44 | // Coefficient for weighted edge detection
45 | const float coef = 2.0;
46 |
47 | // Threshold for if luminance values are "equal"
48 | const vec4 threshold = vec4(0.32);
49 |
50 | // Conversion from RGB to Luminance (from GIMP)
51 | const vec3 lum = vec3(0.21, 0.72, 0.07);
52 |
53 |
54 | // Performs same logic operation as && for vectors
55 | bvec4 _and_(bvec4 A, bvec4 B)
56 | {return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w);}
57 |
58 |
59 | // Performs same logic operation as || for vectors
60 | bvec4 _or_(bvec4 A, bvec4 B)
61 | {return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w);}
62 |
63 |
64 | // Converts 4 3-color vectors into 1 4-value luminance vector
65 | vec4 lum_to(vec3 v0, vec3 v1, vec3 v2, vec3 v3)
66 | {return vec4(dot(lum, v0), dot(lum, v1), dot(lum, v2), dot(lum, v3));}
67 |
68 |
69 | // Gets the difference between 2 4-value luminance vectors
70 | vec4 lum_df(vec4 A, vec4 B)
71 | {return abs(A - B);}
72 |
73 |
74 | // Determines if 2 4-value luminance vectors are "equal" based on threshold
75 | bvec4 lum_eq(vec4 A, vec4 B)
76 | {return lessThan(lum_df(A, B), threshold);}
77 |
78 |
79 | vec4 lum_wd(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
80 | {return lum_df(a, b) + lum_df(a, c) + lum_df(d, e) + lum_df(d, f) + 4.0 * lum_df(g, h);}
81 |
82 |
83 | // Gets the difference between 2 3-value rgb colors
84 | float c_df(vec3 c1, vec3 c2)
85 | {
86 | vec3 df = abs(c1 - c2);
87 | return df.r + df.g + df.b;
88 | }
89 |
90 |
91 | void main()
92 | {
93 | /* Mask for algorhithm
94 | .-----------------------------.
95 | | | 1 | 2 | 3 | |
96 | |-----+-----+-----+-----+-----|
97 | | 5 | 6 | 7 | 8 | 9 |
98 | |-----+-----+-----+-----+-----|
99 | | 10 | 11 | 12 | 13 | 14 |
100 | |-----+-----+-----+-----+-----|
101 | | 15 | 16 | 17 | 18 | 19 |
102 | |-----+-----+-----+-----+-----|
103 | | | 21 | 22 | 23 | |
104 | '----------------------------*/
105 | // Get mask values by performing texture lookup with the uniform sampler
106 | vec3 P1 = texture2D(texture, xyp_1_2_3.xw ).rgb;
107 | vec3 P2 = texture2D(texture, xyp_1_2_3.yw ).rgb;
108 | vec3 P3 = texture2D(texture, xyp_1_2_3.zw ).rgb;
109 |
110 | vec3 P6 = texture2D(texture, xyp_6_7_8.xw ).rgb;
111 | vec3 P7 = texture2D(texture, xyp_6_7_8.yw ).rgb;
112 | vec3 P8 = texture2D(texture, xyp_6_7_8.zw ).rgb;
113 |
114 | vec3 P11 = texture2D(texture, xyp_11_12_13.xw).rgb;
115 | vec3 P12 = texture2D(texture, xyp_11_12_13.yw).rgb;
116 | vec3 P13 = texture2D(texture, xyp_11_12_13.zw).rgb;
117 |
118 | vec3 P16 = texture2D(texture, xyp_16_17_18.xw).rgb;
119 | vec3 P17 = texture2D(texture, xyp_16_17_18.yw).rgb;
120 | vec3 P18 = texture2D(texture, xyp_16_17_18.zw).rgb;
121 |
122 | vec3 P21 = texture2D(texture, xyp_21_22_23.xw).rgb;
123 | vec3 P22 = texture2D(texture, xyp_21_22_23.yw).rgb;
124 | vec3 P23 = texture2D(texture, xyp_21_22_23.zw).rgb;
125 |
126 | vec3 P5 = texture2D(texture, xyp_5_10_15.xy ).rgb;
127 | vec3 P10 = texture2D(texture, xyp_5_10_15.xz ).rgb;
128 | vec3 P15 = texture2D(texture, xyp_5_10_15.xw ).rgb;
129 |
130 | vec3 P9 = texture2D(texture, xyp_9_14_9.xy ).rgb;
131 | vec3 P14 = texture2D(texture, xyp_9_14_9.xz ).rgb;
132 | vec3 P19 = texture2D(texture, xyp_9_14_9.xw ).rgb;
133 |
134 | // Store luminance values of each point in groups of 4
135 | // so that we may operate on all four corners at once
136 | vec4 p7 = lum_to(P7, P11, P17, P13);
137 | vec4 p8 = lum_to(P8, P6, P16, P18);
138 | vec4 p11 = p7.yzwx; // P11, P17, P13, P7
139 | vec4 p12 = lum_to(P12, P12, P12, P12);
140 | vec4 p13 = p7.wxyz; // P13, P7, P11, P17
141 | vec4 p14 = lum_to(P14, P2, P10, P22);
142 | vec4 p16 = p8.zwxy; // P16, P18, P8, P6
143 | vec4 p17 = p7.zwxy; // P17, P13, P7, P11
144 | vec4 p18 = p8.wxyz; // P18, P8, P6, P16
145 | vec4 p19 = lum_to(P19, P3, P5, P21);
146 | vec4 p22 = p14.wxyz; // P22, P14, P2, P10
147 | vec4 p23 = lum_to(P23, P9, P1, P15);
148 |
149 | // Scale current texel coordinate to [0..1]
150 | vec2 fp = fract(tc * textureSize);
151 |
152 | // Determine amount of "smoothing" or mixing that could be done on texel corners
153 | vec4 ma45 = smoothstep(C45 - M45, C45 + M45, Ai * fp.y + B45 * fp.x);
154 | vec4 ma30 = smoothstep(C30 - M30, C30 + M30, Ai * fp.y + B30 * fp.x);
155 | vec4 ma60 = smoothstep(C60 - M60, C60 + M60, Ai * fp.y + B60 * fp.x);
156 | vec4 marn = smoothstep(C45 - M45 + Mshift, C45 + M45 + Mshift, Ai * fp.y + B45 * fp.x);
157 |
158 | // Perform edge weight calculations
159 | vec4 e45 = lum_wd(p12, p8, p16, p18, p22, p14, p17, p13);
160 | vec4 econt = lum_wd(p17, p11, p23, p13, p7, p19, p12, p18);
161 | vec4 e30 = lum_df(p13, p16);
162 | vec4 e60 = lum_df(p8, p17);
163 |
164 | // Calculate rule results for interpolation
165 | bvec4 r45_1 = _and_(notEqual(p12, p13), notEqual(p12, p17));
166 | bvec4 r45_2 = _and_(not(lum_eq(p13, p7)), not(lum_eq(p13, p8)));
167 | bvec4 r45_3 = _and_(not(lum_eq(p17, p11)), not(lum_eq(p17, p16)));
168 | bvec4 r45_4_1 = _and_(not(lum_eq(p13, p14)), not(lum_eq(p13, p19)));
169 | bvec4 r45_4_2 = _and_(not(lum_eq(p17, p22)), not(lum_eq(p17, p23)));
170 | bvec4 r45_4 = _and_(lum_eq(p12, p18), _or_(r45_4_1, r45_4_2));
171 | bvec4 r45_5 = _or_(lum_eq(p12, p16), lum_eq(p12, p8));
172 | bvec4 r45 = _and_(r45_1, _or_(_or_(_or_(r45_2, r45_3), r45_4), r45_5));
173 | bvec4 r30 = _and_(notEqual(p12, p16), notEqual(p11, p16));
174 | bvec4 r60 = _and_(notEqual(p12, p8), notEqual(p7, p8));
175 |
176 | // Combine rules with edge weights
177 | bvec4 edr45 = _and_(lessThan(e45, econt), r45);
178 | bvec4 edrrn = lessThanEqual(e45, econt);
179 | bvec4 edr30 = _and_(lessThanEqual(coef * e30, e60), r30);
180 | bvec4 edr60 = _and_(lessThanEqual(coef * e60, e30), r60);
181 |
182 | // Finalize interpolation rules and cast to float (0.0 for false, 1.0 for true)
183 | vec4 final45 = vec4(_and_(_and_(not(edr30), not(edr60)), edr45));
184 | vec4 final30 = vec4(_and_(_and_(edr45, not(edr60)), edr30));
185 | vec4 final60 = vec4(_and_(_and_(edr45, not(edr30)), edr60));
186 | vec4 final36 = vec4(_and_(_and_(edr60, edr30), edr45));
187 | vec4 finalrn = vec4(_and_(not(edr45), edrrn));
188 |
189 | // Determine the color to mix with for each corner
190 | vec4 px = step(lum_df(p12, p17), lum_df(p12, p13));
191 |
192 | // Determine the mix amounts by combining the final rule result and corresponding
193 | // mix amount for the rule in each corner
194 | vec4 mac = final36 * max(ma30, ma60) + final30 * ma30 + final60 * ma60 + final45 * ma45 + finalrn * marn;
195 |
196 | /*
197 | Calculate the resulting color by traversing clockwise and counter-clockwise around
198 | the corners of the texel
199 |
200 | Finally choose the result that has the largest difference from the texel's original
201 | color
202 | */
203 | vec3 res1 = P12;
204 | res1 = mix(res1, mix(P13, P17, px.x), mac.x);
205 | res1 = mix(res1, mix(P7, P13, px.y), mac.y);
206 | res1 = mix(res1, mix(P11, P7, px.z), mac.z);
207 | res1 = mix(res1, mix(P17, P11, px.w), mac.w);
208 |
209 | vec3 res2 = P12;
210 | res2 = mix(res2, mix(P17, P11, px.w), mac.w);
211 | res2 = mix(res2, mix(P11, P7, px.z), mac.z);
212 | res2 = mix(res2, mix(P7, P13, px.y), mac.y);
213 | res2 = mix(res2, mix(P13, P17, px.x), mac.x);
214 |
215 | gl_FragColor = vec4(mix(res1, res2, step(c_df(P12, res1), c_df(P12, res2))), 1.0);
216 | }
217 |
--------------------------------------------------------------------------------
/resources/common/shaders/GLSL/SABR.vsh:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform vec2 textureSize;
4 | uniform mat4 transform;
5 | attribute vec2 vertex;
6 |
7 | varying vec2 tc;
8 | varying vec4 xyp_1_2_3;
9 | varying vec4 xyp_5_10_15;
10 | varying vec4 xyp_6_7_8;
11 | varying vec4 xyp_9_14_9;
12 | varying vec4 xyp_11_12_13;
13 | varying vec4 xyp_16_17_18;
14 | varying vec4 xyp_21_22_23;
15 |
16 | void main()
17 | {
18 | gl_Position = transform * vec4(vertex.x, -vertex.y, 0.0, 1.0);;
19 |
20 | float x = 1.0 / textureSize.x;
21 | float y = 1.0 / textureSize.y;
22 |
23 | /* Mask for algorhithm
24 | .-----+-----+-----+-----+-----.
25 | | | 1 | 2 | 3 | |
26 | |-----+-----+-----+-----+-----|
27 | | 5 | 6 | 7 | 8 | 9 |
28 | |-----+-----+-----+-----+-----|
29 | | 10 | 11 | 12 | 13 | 14 |
30 | |-----+-----+-----+-----+-----|
31 | | 15 | 16 | 17 | 18 | 19 |
32 | |-----+-----+-----+-----+-----|
33 | | | 21 | 22 | 23 | |
34 | '----------------------------*/
35 |
36 | tc = vertex * vec2(0.5) + vec2(0.5);
37 |
38 | xyp_1_2_3 = tc.xxxy + vec4( -x, 0.0, x, -2.0 * y);
39 | xyp_6_7_8 = tc.xxxy + vec4( -x, 0.0, x, -y);
40 | xyp_11_12_13 = tc.xxxy + vec4( -x, 0.0, x, 0.0);
41 | xyp_16_17_18 = tc.xxxy + vec4( -x, 0.0, x, y);
42 | xyp_21_22_23 = tc.xxxy + vec4( -x, 0.0, x, 2.0 * y);
43 | xyp_5_10_15 = tc.xyyy + vec4(-2.0 * x, -y, 0.0, y);
44 | xyp_9_14_9 = tc.xyyy + vec4( 2.0 * x, -y, 0.0, y);
45 | }
46 |
--------------------------------------------------------------------------------
/resources/common/shaders/GLSL/Simple.fsh:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform sampler2D texture;
4 | varying vec2 texture_point;
5 |
6 | void main(void)
7 | {
8 | gl_FragColor = texture2D(texture, texture_point);
9 | }
10 |
--------------------------------------------------------------------------------
/resources/common/shaders/GLSL/Simple.vsh:
--------------------------------------------------------------------------------
1 | #version 110
2 |
3 | uniform mat4 transform;
4 | varying vec2 texture_point;
5 |
6 | void main(void)
7 | {
8 | gl_Position = gl_Vertex * transform;
9 | texture_point = vec2(gl_Vertex.x, -gl_Vertex.y) * vec2(0.5) + vec2(0.5);
10 | }
11 |
--------------------------------------------------------------------------------
/resources/iOS/UI/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/resources/iOS/UI/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/resources/iOS/UI/MachineView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/resources/iOS/images/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/resources/iOS/images/Joystick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/resources/iOS/images/Joystick.png
--------------------------------------------------------------------------------
/resources/iOS/property lists/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.redcode.iOS.mZX
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 | UIViewControllerBasedStatusBarAppearance
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/screenshots/Avenger In Game.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Avenger In Game.png
--------------------------------------------------------------------------------
/screenshots/Avenger Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Avenger Loading.png
--------------------------------------------------------------------------------
/screenshots/Batman In Game.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Batman In Game.png
--------------------------------------------------------------------------------
/screenshots/Batman Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Batman Loading.png
--------------------------------------------------------------------------------
/screenshots/Black Lamp Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Black Lamp Loading.png
--------------------------------------------------------------------------------
/screenshots/Hydrofool In Game.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Hydrofool In Game.png
--------------------------------------------------------------------------------
/screenshots/Hydrofool Loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Hydrofool Loading.png
--------------------------------------------------------------------------------
/screenshots/Z Moire Run.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Z Moire Run.png
--------------------------------------------------------------------------------
/screenshots/Z Moire Source.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/Z Moire Source.png
--------------------------------------------------------------------------------
/screenshots/ZX Spectrum + 128K Spanish.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/ZX Spectrum + 128K Spanish.png
--------------------------------------------------------------------------------
/screenshots/ZX Spectrum + 128K.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/screenshots/ZX Spectrum + 128K.png
--------------------------------------------------------------------------------
/sources/Linux/ALSAAudioOutputPlayer.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Linux/ALSAAudioOutputPlayer.c
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include "system.h"
8 | #include
9 | #include "ALSAAudioOutputPlayer.hpp"
10 |
11 | #define FRAME_SIZE Z_INT16_SIZE * 882
12 |
13 |
14 | void ALSAAudioOutputPlayer::main()
15 | {
16 | while (_buffer.fill_count < 2)
17 | z_wait(1000000000 / 50 + 1000000000 / 100);
18 |
19 | while (!_must_stop)
20 | {
21 | if (_buffer.fill_count < 2)
22 | snd_pcm_writei(_device, _buffer.consumption_buffer(), 882);
23 |
24 | else {
25 | while (_buffer.fill_count > 3)
26 | _buffer.try_consume();
27 |
28 | snd_pcm_writei(_device, _buffer.consumption_buffer(), 882);
29 | _buffer.try_consume();
30 | }
31 | }
32 | }
33 |
34 |
35 | ALSAAudioOutputPlayer::ALSAAudioOutputPlayer() : _device(NULL), playing(false)
36 | {
37 | void *frames = calloc(1, FRAME_SIZE * 4);
38 | _buffer.initialize(frames, Z_INT16_SIZE * 882, 4);
39 | }
40 |
41 |
42 | ALSAAudioOutputPlayer::~ALSAAudioOutputPlayer()
43 | {free(_buffer.buffers);}
44 |
45 |
46 | void ALSAAudioOutputPlayer::start()
47 | {
48 | if (!playing)
49 | {
50 | void *parameters;
51 | snd_pcm_t *device;
52 | unsigned int rate = 44100;
53 | snd_pcm_uframes_t size = 882 * 2 * 2;
54 |
55 | int error = snd_pcm_open(&device, "default", SND_PCM_STREAM_PLAYBACK, 0);
56 |
57 | /*----------------------------------------.
58 | | Configure device's hardware parameters. |
59 | '----------------------------------------*/
60 | snd_pcm_hw_params_malloc((snd_pcm_hw_params_t **)¶meters);
61 | snd_pcm_hw_params_any(device, (snd_pcm_hw_params_t *)parameters);
62 | snd_pcm_hw_params_set_access(device, (snd_pcm_hw_params_t *)parameters, SND_PCM_ACCESS_RW_INTERLEAVED);
63 | snd_pcm_hw_params_set_format(device, (snd_pcm_hw_params_t *)parameters, SND_PCM_FORMAT_S16_LE);
64 | snd_pcm_hw_params_set_rate_near(device, (snd_pcm_hw_params_t *)parameters, &rate, (int *)NULL);
65 | snd_pcm_hw_params_set_channels(device, (snd_pcm_hw_params_t *)parameters, 1);
66 | snd_pcm_hw_params_set_buffer_size_near(device, (snd_pcm_hw_params_t *)parameters, &size);
67 | size = 882 * 2;
68 | snd_pcm_hw_params_set_period_size(device, (snd_pcm_hw_params_t *)parameters, size, 0);
69 | snd_pcm_hw_params(device, (snd_pcm_hw_params_t *)parameters);
70 | snd_pcm_hw_params_free((snd_pcm_hw_params_t *)parameters);
71 |
72 | /*----------------------------------------.
73 | | Configure device's software parameters. |
74 | '----------------------------------------*/
75 | snd_pcm_sw_params_malloc((snd_pcm_sw_params_t **)¶meters);
76 | snd_pcm_sw_params_current(device, (snd_pcm_sw_params_t *)parameters);
77 | snd_pcm_sw_params_set_start_threshold(device, (snd_pcm_sw_params_t *)parameters, 882);
78 | snd_pcm_sw_params_set_avail_min(device, (snd_pcm_sw_params_t *)parameters, 882);
79 | //snd_pcm_sw_params_set_avail_max(device, parameters, size);
80 | snd_pcm_sw_params(device, (snd_pcm_sw_params_t *)parameters);
81 | snd_pcm_sw_params_free((snd_pcm_sw_params_t *)parameters);
82 |
83 | snd_pcm_prepare(device);
84 |
85 | _device = device;
86 | _must_stop = FALSE;
87 | playing = TRUE;
88 | _thread = std::thread(&ALSAAudioOutputPlayer::main, this);
89 | }
90 | }
91 |
92 |
93 | void ALSAAudioOutputPlayer::stop()
94 | {
95 | if (playing)
96 | {
97 | _must_stop = TRUE;
98 | _thread.join();
99 | playing = FALSE;
100 | snd_pcm_close(_device);
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/sources/Linux/ALSAAudioOutputPlayer.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Linux/ALSAAudioOutputPlayer.hpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_Linux_ALSAAudioOutputPlayer_HPP
8 | #define __mZX_Linux_ALSAAudioOutputPlayer_HPP
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #if Z_CPP < Z_CPP11
15 | # error "C++11 is needed."
16 | #endif
17 |
18 | class ALSAAudioOutputPlayer {
19 | private:
20 | std::thread _thread;
21 | snd_pcm_t* _device;
22 | Zeta::RingBuffer _buffer;
23 | volatile Zeta::Boolean _must_stop;
24 |
25 | public:
26 | Zeta::Boolean playing;
27 |
28 | ALSAAudioOutputPlayer();
29 | ~ALSAAudioOutputPlayer();
30 | Zeta::RingBuffer *buffer() {return &_buffer;}
31 | void start();
32 | void stop();
33 |
34 | private:
35 | void main();
36 | };
37 |
38 | #endif // __mZX_Linux_ALSAAudioOutputPlayer_HPP
39 |
--------------------------------------------------------------------------------
/sources/Linux/Linux.pri:
--------------------------------------------------------------------------------
1 |
2 | SOURCES += \
3 | $$P_SOURCES/Linux/ALSAAudioOutputPlayer.cpp \
4 |
5 | HEADERS += \
6 | $$P_SOURCES/Linux/ALSAAudioOutputPlayer.hpp \
7 |
--------------------------------------------------------------------------------
/sources/OS X & iOS/CoreAudioOutputPlayer.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/CoreAudioOutputPlayer.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "CoreAudioOutputPlayer.hpp"
8 | #import
9 | #import
10 | #import "system.h"
11 | #import
12 |
13 | using namespace Zeta;
14 |
15 |
16 | static OSStatus FillBuffer(
17 | RingBuffer* buffer,
18 | AudioUnitRenderActionFlags* ioActionFlags,
19 | const AudioTimeStamp* inTimeStamp,
20 | UInt32 inBusNumber,
21 | UInt32 inNumberFrames,
22 | AudioBufferList* ioData
23 | )
24 | {
25 | if (buffer->fill_count < 2)
26 | {
27 | ioData->mBuffers[0].mData = buffer->consumption_buffer();
28 | return noErr;
29 | }
30 |
31 | while (buffer->fill_count > 3) buffer->try_consume();
32 | ioData->mBuffers[0].mData = buffer->consumption_buffer();
33 | buffer->try_consume();
34 | return noErr;
35 | }
36 |
37 |
38 | CoreAudioOutputPlayer::CoreAudioOutputPlayer()
39 | : _sample_rate(44100), _buffer_frame_count(2)
40 | {
41 | void *buffer = calloc(1, Z_INT16_SIZE * 882 * 4);
42 | _buffer.initialize(buffer, Z_INT16_SIZE * 882, 4);
43 |
44 | //---------------------------------------------------------------------------.
45 | // Configure the search parameters to find the default playback output unit. |
46 | //---------------------------------------------------------------------------'
47 | AudioComponentDescription output_description = {
48 | .componentType = kAudioUnitType_Output,
49 |
50 | # if Z_OS == Z_OS_MAC_OS_X
51 | .componentSubType = kAudioUnitSubType_DefaultOutput,
52 | # elif Z_OS == Z_OS_IOS
53 | .componentSubType = kAudioUnitSubType_GenericOutput,
54 | # endif
55 |
56 | .componentManufacturer = kAudioUnitManufacturer_Apple,
57 | .componentFlags = 0,
58 | .componentFlagsMask = 0
59 | };
60 |
61 | //---------------------------------------.
62 | // Get the default playback output unit. |
63 | //---------------------------------------'
64 | AudioComponent output = AudioComponentFindNext(NULL, &output_description);
65 | //NSAssert(output, @"Can't find default output");
66 |
67 | //------------------------------------------------------------.
68 | // Create a new unit based on this that we'll use for output. |
69 | //------------------------------------------------------------'
70 | OSErr error = AudioComponentInstanceNew(output, &_audio_unit);
71 | //NSAssert1(_toneUnit, @"Error creating unit: %hd", error);
72 |
73 | // Set our tone rendering function on the unit
74 | AURenderCallbackStruct input;
75 | input.inputProc = (decltype(input.inputProc))FillBuffer;
76 | input.inputProcRefCon = &_buffer;
77 |
78 | error = AudioUnitSetProperty
79 | (_audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,
80 | 0, &input, sizeof(input));
81 |
82 | //NSAssert1(error == noErr, @"Error setting callback: %hd", error);
83 |
84 | UInt32 frames = 882;
85 | // Set the max frames
86 |
87 | error = AudioUnitSetProperty
88 | (_audio_unit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global,
89 | 0, &frames, sizeof(frames));
90 |
91 | //NSAssert1(error == noErr, @"Error setting maximum frames per slice: %hd", error);
92 |
93 | // Set the buffer size
94 | # if Z_OS == Z_OS_MAC_OS_X
95 | error = AudioUnitSetProperty
96 | (_audio_unit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global,
97 | 0, &frames, sizeof(frames));
98 | # endif
99 |
100 | //NSAssert1(error == noErr, @"Error setting buffer frame size: %hd", error);
101 |
102 | //----------------------------------------------------.
103 | // Set the format to 16-bit little-endian lineal PCM. |
104 | //----------------------------------------------------'
105 | AudioStreamBasicDescription streamFormat = {
106 | .mSampleRate = _sample_rate,
107 | .mFormatID = kAudioFormatLinearPCM,
108 | .mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked,
109 | .mBytesPerPacket = 2,
110 | .mFramesPerPacket = 1,
111 | .mBytesPerFrame = 2,
112 | .mChannelsPerFrame = 1,
113 | .mBitsPerChannel = 16,
114 | .mReserved = 0
115 | };
116 |
117 | error = AudioUnitSetProperty
118 | (_audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input,
119 | 0, &streamFormat, sizeof(AudioStreamBasicDescription));
120 |
121 | //NSAssert1(error == noErr, @"Error setting stream format: %hd", error);
122 |
123 | error = AudioUnitInitialize(_audio_unit);
124 | //NSAssert1(error == noErr, @"Error initializing unit: %hd", error);
125 | }
126 |
127 |
128 | CoreAudioOutputPlayer::~CoreAudioOutputPlayer()
129 | {
130 | playing = false;
131 | AudioOutputUnitStop(_audio_unit);
132 | AudioUnitUninitialize(_audio_unit);
133 | }
134 |
135 |
136 | void CoreAudioOutputPlayer::start()
137 | {
138 | playing = true;
139 | OSErr error = AudioOutputUnitStart(_audio_unit);
140 |
141 | //NSAssert1(error == noErr, @"Error starting unit: %hd", error);
142 | }
143 |
144 |
145 | void CoreAudioOutputPlayer::stop()
146 | {
147 | AudioOutputUnitStop(_audio_unit);
148 | }
149 |
--------------------------------------------------------------------------------
/sources/OS X & iOS/CoreAudioOutputPlayer.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/CoreAudioOutputPlayer.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 | #import
9 |
10 | class CoreAudioOutputPlayer {
11 | private:
12 | AudioComponentInstance _audio_unit;
13 | Zeta::RingBuffer _buffer;
14 | zuint _buffer_frame_count;
15 | double _sample_rate;
16 |
17 | public:
18 | Zeta::Boolean playing;
19 |
20 | CoreAudioOutputPlayer();
21 | ~CoreAudioOutputPlayer();
22 | Zeta::RingBuffer *buffer() {return &_buffer;}
23 | void start();
24 | void stop();
25 | };
26 |
--------------------------------------------------------------------------------
/sources/OS X & iOS/GLVideoView.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/GLVideoOutputView.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "GLFrameBufferRenderer.hpp"
8 |
9 | #if Z_OS == Z_OS_MAC_OS_X
10 | # import
11 | #elif Z_OS == Z_OS_IOS
12 | # import
13 | #endif
14 |
15 | @interface GLVideoView :
16 |
17 | # if Z_OS == Z_OS_MAC_OS_X
18 |
19 | NSView {NSOpenGLContext* _GLContext;
20 | CGLContextObj _CGLContext;
21 | NSOpenGLPixelFormat* _pixelFormat;
22 |
23 | # elif Z_OS == Z_OS_IOS
24 |
25 | UIView {CAEAGLLayer* _EAGLLayer;
26 | EAGLContext* _GLContext;
27 | GLuint _renderBuffer;
28 | # endif
29 |
30 | GLFrameBufferRenderer* _renderer;
31 |
32 | struct {BOOL reshaped :1;
33 | BOOL active :1;
34 | BOOL blank :1;
35 | } _flags;
36 | }
37 | @property (nonatomic, readonly) Zeta::TripleBuffer* buffer;
38 | @property (nonatomic, assign) Zeta::Value2D contentSize;
39 | @property (nonatomic, assign) ZKey(SCALING) scaling;
40 |
41 | - (void) setResolution: (Zeta::Value2D) resolution
42 | format: (Zeta::UInt ) format;
43 |
44 | - (void) start;
45 |
46 | - (void) stop;
47 |
48 | - (void) blank;
49 |
50 | - (void) setLinearInterpolation: (BOOL) value;
51 | @end
52 |
--------------------------------------------------------------------------------
/sources/OS X/KeyCodes.h:
--------------------------------------------------------------------------------
1 | #ifndef Spectra_KeyCodes_h
2 | #define Spectra_KeyCodes_h
3 |
4 | /*
5 | * Summary:
6 | * Virtual keycodes
7 | *
8 | * Discussion:
9 | * These constants are the virtual keycodes defined originally in
10 | * Inside Mac Volume V, pg. V-191. They identify physical keys on a
11 | * keyboard. Those constants with "ANSI" in the name are labeled
12 | * according to the key position on an ANSI-standard US keyboard.
13 | * For example, kVK_ANSI_A indicates the virtual keycode for the key
14 | * with the letter 'A' in the US keyboard layout. Other keyboard
15 | * layouts may have the 'A' key label on a different physical key;
16 | * in this case, pressing 'A' will generate a different virtual
17 | * keycode.
18 | */
19 |
20 | #define kVK_ANSI_A 0x00
21 | #define kVK_ANSI_S 0x01
22 | #define kVK_ANSI_D 0x02
23 | #define kVK_ANSI_F 0x03
24 | #define kVK_ANSI_H 0x04
25 | #define kVK_ANSI_G 0x05
26 | #define kVK_ANSI_Z 0x06
27 | #define kVK_ANSI_X 0x07
28 | #define kVK_ANSI_C 0x08
29 | #define kVK_ANSI_V 0x09
30 | #define kVK_ANSI_B 0x0B
31 | #define kVK_ANSI_Q 0x0C
32 | #define kVK_ANSI_W 0x0D
33 | #define kVK_ANSI_E 0x0E
34 | #define kVK_ANSI_R 0x0F
35 | #define kVK_ANSI_Y 0x10
36 | #define kVK_ANSI_T 0x11
37 | #define kVK_ANSI_1 0x12
38 | #define kVK_ANSI_2 0x13
39 | #define kVK_ANSI_3 0x14
40 | #define kVK_ANSI_4 0x15
41 | #define kVK_ANSI_6 0x16
42 | #define kVK_ANSI_5 0x17
43 | #define kVK_ANSI_Equal 0x18
44 | #define kVK_ANSI_9 0x19
45 | #define kVK_ANSI_7 0x1A
46 | #define kVK_ANSI_Minus 0x1B
47 | #define kVK_ANSI_8 0x1C
48 | #define kVK_ANSI_0 0x1D
49 | #define kVK_ANSI_RightBracket 0x1E
50 | #define kVK_ANSI_O 0x1F
51 | #define kVK_ANSI_U 0x20
52 | #define kVK_ANSI_LeftBracket 0x21
53 | #define kVK_ANSI_I 0x22
54 | #define kVK_ANSI_P 0x23
55 | #define kVK_ANSI_L 0x25
56 | #define kVK_ANSI_J 0x26
57 | #define kVK_ANSI_Quote 0x27
58 | #define kVK_ANSI_K 0x28
59 | #define kVK_ANSI_Semicolon 0x29
60 | #define kVK_ANSI_Backslash 0x2A
61 | #define kVK_ANSI_Comma 0x2B
62 | #define kVK_ANSI_Slash 0x2C
63 | #define kVK_ANSI_N 0x2D
64 | #define kVK_ANSI_M 0x2E
65 | #define kVK_ANSI_Period 0x2F
66 | #define kVK_ANSI_Grave 0x32
67 | #define kVK_ANSI_KeypadDecimal 0x41
68 | #define kVK_ANSI_KeypadMultiply 0x43
69 | #define kVK_ANSI_KeypadPlus 0x45
70 | #define kVK_ANSI_KeypadClear 0x47
71 | #define kVK_ANSI_KeypadDivide 0x4B
72 | #define kVK_ANSI_KeypadEnter 0x4C
73 | #define kVK_ANSI_KeypadMinus 0x4E
74 | #define kVK_ANSI_KeypadEquals 0x51
75 | #define kVK_ANSI_Keypad0 0x52
76 | #define kVK_ANSI_Keypad1 0x53
77 | #define kVK_ANSI_Keypad2 0x54
78 | #define kVK_ANSI_Keypad3 0x55
79 | #define kVK_ANSI_Keypad4 0x56
80 | #define kVK_ANSI_Keypad5 0x57
81 | #define kVK_ANSI_Keypad6 0x58
82 | #define kVK_ANSI_Keypad7 0x59
83 | #define kVK_ANSI_Keypad8 0x5B
84 | #define kVK_ANSI_Keypad9 0x5C
85 |
86 |
87 | /* keycodes for keys that are independent of keyboard layout*/
88 |
89 | #define kVK_Return 0x24
90 | #define kVK_Tab 0x30
91 | #define kVK_Space 0x31
92 | #define kVK_Delete 0x33
93 | #define kVK_Escape 0x35
94 | #define kVK_Command 0x37
95 | #define kVK_Shift 0x38
96 | #define kVK_CapsLock 0x39
97 | #define kVK_Option 0x3A
98 | #define kVK_Control 0x3B
99 | #define kVK_RightShift 0x3C
100 | #define kVK_RightOption 0x3D
101 | #define kVK_RightControl 0x3E
102 | #define kVK_Function 0x3F
103 | #define kVK_F17 0x40
104 | #define kVK_VolumeUp 0x48
105 | #define kVK_VolumeDown 0x49
106 | #define kVK_Mute 0x4A
107 | #define kVK_F18 0x4F
108 | #define kVK_F19 0x50
109 | #define kVK_F20 0x5A
110 | #define kVK_F5 0x60
111 | #define kVK_F6 0x61
112 | #define kVK_F7 0x62
113 | #define kVK_F3 0x63
114 | #define kVK_F8 0x64
115 | #define kVK_F9 0x65
116 | #define kVK_F11 0x67
117 | #define kVK_F13 0x69
118 | #define kVK_F16 0x6A
119 | #define kVK_F14 0x6B
120 | #define kVK_F10 0x6D
121 | #define kVK_F12 0x6F
122 | #define kVK_F15 0x71
123 | #define kVK_Help 0x72
124 | #define kVK_Home 0x73
125 | #define kVK_PageUp 0x74
126 | #define kVK_ForwardDelete 0x75
127 | #define kVK_F4 0x76
128 | #define kVK_End 0x77
129 | #define kVK_F2 0x78
130 | #define kVK_PageDown 0x79
131 | #define kVK_F1 0x7A
132 | #define kVK_LeftArrow 0x7B
133 | #define kVK_RightArrow 0x7C
134 | #define kVK_DownArrow 0x7D
135 | #define kVK_UpArrow 0x7E
136 |
137 | /* ISO keyboards only*/
138 |
139 | #define kVK_ISO_Section 0x0A
140 |
141 | /* JIS keyboards only*/
142 |
143 | #define kVK_JIS_Yen 0x5D
144 | #define kVK_JIS_Underscore 0x5E
145 | #define kVK_JIS_KeypadComma 0x5F
146 | #define kVK_JIS_Eisu 0x66
147 | #define kVK_JIS_Kana 0x68
148 |
149 | #endif
150 |
--------------------------------------------------------------------------------
/sources/OS X/KeyboardWindowController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/KeyboardWindowController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | @interface KeyboardWindowController : NSWindowController
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/sources/OS X/KeyboardWindowController.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/KeyboardWindowController.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "KeyboardWindowController.h"
8 |
9 |
10 | @implementation KeyboardWindowController
11 |
12 |
13 | - (id) init
14 | {
15 | if ((self = [super initWithWindowNibName: @"KeyboardWindow"]))
16 | {
17 | }
18 |
19 | return self;
20 | }
21 |
22 |
23 | - (void) windowDidLoad
24 | {
25 | [super windowDidLoad];
26 | }
27 |
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/sources/OS X/MachineWindowController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/MachineWindowController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "Machine.hpp"
8 | #import "GLVideoView.h"
9 | #import "CoreAudioOutputPlayer.hpp"
10 | #import "TapeRecorderWindowController.h"
11 | #import "SNA.h"
12 |
13 | @interface MachineWindowController : NSWindowController {
14 |
15 | //-------------.
16 | // XIB objects |
17 | //-------------'
18 | IBOutlet NSWindow* titleWindow;
19 | IBOutlet NSTextField* titleTextField;
20 |
21 | @public
22 |
23 | //-----------.
24 | // Emulation |
25 | //-----------'
26 | Machine* _machine;
27 |
28 | //----------.
29 | // Geometry |
30 | //----------'
31 | Zeta::Value2D _minimumWindowSize;
32 |
33 | //-------------.
34 | // I/O Buffers |
35 | //-------------'
36 | Zeta::TripleBuffer* _keyboardBuffer;
37 | Z64Bit* _keyboard;
38 | Z64Bit _keyboardState;
39 |
40 | BOOL _smooth;
41 | GLVideoView* _videoOutputView;
42 | CoreAudioOutputPlayer* _audioOutputPlayer;
43 | BOOL _keyboardInput;
44 | Zeta::RingBuffer _audioInputBuffer;
45 |
46 | NSTimer* _pointerVisibilityTimer;
47 | NSTrackingArea* _trackingArea;
48 |
49 | //--------.
50 | // Panels |
51 | //--------'
52 | //KeyboardWindowController* _keyboardWindowController;
53 | //DebuggerWindowController* _debuggerWindowController;
54 | TapeRecorderWindowController* _tapeRecorderWindowController;
55 |
56 | struct {BOOL isFullScreen :1;
57 | BOOL ignoreKeyboardInput :1;
58 | } _flags;
59 |
60 | // Temporal
61 | Zeta::Size _tapeSampleCount;
62 | Zeta::UInt8* _tapeSamples;
63 | BOOL _attachInputBuffer;
64 | }
65 | - (id) initWithMachineABI: (MachineABI *) machineABI;
66 |
67 | //--------------------.
68 | // Main Menu: Machine |
69 | //--------------------'
70 | - (IBAction) togglePower: (id) sender;
71 | - (IBAction) togglePause: (id) sender;
72 | - (IBAction) reset: (id) sender;
73 | - (IBAction) saveState: (id) sender;
74 | - (IBAction) restoreState: (id) sender;
75 | - (IBAction) showStates: (id) sender;
76 | - (IBAction) toggleVSync: (id) sender;
77 | - (IBAction) setFrameSkip: (id) sender;
78 |
79 | //-----------------.
80 | // Main Menu: Edit |
81 | //-----------------'
82 | - (IBAction) copy: (id) sender;
83 |
84 | //-----------------.
85 | // Main Menu: View |
86 | //-----------------'
87 | - (IBAction) zoomIn: (id) sender;
88 | - (IBAction) zoomOut: (id) sender;
89 | - (IBAction) zoomToFit: (id) sender;
90 | - (IBAction) zoomTo1x: (id) sender;
91 | - (IBAction) zoomTo2x: (id) sender;
92 | - (IBAction) zoomTo3x: (id) sender;
93 | - (IBAction) toggleSmooth: (id) sender;
94 | - (IBAction) toggleKeyboardShown: (id) sender;
95 | - (IBAction) toggleTapeRecorderShown: (id) sender;
96 | - (IBAction) toggleDebuggerShown: (id) sender;
97 | - (IBAction) toggleCPUShown: (id) sender;
98 | - (IBAction) toggleULAShown: (id) sender;
99 | - (IBAction) togglePSGShown: (id) sender;
100 |
101 | //-------------------.
102 | // Main Menu: Window |
103 | //-------------------'
104 | - (IBAction) editWindowTitle: (id) sender;
105 | @end
106 |
--------------------------------------------------------------------------------
/sources/OS X/MainController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/MainController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "PreferencesWindowController.h"
8 |
9 | @interface MainController : NSObject {
10 | IBOutlet NSMenu* machinesMenu;
11 |
12 | PreferencesWindowController* _preferencesWindowController;
13 | NSMutableArray* _machineWindowControllers;
14 | }
15 | - (IBAction) preferences: (id) sender;
16 | - (IBAction) newDefaultMachine: (id) sender;
17 | - (IBAction) newMachine: (id) sender;
18 | @end
19 |
--------------------------------------------------------------------------------
/sources/OS X/MainController.mm:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/MainController.mm
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "MainController.h"
8 | #import "MachineWindowController.h"
9 | #import "MachineABI.h"
10 |
11 |
12 | @implementation MainController
13 |
14 |
15 | # pragma mark - Helpers
16 |
17 |
18 | - (void) newMachineWithABI: (MachineABI *) ABI
19 | {
20 | MachineWindowController *controller = [[MachineWindowController alloc] initWithMachineABI: ABI];
21 |
22 | [_machineWindowControllers addObject: controller];
23 | [controller release];
24 |
25 | NSWindow *window = controller.window;
26 |
27 | [[NSNotificationCenter defaultCenter]
28 | addObserver: self
29 | selector: @selector(windowWillClose:)
30 | name: NSWindowWillCloseNotification
31 | object: window];
32 |
33 | [window makeKeyAndOrderFront: self];
34 | }
35 |
36 |
37 | # pragma mark - NSApplicationDelegate
38 |
39 |
40 | - (void) applicationDidFinishLaunching: (NSNotification *) aNotification
41 | {
42 | _machineWindowControllers = [[NSMutableArray alloc] init];
43 |
44 | NSUInteger i = 0;
45 |
46 | for (; i < machine_abi_count; i++) [machinesMenu
47 | addItemWithTitle: [NSString stringWithUTF8String: machine_abi_table[i].model_name]
48 | action: @selector(newMachine:)
49 | keyEquivalent: @""];
50 |
51 | [self newDefaultMachine: nil];
52 | }
53 |
54 |
55 | - (void) applicationWillTerminate: (NSNotification *) notification
56 | {
57 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
58 |
59 | [notificationCenter
60 | removeObserver: self
61 | name: NSWindowDidBecomeMainNotification
62 | object: nil];
63 |
64 | [_machineWindowControllers release];
65 | }
66 |
67 |
68 | # pragma mark - Callbacks
69 |
70 |
71 | - (void) windowWillClose: (NSNotification *) notification
72 | {
73 | NSWindow *window = notification.object;
74 | MachineWindowController *controller = window.windowController;
75 |
76 | [[NSNotificationCenter defaultCenter]
77 | removeObserver: self
78 | name: NSWindowWillCloseNotification
79 | object: window];
80 |
81 | if ([controller isKindOfClass: MachineWindowController.class])
82 | [_machineWindowControllers removeObject: controller];
83 |
84 | else {
85 | [_preferencesWindowController release];
86 | _preferencesWindowController = nil;
87 | }
88 | }
89 |
90 |
91 | # pragma mark - IBAction
92 |
93 |
94 | - (IBAction) preferences: (id) sender
95 | {
96 | if (!_preferencesWindowController)
97 | {
98 | NSWindow *window = (_preferencesWindowController = [[PreferencesWindowController alloc] init]).window;
99 |
100 | [[NSNotificationCenter defaultCenter]
101 | addObserver: self
102 | selector: @selector(windowWillClose:)
103 | name: NSWindowWillCloseNotification
104 | object: window];
105 |
106 | [window makeKeyAndOrderFront: self];
107 | }
108 |
109 | else [_preferencesWindowController.window makeKeyAndOrderFront: self];
110 | }
111 |
112 |
113 | - (IBAction) openDocument: (id) sender
114 | {
115 | /*NSOpenPanel *panel = [NSOpenPanel openPanel];
116 |
117 | panel.allowedFileTypes = [NSArray arrayWithObjects: @"z80", @"sna", nil];
118 |
119 | if ([panel runModal] == NSFileHandlingPanelOKButton)
120 | {
121 | NSString *path = panel.URL.path;
122 | NSError *error;
123 | }*/
124 | }
125 |
126 |
127 | - (IBAction) newDefaultMachine: (NSMenuItem *) sender
128 | {[self newMachineWithABI: &machine_abi_table[4]];}
129 |
130 |
131 | - (IBAction) newMachine: (NSMenuItem *) sender
132 | {[self newMachineWithABI: &machine_abi_table[[machinesMenu.itemArray indexOfObject: sender]]];}
133 |
134 |
135 | @end
136 |
--------------------------------------------------------------------------------
/sources/OS X/PreferencesWindowController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/PreferencesWindowController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | @interface PreferencesWindowController : NSWindowController
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/sources/OS X/PreferencesWindowController.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/PreferencesWindowController.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "PreferencesWindowController.h"
8 |
9 |
10 | @implementation PreferencesWindowController
11 |
12 |
13 | - (id) init
14 | {
15 | if ((self = [super initWithWindowNibName: @"PreferencesWindow"]))
16 | {
17 | }
18 |
19 | return self;
20 | }
21 |
22 |
23 | - (void) windowDidLoad
24 | {
25 | [super windowDidLoad];
26 | }
27 |
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/sources/OS X/Prefix.pch:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/Prefix.pch
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #define CPU_Z80_USE_LOCAL_HEADER
8 |
9 | #ifdef __OBJC__
10 | # define Z_SUPPORT_NS_GEOMETRY
11 | # define STRING(...) [NSString stringWithFormat: __VA_ARGS__]
12 | # define _(string) NSLocalizedString(@string, nil)
13 | #endif
14 |
--------------------------------------------------------------------------------
/sources/OS X/TapeRecorderWindow.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/TapeRecorderWindow.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | @interface TapeRecorderWindow : NSWindow
10 |
11 | @end
12 |
13 |
14 | @protocol TapeRecorderWindowDelegate
15 |
16 | - (void) tapeRecorderWindow: (TapeRecorderWindow *) tapeRecorderWindow
17 | didReceiveDragForFileAtPath: (NSString *) path;
18 |
19 | @end
20 |
21 |
--------------------------------------------------------------------------------
/sources/OS X/TapeRecorderWindow.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/TapeRecorderWindow.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "TapeRecorderWindow.h"
8 |
9 | @implementation TapeRecorderWindow
10 |
11 |
12 | - (NSDragOperation) draggingEntered: (id ) sender
13 | {
14 | return [[[sender draggingPasteboard] types] containsObject: NSFilenamesPboardType]
15 | ? NSDragOperationGeneric
16 | : NSDragOperationNone;
17 | }
18 |
19 |
20 | - (BOOL) performDragOperation: (id ) sender
21 | {
22 | NSPasteboard *pboard;
23 | NSDragOperation sourceDragMask;
24 |
25 | sourceDragMask = [sender draggingSourceOperationMask];
26 | pboard = [sender draggingPasteboard];
27 |
28 | if ([[pboard types] containsObject: NSFilenamesPboardType])
29 | {
30 | NSArray *files = [pboard propertyListForType: NSFilenamesPboardType];
31 |
32 | [(id )self.delegate
33 | tapeRecorderWindow: self
34 | didReceiveDragForFileAtPath: [files objectAtIndex: 0]
35 | ];
36 | }
37 |
38 | return YES;
39 | }
40 |
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/sources/OS X/TapeRecorderWindowController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/TapeRecorderWindowController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "TapeRecorderWindow.h"
8 | #import "CoreAudioOutputPlayer.hpp"
9 | #import
10 | #import
11 |
12 | typedef struct {
13 | } AudioIOCB;
14 |
15 | typedef struct {
16 | zsize (* test_data) (void* data);
17 |
18 | zsize (* object_size_for_data) (void* data);
19 |
20 | zsize (* set_cb) (void* object,
21 | AudioIOCB* cb);
22 |
23 | zsize (* sample_count) (void* object);
24 |
25 | zsize (* read) (void* object,
26 | zsize sample_count,
27 | void* output);
28 |
29 | } AudioIOABI;
30 |
31 | typedef struct {
32 | void* buffer;
33 | void* samples;
34 | zsize sample_count;
35 | zsize frame_size;
36 | zsize frame_count;
37 | zsize frame_index;
38 | IMP output_method;
39 | SEL output_selector;
40 | id output;
41 | } TapeRecorder;
42 |
43 | @interface TapeRecorderWindowController : NSWindowController {
44 | IBOutlet NSView* contentView;
45 | IBOutlet NSImageView* tapeView;
46 |
47 | TapeRecorder _tapeRecorder;
48 | NSString* _filePath;
49 | NSTimer* _timer;
50 | BOOL _playing;
51 | pthread_t _thread;
52 | }
53 | - (void) setFrameSize: (zsize) frameSize
54 | count: (zsize) count;
55 |
56 | - (void) addOutput: (id) output
57 | action: (SEL) action;
58 |
59 | - (void) removeOutput: (id) output;
60 |
61 | - (IBAction) eject: (id) sender;
62 | - (IBAction) play: (id) sender;
63 | - (IBAction) record: (id) sender;
64 | - (IBAction) rewindToPreviousBlock: (id) sender;
65 | - (IBAction) rewind: (id) sender;
66 | - (IBAction) windForward: (id) sender;
67 | - (IBAction) windForwardToNextBlock: (id) sender;
68 | @end
69 |
--------------------------------------------------------------------------------
/sources/OS X/TapeRecorderWindowController.mm:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/TapeRecorderWindowController.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "TapeRecorderWindowController.h"
8 | #import
9 | #import
10 | #import
11 |
12 | using namespace Zeta;
13 |
14 | void tape_recorder_play_frame(TapeRecorder *object)
15 | {
16 | //object->output_method(object->output, object->output_selector, object->samples + object->frame_size * object->frame_index);
17 | object->frame_index++;
18 | }
19 |
20 |
21 | void *tape_recorder_play(TapeRecorder *object)
22 | {
23 | return NULL;
24 | }
25 |
26 |
27 |
28 |
29 | @implementation TapeRecorderWindowController
30 |
31 |
32 | # pragma mark - Helpers
33 |
34 |
35 | - (void) loadTapeAtPath: (NSString *) path
36 | {
37 | NSFileManager *fileManager = [NSFileManager defaultManager];
38 |
39 | if ([fileManager fileExistsAtPath: path])
40 | {
41 | NSData *data = [NSData dataWithContentsOfFile: path];
42 | _tapeRecorder.sample_count = [data length];
43 | _tapeRecorder.samples = malloc([data length] * 2);
44 | memcpy(_tapeRecorder.samples, [data bytes], _tapeRecorder.sample_count);
45 | memset((UInt8 *)_tapeRecorder.samples + _tapeRecorder.sample_count, 0x70, _tapeRecorder.sample_count);
46 | _filePath = [path retain];
47 | [tapeView setHidden: NO];
48 | }
49 | }
50 |
51 | - (void) playFrame
52 | {
53 | ((void (*)(id,SEL, zuint8 *))_tapeRecorder.output_method)(_tapeRecorder.output, _tapeRecorder.output_selector, (UInt8 *)_tapeRecorder.samples + _tapeRecorder.frame_size * _tapeRecorder.frame_index);
54 | _tapeRecorder.frame_index++;
55 | //NSLog(@"playFrame");
56 | }
57 |
58 |
59 | - (void) startPlayThread
60 | {
61 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
62 |
63 | _timer = [NSTimer
64 | scheduledTimerWithTimeInterval: 1.0 / 50.0
65 | target: self
66 | selector: @selector(playFrame)
67 | userInfo: nil
68 | repeats: YES];
69 |
70 | [[NSRunLoop currentRunLoop]
71 | addTimer: _timer
72 | forMode: NSDefaultRunLoopMode];
73 |
74 | [[NSRunLoop currentRunLoop] run];
75 |
76 | NSLog(@"runloop stoped");
77 |
78 | [pool drain];
79 | }
80 |
81 |
82 | - (void) stopPlayThread
83 | {
84 | [_timer invalidate];
85 | _timer = nil;
86 | CFRunLoopStop([[NSRunLoop currentRunLoop] getCFRunLoop]);
87 | }
88 |
89 |
90 | # pragma mark - TapeRecorderWindowDelegate Protocol
91 |
92 |
93 | - (void) tapeRecorderWindow: (TapeRecorderWindow *) tapeRecorderWindow
94 | didReceiveDragForFileAtPath: (NSString *) path
95 | {
96 | [self loadTapeAtPath: path];
97 | }
98 |
99 |
100 | # pragma mark - NSWindowDelegate
101 |
102 |
103 | # pragma mark - Public
104 |
105 |
106 | - (id) init
107 | {
108 | if ((self = [super initWithWindowNibName: @"TapeRecorderWindow"]))
109 | {
110 | NSSize contentSize = contentView.bounds.size;
111 | // NSWindow *window = [[DevicePanel alloc] initWithContentRect: NSMakeRect(100.0, 100.0, contentSize.width, contentSize.height)];
112 |
113 | // window.contentView = contentView;
114 | // [window orderFront: self];
115 | }
116 |
117 | return self;
118 | }
119 |
120 |
121 | - (void) dealloc
122 | {
123 | /* [_timer invalidate];
124 | if (_samples != NULL) free(_samples);
125 | [_filePath release];*/
126 | [super dealloc];
127 | }
128 |
129 |
130 | - (void) windowDidLoad
131 | {
132 | [super windowDidLoad];
133 | [self.window registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
134 | }
135 |
136 |
137 | - (void) setFrameSize: (zsize) frameSize
138 | count: (zsize) frameCount
139 | {
140 | if (_tapeRecorder.buffer != NULL) free(_tapeRecorder.buffer);
141 | _tapeRecorder.buffer = malloc(Z_UINT8_SIZE * frameSize * frameCount);
142 |
143 | _tapeRecorder.frame_count = frameCount;
144 | _tapeRecorder.frame_size = frameSize;
145 | }
146 |
147 |
148 | - (void) addOutput: (id) output
149 | action: (SEL) action
150 | {
151 | _tapeRecorder.output = output;
152 | _tapeRecorder.output_method = [output methodForSelector: _tapeRecorder.output_selector = action];
153 | }
154 |
155 |
156 | - (void) removeOutput: (id) output
157 | {
158 | }
159 |
160 |
161 | # pragma mark - IBAction
162 |
163 |
164 | - (IBAction) eject: (id) sender
165 | {
166 | if (_tapeRecorder.samples)
167 | {
168 | [tapeView setHidden: YES];
169 | free(_tapeRecorder.samples);
170 | _tapeRecorder.samples = NULL;
171 | [_filePath release];
172 | _filePath = nil;
173 | }
174 |
175 | else {
176 | NSOpenPanel *panel = [NSOpenPanel openPanel];
177 |
178 | panel.allowedFileTypes = [NSArray arrayWithObjects: @"wav", @"raw", @"au", @"voc", nil];
179 |
180 | if ([panel runModal] == NSFileHandlingPanelOKButton)
181 | [self loadTapeAtPath: panel.URL.path];
182 | }
183 | }
184 |
185 |
186 | - (IBAction) play: (id) sender
187 | {
188 | if (_playing)
189 | {
190 | //[self performSelector: @selector(stopPlayThread) onThread: _thread withObject: nil waitUntilDone: YES];
191 | _playing = NO;
192 | }
193 |
194 | else {
195 | _playing = YES;
196 | _tapeRecorder.frame_index = 0;
197 | //pthread_create(&_thread, NULL, (void *(*)(void *))tape_recorder_play, &_tapeRecorder);
198 | [NSThread detachNewThreadSelector: @selector(startPlayThread) toTarget: self withObject: nil];
199 | }
200 | }
201 |
202 |
203 | - (IBAction) record: (id) sender
204 | {
205 | }
206 |
207 |
208 | - (IBAction) rewindToPreviousBlock: (id) sender
209 | {
210 | }
211 |
212 |
213 | - (IBAction) rewind: (id) sender
214 | {
215 | }
216 |
217 |
218 | - (IBAction) windForward: (id) sender
219 | {
220 | }
221 |
222 |
223 | - (IBAction) windForwardToNextBlock: (id) sender
224 | {
225 | }
226 |
227 |
228 | @end
229 |
--------------------------------------------------------------------------------
/sources/OS X/Window.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/Window.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | @interface Window : NSWindow @end
10 |
--------------------------------------------------------------------------------
/sources/OS X/Window.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/Window.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "Window.h"
8 |
9 |
10 | @implementation Window
11 |
12 |
13 | - (BOOL) isMovableByWindowBackground
14 | {return YES;}
15 |
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/sources/OS X/extensions/NSView+RedCode.h:
--------------------------------------------------------------------------------
1 | /* NSView - RedCode Software Extensions
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2013 RedCode Software. All rights reserved. */
7 |
8 | #import
9 |
10 | @interface NSView (RedCode)
11 |
12 | - (NSRect) frameInScreen;
13 |
14 | - (NSImage *) imageCapture;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/sources/OS X/extensions/NSView+RedCode.m:
--------------------------------------------------------------------------------
1 | /* NSView - RedCode Software Extensions
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2013 RedCode Software. All rights reserved. */
7 |
8 | #import "NSView+RedCode.h"
9 |
10 |
11 | @implementation NSView (RedCode)
12 |
13 |
14 | - (NSRect) frameInScreen
15 | {
16 | NSRect frame = [self convertRect: self.bounds toView: nil];
17 |
18 | frame.origin = [self.window convertBaseToScreen: frame.origin];
19 | return frame;
20 | }
21 |
22 |
23 | - (NSImage *) imageCapture
24 | {
25 | NSImage *image;
26 | NSRect bounds = self.bounds;
27 | NSBitmapImageRep *bitmap = [self bitmapImageRepForCachingDisplayInRect: bounds];
28 |
29 | bitmap.size = bounds.size;
30 | [self cacheDisplayInRect: bounds toBitmapImageRep: bitmap];
31 | image = [[NSImage alloc] initWithSize: bounds.size];
32 | [image addRepresentation: bitmap];
33 | return [image autorelease];
34 | }
35 |
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/sources/OS X/extensions/NSWindow+RedCode.h:
--------------------------------------------------------------------------------
1 | /* NSWindow - RedCode Software Extensions
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2013 RedCode Software. All rights reserved. */
7 |
8 | #import
9 |
10 | @interface NSWindow (RedCode)
11 |
12 | @property (nonatomic, readonly) NSSize borderSize;
13 | @property (nonatomic, readonly) CGFloat toolbarHeight;
14 |
15 | - (void) replaceContentViewWithView: (NSView *) view
16 | animate: (BOOL) animate;
17 |
18 | - (void) animateIntoScreenFrame: (NSRect) screenFrame
19 | fromTopCenterToSize: (NSSize) size;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/sources/OS X/extensions/NSWindow+RedCode.m:
--------------------------------------------------------------------------------
1 | /* NSWindow - RedCode Software Extensions
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2013 RedCode Software. All rights reserved. */
7 |
8 | #import "NSWindow+RedCode.h"
9 |
10 |
11 | @implementation NSWindow (RedCode)
12 |
13 |
14 | - (NSSize) borderSize
15 | {
16 | NSSize frameSize = self.frame.size;
17 | NSSize contentSize = ((NSView *)self.contentView).bounds.size;
18 |
19 | return NSMakeSize(frameSize.width - contentSize.width, frameSize.height - contentSize.height);
20 | }
21 |
22 |
23 | - (CGFloat) toolbarHeight
24 | {
25 | NSToolbar *toolbar = self.toolbar;
26 | CGFloat toolbarHeight = 0.0;
27 | NSRect windowFrame;
28 |
29 | if (toolbar && [toolbar isVisible])
30 | {
31 | windowFrame = [NSWindow contentRectForFrameRect: self.frame styleMask: self.styleMask];
32 | toolbarHeight = NSHeight(windowFrame) - NSHeight(((NSView *)self.contentView).frame);
33 | }
34 |
35 | return toolbarHeight;
36 | }
37 |
38 |
39 | - (void) replaceContentViewWithView: (NSView *) view
40 | animate: (BOOL) animate
41 | {
42 | if (view != self.contentView)
43 | {
44 | NSRect frame = self.frame;;
45 | NSRect contentFrame = ((NSView *)self.contentView).frame;
46 | NSRect viewFrame = view.frame;
47 |
48 | viewFrame.origin.y = 0.0;
49 | view.frame = viewFrame;
50 | [self setContentView: view];
51 |
52 | frame.origin.y = frame.origin.y + contentFrame.size.height - viewFrame.size.height;
53 | frame.size = viewFrame.size;
54 |
55 | [self setContentView: view];
56 |
57 | [self setFrame: [self frameRectForContentRect: frame]
58 | display: YES
59 | animate: self.isVisible ? animate : NO
60 | ];
61 | }
62 | }
63 |
64 |
65 | - (void) animateIntoScreenFrame: (NSRect) screenFrame
66 | fromTopCenterToSize: (NSSize) size
67 | {
68 | NSRect oldFrame = self.frame;
69 |
70 | NSRect newFrame = NSMakeRect
71 | (floor(oldFrame.origin.x + oldFrame.size.width / 2.0 - size.width / 2.0),
72 | floor(oldFrame.origin.y + oldFrame.size.height - size.height),
73 | size.width, size.height);
74 |
75 | if (!NSContainsRect(screenFrame, newFrame))
76 | {
77 | if (newFrame.origin.x < screenFrame.origin.x)
78 | newFrame.origin.x = screenFrame.origin.x;
79 |
80 | else if (NSMaxX(newFrame) > NSMaxX(screenFrame))
81 | newFrame.origin.x = screenFrame.origin.x + screenFrame.size.width - size.width;
82 |
83 | if (newFrame.origin.y < screenFrame.origin.y)
84 | newFrame.origin.y = screenFrame.origin.y;
85 |
86 | else if (NSMaxY(newFrame) > NSMaxY(screenFrame))
87 | newFrame.origin.y = screenFrame.origin.y + screenFrame.size.height - size.height;
88 | }
89 |
90 | BOOL visible = self.isVisible;
91 | [self setFrame: newFrame display: visible animate: visible];
92 | }
93 |
94 |
95 | @end
96 |
--------------------------------------------------------------------------------
/sources/OS X/main.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/main.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | int main(int argc, const char **argv)
10 | {return NSApplicationMain(argc, argv);}
11 |
--------------------------------------------------------------------------------
/sources/Qt/AboutDialog.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/AboutDialog.cpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include "AboutDialog.hpp"
8 | #include "ui_AboutDialog.h"
9 | #include
10 |
11 |
12 |
13 | AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog)
14 | {
15 | ui->setupUi(this);
16 | setWindowFlags(Qt::Dialog);
17 | setFixedSize(width(), height());
18 | setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
19 | this->setStyleSheet("QToolButton {border:none; color:#0000ff;} QToolButton:hover {text-decoration:underline;}");
20 | ui->compilationTimeLabel->setText("Compiled on " __DATE__ " " __TIME__ " UTC with " Z_COMPILER_STRING " v" Z_COMPILER_VERSION_STRING);
21 | }
22 |
23 |
24 | AboutDialog::~AboutDialog()
25 | {
26 | delete ui;
27 | }
28 |
29 |
30 | // Qt/AboutDialog.cpp EOF
31 |
--------------------------------------------------------------------------------
/sources/Qt/AboutDialog.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/AboutDialog.hpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_Qt_AboutDialog_HPP
8 | #define __mZX_Qt_AboutDialog_HPP
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class AboutDialog;
14 | }
15 |
16 | class AboutDialog : public QDialog {Q_OBJECT
17 | public:
18 | explicit AboutDialog(QWidget *parent = 0);
19 | ~AboutDialog();
20 |
21 | private:
22 | Ui::AboutDialog *ui;
23 | };
24 |
25 | #endif // __mZX_Qt_AboutDialog_HPP
26 |
--------------------------------------------------------------------------------
/sources/Qt/GLVideoOutputView.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/GLVideoOutputView.cpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include "GLVideoOutputView.hpp"
8 | #include
9 | #include
10 | #include
11 | #include "system.h"
12 | #include
13 |
14 | #define BOUNDS Rectangle(0.0, 0.0, Real(this->width()), Real(this->height()))
15 |
16 | using namespace Zeta;
17 |
18 |
19 | GLVideoOutputView::GLVideoOutputView(QWidget *parent) : QGLWidget(parent)
20 | {
21 | active = false;
22 | timer = new QTimer();
23 |
24 | makeCurrent();
25 | videoOutput = new GLVideoOutput();
26 | videoOutput->set_geometry(BOUNDS, Z_SCALING_FIT);
27 | doneCurrent();
28 | }
29 |
30 |
31 | GLVideoOutputView::~GLVideoOutputView()
32 | {
33 | stop();
34 | delete videoOutput;
35 | }
36 |
37 |
38 | void GLVideoOutputView::initializeGL()
39 | {
40 | //QGLFormat format(QGL::SampleBuffers);
41 | //format.setSwapInterval(1); // vsync
42 | //setFormat(format);
43 | }
44 |
45 |
46 | void GLVideoOutputView::paintGL()
47 | {videoOutput->draw(FALSE);}
48 |
49 |
50 | void GLVideoOutputView::resizeGL(int width, int height)
51 | {videoOutput->set_geometry(Rectangle(0.0, 0.0, width, height), Z_SCALING_SAME);}
52 |
53 |
54 | int GLVideoOutputView::heightForWidth(int width) const
55 | {return width;}
56 |
57 |
58 | Value2D GLVideoOutputView::contentSize()
59 | {return videoOutput->content_bounds.size;}
60 |
61 |
62 | void GLVideoOutputView::setContentSize(Value2D contentSize)
63 | {
64 | makeCurrent();
65 | videoOutput->set_content_size(contentSize);
66 | doneCurrent();
67 | }
68 |
69 |
70 | void GLVideoOutputView::setScaling(ZKey(SCALING) scaling)
71 | {
72 | makeCurrent();
73 | videoOutput->set_geometry(BOUNDS, scaling);
74 | doneCurrent();
75 | }
76 |
77 |
78 | void GLVideoOutputView::setResolutionAndFormat(Value2D resolution, UInt format)
79 | {
80 | Q_UNUSED(format);
81 | makeCurrent();
82 | videoOutput->set_resolution(resolution);
83 | doneCurrent();
84 | }
85 |
86 |
87 | void GLVideoOutputView::start()
88 | {
89 | if (!active)
90 | {
91 | active = TRUE;
92 | timer = new QTimer();
93 | timer->setInterval(1000 / 60);
94 | connect(timer, SIGNAL(timeout()), this, SLOT(updateGL()));
95 | timer->start();
96 | }
97 | }
98 |
99 |
100 | void GLVideoOutputView::stop()
101 | {
102 | if (active)
103 | {
104 | timer->stop();
105 | delete timer;
106 | active = FALSE;
107 | }
108 | }
109 |
110 |
111 | void GLVideoOutputView::blank()
112 | {
113 | if (!active)
114 | {
115 | memset(videoOutput->buffer.buffers[0], 0, videoOutput->input_height * videoOutput->input_width * 4 * 3);
116 | updateGL();
117 | }
118 | }
119 |
120 |
121 | void GLVideoOutputView::setLinearInterpolation(bool enabled)
122 | {
123 | makeCurrent();
124 | videoOutput->set_linear_interpolation(enabled);
125 | doneCurrent();
126 | }
127 |
128 |
129 | // Qt/GLVideoOutputView.cpp EOF
130 |
--------------------------------------------------------------------------------
/sources/Qt/GLVideoOutputView.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/GLVideoOutputView.hpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_Qt_GLVideoOutputView_HPP
8 | #define __mZX_Qt_GLVideoOutputView_HPP
9 |
10 | #include
11 | #include
12 | #include "GLVideoOutput.hpp"
13 | #include
14 |
15 | class GLVideoOutputView : public QGLWidget {Q_OBJECT
16 | private:
17 | QTimer* timer;
18 | GLVideoOutput* videoOutput;
19 | bool active;
20 |
21 | public:
22 | explicit GLVideoOutputView(QWidget *parent = 0);
23 | ~GLVideoOutputView();
24 | void initializeGL();
25 | void paintGL();
26 | void resizeGL(int width, int height);
27 | int heightForWidth(int width) const;
28 | static void drawActiveViews();
29 | Zeta::TripleBuffer *buffer() {return &videoOutput->buffer;}
30 | Zeta::Value2D contentSize();
31 | void setContentSize(Zeta::Value2D content_size);
32 | void setScaling(ZKey(SCALING) scaling);
33 | void setResolutionAndFormat(Zeta::Value2D resolution, Zeta::UInt format);
34 | void start();
35 | void stop();
36 | void blank();
37 | void setLinearInterpolation(bool enabled);
38 | };
39 |
40 | #endif // __mZX_Qt_GLVideoOutputView_HPP
41 |
--------------------------------------------------------------------------------
/sources/Qt/MachineWindow.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/MachineWindow.hpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_Qt_MachineWindow_HPP
8 | #define __mZX_Qt_MachineWindow_HPP
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "Machine.hpp"
15 | #include "ALSAAudioOutputPlayer.hpp"
16 |
17 | namespace Ui {class MachineWindow;}
18 |
19 | class MachineWindow : public QMainWindow {Q_OBJECT
20 | public:
21 | explicit MachineWindow(QWidget *parent = 0);
22 | ~MachineWindow();
23 | void emulateMachine();
24 |
25 | private:
26 | Ui::MachineWindow* ui;
27 | ALSAAudioOutputPlayer* audioOutputPlayer;
28 | Machine* machine;
29 | void* memory;
30 | pthread_t thread;
31 | Zeta::TripleBuffer* keyboardBuffer;
32 | Z64Bit* keyboard;
33 | Z64Bit keyboardState;
34 | QFrame* fullScreenMenuFrame;
35 | volatile bool mustStop;
36 |
37 | struct {bool running :1;
38 | } flags;
39 |
40 | void runMachine();
41 | void stopMachine();
42 | Zeta::Real currentZoom();
43 | void setZoom(Zeta::Real);
44 |
45 | protected:
46 | void keyPressEvent (QKeyEvent*);
47 | void keyReleaseEvent (QKeyEvent*);
48 | void mouseDoubleClickEvent (QMouseEvent*);
49 | void resizeEvent (QResizeEvent *);
50 |
51 | private slots:
52 | void aboutDialogClosed();
53 | void on_actionFileNewWindow_triggered();
54 | void on_actionFileOpen_triggered();
55 | void on_actionFileQuit_triggered();
56 | void on_actionMachinePower_toggled(bool);
57 | void on_actionMachinePause_toggled(bool);
58 | void on_actionMachineReset_triggered();
59 | void on_actionViewFullScreen_toggled(bool);
60 | void on_actionViewZoomIn_triggered();
61 | void on_actionViewZoomOut_triggered();
62 | void on_actionView1x_triggered();
63 | void on_actionView2x_triggered();
64 | void on_actionView3x_triggered();
65 | void on_actionViewSmooth_toggled(bool);
66 | void on_actionWindowEditTitle_triggered();
67 | void on_actionHelpAbout_triggered();
68 | void on_actionHelpAboutQt_triggered();
69 | };
70 |
71 | #endif // __mZX_Qt_MachineWindow_HPP
72 |
--------------------------------------------------------------------------------
/sources/Qt/MainWindow.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/MainWindow.cpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 |
8 | #include "MainWindow.hpp"
9 | #include "ui_MainWindow.h"
10 |
11 | MainWindow::MainWindow(QWidget *parent) :
12 | QMainWindow(parent),
13 | ui(new Ui::MainWindow)
14 | {
15 | ui->setupUi(this);
16 | }
17 |
18 | MainWindow::~MainWindow()
19 | {
20 | delete ui;
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/sources/Qt/MainWindow.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/MainWindow.hpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef MAINWINDOW_HPP
8 | #define MAINWINDOW_HPP
9 |
10 | #include
11 |
12 | namespace Ui {
13 | class MainWindow;
14 | }
15 |
16 | class MainWindow : public QMainWindow
17 | {
18 | Q_OBJECT
19 |
20 | public:
21 | explicit MainWindow(QWidget *parent = 0);
22 | ~MainWindow();
23 |
24 | private:
25 | Ui::MainWindow *ui;
26 | };
27 |
28 | #endif // MAINWINDOW_HPP
29 |
--------------------------------------------------------------------------------
/sources/Qt/Qt.pri:
--------------------------------------------------------------------------------
1 |
2 | SOURCES += \
3 | $$P_SOURCES/Qt/main.cpp \
4 | $$P_SOURCES/Qt/GLVideoOutputView.cpp \
5 | $$P_SOURCES/Qt/MachineWindow.cpp \
6 | $$P_SOURCES/Qt/MainWindow.cpp \
7 | $$P_SOURCES/Qt/AboutDialog.cpp \
8 |
9 | HEADERS += \
10 | $$P_SOURCES/Qt/GLVideoOutputView.hpp \
11 | $$P_SOURCES/Qt/MachineWindow.hpp \
12 | $$P_SOURCES/Qt/MainWindow.hpp \
13 | $$P_SOURCES/Qt/AboutDialog.hpp \
14 |
--------------------------------------------------------------------------------
/sources/Qt/main.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / Qt/main.cpp
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include "MainWindow.hpp"
8 | #include "MachineWindow.hpp"
9 | #include
10 | #include
11 |
12 |
13 | int main(int argc, char **argv)
14 | {
15 | XInitThreads();
16 | QApplication application(argc, argv);
17 | MachineWindow window;
18 | window.show();
19 |
20 | return application.exec();
21 | }
22 |
--------------------------------------------------------------------------------
/sources/common/GLFrameBufferRenderer.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / common/GLFrameBufferRenderer.c
3 | | | |_/ /__> < Copyright © 2014-2016 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include "GLFrameBufferRenderer.hpp"
8 | #include
9 | #include
10 | #include
11 |
12 | using namespace Zeta;
13 | using namespace std;
14 |
15 | static GLfloat const vertices[] = {-1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f};
16 |
17 |
18 | GLFrameBufferRenderer::GLFrameBufferRenderer()
19 | : _vertex_shader(0), _fragment_shader(0), _shader_program(0), content_scaling(Z_SCALING_FIT)
20 | {
21 | buffer.buffers[0] = nullptr;
22 |
23 | glEnable(GL_TEXTURE_2D);
24 | //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
25 | glGenTextures(1, &_texture);
26 | glBindTexture(GL_TEXTURE_2D, _texture);
27 | glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
28 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
29 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
30 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
31 | //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
32 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Nedded?
33 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Nedded?
34 | glDisable(GL_TEXTURE_2D);
35 |
36 | glGenBuffers(1, &_vbo);
37 | glBindBuffer(GL_ARRAY_BUFFER, _vbo);
38 | glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 2 * 4, vertices, GL_STATIC_DRAW);
39 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * 2, 0);
40 | }
41 |
42 |
43 | GLFrameBufferRenderer::~GLFrameBufferRenderer()
44 | {
45 | if (_shader_program ) glDeleteProgram(_shader_program );
46 | if (_vertex_shader ) glDeleteShader (_vertex_shader );
47 | if (_fragment_shader) glDeleteShader (_fragment_shader);
48 | glDeleteTextures(1, &_texture);
49 | free(buffer.buffers[0]);
50 | }
51 |
52 |
53 | void GLFrameBufferRenderer::set_resolution(Value2D resolution)
54 | {
55 | Size frame_buffer_size = resolution.inner_product() * sizeof(UInt32);
56 |
57 | buffer.initialize
58 | (buffer.buffers[0] = realloc(buffer.buffers[0], frame_buffer_size * 3),
59 | frame_buffer_size);
60 |
61 | glEnable(GL_TEXTURE_2D);
62 |
63 | glTexImage2D
64 | (GL_TEXTURE_2D, 0, GL_RGBA,
65 | input_width = GLsizei(resolution.x),
66 | input_height = GLsizei(resolution.y),
67 | 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
68 |
69 | glDisable(GL_TEXTURE_2D);
70 | }
71 |
72 |
73 | void GLFrameBufferRenderer::set_content_bounds(Rectangle bounds)
74 | {
75 | content_bounds = bounds;
76 |
77 | // glMatrixMode(GL_MODELVIEW);
78 | // glLoadIdentity();
79 |
80 | _transform = Matrix4x4::translation
81 | (-1.0f + (bounds.point.x + bounds.size.x / 2.0f) / viewport.size.x * 2.0f,
82 | -1.0f + (bounds.point.y + bounds.size.y / 2.0f) / viewport.size.y * 2.0f);
83 |
84 | /*glScalef(bounds.size.x / viewport.size.x,
85 | bounds.size.y / viewport.size.y,
86 | 1.0f);*/
87 |
88 | // glGetFloatv(GL_MODELVIEW_MATRIX, _transform);
89 | }
90 |
91 |
92 | void GLFrameBufferRenderer::set_content_size(Value2D size)
93 | {
94 | content_bounds = Rectangle(viewport.size - size / 2.0, size);
95 |
96 | _transform = _transform = Matrix4x4::scaling
97 | (content_bounds.size.x / viewport.size.x,
98 | content_bounds.size.y / viewport.size.y);
99 | }
100 |
101 |
102 | void GLFrameBufferRenderer::set_geometry(Rectangle viewport, ZKey(SCALING) content_scaling)
103 | {
104 | this->viewport = viewport;
105 | glViewport(viewport.point.x, viewport.point.y, viewport.size.x, viewport.size.y);
106 |
107 | switch (content_scaling ? (this->content_scaling = content_scaling) : this->content_scaling)
108 | {
109 | case Z_SCALING_FIT:
110 | set_content_size(Value2D(input_width, input_height).fit(viewport.size));
111 | break;
112 |
113 | case Z_SCALING_NONE:
114 | set_content_bounds(content_bounds);
115 | break;
116 |
117 | case Z_SCALING_EXPAND:
118 | _transform.set_identity();
119 | //_transform = _transform.translated(1.0, 1.0);
120 | break;
121 | }
122 | }
123 |
124 |
125 | void GLFrameBufferRenderer::set_linear_interpolation(Boolean value)
126 | {
127 | GLint filter = value ? GL_LINEAR : GL_NEAREST;
128 |
129 | glBindTexture(GL_TEXTURE_2D, _texture);
130 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
131 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
132 | }
133 |
134 |
135 | void GLFrameBufferRenderer::draw(Boolean skip_old)
136 | {
137 | void *frame = buffer.consume();
138 |
139 | if (!frame)
140 | {
141 | if (skip_old) return;
142 | frame = buffer.consumption_buffer();
143 | }
144 |
145 | /*for (Size x = 0; x < input_width * input_height; x++)
146 | {
147 | ((UInt32 *)frame)[x] = 0x1F32FFFF;
148 | }*/
149 |
150 | glEnable(GL_TEXTURE_2D);
151 |
152 | if (content_scaling != Z_SCALING_EXPAND)
153 | {
154 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
155 | glClear(GL_COLOR_BUFFER_BIT);
156 | }
157 |
158 | glTexSubImage2D
159 | (GL_TEXTURE_2D, 0, 0, 0,
160 | input_width, input_height,
161 | GL_RGBA, GL_UNSIGNED_BYTE, frame);
162 |
163 | //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
164 | glBindTexture(GL_TEXTURE_2D, _texture);
165 | glUniformMatrix4fv(_transform_uniform, 1, GL_FALSE, _transform.m);
166 |
167 | # ifdef OPEN_GL
168 | glEnableVertexAttribArray(0);
169 | # else
170 | glBindBuffer(GL_ARRAY_BUFFER, _vbo);
171 | glVertexAttribPointer(_vertex_attribute, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);
172 | glEnableVertexAttribArray(_vertex_attribute);
173 | # endif
174 |
175 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
176 | glDisable(GL_TEXTURE_2D);
177 |
178 | # if Z_OS != Z_OS_IOS
179 | glFlush();
180 | # endif
181 | }
182 |
183 |
184 | Boolean GLFrameBufferRenderer::set_vertex_shader(Character *source_code, string **error_log)
185 | {
186 | if (_vertex_shader) glDeleteShader(_vertex_shader);
187 | return !!(_vertex_shader = compile_shader(source_code, GL_VERTEX_SHADER, error_log));
188 | }
189 |
190 |
191 | Boolean GLFrameBufferRenderer::set_fragment_shader(Character *source_code, string **error_log)
192 | {
193 | if (_fragment_shader) glDeleteShader(_fragment_shader);
194 | return !!(_fragment_shader = compile_shader(source_code, GL_FRAGMENT_SHADER, error_log));
195 | }
196 |
197 |
198 | void GLFrameBufferRenderer::create_shader_program()
199 | {
200 | _shader_program = glCreateProgram();
201 |
202 | glAttachShader(_shader_program, _vertex_shader );
203 | glAttachShader(_shader_program, _fragment_shader);
204 | glLinkProgram (_shader_program);
205 | glUseProgram (_shader_program);
206 |
207 | _transform_uniform = glGetUniformLocation(_shader_program, "transform");
208 |
209 | # ifdef OPEN_GL_ES
210 | _vertex_attribute = glGetAttribLocation(_shader_program, "vertex");
211 | # endif
212 | }
213 |
214 |
215 | void GLFrameBufferRenderer::destroy_shader_program()
216 | {
217 | glDetachShader(_shader_program, _fragment_shader);
218 | glDetachShader(_shader_program, _vertex_shader);
219 | glDeleteProgram(_shader_program);
220 | _shader_program = 0;
221 | }
222 |
223 |
224 | /* GLFrameBufferRenderer.c EOF */
225 |
--------------------------------------------------------------------------------
/sources/common/GLFrameBufferRenderer.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / common/GLFrameBufferRenderer.h
3 | | | |_/ /__> < Copyright © 2014-2016 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_common_GLFrameBufferRenderer_HPP
8 | #define __mZX_common_GLFrameBufferRenderer_HPP
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include "OpenGL.hpp"
15 | #include "Matrix.hpp"
16 |
17 | class GLFrameBufferRenderer {
18 | private:
19 | Zeta::Matrix4x4 _transform;
20 | GLuint _texture;
21 | GLuint _vbo;
22 | GLuint _vertex_shader;
23 | GLuint _fragment_shader;
24 | GLuint _shader_program;
25 | GLuint _index_buffer_id;
26 | GLuint _transform_uniform;
27 |
28 | # ifdef OPEN_GL_ES
29 | GLuint _vertex_attribute;
30 | # endif
31 |
32 | //GLuint _texture_size_uniform_id;
33 |
34 | public:
35 | GLsizei input_width;
36 | GLsizei input_height;
37 | Zeta::TripleBuffer buffer;
38 | Zeta::Rectangle viewport;
39 | Zeta::Rectangle content_bounds;
40 | ZKey(SCALING) content_scaling;
41 |
42 | GLFrameBufferRenderer();
43 | ~GLFrameBufferRenderer();
44 |
45 | void set_resolution(Zeta::Value2D resolution);
46 | void set_content_bounds(Zeta::Rectangle bounds);
47 | void set_content_size(Zeta::Value2D size);
48 | void set_geometry(Zeta::Rectangle viewport, ZKey(SCALING) content_scaling);
49 | void draw(Zeta::Boolean skip_old);
50 | void set_linear_interpolation(Zeta::Boolean value);
51 | Zeta::Boolean set_vertex_shader(Zeta::Character *source_code, std::string **error_log);
52 | Zeta::Boolean set_fragment_shader(Zeta::Character *source_code, std::string **error_log);
53 | void create_shader_program();
54 | void destroy_shader_program();
55 | };
56 |
57 | #endif // __mZX_common_GLFrameBufferRenderer_HPP
58 |
--------------------------------------------------------------------------------
/sources/common/Machine.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / common/Machine.c
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include
8 | #include
9 | #include
10 | #include "Machine.hpp"
11 | #include "system.h"
12 | #include "Z80.h"
13 |
14 | using namespace Zeta;
15 |
16 | /*--------------------------------.
17 | | Emulation thread main function. |
18 | '--------------------------------*/
19 | void Machine::main()
20 | {
21 | UInt64 frames_per_second = 50;
22 | UInt64 frame_ticks = 1000000000 / frames_per_second;
23 | UInt64 next_frame_tick = z_ticks();
24 | UInt64 delta;
25 | UInt maximum_frameskip = 5;
26 | UInt loops;
27 | void* buffer;
28 | UInt64* keyboard;
29 |
30 | while (!_must_stop)
31 | {
32 | loops = 0;
33 |
34 | do abi->run_1_frame(context);
35 | while ((next_frame_tick += frame_ticks) < z_ticks() && ++loops < maximum_frameskip);
36 |
37 | //-----------------.
38 | // Produce output. |
39 | //-----------------'
40 | if ((buffer = _audio_output->try_produce()) != NULL)
41 | context->audio_output_buffer = (Int16 *)buffer;
42 |
43 | context->video_output_buffer = _video_output->produce();
44 |
45 | //----------------.
46 | // Consume input. |
47 | //----------------'
48 | if ((keyboard = (UInt64 *)_keyboard_input->consume()) != NULL)
49 | {context->state.keyboard.value_uint64 = *keyboard;}
50 |
51 | # if Z_OS == Z_OS_MAC_OS_X
52 | if (_audio_input)
53 | {
54 | while (!(buffer = _audio_input->try_consume()))
55 | {
56 | //printf("skip");
57 | next_frame_tick += frame_ticks / 4;
58 | z_wait(frame_ticks / 4);
59 | }
60 |
61 | context->audio_input_buffer = (UInt8 *)buffer;
62 | }
63 | # endif
64 |
65 | //----------------------------------------.
66 | // Schedule next iteration time and wait. |
67 | //----------------------------------------'
68 | if ((delta = next_frame_tick - z_ticks()) <= frame_ticks) z_wait(delta);
69 | //else printf("delta => %lu, next => %lu\n", delta, next_frame_tick);
70 | }
71 | }
72 |
73 |
74 | void Machine::start()
75 | {
76 | _must_stop = FALSE;
77 | _thread = std::thread(&Machine::main, this);
78 | }
79 |
80 |
81 | void Machine::stop()
82 | {
83 | _must_stop = TRUE;
84 | _thread.join();
85 | }
86 |
87 |
88 | Machine::Machine(MachineABI *abi, TripleBuffer *video_output, RingBuffer *audio_output, TripleBuffer *keyboard_input)
89 | : _video_output(video_output), _audio_output(audio_output), abi(abi), _keyboard_input(keyboard_input)
90 | {
91 | # if Z_OS != Z_OS_LINUX
92 | _audio_input = NULL;
93 | # endif
94 | flags.power = OFF;
95 | flags.pause = OFF;
96 |
97 | /*--------------------------------------.
98 | | Create the machine and its components |
99 | '--------------------------------------*/
100 | context = (ZXSpectrum *)malloc(abi->context_size);
101 | context->cpu_abi.run = (ZEmulatorRun )z80_run;
102 | context->cpu_abi.irq = (ZContextSwitch)z80_int;
103 | context->cpu_abi.reset = (ZContextDo )z80_reset;
104 | context->cpu_abi.power = (ZEmulatorPower)z80_power;
105 | context->cpu = (Z80 *)malloc(sizeof(Z80));
106 | context->cpu_cycles = &context->cpu->cycles;
107 | context->memory = (UInt8 *)calloc(1, abi->memory_size);
108 | context->video_output_buffer = video_output->production_buffer();
109 | context->audio_output_buffer = (Int16 *)audio_output->production_buffer();
110 | abi->initialize(context);
111 | }
112 |
113 |
114 | Machine::~Machine()
115 | {
116 | free(context->memory);
117 | free(context->cpu);
118 | }
119 |
120 |
121 | void machine_run_one_frame(Machine *object)
122 | {
123 | }
124 |
125 |
126 | void Machine::power(Boolean state)
127 | {
128 | if (state != flags.power)
129 | {
130 | if (state)
131 | {
132 | flags.power = ON;
133 | flags.pause = OFF;
134 | abi->power(context, ON);
135 | start();
136 | }
137 |
138 | else {
139 | Size rom_count = abi->rom_count, index = 0;
140 | Size offset = 0;
141 | ROM *rom;
142 |
143 | if (!flags.pause) stop();
144 | abi->power(context, OFF);
145 |
146 | for (; index < rom_count; index++)
147 | {
148 | rom = &abi->roms[index];
149 | memset(context->memory + offset, 0, rom->base_address - offset);
150 | offset = rom->base_address + rom->size;
151 | }
152 |
153 | memset(context->memory + offset, 0, abi->memory_size - offset);
154 | flags.power = OFF;
155 | flags.pause = OFF;
156 | }
157 | }
158 | }
159 |
160 |
161 | void Machine::pause(Boolean state)
162 | {
163 | if (flags.power && state != flags.pause)
164 | {
165 | if (state)
166 | {
167 | flags.pause = ON;
168 | stop();
169 | }
170 |
171 | else {
172 | start();
173 | flags.pause = OFF;
174 | }
175 | }
176 | }
177 |
178 |
179 | void Machine::reset()
180 | {
181 | if (flags.power)
182 | {
183 | if (!flags.pause) stop();
184 | abi->reset(context);
185 | start();
186 | flags.pause = OFF;
187 | }
188 | }
189 |
190 |
191 | void Machine::set_audio_input(RingBuffer *audio_input)
192 | {
193 | # if Z_OS != Z_OS_LINUX
194 | _audio_input = audio_input;
195 | # endif
196 | }
197 |
198 |
199 | void Machine::write_memory(Zeta::UInt16 base_address, void *data, Zeta::Size data_size)
200 | {memcpy(context->memory + base_address, data, data_size);}
201 |
202 |
203 | /* Machine.c EOF */
204 |
--------------------------------------------------------------------------------
/sources/common/Machine.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / common/Machine.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_common_Machine_H
8 | #define __mZX_common_Machine_H
9 |
10 | #include
11 | #include
12 | #include "ZX Spectrum.h"
13 | #include "MachineABI.h"
14 | #include
15 | #include
16 |
17 | class Machine {
18 | private:
19 | std::thread _thread;
20 | volatile Zeta::Boolean _must_stop;
21 | Zeta::TripleBuffer* _video_output;
22 | Zeta::RingBuffer* _audio_output;
23 | Zeta::TripleBuffer* _keyboard_input;
24 |
25 | # if Z_OS != Z_OS_LINUX
26 | Zeta::RingBuffer* _audio_input;
27 | # endif
28 |
29 | public:
30 | ZXSpectrum* context;
31 | MachineABI* abi;
32 |
33 | struct {Zeta::Boolean power :1;
34 | Zeta::Boolean pause :1;
35 | } flags;
36 |
37 | Machine(MachineABI* abi,
38 | Zeta::TripleBuffer* video_output,
39 | Zeta::RingBuffer* audio_output,
40 | Zeta::TripleBuffer* keyboard_input);
41 |
42 | ~Machine();
43 |
44 | void run_one_frame();
45 | void power(Zeta::Boolean state);
46 | void pause(Zeta::Boolean state);
47 | void reset();
48 | void set_audio_input(Zeta::RingBuffer *audio_input);
49 | void write_memory(Zeta::UInt16 base_address, void *data, Zeta::Size data_size);
50 |
51 | private:
52 | void main();
53 | void start();
54 | void stop();
55 | };
56 |
57 | #endif /* __mZX_common_Machine_H */
58 |
--------------------------------------------------------------------------------
/sources/common/Matrix.hpp:
--------------------------------------------------------------------------------
1 | /* ZMathematics Kit C++ API - Matrix.hpp
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2006-2016 Manuel Sainz de Baranda y Goñi.
7 | Released under the terms of the GNU Lesser General Public License v3. */
8 |
9 | #ifndef __ZMathematics_Matrix_HPP__
10 | #define __ZMathematics_Matrix_HPP__
11 |
12 | #include
13 | #include
14 |
15 | namespace Zeta {
16 | template struct Matrix2x2;
17 | template struct Matrix3x3;
18 | template struct Matrix4x4;
19 | }
20 |
21 | template struct Zeta::Matrix4x4 {
22 | T m[4 * 4];
23 |
24 | // MARK: - Constructors
25 |
26 | static const Matrix4x4 identity;
27 |
28 | inline Matrix4x4() {};
29 |
30 | // MARK: - Operators
31 |
32 | Matrix4x4 operator +(const Matrix4x4 &matrix) const;
33 | Matrix4x4 operator -(const Matrix4x4 &matrix) const;
34 | Matrix4x4 operator *(const Matrix4x4 &matrix) const;
35 | Matrix4x4 operator /(const Matrix4x4 &matrix) const;
36 |
37 | Matrix4x4 &operator +=(const Matrix4x4 &matrix);
38 | Matrix4x4 &operator -=(const Matrix4x4 &matrix);
39 | Matrix4x4 &operator *=(const Matrix4x4 &matrix);
40 | Matrix4x4 &operator /=(const Matrix4x4 &matrix);
41 |
42 | Matrix4x4 operator +(T scalar) const;
43 | Matrix4x4 operator -(T scalar) const;
44 | Matrix4x4 operator *(T scalar) const;
45 | Matrix4x4 operator /(T scalar) const;
46 |
47 | Matrix4x4 &operator +=(T scalar);
48 | Matrix4x4 &operator -=(T scalar);
49 | Matrix4x4 &operator *=(T scalar);
50 | Matrix4x4 &operator /=(T scalar);
51 |
52 | Matrix4x4 &set_identity();
53 | Matrix4x4 &transpose();
54 | T determinant() const;
55 | Matrix4x4 inverse() const;
56 |
57 | // MARK: - Operations for affine transformations
58 |
59 | static Matrix4x4 translation(T x, T y);
60 | static Matrix4x4 translation(T x, T y, T z);
61 | static Matrix4x4 scaling (T x, T y);
62 | static Matrix4x4 scaling (T x, T y, T z);
63 | static Matrix4x4 rotation (T z);
64 | static Matrix4x4 rotation (T x, T y, T z);
65 |
66 |
67 | //static inline Matrix4x4 translation(const Value2D &translation)
68 | // {return Matrix4x4::translation(translation.x, translation.y);}
69 |
70 |
71 | //static inline Matrix4x4 translation(const Value3D &translation)
72 | // {return Matrix4x4::translation(translation.x, translation.y, translation.z);}
73 |
74 |
75 | //static inline Matrix4x4 scaling(const Value2D &scale)
76 | // {return scaling(scale.x, scale.y);}
77 |
78 |
79 | //static inline Matrix scaling(const Value3D &scale)
80 | // {return scaling(scale.x, scale.y, scale.z);}
81 |
82 |
83 | //static inline Matrix4x4 rotation(const Value3D &rotation)
84 | // {return Matrix4x4::rotation(rotation.x, rotation.y, rotation.z);}
85 |
86 |
87 | Matrix4x4 translated(T x, T y) const;
88 | Matrix4x4 translated(T x, T y, T z) const;
89 | Matrix4x4 scaled (T x, T y) const;
90 | Matrix4x4 scaled (T x, T y, T z) const;
91 | Matrix4x4 rotated (T z) const;
92 | Matrix4x4 rotated (T x, T y, T z) const;
93 |
94 |
95 | inline Matrix4x4 translated(const Value2D &translation) const
96 | {return translated(translation.x, translation.y);}
97 |
98 |
99 | //inline Matrix4x4 translated(const Value3D &distance) const
100 | // {return translated(translation.x, translation.y, translation.z);}
101 |
102 |
103 | inline Matrix4x4 scaled(const Value2D &scale) const
104 | {return scaled(scale.x, scale.y);}
105 |
106 |
107 | //inline Matrix4x4 scaled(const Value3D &scale) const
108 | // {return scaled(scale.x, scale.y, scale.z);}
109 |
110 |
111 | //inline Matrix4x4 rotated(const Value3D &rotation) const
112 | // {return scaled(scale.x, scale.y, scale.z);}
113 |
114 |
115 | Matrix4x4 &translate(T x, T y);
116 | Matrix4x4 &translate(T x, T y, T z);
117 | Matrix4x4 &scale (T x, T y);
118 | Matrix4x4 &scale (T x, T y, T z);
119 | Matrix4x4 &rotate (T z);
120 | Matrix4x4 &rotate (T x, T y, T z);
121 | };
122 |
123 |
124 | #endif // __ZMathematics_Matrix_HPP__
125 |
--------------------------------------------------------------------------------
/sources/common/OpenGL.cpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / common/OpenGL.cpp
3 | | | |_/ /__> < Copyright © 2014-2016 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #include "OpenGL.hpp"
8 |
9 | using namespace Zeta;
10 | using namespace std;
11 |
12 |
13 | GLuint compile_shader(Character const *source_code, GLenum type, string **error_log)
14 | {
15 | GLuint id = glCreateShader(type);
16 | GLint source_code_size = GLint(strlen(source_code));
17 | glShaderSource(id, 1, (const GLchar* const *)&source_code, &source_code_size);
18 | glCompileShader(id);
19 |
20 | GLint success;
21 |
22 | glGetShaderiv(id, GL_COMPILE_STATUS, &success);
23 |
24 | if (success == GL_FALSE)
25 | {
26 | if (error_log)
27 | {
28 | GLint log_size;
29 | glGetShaderiv(id, GL_INFO_LOG_LENGTH, &log_size);
30 | *error_log = new string(log_size, ' ');
31 | glGetShaderInfoLog(id, log_size, &log_size, (GLchar *)(*error_log)->data());
32 | }
33 |
34 | glDeleteShader(id);
35 | return 0;
36 | }
37 |
38 | return id;
39 | }
40 |
--------------------------------------------------------------------------------
/sources/common/OpenGL.hpp:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / common/OpenGL.hpp
3 | | | |_/ /__> < Copyright © 2014-2016 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #ifndef __mZX_common_OpenGL_HPP
8 | #define __mZX_common_OpenGL_HPP
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #if Z_OS == Z_OS_MAC_OS_X
15 |
16 | # include
17 | # include
18 |
19 | # define OPEN_GL
20 |
21 | #elif Z_OS == Z_OS_IOS
22 |
23 | # include
24 | # include
25 |
26 | # define OPEN_GL_ES
27 |
28 | #elif Z_OS == Z_OS_LINUX
29 |
30 | # define GL_GLEXT_PROTOTYPES
31 | # include
32 | # include
33 |
34 | # define OPEN_GL
35 |
36 | #endif
37 |
38 |
39 | GLuint compile_shader (Zeta::Character const *source_code,
40 | GLenum type,
41 | std::string **error_log);
42 |
43 |
44 | #endif // __mZX_common_OpenGL_HPP
45 |
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/89C.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/sources/common/codecs/snapshot/89C.c
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/ACH.c:
--------------------------------------------------------------------------------
1 | /* ACH ZX Spectrum Snapshot Codec v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2013 Manuel Sainz de Baranda y Goñi
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 |
18 | static ZStatus test(ZACH *object, zsize object_size)
19 | {
20 | if (object_size != sizeof(ZACH)) return Z_ERROR_INVALID_SIZE;
21 |
22 | return Z_OK;
23 | }
24 |
25 |
26 | static void decode(
27 | ZACH* object,
28 | ZZXSpectrumState* machine,
29 | ZZ80State* cpu,
30 | zuint8* memory
31 | )
32 | {
33 | machine->keyboard.value_uint64 = Z_UINT64(0xFFFFFFFFFFFFFFFF);
34 | machine->flash = FALSE;
35 | machine->ula_io.value = object->border_color & 7;
36 |
37 | Z_Z80_STATE_PC( cpu) = z_uint16_little_endian(object->pc);
38 | Z_Z80_STATE_SP( cpu) = z_uint16_little_endian(object->sp);
39 | Z_Z80_STATE_A ( cpu) = object->a;
40 | Z_Z80_STATE_F ( cpu) = object->f;
41 | Z_Z80_STATE_B ( cpu) = object->b;
42 | Z_Z80_STATE_C ( cpu) = object->c;
43 | Z_Z80_STATE_D ( cpu) = object->d;
44 | Z_Z80_STATE_E ( cpu) = object->e;
45 | Z_Z80_STATE_H ( cpu) = object->h;
46 | Z_Z80_STATE_L ( cpu) = object->l;
47 | Z_Z80_STATE_IX( cpu) = z_uint16_little_endian(object->ix.value_uint16);
48 | Z_Z80_STATE_IY( cpu) = z_uint16_little_endian(object->iy.value_uint16);
49 | Z_Z80_STATE_A_( cpu) = object->a_;
50 | Z_Z80_STATE_F_( cpu) = object->f_;
51 | Z_Z80_STATE_B_( cpu) = object->b_;
52 | Z_Z80_STATE_C_( cpu) = object->c_;
53 | Z_Z80_STATE_D_( cpu) = object->d_;
54 | Z_Z80_STATE_E_( cpu) = object->e_;
55 | Z_Z80_STATE_H_( cpu) = object->h_;
56 | Z_Z80_STATE_L_( cpu) = object->l_;
57 | Z_Z80_STATE_I( cpu) = object->i;
58 | Z_Z80_STATE_R( cpu) = object->r;
59 | Z_Z80_STATE_HALT(cpu) = FALSE;
60 | Z_Z80_STATE_IRQ( cpu) = FALSE;
61 | Z_Z80_STATE_NMI( cpu) = FALSE;
62 | Z_Z80_STATE_IFF1(cpu) =
63 | Z_Z80_STATE_IFF2(cpu) = object->iff2 & 1;
64 | Z_Z80_STATE_EI( cpu) = FALSE;
65 | Z_Z80_STATE_IM( cpu) = object->im & 3;
66 |
67 | memcpy(memory, object->memory, 1024 * 64);
68 | }
69 |
70 |
71 | static void encode(
72 | ZACH* object,
73 | ZZXSpectrumState* machine,
74 | ZZ80State* cpu,
75 | zuint8* memory
76 | )
77 | {
78 | memset(object, 0, sizeof(ZACH) - 1024 * 64);
79 |
80 | object->a = Z_Z80_STATE_A(cpu);
81 | object->f = Z_Z80_STATE_F(cpu);
82 | object->b = Z_Z80_STATE_B(cpu);
83 | object->c = Z_Z80_STATE_C(cpu);
84 | object->d = Z_Z80_STATE_D(cpu);
85 | object->e = Z_Z80_STATE_E(cpu);
86 | object->h = Z_Z80_STATE_H(cpu);
87 | object->l = Z_Z80_STATE_L(cpu);
88 | object->pc = z_uint16_little_endian(Z_Z80_STATE_PC(cpu));
89 | object->sp = z_uint16_little_endian(Z_Z80_STATE_SP(cpu));
90 | object->r = Z_Z80_STATE_R(cpu);
91 | object->border_color = machine->ula_io.fields.border_color;
92 | object->im = Z_Z80_STATE_IM(cpu);
93 | object->i = Z_Z80_STATE_I(cpu);
94 | object->iff2 = Z_Z80_STATE_IFF2(cpu);
95 | object->a_ = Z_Z80_STATE_A_(cpu);
96 | object->f_ = Z_Z80_STATE_F_(cpu);
97 | object->b_ = Z_Z80_STATE_B_(cpu);
98 | object->c_ = Z_Z80_STATE_C_(cpu);
99 | object->d_ = Z_Z80_STATE_D_(cpu);
100 | object->e_ = Z_Z80_STATE_E_(cpu);
101 | object->h_ = Z_Z80_STATE_H_(cpu);
102 | object->l_ = Z_Z80_STATE_L_(cpu);
103 | object->ix.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IX(cpu));
104 | object->iy.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IY(cpu));
105 |
106 | memcpy(object->memory, memory, 1024 * 64);
107 | }
108 |
109 |
110 | /* ACH.c EOF */
111 |
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/FRZ.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/sources/common/codecs/snapshot/FRZ.c
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/PLUSD.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/sources/common/codecs/snapshot/PLUSD.c
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/PRG.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/redcode/MicroZX/bc459fa56beda875978e2271a5759cf68c43f7b7/sources/common/codecs/snapshot/PRG.c
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/SIT.c:
--------------------------------------------------------------------------------
1 | /* SIT ZX Spectrum Snapshot Codec v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2013 Manuel Sainz de Baranda y Goñi
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 |
18 | static ZStatus test(ZSIT *object, zsize object_size)
19 | {
20 | if (object_size != sizeof(ZSIT)) return Z_ERROR_INVALID_SIZE;
21 |
22 | return Z_OK;
23 | }
24 |
25 |
26 | static void decode(
27 | ZSIT* object,
28 | ZZXSpectrumState* machine,
29 | ZZ80State* cpu,
30 | zuint8* memory
31 | )
32 | {
33 | machine->keyboard.value_uint64 = Z_UINT64(0xFFFFFFFFFFFFFFFF);
34 | machine->flash = FALSE;
35 | machine->ula_io.value = object->border_color & 7;
36 |
37 | Z_Z80_STATE_PC( cpu) = z_uint16_little_endian(object->pc);
38 | Z_Z80_STATE_SP( cpu) = z_uint16_little_endian(object->sp);
39 | Z_Z80_STATE_AF( cpu) = z_uint16_little_endian(object->af.value_uint16);
40 | Z_Z80_STATE_BC( cpu) = z_uint16_little_endian(object->bc.value_uint16);
41 | Z_Z80_STATE_DE( cpu) = z_uint16_little_endian(object->de.value_uint16);
42 | Z_Z80_STATE_HL( cpu) = z_uint16_little_endian(object->hl.value_uint16);
43 | Z_Z80_STATE_IX( cpu) = z_uint16_little_endian(object->ix.value_uint16);
44 | Z_Z80_STATE_IY( cpu) = z_uint16_little_endian(object->iy.value_uint16);
45 | Z_Z80_STATE_AF_( cpu) = z_uint16_little_endian(object->af_.value_uint16);
46 | Z_Z80_STATE_BC_( cpu) = z_uint16_little_endian(object->bc_.value_uint16);
47 | Z_Z80_STATE_DE_( cpu) = z_uint16_little_endian(object->de_.value_uint16);
48 | Z_Z80_STATE_HL_( cpu) = z_uint16_little_endian(object->hl_.value_uint16);
49 | Z_Z80_STATE_I( cpu) = object->i;
50 | Z_Z80_STATE_R( cpu) = object->r;
51 | Z_Z80_STATE_HALT(cpu) = FALSE;
52 | Z_Z80_STATE_IRQ( cpu) = FALSE;
53 | Z_Z80_STATE_NMI( cpu) = FALSE;
54 | Z_Z80_STATE_IFF1(cpu) =
55 | Z_Z80_STATE_IFF2(cpu) = TRUE;
56 | Z_Z80_STATE_EI( cpu) = FALSE;
57 | Z_Z80_STATE_IM( cpu) = object->im & 3;
58 |
59 | memcpy(memory, object->memory, 1024 * 64);
60 | }
61 |
62 |
63 | static void encode(
64 | ZSIT* object,
65 | ZZXSpectrumState* machine,
66 | ZZ80State* cpu,
67 | zuint8* memory
68 | )
69 | {
70 | object->bc.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_BC(cpu));
71 | object->de.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_DE(cpu));
72 | object->hl.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_HL(cpu));
73 | object->af.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_AF(cpu));
74 | object->ix.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IX(cpu));
75 | object->iy.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IY(cpu));
76 | object->pc = z_uint16_little_endian(Z_Z80_STATE_PC(cpu));
77 | object->sp = z_uint16_little_endian(Z_Z80_STATE_SP(cpu));
78 | object->r = Z_Z80_STATE_R(cpu);
79 | object->i = Z_Z80_STATE_I(cpu);
80 | object->bc_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_BC_(cpu));
81 | object->de_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_DE_(cpu));
82 | object->hl_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_HL_(cpu));
83 | object->af_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_AF_(cpu));
84 | object->im = Z_Z80_STATE_IM(cpu);
85 | object->border_color = machine->ula_io.fields.border_color;
86 |
87 | memcpy(object->memory, memory, 1024 * 64);
88 | }
89 |
90 |
91 | /* SIT.c EOF */
92 |
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/SNA.c:
--------------------------------------------------------------------------------
1 | /* SNA ZX Spectrum Snapshot Codec v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2013 Manuel Sainz de Baranda y Goñi
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 |
18 | ZStatus sna_v48k_test(ZSNAv48K *object, zsize object_size)
19 | {
20 | if (object_size != sizeof(ZSNAv48K)) return Z_ERROR_INVALID_SIZE;
21 |
22 | return (object->im < 3 && object->border_color < 8)
23 | ? Z_OK : Z_ERROR_INVALID_FORMAT;
24 | }
25 |
26 | zsize sna_v48k_encoding_size(
27 | ZZXSpectrumState* machine,
28 | ZZ80State* cpu,
29 | zuint* memory
30 | )
31 | {return sizeof(ZSNAv48K);}
32 |
33 |
34 | void sna_v48k_decode(
35 | ZSNAv48K* object,
36 | ZZXSpectrumState* machine,
37 | ZZ80State* cpu,
38 | zuint8* memory
39 | )
40 | {
41 | machine->keyboard.value_uint64 = Z_UINT64(0xFFFFFFFFFFFFFFFF);
42 | machine->flash = FALSE;
43 | machine->ula_io.value = object->border_color & 7;
44 |
45 | Z_Z80_STATE_PC( cpu) = Z_SNA_V48K_PC_VALUE;
46 | Z_Z80_STATE_SP( cpu) = z_uint16_little_endian(object->sp);
47 | Z_Z80_STATE_AF( cpu) = z_uint16_little_endian(object->af.value_uint16);
48 | Z_Z80_STATE_BC( cpu) = z_uint16_little_endian(object->bc.value_uint16);
49 | Z_Z80_STATE_DE( cpu) = z_uint16_little_endian(object->de.value_uint16);
50 | Z_Z80_STATE_HL( cpu) = z_uint16_little_endian(object->hl.value_uint16);
51 | Z_Z80_STATE_IX( cpu) = z_uint16_little_endian(object->ix.value_uint16);
52 | Z_Z80_STATE_IY( cpu) = z_uint16_little_endian(object->iy.value_uint16);
53 | Z_Z80_STATE_AF_( cpu) = z_uint16_little_endian(object->af_.value_uint16);
54 | Z_Z80_STATE_BC_( cpu) = z_uint16_little_endian(object->bc_.value_uint16);
55 | Z_Z80_STATE_DE_( cpu) = z_uint16_little_endian(object->de_.value_uint16);
56 | Z_Z80_STATE_HL_( cpu) = z_uint16_little_endian(object->hl_.value_uint16);
57 | Z_Z80_STATE_I( cpu) = object->i;
58 | Z_Z80_STATE_R( cpu) = object->r;
59 | Z_Z80_STATE_HALT(cpu) = FALSE;
60 | Z_Z80_STATE_IRQ( cpu) = FALSE;
61 | Z_Z80_STATE_NMI( cpu) = FALSE;
62 | Z_Z80_STATE_IFF1(cpu) =
63 | Z_Z80_STATE_IFF2(cpu) = object->interrupt.iff2;
64 | Z_Z80_STATE_EI( cpu) = FALSE;
65 | Z_Z80_STATE_IM( cpu) = object->im;
66 |
67 | memcpy(memory + 1024 * 16, object->ram, 1024 * 48);
68 | }
69 |
70 |
71 | void sna_v48k_encode(
72 | ZSNAv48K* object,
73 | ZZXSpectrumState* machine,
74 | ZZ80State* cpu,
75 | zuint8* memory
76 | )
77 | {
78 | object->i = Z_Z80_STATE_I(cpu);
79 | object->hl_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_HL_(cpu));
80 | object->de_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_DE_(cpu));
81 | object->bc_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_BC_(cpu));
82 | object->af_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_AF_(cpu));
83 | object->hl.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_HL (cpu));
84 | object->de.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_DE (cpu));
85 | object->bc.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_BC (cpu));
86 | object->iy.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IY (cpu));
87 | object->ix.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IX (cpu));
88 | object->interrupt.unused_0 = 0;
89 | object->interrupt.iff2 = Z_Z80_STATE_IFF2(cpu);
90 | object->interrupt.unused_1 = 0;
91 | object->r = Z_Z80_STATE_R(cpu);
92 | object->af.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_AF(cpu));
93 | object->sp = z_uint16_little_endian(Z_Z80_STATE_SP(cpu));
94 | object->im = Z_Z80_STATE_IM(cpu);
95 | object->border_color = machine->ula_io.fields.border_color;
96 |
97 | memcpy(object->ram, memory + 1024 * 16, 1024 * 48);
98 | }
99 |
100 |
101 | /* SNA.c EOF */
102 |
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/SNA.h:
--------------------------------------------------------------------------------
1 | #ifndef mZX_SNA_h
2 | #define mZX_SNA_h
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | ZStatus sna_v48k_test(ZSNAv48K *object, zsize object_size);
9 |
10 | zsize sna_v48k_encoding_size(
11 | ZZXSpectrumState* machine,
12 | ZZ80State* cpu,
13 | zuint* memory
14 | );
15 |
16 | void sna_v48k_decode(
17 | ZSNAv48K* object,
18 | ZZXSpectrumState* machine,
19 | ZZ80State* cpu,
20 | zuint8* memory
21 | );
22 |
23 | void sna_v48k_encode(
24 | ZSNAv48K* object,
25 | ZZXSpectrumState* machine,
26 | ZZ80State* cpu,
27 | zuint8* memory
28 | );
29 |
30 |
31 | #endif
32 |
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/SNP.c:
--------------------------------------------------------------------------------
1 | /* SNP ZX Spectrum Snapshot Codec v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2013 Manuel Sainz de Baranda y Goñi
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 |
18 | static ZStatus test(ZSNP *object, zsize object_size)
19 | {
20 | if (object_size != sizeof(ZSNP)) return Z_ERROR_INVALID_SIZE;
21 |
22 | return Z_OK;
23 | }
24 |
25 |
26 | static void decode(
27 | ZSNP* object,
28 | ZZXSpectrumState* machine,
29 | ZZ80State* cpu,
30 | zuint8* memory
31 | )
32 | {
33 | machine->keyboard.value_uint64 = Z_UINT64(0xFFFFFFFFFFFFFFFF);
34 | machine->flash = FALSE;
35 | machine->ula_io.value = object->border_color & 7;
36 |
37 | Z_Z80_STATE_PC( cpu) = z_uint16_little_endian(object->pc);
38 | Z_Z80_STATE_SP( cpu) = z_uint16_little_endian(object->sp);
39 | Z_Z80_STATE_AF( cpu) = z_uint16_little_endian(object->af.value_uint16);
40 | Z_Z80_STATE_BC( cpu) = z_uint16_little_endian(object->bc.value_uint16);
41 | Z_Z80_STATE_DE( cpu) = z_uint16_little_endian(object->de.value_uint16);
42 | Z_Z80_STATE_HL( cpu) = z_uint16_little_endian(object->hl.value_uint16);
43 | Z_Z80_STATE_IX( cpu) = z_uint16_little_endian(object->ix.value_uint16);
44 | Z_Z80_STATE_IY( cpu) = z_uint16_little_endian(object->iy.value_uint16);
45 | Z_Z80_STATE_AF_( cpu) = z_uint16_little_endian(object->af_.value_uint16);
46 | Z_Z80_STATE_BC_( cpu) = z_uint16_little_endian(object->bc_.value_uint16);
47 | Z_Z80_STATE_DE_( cpu) = z_uint16_little_endian(object->de_.value_uint16);
48 | Z_Z80_STATE_HL_( cpu) = z_uint16_little_endian(object->hl_.value_uint16);
49 | Z_Z80_STATE_I( cpu) = object->i;
50 | Z_Z80_STATE_R( cpu) = object->r;
51 | Z_Z80_STATE_IRQ( cpu) = FALSE;
52 | Z_Z80_STATE_NMI( cpu) = FALSE;
53 | Z_Z80_STATE_IFF1(cpu) = object->iff1 & 1;
54 | Z_Z80_STATE_IFF2(cpu) = object->iff2 & 1;
55 | Z_Z80_STATE_EI( cpu) = FALSE;
56 | Z_Z80_STATE_IM( cpu) = object->im & 3;
57 |
58 | memcpy(memory + 1024 * 16, object->ram, 1024 * 48);
59 | }
60 |
61 |
62 | static void encode(
63 | ZSNP* object,
64 | ZZXSpectrumState* machine,
65 | ZZ80State* cpu,
66 | zuint8* memory
67 | )
68 | {
69 | memcpy(object->ram, memory + 1024 * 16, 1024 * 48);
70 |
71 | object->af.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_AF(cpu));
72 | object->border_color = machine->ula_io.fields.border_color;
73 | object->reserved = 0;
74 | object->bc.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_BC(cpu));
75 | object->de.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_DE(cpu));
76 | object->hl.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_HL(cpu));
77 | object->pc = z_uint16_little_endian(Z_Z80_STATE_PC(cpu));
78 | object->sp = z_uint16_little_endian(Z_Z80_STATE_SP(cpu));
79 | object->ix.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IX(cpu));
80 | object->iy.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_IY(cpu));
81 | object->iff1 = Z_Z80_STATE_IFF1(cpu);
82 | object->iff1 = Z_Z80_STATE_IFF2(cpu);
83 | object->im = Z_Z80_STATE_IM(cpu);
84 | object->r = Z_Z80_STATE_R(cpu);
85 | object->i = Z_Z80_STATE_I(cpu);
86 | object->af_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_AF_(cpu));
87 | object->bc_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_BC_(cpu));
88 | object->de_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_DE_(cpu));
89 | object->hl_.value_uint16 = z_uint16_little_endian(Z_Z80_STATE_HL_(cpu));
90 | }
91 |
92 |
93 | /* SNP.c EOF */
94 |
--------------------------------------------------------------------------------
/sources/common/codecs/snapshot/ZX.c:
--------------------------------------------------------------------------------
1 | /* ZX ZX Spectrum Snapshot Codec v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2013 Manuel Sainz de Baranda y Goñi
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 |
18 | static ZStatus test(ZZX *object, zsize object_size)
19 | {
20 | if (object_size != sizeof(ZZX)) return Z_ERROR_INVALID_SIZE;
21 |
22 | return Z_OK;
23 | }
24 |
25 |
26 | static void decode(
27 | ZZX* object,
28 | ZZXSpectrumState* machine,
29 | ZZ80State* cpu,
30 | zuint8* memory
31 | )
32 | {
33 | machine->keyboard.value_uint64 = Z_UINT64(0xFFFFFFFFFFFFFFFF);
34 | machine->flash = FALSE;
35 | machine->ula_io.value = 0;
36 |
37 | Z_Z80_STATE_PC( cpu) = z_uint16_big_endian(object->pc);
38 | Z_Z80_STATE_SP( cpu) = z_uint16_big_endian(object->sp);
39 | Z_Z80_STATE_A( cpu) = object->a;
40 | Z_Z80_STATE_F( cpu) = object->f;
41 | Z_Z80_STATE_BC( cpu) = z_uint16_big_endian(object->bc.value_uint16);
42 | Z_Z80_STATE_DE( cpu) = z_uint16_big_endian(object->de.value_uint16);
43 | Z_Z80_STATE_HL( cpu) = z_uint16_big_endian(object->hl.value_uint16);
44 | Z_Z80_STATE_IX( cpu) = z_uint16_big_endian(object->ix.value_uint16);
45 | Z_Z80_STATE_IY( cpu) = z_uint16_big_endian(object->iy.value_uint16);
46 | Z_Z80_STATE_A_( cpu) = object->a_;
47 | Z_Z80_STATE_F_( cpu) = object->f_;
48 | Z_Z80_STATE_BC_( cpu) = z_uint16_big_endian(object->bc_.value_uint16);
49 | Z_Z80_STATE_DE_( cpu) = z_uint16_big_endian(object->de_.value_uint16);
50 | Z_Z80_STATE_HL_( cpu) = z_uint16_big_endian(object->hl_.value_uint16);
51 | Z_Z80_STATE_I( cpu) = object->i;
52 | Z_Z80_STATE_R( cpu) = object->r;
53 | Z_Z80_STATE_HALT(cpu) = object->halt & 1;
54 | Z_Z80_STATE_IRQ( cpu) = FALSE;
55 | Z_Z80_STATE_NMI( cpu) = FALSE;
56 | Z_Z80_STATE_IFF1(cpu) =
57 | Z_Z80_STATE_IFF2(cpu) = object->iff & 1;
58 | Z_Z80_STATE_EI( cpu) = FALSE;
59 | Z_Z80_STATE_IM( cpu) = object->im & 3;
60 |
61 | memcpy(memory + 1024 * 16, object->ram, 1024 * 48);
62 | }
63 |
64 |
65 | static void encode(
66 | ZZX* object,
67 | ZZXSpectrumState* machine,
68 | ZZ80State* cpu,
69 | zuint8* memory
70 | )
71 | {
72 | memcpy(object->rom_tail, memory + 1024 * 16 - 132, 132 + 1024 * 48);
73 |
74 | memset (object + Z_OFFSET_OF(ZZX, zero_0), 0,
75 | sizeof(ZZX) - Z_OFFSET_OF(ZZX, zero_0));
76 |
77 | object->settings[0] = 10;
78 | object->settings[1] = 10;
79 | object->settings[2] = 4;
80 | object->settings[3] = 1;
81 | object->settings[4] = 1;
82 | object->iff = Z_Z80_STATE_IFF2(cpu);
83 | object->constants[0] = 0;
84 | object->constants[1] = 3;
85 | object->color_mode = Z_ZX_COLOR_MODE_COLOR;
86 | object->bc.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_BC (cpu));
87 | object->bc_.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_BC_(cpu));
88 | object->de.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_DE (cpu));
89 | object->de_.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_DE_(cpu));
90 | object->hl.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_HL (cpu));
91 | object->hl_.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_HL_(cpu));
92 | object->ix.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_IX (cpu));
93 | object->iy.value_uint16 = z_uint16_big_endian(Z_Z80_STATE_IY (cpu));
94 | object->i = Z_Z80_STATE_I(cpu);
95 | object->r = Z_Z80_STATE_R(cpu);
96 | object->a_ = Z_Z80_STATE_A_(cpu);
97 | object->a = Z_Z80_STATE_A(cpu);
98 | object->f_ = Z_Z80_STATE_F_(cpu);
99 | object->f = Z_Z80_STATE_F(cpu);
100 | object->pc = z_uint16_big_endian(Z_Z80_STATE_PC(cpu));
101 | object->sp = z_uint16_big_endian(Z_Z80_STATE_SP(cpu));
102 | object->sound_mode = Z_ZX_SOUND_MODE_SIMPLE;
103 | object->halt = Z_Z80_STATE_HALT(cpu);
104 | object->im = ((zint16)Z_Z80_STATE_IM(cpu)) - 1;
105 | }
106 |
107 |
108 | /* ZX.c EOF */
109 |
--------------------------------------------------------------------------------
/sources/common/common.pri:
--------------------------------------------------------------------------------
1 | SOURCES += \
2 | $$P_SOURCES/common/system.c \
3 | $$P_SOURCES/common/GLVideoOutput.cpp \
4 | $$P_SOURCES/common/Machine.cpp \
5 |
6 | HEADERS += \
7 | $$P_SOURCES/common/OpenGL.h \
8 | $$P_SOURCES/common/system.h \
9 | $$P_SOURCES/common/GLVideoOutput.hpp \
10 | $$P_SOURCES/common/Machine.hpp \
11 |
--------------------------------------------------------------------------------
/sources/common/emulators/AY-3-891x.c:
--------------------------------------------------------------------------------
1 | /* General Instrument AY-3-891x PSG Emulator v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2014 Manuel Sainz de Baranda y Goñi.
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include "AY-3-891x.h"
11 | #include
12 |
13 | #define R(index) object->r[index]
14 |
15 | static const zuint8 levels[16] = {
16 | 0x00, 0x03, 0x05, 0x07,
17 | 0x0A, 0x0F, 0x15, 0x23,
18 | 0x2B, 0x43, 0x5A, 0x73,
19 | 0x92, 0xAF, 0xD9, 0xFF
20 | };
21 |
22 | /*
23 | #define Q_AY_3_891X_CHANNEL_A_TONE_PERIOD_FINE_TUNE 0
24 | #define Q_AY_3_891X_CHANNEL_A_TONE_PERIOD_COARSE_TUNE 1
25 | #define Q_AY_3_891X_CHANNEL_B_TONE_PERIOD_FINE_TUNE 2
26 | #define Q_AY_3_891X_CHANNEL_B_TONE_PERID_COARSE_TUNE 3
27 | #define Q_AY_3_891X_CHANNEL_C_TONE_PERIOD_FINE_TUNE 4
28 | #define Q_AY_3_891X_CHANNEL_C_TONE_PERIOD_COARSE_TUNE 5
29 | #define Q_AY_3_891X_NOISE_PERIOD 6
30 | #define Q_AY_3_891X_ENABLEE 7
31 | #define Q_AY_3_891X_CHANNEL_A_AMPLITUDE 8
32 | #define Q_AY_3_891X_CHANNEL_B_AMPLITUDE 9
33 | #define Q_AY_3_891X_CHANNEL_C_AMPLITUDE 10
34 | #define Q_AY_3_891X_ENVELOPE_PERIOD_FINE_TUNE 11
35 | #define Q_AY_3_891X_ENVELOPE_PERIOD_COARSE_TUNE 12
36 | #define Q_AY_3_891X_ENVELOPE_SHAPE_CYCLE 13
37 | #define Q_AY_3_891X_IO_PORT_A_DATA_STORE 14
38 | #define Q_AY_3_891X_IO_PORT_B_DATA_STORE 15*/
39 |
40 | void power(AY3891x *object, zboolean state)
41 | {
42 | }
43 |
44 |
45 | void reset(AY3891x *object)
46 | {
47 | }
48 |
49 |
50 | zsize run(AY3891x *object, zsize cycles)
51 | {
52 |
53 | return cycles;
54 | }
55 |
--------------------------------------------------------------------------------
/sources/common/emulators/AY-3-891x.h:
--------------------------------------------------------------------------------
1 | /* General Instrument AY-3-891x PSG Emulator v1.0
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2014 Manuel Sainz de Baranda y Goñi.
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #include
11 | #include
12 |
13 | #ifndef __modules_emulation_PSG_AY_3_891x_H__
14 | #define __modules_emulation_PSG_AY_3_891x_H__
15 |
16 | typedef struct {
17 | zuint8 r[16];
18 |
19 | struct {ZContext16BitAddressRead8Bit read;
20 | ZContext16BitAddressWrite8Bit write;
21 | ZContext16BitAddressRead8Bit in;
22 | ZContext16BitAddressWrite8Bit out;
23 | ZContextRead32Bit int_data;
24 | ZContextSwitch halt;
25 | } cb;
26 | } AY3891x;
27 |
28 | Z_C_SYMBOLS_BEGIN
29 |
30 |
31 |
32 | Z_C_SYMBOLS_END
33 |
34 | #endif /* __modules_emulation_PSG_AY_3_891x_H__ */
35 |
--------------------------------------------------------------------------------
/sources/common/emulators/MachineABI.h:
--------------------------------------------------------------------------------
1 | /* mZX - MachineABI.h
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2013 RedCode Software. All rights reserved. */
7 |
8 | #ifndef mZX_MachineABI_h
9 | #define mZX_MachineABI_h
10 |
11 | #include
12 |
13 | Z_C_SYMBOLS_BEGIN
14 |
15 | typedef struct {
16 | ZString* file_name;
17 | zsize base_address;
18 | zsize size;
19 | } ROM;
20 |
21 | typedef struct {
22 | ZString* model_name;
23 | zsize context_size;
24 | zsize context_cpu_context_offset;
25 | zsize memory_size;
26 | zsize rom_count;
27 | ROM* roms;
28 | ZContextDo initialize;
29 | ZContextSwitch power;
30 | ZContextDo reset;
31 | ZContextDo run_1_frame;
32 | ZContextDo run_1_scanline;
33 | } MachineABI;
34 |
35 | extern MachineABI machine_abi_table[];
36 | extern zsize machine_abi_count;
37 |
38 | Z_C_SYMBOLS_END
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/sources/common/emulators/Z80.h:
--------------------------------------------------------------------------------
1 | /* Zilog Z80 CPU Emulator C API
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 1999-2016 Manuel Sainz de Baranda y Goñi.
8 | Released under the terms of the GNU General Public License v3. */
9 |
10 | #ifndef __emulation_CPU_Z80_H__
11 | #define __emulation_CPU_Z80_H__
12 |
13 | #include
14 | #include
15 |
16 | #ifdef CPU_Z80_USE_SLOTS
17 | # include
18 | #endif
19 |
20 | typedef struct {
21 | zsize cycles;
22 | ZZ80State state;
23 | Z16Bit xy;
24 | zuint8 r7;
25 | Z32Bit data;
26 |
27 | # ifdef CPU_Z80_USE_SLOTS
28 | struct {ZSlot(ZContext16BitAddressRead8Bit ) read;
29 | ZSlot(ZContext16BitAddressWrite8Bit) write;
30 | ZSlot(ZContext16BitAddressRead8Bit ) in;
31 | ZSlot(ZContext16BitAddressWrite8Bit) out;
32 | ZSlot(ZContextRead32Bit ) int_data;
33 | ZSlot(ZContextSwitch ) halt;
34 | } cb;
35 | # else
36 | void* cb_context;
37 |
38 | struct {ZContext16BitAddressRead8Bit read;
39 | ZContext16BitAddressWrite8Bit write;
40 | ZContext16BitAddressRead8Bit in;
41 | ZContext16BitAddressWrite8Bit out;
42 | ZContextRead32Bit int_data;
43 | ZContextSwitch halt;
44 | } cb;
45 | # endif
46 | } Z80;
47 |
48 | Z_C_SYMBOLS_BEGIN
49 |
50 | #ifndef CPU_Z80_ABI
51 | # ifdef CPU_Z80_STATIC
52 | # define CPU_Z80_ABI
53 | # else
54 | # define CPU_Z80_ABI Z_API
55 | # endif
56 | #endif
57 |
58 | CPU_Z80_ABI extern ZCPUEmulatorABI const abi_emulation_cpu_z80;
59 |
60 | #ifndef CPU_Z80_API
61 | # ifdef CPU_Z80_STATIC
62 | # define CPU_Z80_API
63 | # else
64 | # define CPU_Z80_API Z_API
65 | # endif
66 | #endif
67 |
68 | CPU_Z80_API zsize z80_run (Z80* object,
69 | zsize cycles);
70 |
71 | CPU_Z80_API void z80_power (Z80* object,
72 | zboolean state);
73 |
74 | CPU_Z80_API void z80_reset (Z80* object);
75 |
76 | CPU_Z80_API void z80_nmi (Z80* object);
77 |
78 | CPU_Z80_API void z80_int (Z80* object,
79 | zboolean state);
80 |
81 | Z_C_SYMBOLS_END
82 |
83 | #endif /* __emulation_CPU_Z80_H__ */
84 |
--------------------------------------------------------------------------------
/sources/common/emulators/ZX Spectrum.h:
--------------------------------------------------------------------------------
1 | /* Spectra - ZXSpectrum.h
2 | ____ ____ ___ ___ ___
3 | / __ \ / ___\ / __` __`\ / __`\
4 | /\ \/ \/\ \__/_/\ \/\ \/\ \/\ __/
5 | \ \__/\_\ \_____\ \_\ \_\ \_\ \____\
6 | \/_/\/_/\/_____/\/_/\/_/\/_/\/____/
7 | Copyright © 2011 RedCode Software.
8 | Released under the terms of the GNU General Public License v2. */
9 |
10 | #define USE_STATIC_EMULATION_CPU_Z80
11 | #include "Z80.h"
12 | #include
13 | #include
14 |
15 | typedef struct {
16 | zsize cycles_per_frame;
17 | zsize cycles_per_scanline;
18 | zsize cycles_per_int;
19 | } Timmings;
20 |
21 | #define ZX_SPECTRUM_VALUES \
22 | zuint8* memory; \
23 | Z80* cpu; \
24 | zsize* cpu_cycles; \
25 | void* video_output_buffer; \
26 | zuint8* audio_input_buffer; \
27 | zint16* audio_output_buffer; \
28 | \
29 | struct {ZEmulatorRun run; \
30 | ZEmulatorPower power; \
31 | ZContextDo reset; \
32 | ZContextSwitch irq; \
33 | } cpu_abi; \
34 | \
35 | zuint8 keyboard[8]; \
36 | zuint32 border_color; \
37 | zsize frame_cycles; \
38 | zsize frames_since_flash; \
39 | zint16 current_audio_sample; \
40 | zsize audio_sample_index; \
41 | zsize audio_input_base_index; \
42 | zboolean accurate; \
43 | ZZXSpectrumState state; \
44 | const void* screen_border; \
45 | const void* cycles; \
46 | const void* contention; \
47 | zuint8 port_fe; \
48 | zuint8 port_fe_update_cycle; \
49 | zuint8* vram; \
50 |
51 | typedef struct {
52 | ZX_SPECTRUM_VALUES
53 | } ZXSpectrum;
54 |
55 |
--------------------------------------------------------------------------------
/sources/common/emulators/emulators.pri:
--------------------------------------------------------------------------------
1 | SOURCES += \
2 | $$P_SOURCES/common/emulators/Z80.c \
3 | "$$P_SOURCES/common/emulators/ZX Spectrum.c" \
4 |
5 | HEADERS += \
6 | $$P_SOURCES/common/emulators/Z80.h \
7 | "$$P_SOURCES/common/emulators/ZX Spectrum.h" \
8 | $$P_SOURCES/common/emulators/MachineABI.h \
9 |
--------------------------------------------------------------------------------
/sources/common/system.c:
--------------------------------------------------------------------------------
1 | /* ZSystem - time.c
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2006-2014 Manuel Sainz de Baranda y Goñi.
7 | Released under the terms of the GNU General Public License v3. */
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 | static zboolean has_monotonic_time = FALSE;
17 | static zboolean ticks_started = FALSE;
18 | static struct timeval start_tv;
19 |
20 |
21 | #if Z_OS == Z_OS_MAC_OS_X
22 |
23 | # include
24 |
25 | static uint64_t start_mach;
26 | mach_timebase_info_data_t mach_base_info;
27 |
28 |
29 | void z_initialize_ticks(void)
30 | {
31 | if (!ticks_started)
32 | {
33 | if (mach_timebase_info(&mach_base_info))
34 | gettimeofday(&start_tv, NULL);
35 |
36 | else {
37 | has_monotonic_time = TRUE;
38 | start_mach = mach_absolute_time();
39 | }
40 |
41 | ticks_started = TRUE;
42 | }
43 | }
44 |
45 |
46 | zuint64 z_ticks(void)
47 | {
48 | zuint64 ticks;
49 |
50 | if (!ticks_started) z_initialize_ticks();
51 |
52 | if (has_monotonic_time)
53 | {
54 | zuint64 now = mach_absolute_time();
55 | ticks = ((now - start_mach) * mach_base_info.numer) / mach_base_info.denom;
56 | }
57 |
58 | else {
59 | struct timeval now;
60 |
61 | gettimeofday(&now, NULL);
62 | ticks = (now.tv_sec - start_tv.tv_sec) * 1000000000 + (now.tv_usec - start_tv.tv_usec);
63 | }
64 |
65 | return ticks;
66 | }
67 |
68 |
69 | #elif Z_OS_IS(POSIX)
70 |
71 |
72 | void z_initialize_ticks(void)
73 | {
74 | if (!ticks_started)
75 | {
76 | gettimeofday(&start_tv, NULL);
77 | ticks_started = TRUE;
78 | }
79 | }
80 |
81 |
82 | zuint64 z_ticks(void)
83 | {
84 | struct timeval now;
85 |
86 | if (!ticks_started) z_initialize_ticks();
87 | gettimeofday(&now, NULL);
88 |
89 | return (zuint64)(now.tv_sec - start_tv.tv_sec) * 1000000000 +
90 | (now.tv_usec - start_tv.tv_usec) * 1000;
91 | }
92 |
93 |
94 | #endif
95 |
96 |
97 | #if Z_OS_IS(POSIX)
98 |
99 | void z_wait(zuint64 time)
100 | {
101 | int was_error;
102 | struct timespec tv;
103 | //exit(0);
104 | /* Set the timeout interval */
105 | tv.tv_sec = (long)(time / 1000000000);
106 | tv.tv_nsec = (long)(time % 1000000000);
107 |
108 | do {
109 | errno = 0;
110 | was_error = nanosleep(&tv, NULL);
111 | }
112 | while (was_error && (errno == EINTR));
113 | }
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/sources/common/system.h:
--------------------------------------------------------------------------------
1 | /* ZSystem API - time.c
2 | __ __
3 | _______ ___/ /______ ___/ /__
4 | / __/ -_) _ / __/ _ \ _ / -_)
5 | /_/ \__/\_,_/\__/\___/_,_/\__/
6 | Copyright © 2006-2014 Manuel Sainz de Baranda y Goñi.
7 | Released under the terms of the GNU General Public License v3. */
8 |
9 | #ifndef __ZSystem_time_H__
10 | #define __ZSystem_time_H__
11 |
12 | #include
13 |
14 | Z_C_SYMBOLS_BEGIN
15 |
16 | #define Z_SYSTEM_API
17 |
18 | Z_SYSTEM_API void z_initialize_ticks (void);
19 |
20 | Z_SYSTEM_API zuint64 z_ticks (void);
21 |
22 | Z_SYSTEM_API void z_wait (zuint64 time);
23 |
24 | Z_C_SYMBOLS_END
25 |
26 | #endif /* __ZSystem_time_H__ */
27 |
--------------------------------------------------------------------------------
/sources/iOS/JoystickView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickView.h
3 | // μZX (iOS)
4 | //
5 | // Created by Manuel on 06/08/15.
6 | // Copyright (c) 2015 Manuel Sainz de Baranda y Goñi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface JoystickView : UIView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/sources/iOS/JoystickView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickView.m
3 | // μZX (iOS)
4 | //
5 | // Created by Manuel on 06/08/15.
6 | // Copyright (c) 2015 Manuel Sainz de Baranda y Goñi. All rights reserved.
7 | //
8 |
9 | #import "JoystickView.h"
10 |
11 | @implementation JoystickView
12 |
13 | - (id) initWithFrame: (CGRect) frame
14 | {
15 | if ((self = [super initWithFrame: frame]))
16 | {
17 | self.backgroundColor = [UIColor greenColor];
18 | }
19 |
20 | return self;
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/sources/iOS/KeyboardView.h:
--------------------------------------------------------------------------------
1 | //
2 | // KeyboardView.h
3 | // μZX (iOS)
4 | //
5 | // Created by Manuel on 06/08/15.
6 | // Copyright (c) 2015 Manuel Sainz de Baranda y Goñi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface KeyboardView : UIView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/sources/iOS/KeyboardView.m:
--------------------------------------------------------------------------------
1 | //
2 | // KeyboardView.m
3 | // μZX (iOS)
4 | //
5 | // Created by Manuel on 06/08/15.
6 | // Copyright (c) 2015 Manuel Sainz de Baranda y Goñi. All rights reserved.
7 | //
8 |
9 | #import "KeyboardView.h"
10 |
11 | @implementation KeyboardView
12 |
13 |
14 | - (id) initWithFrame: (CGRect) frame
15 | {
16 | if ((self = [super initWithFrame: frame]))
17 | {
18 | self.backgroundColor = [UIColor yellowColor];
19 | }
20 |
21 | return self;
22 | }
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/sources/iOS/MachineViewController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/MachineViewController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "Machine.hpp"
8 | #import "GLVideoView.h"
9 | #import "CoreAudioOutputPlayer.hpp"
10 | #import
11 | #import
12 |
13 | @interface MachineViewController : UIViewController {
14 |
15 |
16 | //-----------.
17 | // Emulation |
18 | //-----------'
19 | Machine* _machine;
20 | MachineABI *_abi;
21 | //----------.
22 | // Geometry |
23 | //----------'
24 | Zeta::Value2D _minimumWindowSize;
25 |
26 | //-------------.
27 | // I/O Buffers |
28 | //-------------'
29 | //QTripleBuffer* _videoOutputBuffer;
30 | //QRingBuffer* _audioOutputBuffer;
31 | Zeta::TripleBuffer* _keyboardBuffer;
32 | Z64Bit* _keyboard;
33 | Z64Bit _keyboardState;
34 |
35 | BOOL _smooth;
36 | IBOutlet GLVideoView* _videoOutputView;
37 | CoreAudioOutputPlayer* _audioOutputPlayer;
38 | BOOL _keyboardInput;
39 | Zeta::RingBuffer _audioInputBuffer;
40 |
41 | //--------.
42 | // Panels |
43 | //--------'
44 | //KeyboardWindowController* _keyboardWindowController;
45 | //DebuggerWindowController* _debuggerWindowController;
46 | //TapeRecorderWindowController* _tapeRecorderWindowController;
47 |
48 | struct {BOOL isFullScreen :1;
49 | BOOL ignoreKeyboardInput :1;
50 | } _flags;
51 |
52 | // Temporal
53 | Zeta::Size _tapeSampleCount;
54 | Zeta::UInt8* _tapeSamples;
55 | BOOL _attachInputBuffer;
56 | }
57 |
58 | - (id) initWithMachineABI: (MachineABI *) machineABI;
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/sources/iOS/MachineViewController.mm:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/MachineViewController.mm
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "MachineViewController.h"
8 | #import
9 | #import
10 |
11 | #define SCREEN_SIZE_X Z_JOIN_2(Z_ZX_SPECTRUM_SCREEN_WIDTH, .0)
12 | #define SCREEN_SIZE_Y Z_JOIN_2(Z_ZX_SPECTRUM_SCREEN_HEIGHT, .0)
13 |
14 | using namespace Zeta;
15 |
16 | @implementation MachineViewController
17 |
18 |
19 | - (id) initWithMachineABI: (MachineABI *) machineABI
20 | {
21 | if ((self = [super initWithNibName: @"MachineView" bundle: nil]))
22 | {
23 | _smooth = YES;
24 | _abi = machineABI;
25 |
26 |
27 | }
28 |
29 | return self;
30 | }
31 |
32 |
33 | - (void) viewDidLoad
34 | {
35 | [super viewDidLoad];
36 |
37 |
38 | /*----------------------------.
39 | | Create video output object. |
40 | '----------------------------*/
41 | // _videoOutputView = [[GLVideoView alloc] initWithFrame:
42 | // CGRectMake(0.0, 0.0, SCREEN_SIZE_X, SCREEN_SIZE_Y)];
43 |
44 | [_videoOutputView
45 | setResolution: Value2D(SCREEN_SIZE_X, SCREEN_SIZE_Y)
46 | format: 0];
47 |
48 | //_videoOutputView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
49 |
50 | /*----------------------------.
51 | | Create audio output object. |
52 | '----------------------------*/
53 | _audioOutputPlayer = new CoreAudioOutputPlayer();
54 | //_audioOutput = [[ALOutputPlayer alloc] init];
55 |
56 |
57 | _keyboardBuffer = new TripleBuffer(malloc(Z_UINT64_SIZE * 3), Z_UINT64_SIZE);
58 | _keyboard = (Z64Bit *)_keyboardBuffer->production_buffer();
59 | memset(_keyboardBuffer->buffers[0], 0xFF, Z_UINT64_SIZE * 3);
60 |
61 | _machine = new Machine(_abi, _videoOutputView.buffer, _audioOutputPlayer->buffer(), _keyboardBuffer);
62 |
63 | /*-----------------.
64 | | Load needed ROMs |
65 | '-----------------*/
66 | Zeta::Size index = _abi->rom_count;
67 | NSBundle *bundle = [NSBundle mainBundle];
68 | ROM *rom;
69 |
70 | while (index)
71 | {
72 | rom = &_abi->roms[--index];
73 |
74 | NSData *ROM = [NSData dataWithContentsOfFile: [bundle
75 | pathForResource: [NSString stringWithUTF8String: rom->file_name]
76 | ofType: @"rom"
77 | inDirectory: @"ROMs"]];
78 |
79 | _machine->write_memory(rom->base_address, (void *)[ROM bytes], rom->size);
80 | }
81 |
82 | _keyboardState.value_uint64 = Type::maximum;
83 | _attachInputBuffer = NO;
84 |
85 | [_videoOutputView start];
86 | //_audioOutputPlayer->start();
87 | _machine->power(ON);
88 | }
89 |
90 |
91 | @end
92 |
--------------------------------------------------------------------------------
/sources/iOS/MainController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/MainController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | @interface MainController : UIResponder
10 |
11 | @property (nonatomic, retain) UIWindow *window;
12 |
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/sources/iOS/MainController.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/MainController.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "MainController.h"
8 |
9 |
10 | @implementation MainController
11 |
12 |
13 | - (BOOL) application: (UIApplication *) application
14 | willFinishLaunchingWithOptions: (NSDictionary *) launchOptions
15 | {
16 | [application setStatusBarStyle: UIStatusBarStyleLightContent];
17 | return YES;
18 | }
19 |
20 |
21 | - (BOOL) application: (UIApplication *) application
22 | didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
23 | {
24 | // Override point for customization after application launch.
25 | return YES;
26 | }
27 |
28 |
29 | - (void) applicationWillResignActive: (UIApplication *) application
30 | {
31 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
32 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
33 | }
34 |
35 |
36 | - (void) applicationDidEnterBackground: (UIApplication *) application
37 | {
38 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
39 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
40 | }
41 |
42 |
43 | - (void) applicationWillEnterForeground: (UIApplication *) application
44 | {
45 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
46 | }
47 |
48 |
49 | - (void) applicationDidBecomeActive: (UIApplication *) application
50 | {
51 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
52 | }
53 |
54 |
55 | - (void) applicationWillTerminate: (UIApplication *) application
56 | {
57 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
58 | }
59 |
60 |
61 | @end
62 |
--------------------------------------------------------------------------------
/sources/iOS/MainViewController.h:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/MainViewController.h
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 |
9 | @interface MainViewController : UIViewController {
10 | NSMutableArray* _machineViewControllers;
11 | }
12 |
13 |
14 | - (IBAction) showTapeRecorder: (id) sender;
15 | - (IBAction) showKeyboard: (id) sender;
16 | - (IBAction) showJoystick: (id) sender;
17 | @end
18 |
19 |
--------------------------------------------------------------------------------
/sources/iOS/MainViewController.mm:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/MainViewController.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import "MainViewController.h"
8 | #import "MachineViewController.h"
9 | #import "MachineABI.h"
10 |
11 |
12 | @implementation MainViewController
13 |
14 |
15 | - (void) newMachineWithABI: (MachineABI *) ABI
16 | {
17 | MachineViewController *controller = [[MachineViewController alloc] initWithMachineABI: ABI];
18 |
19 | [_machineViewControllers addObject: controller];
20 |
21 | UIView *view = controller.view;
22 |
23 | view.frame = CGRectMake(0.0, 0.0, 352.0, 296);
24 |
25 | [self.view addSubview: view];
26 | [controller release];
27 | }
28 |
29 |
30 |
31 | - (void) viewDidLoad
32 | {
33 | [super viewDidLoad];
34 | [self newMachineWithABI: &machine_abi_table[4]];
35 | }
36 |
37 |
38 | - (void) didReceiveMemoryWarning
39 | {
40 | [super didReceiveMemoryWarning];
41 | // Dispose of any resources that can be recreated.
42 | }
43 |
44 |
45 | # pragma mark - IBAction
46 |
47 |
48 | - (IBAction) showTapeRecorder: (id) sender
49 | {
50 | }
51 |
52 |
53 | - (IBAction) showKeyboard: (id) sender
54 | {
55 | }
56 |
57 |
58 | - (IBAction) showJoystick: (id) sender
59 | {
60 | }
61 |
62 |
63 | @end
64 |
--------------------------------------------------------------------------------
/sources/iOS/Prefix.pch:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / OS X/Prefix.pch
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the GNU General Public License v3.
5 | |_*/
6 |
7 | #define CPU_Z80_USE_LOCAL_HEADER
8 |
9 | #ifdef __OBJC__
10 | # define Z_SUPPORT_CG_GEOMETRY
11 | //# define Z_USE_REAL_FLOAT
12 | # define STRING(...) [NSString stringWithFormat: __VA_ARGS__]
13 | # define _(string) NSLocalizedString(@string, nil)
14 | #endif
15 |
--------------------------------------------------------------------------------
/sources/iOS/TapeRecorderView.h:
--------------------------------------------------------------------------------
1 | //
2 | // TapeRecorderView.h
3 | // μZX (iOS)
4 | //
5 | // Created by Manuel on 06/08/15.
6 | // Copyright (c) 2015 Manuel Sainz de Baranda y Goñi. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface TapeRecorderView : UIView
12 |
13 |
14 |
15 |
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/sources/iOS/TapeRecorderView.m:
--------------------------------------------------------------------------------
1 | //
2 | // TapeRecorderView.m
3 | // μZX (iOS)
4 | //
5 | // Created by Manuel on 06/08/15.
6 | // Copyright (c) 2015 Manuel Sainz de Baranda y Goñi. All rights reserved.
7 | //
8 |
9 | #import "TapeRecorderView.h"
10 |
11 | @implementation TapeRecorderView
12 |
13 |
14 | - (id) initWithFrame: (CGRect) frame
15 | {
16 | if ((self = [super initWithFrame: frame]))
17 | {
18 | self.backgroundColor = [UIColor redColor];
19 | }
20 |
21 | return self;
22 | }
23 |
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/sources/iOS/main.m:
--------------------------------------------------------------------------------
1 | /* _________ ___
2 | _____ \_ /\ \/ / iOS/main.m
3 | | | |_/ /__> < Copyright © 2014-2015 Manuel Sainz de Baranda y Goñi.
4 | | ____________/\__\ Released under the terms of the GNU General Public License v3.
5 | |_*/
6 |
7 | #import
8 | #import "MainController.h"
9 |
10 |
11 | int main(int argc, char **argv)
12 | {
13 | @autoreleasepool
14 | {return UIApplicationMain(argc, argv, nil, NSStringFromClass([MainController class]));}
15 | }
16 |
--------------------------------------------------------------------------------