1 #ifndef __PD_H__ 2 #define __PD_H__ 3 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include "md.h" 7 8 // DGen/SDL v1.17+ 9 // Platform-dependent interface 10 // Your platform implementation needs to define all these functions and 11 // variables! 12 13 // Return the number of microseconds elapsed since an unspecified time. 14 unsigned long pd_usecs(void); 15 // This is the struct bmap setup by your implementation. 16 // It should be 336x240 (or 336x256 in PAL mode), in 8, 12, 15, 16, 24 or 32 17 // bits-per-pixel. 18 extern struct bmap mdscr; 19 // Also, you should allocate a 256-char palette array, if need be. Otherwise 20 // this can be NULL if you don't have a paletted display. 21 extern unsigned char *mdpal; 22 // Initialize graphics, in NTSC (320x224) or PAL (320x240) mode. 23 // Since many interfaces require that DGen be setuid-root, this should also 24 // discard root priviledges, if at all necessary. 25 // It should return 1 on successful setup, or 0 if something wrong happened. 26 int pd_graphics_init(int want_sound, int want_pal, int hz); 27 int pd_graphics_reinit(int want_sound, int want_pal, int hz); 28 // This updats the palette, if necessary. 29 void pd_graphics_palette_update(); 30 // This updates the screen, with the mdscr bitmap. 31 void pd_graphics_update(bool update); 32 33 // This is the struct sndinfo, also setup by your implementation. 34 // Note that the buffers pointed to in this struct should ALWAYS be 16-bit 35 // signed format, regardless of the actual audio format. 36 extern struct sndinfo sndi; 37 // Initialize sound, with the given frequency and number of samples. 38 // It should keep samples' worth of sound buffered. 39 // The parameters should all be modified to reflect the actual characteristics. 40 // This is always called after pd_graphics_init, so you can count on graphics 41 // stuff being initialized. :) 42 // It should return 1 on successful setup, or 0 if something wrong happened. 43 int pd_sound_init(long &freq, unsigned int &samples); 44 void pd_sound_deinit(); 45 // This should return samples read/write indices in the buffer. 46 unsigned int pd_sound_rp(); 47 unsigned int pd_sound_wp(); 48 // And this function is called to commit the sound buffers to be played. 49 void pd_sound_write(); 50 51 // Register platform-specific rc variables 52 void pd_rc(); 53 // This should be a list of all the command-line options specific to this 54 // platform, in the form given to getopt(3), i.e "a:b::c". 55 extern const char *pd_options; 56 // And, this is called to handle platform-specific stuff. 57 void pd_option(char c, const char *optarg); 58 59 // This is called after displaying the base options for help, so that you may 60 // document your platform-specific command-line options etc. 61 void pd_help(); 62 63 // This is called before each frame to handle events, and update the MegaDrive 64 // accordingly. It returns 1 to continue playing the game, or 0 to quit. 65 int pd_handle_events(md &megad); 66 67 // Tells whether DGen stopped intentionally so emulation can resume without 68 // skipping frames. 69 int pd_stopped(); 70 71 // If true, stop emulation (display last frame repeatedly). 72 extern bool pd_freeze; 73 74 // These are called to display and clear game messages. 75 void pd_message(const char *fmt, ...); 76 void pd_clear_message(); 77 // This should display cartridge header info. You can do this any way you like, 78 // I don't care. :) 79 void pd_show_carthead(md &megad); 80 81 // This should clean up the mess you made. ;) 82 void pd_quit(); 83 84 #endif // __PD_H__ 85