Skip to content

Commit e831c96

Browse files
arodlandmywave82
authored andcommitted
Add "-e rawout" to "play" a file to an OPL2/3 .RAW file
1 parent d3b8424 commit e831c96

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

src/adplay.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <adplug/emuopl.h>
2727
#include <adplug/kemuopl.h>
2828
#include <adplug/wemuopl.h>
29+
#include <adplug/diskopl.h>
2930

3031
/*
3132
* Sun systems declare getopt in unistd.h,
@@ -79,6 +80,7 @@ typedef enum {
7980
#ifdef HAVE_ADPLUG_NUKEDOPL
8081
Emu_Nuked,
8182
#endif
83+
Emu_Rawout,
8284
} EmuType;
8385

8486
/***** Global variables *****/
@@ -184,11 +186,11 @@ static void usage()
184186
program_name);
185187

186188
// Print list of available output mechanisms
187-
printf("Available emulators: satoh ken woody ");
189+
printf("Available emulators: satoh ken woody");
188190
#ifdef HAVE_ADPLUG_NUKEDOPL
189-
printf("nuked");
191+
printf(" nuked");
190192
#endif
191-
printf("\n");
193+
printf(" rawout\n");
192194
printf("Available output mechanisms: "
193195
#ifdef DRIVER_OSS
194196
"oss "
@@ -320,6 +322,12 @@ static int decode_switches(int argc, char **argv)
320322
#ifdef HAVE_ADPLUG_NUKEDOPL
321323
else if(!strcmp(optarg, "nuked")) cfg.emutype = Emu_Nuked;
322324
#endif
325+
else if(!strcmp(optarg, "rawout")) {
326+
cfg.emutype = Emu_Rawout;
327+
cfg.output = null;
328+
cfg.endless = false;
329+
}
330+
323331
else {
324332
message(MSG_ERROR, "unknown emulator -- %s", optarg);
325333
exit(EXIT_FAILURE);
@@ -540,7 +548,8 @@ int main(int argc, char **argv)
540548
}
541549
break;
542550
#endif
543-
}
551+
case Emu_Rawout:
552+
opl = new CDiskopl(cfg.device);
544553

545554
// init player
546555
switch(cfg.output) {
@@ -555,7 +564,7 @@ int main(int argc, char **argv)
555564
#endif
556565
#ifdef DRIVER_NULL
557566
case null:
558-
player = new NullOutput();
567+
player = new NullOutput(opl);
559568
break;
560569
#endif
561570
#ifdef DRIVER_DISK

src/null.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,29 @@
2020
#ifndef H_NULL
2121
#define H_NULL
2222

23-
#include <adplug/silentopl.h>
2423
#include "output.h"
2524

2625
class NullOutput: public Player
2726
{
2827
public:
29-
virtual void frame()
30-
{ }
28+
NullOutput(Copl *nopl)
29+
:opl(nopl)
30+
{ }
31+
32+
virtual void frame() {
33+
playing = p->update();
34+
35+
CDiskopl *dopl = dynamic_cast<CDiskopl *>(opl);
36+
if (dopl != NULL) {
37+
dopl->update(p);
38+
}
39+
}
3140

3241
virtual Copl *get_opl()
33-
{ return &opl; }
42+
{ return opl; }
3443

3544
private:
36-
CSilentopl opl;
45+
Copl *opl;
3746
};
3847

3948
#endif

src/output.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <stdio.h>
2121
#include <adplug/emuopl.h>
2222
#include <adplug/kemuopl.h>
23+
#include <adplug/diskopl.h>
2324

2425
#include "output.h"
2526
#include "defines.h"
@@ -72,6 +73,11 @@ void EmuPlayer::frame()
7273
}
7374
i = MIN(towrite, (long)(minicnt / p->getrefresh() + 4) & ~3);
7475
opl->update((short *)pos, i);
76+
CDiskopl *dopl = dynamic_cast<CDiskopl *>(opl);
77+
if (dopl != NULL) {
78+
dopl->update(p);
79+
}
80+
7581
pos += i * getsampsize(); towrite -= i;
7682
i = (long)(p->getrefresh() * i);
7783
minicnt -= MAX(1, i);

0 commit comments

Comments
 (0)