Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
Fmsx
Commits
dcb9bf06
Commit
dcb9bf06
authored
Nov 16, 2021
by
Cayce
Browse files
Merge branch 'master' into enable-second-joystick
# Conflicts: # libretro.c
parents
eacb52ba
98ea26f6
Changes
31
Hide whitespace changes
Inline
Side-by-side
EMULib/AY8910.c
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** produced by General Instruments, Yamaha, etc. See **/
/** produced by General Instruments, Yamaha, etc. See **/
/** AY8910.h for declarations. **/
/** AY8910.h for declarations. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
@@ -72,6 +72,9 @@ void Reset8910(AY8910 *D,int ClockHz,int First)
...
@@ -72,6 +72,9 @@ void Reset8910(AY8910 *D,int ClockHz,int First)
SetSound
(
4
+
First
,
SND_NOISE
);
SetSound
(
4
+
First
,
SND_NOISE
);
SetSound
(
5
+
First
,
SND_NOISE
);
SetSound
(
5
+
First
,
SND_NOISE
);
/* Configure noise generator */
SetNoise
(
0x10000
,
16
,
14
);
/* Silence all channels */
/* Silence all channels */
for
(
J
=
0
;
J
<
AY8910_CHANNELS
;
J
++
)
for
(
J
=
0
;
J
<
AY8910_CHANNELS
;
J
++
)
{
{
...
@@ -293,7 +296,7 @@ void Sync8910(AY8910 *D,byte Sync)
...
@@ -293,7 +296,7 @@ void Sync8910(AY8910 *D,byte Sync)
J
=
(
D
->
Freq
[
3
]
?
D
->
Volume
[
3
]
:
0
)
J
=
(
D
->
Freq
[
3
]
?
D
->
Volume
[
3
]
:
0
)
+
(
D
->
Freq
[
4
]
?
D
->
Volume
[
4
]
:
0
)
+
(
D
->
Freq
[
4
]
?
D
->
Volume
[
4
]
:
0
)
+
(
D
->
Freq
[
5
]
?
D
->
Volume
[
5
]
:
0
);
+
(
D
->
Freq
[
5
]
?
D
->
Volume
[
5
]
:
0
);
if
(
J
)
Drum
(
DRM_MIDI
|
28
,
(
J
+
2
)
/
3
);
if
(
J
)
Drum
(
DRM_MIDI
|
28
,
J
>
255
?
255
:
J
);
}
}
if
(
Sync
!=
AY8910_FLUSH
)
D
->
Sync
=
Sync
;
if
(
Sync
!=
AY8910_FLUSH
)
D
->
Sync
=
Sync
;
...
...
EMULib/AY8910.h
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** produced by General Instruments, Yamaha, etc. See **/
/** produced by General Instruments, Yamaha, etc. See **/
/** AY8910.c for the actual code. **/
/** AY8910.c for the actual code. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
@@ -37,7 +37,7 @@ typedef struct
...
@@ -37,7 +37,7 @@ typedef struct
byte
R
[
16
];
/* PSG registers contents */
byte
R
[
16
];
/* PSG registers contents */
int
Freq
[
AY8910_CHANNELS
];
/* Frequencies (0 for off) */
int
Freq
[
AY8910_CHANNELS
];
/* Frequencies (0 for off) */
int
Volume
[
AY8910_CHANNELS
];
/* Volumes (0..255) */
int
Volume
[
AY8910_CHANNELS
];
/* Volumes (0..255) */
int
Clock
;
/* Base clock
used by PSG
*/
int
Clock
;
/* Base clock
rate (Fin/16)
*/
int
First
;
/* First used Sound() channel */
int
First
;
/* First used Sound() channel */
byte
Changed
;
/* Bitmap of changed channels */
byte
Changed
;
/* Bitmap of changed channels */
byte
Sync
;
/* AY8910_SYNC/AY8910_ASYNC */
byte
Sync
;
/* AY8910_SYNC/AY8910_ASYNC */
...
...
EMULib/EMULib.c
View file @
dcb9bf06
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/** This file contains platform-independent implementation **/
/** This file contains platform-independent implementation **/
/** part of the emulation library. **/
/** part of the emulation library. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
@@ -112,9 +112,6 @@ void SetVideo(Image *Img,int X,int Y,int W,int H)
...
@@ -112,9 +112,6 @@ void SetVideo(Image *Img,int X,int Y,int W,int H)
VideoY
=
Y
<
0
?
0
:
Y
>=
Img
->
H
?
Img
->
H
-
1
:
Y
;
VideoY
=
Y
<
0
?
0
:
Y
>=
Img
->
H
?
Img
->
H
-
1
:
Y
;
VideoW
=
VideoX
+
W
>
Img
->
W
?
Img
->
W
-
VideoX
:
W
;
VideoW
=
VideoX
+
W
>
Img
->
W
?
Img
->
W
-
VideoX
:
W
;
VideoH
=
VideoY
+
H
>
Img
->
H
?
Img
->
H
-
VideoY
:
H
;
VideoH
=
VideoY
+
H
>
Img
->
H
?
Img
->
H
-
VideoY
:
H
;
#ifdef WINDOWS
FreeImage
(
&
BigScreen
);
#endif
}
}
/** WaitJoystick() *******************************************/
/** WaitJoystick() *******************************************/
...
...
EMULib/EMULib.h
View file @
dcb9bf06
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/** This file contains platform-independent definitions and **/
/** This file contains platform-independent definitions and **/
/** declarations for the emulation library. **/
/** declarations for the emulation library. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
@@ -35,11 +35,18 @@
...
@@ -35,11 +35,18 @@
#define EFF_SHOWFPS 0x0200
/* Show frames-per-sec count */
#define EFF_SHOWFPS 0x0200
/* Show frames-per-sec count */
#define EFF_LCDLINES 0x0400
/* Apply LCD scanlines effect */
#define EFF_LCDLINES 0x0400
/* Apply LCD scanlines effect */
#define EFF_VKBD 0x0800
/* Draw virtual keyboard */
#define EFF_VKBD 0x0800
/* Draw virtual keyboard */
#define EFF_SOFTEN2 0x1000
/* Softening algorithm select */
#define EFF_FULLJOY 0x2000
/* Use full screen controls */
#define EFF_FULLJOY 0x2000
/* Use full screen controls */
#define EFF_TILTJOY 0x4000
/* Use accelerometer controls */
#define EFF_TILTJOY 0x4000
/* Use accelerometer controls */
#define EFF_PENJOY 0x8000
/* Use touchpad controls */
#define EFF_PENJOY 0x8000
/* Use touchpad controls */
#define EFF_VSYNC 0x10000
/* Wait for VBlanks */
#define EFF_VSYNC 0x10000
/* Wait for VBlanks */
#define EFF_DIRECT 0x20000
/* Copy whole VideoImg */
#define EFF_DIRECT 0x20000
/* Copy whole VideoImg */
#define EFF_CMYMASK 0x40000
/* Apply vertical CMY mask */
#define EFF_RGBMASK 0x80000
/* Apply vertical RGB mask */
#define EFF_SOFTEN3 0x1000000
/* Softening algorithm select */
#define EFF_MONO 0x2000000
/* Apply monochrome color */
#define EFF_VIGNETTE 0x4000000
/* Apply CRT-like vignetting */
#define EFF_4X3 0x8000000
/* Stretch video to 4x3 ratio */
#if defined(ANDROID)
#if defined(ANDROID)
#define EFF_FIXFFWD 0x100000
/* Persistent FFWD button */
#define EFF_FIXFFWD 0x100000
/* Persistent FFWD button */
#define EFF_GLES 0x200000
/* OpenGLES video rendering */
#define EFF_GLES 0x200000
/* OpenGLES video rendering */
...
@@ -59,6 +66,22 @@
...
@@ -59,6 +66,22 @@
#define EFF_VARBPP 0x200000
/* X11 determines Image depth */
#define EFF_VARBPP 0x200000
/* X11 determines Image depth */
#endif
#endif
#define EFF_SOFTEN_ALL (EFF_SOFTEN|EFF_SOFTEN2|EFF_SOFTEN3)
#define EFF_2XSAI (EFF_SOFTEN)
#define EFF_EPX (EFF_SOFTEN2)
#define EFF_EAGLE (EFF_SOFTEN|EFF_SOFTEN2)
#define EFF_SCALE2X (EFF_SOFTEN3)
#define EFF_HQ4X (EFF_SOFTEN|EFF_SOFTEN3)
#define EFF_NEAREST (EFF_SOFTEN2|EFF_SOFTEN3)
#define EFF_RASTER_ALL (EFF_TVLINES|EFF_LCDLINES)
#define EFF_RASTER (EFF_TVLINES|EFF_LCDLINES)
#define EFF_MASK_ALL (EFF_CMYMASK|EFF_RGBMASK|EFF_MONO)
#define EFF_GREEN (EFF_MONO|EFF_CMYMASK)
#define EFF_AMBER (EFF_MONO|EFF_RGBMASK)
#define EFF_SEPIA (EFF_MONO|EFF_CMYMASK|EFF_RGBMASK)
/** Button Bits **********************************************/
/** Button Bits **********************************************/
/** Bits returned by GetJoystick() and WaitJoystick(). **/
/** Bits returned by GetJoystick() and WaitJoystick(). **/
/*************************************************************/
/*************************************************************/
...
@@ -244,12 +267,60 @@ void LcdizeImage(Image *Img,int X,int Y,int W,int H);
...
@@ -244,12 +267,60 @@ void LcdizeImage(Image *Img,int X,int Y,int W,int H);
/*************************************************************/
/*************************************************************/
void
RasterizeImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
void
RasterizeImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** CMYizeImage() ********************************************/
/** Apply vertical CMY stripes to the image. **/
/*************************************************************/
void
CMYizeImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** RGBizeImage() ********************************************/
/** Apply vertical RGB stripes to the image. **/
/*************************************************************/
void
RGBizeImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** MonoImage() **********************************************/
/** Turn image into monochrome. **/
/*************************************************************/
void
MonoImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** SepiaImage() *********************************************/
/** Turn image into sepia tones. **/
/*************************************************************/
void
SepiaImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** GreenImage() *********************************************/
/** Simulate green CRT phosphor. **/
/*************************************************************/
void
GreenImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** AmberImage() *********************************************/
/** Simulate amber CRT phosphor. **/
/*************************************************************/
void
AmberImage
(
Image
*
Img
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** SoftenImage() ********************************************/
/** SoftenImage() ********************************************/
/** Uses softening algorithm to interpolate image Src into **/
/** Uses softening algorithm to interpolate image Src into **/
/** a bigger image Dst. **/
/** a bigger image Dst. **/
/*************************************************************/
/*************************************************************/
void
SoftenImage
(
Image
*
Dst
,
const
Image
*
Src
,
int
X
,
int
Y
,
int
W
,
int
H
);
void
SoftenImage
(
Image
*
Dst
,
const
Image
*
Src
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** SoftenSCALE2X() ******************************************/
/** Uses SCALE2X softening algorithm to interpolate image **/
/** Src into a bigger image Dst. **/
/*************************************************************/
void
SoftenSCALE2X
(
Image
*
Dst
,
const
Image
*
Src
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** SoftenEPX() **********************************************/
/** Uses EPX softening algorithm to interpolate image Src **/
/** into a bigger image Dst. **/
/*************************************************************/
void
SoftenEPX
(
Image
*
Dst
,
const
Image
*
Src
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** SoftenEAGLE() ********************************************/
/** Uses EAGLE softening algorithm to interpolate image Src **/
/** into a bigger image Dst. **/
/*************************************************************/
void
SoftenEAGLE
(
Image
*
Dst
,
const
Image
*
Src
,
int
X
,
int
Y
,
int
W
,
int
H
);
/** ClearImage() *********************************************/
/** ClearImage() *********************************************/
/** Clear image with a given color. **/
/** Clear image with a given color. **/
/*************************************************************/
/*************************************************************/
...
@@ -304,6 +375,11 @@ void SetPalette(pixel N,unsigned char R,unsigned char G,unsigned char B);
...
@@ -304,6 +375,11 @@ void SetPalette(pixel N,unsigned char R,unsigned char G,unsigned char B);
/*************************************************************/
/*************************************************************/
unsigned
int
GetFreeAudio
(
void
);
unsigned
int
GetFreeAudio
(
void
);
/** GetTotalAudio() ******************************************/
/** Get total amount of samples in the audio buffer. **/
/*************************************************************/
unsigned
int
GetTotalAudio
(
void
);
/** WriteAudio() *********************************************/
/** WriteAudio() *********************************************/
/** Write up to a given number of samples to audio buffer. **/
/** Write up to a given number of samples to audio buffer. **/
/** Returns the number of samples written. **/
/** Returns the number of samples written. **/
...
@@ -391,6 +467,12 @@ int ProcessEvents(int Wait);
...
@@ -391,6 +467,12 @@ int ProcessEvents(int Wait);
/*************************************************************/
/*************************************************************/
void
SetEffects
(
unsigned
int
NewEffects
);
void
SetEffects
(
unsigned
int
NewEffects
);
/** ParseEffects() *******************************************/
/** Parse command line visual effect options, removing them **/
/** from Args[] and applying to the initial Effects value. **/
/*************************************************************/
unsigned
int
ParseEffects
(
char
*
Args
[],
unsigned
int
Effects
);
/** GetFilePath() ********************************************/
/** GetFilePath() ********************************************/
/** Extracts pathname from filename and returns a pointer **/
/** Extracts pathname from filename and returns a pointer **/
/** to the internal buffer containing just the path name **/
/** to the internal buffer containing just the path name **/
...
...
EMULib/FDIDisk.c
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** disk images in various formats. The internal format is **/
/** disk images in various formats. The internal format is **/
/** always .FDI. See FDIDisk.h for declarations. **/
/** always .FDI. See FDIDisk.h for declarations. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 2007-201
4
**/
/** Copyright (C) Marat Fayzullin 2007-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/FDIDisk.h
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** disk images in various formats. The internal format is **/
/** disk images in various formats. The internal format is **/
/** always .FDI. See FDIDisk.c for the actual code. **/
/** always .FDI. See FDIDisk.c for the actual code. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 2007-201
4
**/
/** Copyright (C) Marat Fayzullin 2007-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/Floppy.c
View file @
dcb9bf06
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/** This file implements functions to operate on 720kB **/
/** This file implements functions to operate on 720kB **/
/** floppy disk images. See Floppy.h for declarations. **/
/** floppy disk images. See Floppy.h for declarations. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 2004-201
4
**/
/** Copyright (C) Marat Fayzullin 2004-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
@@ -185,13 +185,13 @@ int DSKFile(byte *Dsk,const char *FileName)
...
@@ -185,13 +185,13 @@ int DSKFile(byte *Dsk,const char *FileName)
/*************************************************************/
/*************************************************************/
const
char
*
DSKFileName
(
const
byte
*
Dsk
,
int
ID
)
const
char
*
DSKFileName
(
const
byte
*
Dsk
,
int
ID
)
{
{
const
unsigned
char
*
Name
;
const
char
*
Name
;
/* Can't have ID that is out of bounds */
/* Can't have ID that is out of bounds */
if
((
ID
<
1
)
||
(
ID
>
DSK_DIR_SIZE
))
return
(
0
);
if
((
ID
<
1
)
||
(
ID
>
DSK_DIR_SIZE
))
return
(
0
);
/* Return file name */
/* Return file name */
Name
=
DIRENTRY
(
Dsk
,
ID
-
1
);
Name
=
(
const
char
*
)
DIRENTRY
(
Dsk
,
ID
-
1
);
return
(
!
Name
[
0
]
||
(
Name
[
0
]
==
0xE5
)
?
0
:
Name
);
return
(
!
Name
[
0
]
||
(
Name
[
0
]
==
(
char
)
0xE5
)
?
0
:
Name
);
}
}
/** DSKFileSize() ********************************************/
/** DSKFileSize() ********************************************/
...
@@ -371,7 +371,8 @@ int DSKDelete(byte *Dsk,int ID)
...
@@ -371,7 +371,8 @@ int DSKDelete(byte *Dsk,int ID)
/*************************************************************/
/*************************************************************/
byte
*
DSKLoad
(
const
char
*
Name
,
byte
*
Dsk
)
byte
*
DSKLoad
(
const
char
*
Name
,
byte
*
Dsk
)
{
{
byte
*
Dsk1
,
*
Buf
,
FN
[
32
],
*
Path
;
byte
*
Dsk1
,
*
Buf
;
char
*
Path
,
FN
[
32
];
struct
stat
FS
;
struct
stat
FS
;
RFILE
*
F
;
RFILE
*
F
;
struct
RDIR
*
D
;
struct
RDIR
*
D
;
...
@@ -457,7 +458,7 @@ byte *DSKLoad(const char *Name,byte *Dsk)
...
@@ -457,7 +458,7 @@ byte *DSKLoad(const char *Name,byte *Dsk)
const
byte
*
DSKSave
(
const
char
*
Name
,
const
byte
*
Dsk
)
const
byte
*
DSKSave
(
const
char
*
Name
,
const
byte
*
Dsk
)
{
{
const
char
*
T
;
const
char
*
T
;
byte
*
Path
,
*
P
;
char
*
Path
,
*
P
;
struct
stat
FS
;
struct
stat
FS
;
RFILE
*
F
;
RFILE
*
F
;
int
J
,
I
,
K
;
int
J
,
I
,
K
;
...
...
EMULib/Floppy.h
View file @
dcb9bf06
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/** This file declares functions to operate on 720kB **/
/** This file declares functions to operate on 720kB **/
/** floppy disk images. See Floppy.c for implementation. **/
/** floppy disk images. See Floppy.c for implementation. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 2004-201
4
**/
/** Copyright (C) Marat Fayzullin 2004-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/I8255.c
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** port interface (PPI) chip from Intel. See I8255.h for **/
/** port interface (PPI) chip from Intel. See I8255.h for **/
/** declarations. **/
/** declarations. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 2001-201
4
**/
/** Copyright (C) Marat Fayzullin 2001-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/I8255.h
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** port interface (PPI) chip from Intel. See I8255.h for **/
/** port interface (PPI) chip from Intel. See I8255.h for **/
/** the actual code. **/
/** the actual code. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 2001-201
4
**/
/** Copyright (C) Marat Fayzullin 2001-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/MIDIFreq.h
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** into MIDI octave/note numbers. It is included from the **/
/** into MIDI octave/note numbers. It is included from the **/
/** Sound.c and SndWin.c files. **/
/** Sound.c and SndWin.c files. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/SCC.c
View file @
dcb9bf06
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/** This file contains emulation for the SCC sound chip **/
/** This file contains emulation for the SCC sound chip **/
/** produced by Konami. **/
/** produced by Konami. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/SCC.h
View file @
dcb9bf06
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
/** This file contains definitions and declarations for **/
/** This file contains definitions and declarations for **/
/** routines in SCC.c. **/
/** routines in SCC.c. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
...
EMULib/Sound.c
View file @
dcb9bf06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
/** and functions needed to log soundtrack into a MIDI **/
/** and functions needed to log soundtrack into a MIDI **/
/** file. See Sound.h for declarations. **/
/** file. See Sound.h for declarations. **/
/** **/
/** **/
/** Copyright (C) Marat Fayzullin 1996-201
4
**/
/** Copyright (C) Marat Fayzullin 1996-201
6
**/
/** You are not allowed to distribute this software **/
/** You are not allowed to distribute this software **/
/** commercially. Please, notify me, if you make any **/
/** commercially. Please, notify me, if you make any **/
/** changes to this file. **/
/** changes to this file. **/
...
@@ -43,13 +43,13 @@ static const struct { byte Note;word Wheel; } Freqs[4096] =
...
@@ -43,13 +43,13 @@ static const struct { byte Note;word Wheel; } Freqs[4096] =
#include "MIDIFreq.h"
#include "MIDIFreq.h"
};
};
static
const
int
Programs
[
5
]
=
static
const
int
Programs
[]
=
{
{
80
,
/* SND_MELODIC/SND_RECTANGLE */
80
,
/* SND_MELODIC/SND_RECTANGLE */
80
,
/* SND_TRIANGLE */
80
,
/* SND_TRIANGLE */
122
,
/* SND_NOISE */
122
,
/* SND_NOISE */
122
,
/* SND_PERIODIC */
122
,
/* SND_PERIODIC */
80
/* SND_WAVE */
80
,
/* SND_WAVE */
};
};
static
struct
static
struct
...
@@ -58,24 +58,25 @@ static struct
...
@@ -58,24 +58,25 @@ static struct
int
Note
;
int
Note
;
int
Pitch
;
int
Pitch
;
int
Level
;
int
Level
;
int
Power
;
}
MidiCH
[
MIDI_CHANNELS
]
=
}
MidiCH
[
MIDI_CHANNELS
]
=
{
{
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
},
{
-
1
,
-
1
,
-
1
,
-
1
,
256
},
{
-
1
,
-
1
,
-
1
,
-
1
}
{
-
1
,
-
1
,
-
1
,
-
1
,
256
}
};
};
static
struct
static
struct
...
@@ -112,7 +113,9 @@ static struct
...
@@ -112,7 +113,9 @@ static struct
/** RenderAudio() Variables *******************************************/
/** RenderAudio() Variables *******************************************/
static
int
SndRate
=
0
;
/* Sound rate (0=Off) */
static
int
SndRate
=
0
;
/* Sound rate (0=Off) */
static
int
NoiseGen
=
1
;
/* Noise generator seed */
static
int
NoiseGen
=
0x10000
;
/* Noise generator seed */
static
int
NoiseOut
=
16
;
/* NoiseGen bit used for output */
static
int
NoiseXor
=
14
;
/* NoiseGen bit used for XORing */
int
MasterSwitch
=
0xFFFF
;
/* Switches to turn channels on/off */
int
MasterSwitch
=
0xFFFF
;
/* Switches to turn channels on/off */
int
MasterVolume
=
192
;
/* Master volume */
int
MasterVolume
=
192
;
/* Master volume */
...
@@ -153,13 +156,20 @@ void Sound(int Channel,int Freq,int Volume)
...
@@ -153,13 +156,20 @@ void Sound(int Channel,int Freq,int Volume)
{
{
/* All parameters have to be valid */
/* All parameters have to be valid */
if
((
Channel
<
0
)
||
(
Channel
>=
SND_CHANNELS
))
return
;
if
((
Channel
<
0
)
||
(
Channel
>=
SND_CHANNELS
))
return
;
Freq
=
Freq
<
0
?
0
:
Freq
>
20000
?
0
:
Freq
;
Freq
=
Freq
<
0
?
0
:
Freq
;
Volume
=
Volume
<
0
?
0
:
Volume
>
255
?
255
:
Volume
;
Volume
=
Volume
<
0
?
0
:
Volume
>
255
?
255
:
Volume
;
/* Modify
wave
channel */
/* Modify channel
parameters
*/
WaveCH
[
Channel
].
Volume
=
Volume
;
WaveCH
[
Channel
].
Volume
=
Volume
;
WaveCH
[
Channel
].
Freq
=
Freq
;
WaveCH
[
Channel
].
Freq
=
Freq
;
/* When disabling sound, reset waveform */
if
(
!
Freq
||!
Volume
)
{
WaveCH
[
Channel
].
Pos
=
0
;
WaveCH
[
Channel
].
Count
=
0
;
}
/* Log sound to MIDI file */
/* Log sound to MIDI file */
MIDISound
(
Channel
,
Freq
,
Volume
);
MIDISound
(
Channel
,
Freq
,
Volume
);
}
}
...
@@ -209,6 +219,18 @@ void SetChannels(int Volume,int Switch)
...
@@ -209,6 +219,18 @@ void SetChannels(int Volume,int Switch)
MasterSwitch
=
Switch
&
((
1
<<
SND_CHANNELS
)
-
1
);
MasterSwitch
=
Switch
&
((
1
<<
SND_CHANNELS
)
-
1
);
}
}
/** SetNoise() ***********************************************/
/** Initialize random noise generator to the given Seed and **/
/** then take random output from OUTBit and XOR it with **/
/** XORBit. **/
/*************************************************************/
void
SetNoise
(
int
Seed
,
int
OUTBit
,
int
XORBit
)
{
NoiseGen
=
Seed
;
NoiseOut
=
OUTBit
;
NoiseXor
=
XORBit
;
}
/** SetWave() ************************************************/
/** SetWave() ************************************************/
/** Set waveform for a given channel. The channel will be **/
/** Set waveform for a given channel. The channel will be **/
/** marked with sound type SND_WAVE. Set Rate=0 if you want **/
/** marked with sound type SND_WAVE. Set Rate=0 if you want **/
...
@@ -217,6 +239,8 @@ void SetChannels(int Volume,int Switch)
...
@@ -217,6 +239,8 @@ void SetChannels(int Volume,int Switch)
/*************************************************************/
/*************************************************************/
void
SetWave
(
int
Channel
,
const
signed
char
*
Data
,
int
Length
,
int
Rate
)
void
SetWave
(
int
Channel
,
const
signed
char
*
Data
,
int
Length
,
int
Rate
)
{
{
unsigned
int
I
,
J
;
/* Channel and waveform length have to be valid */
/* Channel and waveform length have to be valid */
if
((
Channel
<
0
)
||
(
Channel
>=
SND_CHANNELS
)
||
(
Length
<=
0
))
return
;
if
((
Channel
<
0
)
||
(
Channel
>=
SND_CHANNELS
)
||
(
Length
<=
0
))
return
;
...
@@ -229,7 +253,19 @@ void SetWave(int Channel,const signed char *Data,int Length,int Rate)
...
@@ -229,7 +253,19 @@ void SetWave(int Channel,const signed char *Data,int Length,int Rate)
WaveCH
[
Channel
].
Data
=
Data
;
WaveCH
[
Channel
].
Data
=
Data
;
/* Log instrument change to MIDI file */
/* Log instrument change to MIDI file */
MIDISetSound
(
Channel
,
Rate
?
-
1
:
SND_MELODIC
);