Several cleanups, dynloading OpenAL and FluidSynth, update makefile for crosscompiling using MinGW.

This commit is contained in:
waltje
2018-02-24 23:16:21 -05:00
parent 779cbe062d
commit 51aecc4ba6
10 changed files with 733 additions and 584 deletions

View File

@@ -10,7 +10,7 @@
*
* NOTE: FIXME: Strings 2176 and 2193 are same.
*
* Version: @(#)language.h 1.0.1 2018/02/14
* Version: @(#)language.h 1.0.2 2018/02/24
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -181,6 +181,7 @@
#define IDS_2175 2175 // "ZIP images (*.IM?)\0*.IM..."
#define IDS_2176 2176 // "ZIP images (*.IM?)\0*.IM..."
#define IDS_2177 2177 // "ZIP %i (%03i): %ls"
#define IDS_2178 2178 // "Unable to initialize OpenAL.."
#define IDS_4096 4096 // "Hard disk (%s)"
#define IDS_4097 4097 // "%01i:%01i"
@@ -261,7 +262,7 @@
#define IDS_LANG_ENUS IDS_7168
#define STR_NUM_2048 130
#define STR_NUM_2048 131
#define STR_NUM_3072 11
#define STR_NUM_4096 20
#define STR_NUM_4352 7

View File

@@ -8,7 +8,7 @@
*
* Handling of the emulated machines.
*
* Version: @(#)machine.c 1.0.1 2018/02/14
* Version: @(#)machine.c 1.0.2 2018/02/24
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -51,17 +51,24 @@
#include "../serial.h"
#include "../disk/hdc.h"
#include "../disk/hdc_ide.h"
#include "../plat.h"
#include "machine.h"
int machine;
int AT, PCI;
int romset;
#define PATH_ROM_BIOS "roms/machines"
int romset;
int machine;
int AT, PCI;
void
machine_init(void)
{
char temp[1024];
int i;
pclog("Initializing as \"%s\"\n", machine_getname());
ide_set_bus_master(NULL, NULL, NULL);
@@ -71,7 +78,21 @@ machine_init(void)
PCI = IS_ARCH(machine, MACHINE_PCI);
/* Load the machine's ROM BIOS. */
#if 0
strcpy(temp, PATH_ROM_BIOS);
i = strlen(temp);
#ifdef _WIN32
temp[i++] = '\\';
#else
temp[i++] = '/';
#endif
strcpy(&temp[i], machines[machine].bios_path);
rom_load_bios(temp);
#else
rom_load_bios(romset);
#endif
/* Activate the ROM BIOS. */
mem_add_bios();
/* All good, boot the machine! */

View File

@@ -8,7 +8,7 @@
*
* Handling of the emulated machines.
*
* Version: @(#)machine.h 1.0.2 2018/02/22
* Version: @(#)machine.h 1.0.3 2018/02/24
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -60,16 +60,16 @@
typedef struct _machine_ {
const char *name;
int id;
const char *internal_name;
const char *bios_path;
const char *name;
int id;
const char *internal_name;
const char *bios_path;
struct {
const char *name;
const char *name;
#ifdef EMU_CPU_H
CPU *cpus;
CPU *cpus;
#else
void *cpus;
void *cpus;
#endif
} cpu[5];
int fixed_gfxcard;

View File

@@ -49,7 +49,7 @@
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include <pcap.h>
#include <pcap/pcap.h>
#include "../emu.h"
#include "../config.h"
#include "../device.h"

View File

@@ -10,7 +10,7 @@
*
* Based on the "libpcap" examples.
*
* Version: @(#)pcap_if.c 1.0.8 2018/02/14
* Version: @(#)pcap_if.c 1.0.9 2018/02/24
*
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -52,7 +52,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <pcap.h>
#include <pcap/pcap.h>
#include <time.h>
#include "../emu.h"
#include "../plat.h"

View File

@@ -8,7 +8,7 @@
*
* Definitions for the ROM image handler.
*
* Version: @(#)rom.h 1.0.1 2018/02/14
* Version: @(#)rom.h 1.0.2 2018/02/23
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
*
@@ -60,6 +60,8 @@
romset==ROM_WIN486)
#endif
#define ROMDEF_NFILES 8 /* max number of rom image files */
typedef struct {
uint8_t *rom;
@@ -67,6 +69,19 @@ typedef struct {
mem_mapping_t mapping;
} rom_t;
typedef struct {
int mode;
int nfiles;
uint32_t offset;
uint32_t total;
struct romfile {
char path[1024];
int mode;
uint32_t offset;
uint32_t skip;
} files[ROMDEF_NFILES];
} romdef_t;
enum {
ROM_IBMPC = 0, /* 301 keyboard error, 131 cassette (!!!) error */
@@ -212,7 +227,7 @@ extern int rom_init_interleaved(rom_t *rom, wchar_t *fn_low,
int size, int mask, int file_offset,
uint32_t flags);
extern int rom_load_bios(int rom_id);
extern int rom_load_bios(int romset);
#endif /*EMU_ROM_H*/

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
* Interface to the OpenAL sound processing library.
*
* Version: @(#)openal.c 1.0.1 2018/02/14
* Version: @(#)openal.c 1.0.2 2018/02/24
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -52,24 +52,76 @@
# include <AL/alext.h>
#endif
#include "../emu.h"
#include "../plat.h"
#include "../plat_dynld.h"
#include "../ui.h"
#include "sound.h"
#define FREQ 48000
#define BUFLEN SOUNDBUFLEN
#ifdef _WIN32
# define PATH_AL_DLL "libopenal-1.dll"
#else
# define PATH_AL_DLL "libopenal.so.1"
#endif
#ifdef USE_OPENAL
ALuint buffers[4]; /* front and back buffers */
ALuint buffers_cd[4]; /* front and back buffers */
ALuint buffers_midi[4]; /* front and back buffers */
static ALuint source[3]; /* audio source */
ALuint buffers[4]; /* front and back buffers */
ALuint buffers_cd[4]; /* front and back buffers */
ALuint buffers_midi[4]; /* front and back buffers */
static ALuint source[3]; /* audio source */
static void *openal_handle = NULL; /* handle to (open) DLL */
/* Pointers to the real functions. */
static ALC_API ALCdevice* ALC_APIENTRY (*f_alcOpenDevice)(const ALCchar *devicename);
static ALC_API ALCboolean ALC_APIENTRY (*f_alcCloseDevice)(ALCdevice *device);
static ALC_API ALCcontext* ALC_APIENTRY (*f_alcCreateContext)(ALCdevice *device, const ALCint* attrlist);
static ALC_API void ALC_APIENTRY (*f_alcDestroyContext)(ALCcontext *context);
static ALC_API ALCboolean ALC_APIENTRY (*f_alcMakeContextCurrent)(ALCcontext *context);
static ALC_API ALCcontext* ALC_APIENTRY (*f_alcGetCurrentContext)(void);
static ALC_API ALCdevice* ALC_APIENTRY (*f_alcGetContextsDevice)(ALCcontext *context);
static AL_API void AL_APIENTRY (*f_alSource3f)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3);
static AL_API void AL_APIENTRY (*f_alSourcef)(ALuint source, ALenum param, ALfloat value);
static AL_API void AL_APIENTRY (*f_alSourcei)(ALuint source, ALenum param, ALint value);
static AL_API void AL_APIENTRY (*f_alBufferData)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq);
static AL_API void AL_APIENTRY (*f_alSourceQueueBuffers)(ALuint source, ALsizei nb, const ALuint *buffers);
static AL_API void AL_APIENTRY (*f_alSourceUnqueueBuffers)(ALuint source, ALsizei nb, ALuint *buffers);
static AL_API void AL_APIENTRY (*f_alSourcePlay)(ALuint source);
static AL_API void AL_APIENTRY (*f_alGetSourcei)(ALuint source, ALenum param, ALint *value);
static AL_API void AL_APIENTRY (*f_alListenerf)(ALenum param, ALfloat value);
static AL_API void AL_APIENTRY (*f_alGenBuffers)(ALsizei n, ALuint *buffers);
static AL_API void AL_APIENTRY (*f_alGenSources)(ALsizei n, ALuint *sources);
static dllimp_t openal_imports[] = {
{ "alcOpenDevice", &f_alcOpenDevice },
{ "alcCloseDevice", &f_alcCloseDevice },
{ "alcCreateContext", &f_alcCreateContext },
{ "alcDestroyContext", &f_alcDestroyContext },
{ "alcMakeContextCurrent", &f_alcMakeContextCurrent },
{ "alcGetCurrentContext", &f_alcGetCurrentContext },
{ "alcGetContextsDevice", &f_alcGetContextsDevice },
{ "alSource3f", &f_alSource3f },
{ "alSourcef", &f_alSourcef },
{ "alSourcei", &f_alSourcei },
{ "alBufferData", &f_alBufferData },
{ "alSourceQueueBuffers", &f_alSourceQueueBuffers },
{ "alSourceUnqueueBuffers", &f_alSourceUnqueueBuffers },
{ "alSourcePlay", &f_alSourcePlay },
{ "alGetSourcei", &f_alGetSourcei },
{ "alListenerf", &f_alListenerf },
{ "alGenBuffers", &f_alGenBuffers },
{ "alGenSources", &f_alGenSources },
{ NULL, NULL }
};
#endif
static int midi_freq = 44100;
static int midi_buf_size = 4410;
static int initialized = 0;
void
@@ -81,20 +133,21 @@ al_set_midi(int freq, int buf_size)
#ifdef USE_OPENAL
void closeal(void);
ALvoid alutInit(ALint *argc,ALbyte **argv)
ALvoid alutInit(ALint *argc, ALbyte **argv)
{
ALCcontext *Context;
ALCdevice *Device;
if (openal_handle == NULL) return;
/* Open device */
Device = alcOpenDevice((ALCchar *)"");
Device = f_alcOpenDevice((ALCchar *)"");
if (Device != NULL) {
/* Create context(s) */
Context = alcCreateContext(Device, NULL);
Context = f_alcCreateContext(Device, NULL);
if (Context != NULL) {
/* Set active context */
alcMakeContextCurrent(Context);
f_alcMakeContextCurrent(Context);
}
}
}
@@ -106,21 +159,29 @@ alutExit(ALvoid)
ALCcontext *Context;
ALCdevice *Device;
if (openal_handle == NULL) return;
/* Get active context */
Context = alcGetCurrentContext();
Context = f_alcGetCurrentContext();
if (Context != NULL) {
/* Get device for active context */
Device = alcGetContextsDevice(Context);
Device = f_alcGetContextsDevice(Context);
if (Device != NULL) {
/* Disable context */
alcMakeContextCurrent(NULL);
f_alcMakeContextCurrent(NULL);
/* Close device */
alcCloseDevice(Device);
f_alcCloseDevice(Device);
}
/* Release context(s) */
alcDestroyContext(Context);
f_alcDestroyContext(Context);
}
/* Unload the DLL if possible. */
if (openal_handle != NULL) {
dynld_close((void *)openal_handle);
openal_handle = NULL;
}
}
#endif
@@ -138,26 +199,34 @@ closeal(void)
void
initalmain(int argc, char *argv[])
{
if (! initialized) return;
#ifdef USE_OPENAL
alutInit(0,0);
atexit(closeal);
if (openal_handle != NULL) return;
/* Try loading the DLL. */
openal_handle = dynld_module(PATH_AL_DLL, openal_imports);
if (openal_handle != NULL) {
pclog("SOUND: OpenAL module '%s' loaded.\n", PATH_AL_DLL);
alutInit(NULL, NULL);
atexit(closeal);
} else {
pclog("SOUND: unable to load OpenAL module '%s' !\n", PATH_AL_DLL);
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2178);
return;
}
#endif
initialized = 0;
}
void
inital(void)
{
if (initialized) return;
#ifdef USE_OPENAL
float *buf = NULL, *cd_buf = NULL, *midi_buf = NULL;
int16_t *buf_int16 = NULL, *cd_buf_int16 = NULL, *midi_buf_int16 = NULL;
int c;
if (openal_handle == NULL) return;
if (sound_is_float) {
buf = (float *) malloc((BUFLEN << 1) * sizeof(float));
cd_buf = (float *) malloc((CD_BUFLEN << 1) * sizeof(float));
@@ -168,27 +237,27 @@ inital(void)
midi_buf_int16 = (int16_t *) malloc(midi_buf_size * sizeof(int16_t));
}
alGenBuffers(4, buffers);
alGenBuffers(4, buffers_cd);
alGenBuffers(4, buffers_midi);
f_alGenBuffers(4, buffers);
f_alGenBuffers(4, buffers_cd);
f_alGenBuffers(4, buffers_midi);
alGenSources(3, source);
f_alGenSources(3, source);
alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0);
alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0);
alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0);
alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 );
alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE );
alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0);
alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0);
alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0);
alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 );
alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE );
alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0);
alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0);
alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0);
alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 );
alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE );
f_alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0);
f_alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0);
f_alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0);
f_alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 );
f_alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE );
f_alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0);
f_alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0);
f_alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0);
f_alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 );
f_alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE );
f_alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0);
f_alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0);
f_alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0);
f_alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 );
f_alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE );
if (sound_is_float) {
memset(buf,0,BUFLEN*2*sizeof(float));
@@ -202,22 +271,22 @@ inital(void)
for (c=0; c<4; c++) {
if (sound_is_float) {
alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ);
alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ);
alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq);
f_alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ);
f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ);
f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq);
} else {
alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ);
alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ);
alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq);
f_alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ);
f_alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ);
f_alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq);
}
}
alSourceQueueBuffers(source[0], 4, buffers);
alSourceQueueBuffers(source[1], 4, buffers_cd);
alSourceQueueBuffers(source[2], 4, buffers_midi);
alSourcePlay(source[0]);
alSourcePlay(source[1]);
alSourcePlay(source[2]);
f_alSourceQueueBuffers(source[0], 4, buffers);
f_alSourceQueueBuffers(source[1], 4, buffers_cd);
f_alSourceQueueBuffers(source[2], 4, buffers_midi);
f_alSourcePlay(source[0]);
f_alSourcePlay(source[1]);
f_alSourcePlay(source[2]);
if (sound_is_float) {
free(midi_buf);
@@ -228,8 +297,6 @@ inital(void)
free(cd_buf_int16);
free(buf_int16);
}
initialized = 1;
#endif
}
@@ -243,26 +310,28 @@ givealbuffer_common(void *buf, uint8_t src, int size, int freq)
ALuint buffer;
double gain;
alGetSourcei(source[src], AL_SOURCE_STATE, &state);
if (openal_handle == NULL) return;
f_alGetSourcei(source[src], AL_SOURCE_STATE, &state);
if (state == 0x1014) {
alSourcePlay(source[src]);
f_alSourcePlay(source[src]);
}
alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed);
f_alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed);
if (processed >= 1) {
gain = pow(10.0, (double)sound_gain / 20.0);
alListenerf(AL_GAIN, gain);
f_alListenerf(AL_GAIN, gain);
alSourceUnqueueBuffers(source[src], 1, &buffer);
f_alSourceUnqueueBuffers(source[src], 1, &buffer);
if (sound_is_float) {
alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq);
f_alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq);
} else {
alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq);
f_alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq);
}
alSourceQueueBuffers(source[src], 1, &buffer);
f_alSourceQueueBuffers(source[src], 1, &buffer);
}
#endif
}

View File

@@ -6,9 +6,9 @@
#
# This file is part of the VARCem Project.
#
# Makefile for Win32 (MinGW32) environment.
# Makefile for Windows systems using the MinGW32 environment.
#
# Version: @(#)Makefile.mingw 1.0.3 2018/02/22
# Version: @(#)Makefile.mingw 1.0.4 2018/02/24
#
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
#
@@ -62,6 +62,9 @@ endif
ifndef CRASHDUMP
CRASHDUMP := n
endif
ifndef CROSS
CROSS := n
endif
ifndef DEBUG
DEBUG := n
endif
@@ -143,7 +146,6 @@ ifeq ($(DEV_BUILD), y)
DEBUG := y
CRASHDUMP := y
DEV_BRANCH := y
VNC := y
I686 := y
AMD_K := y
GREENB := y
@@ -197,14 +199,45 @@ VPATH := $(EXPATH) . cpu \
sound/munt/srchelper \
sound/resid-fp \
scsi video lzf network network/slirp win
ifeq ($(X64), y)
CPP := g++ -m64
CC := gcc -m64
#
# Select the required build environment. We have, uhm, many..
#
#
ifneq ($(CROSS), n)
# Cross-compiling (under Linux), select proper version.
ifeq ($(X64), y)
MINGW := x86_64-w64-mingw32
else
MINGW := i686-w64-mingw32
endif
ifeq ($(X64), y)
CPP := /usr/bin/$(MINGW)-g++ -m64
CC := /usr/bin/$(MINGW)-gcc -m64
else
CPP := /usr/bin/$(MINGW)-g++ -m32
CC := /usr/bin/$(MINGW)-gcc -m32
endif
WINDRES := /usr/bin/$(MINGW)-windres
SYSINC := -I/usr/$(MINGW)/include -I../mingw/include
SYSLIB := -L/usr/$(MINGW)/lib
else
CPP := g++ -m32
CC := gcc -m32
# Native compilation using MinGW for Windows.
ifeq ($(X64), y)
CPP := g++ -m64
CC := gcc -m64
else
CPP := g++ -m32
CC := gcc -m32
endif
WINDRES := windres
SYSINC :=
SYSLIB :=
endif
WINDRES := windres
DEPS = -MMD -MF $*.d -c $<
DEPFILE := win/.depends
@@ -216,6 +249,10 @@ endif
ifdef EXINC
OPTS += -I$(EXINC)
endif
OPTS += $(SYSINC)
ifneq ($(CROSS), n)
OPTS += -DUSE_CROSS
endif
ifeq ($(X64), y)
ifeq ($(OPTIM), y)
DFLAGS := -march=native
@@ -550,7 +587,6 @@ endif
LZFOBJ := lzf_c.o lzf_d.o
LIBS := -mwindows \
-lopenal.dll \
-lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \
-lcomctl32 -lwinmm
ifeq ($(VNC), y)

View File

@@ -8,7 +8,7 @@
*
* Application resource script for Windows.
*
* Version: @(#)VARCem.rc 1.0.2 2018/02/21
* Version: @(#)VARCem.rc 1.0.3 2018/02/24
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -974,6 +974,7 @@ BEGIN
IDS_2175 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0All files (*.*)\0*.*\0"
IDS_2176 "ZIP images (*.IM?;*.ZDI)\0*.IM?;*.ZDI\0"
IDS_2177 "ZIP %i (%03i): %ls"
IDS_2178 "Unable to initialize OpenAL, make sure you have the following library\nin your program folder:\n\nlibopenal-1.dll"
IDS_4096 "Hard disk (%s)"
IDS_4097 "%01i:%01i"