forked from libretro/virtualjaguar-libretro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libretro.cpp
525 lines (437 loc) · 16.9 KB
/
libretro.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
#include <iostream>
#include <cstring>
#include <cstdlib>
#include "libretro.h"
#include "file.h"
#include "jagbios.h"
#include "jagbios2.h"
#include "jagcdbios.h"
#include "jagstub2bios.h"
#include "jaguar.h"
#include "dac.h"
#include "dsp.h"
#include "joystick.h"
#include "log.h"
#include "memory.h"
#include "settings.h"
#include "tom.h"
#define STARTWIDTH 320
#define STARTHEIGHT 240
#define MAXWIDTH 1400
#define MAXHEIGHT 576
#define FNTSC 60
#define FPAL 50
#define SAMPLERATE 48000
#define BUFPAL (SAMPLERATE/FPAL*2)
#define BUFNTSC (SAMPLERATE/FNTSC*2)
#define BUFMAX 2048
// From jaguar.cpp
extern bool startM68KTracing;
// From joystick.cpp
extern int blit_start_log;
// From blitter.cpp
extern bool startConciseBlitLogging;
static bool failed_init;
int videoWidth, videoHeight;
uint32_t *videoBuffer = NULL;
int game_width;
int game_height;
static retro_video_refresh_t video_cb;
static retro_input_poll_t input_poll_cb;
static retro_input_state_t input_state_cb;
static retro_environment_t environ_cb;
static retro_audio_sample_batch_t audio_batch_cb;
void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
void retro_set_audio_sample(retro_audio_sample_t cb) { (void)cb; }
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_batch_cb = cb; }
void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; }
void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; }
static struct retro_system_av_info g_av_info;
int doom_res_hack=0; // Doom Hack to double pixel if pwidth==8 (163*2)
int log_enabled=0;
void retro_set_environment(retro_environment_t cb)
{
environ_cb = cb;
struct retro_variable variables[] = {
{
"virtualjaguar_usefastblitter",
"Fast Blitter; enabled|disabled",
},
{
"virtualjaguar_doom_res_hack",
"Doom Hack; disabled|enabled",
},
{
"virtualjaguar_pal",
"Pal (Restart); disabled|enabled",
},
{
"virtualjaguar_bios",
"Bios; disabled|enabled",
},
{
"virtualjaguar_audio",
"Audio; enabled|disabled",
},
{
"virtualjaguar_gpu",
"Gpu; enabled|disabled",
},
{
"virtualjaguar_dsp",
"Dsp; enabled|disabled",
},
{
"virtualjaguar_log",
"Log; disabled|enabled",
},
{
"virtualjaguar_blit_start_log",
"blit_start_Log; stop|start",
},
{
"virtualjaguar_startConciseBlitLogging",
"startConciseBlit_Log; stop|start",
},
{
"virtualjaguar_startM68KTracing",
"startM68KTracing; stop|start",
},
{ NULL, NULL },
};
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
}
static void check_variables(void)
{
struct retro_variable var;
var.key = "virtualjaguar_usefastblitter";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
vjs.useFastBlitter=1;
if (strcmp(var.value, "disabled") == 0)
vjs.useFastBlitter=0;
}
else
vjs.useFastBlitter=1;
var.key = "virtualjaguar_doom_res_hack";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
doom_res_hack=1;
if (strcmp(var.value, "disabled") == 0)
doom_res_hack=0;
}
else
doom_res_hack=0;
var.key = "virtualjaguar_pal";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
vjs.hardwareTypeNTSC=0;
if (strcmp(var.value, "disabled") == 0)
vjs.hardwareTypeNTSC=1;
}
else
vjs.hardwareTypeNTSC=1;
var.key = "virtualjaguar_bios";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
vjs.useJaguarBIOS = true;
if (strcmp(var.value, "disabled") == 0)
vjs.useJaguarBIOS = false;
}
else
vjs.useJaguarBIOS = false;
var.key = "virtualjaguar_gpu";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
vjs.GPUEnabled = true;
if (strcmp(var.value, "disabled") == 0)
vjs.GPUEnabled = false;
}
else
vjs.GPUEnabled = true;
var.key = "virtualjaguar_audio";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
vjs.audioEnabled = true;
if (strcmp(var.value, "disabled") == 0)
vjs.audioEnabled = false;
}
else
vjs.audioEnabled = true;
var.key = "virtualjaguar_dsp";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
vjs.DSPEnabled = true;
if (strcmp(var.value, "disabled") == 0)
vjs.DSPEnabled = false;
}
else
vjs.DSPEnabled = true;
var.key = "virtualjaguar_log";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
log_enabled = 1;
if (strcmp(var.value, "disabled") == 0)
log_enabled = 0;
}
else
log_enabled = 0;
var.key = "virtualjaguar_blit_start_log";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "start") == 0)
blit_start_log = true;
if (strcmp(var.value, "stop") == 0)
blit_start_log = false;
}
else
blit_start_log = false;
var.key = "virtualjaguar_startConciseBlitLogging";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "start") == 0)
startConciseBlitLogging = true;
if (strcmp(var.value, "stop") == 0)
startConciseBlitLogging = false;
}
else
startConciseBlitLogging = false;
var.key = "virtualjaguar_startM68KTracing";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "start") == 0)
startM68KTracing = true;
if (strcmp(var.value, "stop") == 0)
startM68KTracing = false;
}
else
startM68KTracing = false;
}
static void update_input(void)
{
if (!input_poll_cb)
return;
input_poll_cb();
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) ? joypad0Buttons[BUTTON_U] = 0xff : joypad0Buttons[BUTTON_U] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN) ? joypad0Buttons[BUTTON_D] = 0xff : joypad0Buttons[BUTTON_D] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT) ? joypad0Buttons[BUTTON_L] = 0xff : joypad0Buttons[BUTTON_L] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) ? joypad0Buttons[BUTTON_R] = 0xff : joypad0Buttons[BUTTON_R] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) ? joypad0Buttons[BUTTON_A] = 0xff : joypad0Buttons[BUTTON_A] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) ? joypad0Buttons[BUTTON_B] = 0xff : joypad0Buttons[BUTTON_B] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y) ? joypad0Buttons[BUTTON_C] = 0xff : joypad0Buttons[BUTTON_C] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START) ? joypad0Buttons[BUTTON_PAUSE] = 0xff : joypad0Buttons[BUTTON_PAUSE] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT) ? joypad0Buttons[BUTTON_OPTION] = 0xff : joypad0Buttons[BUTTON_OPTION] = 0x00;
// others pound/hash/0-9
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X) ? joypad0Buttons[BUTTON_0] = 0xff : joypad0Buttons[BUTTON_0] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R) ? joypad0Buttons[BUTTON_d] = 0xff : joypad0Buttons[BUTTON_d] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L) ? joypad0Buttons[BUTTON_s] = 0xff : joypad0Buttons[BUTTON_s] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2) ? joypad0Buttons[BUTTON_1] = 0xff : joypad0Buttons[BUTTON_1] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2) ? joypad0Buttons[BUTTON_2] = 0xff : joypad0Buttons[BUTTON_2] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3) ? joypad0Buttons[BUTTON_3] = 0xff : joypad0Buttons[BUTTON_3] = 0x00;
input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3) ? joypad0Buttons[BUTTON_4] = 0xff : joypad0Buttons[BUTTON_4] = 0x00;
//only for P1 for now
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP0) ? joypad0Buttons[BUTTON_0] = 0xff : joypad0Buttons[BUTTON_0] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP1) ? joypad0Buttons[BUTTON_1] = 0xff : joypad0Buttons[BUTTON_1] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP2) ? joypad0Buttons[BUTTON_2] = 0xff : joypad0Buttons[BUTTON_2] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP3) ? joypad0Buttons[BUTTON_3] = 0xff : joypad0Buttons[BUTTON_3] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP4) ? joypad0Buttons[BUTTON_4] = 0xff : joypad0Buttons[BUTTON_4] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP5) ? joypad0Buttons[BUTTON_5] = 0xff : joypad0Buttons[BUTTON_5] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP6) ? joypad0Buttons[BUTTON_6] = 0xff : joypad0Buttons[BUTTON_6] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP7) ? joypad0Buttons[BUTTON_7] = 0xff : joypad0Buttons[BUTTON_7] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP8) ? joypad0Buttons[BUTTON_8] = 0xff : joypad0Buttons[BUTTON_8] = 0x00;
input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,RETROK_KP9) ? joypad0Buttons[BUTTON_9] = 0xff : joypad0Buttons[BUTTON_9] = 0x00;
//JOY2
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP) ? joypad1Buttons[BUTTON_U] = 0xff : joypad1Buttons[BUTTON_U] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN) ? joypad1Buttons[BUTTON_D] = 0xff : joypad1Buttons[BUTTON_D] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT) ? joypad1Buttons[BUTTON_L] = 0xff : joypad1Buttons[BUTTON_L] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT) ? joypad1Buttons[BUTTON_R] = 0xff : joypad1Buttons[BUTTON_R] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) ? joypad1Buttons[BUTTON_A] = 0xff : joypad1Buttons[BUTTON_A] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) ? joypad1Buttons[BUTTON_B] = 0xff : joypad1Buttons[BUTTON_B] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y) ? joypad1Buttons[BUTTON_C] = 0xff : joypad1Buttons[BUTTON_C] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START) ? joypad1Buttons[BUTTON_PAUSE] = 0xff : joypad1Buttons[BUTTON_PAUSE] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT) ? joypad1Buttons[BUTTON_OPTION] = 0xff : joypad1Buttons[BUTTON_OPTION] = 0x00;
// others pound/hash/0-9
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X) ? joypad1Buttons[BUTTON_0] = 0xff : joypad1Buttons[BUTTON_0] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R) ? joypad1Buttons[BUTTON_d] = 0xff : joypad1Buttons[BUTTON_d] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L) ? joypad1Buttons[BUTTON_s] = 0xff : joypad1Buttons[BUTTON_s] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2) ? joypad1Buttons[BUTTON_1] = 0xff : joypad1Buttons[BUTTON_1] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L2) ? joypad1Buttons[BUTTON_2] = 0xff : joypad1Buttons[BUTTON_2] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3) ? joypad1Buttons[BUTTON_3] = 0xff : joypad1Buttons[BUTTON_3] = 0x00;
input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L3) ? joypad1Buttons[BUTTON_3] = 0xff : joypad1Buttons[BUTTON_3] = 0x00;
}
/************************************
* libretro implementation
************************************/
void retro_get_system_info(struct retro_system_info *info)
{
memset(info, 0, sizeof(*info));
info->library_name = "Virtual Jaguar";
info->library_version = "v2.1.0+";
info->need_fullpath = false;
info->valid_extensions = "j64|jag|bin|rom|zip";
}
void retro_get_system_av_info(struct retro_system_av_info *info)
{
float maspect=(float)game_width/(float)game_height;
printf("start res:%dx%d %f\n",game_width,game_height,maspect);
memset(info, 0, sizeof(*info));
info->timing.fps = FNTSC;
info->timing.sample_rate = SAMPLERATE;
info->geometry.base_width = game_width;
info->geometry.base_height = game_height;
info->geometry.max_width = MAXWIDTH;
info->geometry.max_height = MAXHEIGHT;
info->geometry.aspect_ratio = maspect;
}
void retro_set_controller_port_device(unsigned port, unsigned device)
{
(void)port;
(void)device;
}
size_t retro_serialize_size(void)
{
return 0;
}
bool retro_serialize(void *data, size_t size)
{
return false;
}
bool retro_unserialize(const void *data, size_t size)
{
return false;
}
void retro_cheat_reset(void)
{}
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
(void)index;
(void)enabled;
(void)code;
}
bool retro_load_game(const struct retro_game_info *info)
{
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
{
fprintf(stderr, "Pixel format XRGB8888 not supported by platform, cannot use.\n");
return false;
}
const char *full_path;
if(failed_init)
return false;
full_path = info->path;
vjs.renderType = 0;
check_variables();
jaguarCartInserted = true;
if (log_enabled)
{
bool success = (bool)LogInit("./virtualjaguar.log"); // Init logfile
if (!success)
printf("Failed to open virtualjaguar.log for writing!\n");
}
//strcpy(vjs.EEPROMPath, "/path/to/eeproms/"); // battery saves
JaguarInit(); // set up hardware
memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
//memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
JaguarSetScreenPitch(videoWidth);
JaguarSetScreenBuffer(videoBuffer);
//Init video
for (int i = 0; i < videoWidth * videoHeight; ++i)
videoBuffer[i] = 0xFF00FFFF;
SET32(jaguarMainRAM, 0, 0x00200000); // set up stack
JaguarLoadFile((char *)full_path); // load rom
JaguarReset();
return true;
}
bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, size_t num_info)
{
(void)game_type;
(void)info;
(void)num_info;
return false;
}
void retro_unload_game(void)
{
}
unsigned retro_get_region(void)
{
return RETRO_REGION_NTSC;
}
unsigned retro_api_version(void)
{
return RETRO_API_VERSION;
}
void *retro_get_memory_data(unsigned id)
{
return NULL;
}
size_t retro_get_memory_size(unsigned id)
{
return 0;
}
void retro_init(void)
{
unsigned level = 18;
videoWidth = MAXWIDTH;
videoHeight = MAXHEIGHT;
videoBuffer = (uint32_t *)calloc(sizeof(uint32_t), MAXWIDTH * MAXHEIGHT);
sampleBuffer = (uint16_t *)malloc(BUFMAX * sizeof(uint16_t)); //found in dac.h
memset(sampleBuffer, 0, BUFMAX * sizeof(uint16_t));
game_width = STARTWIDTH;
game_height = STARTHEIGHT;
environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level);
}
void retro_deinit(void)
{
JaguarDone();
if (log_enabled)LogDone(); // Close logfile
free(videoBuffer);
free(sampleBuffer); //found in dac.h
}
void retro_reset(void)
{
JaguarReset();
}
void retro_run(void)
{
bool updated = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
check_variables();
update_input();
JaguarExecuteNew();
static int lastw=STARTWIDTH;
if(lastw!=TOMGetVideoModeWidth()){
retro_get_system_av_info(&g_av_info);
printf("width change:%d-" ,lastw);
lastw=TOMGetVideoModeWidth();
printf(">%d\n" ,lastw);
game_width = TOMGetVideoModeWidth();
game_height = TOMGetVideoModeHeight();
tomWidth = game_width; tomHeight = game_height;
printf("new res:%dx%d %f\n",game_width,game_height,(float)game_width/game_height);
bool ret;
ret = environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &g_av_info.geometry);
}
SDLSoundCallback(NULL,sampleBuffer, vjs.hardwareTypeNTSC==1?BUFNTSC:BUFPAL);
video_cb(videoBuffer, game_width, game_height, MAXWIDTH << 2);
audio_batch_cb((int16_t *)sampleBuffer, vjs.hardwareTypeNTSC==1?BUFNTSC/2:BUFPAL/2);
}