Skip to content

Commit

Permalink
feat: add two utilties and recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
eshaz committed May 3, 2024
1 parent ba7fadc commit c9dbaac
Show file tree
Hide file tree
Showing 20 changed files with 680 additions and 10 deletions.
12 changes: 2 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*.ilk
*.map
*.exp
*.lk1
*.err

# Precompiled Headers
*.gch
Expand All @@ -29,7 +31,6 @@
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
Expand All @@ -41,12 +42,3 @@
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
10 changes: 10 additions & 0 deletions 1869opl3.mk1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
INSTRUCTION_SET=-5 # 80386 (pentium optimized)
OPTIMIZATION=-os

1869opl3.obj : src\1869opl3.c .AUTODEPEND
*wcc src\1869opl3.c -i="$(%watcom)/h" $(INSTRUCTION_SET) $(OPTIMIZATION) -w4 -e10 -d1 -bt=dos -fo=.obj -ms

1869opl3.com : 1869opl3.obj .AUTODEPEND
@%write 1869opl3.lk1 FIL 1869opl3.obj
@%append 1869opl3.lk1
*wlink name 1869opl3 sys com op maxe=10 op q @1869opl3.lk1
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project : essreg.exe .SYMBOLIC
project : 1869opl3.com .SYMBOLIC

!include essreg.mk1
!include 1869opl3.mk1
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# essreg
ES1869 Register Utility

This repository contains two utilities designed for the ESS AudioDrive ES1869sound card chipset.

## [`essreg.exe`](build)
* Utility to control otherwise unsupported registers for the ES1869 audio chip.
* This program can be executed in native DOS or Windows DOS box environment.
* Sound card with ES1869 chip is assumed to be on I/O port 220h.
* Check out the `d` option that enables digital recording of the FM chip at 48kHz!
* [Examples!](digital_recording)

```
ES1869 Register Utility
(c) 2024 Ethan Halsall <ethan.s.halsall@gmail.com>
|Option------|Description----------------------------------------------
| c | (Calibrate Op Amp)
| r=[path] | (Dump ES1869 Registers)
| | * `path` to save the registers; defaults to essreg.txt
| g | (Get all values)
| 3=[value] | (Get / Set 3D Amount)
| | * 0 3D disable
| | * 1 - 63 3D amount (raw value)
| | * 1% - 100% 3D amount (percent)
| ml=[value] | (Get / Set Mono-In Level)
| | * 0 - 15 Mono-In Level (raw value)
| | * 0% - 100% Mono-In Level (percent)
| m=[1,0] | (Enable / Disable Mono-In)
| p=[1,0] | (Enable / Disable Mic Preamp)
| d=[1,0] | (Enable / Disable FM,IIS,ES689 digital record)
| t=[1,0] | (Enable / Disable Telegaming Mode)
`3`, `ml`, `m`, `p`, `d`, `t`
* Omitting the parameter will show the current value.
Example: `essreg r=before.txt 3=0 m=1 p=1 r=0 t=0 r=after.txt`
```

## [`1869opl3.com`](build)
* Utility to fix ES1869 OPL3 playback for some games in the Windows DOS box.
* This program reads the FM volume mixer register on the sound card and then runs the application.
* Sound card with ES1869 chip is assumed to be on I/O port 220h.

```
Example:
c:\>1869opl3.com "c:\path\to\game.exe"
```

## Building

### Prerequisites
* MSDOS like build environment (MS-DOS, Windows 9x, DOS-BOX, etc.)
* [Watcom C 11.0](https://winworldpc.com/product/watcom-c-c/110b)

### Building
* Clone this repo and copy it your build environment.
* Run [`build.bat`](build.bat) to build the executables

### Testing
* This code has been tested using a real ES1869 soundcard on I/O port 0x220. It probably won't work with any other ESS sound chips.

## License
* GPL 3.0

## Thanks to
* The community over at [Vogons](https://www.vogons.org/viewtopic.php?f=62&p=1258077) who helped out!
* [Phil's Computer Lab](https://www.philscomputerlab.com/ess-audiodrive-es1868.html) for uploading the ES1869 datasheet!
8 changes: 8 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\NETCOM;%PATH%;C:\WATCOM\BINNT;C:\WATCOM\BINW
SET INCLUDE=C:\WATCOM\H;C:\WATCOM\MFC\INCLUDE;C:\WATCOM\H\NT
SET WATCOM=C:\WATCOM
SET EDPATH=C:\WATCOM\EDDAT
wmake
move essreg.exe build\essreg.exe
move es1869opl3.com build\es1869opl3.com

Binary file added build/1869opl3.com
Binary file not shown.
Binary file added build/essreg.exe
Binary file not shown.
Binary file added digital_recording/3d_ultra_pinball_colony.flac
Binary file not shown.
Binary file added digital_recording/3d_ultra_pinball_menu.flac
Binary file not shown.
Binary file added digital_recording/GROOVE.MID
Binary file not shown.
Binary file added digital_recording/groove.flac
Binary file not shown.
53 changes: 53 additions & 0 deletions essconf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
HKR,Config,"3D Effect",01,20,20,00,00
HKR,Config,"3D Effect",01,80,80,80,80
HKR,Config,"3D Effect",01,DA,DA,00,00
HKR,Config,"3D Effect",01,FF,FF,FF,FF
HKR,Config,"3D Effect Enable",01,00,00,00,00
HKR,Config,"3D Effect Enable",01,FF,FF,00,00
HKR,Config,"3D Limit",01,00,00,00,00
HKR,Config,"AuxBVolumeInMap",01, \
HKR,Config,"AuxBVolumeOutMap",01, \
HKR,Config,Bass,01,FF,7F,FF,7F
HKR,Config,"CDAudioVolumeInMap",01, \
HKR,Config,"CDAudioVolumeOutMap",01, \
HKR,Config,"DCdrift",01,00,00,00,00
;HKR,Config,"Disable Mic Gain",01,FF
;HKR,Config,"Disable Mic Preamp",01,00
HKR,Config,"Disable Warning",01,FF
HKR,Config,"Enable AUXB",01,00,00,00,00
HKR,Config,"Enable AUXB",01,01,00,00,00
;HKR,Config,"Enable ES938",01,01,00,00,00
HKR,Config,"Enable ES938",01,ff,00,00,00
;HKR,Config,"Enable IIS",01,00,00,00,00
;HKR,Config,"Enable Software 3D Effect",01,01,00,00,00
;HKR,Config,"HwVolume 2-Wire Mode",01,01,00,00,00
;HKR,Config,"HwVolumeMap",01, \
;HKR,Config,"HwVolumeStep",01,02,00,00,00
HKR,Config,"IISVolumeOutMap",01, \
HKR,Config,"LineInVolumeInMap",01, \
HKR,Config,"LineInVolumeOutMap",01, \
;HKR,Config,"Mappable Input",01,01,00,00,00
;HKR,Config,"Mappable Input Mute Label",,"X-Mic Mute"
;HKR,Config,"Mappable Input Mute LongLabel",,"X-Microphone Mute"
;HKR,Config,"Mappable Input Source Label",,"X-Mic"
;HKR,Config,"Mappable Input Source LongLabel",,"X-Microphone"
;HKR,Config,"Mappable Input Volume Label",,"X-Mic Volume"
;HKR,Config,"Mappable Input Volume LongLabel",,"X-Microphone Volume Level"
HKR,Config,"MicVolumeInMap",01, \
HKR,Config,"MicVolumeOutMap",01, \
HKR,Config,"Mixer:Output",01,5b,00,00,00
HKR,Config,"MonoInPhoneMute",01,00,00,00,00
;HKR,Config,"MonoInPhoneMute",01,ff
HKR,Config,"Multiple FM Support",01,FF
HKR,Config,MutesOut,01,44,00,00,00
HKR,Config,"PCSpeakerVol",01,00,40,00,00
;HKR,Config,"Single Mode DMA",01,01,00,00,00
HKR,Config,"SynthVolumeInMap",01, \
HKR,Config,"SynthVolumeOutMap",01, \
;HKR,Config,"Telegaming",01,01,00,00,00
HKR,Config,"Telegaming",01,01,00,00,00
HKR,Config,"Telegaming Vol",01,FF,00,00,00
HKR,Config,Treble,01,FF,7F,FF,7F
;HKR,Config,"Want Local Powerdown",01,01,00,00,00
HKR,Config,"WaveVolumeInMap",01, \
HKR,Config,"WaveVolumeOutMap",01, \
16 changes: 16 additions & 0 deletions essreg.mk1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
INSTRUCTION_SET=-5 # 80386 (pentium optimized)
OPTIMIZATION=-osbhlkp

regs.obj : src\regs.c .AUTODEPEND
*wcc src\regs.c -i="$(%watcom)/h" $(INSTRUCTION_SET) $(OPTIMIZATION) -w4 -e10 -d1 -bt=dos -fo=.obj -ms

debug.obj : src\debug.c .AUTODEPEND
*wcc src\debug.c -i="$(%watcom)/h" $(INSTRUCTION_SET) $(OPTIMIZATION) -w4 -e10 -d1 -bt=dos -fo=.obj -ms

main.obj : src\main.c .AUTODEPEND
*wcc src\main.c -i="$(%watcom)/h" $(INSTRUCTION_SET) $(OPTIMIZATION) -w4 -e10 -d1 -bt=dos -fo=.obj -ms

essreg.exe : regs.obj debug.obj main.obj .AUTODEPEND
@%write essreg.lk1 FIL main.obj,debug.obj,regs.obj
@%append essreg.lk1
*wlink name essreg sys dos op m libf cstart_t op maxe=10 op q op DOSSEG op STACK=512 op el sort @essreg.lk1
1 change: 1 addition & 0 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ES1869FM volume assigned to IISResetting mixer fixes opl3, freezes windows audioDisabling es689 bit in mixer register enables opl3just reading a mixer reg enables opl3having another sound operation before reading the register does not enable the opl3, might be that it's required to read a register before going to dos mode to enable the opl3
Expand Down
42 changes: 42 additions & 0 deletions src/1869opl3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 1869opl3 is a program to allow OPL2 / OPL3 FM
* playback with the ES1869 drivers in a Windows
* dos box.
*
* Notes:
*
* The FM synthesizer volume may be mapped to the IIS
* volume mixer in Windows. The mixer volume for IIS may
* set to zero, but must not be muted.
*
* Usage:
* `1869opl3 "c:\path\to\game.exe /arg1 /arg2"`
*
* (c) 2024 Ethan Halsall <ethan.s.halsall@gmail.com>
*
* Licensed under GPL Version 3.0
*/

#include <conio.h>
#include <process.h>

int main(int argc, char **argv) {
int audio_base = 0x220;
char application_path[256];
unsigned char prev_val;

getcmd(application_path);

// set mixer register to full FM volume
outp(audio_base + 0x04, 0x36);
prev_val = inp(audio_base + 0x05);
outp(audio_base + 0x05, 0xff);

// execute the command supplied from the args
system(application_path);

// reset FM volume to previous value
outp(audio_base + 0x04, 0x36);
outp(audio_base + 0x05, prev_val);
return 0;
}
48 changes: 48 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "debug.h"
#include "regs.h"

void print_reg(unsigned int reg_addr, unsigned char reg_value) {
fprintf(stderr, "%02X | %02X | "BIN_PAT" \n", reg_addr, reg_value, BIN(reg_value));
}

void dump_regs(const char* path) {
unsigned int i;
unsigned int reg_addr;
unsigned int reg_value;
FILE* fd;

fd = freopen(path, "w", stderr);

fprintf(stderr, "Config Regs: \n");
for (i = 0; i < config_reg_count; i++) {
reg_addr = config_regs[i];
reg_value = inp(config_base + reg_addr);
print_reg(reg_addr, reg_value);
}

fprintf(stderr, "Config Audio: \n");
for (i = 0; i < audio_config_reg_count; i++) {
reg_addr = audio_config_regs[i];
reg_value = read_audio_reg(reg_addr);
print_reg(reg_addr, reg_value);
}

fprintf(stderr, "Audio Regs: \n");
for (i = 0; i < audio_reg_count; i++) {
reg_addr = audio_regs[i];
reg_value = inp(audio_base + reg_addr);
print_reg(reg_addr, reg_value);
}

fprintf(stderr, "Audio Mixer Regs: \n");
for (i = 0; i < mixer_reg_count; i++) {
reg_addr = mixer_regs[i];
reg_value = read_mixer_reg(reg_addr);
print_reg(reg_addr, reg_value);
}

fflush(fd);
fclose(fd);

printf("Saved registers to %s\n", path);
}
100 changes: 100 additions & 0 deletions src/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include <io.h>
#include <stdio.h>
#include <dos.h>

#ifndef DEBUG_H
#define DEBUG_H

void print_reg(unsigned int reg_addr, unsigned char reg_value);
void dump_regs(const char* path);

unsigned char config_reg_count = 2;
unsigned char config_regs[2] = {
0x06, // Interrupt Status Register
0x07 // Interrupt Mask Register
};

unsigned char audio_config_reg_count = 14;
unsigned char audio_config_regs[14] = {
0x30, // Activate
0x31, // IO Range Check
0x60, // Audio processor IO Base Address 11:8
0x61, // Audio processor IO Base Address 7:4
0x62, // FM Alias IO Base Address 11:8
0x63, // FM Alias IO Base Address 7:2
0x64, // MPU-401 IO Base Address 11:8
0x65, // MPU-401 IO Base Address 7:2
0x70, // Interrupt Request Channel 1 Select
0x71, // Interrupt Request Type Select 1
0x72, // Interrupt Request Channel 2 Select
0x73, // Interrupt Request Type Select 2
0x74, // DMA Channel 1 Select
0x75, // DMA Channel 2 Select
};

unsigned char audio_reg_count = 2;
unsigned char audio_regs[2] = {
0x06, // Reset and Status flags
0x07, // Power Management
};

unsigned char mixer_reg_count = 53;
unsigned char mixer_regs[53] = {
0x00,
// sound blaster mixer
0x04,
0x0a,
0x0c,
0x0e,
0x22,
0x26,
0x28,
0x2e,
// ess mixer
0x14,
0x1a,
0x1c,
0x32,
0x36,
0x38,
0x3a,
0x3c,
0x3e,
0x40,
0x42,
0x44,
0x46,
0x48,
0x4a,
0x4c,
0x4e,
0x50,
0x52,
0x60,
0x61,
0x62,
0x63,
0x64,
0x65,
0x66,
0x68,
0x69,
0x6a,
0x6b,
0x6c,
0x6d,
0x6e,
0x6f,
0x70,
0x71,
0x72,
0x74,
0x76,
0x78,
0x7a,
0x7c,
0x7d,
0x7f
};

#endif /* DEBUG_H */
Loading

0 comments on commit c9dbaac

Please sign in to comment.