Mercurial > repos > blastem
annotate libblastem.c @ 1944:357878be8be6
Fix vgmplay target
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 26 Apr 2020 14:56:44 -0700 |
parents | b387f1c5a1d0 |
children | 81df9aa2de9b |
rev | line source |
---|---|
1688
395f684c5379
Fixed the most glaring issues in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1687
diff
changeset
|
1 #include <stdlib.h> |
395f684c5379
Fixed the most glaring issues in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1687
diff
changeset
|
2 #include <string.h> |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 #include "libretro.h" |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include "system.h" |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "util.h" |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #include "vdp.h" |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include "render.h" |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include "io.h" |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
9 #include "genesis.h" |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
10 #include "sms.h" |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 static retro_environment_t retro_environment; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 RETRO_API void retro_set_environment(retro_environment_t re) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 retro_environment = re; |
1864
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
16 # define input_descriptor_macro(pad_num) \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
17 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "D-Pad Left" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
18 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "D-Pad Up" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
19 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "D-Pad Down" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
20 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "D-Pad Right" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
21 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "A" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
22 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "B" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
23 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Y" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
24 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y, "X" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
25 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Z" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
26 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "C" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
27 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Mode" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
28 { pad_num, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" }, \ |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
29 |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
30 static const struct retro_input_descriptor desc[] = { |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
31 input_descriptor_macro(0) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
32 input_descriptor_macro(1) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
33 input_descriptor_macro(2) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
34 input_descriptor_macro(3) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
35 input_descriptor_macro(4) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
36 input_descriptor_macro(5) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
37 input_descriptor_macro(6) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
38 input_descriptor_macro(7) |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
39 { 0 }, |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
40 }; |
96323d73b8ab
add input descriptors
hizzlekizzle <hizzlekizzle@users.noreply.github.com>
parents:
1822
diff
changeset
|
41 |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
42 re(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, (void *)desc); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 static retro_video_refresh_t retro_video_refresh; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 RETRO_API void retro_set_video_refresh(retro_video_refresh_t rvf) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 retro_video_refresh = rvf; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 RETRO_API void retro_set_audio_sample(retro_audio_sample_t ras) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
55 static retro_audio_sample_batch_t retro_audio_sample_batch; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 RETRO_API void retro_set_audio_sample_batch(retro_audio_sample_batch_t rasb) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 { |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
58 retro_audio_sample_batch = rasb; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 static retro_input_poll_t retro_input_poll; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 RETRO_API void retro_set_input_poll(retro_input_poll_t rip) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 retro_input_poll = rip; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 static retro_input_state_t retro_input_state; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 RETRO_API void retro_set_input_state(retro_input_state_t ris) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 retro_input_state = ris; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 int headless = 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 int exit_after = 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 int z80_enabled = 1; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 char *save_filename; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 tern_node *config; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 uint8_t use_native_states = 1; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 system_header *current_system; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 system_media media; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 RETRO_API void retro_init(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 { |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
84 render_audio_initialized(RENDER_AUDIO_S16, 53693175 / (7 * 6 * 4), 2, 4, sizeof(int16_t)); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 RETRO_API void retro_deinit(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 { |
1691
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
89 if (current_system) { |
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
90 retro_unload_game(); |
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
91 } |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 RETRO_API unsigned retro_api_version(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 return RETRO_API_VERSION; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 RETRO_API void retro_get_system_info(struct retro_system_info *info) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 info->library_name = "BlastEm"; |
1819
4fb9af0c65b6
Update verison number in liblastem.c
Mike Pavone <pavone@retrodev.com>
parents:
1818
diff
changeset
|
102 info->library_version = "0.6.3-pre"; //TODO: share this with blastem.c |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 info->valid_extensions = "md|gen|sms|bin|rom"; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 info->need_fullpath = 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 info->block_extract = 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 static vid_std video_standard; |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
109 static uint32_t last_width, last_height; |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
110 static uint32_t overscan_top, overscan_bot, overscan_left, overscan_right; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
111 static void update_overscan(void) |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
112 { |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
113 uint8_t overscan; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
114 retro_environment(RETRO_ENVIRONMENT_GET_OVERSCAN, &overscan); |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
115 if (overscan) { |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
116 overscan_top = overscan_bot = overscan_left = overscan_right = 0; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
117 } else { |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
118 if (video_standard == VID_NTSC) { |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
119 overscan_top = 11; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
120 overscan_bot = 8; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
121 overscan_left = 13; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
122 overscan_right = 14; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
123 } else { |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
124 overscan_top = 30; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
125 overscan_bot = 24; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
126 overscan_left = 13; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
127 overscan_right = 14; |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
128 } |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
129 } |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
130 } |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
131 |
1889
377f110e4cea
Report more accurate frame and sample rates to frontend in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1882
diff
changeset
|
132 static int32_t sample_rate; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 RETRO_API void retro_get_system_av_info(struct retro_system_av_info *info) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 { |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
135 update_overscan(); |
1694
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
136 last_width = LINEBUF_SIZE; |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
137 info->geometry.base_width = info->geometry.max_width = LINEBUF_SIZE - (overscan_left + overscan_right); |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
138 info->geometry.base_height = (video_standard == VID_NTSC ? 243 : 294) - (overscan_top + overscan_bot); |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
139 last_height = info->geometry.base_height; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
140 info->geometry.max_height = info->geometry.base_height * 2; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 info->geometry.aspect_ratio = 0; |
1889
377f110e4cea
Report more accurate frame and sample rates to frontend in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1882
diff
changeset
|
142 double master_clock = video_standard == VID_NTSC ? 53693175 : 53203395; |
377f110e4cea
Report more accurate frame and sample rates to frontend in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1882
diff
changeset
|
143 double lines = video_standard == VID_NTSC ? 262 : 313; |
377f110e4cea
Report more accurate frame and sample rates to frontend in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1882
diff
changeset
|
144 info->timing.fps = master_clock / (3420.0 * lines); |
377f110e4cea
Report more accurate frame and sample rates to frontend in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1882
diff
changeset
|
145 info->timing.sample_rate = master_clock / (7 * 6 * 24); //sample rate of YM2612 |
377f110e4cea
Report more accurate frame and sample rates to frontend in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1882
diff
changeset
|
146 sample_rate = info->timing.sample_rate; |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
147 render_audio_initialized(RENDER_AUDIO_S16, info->timing.sample_rate, 2, 4, sizeof(int16_t)); |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
148 //force adjustment of resampling parameters since target sample rate may have changed slightly |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
149 current_system->set_speed_percent(current_system, 100); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 RETRO_API void retro_set_controller_port_device(unsigned port, unsigned device) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 /* Resets the current game. */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 RETRO_API void retro_reset(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 current_system->soft_reset(current_system); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 /* Runs the game for one video frame. |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 * During retro_run(), input_poll callback must be called at least once. |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 * |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 * If a frame is not rendered for reasons where a game "dropped" a frame, |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 * this still counts as a frame, and retro_run() should explicitly dupe |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 * a frame if GET_CAN_DUPE returns true. |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 * In this case, the video callback can take a NULL argument for data. |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 static uint8_t started; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 RETRO_API void retro_run(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 if (started) { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 current_system->resume_context(current_system); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 } else { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 current_system->start_context(current_system, NULL); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 started = 1; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 /* Returns the amount of data the implementation requires to serialize |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 * internal state (save states). |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 * Between calls to retro_load_game() and retro_unload_game(), the |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 * returned size is never allowed to be larger than a previous returned |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 * value, to ensure that the frontend can allocate a save state buffer once. |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 */ |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
187 static size_t serialize_size_cache; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 RETRO_API size_t retro_serialize_size(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 { |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
190 if (!serialize_size_cache) { |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
191 uint8_t *tmp = current_system->serialize(current_system, &serialize_size_cache); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
192 free(tmp); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
193 } |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
194 return serialize_size_cache; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 /* Serializes internal state. If failed, or size is lower than |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 * retro_serialize_size(), it should return false, true otherwise. */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 RETRO_API bool retro_serialize(void *data, size_t size) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 { |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
201 size_t actual_size; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
202 uint8_t *tmp = current_system->serialize(current_system, &actual_size); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
203 if (actual_size > size) { |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
204 free(tmp); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
205 return 0; |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
206 } |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
207 memcpy(data, tmp, actual_size); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
208 free(tmp); |
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
209 return 1; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 RETRO_API bool retro_unserialize(const void *data, size_t size) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 { |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
214 current_system->deserialize(current_system, (uint8_t *)data, size); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 return 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 RETRO_API void retro_cheat_reset(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 /* Loads a game. */ |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
227 static system_type stype; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 RETRO_API bool retro_load_game(const struct retro_game_info *game) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 { |
1690
319d90025d50
Implement serialization/deserialization in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1689
diff
changeset
|
230 serialize_size_cache = 0; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 if (game->path) { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 media.dir = path_dirname(game->path); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 media.name = basename_no_extension(game->path); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 media.extension = path_extension(game->path); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 media.buffer = malloc(nearest_pow2(game->size)); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 memcpy(media.buffer, game->data, game->size); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 media.size = game->size; |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
239 stype = detect_system_type(&media); |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
240 current_system = alloc_config_system(stype, &media, 0, 0); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 unsigned format = RETRO_PIXEL_FORMAT_XRGB8888; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 retro_environment(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &format); |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
244 |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 return current_system != NULL; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
246 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 /* Loads a "special" kind of game. Should not be used, |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 * except in extreme cases. */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 RETRO_API bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 return retro_load_game(info); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 /* Unloads a currently loaded game. */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 RETRO_API void retro_unload_game(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 free(media.dir); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 free(media.name); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 free(media.extension); |
1691
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
261 media.dir = media.name = media.extension = NULL; |
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
262 //buffer is freed by the context |
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
263 media.buffer = NULL; |
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
264 current_system->free_context(current_system); |
e96d0d3bec7f
Don't leak a system context when a game is unloaded
Mike Pavone <pavone@retrodev.com>
parents:
1690
diff
changeset
|
265 current_system = NULL; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 /* Gets region of game. */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 RETRO_API unsigned retro_get_region(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 return video_standard == VID_NTSC ? RETRO_REGION_NTSC : RETRO_REGION_PAL; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 /* Gets region of memory. */ |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 RETRO_API void *retro_get_memory_data(unsigned id) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 { |
1926
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
277 switch (id) { |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
278 case RETRO_MEMORY_SYSTEM_RAM: |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
279 switch (stype) { |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
280 case SYSTEM_GENESIS: { |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
281 genesis_context *gen = (genesis_context *)current_system; |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
282 return (uint8_t *)gen->work_ram; |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
283 } |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
284 #ifndef NO_Z80 |
1926
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
285 case SYSTEM_SMS: { |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
286 sms_context *sms = (sms_context *)current_system; |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
287 return sms->ram; |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
288 } |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
289 #endif |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
290 } |
1926
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
291 break; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
292 case RETRO_MEMORY_SAVE_RAM: |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
293 if (stype == SYSTEM_GENESIS) { |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
294 genesis_context *gen = (genesis_context *)current_system; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
295 if (gen->save_type != SAVE_NONE) |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
296 return gen->save_storage; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
297 } |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
298 break; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
299 default: |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
300 break; |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
301 } |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 return NULL; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 RETRO_API size_t retro_get_memory_size(unsigned id) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 { |
1926
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
307 switch (id) { |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
308 case RETRO_MEMORY_SYSTEM_RAM: |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
309 switch (stype) { |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
310 case SYSTEM_GENESIS: |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
311 return RAM_WORDS * sizeof(uint16_t); |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
312 #ifndef NO_Z80 |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
313 case SYSTEM_SMS: |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
314 return SMS_RAM_SIZE; |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
315 #endif |
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
316 } |
1926
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
317 break; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
318 case RETRO_MEMORY_SAVE_RAM: |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
319 if (stype == SYSTEM_GENESIS) { |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
320 genesis_context *gen = (genesis_context *)current_system; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
321 if (gen->save_type != SAVE_NONE) |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
322 return gen->save_size; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
323 } |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
324 break; |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
325 default: |
94f37e4b1469
Add memory hook for genesis/megadrive save and cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1924
diff
changeset
|
326 break; |
1924
81b059e3ded6
Add memory hook for cheat/rumble/cheevos support
negativeExponent <negativeExponent@users.noreply.github.com>
parents:
1889
diff
changeset
|
327 } |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 return 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
329 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 //blastem render backend API implementation |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 uint32_t render_map_color(uint8_t r, uint8_t g, uint8_t b) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 return r << 16 | g << 8 | b; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 uint8_t render_create_window(char *caption, uint32_t width, uint32_t height, window_close_handler close_handler) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 //not supported in lib build |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 return 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 void render_destroy_window(uint8_t which) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 //not supported in lib build |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 static uint32_t fb[LINEBUF_SIZE * 294 * 2]; |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
349 static uint8_t last_fb; |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 uint32_t *render_get_framebuffer(uint8_t which, int *pitch) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 *pitch = LINEBUF_SIZE * sizeof(uint32_t); |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
353 if (which != last_fb) { |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
354 *pitch = *pitch * 2; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
355 } |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
356 |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
357 if (which) { |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
358 return fb + LINEBUF_SIZE; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
359 } else { |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
360 return fb; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
361 } |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 void render_framebuffer_updated(uint8_t which, int width) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 { |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
366 unsigned height = (video_standard == VID_NTSC ? 243 : 294) - (overscan_top + overscan_bot); |
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
367 width -= (overscan_left + overscan_right); |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
368 unsigned base_height = height; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
369 if (which != last_fb) { |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
370 height *= 2; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
371 last_fb = which; |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
372 } |
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
373 if (width != last_width || height != last_height) { |
1694
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
374 struct retro_game_geometry geometry = { |
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
375 .base_width = width, |
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
376 .base_height = height, |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
377 .aspect_ratio = (float)LINEBUF_SIZE / base_height |
1694
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
378 }; |
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
379 retro_environment(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry); |
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
380 last_width = width; |
1695
3c34122754ac
Properly support interlace in libretro build
Michael Pavone <pavone@retrodev.com>
parents:
1694
diff
changeset
|
381 last_height = height; |
1694
9e4dd1595f37
Fix aspect ratio for H32 games
Michael Pavone <pavone@retrodev.com>
parents:
1691
diff
changeset
|
382 } |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
383 retro_video_refresh(fb + overscan_left + LINEBUF_SIZE * overscan_top, width, height, LINEBUF_SIZE * sizeof(uint32_t)); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 current_system->request_exit(current_system); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 uint8_t render_get_active_framebuffer(void) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
388 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 return 0; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
391 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 void render_set_video_standard(vid_std std) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
393 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 video_standard = std; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 |
1822
8500bd987dda
Make libretro target successfully build for Windows and possibly Mac
Mike Pavone <pavone@retrodev.com>
parents:
1819
diff
changeset
|
397 int render_fullscreen(void) |
8500bd987dda
Make libretro target successfully build for Windows and possibly Mac
Mike Pavone <pavone@retrodev.com>
parents:
1819
diff
changeset
|
398 { |
8500bd987dda
Make libretro target successfully build for Windows and possibly Mac
Mike Pavone <pavone@retrodev.com>
parents:
1819
diff
changeset
|
399 return 1; |
8500bd987dda
Make libretro target successfully build for Windows and possibly Mac
Mike Pavone <pavone@retrodev.com>
parents:
1819
diff
changeset
|
400 } |
8500bd987dda
Make libretro target successfully build for Windows and possibly Mac
Mike Pavone <pavone@retrodev.com>
parents:
1819
diff
changeset
|
401 |
1881
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
402 uint32_t render_overscan_top() |
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
403 { |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
404 return overscan_top; |
1881
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
405 } |
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
406 |
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
407 uint32_t render_overscan_bot() |
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
408 { |
1882
62e8a8833e39
Implement overscan crop in libretro target
Michael Pavone <pavone@retrodev.com>
parents:
1881
diff
changeset
|
409 return overscan_bot; |
1881
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
410 } |
55198fc9cc1f
Don't render lines that are cropped by overscan. Allows submitting frame earlier when bottom overscan is non-zero which can reduce latency in some cases
Mike Pavone <pavone@retrodev.com>
parents:
1868
diff
changeset
|
411 |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
412 void process_events() |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
413 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 static int16_t prev_state[2][RETRO_DEVICE_ID_JOYPAD_L2]; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
415 static const uint8_t map[] = { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 BUTTON_A, BUTTON_X, BUTTON_MODE, BUTTON_START, DPAD_UP, DPAD_DOWN, |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
417 DPAD_LEFT, DPAD_RIGHT, BUTTON_B, BUTTON_Y, BUTTON_Z, BUTTON_C |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
418 }; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
419 //TODO: handle other input device types |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
420 //TODO: handle more than 2 ports when appropriate |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
421 retro_input_poll(); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
422 for (int port = 0; port < 2; port++) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
423 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
424 for (int id = RETRO_DEVICE_ID_JOYPAD_B; id < RETRO_DEVICE_ID_JOYPAD_L2; id++) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
425 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
426 int16_t new_state = retro_input_state(port, RETRO_DEVICE_JOYPAD, 0, id); |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
427 if (new_state != prev_state[port][id]) { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
428 if (new_state) { |
1689
7f42a93f18a4
Have a suitable default IO port configuration when nonIO is present from the config file. Fixed off by one in processing gamepad button events in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
429 current_system->gamepad_down(current_system, port + 1, map[id]); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
430 } else { |
1689
7f42a93f18a4
Have a suitable default IO port configuration when nonIO is present from the config file. Fixed off by one in processing gamepad button events in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1688
diff
changeset
|
431 current_system->gamepad_up(current_system, port + 1, map[id]); |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
432 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 prev_state[port][id] = new_state; |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
435 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
436 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
437 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
438 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
439 void render_errorbox(char *title, char *message) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
441 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
442 void render_warnbox(char *title, char *message) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
443 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
444 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
445 void render_infobox(char *title, char *message) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
446 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
447 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
448 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
449 uint8_t render_is_audio_sync(void) |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
450 { |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
451 //whether this is true depends on the libretro frontend implementation |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
452 //but the sync to audio path works better here |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
453 return 1; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
454 } |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
455 |
1932
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1927
diff
changeset
|
456 uint8_t render_should_release_on_exit(void) |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1927
diff
changeset
|
457 { |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1927
diff
changeset
|
458 return 0; |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1927
diff
changeset
|
459 } |
b387f1c5a1d0
WIP new sync mode that runs emulation on audio thread
Michael Pavone <pavone@retrodev.com>
parents:
1927
diff
changeset
|
460 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
461 void render_buffer_consumed(audio_source *src) |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
463 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
464 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
465 void *render_new_audio_opaque(void) |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
466 { |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
467 return NULL; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
468 } |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
469 |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
470 void render_free_audio_opaque(void *opaque) |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
471 { |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
472 } |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
473 |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
474 void render_lock_audio(void) |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
475 { |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
476 } |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
477 |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
478 void render_unlock_audio() |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
481 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
482 uint32_t render_min_buffered(void) |
1817
03895a4585c3
Fix build breakage for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1695
diff
changeset
|
483 { |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
484 //not actually used in the sync to audio path |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
485 return 4; |
1817
03895a4585c3
Fix build breakage for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1695
diff
changeset
|
486 } |
03895a4585c3
Fix build breakage for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1695
diff
changeset
|
487 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
488 uint32_t render_audio_syncs_per_sec(void) |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
489 { |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
490 return 0; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
491 } |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
492 |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
493 void render_audio_created(audio_source *src) |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
494 { |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
495 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
497 void render_do_audio_ready(audio_source *src) |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 { |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
499 int16_t *tmp = src->front; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
500 src->front = src->back; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
501 src->back = tmp; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
502 src->front_populated = 1; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
503 src->buffer_pos = 0; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
504 if (all_sources_ready()) { |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
505 int16_t buffer[8]; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
506 int min_remaining_out; |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
507 mix_and_convert((uint8_t *)buffer, sizeof(buffer), &min_remaining_out); |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
508 retro_audio_sample_batch(buffer, sizeof(buffer)/(2*sizeof(*buffer))); |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
509 } |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
510 } |
1688
395f684c5379
Fixed the most glaring issues in libretro build
Mike Pavone <pavone@retrodev.com>
parents:
1687
diff
changeset
|
511 |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
512 void render_source_paused(audio_source *src, uint8_t remaining_sources) |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
513 { |
1927
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
514 } |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
515 |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
516 void render_source_resumed(audio_source *src) |
9fd4bedc1a31
Update libretro target to use render_audio shared audio code
Mike Pavone <pavone@retrodev.com>
parents:
1926
diff
changeset
|
517 { |
1687
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
518 } |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
519 |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
520 void bindings_set_mouse_mode(uint8_t mode) |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 { |
6c54bb5fe3b3
Hacky WIP libertro implementation
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 } |
1818
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
523 |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
524 extern const char rom_db_data[]; |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
525 char *read_bundled_file(char *name, uint32_t *sizeret) |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
526 { |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
527 if (!strcmp(name, "rom.db")) { |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
528 *sizeret = strlen(rom_db_data); |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
529 char *ret = malloc(*sizeret+1); |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
530 memcpy(ret, rom_db_data, *sizeret + 1); |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
531 return ret; |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
532 } |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
533 return NULL; |
243f3a7247f9
Include ROM DB in library binary for libretro target
Mike Pavone <pavone@retrodev.com>
parents:
1817
diff
changeset
|
534 } |