-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDisplayOpenGLView.h
More file actions
255 lines (197 loc) · 7.59 KB
/
DisplayOpenGLView.h
File metadata and controls
255 lines (197 loc) · 7.59 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/* DisplayOpenGLView.h: Implementation for the DisplayOpenGLView class
Copyright (c) 2006-2007 Fredrick Meunier
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
E-mail: fredm@spamcop.net
*/
#import <Cocoa/Cocoa.h>
#import <MetalKit/MetalKit.h>
#import <QuartzCore/QuartzCore.h>
#include <libspectrum.h>
#include "input.h"
#include "machines/specplus3.h"
#include "peripherals/disk/beta.h"
#include "ui/cocoa/cocoadisplay.h"
#include "ui/ui.h"
#define MAX_SCREEN_BUFFERS 2
@class Emulator;
@class Texture;
@interface DisplayOpenGLView : MTKView <MTKViewDelegate>
{
/* Two CPU-side screen buffers; the dirty machinery in
-uploadDirtyToTexture keeps both consistent across frames. */
Cocoa_Texture screenTex[MAX_SCREEN_BUFFERS];
/* Matching MTLTextures uploaded to the GPU. */
id<MTLTexture> screenTexMTL[MAX_SCREEN_BUFFERS];
int currentScreenTex;
Texture *redCassette;
Texture *greenCassette;
Texture *redMdr;
Texture *greenMdr;
Texture *redDisk;
Texture *greenDisk;
BOOL screenTexInitialised;
ui_statusbar_state disk_state;
ui_statusbar_state mdr_state;
ui_statusbar_state tape_state;
NSLock *view_lock;
float target_ratio;
Emulator *real_emulator;
Emulator *proxy_emulator;
NSConnection *kitConnection;
/* Metal rendering state. */
id<MTLDevice> mtlDevice;
id<MTLCommandQueue> commandQueue;
id<MTLRenderPipelineState> pipelineState;
/* Reusable CPU-side staging buffer for the BGR5A1 -> BGRA8 conversion
done at upload time. Sized to a full screen on first use. */
uint32_t *conversionBuffer;
size_t conversionBufferPixels;
/* Frame pacing is driven by MTKView's built-in CADisplayLink, which
calls -drawInMTKView: each vsync. -displayLinkStart / -displayLinkStop
toggle self.paused (always on the main thread). */
}
+(DisplayOpenGLView *) instance;
-(IBAction) zoom:(id)sender;
-(void) createTexture:(Cocoa_Texture*)newScreen;
-(void) destroyTexture;
-(void) setServer:(id)anObject;
-(id) initWithFrame:(NSRect)frameRect;
-(void) awakeFromNib;
-(NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
-(void) loadPicture:(NSString *) name
greenTex:(Texture*) greenTexture
redTex:(Texture*) redTexture
xOrigin:(int) x
yOrigin:(int) y;
-(void) openFile:(const char *)filename;
-(void) snapOpen:(const char *)filename;
-(void) tapeOpen:(const char *)filename;
-(void) tapeWrite:(const char *)filename;
-(void) tapeTogglePlay;
-(void) tapeToggleRecord;
-(void) tapeRewind;
-(void) tapeClear;
-(int) tapeClose;
-(void) tapeWindowInitialise;
-(void) cocoaBreak;
-(void) pause;
-(void) unpause;
-(void) reset;
-(void) hard_reset;
-(void) nmi;
-(int) checkMediaChanged;
-(void) diskInsertNew:(int)which;
-(void) diskInsert:(const char *)filename inDrive:(int)which;
-(void) diskEject:(int)drive;
-(void) diskSave:(int)drive saveAs:(bool)saveas;
-(int) diskWrite:(int)drive saveAs:(bool)saveas;
-(void) diskFlip:(int)drive side:(int)flip;
-(void) diskWriteProtect:(int)which protect:(int)write;
-(void) snapshotWrite:(const char *)filename;
-(void) screenshotScrRead:(const char *)filename;
-(void) screenshotScrWrite:(const char *)filename;
-(void) screenshotWrite:(const char *)filename;
-(void) profileStart;
-(void) profileFinish:(const char *)filename;
-(void) settingsSave;
-(void) settingsResetDefaults;
-(void) joystickToggleKeyboard;
-(void) keyboardToggleRecreatedZXSpectrum;
-(void) keyboardToggleArrowsShifted;
-(int) rzxStartPlayback:(const char *)filename;
-(void) rzxInsertSnap;
-(void) rzxRollback;
-(int) rzxStartRecording:(const char *)filename embedSnapshot:(int)flag;
-(void) rzxStop;
-(int) rzxContinueRecording:(const char *)filename;
-(int) rzxFinaliseRecording:(const char *)filename;
-(void) movieStartRecording:(const char *)filename;
-(void) movieTogglePause;
-(void) movieStop;
-(void) didaktik80Snap;
-(void) multifaceRedButton;
-(void) if1MdrNew:(int)drive;
-(void) if1MdrInsert:(const char *)filename inDrive:(int)drive;
-(void) if1MdrCartEject:(int)drive;
-(void) if1MdrCartSave:(int)drive saveAs:(bool)saveas;
-(void) if1MdrWriteProtect:(int)w inDrive:(int)drive;
-(int) if2Insert:(const char *)filename;
-(void) if2Eject;
-(int) dckInsert:(const char *)filename;
-(void) dckEject;
-(void) psgStart:(const char *)psgfile;
-(void) psgStop;
-(int) simpleideInsert:(const char *)filename inUnit:(libspectrum_ide_unit)unit;
-(int) simpleideCommit:(libspectrum_ide_unit)unit;
-(int) simpleideEject:(libspectrum_ide_unit)unit;
-(int) zxataspInsert:(const char *)filename inUnit:(libspectrum_ide_unit)unit;
-(int) zxataspCommit:(libspectrum_ide_unit)unit;
-(int) zxataspEject:(libspectrum_ide_unit)unit;
-(int) zxcfInsert:(const char *)filename;
-(int) zxcfCommit;
-(int) zxcfEject;
-(int) divideInsert:(const char *)filename inUnit:(libspectrum_ide_unit)unit;
-(int) divideCommit:(libspectrum_ide_unit)unit;
-(int) divideEject:(libspectrum_ide_unit)unit;
-(int) divmmcInsert:(const char *)filename;
-(int) divmmcCommit;
-(int) divmmcEject;
-(int) zxmmcInsert:(const char *)filename;
-(int) zxmmcCommit;
-(int) zxmmcEject;
-(void) setDiskState:(NSNumber*)state;
-(void) setTapeState:(NSNumber*)state;
-(void) setMdrState:(NSNumber*)state;
-(ui_confirm_save_t) confirmSave:(NSString*)theMessage;
-(int) confirm:(NSString*)theMessage;
-(int) tapeWrite;
-(int) diskWrite:(int)which saveAs:(bool)saveas;
-(int) if1MdrWrite:(int)which saveAs:(bool)saveas;
-(ui_confirm_joystick_t) confirmJoystick:(libspectrum_joystick)type inputs:(int)theInputs;
-(void) debuggerActivate;
-(void) mouseMoved:(NSEvent *)theEvent;
-(void) mouseDown:(NSEvent *)theEvent;
-(void) mouseUp:(NSEvent *)theEvent;
-(void) rightMouseDown:(NSEvent *)theEvent;
-(void) rightMouseUp:(NSEvent *)theEvent;
-(void) otherMouseDown:(NSEvent *)theEvent;
-(void) otherMouseUp:(NSEvent *)theEvent;
-(void) flagsChanged:(NSEvent *)theEvent;
-(void) keyDown:(NSEvent *)theEvent;
-(void) keyUp:(NSEvent *)theEvent;
-(BOOL) acceptsFirstResponder;
-(BOOL) becomeFirstResponder;
-(BOOL) resignFirstResponder;
-(BOOL) isFlipped;
-(BOOL) windowShouldClose:(id)window;
-(void) windowDidResignKey:(NSNotification *)notification;
-(void) windowChangedScreen:(NSNotification*)inNotification;
-(void) displayLinkStop;
-(void) displayLinkStart;
@end
/* Helper category used by every utility controller in §Affected Windows
(spec 004) to pin its panel to a parent window and reverse that
relationship at teardown. Centralizing the reconciliation removes
the previously-duplicated 7-line block in seven controllers. */
@interface NSWindow (FuseChildPinning)
/* Make `self` a child window of `parent` with NSWindowAbove ordering.
If `self` is already a child of `parent`, this is a no-op. If `self`
has a different parent, it is detached first. Passing `nil` or
`self` for `parent` is a no-op. */
- (void)pinAsChildOf:(NSWindow *)parent;
/* Remove `self` from whatever parent it currently has. No-op if there
is no parent. */
- (void)unpinFromParent;
@end