Mercurial > repos > blastem
annotate render_sdl.c @ 402:de2c085ce174
Assert z80 interrupt longer so that they are not missed when they should not be
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 15 Jun 2013 23:50:59 -0700 |
parents | c26e48a93fa3 |
children | c1bddeadc566 |
rev | line source |
---|---|
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <stdlib.h> |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdio.h> |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include "render.h" |
66 | 4 #include "blastem.h" |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 SDL_Surface *screen; |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
7 uint8_t render_dbg = 0; |
135 | 8 uint8_t debug_pal = 0; |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
10 uint32_t last_frame = 0; |
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
11 |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
12 int32_t color_map[1 << 12]; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
13 uint8_t levels[] = {0, 27, 49, 71, 87, 103, 119, 130, 146, 157, 174, 190, 206, 228, 255}; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
14 |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
15 uint32_t min_delay; |
342
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
16 uint32_t frame_delay = 1000/60; |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
17 |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
18 int16_t * current_psg = NULL; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
19 int16_t * current_ym = NULL; |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
20 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
21 uint32_t buffer_samples, sample_rate; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
22 uint32_t missing_count; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
23 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
24 SDL_mutex * audio_mutex; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
25 SDL_cond * audio_ready; |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
26 SDL_cond * psg_cond; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
27 SDL_cond * ym_cond; |
361 | 28 uint8_t quitting = 0; |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
29 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
30 void audio_callback(void * userdata, uint8_t *byte_stream, int len) |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 { |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
32 //puts("audio_callback"); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
33 int16_t * stream = (int16_t *)byte_stream; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
34 int samples = len/(sizeof(int16_t)*2); |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
35 int16_t * psg_buf, * ym_buf; |
361 | 36 uint8_t local_quit; |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
37 SDL_LockMutex(audio_mutex); |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
38 psg_buf = NULL; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
39 ym_buf = NULL; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
40 do { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
41 if (!psg_buf) { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
42 psg_buf = current_psg; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
43 current_psg = NULL; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
44 SDL_CondSignal(psg_cond); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
45 } |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
46 if (!ym_buf) { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
47 ym_buf = current_ym; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
48 current_ym = NULL; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
49 SDL_CondSignal(ym_cond); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
50 } |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
51 if (!quitting && (!psg_buf || !ym_buf)) { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
52 SDL_CondWait(audio_ready, audio_mutex); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
53 } |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
54 } while(!quitting && (!psg_buf || !ym_buf)); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
55 |
361 | 56 local_quit = quitting; |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
57 SDL_UnlockMutex(audio_mutex); |
361 | 58 if (!local_quit) { |
59 for (int i = 0; i < samples; i++) { | |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
60 *(stream++) = psg_buf[i] + *(ym_buf++); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
61 *(stream++) = psg_buf[i] + *(ym_buf++); |
361 | 62 } |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
63 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
64 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
65 |
361 | 66 void render_close_audio() |
67 { | |
68 SDL_LockMutex(audio_mutex); | |
69 quitting = 1; | |
70 SDL_CondSignal(audio_ready); | |
71 SDL_UnlockMutex(audio_mutex); | |
72 SDL_CloseAudio(); | |
73 } | |
74 | |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
75 void render_init(int width, int height, char * title, uint32_t fps) |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
76 { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
77 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 exit(1); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 atexit(SDL_Quit); |
361 | 82 atexit(render_close_audio); |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
83 printf("width: %d, height: %d\n", width, height); |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
84 screen = SDL_SetVideoMode(width, height, 32, SDL_SWSURFACE | SDL_ANYFORMAT); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 if (!screen) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 fprintf(stderr, "Unable to get SDL surface: %s\n", SDL_GetError()); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 exit(1); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 if (screen->format->BytesPerPixel < 2) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 fprintf(stderr, "BlastEm requires at least a 16-bit surface, SDL returned a %d-bit surface\n", screen->format->BytesPerPixel * 8); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 exit(1); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 } |
340
58a085cfc6bd
Set window title based on ROM header name
Mike Pavone <pavone@retrodev.com>
parents:
339
diff
changeset
|
93 SDL_WM_SetCaption(title, title); |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
94 uint8_t b,g,r; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
95 for (uint16_t color = 0; color < (1 << 12); color++) { |
230
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
96 if (color & FBUF_SHADOW) { |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
97 b = levels[(color >> 9) & 0x7]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
98 g = levels[(color >> 5) & 0x7]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
99 r = levels[(color >> 1) & 0x7]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
100 } else if(color & FBUF_HILIGHT) { |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
101 b = levels[((color >> 9) & 0x7) + 7]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
102 g = levels[((color >> 5) & 0x7) + 7]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
103 r = levels[((color >> 1) & 0x7) + 7]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
104 } else { |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
105 b = levels[(color >> 8) & 0xE]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
106 g = levels[(color >> 4) & 0xE]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
107 r = levels[color & 0xE]; |
d3266cee02c9
Implemented shadow hilight mode.
Mike Pavone <pavone@retrodev.com>
parents:
229
diff
changeset
|
108 } |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
109 color_map[color] = SDL_MapRGB(screen->format, r, g, b); |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
110 } |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
111 min_delay = 0; |
339
80d934369fd5
Increase sample size for min_delay
Mike Pavone <pavone@retrodev.com>
parents:
338
diff
changeset
|
112 for (int i = 0; i < 100; i++) { |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
113 uint32_t start = SDL_GetTicks(); |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
114 SDL_Delay(1); |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
115 uint32_t delay = SDL_GetTicks()-start; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
116 if (delay > min_delay) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
117 min_delay = delay; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
118 } |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
119 } |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
120 if (!min_delay) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
121 min_delay = 1; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
122 } |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
123 printf("minimum delay: %d\n", min_delay); |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
124 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
125 frame_delay = 1000/fps; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
126 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
127 audio_mutex = SDL_CreateMutex(); |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
128 psg_cond = SDL_CreateCond(); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
129 ym_cond = SDL_CreateCond(); |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
130 audio_ready = SDL_CreateCond(); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
131 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
132 SDL_AudioSpec desired, actual; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
133 desired.freq = 48000; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
134 desired.format = AUDIO_S16SYS; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
135 desired.channels = 2; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
136 desired.samples = 1024; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
137 desired.callback = audio_callback; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
138 desired.userdata = NULL; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
139 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
140 if (SDL_OpenAudio(&desired, &actual) < 0) { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
141 fprintf(stderr, "Unable to open SDL audio: %s\n", SDL_GetError()); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
142 exit(1); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
143 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
144 buffer_samples = actual.samples; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
145 sample_rate = actual.freq; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
146 printf("Initialized audio at frequency %d with a %d sample buffer\n", actual.freq, actual.samples); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
147 SDL_PauseAudio(0); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 void render_context(vdp_context * context) |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 uint8_t *buf_8; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 uint16_t *buf_16; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 uint32_t *buf_32; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 uint8_t b,g,r; |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
156 last_frame = SDL_GetTicks(); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 if (SDL_MUSTLOCK(screen)) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 if (SDL_LockSurface(screen) < 0) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 return; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 } |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
162 uint16_t repeat_x = screen->clip_rect.w / 320; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
163 uint16_t repeat_y = screen->clip_rect.h / 240; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
164 if (repeat_x > repeat_y) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
165 repeat_x = repeat_y; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
166 } else { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
167 repeat_y = repeat_x; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
168 } |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 switch (screen->format->BytesPerPixel) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 case 2: |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 buf_16 = (uint16_t *)screen->pixels; |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
172 for (int y = 0; y < 240; y++) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
173 for (int i = 0; i < repeat_y; i++,buf_16 += screen->pitch/2) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
174 uint16_t *line = buf_16; |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
175 uint16_t *src_line = context->framebuf + y * 320; |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
176 for (int x = 0; x < 320; x++) { |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
177 uint16_t color = color_map[*(src_line++) & 0xFFF]; |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
178 for (int j = 0; j < repeat_x; j++) { |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
179 *(line++) = color; |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
180 } |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
181 } |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
182 } |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 break; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 case 3: |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 buf_8 = (uint8_t *)screen->pixels; |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
187 for (int y = 0; y < 240; y++) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
188 for (int i = 0; i < repeat_y; i++,buf_8 += screen->pitch) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
189 uint8_t *line = buf_8; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
190 for (int x = 0; x < 320; x++) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
191 uint16_t gen_color = context->framebuf[y * 320 + x]; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
192 b = ((gen_color >> 8) & 0xE) * 18; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
193 g = ((gen_color >> 4) & 0xE) * 18; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
194 r = (gen_color& 0xE) * 18; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
195 for (int j = 0; j < repeat_x; j++) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
196 *(buf_8+screen->format->Rshift/8) = r; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
197 *(buf_8+screen->format->Gshift/8) = g; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
198 *(buf_8+screen->format->Bshift/8) = b; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
199 buf_8 += 3; |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
200 } |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
201 } |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
202 } |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 break; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 case 4: |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 buf_32 = (uint32_t *)screen->pixels; |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
207 |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
208 for (int y = 0; y < 240; y++) { |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
209 for (int i = 0; i < repeat_y; i++,buf_32 += screen->pitch/4) { |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
210 uint32_t *line = buf_32; |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
211 uint16_t *src_line = context->framebuf + y * 320; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
212 for (int x = 0; x < 320; x++) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
213 uint32_t color; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
214 if (!render_dbg) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
215 color = color_map[*(src_line++) & 0xFFF]; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
216 } else if(render_dbg == 2) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
217 color = color_map[context->cram[(y/30)*8 + x/40]]; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
218 } else if(render_dbg == 3) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
219 if (x & 1) { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
220 color = color_map[context->cram[ (debug_pal << 4) | (context->vdpmem[(x/8)*32 + (y/8)*32*40 + (x%8)/2 + (y%8)*4] & 0xF) ]]; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
221 } else { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
222 color = color_map[context->cram[ (debug_pal << 4) | (context->vdpmem[(x/8)*32 + (y/8)*32*40 + (x%8)/2 + (y%8)*4] >> 4) ]]; |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
223 } |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
224 }else { |
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
225 uint16_t gen_color = context->framebuf[y * 320 + x]; |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
226 r = g = b = 0; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
227 switch(gen_color & FBUF_SRC_MASK) |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
228 { |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
229 case FBUF_SRC_A: |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
230 g = 127; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
231 break; |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
232 case FBUF_SRC_W: |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
233 g = 127; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
234 b = 127; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
235 break; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
236 case FBUF_SRC_B: |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
237 b = 127; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
238 break; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
239 case FBUF_SRC_S: |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
240 r = 127; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
241 break; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
242 case FBUF_SRC_BG: |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
243 r = 127; |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
244 b = 127; |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
245 } |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
246 if (gen_color & FBUF_BIT_PRIORITY) { |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
247 b *= 2; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
248 g *= 2; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
249 r *= 2; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
250 } |
234
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
251 if (gen_color & FBUF_SHADOW) { |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
252 b /= 2; |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
253 g /= 2; |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
254 r /= 2; |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
255 } else if(gen_color & FBUF_HILIGHT) { |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
256 b = b ? b : 64; |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
257 g = g ? g : 64; |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
258 r = r ? r : 64; |
f456ee23d372
Add shadow/higlight info to debug renderer
Mike Pavone <pavone@retrodev.com>
parents:
230
diff
changeset
|
259 } |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
260 color = SDL_MapRGB(screen->format, r, g, b); |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
261 } |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
262 for (int j = 0; j < repeat_x; j++) { |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
263 *(line++) = color; |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
264 } |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
265 } |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
266 } |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
267 } |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
268 break; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
269 } |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 if ( SDL_MUSTLOCK(screen) ) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 SDL_UnlockSurface(screen); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 } |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
28
diff
changeset
|
273 SDL_UpdateRect(screen, 0, 0, screen->clip_rect.w, screen->clip_rect.h); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
276 void render_wait_quit(vdp_context * context) |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 SDL_Event event; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 while(SDL_WaitEvent(&event)) { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 switch (event.type) { |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
281 case SDL_KEYDOWN: |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
282 if (event.key.keysym.sym == SDLK_LEFTBRACKET) { |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
283 render_dbg++; |
135 | 284 if (render_dbg == 4) { |
55
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
285 render_dbg = 0; |
8317f174d916
Add palette debug to SDL renderer
Mike Pavone <pavone@retrodev.com>
parents:
54
diff
changeset
|
286 } |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
287 render_context(context); |
135 | 288 } else if(event.key.keysym.sym == SDLK_RIGHTBRACKET) { |
289 debug_pal++; | |
290 if (debug_pal == 4) { | |
291 debug_pal = 0; | |
292 } | |
43
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
293 } |
3fc57e1a2c56
Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents:
33
diff
changeset
|
294 break; |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 case SDL_QUIT: |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 return; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 |
398
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
301 void render_debug_mode(uint8_t mode) |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
302 { |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
303 if (mode < 4) { |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
304 render_dbg = mode; |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
305 } |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
306 } |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
307 |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
308 void render_debug_pal(uint8_t pal) |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
309 { |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
310 if (pal < 4) { |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
311 debug_pal = pal; |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
312 } |
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
313 } |
66 | 314 |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
315 int32_t handle_event(SDL_Event *event) |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
316 { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
317 switch (event->type) { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
318 case SDL_KEYDOWN: |
398
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
319 handle_keydown(event->key.keysym.sym); |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
320 break; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
321 case SDL_KEYUP: |
398
c26e48a93fa3
Make keybindings data driven so they can be populated from a config file later
Mike Pavone <pavone@retrodev.com>
parents:
364
diff
changeset
|
322 handle_keyup(event->key.keysym.sym); |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
323 break; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
324 case SDL_QUIT: |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
325 puts(""); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
326 exit(0); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
327 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
328 return 0; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
329 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
330 |
63
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
331 uint32_t frame_counter = 0; |
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
332 uint32_t start = 0; |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
333 int wait_render_frame(vdp_context * context, int frame_limit) |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
334 { |
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
335 SDL_Event event; |
198
209a37eed3e7
Add support for breaking into the debugger while game is running
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
336 int ret = 0; |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
337 while(SDL_PollEvent(&event)) { |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
338 ret = handle_event(&event); |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
339 } |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
340 if (frame_limit) { |
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
341 //TODO: Adjust frame delay so we actually get 60 FPS rather than 62.5 FPS |
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
342 uint32_t current = SDL_GetTicks(); |
342
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
343 uint32_t desired = last_frame + frame_delay; |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
344 if (current < desired) { |
342
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
345 uint32_t delay = last_frame + frame_delay - current; |
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
346 if (delay > min_delay) { |
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
347 SDL_Delay((delay/min_delay)*min_delay); |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
348 } |
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
349 while ((desired) >= SDL_GetTicks()) { |
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
350 } |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
351 } |
338
5c34a9c39394
Re-enable frame limit, but add a command line flag to disable it
Mike Pavone <pavone@retrodev.com>
parents:
322
diff
changeset
|
352 } |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
353 render_context(context); |
229
d60837a7d18a
Improve color rendering accuracy and optimize SDL renderer a bit
Mike Pavone <pavone@retrodev.com>
parents:
198
diff
changeset
|
354 |
272 | 355 |
64
2b1a65f4b85d
Cleanup 68K timing code. Temporarily omment out fFPS counter as it was causing segfaults
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
356 //TODO: Figure out why this causes segfaults |
272 | 357 /*frame_counter++; |
63
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
358 if ((last_frame - start) > 1000) { |
272 | 359 if (start && (last_frame-start)) { |
63
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
360 printf("\r%f fps", ((float)frame_counter) / (((float)(last_frame-start)) / 1000.0)); |
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
361 fflush(stdout); |
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
362 } |
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
363 start = last_frame; |
a6dd5b7a971b
Add FPS counter to console output
Mike Pavone <pavone@retrodev.com>
parents:
55
diff
changeset
|
364 frame_counter = 0; |
64
2b1a65f4b85d
Cleanup 68K timing code. Temporarily omment out fFPS counter as it was causing segfaults
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
365 }*/ |
198
209a37eed3e7
Add support for breaking into the debugger while game is running
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
366 return ret; |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
367 } |
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
368 |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
369 void render_wait_psg(psg_context * context) |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
370 { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
371 SDL_LockMutex(audio_mutex); |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
372 while (current_psg != NULL) { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
373 SDL_CondWait(psg_cond, audio_mutex); |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
374 } |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
375 current_psg = context->audio_buffer; |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
376 SDL_CondSignal(audio_ready); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
377 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
378 context->audio_buffer = context->back_buffer; |
364
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
379 context->back_buffer = current_psg; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
380 SDL_UnlockMutex(audio_mutex); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
381 context->buffer_pos = 0; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
382 } |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
383 |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
384 void render_wait_ym(ym2612_context * context) |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
385 { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
386 SDL_LockMutex(audio_mutex); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
387 while (current_ym != NULL) { |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
388 SDL_CondWait(ym_cond, audio_mutex); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
389 } |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
390 current_ym = context->audio_buffer; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
391 SDL_CondSignal(audio_ready); |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
392 |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
393 context->audio_buffer = context->back_buffer; |
62177cc39049
Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents:
361
diff
changeset
|
394 context->back_buffer = current_ym; |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
395 SDL_UnlockMutex(audio_mutex); |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
396 context->buffer_pos = 0; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
397 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
398 |
342
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
399 void render_fps(uint32_t fps) |
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
400 { |
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
401 frame_delay = 1000/fps; |
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
402 } |
54
3b79cbcf6846
Get Flavio's color bar demo kind of sort of working
Mike Pavone <pavone@retrodev.com>
parents:
43
diff
changeset
|
403 |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
404 uint32_t render_audio_buffer() |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
405 { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
406 return buffer_samples; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
407 } |
342
13f994c88c34
Get frame time correct and frame rate sort of correct for EUR region
Mike Pavone <pavone@retrodev.com>
parents:
340
diff
changeset
|
408 |
354
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
409 uint32_t render_sample_rate() |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
410 { |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
411 return sample_rate; |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
412 } |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
413 |
15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
Mike Pavone <pavone@retrodev.com>
parents:
342
diff
changeset
|
414 |