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