Skip to content

Commit c85a3b8

Browse files
committed
Vsync and SB config in settings.dat
1 parent 0a56b43 commit c85a3b8

8 files changed

Lines changed: 72 additions & 14 deletions

File tree

src/main.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@ int my_main (int argc, char** argv)
322322
ma_freq = 22050;
323323
}
324324

325+
if (settings.get("vsync"))
326+
{
327+
setenv("FX_GLIDE_SWAPINTERVAL", "1", 1);
328+
setenv("SST_SWAP_EN_WAIT_ON_VIDSYNC", "1", 1);
329+
}
330+
else
331+
{
332+
setenv("FX_GLIDE_SWAPINTERVAL", "0", 1);
333+
setenv("SST_SWAP_EN_WAIT_ON_VIDSYNC", "0", 1);
334+
}
335+
325336
// initialize SDL video
326337
/*if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
327338
{
@@ -374,6 +385,9 @@ int my_main (int argc, char** argv)
374385
static const ALCint attribs[] = {
375386
ALC_FREQUENCY, ma_freq,
376387
ALC_MONO_SOURCES, 14,
388+
ALC_EXT_SB_A, (ALCint)settings.get("blaster_a"),
389+
ALC_EXT_SB_I, (ALCint)settings.get("blaster_i"),
390+
ALC_EXT_SB_D, (ALCint)settings.get("blaster_d"),
377391
0, 0
378392
};
379393

src/minial.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,30 @@ ALCcontext* alcCreateContext(const ALCdevice* device, const ALCint* attrlist)
8484
ALCint freq = 22050;
8585
ALCint monoSources = 32;
8686

87+
ALCint blasterA = 0, blasterI = 0, blasterD = 0;
88+
8789
if (attrlist)
8890
{
8991
for (int i = 0; attrlist[i * 2] || attrlist[i * 2 + 1]; ++i)
9092
{
91-
switch (attrlist[i * 2])
93+
ALCint key = attrlist[i * 2];
94+
ALCint val = attrlist[i * 2 + 1];
95+
switch (key)
9296
{
9397
case ALC_FREQUENCY:
94-
freq = attrlist[i * 2 + 1];
98+
freq = val;
9599
break;
96100
case ALC_MONO_SOURCES:
97-
monoSources = attrlist[i * 2 + 1];
101+
monoSources = val;
102+
break;
103+
case ALC_EXT_SB_A:
104+
blasterA = val;
105+
break;
106+
case ALC_EXT_SB_I:
107+
blasterI = val;
108+
break;
109+
case ALC_EXT_SB_D:
110+
blasterD = val;
98111
break;
99112
default:
100113
break;
@@ -107,7 +120,7 @@ ALCcontext* alcCreateContext(const ALCdevice* device, const ALCint* attrlist)
107120

108121
if (device == 0 || strcmp(device->deviceName, "default") == 0 || strcmp(device->deviceName, "sb") == 0)
109122
{
110-
alcContext->minialInterface = new MinialSB(freq);
123+
alcContext->minialInterface = new MinialSB(freq, blasterA, blasterI, blasterD);
111124
}
112125
else if (strcmp(device->deviceName, "none") == 0)
113126
{

src/minial.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ typedef unsigned int ALuint;
1818
#define ALC_ALL_DEVICES_SPECIFIER 0x1013
1919
#define ALC_FREQUENCY 0x1007
2020
#define ALC_MONO_SOURCES 0x1010
21+
#define ALC_EXT_SB_A 0xE0002
22+
#define ALC_EXT_SB_I 0xE0003
23+
#define ALC_EXT_SB_D 0xE0004
2124

2225
ALCboolean alcCloseDevice(ALCdevice *device);
2326
ALCcontext* alcCreateContext(const ALCdevice *device, const ALCint *attrlist);

src/minial_sb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#include "sb.h"
44
#include <cmath>
55

6-
MinialSB::MinialSB(ALCint freq)
6+
MinialSB::MinialSB(ALCint freq, ALCint sbA, ALCint sbI, ALCint sbD)
77
{
88
m_freq = freq;
99
floatBuff.resize(DMA_CHUNK);
1010

11-
if (sb_init())
11+
if (sb_init(sbA, sbI, sbD))
1212
{
1313
m_valid = true;
1414
StreamStart(m_freq);

src/minial_sb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct MA_SB_Buffer
4040
class MinialSB : public MinialInterface
4141
{
4242
public:
43-
MinialSB(ALCint freq);
43+
MinialSB(ALCint freq, ALCint sbA, ALCint sbI, ALCint sbD);
4444
virtual ~MinialSB();
4545
virtual void GenSources(ALsizei n, ALuint *sources) override;
4646
virtual void GenBuffers(ALsizei n, ALuint *buffers) override;

src/sb.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,24 @@ int sb_init_buffers()
375375
* for sample playing.
376376
*
377377
* Call this once per program, not once per sample. */
378-
int sb_init()
378+
int sb_init(int sbA, int sbI, int sbD)
379379
{
380380
memset(&rm_regs, 0, sizeof(_go32_dpmi_registers));
381381
/* undefined registers cause trouble */
382382
rm_si.size = -1; /* to allow safety check before free */
383383
pm_si.size = -1;
384384
dosmem.size = -1;
385385

386-
sb_getparams(); /* Card card params and initialize card. */
386+
if (sbA)
387+
{
388+
sb_ioaddr = sbA;
389+
sb_irq = sbI;
390+
sb_dmachan = sbD;
391+
}
392+
else
393+
{
394+
sb_getparams(); /* Card card params and initialize card. */
395+
}
387396
sb_ioaddr = sb_initcard();
388397

389398
if (sb_ioaddr)

src/sb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void sb_voice(int state);
142142
void sb_getparams();
143143
int sb_initcard();
144144
int sb_init_buffers();
145-
int sb_init();
145+
int sb_init(int sbA, int sbI, int sbD);
146146
int sb_read_dac(int Base);
147147

148148
void sb_install_interrupts(void (*sb_intr)(_go32_dpmi_registers*));

src/settings_dat.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const Sett_entry_base entry_base[] = {
2222
{"sound_device", 1, 0, 2, "0 - none, 1 - SB, 2 - GUS"},
2323
{"sound_quality", 2, 1, 2, "1 - low quality, 2 - normal quality"},
2424
{"sound_volume", 100, 0, 100, "0 - 100"},
25+
{"blaster_a", 0, 0, 0x280, "SB address (0 - use A, I, D from BLASTER)"},
26+
{"blaster_i", 0, 0, 15, "SB IRQ"},
27+
{"blaster_d", 0, 0, 7, "SB DMA"},
2528
{"last_laps", 3, 1, 50, "last session"},
2629
{"last_daytime", 0, 0, 1, "0 - day, 1 - evening"},
2730
{"last_track", 0, 0, UINT_MAX, ""},
@@ -89,7 +92,14 @@ int Settings::load()
8992
bool found = false;
9093
for (unsigned int i = 0; i != entry_size; ++i)
9194
{
92-
snprintf(format, 1023, "%s %s", entry_base[i].key, "%u");
95+
if (strcmp(entry_base[i].key, "blaster_a") == 0)
96+
{
97+
snprintf(format, 1023, "%s %s", entry_base[i].key, "%x");
98+
}
99+
else
100+
{
101+
snprintf(format, 1023, "%s %s", entry_base[i].key, "%u");
102+
}
93103
unsigned int val;
94104
if (sscanf(buff, format, &val) == 1)
95105
{
@@ -258,9 +268,18 @@ int Settings::save()
258268
if (!fout) return 1;
259269
for (unsigned int i = 0; i != entry_size; ++i)
260270
{
261-
fprintf(fout, "%s %d%s%s \n", entry_base[i].key,
262-
std::max(std::min(entry[i].val, entry_base[i].maxval), entry_base[i].minval),
263-
strlen(entry_base[i].comment) ? " // " : "" , entry_base[i].comment);
271+
if (strcmp(entry_base[i].key, "blaster_a") == 0)
272+
{
273+
fprintf(fout, "%s %d%s%s \n", entry_base[i].key,
274+
std::max(std::min(entry[i].val, entry_base[i].maxval), entry_base[i].minval),
275+
strlen(entry_base[i].comment) ? " // " : "" , entry_base[i].comment);
276+
}
277+
else
278+
{
279+
fprintf(fout, "%s %d%s%s \n", entry_base[i].key,
280+
std::max(std::min(entry[i].val, entry_base[i].maxval), entry_base[i].minval),
281+
strlen(entry_base[i].comment) ? " // " : "" , entry_base[i].comment);
282+
}
264283
}
265284

266285
for (unsigned i = 0; i != 16; ++i)

0 commit comments

Comments
 (0)