ref: 7d1bc4ab95db2a1199150eb91cc0d7b1a5dd1128
parent: 3b2f4d3df58368ce53243dd992612b9fcb7f0d1a
author: Konstantinn Bonnet <qu7uux@gmail.com>
date: Sat Dec 3 21:57:23 EST 2016
disown opl2(1)
--- a/man/1/opl2
+++ /dev/null
@@ -1,62 +1,0 @@
-.TH OPL2 1
-.SH NAME
-opl2 \- OPL2 chip emulator
-.SH SYNOPSIS
-.B opl2
-[
-.B -n
-.I rate
-] [
-.I file
-]
-.SH DESCRIPTION
-.I Opl2
-is an emulator of a single Yamaha 3812 chip, also known as
-.SM OPL2.
-.PP
-The emulated chip is programmed by a stream of commands either from stdin or
-from
-.IR file .
-Guided by these commands, it then synthesizes a number of 16 bit little-endian samples for a sampling rate of 44.1 kHz.
-Each is duplicated for stereo sound and written to stdout.
-.PP
-While the output's sampling rate is the same as the audio device's default (see
-.IR audio (3)),
-the chip is meant to be sampled at a much lower rate, 700 Hz by default.
-A different expected sampling rate is given in Hz using the
-.B -n
-parameter.
-Internally, for each sample,
-.I opl2
-generates a number of additional samples depending on this rate.
-.PP
-Commands are 4 bytes formatted as follows, where the size of each field is given in bytes between brackets:
-.RS
-.IR register [1]
-.IR value [1]
-.IR delay [2]
-.RE
-.PP
-Each command specifies a
-.I value
-to be written to an
-.SM OPL2
-chip
-.IR register ,
-modifying its internal state.
-The
-.I delay
-field indicates a multiple of the expected sampling period (the inverse of the expected sampling rate) during which the chip should be sampled before processing the next command.
-Output is then triggered by a non-zero delay.
-.I Delay
-is stored as a 16-bit unsigned integer in little-endian byte order.
-.SH "SEE ALSO"
-.IR wl3d (1) ,
-.IR audio (3)
-.SH HISTORY
-.I Opl2
-first appeared for 9front (May, 2016), based on
-.I fmopl.c
-from the Multiple Arcade Machine Emulator (
-.SM MAME
-).
--- a/mkfile
+++ b/mkfile
@@ -1,11 +1,9 @@
</$objtype/mkfile
-TARG=\
- opl2\
- wl3d\
+BIN=$home/bin/$objtype
+TARG=wl3d
-OFILES=
-WOFILES=\
+OFILES=\
drw.$O\
fs.$O\
gm.$O\
@@ -18,17 +16,10 @@
HFILES= dat.h fns.h
-</sys/src/cmd/mkmany
-BIN=$home/bin/$objtype
+</sys/src/cmd/mkone
sysinstall:V:
mkdir -p /sys/games/lib/wl3d
- cp intro.wl6 intro.sod /sys/games/lib/wl3d
- cp man/1/wl3d man/1/opl2 /sys/man/1
- cp man/6/wl3d /sys/man/6
-
-$O.wl3d: $WOFILES
- $LD -o $target $prereq
-
-$O.opl2: opl2.$O opl2m.$O
- $LD -o $target $prereq
+ cp intro.wl6 intro.sod /sys/games/lib/wl3d/
+ cp man/1/wl3d /sys/man/1/
+ cp man/6/wl3d /sys/man/6/
--- a/opl2m.c
+++ /dev/null
@@ -1,65 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <bio.h>
-
-uchar* opl2out(uchar *, int);
-void opl2wr(int, int);
-void opl2init(int);
-
-enum{
- Rate = 44100,
- Hz = 700,
- Samp = Rate / Hz
-};
-
-void
-usage(void)
-{
- fprint(2, "usage: %s [-n nsamp] [file]\n", argv0);
- exits("usage");
-}
-
-void
-main(int argc, char **argv)
-{
- int n, r, v, dt, nsamp, fd;
- uchar *sb, u[4];
- Biobuf *bi, *bo;
-
- fd = 0;
- nsamp = Samp;
- ARGBEGIN{
- case 'n':
- nsamp = Rate / atoi(EARGF(usage()));
- break;
- default:
- usage();
- }ARGEND;
- if(*argv != nil){
- fd = open(*argv, OREAD);
- if(fd < 0)
- sysfatal("open: %r");
- }
- bi = Bfdopen(fd, OREAD);
- bo = Bfdopen(1, OWRITE);
- if(bi == nil || bo == nil)
- sysfatal("Bfdopen: %r");
- nsamp *= 4;
- sb = malloc(nsamp);
- if(sb == nil)
- sysfatal("malloc: %r");
- opl2init(Rate);
-
- while(n = Bread(bi, u, sizeof u), n > 0){
- r = u[0];
- v = u[1];
- dt = u[3]<<8 | u[2];
- opl2wr(r, v);
- while(dt-- > 0){
- opl2out(sb, nsamp);
- Bwrite(bo, sb, nsamp);
- }
- }
- if(n < 0)
- sysfatal("Bread: %r");
-}