ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/Display.h
Revision: 1.4
Committed: 2005-06-27T19:55:48Z (19 years, 3 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: VERSION_4_2
Changes since 1.3: +1 -1 lines
Log Message:
updated copyright dates

File Contents

# Content
1 /*
2 * Display.h - C64 graphics display, emulator window handling
3 *
4 * Frodo (C) 1994-1997,2002-2005 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #ifndef _DISPLAY_H
22 #define _DISPLAY_H
23
24 #ifdef __BEOS__
25 #include <InterfaceKit.h>
26 #endif
27
28 #ifdef AMIGA
29 #include <graphics/rastport.h>
30 #endif
31
32 #ifdef HAVE_SDL
33 struct SDL_Surface;
34 #endif
35
36 #ifdef WIN32
37 #include <ddraw.h>
38 #endif
39
40 #ifdef __riscos__
41 #include "ROlib.h"
42 #endif
43
44
45 // Display dimensions
46 #if defined(SMALL_DISPLAY)
47 const int DISPLAY_X = 0x168;
48 const int DISPLAY_Y = 0x110;
49 #else
50 const int DISPLAY_X = 0x180;
51 const int DISPLAY_Y = 0x110;
52 #endif
53
54
55 class C64Window;
56 class C64Screen;
57 class C64;
58 class Prefs;
59
60 // Class for C64 graphics display
61 class C64Display {
62 public:
63 C64Display(C64 *the_c64);
64 ~C64Display();
65
66 void Update(void);
67 void UpdateLEDs(int l0, int l1, int l2, int l3);
68 void Speedometer(int speed);
69 uint8 *BitmapBase(void);
70 int BitmapXMod(void);
71 #ifdef __riscos__
72 void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick, uint8 *joystick2);
73 #else
74 void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick);
75 #endif
76 bool NumLock(void);
77 void InitColors(uint8 *colors);
78 void NewPrefs(Prefs *prefs);
79
80 C64 *TheC64;
81
82 #ifdef __BEOS__
83 void Pause(void);
84 void Resume(void);
85 #endif
86
87 #ifdef __riscos__
88 void ModeChange(void);
89 unsigned int *GetColourTable(void); // returns pointer to mode_cols
90 bool CheckForUnpause(bool CheckLastState);
91
92 ROScreen *screen;
93 Joy_Keys JoystickKeys[2]; // it's easier making the joystick keys public
94 #endif
95
96 #ifdef __unix
97 bool quit_requested;
98 #endif
99
100 private:
101 int led_state[4];
102 int old_led_state[4];
103
104 #ifdef __BEOS__
105 C64Window *the_window; // One of these is NULL
106 C64Screen *the_screen;
107 bool using_screen; // Flag: Using the_screen
108 key_info old_key_info;
109 int draw_bitmap; // Number of bitmap for the VIC to draw into
110 #endif
111
112 #ifdef AMIGA
113 void draw_led_bar(void); // Draw LED bar at the bottom of the window
114 void draw_led(int num, int state); // Draw one LED
115
116 struct Window *the_window; // Pointer to C64 display window
117 struct Screen *the_screen; // The window's screen
118 struct RastPort *the_rp; // The window's RastPort
119 struct VisualInfo *the_visual_info;
120 struct Menu *the_menus;
121 struct TextFont *led_font;
122 struct TextFont *speedo_font;
123 struct RastPort temp_rp; // For WritePixelArray8()
124 struct BitMap *temp_bm;
125 uint8 *chunky_buf; // Chunky buffer for drawing into
126 LONG pens[16]; // Pens for C64 colors
127 int xo, yo; // Window X/Y border size
128 struct FileRequester *open_req, *save_req; // File requesters for load/save snapshot
129 #endif
130
131 #ifdef HAVE_SDL
132 char speedometer_string[16]; // Speedometer text
133 void draw_string(SDL_Surface *s, int x, int y, const char *str, uint8 front_color, uint8 back_color);
134 #endif
135
136 #ifdef __unix
137 void draw_led(int num, int state); // Draw one LED
138 static void pulse_handler(...); // LED error blinking
139 #endif
140
141 #ifdef WIN32
142 public:
143 long ShowRequester(const char *str, const char *button1, const char *button2 = NULL);
144 void WaitUntilActive();
145 void NewPrefs();
146 void Pause();
147 void Resume();
148 void Quit();
149
150 struct DisplayMode {
151 int x;
152 int y;
153 int depth;
154 BOOL modex;
155 };
156 int GetNumDisplayModes() const;
157 const DisplayMode *GetDisplayModes() const;
158
159 private:
160 // Window members.
161 void ResetKeyboardState();
162 BOOL MakeWindow();
163 static LRESULT CALLBACK StaticWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
164 long WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
165 static int VirtKey2C64(int virtkey, DWORD keydata);
166 BOOL CalcViewPort();
167 BOOL SetupWindow();
168 BOOL SetupWindowMode(BOOL full_screen);
169 BOOL RestoreWindow();
170 BOOL ResizeWindow(int side, RECT *pRect);
171 void WindowTitle();
172 void CreateObjects();
173 void DeleteObjects();
174
175 // DirectDraw management members.
176 BOOL StartDirectDraw();
177 BOOL ResumeDirectDraw();
178 BOOL ResetDirectDraw();
179 BOOL StopDirectDraw();
180 static HRESULT CALLBACK EnumModesCallback(LPDDSURFACEDESC pDDSD, LPVOID lpContext);
181 HRESULT EnumModesCallback(LPDDSURFACEDESC pDDSD);
182 static int CompareModes(const void *e1, const void *e2);
183 BOOL Fail(const char *message);
184
185 // DirectDraw worker members.
186 BOOL SetPalettes();
187 BOOL BuildColorTable();
188 BOOL CopySurface(RECT &rcWork);
189 BOOL FlipSurfaces();
190 BOOL EraseSurfaces();
191 BOOL RestoreSurfaces();
192
193 void draw_led_bar(void); // Draw LED bar on the window
194 void draw_leds(BOOL force = false); // Draw LEDs if force or changed
195 void led_rect(int n, RECT &rc, RECT &led); // Compute LED rectangle
196 void InsertNextDisk(); // should be a common func
197 BOOL FileNameDialog(char *prefs_path, BOOL save = false);
198 void OfferSave(); // Offer chance to save changes
199
200 UBYTE *chunky_buf; // Chunky buffer for drawing
201 BOOL active; // is application active?
202 BOOL paused; // is application paused?
203 BOOL waiting; // is application waiting?
204 DWORD windowed_style; // style of windowed window
205 DWORD fullscreen_style; // style of fullscreen window
206 char failure_message[128]; // what when wrong
207 int speed_index; // look ma, no hands
208 BOOL show_leds; // cached prefs option
209 BOOL full_screen; // cached prefs option
210 BOOL in_constructor; // if we are being contructed
211 BOOL in_destructor; // if we are being destroyed
212
213 LPDIRECTDRAW pDD; // DirectDraw object
214 LPDIRECTDRAWSURFACE pPrimary; // DirectDraw primary surface
215 LPDIRECTDRAWSURFACE pBack; // DirectDraw back surface
216 LPDIRECTDRAWSURFACE pWork; // DirectDraw working surface
217 LPDIRECTDRAWCLIPPER pClipper; // DirectDraw clipper
218 LPDIRECTDRAWPALETTE pPalette; // DirectDraw palette
219
220 DWORD colors[256]; // our palette colors
221 int colors_depth; // depth of the colors table
222 #endif
223
224 #ifdef __riscos__
225 unsigned int mode_cols[256]; // Colours in the current mode corresponding to C64's
226 uint8 *bitmap;
227 uint32 lastkeys[8]; // bitfield describing keys pressed last time.
228 #endif
229 };
230
231
232 // Exported functions
233 extern long ShowRequester(char *str, char *button1, char *button2 = NULL);
234
235
236 #endif