adlib.c (36cd6f6f20724d49aac1910e310f81a43e0cb657) adlib.c (db895a1e6a97e919f9b86d60c969377357b05066)
1/*
2 * QEMU Proxy for OPL2/3 emulation by MAME team
3 *
4 * Copyright (c) 2004-2005 Vassili Karpov (malc)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 269 unchanged lines hidden (view full) ---

278 g_free (s->mixbuf);
279 }
280
281 s->active = 0;
282 s->enabled = 0;
283 AUD_remove_card (&s->card);
284}
285
1/*
2 * QEMU Proxy for OPL2/3 emulation by MAME team
3 *
4 * Copyright (c) 2004-2005 Vassili Karpov (malc)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights

--- 269 unchanged lines hidden (view full) ---

278 g_free (s->mixbuf);
279 }
280
281 s->active = 0;
282 s->enabled = 0;
283 AUD_remove_card (&s->card);
284}
285
286static int Adlib_initfn (ISADevice *dev)
286static void adlib_realizefn (DeviceState *dev, Error **errp)
287{
288 AdlibState *s = ADLIB(dev);
289 struct audsettings as;
290
291 if (glob_adlib) {
287{
288 AdlibState *s = ADLIB(dev);
289 struct audsettings as;
290
291 if (glob_adlib) {
292 dolog ("Cannot create more than 1 adlib device\n");
293 return -1;
292 error_setg (errp, "Cannot create more than 1 adlib device");
293 return;
294 }
295 glob_adlib = s;
296
297#ifdef HAS_YMF262
298 if (YMF262Init (1, 14318180, s->freq)) {
294 }
295 glob_adlib = s;
296
297#ifdef HAS_YMF262
298 if (YMF262Init (1, 14318180, s->freq)) {
299 dolog ("YMF262Init %d failed\n", s->freq);
300 return -1;
299 error_setg (errp, "YMF262Init %d failed", s->freq);
300 return;
301 }
302 else {
303 YMF262SetTimerHandler (0, timer_handler, 0);
304 s->enabled = 1;
305 }
306#else
307 s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
308 if (!s->opl) {
301 }
302 else {
303 YMF262SetTimerHandler (0, timer_handler, 0);
304 s->enabled = 1;
305 }
306#else
307 s->opl = OPLCreate (OPL_TYPE_YM3812, 3579545, s->freq);
308 if (!s->opl) {
309 dolog ("OPLCreate %d failed\n", s->freq);
310 return -1;
309 error_setg (errp, "OPLCreate %d failed", s->freq);
310 return;
311 }
312 else {
313 OPLSetTimerHandler (s->opl, timer_handler, 0);
314 s->enabled = 1;
315 }
316#endif
317
318 as.freq = s->freq;

--- 8 unchanged lines hidden (view full) ---

327 s->voice,
328 "adlib",
329 s,
330 adlib_callback,
331 &as
332 );
333 if (!s->voice) {
334 Adlib_fini (s);
311 }
312 else {
313 OPLSetTimerHandler (s->opl, timer_handler, 0);
314 s->enabled = 1;
315 }
316#endif
317
318 as.freq = s->freq;

--- 8 unchanged lines hidden (view full) ---

327 s->voice,
328 "adlib",
329 s,
330 adlib_callback,
331 &as
332 );
333 if (!s->voice) {
334 Adlib_fini (s);
335 return -1;
335 error_setg (errp, "Initializing audio voice failed");
336 return;
336 }
337
338 s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
339 s->mixbuf = g_malloc0 (s->samples << SHIFT);
340
341 register_ioport_read (0x388, 4, 1, adlib_read, s);
342 register_ioport_write (0x388, 4, 1, adlib_write, s);
343
344 register_ioport_read (s->port, 4, 1, adlib_read, s);
345 register_ioport_write (s->port, 4, 1, adlib_write, s);
346
347 register_ioport_read (s->port + 8, 2, 1, adlib_read, s);
348 register_ioport_write (s->port + 8, 2, 1, adlib_write, s);
337 }
338
339 s->samples = AUD_get_buffer_size_out (s->voice) >> SHIFT;
340 s->mixbuf = g_malloc0 (s->samples << SHIFT);
341
342 register_ioport_read (0x388, 4, 1, adlib_read, s);
343 register_ioport_write (0x388, 4, 1, adlib_write, s);
344
345 register_ioport_read (s->port, 4, 1, adlib_read, s);
346 register_ioport_write (s->port, 4, 1, adlib_write, s);
347
348 register_ioport_read (s->port + 8, 2, 1, adlib_read, s);
349 register_ioport_write (s->port + 8, 2, 1, adlib_write, s);
349
350 return 0;
351}
352
353static Property adlib_properties[] = {
354 DEFINE_PROP_HEX32 ("iobase", AdlibState, port, 0x220),
355 DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100),
356 DEFINE_PROP_END_OF_LIST (),
357};
358
359static void adlib_class_initfn (ObjectClass *klass, void *data)
360{
361 DeviceClass *dc = DEVICE_CLASS (klass);
350}
351
352static Property adlib_properties[] = {
353 DEFINE_PROP_HEX32 ("iobase", AdlibState, port, 0x220),
354 DEFINE_PROP_UINT32 ("freq", AdlibState, freq, 44100),
355 DEFINE_PROP_END_OF_LIST (),
356};
357
358static void adlib_class_initfn (ObjectClass *klass, void *data)
359{
360 DeviceClass *dc = DEVICE_CLASS (klass);
362 ISADeviceClass *ic = ISA_DEVICE_CLASS (klass);
363 ic->init = Adlib_initfn;
361
362 dc->realize = adlib_realizefn;
364 dc->desc = ADLIB_DESC;
365 dc->props = adlib_properties;
366}
367
368static const TypeInfo adlib_info = {
369 .name = TYPE_ADLIB,
370 .parent = TYPE_ISA_DEVICE,
371 .instance_size = sizeof (AdlibState),

--- 16 unchanged lines hidden ---
363 dc->desc = ADLIB_DESC;
364 dc->props = adlib_properties;
365}
366
367static const TypeInfo adlib_info = {
368 .name = TYPE_ADLIB,
369 .parent = TYPE_ISA_DEVICE,
370 .instance_size = sizeof (AdlibState),

--- 16 unchanged lines hidden ---