-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay.h
More file actions
executable file
·225 lines (188 loc) · 5.88 KB
/
Copy pathDisplay.h
File metadata and controls
executable file
·225 lines (188 loc) · 5.88 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
/*
* Display.h - C64 graphics display, emulator window handling
*
* Frodo (C) 1994-1997,2002 Christian Bauer
*/
#ifndef _DISPLAY_H
#define _DISPLAY_H
#ifdef __BEOS__
#include <InterfaceKit.h>
#endif
#ifdef AMIGA
#include <graphics/rastport.h>
#endif
#ifdef HAVE_SDL
struct SDL_Surface;
#endif
#ifdef WIN32
#include <ddraw.h>
#endif
#ifdef __riscos__
#include "ROlib.h"
#endif
// Display dimensions
#if defined(SMALL_DISPLAY)
const int DISPLAY_X = 0x168;
const int DISPLAY_Y = 0x110;
#else
const int DISPLAY_X = 0x180;
const int DISPLAY_Y = 0x110;
#endif
class C64Window;
class C64Screen;
class C64;
class Prefs;
// Class for C64 graphics display
class C64Display {
public:
C64Display(C64 *the_c64);
~C64Display();
void Update(void);
#ifdef AMIGA
void UpdateScanline(uint8 *line, int line_number);
#endif
void UpdateLEDs(int l0, int l1, int l2, int l3);
void Speedometer(int speed);
uint8 *BitmapBase(void);
int BitmapXMod(void);
#ifdef __riscos__
void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick, uint8 *joystick2);
#else
void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick);
#endif
bool NumLock(void);
void InitColors(uint8 *colors);
void NewPrefs(Prefs *prefs);
C64 *TheC64;
#ifdef __BEOS__
void Pause(void);
void Resume(void);
#endif
#ifdef __riscos__
void ModeChange(void);
unsigned int *GetColourTable(void); // returns pointer to mode_cols
bool CheckForUnpause(bool CheckLastState);
ROScreen *screen;
Joy_Keys JoystickKeys[2]; // it's easier making the joystick keys public
#endif
#ifdef __unix
bool quit_requested;
#endif
private:
int led_state[4];
int old_led_state[4];
#ifdef __BEOS__
C64Window *the_window; // One of these is NULL
C64Screen *the_screen;
bool using_screen; // Flag: Using the_screen
key_info old_key_info;
int draw_bitmap; // Number of bitmap for the VIC to draw into
#endif
#ifdef AMIGA
void draw_led_bar(void); // Draw LED bar at the bottom of the window
void draw_led(int num, int state); // Draw one LED
struct Window *the_window; // Pointer to C64 display window
struct Screen *the_screen; // The window's screen
struct RastPort *the_rp; // The window's RastPort
struct VisualInfo *the_visual_info;
struct Menu *the_menus;
struct TextFont *led_font;
struct TextFont *speedo_font;
struct RastPort temp_rp; // For WritePixelArray8()
struct BitMap *temp_bm;
uint8 *chunky_buf; // Chunky buffer for drawing into
LONG pens[16]; // Pens for C64 colors
int xo, yo; // Window X/Y border size
struct FileRequester *open_req, *save_req; // File requesters for load/save snapshot
#endif
#ifdef HAVE_SDL
char speedometer_string[16]; // Speedometer text
void draw_string(SDL_Surface *s, int x, int y, const char *str, uint8 front_color, uint8 back_color);
#endif
#ifdef __unix
void draw_led(int num, int state); // Draw one LED
static void pulse_handler(...); // LED error blinking
#endif
#ifdef WIN32
public:
long ShowRequester(const char *str, const char *button1, const char *button2 = NULL);
void WaitUntilActive();
void NewPrefs();
void Pause();
void Resume();
void Quit();
struct DisplayMode {
int x;
int y;
int depth;
BOOL modex;
};
int GetNumDisplayModes() const;
const DisplayMode *GetDisplayModes() const;
private:
// Window members.
void ResetKeyboardState();
BOOL MakeWindow();
static LRESULT CALLBACK StaticWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
long WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static int VirtKey2C64(int virtkey, DWORD keydata);
BOOL CalcViewPort();
BOOL SetupWindow();
BOOL SetupWindowMode(BOOL full_screen);
BOOL RestoreWindow();
BOOL ResizeWindow(int side, RECT *pRect);
void WindowTitle();
void CreateObjects();
void DeleteObjects();
// DirectDraw management members.
BOOL StartDirectDraw();
BOOL ResumeDirectDraw();
BOOL ResetDirectDraw();
BOOL StopDirectDraw();
static HRESULT CALLBACK EnumModesCallback(LPDDSURFACEDESC pDDSD, LPVOID lpContext);
HRESULT EnumModesCallback(LPDDSURFACEDESC pDDSD);
static int CompareModes(const void *e1, const void *e2);
BOOL Fail(const char *message);
// DirectDraw worker members.
BOOL SetPalettes();
BOOL BuildColorTable();
BOOL CopySurface(RECT &rcWork);
BOOL FlipSurfaces();
BOOL EraseSurfaces();
BOOL RestoreSurfaces();
void draw_led_bar(void); // Draw LED bar on the window
void draw_leds(BOOL force = false); // Draw LEDs if force or changed
void led_rect(int n, RECT &rc, RECT &led); // Compute LED rectangle
void InsertNextDisk(); // should be a common func
BOOL FileNameDialog(char *prefs_path, BOOL save = false);
void OfferSave(); // Offer chance to save changes
UBYTE *chunky_buf; // Chunky buffer for drawing
BOOL active; // is application active?
BOOL paused; // is application paused?
BOOL waiting; // is application waiting?
DWORD windowed_style; // style of windowed window
DWORD fullscreen_style; // style of fullscreen window
char failure_message[128]; // what when wrong
int speed_index; // look ma, no hands
BOOL show_leds; // cached prefs option
BOOL full_screen; // cached prefs option
BOOL in_constructor; // if we are being contructed
BOOL in_destructor; // if we are being destroyed
LPDIRECTDRAW pDD; // DirectDraw object
LPDIRECTDRAWSURFACE pPrimary; // DirectDraw primary surface
LPDIRECTDRAWSURFACE pBack; // DirectDraw back surface
LPDIRECTDRAWSURFACE pWork; // DirectDraw working surface
LPDIRECTDRAWCLIPPER pClipper; // DirectDraw clipper
LPDIRECTDRAWPALETTE pPalette; // DirectDraw palette
DWORD colors[256]; // our palette colors
int colors_depth; // depth of the colors table
#endif
#ifdef __riscos__
unsigned int mode_cols[256]; // Colours in the current mode corresponding to C64's
uint8 *bitmap;
uint32 lastkeys[8]; // bitfield describing keys pressed last time.
#endif
};
// Exported functions
extern long ShowRequester(char *str, char *button1, char *button2 = NULL);
#endif