| 1 | #include <windows.h> |
| 2 | #include <stdio.h> |
| 3 | |
| 4 | #include "../common/lprintf.h" |
| 5 | #include "../common/plat.h" |
| 6 | #include "../common/emu.h" |
| 7 | #include "../../pico/pico.h" |
| 8 | #include "version.h" |
| 9 | #include "direct.h" |
| 10 | #include "dsnd.h" |
| 11 | #include "main.h" |
| 12 | |
| 13 | static unsigned short screen_buff[320 * 240]; |
| 14 | static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; |
| 15 | unsigned char *PicoDraw2FB = PicoDraw2FB_; |
| 16 | const char *renderer_names[] = { NULL }; |
| 17 | const char *renderer_names32x[] = { NULL }; |
| 18 | |
| 19 | char cpu_clk_name[] = "unused"; |
| 20 | |
| 21 | void plat_init(void) |
| 22 | { |
| 23 | g_screen_ptr = (void *)screen_buff; |
| 24 | } |
| 25 | |
| 26 | int plat_is_dir(const char *path) |
| 27 | { |
| 28 | return (GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; |
| 29 | } |
| 30 | |
| 31 | unsigned int plat_get_ticks_ms(void) |
| 32 | { |
| 33 | return GetTickCount(); |
| 34 | } |
| 35 | |
| 36 | unsigned int plat_get_ticks_us(void) |
| 37 | { |
| 38 | // XXX: maybe performance counters? |
| 39 | return GetTickCount() * 1000; |
| 40 | } |
| 41 | |
| 42 | void plat_wait_till_us(unsigned int us) |
| 43 | { |
| 44 | int msdiff = (int)(us - plat_get_ticks_us()) / 1000; |
| 45 | if (msdiff > 6) |
| 46 | Sleep(msdiff - 6); |
| 47 | while (plat_get_ticks_us() < us) |
| 48 | ; |
| 49 | } |
| 50 | |
| 51 | void plat_sleep_ms(int ms) |
| 52 | { |
| 53 | Sleep(ms); |
| 54 | } |
| 55 | |
| 56 | int plat_wait_event(int *fds_hnds, int count, int timeout_ms) |
| 57 | { |
| 58 | return -1; |
| 59 | } |
| 60 | |
| 61 | void pemu_prep_defconfig(void) |
| 62 | { |
| 63 | memset(&defaultConfig, 0, sizeof(defaultConfig)); |
| 64 | defaultConfig.s_PicoOpt|= POPT_6BTN_PAD; // for xmen proto |
| 65 | defaultConfig.s_PicoCDBuffers = 0; |
| 66 | defaultConfig.Frameskip = 0; |
| 67 | } |
| 68 | |
| 69 | void pemu_validate_config(void) |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | void pemu_loop_prep(void) |
| 74 | { |
| 75 | PicoDrawSetOutFormat(PDF_RGB555, 1); |
| 76 | PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); |
| 77 | pemu_sound_start(); |
| 78 | } |
| 79 | |
| 80 | void pemu_loop_end(void) |
| 81 | { |
| 82 | pemu_sound_stop(); |
| 83 | } |
| 84 | |
| 85 | void pemu_forced_frame(int opts, int no_scale) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void pemu_finalize_frame(const char *fps, const char *notice_msg) |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | void plat_video_flip(void) |
| 94 | { |
| 95 | DirectScreen(g_screen_ptr); |
| 96 | DirectPresent(); |
| 97 | } |
| 98 | |
| 99 | void plat_video_wait_vsync(void) |
| 100 | { |
| 101 | } |
| 102 | |
| 103 | void plat_video_toggle_renderer(int change, int is_menu) |
| 104 | { |
| 105 | // this will auto-select SMS/32X renderers |
| 106 | PicoDrawSetOutFormat(PDF_RGB555, 1); |
| 107 | } |
| 108 | |
| 109 | void emu_video_mode_change(int start_line, int line_count, int is_32cols) |
| 110 | { |
| 111 | EmuScreenRect.left = is_32cols ? 32 : 0; |
| 112 | EmuScreenRect.right = is_32cols ? 256+32 : 320; |
| 113 | EmuScreenRect.top = start_line; |
| 114 | EmuScreenRect.bottom = start_line + line_count; |
| 115 | |
| 116 | PostMessage(FrameWnd, WM_COMMAND, 0x20000 | 2000, 0); |
| 117 | } |
| 118 | |
| 119 | static int sndbuff[2*44100/50/2 + 4]; |
| 120 | |
| 121 | static void update_sound(int len) |
| 122 | { |
| 123 | /* avoid writing audio when lagging behind to prevent audio lag */ |
| 124 | if (PicoSkipFrame != 2) |
| 125 | DSoundUpdate(sndbuff, (currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) ? 0 : 1); |
| 126 | } |
| 127 | |
| 128 | void pemu_sound_start(void) |
| 129 | { |
| 130 | int ret; |
| 131 | |
| 132 | PsndOut = NULL; |
| 133 | currentConfig.EmuOpt &= ~EOPT_EXT_FRMLIMIT; |
| 134 | |
| 135 | // prepare sound stuff |
| 136 | if (currentConfig.EmuOpt & EOPT_EN_SOUND) |
| 137 | { |
| 138 | PsndRerate(0); |
| 139 | |
| 140 | ret = DSoundInit(FrameWnd, PsndRate, (PicoOpt & POPT_EN_STEREO) ? 1 : 0, PsndLen); |
| 141 | if (ret != 0) { |
| 142 | lprintf("dsound init failed\n"); |
| 143 | return; |
| 144 | } |
| 145 | |
| 146 | PsndOut = (void *)sndbuff; |
| 147 | PicoWriteSound = update_sound; |
| 148 | currentConfig.EmuOpt |= EOPT_EXT_FRMLIMIT; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | void pemu_sound_stop(void) |
| 153 | { |
| 154 | DSoundExit(); |
| 155 | } |
| 156 | |
| 157 | void pemu_sound_wait(void) |
| 158 | { |
| 159 | } |
| 160 | |
| 161 | int plat_get_root_dir(char *dst, int len) |
| 162 | { |
| 163 | int ml; |
| 164 | |
| 165 | ml = GetModuleFileName(NULL, dst, len); |
| 166 | while (ml > 0 && dst[ml] != '\\') |
| 167 | ml--; |
| 168 | if (ml != 0) |
| 169 | ml++; |
| 170 | |
| 171 | dst[ml] = 0; |
| 172 | return ml; |
| 173 | } |
| 174 | |
| 175 | void plat_status_msg_busy_first(const char *msg) |
| 176 | { |
| 177 | } |
| 178 | |
| 179 | void plat_status_msg_busy_next(const char *msg) |
| 180 | { |
| 181 | } |
| 182 | |
| 183 | void plat_status_msg_clear(void) |
| 184 | { |
| 185 | } |
| 186 | |
| 187 | void plat_video_menu_enter(int is_rom_loaded) |
| 188 | { |
| 189 | } |
| 190 | |
| 191 | void plat_video_menu_begin(void) |
| 192 | { |
| 193 | } |
| 194 | |
| 195 | void plat_video_menu_end(void) |
| 196 | { |
| 197 | } |
| 198 | |
| 199 | void plat_update_volume(int has_changed, int is_up) |
| 200 | { |
| 201 | } |
| 202 | |
| 203 | const char *plat_get_credits(void) |
| 204 | { |
| 205 | return "PicoDrive v" VERSION " minibeta (c) notaz, 2006-2009\n\n" |
| 206 | "Credits:\n" |
| 207 | "fDave: base code of PicoDrive\n" |
| 208 | "Chui: Fame/C\n" |
| 209 | "NJ: CZ80\n" |
| 210 | "MAME devs: YM2612, SN76496 and SH2 cores\n" |
| 211 |