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