2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2005 Simon Peter, <dn.tlp@gmx.net>, et al.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * emutest.cpp - Test AdPlug emulators, by Simon Peter <dn.tlp@gmx.net>
25 #include "../src/emuopl.h"
27 /***** Local variables *****/
29 // String holding the relative path to the source directory
32 /***** Local functions *****/
36 static bool check_emu_output(CEmuopl *emu)
38 * Test if the emulator produces any output.
41 short *buf = (short *)calloc(BUF_SIZE, sizeof(short));
42 bool nonull = false, no10k = true, nom10k = true;
46 emu->write(1, 5 << 1);
48 // set test instrument
50 emu->write(0x40, 0x10);
51 emu->write(0x60, 0xf0);
52 emu->write(0x80, 0x77);
53 emu->write(0xa0, 0x98);
56 emu->write(0x63, 0xf0);
57 emu->write(0x83, 0x77);
58 emu->write(0xb0, 0x31);
60 // check output from emu
61 emu->update(buf, BUF_SIZE);
62 for(int i = 0; i < BUF_SIZE; i++) {
63 if(buf[i] != 0) nonull = true;
64 if(buf[i] > 10000) no10k = false;
65 if(buf[i] < -10000) nom10k = false;
70 return (nonull && no10k && nom10k);
73 /***** Main program *****/
75 int main(int argc, char *argv[])
79 // Set path to source directory
80 srcdir = getenv("srcdir");
81 if(!srcdir) srcdir = ".";
84 CEmuopl emu(8000, true, false);
85 retval = check_emu_output(&emu);
88 return retval ? EXIT_SUCCESS : EXIT_FAILURE;