Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Display.h

Go to the documentation of this file.
00001 /*
00002  *  Display.h - C64 graphics display, emulator window handling
00003  *
00004  *  Frodo (C) 1994-1997 Christian Bauer
00005  */
00006 
00007 #ifndef _DISPLAY_H
00008 #define _DISPLAY_H
00009 
00010 #ifdef __BEOS__
00011 #include <InterfaceKit.h>
00012 #endif
00013 
00014 #ifdef AMIGA
00015 #include <graphics/rastport.h>
00016 #endif
00017 
00018 #ifdef WIN32
00019 #include <ddraw.h>
00020 #endif
00021 
00022 #ifdef __riscos__
00023 #include "ROlib.h"
00024 #endif
00025 
00026 #ifdef __SYMBIAN32__
00027 #include <e32keys.h>
00028 #include <w32std.h>
00029 #endif
00030 
00031 // Display dimensions
00032 #if defined(SMALL_DISPLAY)
00033 const int DISPLAY_X = 0x168;
00034 const int DISPLAY_Y = 0x110;
00035 #else
00036 
00037 #if COLOR_DEPTH == 4
00038 const int DISPLAY_X = 0x180/2;  // use half the X size of nibbled
00039 #elif COLOR_DEPTH == 8
00040 const int DISPLAY_X = 0x180;
00041 #else
00042 COLOR_DEPTH not defined!
00043 #endif
00044 
00045 const int DISPLAY_Y = 0x110;    // 272 dec
00046 
00047 #endif
00048 
00049 #include "C64.h"
00050 #include "VIC.h"
00051 
00052 class C64Window;
00053 class C64Screen;
00054 class C64;
00055 class Prefs;
00056 
00060 class C64Display {
00061 public:
00062         C64Display(C64 *the_c64);
00063         ~C64Display();
00064 
00065         void Update(void);
00066         void UpdateLEDs(int l0, int l1, int l2, int l3);
00067         void Speedometer(int speed);
00068         uint8 *BitmapBase();
00069         int BitmapXMod() const;
00070 #ifdef __riscos__
00071         void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick, uint8 *joystick2);
00072 #else
00073         void PollKeyboard(uint8 *key_matrix, uint8 *rev_matrix, uint8 *joystick);
00074 #endif
00075 #ifndef __SYMBIAN32__
00076         bool NumLock(void);
00077 #endif
00078         void InitColors(uint8 *colors);
00079         void NewPrefs(Prefs *prefs);
00080 
00081         C64 *TheC64;
00082 
00083 #ifdef __BEOS__
00084         void Pause(void);
00085         void Resume(void);
00086 #endif
00087 
00088 #ifdef __riscos__
00089         void ModeChange(void);
00090         unsigned int *GetColourTable(void);     // returns pointer to mode_cols
00091         bool CheckForUnpause(bool CheckLastState);
00092 
00093         ROScreen *screen;
00094         Joy_Keys JoystickKeys[2];               // it's easier making the joystick keys public
00095 #endif
00096 
00097 #ifdef __unix
00098         bool quit_requested;
00099 #endif
00100 
00102 #ifdef __SYMBIAN32__
00103         static int VirtKey2C64(const TKeyEvent& virtkey, TUint8& aJoyKey);
00104         void ResetKeyboardState();
00105 public:
00106         // methods
00107         bool BuildColorTable();
00108 private:
00109     void draw_leds(TBool force = EFalse);
00110 
00111         // vars
00112 public:
00113         bool quit_requested;
00114 private:
00115 //      long colors[256];                       // our palette colors
00116         uint8 colors[256];                      // our palette colors
00117         bool in_constructor;                    // if we are being contructed 
00118         int max_speed;
00119         int iSpeedCount;
00120         bool colors_changed;
00121         int colors_depth;                       // depth of the colors table
00122 #endif  //__SYMBIAN32__
00123 
00124 
00126 private:
00127         int led_state[4];
00128         int old_led_state[4];
00129 
00130 #ifdef __BEOS__
00131         C64Window *the_window;  // One of these is NULL
00132         C64Screen *the_screen;
00133         bool using_screen;              // Flag: Using the_screen
00134         key_info old_key_info;
00135         int draw_bitmap;                // Number of bitmap for the VIC to draw into
00136 #endif
00137 
00138 #ifdef AMIGA
00139         void draw_led_bar(void);        // Draw LED bar at the bottom of the window
00140         void draw_led(int num, int state);      // Draw one LED
00141 
00142         struct Window *the_window;      // Pointer to C64 display window
00143         struct Screen *the_screen;      // The window's screen
00144         struct RastPort *the_rp;        // The window's RastPort
00145         struct VisualInfo *the_visual_info;
00146         struct Menu *the_menus;
00147         struct TextFont *led_font;
00148         struct TextFont *speedo_font;
00149         struct RastPort temp_rp;        // For WritePixelArray8()
00150         struct BitMap *temp_bm;
00151         uint8 *chunky_buf;                      // Chunky buffer for drawing into
00152         LONG pens[16];                          // Pens for C64 colors
00153         int xo, yo;                                     // Window X/Y border size
00154         struct FileRequester *open_req, *save_req;      // File requesters for load/save snapshot
00155 #endif
00156 
00157 #ifdef __unix
00158         void draw_led(int num, int state);      // Draw one LED
00159         static void pulse_handler(int);         // LED error blinking
00160 #endif
00161 
00162 #ifdef WIN32
00163 public:
00164         long ShowRequester(const char *str, const char *button1, const char *button2 = NULL);
00165         void WaitUntilActive();
00166         void NewPrefs();
00167         void Pause();
00168         void Resume();
00169         void Quit();
00170 
00171         struct DisplayMode {
00172                 int x;
00173                 int y;
00174                 int depth;
00175                 BOOL modex;
00176         };
00177         int GetNumDisplayModes() const;
00178         const DisplayMode *GetDisplayModes() const;
00179 
00180 private:
00181         // Window members.
00182         void ResetKeyboardState();
00183         BOOL MakeWindow();
00184         static LRESULT CALLBACK StaticWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00185         long WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
00186         static int VirtKey2C64(int virtkey, DWORD keydata);
00187         BOOL CalcViewPort();
00188         BOOL SetupWindow();
00189         BOOL SetupWindowMode(BOOL full_screen);
00190         BOOL RestoreWindow();
00191         BOOL ResizeWindow(int side, RECT *pRect);
00192         void WindowTitle();
00193         void CreateObjects();
00194         void DeleteObjects();
00195 
00196         // DirectDraw management members.
00197         BOOL StartDirectDraw();
00198         BOOL ResumeDirectDraw();
00199         BOOL ResetDirectDraw();
00200         BOOL StopDirectDraw();
00201         static HRESULT CALLBACK EnumModesCallback(LPDDSURFACEDESC pDDSD, LPVOID lpContext);
00202         HRESULT EnumModesCallback(LPDDSURFACEDESC pDDSD);
00203         static int CompareModes(const void *e1, const void *e2);
00204         BOOL Fail(const char *message);
00205 
00206         // DirectDraw worker members.
00207         BOOL SetPalettes();
00208         BOOL BuildColorTable();
00209         BOOL CopySurface(RECT &rcWork);
00210         BOOL FlipSurfaces();
00211         BOOL EraseSurfaces();
00212         BOOL RestoreSurfaces();
00213 
00214         void draw_led_bar(void);                // Draw LED bar on the window
00215         void draw_leds(BOOL force = false);     // Draw LEDs if force or changed
00216         void led_rect(int n, RECT &rc, RECT &led); // Compute LED rectangle
00217         void InsertNextDisk();                  // should be a common func
00218         BOOL FileNameDialog(char *prefs_path, BOOL save = false);
00219         void OfferSave();                       // Offer chance to save changes
00220 
00221         UBYTE *chunky_buf;                      // Chunky buffer for drawing
00222         BOOL active;                            // is application active?
00223         BOOL paused;                            // is application paused?
00224         BOOL waiting;                           // is application waiting?
00225         DWORD windowed_style;                   // style of windowed window
00226         DWORD fullscreen_style;                 // style of fullscreen window
00227         char failure_message[128];              // what when wrong
00228         int speed_index;                        // look ma, no hands
00229         BOOL show_leds;                         // cached prefs option
00230         BOOL full_screen;                       // cached prefs option
00231         BOOL in_constructor;                    // if we are being contructed 
00232         BOOL in_destructor;                     // if we are being destroyed
00233 
00234         LPDIRECTDRAW pDD;                       // DirectDraw object
00235         LPDIRECTDRAWSURFACE pPrimary;           // DirectDraw primary surface
00236         LPDIRECTDRAWSURFACE pBack;              // DirectDraw back surface
00237         LPDIRECTDRAWSURFACE pWork;              // DirectDraw working surface
00238         LPDIRECTDRAWCLIPPER pClipper;           // DirectDraw clipper
00239         LPDIRECTDRAWPALETTE pPalette;           // DirectDraw palette
00240 
00241         DWORD colors[256];                      // our palette colors
00242         int colors_depth;                       // depth of the colors table
00243 #endif
00244 
00245 #ifdef __riscos__
00246         unsigned int mode_cols[256];    // Colours in the current mode corresponding to C64's
00247         uint8 *bitmap;
00248         uint32 lastkeys[8];             // bitfield describing keys pressed last time.
00249 #endif
00250 };
00251 
00252 
00253 // Exported functions
00254 extern long ShowRequester(char *str, char *button1, char *button2 = NULL);
00255 
00256 
00257 #endif

Generated on Tue Feb 8 04:07:45 2005 for E32frodo by doxygen 1.3.3