first working interraction with VRAM (SDL_FillRect())
This commit is contained in:
parent
57a084f989
commit
2ea4ea7eab
|
@ -2,34 +2,73 @@
|
|||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="src/video/prizm/SDL_prizmevents.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/SDL_surface.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1755" topLine="40" />
|
||||
<Cursor1 position="14589" topLine="710" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmvideo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/timer/prizm/SDL_systimer.c" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="11" />
|
||||
<Cursor1 position="1475" topLine="3" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmfonts.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/prizm/SDL_prizmvideo.c" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="159" topLine="0" />
|
||||
<Cursor1 position="3544" topLine="86" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmutils.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/SDL_pixels.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="307" topLine="0" />
|
||||
<Cursor1 position="8603" topLine="83" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="36" />
|
||||
<Collapse line="38" />
|
||||
<Collapse line="225" />
|
||||
<Collapse line="238" />
|
||||
<Collapse line="251" />
|
||||
<Collapse line="266" />
|
||||
<Collapse line="291" />
|
||||
<Collapse line="313" />
|
||||
<Collapse line="340" />
|
||||
<Collapse line="342" />
|
||||
<Collapse line="355" />
|
||||
<Collapse line="357" />
|
||||
<Collapse line="370" />
|
||||
<Collapse line="404" />
|
||||
<Collapse line="424" />
|
||||
<Collapse line="436" />
|
||||
<Collapse line="464" />
|
||||
<Collapse line="489" />
|
||||
<Collapse line="506" />
|
||||
<Collapse line="530" />
|
||||
<Collapse line="531" />
|
||||
<Collapse line="542" />
|
||||
<Collapse line="617" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="Makefile.prizm" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/SDL_blit_0.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1727" topLine="47" />
|
||||
<Cursor1 position="0" topLine="39" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="29" />
|
||||
<Collapse line="82" />
|
||||
<Collapse line="117" />
|
||||
<Collapse line="154" />
|
||||
<Collapse line="190" />
|
||||
<Collapse line="242" />
|
||||
<Collapse line="276" />
|
||||
<Collapse line="309" />
|
||||
<Collapse line="343" />
|
||||
<Collapse line="388" />
|
||||
<Collapse line="438" />
|
||||
<Collapse line="443" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmvideo.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/prizm/SDL_prizmevents_c.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="72" />
|
||||
<Cursor1 position="2002" topLine="69" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_config_prizm.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
|
@ -37,16 +76,50 @@
|
|||
<Cursor1 position="2746" topLine="12" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_sysvideo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/SDL_blit.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="12039" topLine="392" />
|
||||
<Cursor1 position="1552" topLine="468" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmfonts.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="159" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_video.c" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2971" topLine="135" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="154" />
|
||||
<Collapse line="290" />
|
||||
<Collapse line="302" />
|
||||
<Collapse line="316" />
|
||||
<Collapse line="334" />
|
||||
<Collapse line="357" />
|
||||
<Collapse line="376" />
|
||||
<Collapse line="435" />
|
||||
<Collapse line="505" />
|
||||
<Collapse line="523" />
|
||||
<Collapse line="1111" />
|
||||
<Collapse line="1629" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="include/SDL_config.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1297" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmutils.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="307" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_sysvideo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="12039" topLine="392" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmnti.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="762" topLine="3" />
|
||||
|
@ -55,24 +128,54 @@
|
|||
<Collapse line="5" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="src/SDL_error.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1681" topLine="25" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmfonts.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="567" topLine="0" />
|
||||
<Cursor1 position="706" topLine="7" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmevents_c.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="Makefile.prizm" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2002" topLine="69" />
|
||||
<Cursor1 position="1235" topLine="26" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_blit.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/video/prizm/SDL_prizmvideo.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1552" topLine="468" />
|
||||
<Cursor1 position="0" topLine="11" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/SDL_blit_N.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="153" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/events/SDL_events.c" open="1" top="1" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2769" topLine="255" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_error.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1459" topLine="47" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_video.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="8312" topLine="258" />
|
||||
<Cursor1 position="8955" topLine="277" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/stdlib/SDL_string.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="7025" topLine="273" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/video/prizm/SDL_prizmevents.c" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1755" topLine="40" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
@ -89,12 +89,12 @@
|
|||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
//#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
//#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_CDROM_DUMMY 1
|
||||
#define SDL_JOYSTICK_DUMMY 1
|
||||
#define SDL_LOADSO_DUMMY 1
|
||||
#define SDL_TIMER_DUMMY 1
|
||||
//#define SDL_TIMER_DUMMY 1
|
||||
|
||||
|
||||
/* Enable various timer systems */
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Get the name of the audio device we use for output */
|
||||
|
||||
#if SDL_AUDIO_DRIVER_BSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audiodev_c.h"
|
||||
|
||||
#ifndef _PATH_DEV_DSP
|
||||
#if defined(__NETBSD__) || defined(__OPENBSD__)
|
||||
#define _PATH_DEV_DSP "/dev/audio"
|
||||
#else
|
||||
#define _PATH_DEV_DSP "/dev/dsp"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _PATH_DEV_DSP24
|
||||
#define _PATH_DEV_DSP24 "/dev/sound/dsp"
|
||||
#endif
|
||||
#ifndef _PATH_DEV_AUDIO
|
||||
#define _PATH_DEV_AUDIO "/dev/audio"
|
||||
#endif
|
||||
|
||||
|
||||
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
{
|
||||
const char *audiodev;
|
||||
int audio_fd;
|
||||
char audiopath[1024];
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
|
||||
((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
|
||||
if ( classic ) {
|
||||
audiodev = _PATH_DEV_AUDIO;
|
||||
} else {
|
||||
struct stat sb;
|
||||
|
||||
/* Added support for /dev/sound/\* in Linux 2.4 */
|
||||
if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) &&
|
||||
((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) {
|
||||
audiodev = _PATH_DEV_DSP24;
|
||||
} else {
|
||||
audiodev = _PATH_DEV_DSP;
|
||||
}
|
||||
}
|
||||
}
|
||||
audio_fd = open(audiodev, flags, 0);
|
||||
|
||||
/* If the first open fails, look for other devices */
|
||||
if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
|
||||
int exists, instance;
|
||||
struct stat sb;
|
||||
|
||||
instance = 1;
|
||||
do { /* Don't use errno ENOENT - it may not be thread-safe */
|
||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance++);
|
||||
exists = 0;
|
||||
if ( stat(audiopath, &sb) == 0 ) {
|
||||
exists = 1;
|
||||
audio_fd = open(audiopath, flags, 0);
|
||||
}
|
||||
} while ( exists && (audio_fd < 0) );
|
||||
audiodev = audiopath;
|
||||
}
|
||||
if ( path != NULL ) {
|
||||
SDL_strlcpy(path, audiodev, maxlen);
|
||||
path[maxlen-1] = '\0';
|
||||
}
|
||||
return(audio_fd);
|
||||
}
|
||||
|
||||
#elif SDL_AUDIO_DRIVER_PAUD
|
||||
|
||||
/* Get the name of the audio device we use for output */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audiodev_c.h"
|
||||
|
||||
#ifndef _PATH_DEV_DSP
|
||||
#define _PATH_DEV_DSP "/dev/%caud%c/%c"
|
||||
#endif
|
||||
|
||||
char devsettings[][3] =
|
||||
{
|
||||
{ 'p', '0', '1' }, { 'p', '0', '2' }, { 'p', '0', '3' }, { 'p', '0', '4' },
|
||||
{ 'p', '1', '1' }, { 'p', '1', '2' }, { 'p', '1', '3' }, { 'p', '1', '4' },
|
||||
{ 'p', '2', '1' }, { 'p', '2', '2' }, { 'p', '2', '3' }, { 'p', '2', '4' },
|
||||
{ 'p', '3', '1' }, { 'p', '3', '2' }, { 'p', '3', '3' }, { 'p', '3', '4' },
|
||||
{ 'b', '0', '1' }, { 'b', '0', '2' }, { 'b', '0', '3' }, { 'b', '0', '4' },
|
||||
{ 'b', '1', '1' }, { 'b', '1', '2' }, { 'b', '1', '3' }, { 'b', '1', '4' },
|
||||
{ 'b', '2', '1' }, { 'b', '2', '2' }, { 'b', '2', '3' }, { 'b', '2', '4' },
|
||||
{ 'b', '3', '1' }, { 'b', '3', '2' }, { 'b', '3', '3' }, { 'b', '3', '4' },
|
||||
{ '\0', '\0', '\0' }
|
||||
};
|
||||
|
||||
static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
|
||||
{
|
||||
const char *audiodev;
|
||||
int audio_fd;
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) {
|
||||
audiodev=SDL_getenv("AUDIODEV");
|
||||
}
|
||||
if ( audiodev == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
audio_fd = open(audiodev, flags, 0);
|
||||
if ( path != NULL ) {
|
||||
SDL_strlcpy(path, audiodev, maxlen);
|
||||
path[maxlen-1] = '\0';
|
||||
}
|
||||
return audio_fd;
|
||||
}
|
||||
|
||||
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
{
|
||||
struct stat sb;
|
||||
int audio_fd;
|
||||
char audiopath[1024];
|
||||
int cycle;
|
||||
|
||||
audio_fd = OpenUserDefinedDevice(path,maxlen,flags);
|
||||
if ( audio_fd != -1 ) {
|
||||
return audio_fd;
|
||||
}
|
||||
|
||||
cycle = 0;
|
||||
while( devsettings[cycle][0] != '\0' ) {
|
||||
SDL_snprintf( audiopath, SDL_arraysize(audiopath),
|
||||
_PATH_DEV_DSP,
|
||||
devsettings[cycle][0],
|
||||
devsettings[cycle][1],
|
||||
devsettings[cycle][2]);
|
||||
|
||||
if ( stat(audiopath, &sb) == 0 ) {
|
||||
audio_fd = open(audiopath, flags, 0);
|
||||
if ( audio_fd > 0 ) {
|
||||
if ( path != NULL ) {
|
||||
SDL_strlcpy( path, audiopath, maxlen );
|
||||
}
|
||||
return audio_fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* Audio driver selection */
|
Binary file not shown.
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Open the audio device, storing the pathname in 'path' */
|
||||
extern int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic);
|
||||
|
|
@ -1,264 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This provides the default mixing callback for the SDL audio routines */
|
||||
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
#include "SDL_mixer_MMX.h"
|
||||
#include "SDL_mixer_MMX_VC.h"
|
||||
#include "SDL_mixer_m68k.h"
|
||||
|
||||
/* This table is used to add two sound values together and pin
|
||||
* the value to avoid overflow. (used with permission from ARDI)
|
||||
* Changed to use 0xFE instead of 0xFF for better sound quality.
|
||||
*/
|
||||
static const Uint8 mix8[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
|
||||
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
|
||||
0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
|
||||
0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
|
||||
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
|
||||
0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
|
||||
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
|
||||
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
|
||||
0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
|
||||
0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
|
||||
0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
|
||||
0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
|
||||
0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
|
||||
0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
|
||||
0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
|
||||
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
|
||||
0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
|
||||
0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
|
||||
};
|
||||
|
||||
/* The volume ranges from 0 - 128 */
|
||||
#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
|
||||
#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
|
||||
|
||||
void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
||||
{
|
||||
Uint16 format;
|
||||
|
||||
if ( volume == 0 ) {
|
||||
return;
|
||||
}
|
||||
/* Mix the user-level audio format */
|
||||
if ( current_audio ) {
|
||||
if ( current_audio->convert.needed ) {
|
||||
format = current_audio->convert.src_format;
|
||||
} else {
|
||||
format = current_audio->spec.format;
|
||||
}
|
||||
} else {
|
||||
/* HACK HACK HACK */
|
||||
format = AUDIO_S16;
|
||||
}
|
||||
switch (format) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_U8((char*)dst,(char*)src,(unsigned long)len,(long)volume,(char *)mix8);
|
||||
#else
|
||||
Uint8 src_sample;
|
||||
|
||||
while ( len-- ) {
|
||||
src_sample = *src;
|
||||
ADJUST_VOLUME_U8(src_sample, volume);
|
||||
*dst = mix8[*dst+src_sample];
|
||||
++dst;
|
||||
++src;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S8((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S8_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S8((char*)dst,(char*)src,(unsigned long)len,(long)volume);
|
||||
#else
|
||||
{
|
||||
Sint8 *dst8, *src8;
|
||||
Sint8 src_sample;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(8-1))-1);
|
||||
const int min_audioval = -(1<<(8-1));
|
||||
|
||||
src8 = (Sint8 *)src;
|
||||
dst8 = (Sint8 *)dst;
|
||||
while ( len-- ) {
|
||||
src_sample = *src8;
|
||||
ADJUST_VOLUME(src_sample, volume);
|
||||
dst_sample = *dst8 + src_sample;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
*dst8 = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
*dst8 = min_audioval;
|
||||
} else {
|
||||
*dst8 = dst_sample;
|
||||
}
|
||||
++dst8;
|
||||
++src8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16LSB: {
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S16((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S16_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16LSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
|
||||
#else
|
||||
{
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(16-1))-1);
|
||||
const int min_audioval = -(1<<(16-1));
|
||||
|
||||
len /= 2;
|
||||
while ( len-- ) {
|
||||
src1 = ((src[1])<<8|src[0]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[1])<<8|dst[0]);
|
||||
src += 2;
|
||||
dst_sample = src1+src2;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[0] = dst_sample&0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[1] = dst_sample&0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16MSB: {
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16MSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
|
||||
#else
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(16-1))-1);
|
||||
const int min_audioval = -(1<<(16-1));
|
||||
|
||||
len /= 2;
|
||||
while ( len-- ) {
|
||||
src1 = ((src[0])<<8|src[1]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[0])<<8|dst[1]);
|
||||
src += 2;
|
||||
dst_sample = src1+src2;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[1] = dst_sample&0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[0] = dst_sample&0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* If this happens... FIXME! */
|
||||
SDL_SetError("SDL_MixAudio(): unknown audio format");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************
|
||||
* Mixing for 16 bit signed buffers
|
||||
***********************************************/
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void SDL_MixAudio_MMX_S16(char* dst,char* src,unsigned int size,int volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
" movl %3,%%eax\n" /* eax = volume */
|
||||
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
|
||||
" shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */
|
||||
|
||||
" jz .endS16\n"
|
||||
|
||||
" pxor %%mm0,%%mm0\n"
|
||||
|
||||
" movd %%eax,%%mm0\n"
|
||||
" movq %%mm0,%%mm1\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */
|
||||
|
||||
".align 8\n"
|
||||
" .mixloopS16:\n"
|
||||
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
|
||||
|
||||
" movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */
|
||||
|
||||
" movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */
|
||||
|
||||
/* pré charger le buffer dst dans mm7 */
|
||||
" movq (%0),%%mm7\n" /* mm7 = dst[0] */
|
||||
|
||||
/* multiplier par le volume */
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
|
||||
" pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */
|
||||
" movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */
|
||||
|
||||
" pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
|
||||
" pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
|
||||
" punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */
|
||||
|
||||
" movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
" punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */
|
||||
|
||||
" punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */
|
||||
|
||||
" punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */
|
||||
|
||||
/* pré charger le buffer dst dans mm5 */
|
||||
" movq 8(%0),%%mm5\n" /* mm5 = dst[1] */
|
||||
|
||||
/* diviser par 128 */
|
||||
" psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */
|
||||
" add $16,%1\n"
|
||||
|
||||
" psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
|
||||
|
||||
" psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */
|
||||
|
||||
/* mm1 = le sample avec le volume modifié */
|
||||
" packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */
|
||||
|
||||
" psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */
|
||||
" paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */
|
||||
|
||||
/* mm4 = le sample avec le volume modifié */
|
||||
" packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */
|
||||
" movq %%mm3,(%0)\n"
|
||||
|
||||
" paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
|
||||
|
||||
" movq %%mm6,8(%0)\n"
|
||||
|
||||
" add $16,%0\n"
|
||||
|
||||
" dec %%edx\n"
|
||||
|
||||
" jnz .mixloopS16\n"
|
||||
|
||||
" emms\n"
|
||||
|
||||
".endS16:\n"
|
||||
:
|
||||
: "r" (dst), "r"(src),"m"(size),
|
||||
"m"(volume)
|
||||
: "eax","edx","memory"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////// */
|
||||
/* Mixing for 8 bit signed buffers */
|
||||
/*////////////////////////////////////////////// */
|
||||
|
||||
void SDL_MixAudio_MMX_S8(char* dst,char* src,unsigned int size,int volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
" movl %3,%%eax\n" /* eax = volume */
|
||||
|
||||
" movd %%eax,%%mm0\n"
|
||||
" movq %%mm0,%%mm1\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
" shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */
|
||||
|
||||
" cmp $0,%%edx\n"
|
||||
" je .endS8\n"
|
||||
|
||||
".align 8\n"
|
||||
" .mixloopS8:\n"
|
||||
|
||||
" pxor %%mm2,%%mm2\n" /* mm2 = 0 */
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */
|
||||
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */
|
||||
|
||||
/* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */
|
||||
" pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */
|
||||
|
||||
" punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */
|
||||
|
||||
" punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */
|
||||
" movq (%0),%%mm2\n" /* mm2 = destination */
|
||||
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */
|
||||
" add $8,%1\n"
|
||||
|
||||
" pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */
|
||||
" psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */
|
||||
|
||||
" psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
|
||||
" packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
|
||||
" paddsb %%mm2,%%mm3\n" /* add to destination buffer */
|
||||
|
||||
" movq %%mm3,(%0)\n" /* store back to ram */
|
||||
" add $8,%0\n"
|
||||
|
||||
" dec %%edx\n"
|
||||
|
||||
" jnz .mixloopS8\n"
|
||||
|
||||
".endS8:\n"
|
||||
" emms\n"
|
||||
:
|
||||
: "r" (dst), "r"(src),"m"(size),
|
||||
"m"(volume)
|
||||
: "eax","edx","memory"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
headers for MMX assembler version of SDL_MixAudio
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void SDL_MixAudio_MMX_S16(char* ,char* ,unsigned int ,int );
|
||||
void SDL_MixAudio_MMX_S8(char* ,char* ,unsigned int ,int );
|
||||
#endif
|
||||
#endif
|
||||
|
Binary file not shown.
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_mixer_MMX_VC.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
|
||||
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
// Converted to Intel ASM notation by Cth
|
||||
// This code is licensed under the LGPL (see COPYING for details)
|
||||
//
|
||||
// Assumes buffer size in bytes is a multiple of 16
|
||||
// Assumes SDL_MIX_MAXVOLUME = 128
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 16 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov edi, dst // edi = dst
|
||||
mov esi, src // esi = src
|
||||
mov eax, volume // eax = volume
|
||||
mov ebx, nSize // ebx = size
|
||||
shr ebx, 4 // process 16 bytes per iteration = 8 samples
|
||||
jz endS16
|
||||
|
||||
pxor mm0, mm0
|
||||
movd mm0, eax //%%eax,%%mm0
|
||||
movq mm1, mm0 //%%mm0,%%mm1
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0 // mm0 = vol|vol|vol|vol
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
align 16
|
||||
#endif
|
||||
mixloopS16:
|
||||
movq mm1, [esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d
|
||||
movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d
|
||||
movq mm4, [esi + 8] //8(%%esi),%%mm4\n" // mm4 = e|f|g|h
|
||||
// pre charger le buffer dst dans mm7
|
||||
movq mm7, [edi] //(%%edi),%%mm7\n" // mm7 = dst[0]"
|
||||
// multiplier par le volume
|
||||
pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
|
||||
pmulhw mm2, mm0 //%%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v)
|
||||
movq mm5, mm4 //%%mm4,%%mm5\n" // mm5 = e|f|g|h
|
||||
pmullw mm4, mm0 //%%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
|
||||
pmulhw mm5, mm0 //%%mm0,%%mm5\n" // mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v)
|
||||
movq mm3, mm1 //%%mm1,%%mm3\n" // mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
|
||||
punpckhwd mm1, mm2 //%%mm2,%%mm1\n" // mm1 = a*v|b*v
|
||||
movq mm6, mm4 //%%mm4,%%mm6\n" // mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
|
||||
punpcklwd mm3, mm2 //%%mm2,%%mm3\n" // mm3 = c*v|d*v
|
||||
punpckhwd mm4, mm5 //%%mm5,%%mm4\n" // mm4 = e*f|f*v
|
||||
punpcklwd mm6, mm5 //%%mm5,%%mm6\n" // mm6 = g*v|h*v
|
||||
// pre charger le buffer dst dans mm5
|
||||
movq mm5, [edi + 8] //8(%%edi),%%mm5\n" // mm5 = dst[1]
|
||||
// diviser par 128
|
||||
psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME
|
||||
add esi, 16 //$16,%%esi\n"
|
||||
psrad mm3, 7 //$7,%%mm3\n" // mm3 = c*v/128|d*v/128
|
||||
psrad mm4, 7 //$7,%%mm4\n" // mm4 = e*v/128|f*v/128
|
||||
// mm1 = le sample avec le volume modifie
|
||||
packssdw mm3, mm1 //%%mm1,%%mm3\n" // mm3 = s(a*v|b*v|c*v|d*v)
|
||||
psrad mm6, 7 //$7,%%mm6\n" // mm6= g*v/128|h*v/128
|
||||
paddsw mm3, mm7 //%%mm7,%%mm3\n" // mm3 = adjust_volume(src)+dst
|
||||
// mm4 = le sample avec le volume modifie
|
||||
packssdw mm6, mm4 //%%mm4,%%mm6\n" // mm6 = s(e*v|f*v|g*v|h*v)
|
||||
movq [edi], mm3 //%%mm3,(%%edi)\n"
|
||||
paddsw mm6, mm5 //%%mm5,%%mm6\n" // mm6 = adjust_volume(src)+dst
|
||||
movq [edi + 8], mm6 //%%mm6,8(%%edi)\n"
|
||||
add edi, 16 //$16,%%edi\n"
|
||||
dec ebx //%%ebx\n"
|
||||
jnz mixloopS16
|
||||
|
||||
endS16:
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 8 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void SDL_MixAudio_MMX_S8_VC(char* dst,char* src,unsigned int nSize,int volume)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov edi, dst //movl %0,%%edi // edi = dst
|
||||
mov esi, src //%1,%%esi // esi = src
|
||||
mov eax, volume //%3,%%eax // eax = volume
|
||||
|
||||
movd mm0, eax //%%eax,%%mm0
|
||||
movq mm1, mm0 //%%mm0,%%mm1
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
|
||||
mov ebx, nSize //%2,%%ebx // ebx = size
|
||||
shr ebx, 3 //$3,%%ebx // process 8 bytes per iteration = 8 samples
|
||||
cmp ebx, 0 //$0,%%ebx
|
||||
je endS8
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
align 16
|
||||
#endif
|
||||
mixloopS8:
|
||||
pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0
|
||||
movq mm1, [esi] //(%%esi),%%mm1 // mm1 = a|b|c|d|e|f|g|h
|
||||
movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h
|
||||
// on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0
|
||||
pcmpgtb mm2, mm1 //%%mm1,%%mm2 // mm2 = 11111111|00000000|00000000....
|
||||
punpckhbw mm1, mm2 //%%mm2,%%mm1 // mm1 = 0|a|0|b|0|c|0|d
|
||||
punpcklbw mm3, mm2 //%%mm2,%%mm3 // mm3 = 0|e|0|f|0|g|0|h
|
||||
movq mm2, [edi] //(%%edi),%%mm2 // mm2 = destination
|
||||
pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d
|
||||
add esi, 8 //$8,%%esi
|
||||
pmullw mm3, mm0 //%%mm0,%%mm3 // mm3 = v*e|v*f|v*g|v*h
|
||||
psraw mm1, 7 //$7,%%mm1 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128
|
||||
psraw mm3, 7 //$7,%%mm3 // mm3 = v*e/128|v*f/128|v*g/128|v*h/128
|
||||
packsswb mm3, mm1 //%%mm1,%%mm3 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128
|
||||
paddsb mm3, mm2 //%%mm2,%%mm3 // add to destination buffer
|
||||
movq [edi], mm3 //%%mm3,(%%edi) // store back to ram
|
||||
add edi, 8 //$8,%%edi
|
||||
dec ebx //%%ebx
|
||||
jnz mixloopS8
|
||||
|
||||
endS8:
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_ASSEMBLY_ROUTINES */
|
||||
#endif /* SDL_BUGGY_MMX_MIXERS */
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
/* headers for MMX assembler version of SDL_MixAudio
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
Converted to Intel ASM notation by Cth
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int );
|
||||
void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int );
|
||||
#endif
|
||||
#endif
|
Binary file not shown.
|
@ -1,210 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
m68k assembly mix routines
|
||||
|
||||
Patrice Mandin
|
||||
*/
|
||||
|
||||
#if (defined(__m68k__) && !defined(__mcoldfire__)) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_u8\n"
|
||||
"mixloop_u8:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" moveq #0,%%d0\n"
|
||||
" moveq #0,%%d1\n"
|
||||
|
||||
" moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" sub #128,%%d0\n" /* d0 -= 128 */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" add #128,%%d0\n" /* d0 += 128 */
|
||||
|
||||
" add %%d1,%%d0\n"
|
||||
|
||||
" moveb %4@(%%d0:w),%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_u8\n"
|
||||
"stoploop_u8:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_s8\n"
|
||||
" moveq #-128,%%d2\n"
|
||||
" moveq #127,%%d3\n"
|
||||
"mixloop_s8:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" moveq #0,%%d0\n"
|
||||
" moveq #0,%%d1\n"
|
||||
|
||||
" moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" add %%d1,%%d0\n"
|
||||
|
||||
" cmp %%d2,%%d0\n"
|
||||
" bges lower_limit_s8\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s8:\n"
|
||||
|
||||
" cmp %%d3,%%d0\n"
|
||||
" bles upper_limit_s8\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s8:\n"
|
||||
" moveb %%d0,%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s8\n"
|
||||
"stoploop_s8:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_s16msb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n"
|
||||
"mixloop_s16msb:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" addl %%d1,%%d0\n"
|
||||
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16msb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16msb:\n"
|
||||
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16msb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16msb:\n"
|
||||
" move %%d0,%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s16msb\n"
|
||||
"stoploop_s16msb:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_s16lsb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n"
|
||||
"mixloop_s16lsb:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" rorw #8,%%d0\n"
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" rorw #8,%%d1\n"
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" addl %%d1,%%d0\n"
|
||||
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16lsb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16lsb:\n"
|
||||
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16lsb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16lsb:\n"
|
||||
" rorw #8,%%d0\n"
|
||||
" move %%d0,%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s16lsb\n"
|
||||
"stoploop_s16lsb:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
}
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
m68k assembly mix routines
|
||||
|
||||
Patrice Mandin
|
||||
*/
|
||||
|
||||
#if (defined(__m68k__) && !defined(__mcoldfire__)) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char* dst,char* src, long len, long volume, char* mix8);
|
||||
void SDL_MixAudio_m68k_S8(char* dst,char* src, long len, long volume);
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short* dst,short* src, long len, long volume);
|
||||
void SDL_MixAudio_m68k_S16LSB(short* dst,short* src, long len, long volume);
|
||||
#endif
|
Binary file not shown.
|
@ -1,596 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Microsoft WAVE file loading routines */
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_wave.h"
|
||||
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk);
|
||||
|
||||
struct MS_ADPCM_decodestate {
|
||||
Uint8 hPredictor;
|
||||
Uint16 iDelta;
|
||||
Sint16 iSamp1;
|
||||
Sint16 iSamp2;
|
||||
};
|
||||
static struct MS_ADPCM_decoder {
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
Uint16 wNumCoef;
|
||||
Sint16 aCoeff[7][2];
|
||||
/* * * */
|
||||
struct MS_ADPCM_decodestate state[2];
|
||||
} MS_ADPCM_state;
|
||||
|
||||
static int InitMS_ADPCM(WaveFMT *format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
int i;
|
||||
|
||||
/* Set the rogue pointer to the MS_ADPCM specific data */
|
||||
MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
MS_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||||
if ( sizeof(*format) == 16 ) {
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.wNumCoef = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
if ( MS_ADPCM_state.wNumCoef != 7 ) {
|
||||
SDL_SetError("Unknown set of MS_ADPCM coefficients");
|
||||
return(-1);
|
||||
}
|
||||
for ( i=0; i<MS_ADPCM_state.wNumCoef; ++i ) {
|
||||
MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||||
Uint8 nybble, Sint16 *coeff)
|
||||
{
|
||||
const Sint32 max_audioval = ((1<<(16-1))-1);
|
||||
const Sint32 min_audioval = -(1<<(16-1));
|
||||
const Sint32 adaptive[] = {
|
||||
230, 230, 230, 230, 307, 409, 512, 614,
|
||||
768, 614, 512, 409, 307, 230, 230, 230
|
||||
};
|
||||
Sint32 new_sample, delta;
|
||||
|
||||
new_sample = ((state->iSamp1 * coeff[0]) +
|
||||
(state->iSamp2 * coeff[1]))/256;
|
||||
if ( nybble & 0x08 ) {
|
||||
new_sample += state->iDelta * (nybble-0x10);
|
||||
} else {
|
||||
new_sample += state->iDelta * nybble;
|
||||
}
|
||||
if ( new_sample < min_audioval ) {
|
||||
new_sample = min_audioval;
|
||||
} else
|
||||
if ( new_sample > max_audioval ) {
|
||||
new_sample = max_audioval;
|
||||
}
|
||||
delta = ((Sint32)state->iDelta * adaptive[nybble])/256;
|
||||
if ( delta < 16 ) {
|
||||
delta = 16;
|
||||
}
|
||||
state->iDelta = (Uint16)delta;
|
||||
state->iSamp2 = state->iSamp1;
|
||||
state->iSamp1 = (Sint16)new_sample;
|
||||
return(new_sample);
|
||||
}
|
||||
|
||||
static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
struct MS_ADPCM_decodestate *state[2];
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
Sint8 nybble, stereo;
|
||||
Sint16 *coeff[2];
|
||||
Sint32 new_sample;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) *
|
||||
MS_ADPCM_state.wSamplesPerBlock*
|
||||
MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
|
||||
if ( *audio_buf == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
stereo = (MS_ADPCM_state.wavefmt.channels == 2);
|
||||
state[0] = &MS_ADPCM_state.state[0];
|
||||
state[1] = &MS_ADPCM_state.state[stereo];
|
||||
while ( encoded_len >= MS_ADPCM_state.wavefmt.blockalign ) {
|
||||
/* Grab the initial information for this block */
|
||||
state[0]->hPredictor = *encoded++;
|
||||
if ( stereo ) {
|
||||
state[1]->hPredictor = *encoded++;
|
||||
}
|
||||
state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iDelta = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
|
||||
coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
|
||||
|
||||
/* Store the two initial samples we start with */
|
||||
decoded[0] = state[0]->iSamp2&0xFF;
|
||||
decoded[1] = state[0]->iSamp2>>8;
|
||||
decoded += 2;
|
||||
if ( stereo ) {
|
||||
decoded[0] = state[1]->iSamp2&0xFF;
|
||||
decoded[1] = state[1]->iSamp2>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
decoded[0] = state[0]->iSamp1&0xFF;
|
||||
decoded[1] = state[0]->iSamp1>>8;
|
||||
decoded += 2;
|
||||
if ( stereo ) {
|
||||
decoded[0] = state[1]->iSamp1&0xFF;
|
||||
decoded[1] = state[1]->iSamp1>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (MS_ADPCM_state.wSamplesPerBlock-2)*
|
||||
MS_ADPCM_state.wavefmt.channels;
|
||||
while ( samplesleft > 0 ) {
|
||||
nybble = (*encoded)>>4;
|
||||
new_sample = MS_ADPCM_nibble(state[0],nybble,coeff[0]);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2;
|
||||
|
||||
nybble = (*encoded)&0x0F;
|
||||
new_sample = MS_ADPCM_nibble(state[1],nybble,coeff[1]);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2;
|
||||
|
||||
++encoded;
|
||||
samplesleft -= 2;
|
||||
}
|
||||
encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
SDL_free(freeable);
|
||||
return(0);
|
||||
}
|
||||
|
||||
struct IMA_ADPCM_decodestate {
|
||||
Sint32 sample;
|
||||
Sint8 index;
|
||||
};
|
||||
static struct IMA_ADPCM_decoder {
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
/* * * */
|
||||
struct IMA_ADPCM_decodestate state[2];
|
||||
} IMA_ADPCM_state;
|
||||
|
||||
static int InitIMA_ADPCM(WaveFMT *format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
|
||||
/* Set the rogue pointer to the IMA_ADPCM specific data */
|
||||
IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
IMA_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||||
if ( sizeof(*format) == 16 ) {
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
|
||||
{
|
||||
const Sint32 max_audioval = ((1<<(16-1))-1);
|
||||
const Sint32 min_audioval = -(1<<(16-1));
|
||||
const int index_table[16] = {
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8,
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8
|
||||
};
|
||||
const Sint32 step_table[89] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
|
||||
34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
|
||||
143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
|
||||
449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
|
||||
1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
|
||||
3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
|
||||
9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
|
||||
22385, 24623, 27086, 29794, 32767
|
||||
};
|
||||
Sint32 delta, step;
|
||||
|
||||
/* Compute difference and new sample value */
|
||||
step = step_table[state->index];
|
||||
delta = step >> 3;
|
||||
if ( nybble & 0x04 ) delta += step;
|
||||
if ( nybble & 0x02 ) delta += (step >> 1);
|
||||
if ( nybble & 0x01 ) delta += (step >> 2);
|
||||
if ( nybble & 0x08 ) delta = -delta;
|
||||
state->sample += delta;
|
||||
|
||||
/* Update index value */
|
||||
state->index += index_table[nybble];
|
||||
if ( state->index > 88 ) {
|
||||
state->index = 88;
|
||||
} else
|
||||
if ( state->index < 0 ) {
|
||||
state->index = 0;
|
||||
}
|
||||
|
||||
/* Clamp output sample */
|
||||
if ( state->sample > max_audioval ) {
|
||||
state->sample = max_audioval;
|
||||
} else
|
||||
if ( state->sample < min_audioval ) {
|
||||
state->sample = min_audioval;
|
||||
}
|
||||
return(state->sample);
|
||||
}
|
||||
|
||||
/* Fill the decode buffer with a channel block of data (8 samples) */
|
||||
static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
|
||||
int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
|
||||
{
|
||||
int i;
|
||||
Sint8 nybble;
|
||||
Sint32 new_sample;
|
||||
|
||||
decoded += (channel * 2);
|
||||
for ( i=0; i<4; ++i ) {
|
||||
nybble = (*encoded)&0x0F;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
nybble = (*encoded)>>4;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
++encoded;
|
||||
}
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
struct IMA_ADPCM_decodestate *state;
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
unsigned int c, channels;
|
||||
|
||||
/* Check to make sure we have enough variables in the state array */
|
||||
channels = IMA_ADPCM_state.wavefmt.channels;
|
||||
if ( channels > SDL_arraysize(IMA_ADPCM_state.state) ) {
|
||||
SDL_SetError("IMA ADPCM decoder can only handle %d channels",
|
||||
SDL_arraysize(IMA_ADPCM_state.state));
|
||||
return(-1);
|
||||
}
|
||||
state = IMA_ADPCM_state.state;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) *
|
||||
IMA_ADPCM_state.wSamplesPerBlock*
|
||||
IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
|
||||
if ( *audio_buf == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
while ( encoded_len >= IMA_ADPCM_state.wavefmt.blockalign ) {
|
||||
/* Grab the initial information for this block */
|
||||
for ( c=0; c<channels; ++c ) {
|
||||
/* Fill the state information for this block */
|
||||
state[c].sample = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += 2;
|
||||
if ( state[c].sample & 0x8000 ) {
|
||||
state[c].sample -= 0x10000;
|
||||
}
|
||||
state[c].index = *encoded++;
|
||||
/* Reserved byte in buffer header, should be 0 */
|
||||
if ( *encoded++ != 0 ) {
|
||||
/* Uh oh, corrupt data? Buggy code? */;
|
||||
}
|
||||
|
||||
/* Store the initial sample we start with */
|
||||
decoded[0] = (Uint8)(state[c].sample&0xFF);
|
||||
decoded[1] = (Uint8)(state[c].sample>>8);
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (IMA_ADPCM_state.wSamplesPerBlock-1)*channels;
|
||||
while ( samplesleft > 0 ) {
|
||||
for ( c=0; c<channels; ++c ) {
|
||||
Fill_IMA_ADPCM_block(decoded, encoded,
|
||||
c, channels, &state[c]);
|
||||
encoded += 4;
|
||||
samplesleft -= 8;
|
||||
}
|
||||
decoded += (channels * 8 * 2);
|
||||
}
|
||||
encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
SDL_free(freeable);
|
||||
return(0);
|
||||
}
|
||||
|
||||
SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int was_error;
|
||||
Chunk chunk;
|
||||
int lenread;
|
||||
int MS_ADPCM_encoded, IMA_ADPCM_encoded;
|
||||
int samplesize;
|
||||
|
||||
/* WAV magic header */
|
||||
Uint32 RIFFchunk;
|
||||
Uint32 wavelen = 0;
|
||||
Uint32 WAVEmagic;
|
||||
Uint32 headerDiff = 0;
|
||||
|
||||
/* FMT chunk */
|
||||
WaveFMT *format = NULL;
|
||||
|
||||
/* Make sure we are passed a valid data source */
|
||||
was_error = 0;
|
||||
if ( src == NULL ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Check the magic header */
|
||||
RIFFchunk = SDL_ReadLE32(src);
|
||||
wavelen = SDL_ReadLE32(src);
|
||||
if ( wavelen == WAVE ) { /* The RIFFchunk has already been read */
|
||||
WAVEmagic = wavelen;
|
||||
wavelen = RIFFchunk;
|
||||
RIFFchunk = RIFF;
|
||||
} else {
|
||||
WAVEmagic = SDL_ReadLE32(src);
|
||||
}
|
||||
if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) {
|
||||
SDL_SetError("Unrecognized file type (not WAVE)");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
headerDiff += sizeof(Uint32); /* for WAVE */
|
||||
|
||||
/* Read the audio data format chunk */
|
||||
chunk.data = NULL;
|
||||
do {
|
||||
if ( chunk.data != NULL ) {
|
||||
SDL_free(chunk.data);
|
||||
chunk.data = NULL;
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if ( lenread < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *)chunk.data;
|
||||
if ( chunk.magic != FMT ) {
|
||||
SDL_SetError("Complex WAVE files not supported");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
|
||||
switch (SDL_SwapLE16(format->encoding)) {
|
||||
case PCM_CODE:
|
||||
/* We can understand this */
|
||||
break;
|
||||
case MS_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if ( InitMS_ADPCM(format) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = 1;
|
||||
break;
|
||||
case IMA_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if ( InitIMA_ADPCM(format) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
IMA_ADPCM_encoded = 1;
|
||||
break;
|
||||
case MP3_CODE:
|
||||
SDL_SetError("MPEG Layer 3 data not supported",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
default:
|
||||
SDL_SetError("Unknown WAVE data format: 0x%.4x",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
SDL_memset(spec, 0, (sizeof *spec));
|
||||
spec->freq = SDL_SwapLE32(format->frequency);
|
||||
switch (SDL_SwapLE16(format->bitspersample)) {
|
||||
case 4:
|
||||
if ( MS_ADPCM_encoded || IMA_ADPCM_encoded ) {
|
||||
spec->format = AUDIO_S16;
|
||||
} else {
|
||||
was_error = 1;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
spec->format = AUDIO_U8;
|
||||
break;
|
||||
case 16:
|
||||
spec->format = AUDIO_S16;
|
||||
break;
|
||||
default:
|
||||
was_error = 1;
|
||||
break;
|
||||
}
|
||||
if ( was_error ) {
|
||||
SDL_SetError("Unknown %d-bit PCM data format",
|
||||
SDL_SwapLE16(format->bitspersample));
|
||||
goto done;
|
||||
}
|
||||
spec->channels = (Uint8)SDL_SwapLE16(format->channels);
|
||||
spec->samples = 4096; /* Good default buffer size */
|
||||
|
||||
/* Read the audio data chunk */
|
||||
*audio_buf = NULL;
|
||||
do {
|
||||
if ( *audio_buf != NULL ) {
|
||||
SDL_free(*audio_buf);
|
||||
*audio_buf = NULL;
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if ( lenread < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
*audio_len = lenread;
|
||||
*audio_buf = chunk.data;
|
||||
if(chunk.magic != DATA) headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ( chunk.magic != DATA );
|
||||
headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
|
||||
|
||||
if ( MS_ADPCM_encoded ) {
|
||||
if ( MS_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ( IMA_ADPCM_encoded ) {
|
||||
if ( IMA_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't return a buffer that isn't a multiple of samplesize */
|
||||
samplesize = ((spec->format & 0xFF)/8)*spec->channels;
|
||||
*audio_len &= ~(samplesize-1);
|
||||
|
||||
done:
|
||||
if ( format != NULL ) {
|
||||
SDL_free(format);
|
||||
}
|
||||
if ( src ) {
|
||||
if ( freesrc ) {
|
||||
SDL_RWclose(src);
|
||||
} else {
|
||||
/* seek to the end of the file (given by the RIFF chunk) */
|
||||
SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
|
||||
}
|
||||
}
|
||||
if ( was_error ) {
|
||||
spec = NULL;
|
||||
}
|
||||
return(spec);
|
||||
}
|
||||
|
||||
/* Since the WAV memory is allocated in the shared library, it must also
|
||||
be freed here. (Necessary under Win32, VC++)
|
||||
*/
|
||||
void SDL_FreeWAV(Uint8 *audio_buf)
|
||||
{
|
||||
if ( audio_buf != NULL ) {
|
||||
SDL_free(audio_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk)
|
||||
{
|
||||
chunk->magic = SDL_ReadLE32(src);
|
||||
chunk->length = SDL_ReadLE32(src);
|
||||
chunk->data = (Uint8 *)SDL_malloc(chunk->length);
|
||||
if ( chunk->data == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
SDL_free(chunk->data);
|
||||
chunk->data = NULL;
|
||||
return(-1);
|
||||
}
|
||||
return(chunk->length);
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is SDL_free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* WAVE files are little-endian */
|
||||
|
||||
/*******************************************/
|
||||
/* Define values for Microsoft WAVE format */
|
||||
/*******************************************/
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
#define FACT 0x74636166 /* "fact" */
|
||||
#define LIST 0x5453494c /* "LIST" */
|
||||
#define FMT 0x20746D66 /* "fmt " */
|
||||
#define DATA 0x61746164 /* "data" */
|
||||
#define PCM_CODE 0x0001
|
||||
#define MS_ADPCM_CODE 0x0002
|
||||
#define IMA_ADPCM_CODE 0x0011
|
||||
#define MP3_CODE 0x0055
|
||||
#define WAVE_MONO 1
|
||||
#define WAVE_STEREO 2
|
||||
|
||||
/* Normally, these three chunks come consecutively in a WAVE file */
|
||||
typedef struct WaveFMT {
|
||||
/* Not saved in the chunk we read:
|
||||
Uint32 FMTchunk;
|
||||
Uint32 fmtlen;
|
||||
*/
|
||||
Uint16 encoding;
|
||||
Uint16 channels; /* 1 = mono, 2 = stereo */
|
||||
Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
|
||||
Uint32 byterate; /* Average bytes per second */
|
||||
Uint16 blockalign; /* Bytes per sample block */
|
||||
Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
|
||||
} WaveFMT;
|
||||
|
||||
/* The general chunk found in the WAVE file */
|
||||
typedef struct Chunk {
|
||||
Uint32 magic;
|
||||
Uint32 length;
|
||||
Uint8 *data;
|
||||
} Chunk;
|
||||
|
Binary file not shown.
|
@ -1,156 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
|
||||
This file written by Ryan C. Gordon (icculus@icculus.org)
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Output audio to nowhere... */
|
||||
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audiomem.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "../SDL_audiodev_c.h"
|
||||
#include "SDL_dummyaudio.h"
|
||||
|
||||
/* The tag name used by DUMMY audio */
|
||||
#define DUMMYAUD_DRIVER_NAME "dummy"
|
||||
|
||||
/* Audio driver functions */
|
||||
static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec);
|
||||
static void DUMMYAUD_WaitAudio(_THIS);
|
||||
static void DUMMYAUD_PlayAudio(_THIS);
|
||||
static Uint8 *DUMMYAUD_GetAudioBuf(_THIS);
|
||||
static void DUMMYAUD_CloseAudio(_THIS);
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
static int DUMMYAUD_Available(void)
|
||||
{
|
||||
const char *envr = SDL_getenv("SDL_AUDIODRIVER");
|
||||
if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
|
||||
if ( this ) {
|
||||
SDL_memset(this, 0, (sizeof *this));
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
}
|
||||
if ( (this == NULL) || (this->hidden == NULL) ) {
|
||||
SDL_OutOfMemory();
|
||||
if ( this ) {
|
||||
SDL_free(this);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
/* Set the function pointers */
|
||||
this->OpenAudio = DUMMYAUD_OpenAudio;
|
||||
this->WaitAudio = DUMMYAUD_WaitAudio;
|
||||
this->PlayAudio = DUMMYAUD_PlayAudio;
|
||||
this->GetAudioBuf = DUMMYAUD_GetAudioBuf;
|
||||
this->CloseAudio = DUMMYAUD_CloseAudio;
|
||||
|
||||
this->free = DUMMYAUD_DeleteDevice;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
AudioBootStrap DUMMYAUD_bootstrap = {
|
||||
DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
|
||||
DUMMYAUD_Available, DUMMYAUD_CreateDevice
|
||||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DUMMYAUD_WaitAudio(_THIS)
|
||||
{
|
||||
/* Don't block on first calls to simulate initial fragment filling. */
|
||||
if (this->hidden->initial_calls)
|
||||
this->hidden->initial_calls--;
|
||||
else
|
||||
SDL_Delay(this->hidden->write_delay);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_PlayAudio(_THIS)
|
||||
{
|
||||
/* no-op...this is a null driver. */
|
||||
}
|
||||
|
||||
static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return(this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_CloseAudio(_THIS)
|
||||
{
|
||||
if ( this->hidden->mixbuf != NULL ) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
this->hidden->mixbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
{
|
||||
float bytes_per_sec = 0.0f;
|
||||
|
||||
/* Allocate mixing buffer */
|
||||
this->hidden->mixlen = spec->size;
|
||||
this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
|
||||
if ( this->hidden->mixbuf == NULL ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
|
||||
|
||||
bytes_per_sec = (float) (((spec->format & 0xFF) / 8) *
|
||||
spec->channels * spec->freq);
|
||||
|
||||
/*
|
||||
* We try to make this request more audio at the correct rate for
|
||||
* a given audio spec, so timing stays fairly faithful.
|
||||
* Also, we have it not block at all for the first two calls, so
|
||||
* it seems like we're filling two audio fragments right out of the
|
||||
* gate, like other SDL drivers tend to do.
|
||||
*/
|
||||
this->hidden->initial_calls = 2;
|
||||
this->hidden->write_delay =
|
||||
(Uint32) ((((float) spec->size) / bytes_per_sec) * 1000.0f);
|
||||
|
||||
/* We're ready to rock and roll. :-) */
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_dummyaudio_h
|
||||
#define _SDL_dummyaudio_h
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
/* The file descriptor for the audio device */
|
||||
Uint8 *mixbuf;
|
||||
Uint32 mixlen;
|
||||
Uint32 write_delay;
|
||||
Uint32 initial_calls;
|
||||
};
|
||||
|
||||
#endif /* _SDL_dummyaudio_h */
|
Binary file not shown.
|
@ -1,341 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This is the CD-audio control API for Simple DirectMedia Layer */
|
||||
|
||||
#include "SDL_cdrom.h"
|
||||
#include "SDL_syscdrom.h"
|
||||
|
||||
#if !defined(__MACOS__)
|
||||
#define CLIP_FRAMES 10 /* Some CD-ROMs won't go all the way */
|
||||
#endif
|
||||
|
||||
static int SDL_cdinitted = 0;
|
||||
static SDL_CD *default_cdrom;
|
||||
|
||||
/* The system level CD-ROM control functions */
|
||||
struct CDcaps SDL_CDcaps = {
|
||||
NULL, /* Name */
|
||||
NULL, /* Open */
|
||||
NULL, /* GetTOC */
|
||||
NULL, /* Status */
|
||||
NULL, /* Play */
|
||||
NULL, /* Pause */
|
||||
NULL, /* Resume */
|
||||
NULL, /* Stop */
|
||||
NULL, /* Eject */
|
||||
NULL, /* Close */
|
||||
};
|
||||
int SDL_numcds;
|
||||
|
||||
int SDL_CDROMInit(void)
|
||||
{
|
||||
int retval;
|
||||
|
||||
SDL_numcds = 0;
|
||||
retval = SDL_SYS_CDInit();
|
||||
if ( retval == 0 ) {
|
||||
SDL_cdinitted = 1;
|
||||
}
|
||||
default_cdrom = NULL;
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/* Check to see if the CD-ROM subsystem has been initialized */
|
||||
static int CheckInit(int check_cdrom, SDL_CD **cdrom)
|
||||
{
|
||||
int okay;
|
||||
|
||||
okay = SDL_cdinitted;
|
||||
if ( check_cdrom && (*cdrom == NULL) ) {
|
||||
*cdrom = default_cdrom;
|
||||
if ( *cdrom == NULL ) {
|
||||
SDL_SetError("CD-ROM not opened");
|
||||
okay = 0;
|
||||
}
|
||||
}
|
||||
if ( ! SDL_cdinitted ) {
|
||||
SDL_SetError("CD-ROM subsystem not initialized");
|
||||
}
|
||||
return(okay);
|
||||
}
|
||||
|
||||
int SDL_CDNumDrives(void)
|
||||
{
|
||||
if ( ! CheckInit(0, NULL) ) {
|
||||
return(-1);
|
||||
}
|
||||
return(SDL_numcds);
|
||||
}
|
||||
|
||||
const char *SDL_CDName(int drive)
|
||||
{
|
||||
if ( ! CheckInit(0, NULL) ) {
|
||||
return(NULL);
|
||||
}
|
||||
if ( drive >= SDL_numcds ) {
|
||||
SDL_SetError("Invalid CD-ROM drive index");
|
||||
return(NULL);
|
||||
}
|
||||
if ( SDL_CDcaps.Name ) {
|
||||
return(SDL_CDcaps.Name(drive));
|
||||
} else {
|
||||
return("");
|
||||
}
|
||||
}
|
||||
|
||||
SDL_CD *SDL_CDOpen(int drive)
|
||||
{
|
||||
struct SDL_CD *cdrom;
|
||||
|
||||
if ( ! CheckInit(0, NULL) ) {
|
||||
return(NULL);
|
||||
}
|
||||
if ( drive >= SDL_numcds ) {
|
||||
SDL_SetError("Invalid CD-ROM drive index");
|
||||
return(NULL);
|
||||
}
|
||||
cdrom = (SDL_CD *)SDL_malloc(sizeof(*cdrom));
|
||||
if ( cdrom == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
SDL_memset(cdrom, 0, sizeof(*cdrom));
|
||||
cdrom->id = SDL_CDcaps.Open(drive);
|
||||
if ( cdrom->id < 0 ) {
|
||||
SDL_free(cdrom);
|
||||
return(NULL);
|
||||
}
|
||||
default_cdrom = cdrom;
|
||||
return(cdrom);
|
||||
}
|
||||
|
||||
CDstatus SDL_CDStatus(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int i;
|
||||
Uint32 position;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Get the current status of the drive */
|
||||
cdrom->numtracks = 0;
|
||||
cdrom->cur_track = 0;
|
||||
cdrom->cur_frame = 0;
|
||||
status = SDL_CDcaps.Status(cdrom, &i);
|
||||
position = (Uint32)i;
|
||||
cdrom->status = status;
|
||||
|
||||
/* Get the table of contents, if there's a CD available */
|
||||
if ( CD_INDRIVE(status) ) {
|
||||
if ( SDL_CDcaps.GetTOC(cdrom) < 0 ) {
|
||||
status = CD_ERROR;
|
||||
}
|
||||
/* If the drive is playing, get current play position */
|
||||
if ( (status == CD_PLAYING) || (status == CD_PAUSED) ) {
|
||||
for ( i=1; cdrom->track[i].offset <= position; ++i ) {
|
||||
/* Keep looking */;
|
||||
}
|
||||
#ifdef DEBUG_CDROM
|
||||
fprintf(stderr, "Current position: %d, track = %d (offset is %d)\n",
|
||||
position, i-1, cdrom->track[i-1].offset);
|
||||
#endif
|
||||
cdrom->cur_track = i-1;
|
||||
position -= cdrom->track[cdrom->cur_track].offset;
|
||||
cdrom->cur_frame = position;
|
||||
}
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
int SDL_CDPlayTracks(SDL_CD *cdrom,
|
||||
int strack, int sframe, int ntracks, int nframes)
|
||||
{
|
||||
int etrack, eframe;
|
||||
int start, length;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Determine the starting and ending tracks */
|
||||
if ( (strack < 0) || (strack >= cdrom->numtracks) ) {
|
||||
SDL_SetError("Invalid starting track");
|
||||
return(CD_ERROR);
|
||||
}
|
||||
if ( ! ntracks && ! nframes ) {
|
||||
etrack = cdrom->numtracks;
|
||||
eframe = 0;
|
||||
} else {
|
||||
etrack = strack+ntracks;
|
||||
if ( etrack == strack ) {
|
||||
eframe = sframe + nframes;
|
||||
} else {
|
||||
eframe = nframes;
|
||||
}
|
||||
}
|
||||
if ( etrack > cdrom->numtracks ) {
|
||||
SDL_SetError("Invalid play length");
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Skip data tracks and verify frame offsets */
|
||||
while ( (strack <= etrack) &&
|
||||
(cdrom->track[strack].type == SDL_DATA_TRACK) ) {
|
||||
++strack;
|
||||
}
|
||||
if ( sframe >= (int)cdrom->track[strack].length ) {
|
||||
SDL_SetError("Invalid starting frame for track %d", strack);
|
||||
return(CD_ERROR);
|
||||
}
|
||||
while ( (etrack > strack) &&
|
||||
(cdrom->track[etrack-1].type == SDL_DATA_TRACK) ) {
|
||||
--etrack;
|
||||
}
|
||||
if ( eframe > (int)cdrom->track[etrack].length ) {
|
||||
SDL_SetError("Invalid ending frame for track %d", etrack);
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Determine start frame and play length */
|
||||
start = (cdrom->track[strack].offset+sframe);
|
||||
length = (cdrom->track[etrack].offset+eframe)-start;
|
||||
#ifdef CLIP_FRAMES
|
||||
/* I've never seen this necessary, but xmcd does it.. */
|
||||
length -= CLIP_FRAMES; /* CLIP_FRAMES == 10 */
|
||||
#endif
|
||||
if ( length < 0 ) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Play! */
|
||||
#ifdef DEBUG_CDROM
|
||||
fprintf(stderr, "Playing %d frames at offset %d\n", length, start);
|
||||
#endif
|
||||
return(SDL_CDcaps.Play(cdrom, start, length));
|
||||
}
|
||||
|
||||
int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length)
|
||||
{
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
return(SDL_CDcaps.Play(cdrom, sframe, length));
|
||||
}
|
||||
|
||||
int SDL_CDPause(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int retval;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
status = SDL_CDcaps.Status(cdrom, NULL);
|
||||
switch (status) {
|
||||
case CD_PLAYING:
|
||||
retval = SDL_CDcaps.Pause(cdrom);
|
||||
break;
|
||||
default:
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int SDL_CDResume(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int retval;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
status = SDL_CDcaps.Status(cdrom, NULL);
|
||||
switch (status) {
|
||||
case CD_PAUSED:
|
||||
retval = SDL_CDcaps.Resume(cdrom);
|
||||
default:
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int SDL_CDStop(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int retval;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
status = SDL_CDcaps.Status(cdrom, NULL);
|
||||
switch (status) {
|
||||
case CD_PLAYING:
|
||||
case CD_PAUSED:
|
||||
retval = SDL_CDcaps.Stop(cdrom);
|
||||
default:
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int SDL_CDEject(SDL_CD *cdrom)
|
||||
{
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
return(SDL_CDcaps.Eject(cdrom));
|
||||
}
|
||||
|
||||
void SDL_CDClose(SDL_CD *cdrom)
|
||||
{
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return;
|
||||
}
|
||||
SDL_CDcaps.Close(cdrom);
|
||||
SDL_free(cdrom);
|
||||
default_cdrom = NULL;
|
||||
}
|
||||
|
||||
void SDL_CDROMQuit(void)
|
||||
{
|
||||
SDL_SYS_CDQuit();
|
||||
SDL_cdinitted = 0;
|
||||
}
|
Binary file not shown.
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is SDL_free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This is the system specific header for the SDL CD-ROM API */
|
||||
|
||||
/* Structure of CD audio control functions */
|
||||
extern struct CDcaps {
|
||||
/* Get the name of the specified drive */
|
||||
const char *(*Name)(int drive);
|
||||
|
||||
/* Open the specified drive, returning a drive id, or -1 on error */
|
||||
int (*Open)(int drive);
|
||||
|
||||
/* Get table-of-contents (number of tracks + track info) for disk.
|
||||
The TOC information should be stored in the cdrom structure.
|
||||
This function should return 0 on success, or -1 on error.
|
||||
*/
|
||||
int (*GetTOC)(SDL_CD *cdrom);
|
||||
|
||||
/* Return the current status and play position, in frames, of the
|
||||
drive. 'position' may be NULL, and if so, should be ignored.
|
||||
*/
|
||||
CDstatus (*Status)(SDL_CD *cdrom, int *position);
|
||||
|
||||
/* Play from frame 'start' to 'start+len' */
|
||||
int (*Play)(SDL_CD *cdrom, int start, int len);
|
||||
|
||||
/* Pause play */
|
||||
int (*Pause)(SDL_CD *cdrom);
|
||||
|
||||
/* Resume play */
|
||||
int (*Resume)(SDL_CD *cdrom);
|
||||
|
||||
/* Stop play */
|
||||
int (*Stop)(SDL_CD *cdrom);
|
||||
|
||||
/* Eject the current disk */
|
||||
int (*Eject)(SDL_CD *cdrom);
|
||||
|
||||
/* Close the specified drive */
|
||||
void (*Close)(SDL_CD *cdrom);
|
||||
} SDL_CDcaps;
|
||||
|
||||
/* The number of available CD-ROM drives on the system */
|
||||
extern int SDL_numcds;
|
||||
|
||||
/* Function to scan the system for CD-ROM drives and fill SDL_CDcaps.
|
||||
* This function should set SDL_numcds to the number of available CD
|
||||
* drives. Drive 0 should be the system default CD-ROM.
|
||||
* It should return 0, or -1 on an unrecoverable fatal error.
|
||||
*/
|
||||
extern int SDL_SYS_CDInit(void);
|
||||
|
||||
/* Function to perform any system-specific CD-ROM related cleanup */
|
||||
extern void SDL_SYS_CDQuit(void);
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_CDROM_DUMMY) || defined(SDL_CDROM_DISABLED)
|
||||
|
||||
/* Stub functions for system-level CD-ROM audio control */
|
||||
|
||||
#include "SDL_cdrom.h"
|
||||
#include "../SDL_syscdrom.h"
|
||||
|
||||
int SDL_SYS_CDInit(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void SDL_SYS_CDQuit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_CDROM_DUMMY || SDL_CDROM_DISABLED */
|
Binary file not shown.
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
|
||||
|
||||
/* This is the system specific header for the SDL joystick API */
|
||||
|
||||
#include "SDL_joystick.h"
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
|
||||
/* Function to scan the system for joysticks.
|
||||
* This function should set SDL_numjoysticks to the number of available
|
||||
* joysticks. Joystick 0 should be the system default joystick.
|
||||
* It should return 0, or -1 on an unrecoverable fatal error.
|
||||
*/
|
||||
int SDL_SYS_JoystickInit(void)
|
||||
{
|
||||
SDL_numjoysticks = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Function to get the device-dependent name of a joystick */
|
||||
const char *SDL_SYS_JoystickName(int index)
|
||||
{
|
||||
SDL_SetError("Logic error: No joysticks available");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Function to open a joystick for use.
|
||||
The joystick to open is specified by the index field of the joystick.
|
||||
This should fill the nbuttons and naxes fields of the joystick structure.
|
||||
It returns 0, or -1 if there is an error.
|
||||
*/
|
||||
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_SetError("Logic error: No joysticks available");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Function to update the state of a joystick - called as a device poll.
|
||||
* This function shouldn't update the joystick structure directly,
|
||||
* but instead should call SDL_PrivateJoystick*() to deliver events
|
||||
* and update joystick device state.
|
||||
*/
|
||||
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Function to perform any system-specific joystick related cleanup */
|
||||
void SDL_SYS_JoystickQuit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
|
Binary file not shown.
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_LOADSO_DUMMY) || defined(SDL_LOADSO_DISABLED)
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent library loading routines */
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
|
||||
void *SDL_LoadObject(const char *sofile)
|
||||
{
|
||||
const char *loaderror = "SDL_LoadObject() not implemented";
|
||||
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void *SDL_LoadFunction(void *handle, const char *name)
|
||||
{
|
||||
const char *loaderror = "SDL_LoadFunction() not implemented";
|
||||
SDL_SetError("Failed loading %s: %s", name, loaderror);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void SDL_UnloadObject(void *handle)
|
||||
{
|
||||
/* no-op. */
|
||||
}
|
||||
|
||||
#endif /* SDL_LOADSO_DUMMY || SDL_LOADSO_DISABLED */
|
Binary file not shown.
|
@ -1,13 +0,0 @@
|
|||
|
||||
/* Include the SDL main definition header */
|
||||
#include "SDL_main.h"
|
||||
|
||||
#ifdef main
|
||||
#undef main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return(SDL_main(argc, argv));
|
||||
}
|
||||
#else
|
||||
/* Nothing to do on this platform */
|
||||
#endif
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
}
|
||||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* Data to handle a single periodic alarm */
|
||||
static int timer_alive = 0;
|
||||
static SDL_Thread *timer = NULL;
|
||||
|
||||
static int RunTimer(void *unused)
|
||||
{
|
||||
while ( timer_alive ) {
|
||||
if ( SDL_timer_running ) {
|
||||
SDL_ThreadedTimerCheck();
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* This is only called if the event thread is not running */
|
||||
int SDL_SYS_TimerInit(void)
|
||||
{
|
||||
timer_alive = 1;
|
||||
timer = SDL_CreateThread(RunTimer, NULL);
|
||||
if ( timer == NULL )
|
||||
return(-1);
|
||||
return(SDL_SetTimerThreaded(1));
|
||||
}
|
||||
|
||||
void SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
timer_alive = 0;
|
||||
if ( timer ) {
|
||||
SDL_WaitThread(timer, NULL);
|
||||
timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_SYS_StartTimer(void)
|
||||
{
|
||||
SDL_SetError("Internal logic error: threaded timer in use");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void SDL_SYS_StopTimer(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
|
Binary file not shown.
|
@ -31,10 +31,12 @@
|
|||
#include "SDL_timer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
static volatile unsigned *value;
|
||||
/*
|
||||
* static volatile unsigned *value;
|
||||
static volatile unsigned *control;
|
||||
Uint32 tick_sum = 0;
|
||||
Uint32 start = 0;
|
||||
*/
|
||||
|
||||
/*
|
||||
Uses the first timer (0x900C0000)
|
||||
|
@ -54,7 +56,7 @@ Uint32 SDL_GetTicks (void)
|
|||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "../events/SDL_sysevents.h"
|
||||
#include "../events/SDL_events_c.h"
|
||||
|
||||
extern VideoBootStrap PRZ_bootstrap;
|
||||
|
||||
/* Available video drivers */
|
||||
static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_QUARTZ
|
||||
|
@ -128,6 +130,9 @@ static VideoBootStrap *bootstrap[] = {
|
|||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
&DUMMY_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PRIZM
|
||||
&PRZ_bootstrap,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@ -217,7 +222,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
|
|||
video->offset_x = 0;
|
||||
video->offset_y = 0;
|
||||
SDL_memset(&video->info, 0, (sizeof video->info));
|
||||
|
||||
|
||||
video->displayformatalphapixel = NULL;
|
||||
|
||||
/* Set some very sane GL defaults */
|
||||
|
@ -240,7 +245,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
|
|||
video->gl_config.multisamplesamples = 0;
|
||||
video->gl_config.accelerated = -1; /* not known, don't set */
|
||||
video->gl_config.swap_control = -1; /* not known, don't set */
|
||||
|
||||
|
||||
/* Initialize the video subsystem */
|
||||
SDL_memset(&vformat, 0, sizeof(vformat));
|
||||
if ( video->VideoInit(video, &vformat) < 0 ) {
|
||||
|
@ -397,7 +402,7 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
|
|||
if ( sizes == (SDL_Rect **)0 ) {
|
||||
/* No sizes supported at this bit-depth */
|
||||
continue;
|
||||
} else
|
||||
} else
|
||||
if (sizes == (SDL_Rect **)NEGATIVE_ONE) {
|
||||
/* Any size supported at this bit-depth */
|
||||
supported = 1;
|
||||
|
@ -788,7 +793,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
|
||||
#include "SDL_glfuncs.h"
|
||||
#undef SDL_PROC
|
||||
#undef SDL_PROC
|
||||
}
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
|
||||
|
@ -817,9 +822,9 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
) {
|
||||
video->is_32bit = 0;
|
||||
SDL_VideoSurface = SDL_CreateRGBSurface(
|
||||
flags,
|
||||
width,
|
||||
height,
|
||||
flags,
|
||||
width,
|
||||
height,
|
||||
16,
|
||||
31 << 11,
|
||||
63 << 5,
|
||||
|
@ -832,10 +837,10 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
{
|
||||
video->is_32bit = 1;
|
||||
SDL_VideoSurface = SDL_CreateRGBSurface(
|
||||
flags,
|
||||
width,
|
||||
height,
|
||||
32,
|
||||
flags,
|
||||
width,
|
||||
height,
|
||||
32,
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
0x000000FF,
|
||||
0x0000FF00,
|
||||
|
@ -893,7 +898,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
(
|
||||
( !(flags&SDL_ANYFORMAT) &&
|
||||
(SDL_VideoSurface->format->BitsPerPixel != bpp)) ||
|
||||
( (flags&SDL_HWPALETTE) &&
|
||||
( (flags&SDL_HWPALETTE) &&
|
||||
!(SDL_VideoSurface->flags&SDL_HWPALETTE)) ||
|
||||
/* If the surface is in hardware, video writes are visible
|
||||
as soon as they are performed, so we need to buffer them
|
||||
|
@ -921,7 +926,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
return(SDL_PublicSurface);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Convert a surface into the video pixel format.
|
||||
*/
|
||||
SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
|
||||
|
@ -935,7 +940,7 @@ SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
|
|||
/* Set the flags appropriate for copying to display surface */
|
||||
if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw)
|
||||
flags = SDL_HWSURFACE;
|
||||
else
|
||||
else
|
||||
flags = SDL_SWSURFACE;
|
||||
#ifdef AUTORLE_DISPLAYFORMAT
|
||||
flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA));
|
||||
|
@ -1063,14 +1068,14 @@ void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
|
|||
SDL_LockCursor();
|
||||
SDL_DrawCursor(SDL_ShadowSurface);
|
||||
for ( i=0; i<numrects; ++i ) {
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_VideoSurface, &rects[i]);
|
||||
}
|
||||
SDL_EraseCursor(SDL_ShadowSurface);
|
||||
SDL_UnlockCursor();
|
||||
} else {
|
||||
for ( i=0; i<numrects; ++i ) {
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_VideoSurface, &rects[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1576,42 +1581,42 @@ void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
|
|||
|
||||
if ( update.h > 256 )
|
||||
update.h = 256;
|
||||
|
||||
|
||||
this->glFlush();
|
||||
this->glTexSubImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
update.w,
|
||||
update.h,
|
||||
this->glTexSubImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
update.w,
|
||||
update.h,
|
||||
this->is_32bit? GL_RGBA : GL_RGB,
|
||||
#ifdef GL_VERSION_1_2
|
||||
this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
|
||||
#else
|
||||
GL_UNSIGNED_BYTE,
|
||||
#endif
|
||||
(Uint8 *)this->screen->pixels +
|
||||
this->screen->format->BytesPerPixel * update.x +
|
||||
(Uint8 *)this->screen->pixels +
|
||||
this->screen->format->BytesPerPixel * update.x +
|
||||
update.y * this->screen->pitch );
|
||||
|
||||
|
||||
this->glFlush();
|
||||
/*
|
||||
* Note the parens around the function name:
|
||||
* This is because some OpenGL implementations define glTexCoord etc
|
||||
* This is because some OpenGL implementations define glTexCoord etc
|
||||
* as macros, and we don't want them expanded here.
|
||||
*/
|
||||
this->glBegin(GL_TRIANGLE_STRIP);
|
||||
(this->glTexCoord2f)( 0.0, 0.0 );
|
||||
(this->glTexCoord2f)( 0.0, 0.0 );
|
||||
(this->glVertex2i)( update.x, update.y );
|
||||
(this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 );
|
||||
(this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 );
|
||||
(this->glVertex2i)( update.x + update.w, update.y );
|
||||
(this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) );
|
||||
(this->glVertex2i)( update.x, update.y + update.h );
|
||||
(this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) );
|
||||
(this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) );
|
||||
(this->glVertex2i)( update.x + update.w , update.y + update.h );
|
||||
this->glEnd();
|
||||
|
||||
this->glEnd();
|
||||
|
||||
tmp.x += 256;
|
||||
tmp.w -= 256;
|
||||
}
|
||||
|
@ -1641,7 +1646,7 @@ void SDL_GL_Lock()
|
|||
this->glDisable(GL_FOG);
|
||||
this->glDisable(GL_ALPHA_TEST);
|
||||
this->glDisable(GL_DEPTH_TEST);
|
||||
this->glDisable(GL_SCISSOR_TEST);
|
||||
this->glDisable(GL_SCISSOR_TEST);
|
||||
this->glDisable(GL_STENCIL_TEST);
|
||||
this->glDisable(GL_CULL_FACE);
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Being a null driver, there's no event stream. We just define stubs for
|
||||
most of the API. */
|
||||
|
||||
#include "SDL.h"
|
||||
#include "../../events/SDL_sysevents.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
#include "SDL_nullevents_c.h"
|
||||
|
||||
void DUMMY_PumpEvents(_THIS)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
void DUMMY_InitOSKeymap(_THIS)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
/* end of SDL_nullevents.c ... */
|
||||
|
Binary file not shown.
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
|
||||
/* Variables and functions exported by SDL_sysevents.c to other parts
|
||||
of the native video subsystem (SDL_sysvideo.c)
|
||||
*/
|
||||
extern void DUMMY_InitOSKeymap(_THIS);
|
||||
extern void DUMMY_PumpEvents(_THIS);
|
||||
|
||||
/* end of SDL_nullevents_c.h ... */
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_nullmouse_c.h"
|
||||
|
||||
|
||||
/* The implementation dependent data for the window manager cursor */
|
||||
struct WMcursor {
|
||||
int unused;
|
||||
};
|
Binary file not shown.
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
|
||||
/* Functions to be exported */
|
|
@ -1,239 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Dummy SDL video driver implementation; this is just enough to make an
|
||||
* SDL-based application THINK it's got a working video driver, for
|
||||
* applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
|
||||
* and also for use as a collection of stubs when porting SDL to a new
|
||||
* platform for which you haven't yet written a valid video driver.
|
||||
*
|
||||
* This is also a great way to determine bottlenecks: if you think that SDL
|
||||
* is a performance problem for a given platform, enable this driver, and
|
||||
* then see if your application runs faster without video overhead.
|
||||
*
|
||||
* Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
|
||||
* of this was cut-and-pasted from Stephane Peter's work in the AAlib
|
||||
* SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
|
||||
*/
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_mouse.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "../SDL_pixels_c.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
#include "SDL_nullevents_c.h"
|
||||
#include "SDL_nullmouse_c.h"
|
||||
|
||||
#define DUMMYVID_DRIVER_NAME "dummy"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat);
|
||||
static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
|
||||
static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
|
||||
static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
|
||||
static void DUMMY_VideoQuit(_THIS);
|
||||
|
||||
/* Hardware surface functions */
|
||||
static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface);
|
||||
static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface);
|
||||
static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface);
|
||||
static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface);
|
||||
|
||||
/* etc. */
|
||||
static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
|
||||
|
||||
/* DUMMY driver bootstrap functions */
|
||||
|
||||
static int DUMMY_Available(void)
|
||||
{
|
||||
const char *envr = SDL_getenv("SDL_VIDEODRIVER");
|
||||
if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void DUMMY_DeleteDevice(SDL_VideoDevice *device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *DUMMY_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
|
||||
if ( device ) {
|
||||
SDL_memset(device, 0, (sizeof *device));
|
||||
device->hidden = (struct SDL_PrivateVideoData *)
|
||||
SDL_malloc((sizeof *device->hidden));
|
||||
}
|
||||
if ( (device == NULL) || (device->hidden == NULL) ) {
|
||||
SDL_OutOfMemory();
|
||||
if ( device ) {
|
||||
SDL_free(device);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
SDL_memset(device->hidden, 0, (sizeof *device->hidden));
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = DUMMY_VideoInit;
|
||||
device->ListModes = DUMMY_ListModes;
|
||||
device->SetVideoMode = DUMMY_SetVideoMode;
|
||||
device->CreateYUVOverlay = NULL;
|
||||
device->SetColors = DUMMY_SetColors;
|
||||
device->UpdateRects = DUMMY_UpdateRects;
|
||||
device->VideoQuit = DUMMY_VideoQuit;
|
||||
device->AllocHWSurface = DUMMY_AllocHWSurface;
|
||||
device->CheckHWBlit = NULL;
|
||||
device->FillHWRect = NULL;
|
||||
device->SetHWColorKey = NULL;
|
||||
device->SetHWAlpha = NULL;
|
||||
device->LockHWSurface = DUMMY_LockHWSurface;
|
||||
device->UnlockHWSurface = DUMMY_UnlockHWSurface;
|
||||
device->FlipHWSurface = NULL;
|
||||
device->FreeHWSurface = DUMMY_FreeHWSurface;
|
||||
device->SetCaption = NULL;
|
||||
device->SetIcon = NULL;
|
||||
device->IconifyWindow = NULL;
|
||||
device->GrabInput = NULL;
|
||||
device->GetWMInfo = NULL;
|
||||
device->InitOSKeymap = DUMMY_InitOSKeymap;
|
||||
device->PumpEvents = DUMMY_PumpEvents;
|
||||
|
||||
device->free = DUMMY_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap DUMMY_bootstrap = {
|
||||
DUMMYVID_DRIVER_NAME, "SDL dummy video driver",
|
||||
DUMMY_Available, DUMMY_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||
{
|
||||
/*
|
||||
fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n");
|
||||
*/
|
||||
|
||||
/* Determine the screen depth (use default 8-bit depth) */
|
||||
/* we change this during the SDL_SetVideoMode implementation... */
|
||||
vformat->BitsPerPixel = 8;
|
||||
vformat->BytesPerPixel = 1;
|
||||
|
||||
/* We're done! */
|
||||
return(0);
|
||||
}
|
||||
|
||||
SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
||||
{
|
||||
return (SDL_Rect **) -1;
|
||||
}
|
||||
|
||||
SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
int width, int height, int bpp, Uint32 flags)
|
||||
{
|
||||
if ( this->hidden->buffer ) {
|
||||
SDL_free( this->hidden->buffer );
|
||||
}
|
||||
|
||||
this->hidden->buffer = SDL_malloc(width * height * (bpp / 8));
|
||||
if ( ! this->hidden->buffer ) {
|
||||
SDL_SetError("Couldn't allocate buffer for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* printf("Setting mode %dx%d\n", width, height); */
|
||||
|
||||
SDL_memset(this->hidden->buffer, 0, width * height * (bpp / 8));
|
||||
|
||||
/* Allocate the new pixel format for the screen */
|
||||
if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
|
||||
SDL_free(this->hidden->buffer);
|
||||
this->hidden->buffer = NULL;
|
||||
SDL_SetError("Couldn't allocate new pixel format for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Set up the new mode framebuffer */
|
||||
current->flags = flags & SDL_FULLSCREEN;
|
||||
this->hidden->w = current->w = width;
|
||||
this->hidden->h = current->h = height;
|
||||
current->pitch = current->w * (bpp / 8);
|
||||
current->pixels = this->hidden->buffer;
|
||||
|
||||
/* We're done */
|
||||
return(current);
|
||||
}
|
||||
|
||||
/* We don't actually allow hardware surfaces other than the main one */
|
||||
static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* We need to wait for vertical retrace on page flipped displays */
|
||||
static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
|
||||
{
|
||||
/* do nothing of note. */
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Note: If we are terminated, this could be called in the middle of
|
||||
another SDL video routine -- notably UpdateRects.
|
||||
*/
|
||||
void DUMMY_VideoQuit(_THIS)
|
||||
{
|
||||
if (this->screen->pixels != NULL)
|
||||
{
|
||||
SDL_free(this->screen->pixels);
|
||||
this->screen->pixels = NULL;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_nullvideo_h
|
||||
#define _SDL_nullvideo_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_VideoDevice *this
|
||||
|
||||
|
||||
/* Private display data */
|
||||
|
||||
struct SDL_PrivateVideoData {
|
||||
int w, h;
|
||||
void *buffer;
|
||||
};
|
||||
|
||||
#endif /* _SDL_nullvideo_h */
|
Binary file not shown.
|
@ -14,11 +14,11 @@ nSDL_Font *nSDL_LoadFont(int font_index, Uint8 r, Uint8 g, Uint8 b)
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
for ( i = 0; i < NSP_FONT_NUMCHARS; ++i ) {
|
||||
for ( i = 0; i < PRZ_FONT_NUMCHARS; ++i ) {
|
||||
int offset = 8 * i;
|
||||
int max_width = 0;
|
||||
Uint32 color;
|
||||
SDL_Surface *tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, NSP_FONT_WIDTH, NSP_FONT_HEIGHT,
|
||||
SDL_Surface *tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, PRZ_FONT_WIDTH, PRZ_FONT_HEIGHT,
|
||||
16, PRZ_RMASK16, PRZ_GMASK16, PRZ_BMASK16, 0);
|
||||
if ( tmp == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
|
@ -27,11 +27,11 @@ nSDL_Font *nSDL_LoadFont(int font_index, Uint8 r, Uint8 g, Uint8 b)
|
|||
color = SDL_MapRGB(tmp->format, r, g, b);
|
||||
SDL_FillRect(tmp, NULL, ! color);
|
||||
SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, ! color);
|
||||
font->char_width[i] = NSP_FONT_WIDTH;
|
||||
font->char_width[i] = PRZ_FONT_WIDTH;
|
||||
SDL_LockSurface(tmp);
|
||||
for ( j = 0; j < NSP_FONT_HEIGHT; ++j )
|
||||
for ( k = 0; k < NSP_FONT_WIDTH; ++k ) {
|
||||
if ( nsp_font_charmaps[font_index][offset + j] & (1 << (NSP_FONT_WIDTH - k - 1)) ) { /* "Pixel" set */
|
||||
for ( j = 0; j < PRZ_FONT_HEIGHT; ++j )
|
||||
for ( k = 0; k < PRZ_FONT_WIDTH; ++k ) {
|
||||
if ( prz_font_charmaps[font_index][offset + j] & (1 << (PRZ_FONT_WIDTH - k - 1)) ) { /* "Pixel" set */
|
||||
if ( k > max_width ) {
|
||||
font->char_width[i] = k + 1;
|
||||
max_width = k;
|
||||
|
@ -65,7 +65,7 @@ void nSDL_FreeFont(nSDL_Font *font)
|
|||
int i;
|
||||
if ( font == NULL )
|
||||
return;
|
||||
for ( i = 0; i < NSP_FONT_NUMCHARS; ++i )
|
||||
for ( i = 0; i < PRZ_FONT_NUMCHARS; ++i )
|
||||
SDL_FreeSurface(font->chars[i]);
|
||||
SDL_free(font);
|
||||
}
|
||||
|
@ -92,15 +92,15 @@ int nSDL_DrawString(SDL_Surface *surface, nSDL_Font *font,
|
|||
int c = buf[i];
|
||||
if ( c == '\n' ) {
|
||||
pos.x = x;
|
||||
pos.y += NSP_FONT_HEIGHT + font->vspacing;
|
||||
pos.y += PRZ_FONT_HEIGHT + font->vspacing;
|
||||
} else {
|
||||
SDL_Rect rect;
|
||||
rect.x = rect.y = 0;
|
||||
rect.w = font->char_width[c];
|
||||
rect.h = NSP_FONT_HEIGHT;
|
||||
rect.h = PRZ_FONT_HEIGHT;
|
||||
if ( SDL_BlitSurface(font->chars[c], &rect, surface, &pos) == -1 )
|
||||
return(-1);
|
||||
pos.x += NSP_CHAR_WIDTH(font, c) + font->hspacing;
|
||||
pos.x += PRZ_CHAR_WIDTH(font, c) + font->hspacing;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ int nSDL_GetStringWidth(nSDL_Font *font, const char *s)
|
|||
max_width = width;
|
||||
width = 0;
|
||||
} else
|
||||
width += NSP_CHAR_WIDTH(font, *s) + font->hspacing;
|
||||
width += PRZ_CHAR_WIDTH(font, *s) + font->hspacing;
|
||||
} while ( *s++ );
|
||||
return(max_width - font->hspacing);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ int nSDL_GetStringHeight(nSDL_Font *font, const char *s)
|
|||
int height = 0;
|
||||
do {
|
||||
if ( *s == '\n' || *s == '\0' )
|
||||
height += NSP_FONT_HEIGHT + font->vspacing;
|
||||
height += PRZ_FONT_HEIGHT + font->vspacing;
|
||||
} while ( *s++ );
|
||||
return(height - font->vspacing);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _SDL_tinspirefonts_h
|
||||
#define _SDL_tinspirefonts_h
|
||||
|
||||
#define NSP_CHAR_WIDTH(font, c) (font->monospaced ? NSP_FONT_WIDTH : font->char_width[(int)c])
|
||||
#define PRZ_CHAR_WIDTH(font, c) (font->monospaced ? PRZ_FONT_WIDTH : font->char_width[(int)c])
|
||||
|
||||
|
||||
static unsigned char nsp_font_charmaps[NSP_NUMFONTS][2048] = {
|
||||
static unsigned char prz_font_charmaps[NSP_NUMFONTS][2048] = {
|
||||
/* NSDL_FONT_THIN */
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 000 (.)
|
||||
|
|
|
@ -94,11 +94,13 @@ static SDL_VideoDevice *PRZ_CreateDevice(int devindex)
|
|||
return device;
|
||||
}
|
||||
|
||||
|
||||
VideoBootStrap PRZ_bootstrap = {
|
||||
"prizm", "SDL Casio PRIZM video driver",
|
||||
PRZ_Available, PRZ_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
static int PRZ_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||
{
|
||||
this->hidden->cx = (int) true;
|
||||
|
@ -142,8 +144,8 @@ static SDL_Surface *PRZ_SetVideoMode(_THIS, SDL_Surface *current,
|
|||
rmask = PRZ_RMASK16;
|
||||
gmask = PRZ_GMASK16;
|
||||
bmask = PRZ_BMASK16;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( this->hidden->buffer ) {
|
||||
SDL_free( this->hidden->buffer );
|
||||
}
|
||||
|
@ -215,7 +217,8 @@ static void PRZ_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
|||
|
||||
src_addr = PRZ_PIXEL_ADDR(SDL_VideoSurface->pixels, rect->x, rect->y,
|
||||
SDL_VideoSurface->pitch, SDL_VideoSurface->format->BytesPerPixel);
|
||||
dst_addr = PRZ_PIXEL_ADDR(this->hidden->buffer2, rect->x, rect->y, 2 * DWIDTH, 2);
|
||||
//dst_addr = PRZ_PIXEL_ADDR(this->hidden->buffer2, rect->x, rect->y, 2 * DWIDTH, 2);
|
||||
dst_addr = PRZ_PIXEL_ADDR(gint_vram, rect->x, rect->y, 2 * DWIDTH, 2);
|
||||
dst_addr += this->hidden->offset;
|
||||
|
||||
odd_left = (this->hidden->win_x + rect->x) & 1;
|
||||
|
@ -232,7 +235,7 @@ static void PRZ_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
|||
PRZ_DRAW_LOOP(
|
||||
SDL_memcpy(dst_addr, src_addr, row_bytes);
|
||||
);
|
||||
}
|
||||
}
|
||||
dupdate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue