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