1
0
Fork 0
forked from len0rd/rockbox

SDL: Silence a large number of compile warnings (WIP)

There are some real bugs in here, but we're drowning in warnings.

Change-Id: I7c2c0eafc8426327521bdd8a3ac2d3742ac16864
This commit is contained in:
Solomon Peachy 2020-04-04 20:24:33 -04:00
parent 2ad6c3438e
commit e28d1fe916
44 changed files with 424 additions and 395 deletions

View file

@ -60,15 +60,15 @@ const SDL_version *IMG_Linked_Version(void)
return(&linked_version); return(&linked_version);
} }
extern int IMG_InitJPG(); extern int IMG_InitJPG(void);
extern void IMG_QuitJPG(); extern void IMG_QuitJPG(void);
extern int IMG_InitPNG(); extern int IMG_InitPNG(void);
extern void IMG_QuitPNG(); extern void IMG_QuitPNG(void);
extern int IMG_InitTIF(); extern int IMG_InitTIF(void);
extern void IMG_QuitTIF(); extern void IMG_QuitTIF(void);
extern int IMG_InitWEBP(); extern int IMG_InitWEBP(void);
extern void IMG_QuitWEBP(); extern void IMG_QuitWEBP(void);
static int initialized = 0; static int initialized = 0;

View file

@ -60,7 +60,7 @@ static struct {
} lib; } lib;
#ifdef LOAD_JPG_DYNAMIC #ifdef LOAD_JPG_DYNAMIC
int IMG_InitJPG() int IMG_InitJPG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.handle = SDL_LoadObject(LOAD_JPG_DYNAMIC); lib.handle = SDL_LoadObject(LOAD_JPG_DYNAMIC);
@ -74,56 +74,56 @@ int IMG_InitJPG()
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_CreateDecompress = lib.jpeg_CreateDecompress =
(void (*) (j_decompress_ptr, int, size_t)) (void (*) (j_decompress_ptr, int, size_t))
SDL_LoadFunction(lib.handle, "jpeg_CreateDecompress"); SDL_LoadFunction(lib.handle, "jpeg_CreateDecompress");
if ( lib.jpeg_CreateDecompress == NULL ) { if ( lib.jpeg_CreateDecompress == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_destroy_decompress = lib.jpeg_destroy_decompress =
(void (*) (j_decompress_ptr)) (void (*) (j_decompress_ptr))
SDL_LoadFunction(lib.handle, "jpeg_destroy_decompress"); SDL_LoadFunction(lib.handle, "jpeg_destroy_decompress");
if ( lib.jpeg_destroy_decompress == NULL ) { if ( lib.jpeg_destroy_decompress == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_finish_decompress = lib.jpeg_finish_decompress =
(boolean (*) (j_decompress_ptr)) (boolean (*) (j_decompress_ptr))
SDL_LoadFunction(lib.handle, "jpeg_finish_decompress"); SDL_LoadFunction(lib.handle, "jpeg_finish_decompress");
if ( lib.jpeg_finish_decompress == NULL ) { if ( lib.jpeg_finish_decompress == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_read_header = lib.jpeg_read_header =
(int (*) (j_decompress_ptr, boolean)) (int (*) (j_decompress_ptr, boolean))
SDL_LoadFunction(lib.handle, "jpeg_read_header"); SDL_LoadFunction(lib.handle, "jpeg_read_header");
if ( lib.jpeg_read_header == NULL ) { if ( lib.jpeg_read_header == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_read_scanlines = lib.jpeg_read_scanlines =
(JDIMENSION (*) (j_decompress_ptr, JSAMPARRAY, JDIMENSION)) (JDIMENSION (*) (j_decompress_ptr, JSAMPARRAY, JDIMENSION))
SDL_LoadFunction(lib.handle, "jpeg_read_scanlines"); SDL_LoadFunction(lib.handle, "jpeg_read_scanlines");
if ( lib.jpeg_read_scanlines == NULL ) { if ( lib.jpeg_read_scanlines == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_resync_to_restart = lib.jpeg_resync_to_restart =
(boolean (*) (j_decompress_ptr, int)) (boolean (*) (j_decompress_ptr, int))
SDL_LoadFunction(lib.handle, "jpeg_resync_to_restart"); SDL_LoadFunction(lib.handle, "jpeg_resync_to_restart");
if ( lib.jpeg_resync_to_restart == NULL ) { if ( lib.jpeg_resync_to_restart == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_start_decompress = lib.jpeg_start_decompress =
(boolean (*) (j_decompress_ptr)) (boolean (*) (j_decompress_ptr))
SDL_LoadFunction(lib.handle, "jpeg_start_decompress"); SDL_LoadFunction(lib.handle, "jpeg_start_decompress");
if ( lib.jpeg_start_decompress == NULL ) { if ( lib.jpeg_start_decompress == NULL ) {
SDL_UnloadObject(lib.handle); SDL_UnloadObject(lib.handle);
return -1; return -1;
} }
lib.jpeg_std_error = lib.jpeg_std_error =
(struct jpeg_error_mgr * (*) (struct jpeg_error_mgr *)) (struct jpeg_error_mgr * (*) (struct jpeg_error_mgr *))
SDL_LoadFunction(lib.handle, "jpeg_std_error"); SDL_LoadFunction(lib.handle, "jpeg_std_error");
if ( lib.jpeg_std_error == NULL ) { if ( lib.jpeg_std_error == NULL ) {
@ -135,7 +135,7 @@ int IMG_InitJPG()
return 0; return 0;
} }
void IMG_QuitJPG() void IMG_QuitJPG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -146,7 +146,7 @@ void IMG_QuitJPG()
--lib.loaded; --lib.loaded;
} }
#else #else
int IMG_InitJPG() int IMG_InitJPG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.jpeg_calc_output_dimensions = jpeg_calc_output_dimensions; lib.jpeg_calc_output_dimensions = jpeg_calc_output_dimensions;
@ -163,7 +163,7 @@ int IMG_InitJPG()
return 0; return 0;
} }
void IMG_QuitJPG() void IMG_QuitJPG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -468,13 +468,13 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
#else #else
int IMG_InitJPG() int IMG_InitJPG(void)
{ {
IMG_SetError("JPEG images are not supported"); IMG_SetError("JPEG images are not supported");
return(-1); return(-1);
} }
void IMG_QuitJPG() void IMG_QuitJPG(void)
{ {
} }

View file

@ -32,25 +32,25 @@
/*============================================================================= /*=============================================================================
File: SDL_png.c File: SDL_png.c
Purpose: A PNG loader and saver for the SDL library Purpose: A PNG loader and saver for the SDL library
Revision: Revision:
Created by: Philippe Lavoie (2 November 1998) Created by: Philippe Lavoie (2 November 1998)
lavoie@zeus.genie.uottawa.ca lavoie@zeus.genie.uottawa.ca
Modified by: Modified by:
Copyright notice: Copyright notice:
Copyright (C) 1998 Philippe Lavoie Copyright (C) 1998 Philippe Lavoie
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU Library General Public You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@ -102,7 +102,7 @@ static struct {
} lib; } lib;
#ifdef LOAD_PNG_DYNAMIC #ifdef LOAD_PNG_DYNAMIC
int IMG_InitPNG() int IMG_InitPNG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.handle = SDL_LoadObject(LOAD_PNG_DYNAMIC); lib.handle = SDL_LoadObject(LOAD_PNG_DYNAMIC);
@ -249,7 +249,7 @@ int IMG_InitPNG()
return 0; return 0;
} }
void IMG_QuitPNG() void IMG_QuitPNG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -260,7 +260,7 @@ void IMG_QuitPNG()
--lib.loaded; --lib.loaded;
} }
#else #else
int IMG_InitPNG() int IMG_InitPNG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.png_create_info_struct = png_create_info_struct; lib.png_create_info_struct = png_create_info_struct;
@ -289,7 +289,7 @@ int IMG_InitPNG()
return 0; return 0;
} }
void IMG_QuitPNG() void IMG_QuitPNG(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -526,7 +526,7 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
palette->colors[i].b = i; palette->colors[i].b = i;
} }
} else if (png_num_palette > 0 ) { } else if (png_num_palette > 0 ) {
palette->ncolors = png_num_palette; palette->ncolors = png_num_palette;
for( i=0; i<png_num_palette; ++i ) { for( i=0; i<png_num_palette; ++i ) {
palette->colors[i].b = png_palette[i].blue; palette->colors[i].b = png_palette[i].blue;
palette->colors[i].g = png_palette[i].green; palette->colors[i].g = png_palette[i].green;
@ -552,18 +552,18 @@ done: /* Clean up and return */
} }
IMG_SetError(error); IMG_SetError(error);
} }
return(surface); return(surface);
} }
#else #else
int IMG_InitPNG() int IMG_InitPNG(void)
{ {
IMG_SetError("PNG images are not supported"); IMG_SetError("PNG images are not supported");
return(-1); return(-1);
} }
void IMG_QuitPNG() void IMG_QuitPNG(void)
{ {
} }

View file

@ -42,7 +42,7 @@ static struct {
} lib; } lib;
#ifdef LOAD_TIF_DYNAMIC #ifdef LOAD_TIF_DYNAMIC
int IMG_InitTIF() int IMG_InitTIF(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.handle = SDL_LoadObject(LOAD_TIF_DYNAMIC); lib.handle = SDL_LoadObject(LOAD_TIF_DYNAMIC);
@ -89,7 +89,7 @@ int IMG_InitTIF()
return 0; return 0;
} }
void IMG_QuitTIF() void IMG_QuitTIF(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -100,7 +100,7 @@ void IMG_QuitTIF()
--lib.loaded; --lib.loaded;
} }
#else #else
int IMG_InitTIF() int IMG_InitTIF(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.TIFFClientOpen = TIFFClientOpen; lib.TIFFClientOpen = TIFFClientOpen;
@ -113,7 +113,7 @@ int IMG_InitTIF()
return 0; return 0;
} }
void IMG_QuitTIF() void IMG_QuitTIF(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -222,7 +222,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
} }
/* turn off memory mapped access with the m flag */ /* turn off memory mapped access with the m flag */
tiff = lib.TIFFClientOpen("SDL_image", "rm", (thandle_t)src, tiff = lib.TIFFClientOpen("SDL_image", "rm", (thandle_t)src,
tiff_read, tiff_write, tiff_seek, tiff_close, tiff_size, tiff_map, tiff_unmap); tiff_read, tiff_write, tiff_seek, tiff_close, tiff_size, tiff_map, tiff_unmap);
if(!tiff) if(!tiff)
goto error; goto error;
@ -239,7 +239,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
Rmask, Gmask, Bmask, Amask); Rmask, Gmask, Bmask, Amask);
if(!surface) if(!surface)
goto error; goto error;
if(!lib.TIFFReadRGBAImage(tiff, img_width, img_height, surface->pixels, 0)) if(!lib.TIFFReadRGBAImage(tiff, img_width, img_height, surface->pixels, 0))
goto error; goto error;
@ -258,7 +258,7 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
} }
} }
lib.TIFFClose(tiff); lib.TIFFClose(tiff);
return surface; return surface;
error: error:
@ -271,13 +271,13 @@ error:
#else #else
int IMG_InitTIF() int IMG_InitTIF(void)
{ {
IMG_SetError("TIFF images are not supported"); IMG_SetError("TIFF images are not supported");
return(-1); return(-1);
} }
void IMG_QuitTIF() void IMG_QuitTIF(void)
{ {
} }

View file

@ -30,8 +30,8 @@
/*============================================================================= /*=============================================================================
File: SDL_webp.c File: SDL_webp.c
Purpose: A WEBP loader for the SDL library Purpose: A WEBP loader for the SDL library
Revision: Revision:
Created by: Michael Bonfils (Murlock) (26 November 2011) Created by: Michael Bonfils (Murlock) (26 November 2011)
murlock42@gmail.com murlock42@gmail.com
@ -53,14 +53,14 @@ static struct {
} lib; } lib;
#ifdef LOAD_WEBP_DYNAMIC #ifdef LOAD_WEBP_DYNAMIC
int IMG_InitWEBP() int IMG_InitWEBP(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.handle = SDL_LoadObject(LOAD_WEBP_DYNAMIC); lib.handle = SDL_LoadObject(LOAD_WEBP_DYNAMIC);
if ( lib.handle == NULL ) { if ( lib.handle == NULL ) {
return -1; return -1;
} }
lib.webp_get_features_internal = lib.webp_get_features_internal =
( int (*) (const uint8_t *, uint32_t, WebPBitstreamFeatures* const, int) ) ( int (*) (const uint8_t *, uint32_t, WebPBitstreamFeatures* const, int) )
SDL_LoadFunction(lib.handle, "WebPGetFeaturesInternal" ); SDL_LoadFunction(lib.handle, "WebPGetFeaturesInternal" );
if ( lib.webp_get_features_internal == NULL ) { if ( lib.webp_get_features_internal == NULL ) {
@ -68,7 +68,7 @@ int IMG_InitWEBP()
return -1; return -1;
} }
lib.webp_decode_rgb_into = lib.webp_decode_rgb_into =
( uint8_t* (*) (const uint8_t*, uint32_t, uint8_t*, int, int ) ) ( uint8_t* (*) (const uint8_t*, uint32_t, uint8_t*, int, int ) )
SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" ); SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" );
if ( lib.webp_decode_rgb_into == NULL ) { if ( lib.webp_decode_rgb_into == NULL ) {
@ -76,7 +76,7 @@ int IMG_InitWEBP()
return -1; return -1;
} }
lib.webp_decode_rgba_into = lib.webp_decode_rgba_into =
( uint8_t* (*) (const uint8_t*, uint32_t, uint8_t*, int, int ) ) ( uint8_t* (*) (const uint8_t*, uint32_t, uint8_t*, int, int ) )
SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" ); SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" );
if ( lib.webp_decode_rgba_into == NULL ) { if ( lib.webp_decode_rgba_into == NULL ) {
@ -88,7 +88,7 @@ int IMG_InitWEBP()
return 0; return 0;
} }
void IMG_QuitWEBP() void IMG_QuitWEBP(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -99,7 +99,7 @@ void IMG_QuitWEBP()
--lib.loaded; --lib.loaded;
} }
#else #else
int IMG_InitWEBP() int IMG_InitWEBP(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
lib.webp_get_features_internal = WebPGetFeaturesInternal; lib.webp_get_features_internal = WebPGetFeaturesInternal;
@ -110,7 +110,7 @@ int IMG_InitWEBP()
return 0; return 0;
} }
void IMG_QuitWEBP() void IMG_QuitWEBP(void)
{ {
if ( lib.loaded == 0 ) { if ( lib.loaded == 0 ) {
return; return;
@ -207,7 +207,7 @@ SDL_Surface *IMG_LoadWEBP_RW(SDL_RWops *src)
error = "Failed to read WEBP"; error = "Failed to read WEBP";
goto error; goto error;
} }
#if 0 #if 0
// extract size of picture, not interesting since we don't know about alpha channel // extract size of picture, not interesting since we don't know about alpha channel
int width = -1, height = -1; int width = -1, height = -1;
@ -270,13 +270,13 @@ error:
#else #else
int IMG_InitWEBP() int IMG_InitWEBP(void)
{ {
IMG_SetError("WEBP images are not supported"); IMG_SetError("WEBP images are not supported");
return(-1); return(-1);
} }
void IMG_QuitWEBP() void IMG_QuitWEBP(void)
{ {
} }

View file

@ -62,5 +62,5 @@ extern flac_loader flac;
#endif /* FLAC_MUSIC */ #endif /* FLAC_MUSIC */
extern int Mix_InitFLAC(); extern int Mix_InitFLAC(void);
extern void Mix_QuitFLAC(); extern void Mix_QuitFLAC(void);

View file

@ -58,5 +58,5 @@ extern mikmod_loader mikmod;
#endif /* MOD_MUSIC */ #endif /* MOD_MUSIC */
extern int Mix_InitMOD(); extern int Mix_InitMOD(void);
extern void Mix_QuitMOD(); extern void Mix_QuitMOD(void);

View file

@ -43,5 +43,5 @@ extern smpeg_loader smpeg;
#endif /* MUSIC_MP3 */ #endif /* MUSIC_MP3 */
extern int Mix_InitMP3(); extern int Mix_InitMP3(void);
extern void Mix_QuitMP3(); extern void Mix_QuitMP3(void);

View file

@ -49,5 +49,5 @@ extern vorbis_loader vorbis;
#endif /* OGG_MUSIC */ #endif /* OGG_MUSIC */
extern int Mix_InitOgg(); extern int Mix_InitOgg(void);
extern void Mix_QuitOgg(); extern void Mix_QuitOgg(void);

View file

@ -173,7 +173,7 @@ static void music_internal_initialize_volume(void);
static void music_internal_volume(int volume); static void music_internal_volume(int volume);
static int music_internal_play(Mix_Music *music, double position); static int music_internal_play(Mix_Music *music, double position);
static int music_internal_position(double position); static int music_internal_position(double position);
static int music_internal_playing(); static int music_internal_playing(void);
static void music_internal_halt(void); static void music_internal_halt(void);
@ -193,8 +193,8 @@ void Mix_HookMusicFinished(void (*music_finished)(void))
static int music_halt_or_loop (void) static int music_halt_or_loop (void)
{ {
/* Restart music if it has to loop */ /* Restart music if it has to loop */
if (!music_internal_playing()) if (!music_internal_playing())
{ {
#ifdef USE_NATIVE_MIDI #ifdef USE_NATIVE_MIDI
/* Native MIDI handles looping internally */ /* Native MIDI handles looping internally */
@ -211,17 +211,17 @@ static int music_halt_or_loop (void)
current_fade = music_playing->fading; current_fade = music_playing->fading;
music_internal_play(music_playing, 0.0); music_internal_play(music_playing, 0.0);
music_playing->fading = current_fade; music_playing->fading = current_fade;
} }
else else
{ {
music_internal_halt(); music_internal_halt();
if (music_finished_hook) if (music_finished_hook)
music_finished_hook(); music_finished_hook();
return 0; return 0;
} }
} }
return 1; return 1;
} }
@ -258,7 +258,7 @@ void music_mixer(void *udata, Uint8 *stream, int len)
music_playing->fading = MIX_NO_FADING; music_playing->fading = MIX_NO_FADING;
} }
} }
music_halt_or_loop(); music_halt_or_loop();
if (!music_internal_playing()) if (!music_internal_playing())
return; return;
@ -309,7 +309,7 @@ void music_mixer(void *udata, Uint8 *stream, int len)
#endif #endif
#ifdef OGG_MUSIC #ifdef OGG_MUSIC
case MUS_OGG: case MUS_OGG:
left = OGG_playAudio(music_playing->data.ogg, stream, len); left = OGG_playAudio(music_playing->data.ogg, stream, len);
break; break;
#endif #endif
@ -334,7 +334,7 @@ void music_mixer(void *udata, Uint8 *stream, int len)
} }
} }
skip: skip:
/* Handle seamless music looping */ /* Handle seamless music looping */
if (left > 0 && left < len) { if (left > 0 && left < len) {

View file

@ -9,7 +9,9 @@
/* This is for use with the SDL library */ /* This is for use with the SDL library */
#ifndef __TIMIDITY_CONFIG_H__ #ifndef __TIMIDITY_CONFIG_H__
#define __TIMIDITY_CONFIG_H__ #define __TIMIDITY_CONFIG_H__
#ifndef SDL
#define SDL #define SDL
#endif
#include "SDL_config.h" #include "SDL_config.h"
#include "SDL_endian.h" #include "SDL_endian.h"
@ -24,7 +26,7 @@
#define DEFAULT_PROGRAM 0 #define DEFAULT_PROGRAM 0
/* 9 here is MIDI channel 10, which is the standard percussion channel. /* 9 here is MIDI channel 10, which is the standard percussion channel.
Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too.
On the other hand, some files know that 16 is not a drum channel and On the other hand, some files know that 16 is not a drum channel and
try to play music on it. This is now a runtime option, so this isn't try to play music on it. This is now a runtime option, so this isn't
a critical choice anymore. */ a critical choice anymore. */
@ -131,7 +133,7 @@ typedef double FLOAT_T;
#define MAX_CONTROL_RATIO 255 #define MAX_CONTROL_RATIO 255
typedef unsigned int uint32; typedef unsigned int uint32;
typedef int int32; typedef int int32;
typedef unsigned short uint16; typedef unsigned short uint16;
typedef short int16; typedef short int16;
typedef unsigned char uint8; typedef unsigned char uint8;

View file

@ -6,9 +6,10 @@
it under the terms of the Perl Artistic License, available in COPYING. it under the terms of the Perl Artistic License, available in COPYING.
*/ */
#include "config.h"
#include <SDL_rwops.h> #include <SDL_rwops.h>
#include "config.h"
#include "common.h" #include "common.h"
#include "instrum.h" #include "instrum.h"
#include "playmidi.h" #include "playmidi.h"
@ -69,14 +70,14 @@ int XG_System_variation_type;
static void adjust_amplification(void) static void adjust_amplification(void)
{ {
master_volume = (FLOAT_T)(amplification) / (FLOAT_T)100.0; master_volume = (FLOAT_T)(amplification) / (FLOAT_T)100.0;
master_volume /= 2; master_volume /= 2;
} }
static void adjust_master_volume(int32 vol) static void adjust_master_volume(int32 vol)
{ {
master_volume = (double)(vol*amplification) / 1638400.0L; master_volume = (double)(vol*amplification) / 1638400.0L;
master_volume /= 2; master_volume /= 2;
} }
@ -146,7 +147,7 @@ static void select_sample(int v, Instrument *ip)
} }
f=voice[v].orig_frequency; f=voice[v].orig_frequency;
/* /*
No suitable sample found! We'll select the sample whose root No suitable sample found! We'll select the sample whose root
frequency is closest to the one we want. (Actually we should frequency is closest to the one we want. (Actually we should
probably convert the low, high, and root frequencies to MIDI note probably convert the low, high, and root frequencies to MIDI note
@ -214,11 +215,11 @@ static void select_stereo_samples(int v, InstrumentLayer *lp)
static void recompute_freq(int v) static void recompute_freq(int v)
{ {
int int
sign=(voice[v].sample_increment < 0), /* for bidirectional loops */ sign=(voice[v].sample_increment < 0), /* for bidirectional loops */
pb=channel[voice[v].channel].pitchbend; pb=channel[voice[v].channel].pitchbend;
double a; double a;
if (!voice[v].sample->sample_rate) if (!voice[v].sample->sample_rate)
return; return;
@ -262,22 +263,22 @@ static void recompute_freq(int v)
(double)(play_mode->rate)), (double)(play_mode->rate)),
FRACTION_BITS); FRACTION_BITS);
if (sign) if (sign)
a = -a; /* need to preserve the loop direction */ a = -a; /* need to preserve the loop direction */
voice[v].sample_increment = (int32)(a); voice[v].sample_increment = (int32)(a);
} }
static int expr_curve[128] = { static int expr_curve[128] = {
7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11,
11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15,
15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 22, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 22,
22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31,
32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 63, 45, 46, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 63,
64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 80, 82, 83, 85, 87, 89, 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 80, 82, 83, 85, 87, 89,
91, 93, 95, 97, 99, 102, 104, 106, 109, 111, 113, 116, 118, 121, 91, 93, 95, 97, 99, 102, 104, 106, 109, 111, 113, 116, 118, 121,
124, 127 124, 127
}; };
static int panf(int pan, int speaker, int separation) static int panf(int pan, int speaker, int separation)
@ -423,7 +424,7 @@ static void recompute_amp(int v)
/* just a variant of note_on() */ /* just a variant of note_on() */
static int vc_alloc(int j) static int vc_alloc(int j)
{ {
int i=voices; int i=voices;
while (i--) while (i--)
{ {
@ -439,7 +440,7 @@ static void kill_note(int i);
static void kill_others(int i) static void kill_others(int i)
{ {
int j=voices; int j=voices;
if (!voice[i].sample->exclusiveClass) return; if (!voice[i].sample->exclusiveClass) return;
@ -769,7 +770,7 @@ static void start_note(MidiEvent *e, int i)
ip = lp->instrument; ip = lp->instrument;
if (ip->type == INST_GUS && ip->samples != 1) if (ip->type == INST_GUS && ip->samples != 1)
{ {
ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
"Strange: percussion instrument with %d samples!", ip->samples); "Strange: percussion instrument with %d samples!", ip->samples);
} }
@ -989,14 +990,14 @@ static void kill_note(int i)
/* Only one instance of a note can be playing on a single channel. */ /* Only one instance of a note can be playing on a single channel. */
static void note_on(MidiEvent *e) static void note_on(MidiEvent *e)
{ {
int i=voices, lowest=-1; int i=voices, lowest=-1;
int32 lv=0x7FFFFFFF, v; int32 lv=0x7FFFFFFF, v;
while (i--) while (i--)
{ {
if (voice[i].status == VOICE_FREE) if (voice[i].status == VOICE_FREE)
lowest=i; /* Can't get a lower volume than silence */ lowest=i; /* Can't get a lower volume than silence */
else if (voice[i].channel==e->channel && else if (voice[i].channel==e->channel &&
(voice[i].note==e->a || channel[voice[i].channel].mono)) (voice[i].note==e->a || channel[voice[i].channel].mono))
kill_note(i); kill_note(i);
} }
@ -1007,7 +1008,7 @@ static void note_on(MidiEvent *e)
start_note(e,lowest); start_note(e,lowest);
return; return;
} }
#if 0 #if 0
/* Look for the decaying note with the lowest volume */ /* Look for the decaying note with the lowest volume */
i=voices; i=voices;
@ -1136,7 +1137,7 @@ static void all_notes_off(int c)
if (voice[i].status==VOICE_ON && if (voice[i].status==VOICE_ON &&
voice[i].channel==c) voice[i].channel==c)
{ {
if (channel[c].sustain) if (channel[c].sustain)
{ {
voice[i].status=VOICE_SUSTAINED; voice[i].status=VOICE_SUSTAINED;
ctl->note(i); ctl->note(i);
@ -1151,7 +1152,7 @@ static void all_sounds_off(int c)
{ {
int i=voices; int i=voices;
while (i--) while (i--)
if (voice[i].channel==c && if (voice[i].channel==c &&
voice[i].status != VOICE_FREE && voice[i].status != VOICE_FREE &&
voice[i].status != VOICE_DIE) voice[i].status != VOICE_DIE)
{ {
@ -1232,29 +1233,29 @@ static void seek_forward(int32 until_time)
current_event->a; current_event->a;
channel[current_event->channel].pitchfactor=0; channel[current_event->channel].pitchfactor=0;
break; break;
case ME_PITCHWHEEL: case ME_PITCHWHEEL:
channel[current_event->channel].pitchbend= channel[current_event->channel].pitchbend=
current_event->a + current_event->b * 128; current_event->a + current_event->b * 128;
channel[current_event->channel].pitchfactor=0; channel[current_event->channel].pitchfactor=0;
break; break;
case ME_MAINVOLUME: case ME_MAINVOLUME:
channel[current_event->channel].volume=current_event->a; channel[current_event->channel].volume=current_event->a;
break; break;
case ME_MASTERVOLUME: case ME_MASTERVOLUME:
adjust_master_volume(current_event->a + (current_event->b <<7)); adjust_master_volume(current_event->a + (current_event->b <<7));
break; break;
case ME_PAN: case ME_PAN:
channel[current_event->channel].panning=current_event->a; channel[current_event->channel].panning=current_event->a;
break; break;
case ME_EXPRESSION: case ME_EXPRESSION:
channel[current_event->channel].expression=current_event->a; channel[current_event->channel].expression=current_event->a;
break; break;
case ME_PROGRAM: case ME_PROGRAM:
/* if (ISDRUMCHANNEL(current_event->channel)) */ /* if (ISDRUMCHANNEL(current_event->channel)) */
if (channel[current_event->channel].kit) if (channel[current_event->channel].kit)
@ -1310,11 +1311,11 @@ static void seek_forward(int32 until_time)
case ME_RESET_CONTROLLERS: case ME_RESET_CONTROLLERS:
reset_controllers(current_event->channel); reset_controllers(current_event->channel);
break; break;
case ME_TONE_BANK: case ME_TONE_BANK:
channel[current_event->channel].bank=current_event->a; channel[current_event->channel].bank=current_event->a;
break; break;
case ME_EOT: case ME_EOT:
current_sample=current_event->time; current_sample=current_event->time;
return; return;
@ -1336,7 +1337,7 @@ static void skip_to(int32 until_time)
buffered_count=0; buffered_count=0;
buffer_pointer=common_buffer; buffer_pointer=common_buffer;
current_event=event_list; current_event=event_list;
if (until_time) if (until_time)
seek_forward(until_time); seek_forward(until_time);
ctl->reset(); ctl->reset();
@ -1351,15 +1352,15 @@ static int apply_controls(void)
switch(rc=ctl->read(&val)) switch(rc=ctl->read(&val))
{ {
case RC_QUIT: /* [] */ case RC_QUIT: /* [] */
case RC_LOAD_FILE: case RC_LOAD_FILE:
case RC_NEXT: /* >>| */ case RC_NEXT: /* >>| */
case RC_REALLY_PREVIOUS: /* |<< */ case RC_REALLY_PREVIOUS: /* |<< */
return rc; return rc;
case RC_CHANGE_VOLUME: case RC_CHANGE_VOLUME:
if (val>0 || amplification > -val) if (val>0 || amplification > -val)
amplification += val; amplification += val;
else else
amplification=0; amplification=0;
if (amplification > MAX_AMPLIFICATION) if (amplification > MAX_AMPLIFICATION)
amplification=MAX_AMPLIFICATION; amplification=MAX_AMPLIFICATION;
@ -1382,20 +1383,20 @@ static int apply_controls(void)
skip_to(0); skip_to(0);
did_skip=1; did_skip=1;
break; break;
case RC_JUMP: case RC_JUMP:
if (val >= sample_count) if (val >= sample_count)
return RC_NEXT; return RC_NEXT;
skip_to(val); skip_to(val);
return rc; return rc;
case RC_FORWARD: /* >> */ case RC_FORWARD: /* >> */
if (val+current_sample >= sample_count) if (val+current_sample >= sample_count)
return RC_NEXT; return RC_NEXT;
skip_to(val+current_sample); skip_to(val+current_sample);
did_skip=1; did_skip=1;
break; break;
case RC_BACK: /* << */ case RC_BACK: /* << */
if (current_sample > val) if (current_sample > val)
skip_to(current_sample-val); skip_to(current_sample-val);
@ -1405,10 +1406,10 @@ static int apply_controls(void)
break; break;
} }
while (rc!= RC_NONE); while (rc!= RC_NONE);
/* Advertise the skip so that we stop computing the audio buffer */ /* Advertise the skip so that we stop computing the audio buffer */
if (did_skip) if (did_skip)
return RC_JUMP; return RC_JUMP;
else else
return rc; return rc;
} }
@ -1466,7 +1467,7 @@ static int compute_data(void *stream, int32 count)
s32tobuf(stream, common_buffer, channels*AUDIO_BUFFER_SIZE); s32tobuf(stream, common_buffer, channels*AUDIO_BUFFER_SIZE);
buffer_pointer=common_buffer; buffer_pointer=common_buffer;
buffered_count=0; buffered_count=0;
ctl->current_time(current_sample); ctl->current_time(current_sample);
if ((rc=apply_controls())!=RC_NONE) if ((rc=apply_controls())!=RC_NONE)
return rc; return rc;
@ -1485,7 +1486,7 @@ int Timidity_PlaySome(void *stream, int samples)
//printf("Timidity_PlaySome()\n"); //printf("Timidity_PlaySome()\n");
int rc = RC_NONE; int rc = RC_NONE;
int32 end_sample; int32 end_sample;
if ( ! midi_playing ) { if ( ! midi_playing ) {
return RC_NONE; return RC_NONE;
} }
@ -1504,33 +1505,33 @@ int Timidity_PlaySome(void *stream, int samples)
else else
note_on(current_event); note_on(current_event);
break; break;
case ME_NOTEOFF: case ME_NOTEOFF:
current_event->a += channel[current_event->channel].transpose; current_event->a += channel[current_event->channel].transpose;
note_off(current_event); note_off(current_event);
break; break;
case ME_KEYPRESSURE: case ME_KEYPRESSURE:
adjust_pressure(current_event); adjust_pressure(current_event);
break; break;
/* Effects affecting a single channel */ /* Effects affecting a single channel */
case ME_PITCH_SENS: case ME_PITCH_SENS:
channel[current_event->channel].pitchsens=current_event->a; channel[current_event->channel].pitchsens=current_event->a;
channel[current_event->channel].pitchfactor=0; channel[current_event->channel].pitchfactor=0;
break; break;
case ME_PITCHWHEEL: case ME_PITCHWHEEL:
channel[current_event->channel].pitchbend= channel[current_event->channel].pitchbend=
current_event->a + current_event->b * 128; current_event->a + current_event->b * 128;
channel[current_event->channel].pitchfactor=0; channel[current_event->channel].pitchfactor=0;
/* Adjust pitch for notes already playing */ /* Adjust pitch for notes already playing */
adjust_pitchbend(current_event->channel); adjust_pitchbend(current_event->channel);
ctl->pitch_bend(current_event->channel, ctl->pitch_bend(current_event->channel,
channel[current_event->channel].pitchbend); channel[current_event->channel].pitchbend);
break; break;
case ME_MAINVOLUME: case ME_MAINVOLUME:
channel[current_event->channel].volume=current_event->a; channel[current_event->channel].volume=current_event->a;
adjust_volume(current_event->channel); adjust_volume(current_event->channel);
@ -1540,7 +1541,7 @@ int Timidity_PlaySome(void *stream, int samples)
case ME_MASTERVOLUME: case ME_MASTERVOLUME:
adjust_master_volume(current_event->a + (current_event->b <<7)); adjust_master_volume(current_event->a + (current_event->b <<7));
break; break;
case ME_REVERBERATION: case ME_REVERBERATION:
channel[current_event->channel].reverberation=current_event->a; channel[current_event->channel].reverberation=current_event->a;
break; break;
@ -1555,13 +1556,13 @@ int Timidity_PlaySome(void *stream, int samples)
adjust_panning(current_event->channel); adjust_panning(current_event->channel);
ctl->panning(current_event->channel, current_event->a); ctl->panning(current_event->channel, current_event->a);
break; break;
case ME_EXPRESSION: case ME_EXPRESSION:
channel[current_event->channel].expression=current_event->a; channel[current_event->channel].expression=current_event->a;
adjust_volume(current_event->channel); adjust_volume(current_event->channel);
ctl->expression(current_event->channel, current_event->a); ctl->expression(current_event->channel, current_event->a);
break; break;
case ME_PROGRAM: case ME_PROGRAM:
/* if (ISDRUMCHANNEL(current_event->channel)) { */ /* if (ISDRUMCHANNEL(current_event->channel)) { */
if (channel[current_event->channel].kit) { if (channel[current_event->channel].kit) {
@ -1574,23 +1575,23 @@ int Timidity_PlaySome(void *stream, int samples)
} }
ctl->program(current_event->channel, current_event->a); ctl->program(current_event->channel, current_event->a);
break; break;
case ME_SUSTAIN: case ME_SUSTAIN:
channel[current_event->channel].sustain=current_event->a; channel[current_event->channel].sustain=current_event->a;
if (!current_event->a) if (!current_event->a)
drop_sustain(current_event->channel); drop_sustain(current_event->channel);
ctl->sustain(current_event->channel, current_event->a); ctl->sustain(current_event->channel, current_event->a);
break; break;
case ME_RESET_CONTROLLERS: case ME_RESET_CONTROLLERS:
reset_controllers(current_event->channel); reset_controllers(current_event->channel);
redraw_controllers(current_event->channel); redraw_controllers(current_event->channel);
break; break;
case ME_ALL_NOTES_OFF: case ME_ALL_NOTES_OFF:
all_notes_off(current_event->channel); all_notes_off(current_event->channel);
break; break;
case ME_ALL_SOUNDS_OFF: case ME_ALL_SOUNDS_OFF:
all_sounds_off(current_event->channel); all_sounds_off(current_event->channel);
break; break;
@ -1725,7 +1726,7 @@ void Timidity_FreeSong(MidiSong *song)
{ {
if (free_instruments_afterwards) if (free_instruments_afterwards)
free_instruments(); free_instruments();
free(song->events); free(song->events);
free(song); free(song);
} }
@ -1743,4 +1744,3 @@ void Timidity_Close(void)
free_instruments(); free_instruments();
free_pathlist(); free_pathlist();
} }

View file

@ -6,9 +6,10 @@
it under the terms of the Perl Artistic License, available in COPYING. it under the terms of the Perl Artistic License, available in COPYING.
*/ */
#include "config.h"
#include <SDL_rwops.h> #include <SDL_rwops.h>
#include "config.h"
#include "common.h" #include "common.h"
#include "instrum.h" #include "instrum.h"
#include "playmidi.h" #include "playmidi.h"
@ -282,11 +283,11 @@ static MidiEventList *read_midi_event(void)
at+=getvl(); at+=getvl();
if (SDL_RWread(rw,&me,1,1)!=1) if (SDL_RWread(rw,&me,1,1)!=1)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s", ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s",
current_filename, strerror(errno)); current_filename, strerror(errno));
return 0; return 0;
} }
if(me==0xF0 || me == 0xF7) /* SysEx event */ if(me==0xF0 || me == 0xF7) /* SysEx event */
{ {
int32 sret; int32 sret;
@ -340,9 +341,9 @@ static MidiEventList *read_midi_event(void)
case 0x51: /* Tempo */ case 0x51: /* Tempo */
SDL_RWread(rw,&a,1,1); SDL_RWread(rw,&b,1,1); SDL_RWread(rw,&c,1,1); SDL_RWread(rw,&a,1,1); SDL_RWread(rw,&b,1,1); SDL_RWread(rw,&c,1,1);
MIDIEVENT(at, ME_TEMPO, c, a, b); MIDIEVENT(at, ME_TEMPO, c, a, b);
default: default:
ctl->cmsg(CMSG_INFO, VERB_DEBUG, ctl->cmsg(CMSG_INFO, VERB_DEBUG,
"(Meta event type 0x%02x, length %ld)", type, len); "(Meta event type 0x%02x, length %ld)", type, len);
SDL_RWseek(rw, len, RW_SEEK_CUR); SDL_RWseek(rw, len, RW_SEEK_CUR);
break; break;
@ -414,7 +415,7 @@ static MidiEventList *read_midi_event(void)
case 101: nrpn=0; rpn_lsb[lastchan]=b; break; case 101: nrpn=0; rpn_lsb[lastchan]=b; break;
case 99: nrpn=1; rpn_msb[lastchan]=b; break; case 99: nrpn=1; rpn_msb[lastchan]=b; break;
case 98: nrpn=1; rpn_lsb[lastchan]=b; break; case 98: nrpn=1; rpn_lsb[lastchan]=b; break;
case 6: case 6:
if (nrpn) if (nrpn)
{ {
@ -455,13 +456,13 @@ static MidiEventList *read_midi_event(void)
*/ */
} }
ctl->cmsg(CMSG_INFO, VERB_DEBUG, ctl->cmsg(CMSG_INFO, VERB_DEBUG,
"(Data entry (MSB) for NRPN %02x,%02x: %ld)", "(Data entry (MSB) for NRPN %02x,%02x: %ld)",
rpn_msb[lastchan], rpn_lsb[lastchan], rpn_msb[lastchan], rpn_lsb[lastchan],
b); b);
break; break;
} }
switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan]) switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan])
{ {
case 0x0000: /* Pitch bend sensitivity */ case 0x0000: /* Pitch bend sensitivity */
@ -473,22 +474,22 @@ static MidiEventList *read_midi_event(void)
MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0); MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0);
default: default:
ctl->cmsg(CMSG_INFO, VERB_DEBUG, ctl->cmsg(CMSG_INFO, VERB_DEBUG,
"(Data entry (MSB) for RPN %02x,%02x: %ld)", "(Data entry (MSB) for RPN %02x,%02x: %ld)",
rpn_msb[lastchan], rpn_lsb[lastchan], rpn_msb[lastchan], rpn_lsb[lastchan],
b); b);
break; break;
} }
break; break;
default: default:
ctl->cmsg(CMSG_INFO, VERB_DEBUG, ctl->cmsg(CMSG_INFO, VERB_DEBUG,
"(Control %d: %d)", a, b); "(Control %d: %d)", a, b);
break; break;
} }
if (control != 255) if (control != 255)
{ {
MIDIEVENT(at, control, lastchan, b, 0); MIDIEVENT(at, control, lastchan, b, 0);
} }
} }
break; break;
@ -505,15 +506,15 @@ static MidiEventList *read_midi_event(void)
b &= 0x7F; b &= 0x7F;
MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b); MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b);
default: default:
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"*** Can't happen: status 0x%02X, channel 0x%02X", "*** Can't happen: status 0x%02X, channel 0x%02X",
laststatus, lastchan); laststatus, lastchan);
break; break;
} }
} }
} }
return new; return new;
} }
@ -574,7 +575,7 @@ static int read_track(int append)
meep=next; meep=next;
next=meep->next; next=meep->next;
} }
new->next=next; new->next=next;
meep->next=new; meep->next=new;
@ -720,7 +721,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
} }
if (current_set[meep->event.channel] != new_value) if (current_set[meep->event.channel] != new_value)
current_set[meep->event.channel]=new_value; current_set[meep->event.channel]=new_value;
else else
skip_this_event=1; skip_this_event=1;
} }
else else
@ -776,7 +777,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
if (mprog==SPECIAL_PROGRAM) if (mprog==SPECIAL_PROGRAM)
break; break;
if (XG_System_On && banknum==SFXBANK && !tonebank[SFXBANK] && tonebank[120]) if (XG_System_On && banknum==SFXBANK && !tonebank[SFXBANK] && tonebank[120])
banknum = 120; banknum = 120;
/*if (current_config_pc42b) pcmap(&banknum, &dnote, &mprog, &drumsflag);*/ /*if (current_config_pc42b) pcmap(&banknum, &dnote, &mprog, &drumsflag);*/
@ -812,7 +813,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
new_value=meep->event.a; new_value=meep->event.a;
if (current_kit[meep->event.channel] != new_value) if (current_kit[meep->event.channel] != new_value)
current_kit[meep->event.channel]=new_value; current_kit[meep->event.channel]=new_value;
else else
skip_this_event=1; skip_this_event=1;
break; break;
} }
@ -846,7 +847,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
} }
if (tonebank[SFXBANK] || tonebank[120]) /* Is this a defined tone bank? */ if (tonebank[SFXBANK] || tonebank[120]) /* Is this a defined tone bank? */
new_value=SFX_BANKTYPE; new_value=SFX_BANKTYPE;
else else
{ {
ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
"XG Sfx bank is undefined"); "XG Sfx bank is undefined");
@ -873,7 +874,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
} }
else if (tonebank[meep->event.a]) /* Is this a defined tone bank? */ else if (tonebank[meep->event.a]) /* Is this a defined tone bank? */
new_value=meep->event.a; new_value=meep->event.a;
else else
{ {
ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
"Tone bank %d is undefined", meep->event.a); "Tone bank %d is undefined", meep->event.a);
@ -924,7 +925,7 @@ static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp)
lp->type=ME_EOT; lp->type=ME_EOT;
our_event_count++; our_event_count++;
free_midi_list(); free_midi_list();
*eventsp=our_event_count; *eventsp=our_event_count;
*samplesp=st; *samplesp=st;
return groomed_list; return groomed_list;
@ -968,11 +969,11 @@ past_riff:
{ {
/* if (ferror(fp)) /* if (ferror(fp))
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", current_filename, ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", current_filename,
strerror(errno)); strerror(errno));
} }
else*/ else*/
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: Not a MIDI file!", current_filename); "%s: Not a MIDI file!", current_filename);
return 0; return 0;
} }
@ -1010,18 +1011,18 @@ past_riff:
if (len > 6) if (len > 6)
{ {
ctl->cmsg(CMSG_WARNING, VERB_NORMAL, ctl->cmsg(CMSG_WARNING, VERB_NORMAL,
"%s: MIDI file header size %ld bytes", "%s: MIDI file header size %ld bytes",
current_filename, len); current_filename, len);
SDL_RWseek(rw, len-6, RW_SEEK_CUR); /* skip the excess */ SDL_RWseek(rw, len-6, RW_SEEK_CUR); /* skip the excess */
} }
if (format<0 || format >2) if (format<0 || format >2)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: Unknown MIDI file format %d", current_filename, format); "%s: Unknown MIDI file format %d", current_filename, format);
return 0; return 0;
} }
ctl->cmsg(CMSG_INFO, VERB_VERBOSE, ctl->cmsg(CMSG_INFO, VERB_VERBOSE,
"Format: %d Tracks: %d Divisions: %d", format, tracks, divisions); "Format: %d Tracks: %d Divisions: %d", format, tracks, divisions);
/* Put a do-nothing event first in the list for easier processing */ /* Put a do-nothing event first in the list for easier processing */

View file

@ -6,8 +6,8 @@
it under the terms of the Perl Artistic License, available in COPYING. it under the terms of the Perl Artistic License, available in COPYING.
*/ */
#include "SDL.h"
#include "config.h" #include "config.h"
#include "SDL.h"
#include "common.h" #include "common.h"
#include "instrum.h" #include "instrum.h"
#include "playmidi.h" #include "playmidi.h"
@ -88,7 +88,7 @@ static int read_config_file(const char *name)
{ {
if (words != 2) if (words != 2)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: Must specify exactly one patch name\n", "%s: line %d: Must specify exactly one patch name\n",
name, line); name, line);
return -2; return -2;
@ -101,14 +101,14 @@ static int read_config_file(const char *name)
if (words < 2) if (words < 2)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: No drum set number given\n", "%s: line %d: No drum set number given\n",
name, line); name, line);
return -2; return -2;
} }
i=atoi(w[1]); i=atoi(w[1]);
if (i<0 || i>127) if (i<0 || i>127)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: Drum set must be between 0 and 127\n", "%s: line %d: Drum set must be between 0 and 127\n",
name, line); name, line);
return -2; return -2;
@ -125,14 +125,14 @@ static int read_config_file(const char *name)
if (words < 2) if (words < 2)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: No bank number given\n", "%s: line %d: No bank number given\n",
name, line); name, line);
return -2; return -2;
} }
i=atoi(w[1]); i=atoi(w[1]);
if (i<0 || i>127) if (i<0 || i>127)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: Tone bank must be between 0 and 127\n", "%s: line %d: Tone bank must be between 0 and 127\n",
name, line); name, line);
return -2; return -2;
@ -161,7 +161,7 @@ static int read_config_file(const char *name)
} }
if (!bank) if (!bank)
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: Must specify tone bank or drum set " "%s: line %d: Must specify tone bank or drum set "
"before assignment\n", "before assignment\n",
name, line); name, line);
@ -188,7 +188,7 @@ static int read_config_file(const char *name)
k=atoi(cp); k=atoi(cp);
if ((k<0 || k>MAX_AMPLIFICATION) || (*cp < '0' || *cp > '9')) if ((k<0 || k>MAX_AMPLIFICATION) || (*cp < '0' || *cp > '9'))
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: amplification must be between " "%s: line %d: amplification must be between "
"0 and %d\n", name, line, MAX_AMPLIFICATION); "0 and %d\n", name, line, MAX_AMPLIFICATION);
return -2; return -2;
@ -200,7 +200,7 @@ static int read_config_file(const char *name)
k=atoi(cp); k=atoi(cp);
if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) if ((k<0 || k>127) || (*cp < '0' || *cp > '9'))
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: note must be between 0 and 127\n", "%s: line %d: note must be between 0 and 127\n",
name, line); name, line);
return -2; return -2;
@ -220,7 +220,7 @@ static int read_config_file(const char *name)
if ((k<0 || k>127) || if ((k<0 || k>127) ||
(k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) (k==0 && *cp!='-' && (*cp < '0' || *cp > '9')))
{ {
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
"%s: line %d: panning must be left, right, " "%s: line %d: panning must be left, right, "
"center, or between -100 and 100\n", "center, or between -100 and 100\n",
name, line); name, line);
@ -302,7 +302,7 @@ int Timidity_Init(int rate, int format, int channels, int samples)
} }
if ( channels == 1 ) { if ( channels == 1 ) {
play_mode->encoding |= PE_MONO; play_mode->encoding |= PE_MONO;
} }
switch (format) { switch (format) {
case AUDIO_S8: case AUDIO_S8:
s32tobuf = s32tos8; s32tobuf = s32tos8;
@ -356,4 +356,3 @@ const char *Timidity_Error(void)
{ {
return(timidity_error); return(timidity_error);
} }

View file

@ -59,7 +59,7 @@ typedef struct WaveFMT {
Uint32 FMTchunk; Uint32 FMTchunk;
Uint32 fmtlen; Uint32 fmtlen;
*/ */
Uint16 encoding; Uint16 encoding;
Uint16 channels; /* 1 = mono, 2 = stereo */ Uint16 channels; /* 1 = mono, 2 = stereo */
Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
Uint32 byterate; /* Average bytes per second */ Uint32 byterate; /* Average bytes per second */
@ -213,11 +213,11 @@ int WAVStream_PlaySome(Uint8 *stream, int len)
} }
data = SDL_stack_alloc(Uint8, len); data = SDL_stack_alloc(Uint8, len);
if (data) if (data)
{ {
SDL_RWread(music->rw, data, len, 1); SDL_RWread(music->rw, data, len, 1);
SDL_MixAudio(stream, data, len, wavestream_volume); SDL_MixAudio(stream, data, len, wavestream_volume);
SDL_stack_free(data); SDL_stack_free(data);
} }
} }
} }
return left; return left;
@ -286,7 +286,7 @@ static SDL_RWops *LoadWAVStream (SDL_RWops *src, SDL_AudioSpec *spec,
/* WAV magic header */ /* WAV magic header */
Uint32 RIFFchunk; Uint32 RIFFchunk;
Uint32 wavelen; // Uint32 wavelen;
Uint32 WAVEmagic; Uint32 WAVEmagic;
/* FMT chunk */ /* FMT chunk */
@ -296,7 +296,7 @@ static SDL_RWops *LoadWAVStream (SDL_RWops *src, SDL_AudioSpec *spec,
/* Check the magic header */ /* Check the magic header */
RIFFchunk = SDL_ReadLE32(src); RIFFchunk = SDL_ReadLE32(src);
wavelen = SDL_ReadLE32(src); // wavelen = SDL_ReadLE32(src);
WAVEmagic = SDL_ReadLE32(src); WAVEmagic = SDL_ReadLE32(src);
if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) { if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) {
Mix_SetError("Unrecognized file type (not WAVE)"); Mix_SetError("Unrecognized file type (not WAVE)");
@ -416,7 +416,7 @@ static SDL_RWops *LoadAIFFStream (SDL_RWops *src, SDL_AudioSpec *spec,
Uint32 AIFFmagic; Uint32 AIFFmagic;
/* SSND chunk */ /* SSND chunk */
Uint32 offset; Uint32 offset;
Uint32 blocksize; // Uint32 blocksize;
/* COMM format chunk */ /* COMM format chunk */
Uint16 channels = 0; Uint16 channels = 0;
Uint32 numsamples = 0; Uint32 numsamples = 0;
@ -459,7 +459,7 @@ static SDL_RWops *LoadAIFFStream (SDL_RWops *src, SDL_AudioSpec *spec,
case SSND: case SSND:
found_SSND = 1; found_SSND = 1;
offset = SDL_ReadBE32(src); offset = SDL_ReadBE32(src);
blocksize = SDL_ReadBE32(src); // blocksize = SDL_ReadBE32(src);
*start = SDL_RWtell(src) + offset; *start = SDL_RWtell(src) + offset;
break; break;
@ -485,7 +485,7 @@ static SDL_RWops *LoadAIFFStream (SDL_RWops *src, SDL_AudioSpec *spec,
was_error = 1; was_error = 1;
goto done; goto done;
} }
if (!found_COMM) { if (!found_COMM) {
Mix_SetError("Bad AIFF file (no COMM chunk)"); Mix_SetError("Bad AIFF file (no COMM chunk)");
was_error = 1; was_error = 1;
@ -518,4 +518,3 @@ done:
} }
return(src); return(src);
} }

View file

@ -92,6 +92,9 @@
#undef strdup #undef strdup
/* clock() wraps current_tick */ /* clock() wraps current_tick */
#ifdef CLOCKS_PER_SEC
#undef CLOCKS_PER_SEC
#endif
#define CLOCKS_PER_SEC HZ #define CLOCKS_PER_SEC HZ
/* /*
@ -160,9 +163,13 @@
#define strlcpy rb->strlcpy #define strlcpy rb->strlcpy
#define strlen rb->strlen #define strlen rb->strlen
#define strncasecmp rb->strncasecmp #define strncasecmp rb->strncasecmp
#ifndef strncat
#define strncat rb->strlcat /* hack */ #define strncat rb->strlcat /* hack */
#endif
#define strncmp rb->strncmp #define strncmp rb->strncmp
#ifndef strncat
#define strpbrk strpbrk_wrapper #define strpbrk strpbrk_wrapper
#endif
#define strrchr rb->strrchr #define strrchr rb->strrchr
#define strstr SDL_strstr #define strstr SDL_strstr
#define strtok strtok_wrapper #define strtok strtok_wrapper

View file

@ -71,8 +71,8 @@ void cleanup(void)
#endif #endif
} }
/* 256KB */ static long main_stack[1024 * 1024 / 4]; /* ie 1 MB */
static long main_stack[1024 * 1024 / 2];
int (*main_fn)(int argc, char *argv[]); int (*main_fn)(int argc, char *argv[]);
int prog_idx; int prog_idx;
static void main_thread(void) static void main_thread(void)

View file

@ -244,7 +244,7 @@ static void init_new_res_vars(int32_t davidoption)
qsetmode = surface->h; qsetmode = surface->h;
activepage = visualpage = 0; activepage = visualpage = 0;
frameoffset = frameplace = (uint8_t*)surface->pixels; frameoffset = frameplace = (uint8_t*)surface->pixels;
if (screen != NULL) if (screen != NULL)
@ -259,7 +259,7 @@ static void init_new_res_vars(int32_t davidoption)
{ {
case 1:i = xdim*ydim; break; case 1:i = xdim*ydim; break;
case 2: xdim = 320; ydim = 200; i = xdim*ydim; break; case 2: xdim = 320; ydim = 200; i = xdim*ydim; break;
default: assert(0); default: assert(0);
} }
j = ydim*4*sizeof(int32_t); /* Leave room for horizlookup&horizlookup2 */ j = ydim*4*sizeof(int32_t); /* Leave room for horizlookup&horizlookup2 */
@ -269,13 +269,13 @@ static void init_new_res_vars(int32_t davidoption)
if(horizlookup2) if(horizlookup2)
free(horizlookup2); free(horizlookup2);
horizlookup = (int32_t*)malloc(j); horizlookup = (int32_t*)malloc(j);
horizlookup2 = (int32_t*)malloc(j); horizlookup2 = (int32_t*)malloc(j);
j = 0; j = 0;
//Build lookup table (X screespace -> frambuffer offset. //Build lookup table (X screespace -> frambuffer offset.
for(i = 0; i <= ydim; i++) for(i = 0; i <= ydim; i++)
{ {
ylookup[i] = j; ylookup[i] = j;
@ -290,16 +290,16 @@ static void init_new_res_vars(int32_t davidoption)
//Let the Assembly module how many pixels to skip when drawing a column //Let the Assembly module how many pixels to skip when drawing a column
setBytesPerLine(bytesperline); setBytesPerLine(bytesperline);
setview(0L,0L,xdim-1,ydim-1); setview(0L,0L,xdim-1,ydim-1);
setbrightness(curbrightness, palette); setbrightness(curbrightness, palette);
if (searchx < 0) { if (searchx < 0) {
searchx = halfxdimen; searchx = halfxdimen;
searchy = (ydimen>>1); searchy = (ydimen>>1);
} }
} }
@ -370,17 +370,17 @@ static int sdl_mouse_motion_filter(SDL_Event const *event)
} }
else else
{ {
if (SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_ON) if (SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_ON)
{ {
mouse_relative_x += event->motion.xrel; mouse_relative_x += event->motion.xrel;
mouse_relative_y += event->motion.yrel; mouse_relative_y += event->motion.yrel;
//printf("sdl_mouse_motion_filter: mrx=%d, mry=%d, mx=%d, my=%d\n", //printf("sdl_mouse_motion_filter: mrx=%d, mry=%d, mx=%d, my=%d\n",
// mouse_relative_x, mouse_relative_y, event->motion.xrel, event->motion.yrel); // mouse_relative_x, mouse_relative_y, event->motion.xrel, event->motion.yrel);
// mouse_relative_* is already reset in // mouse_relative_* is already reset in
// readmousexy(). It must not be // readmousexy(). It must not be
// reset here because calling this function does not mean // reset here because calling this function does not mean
// we always handle the mouse. // we always handle the mouse.
// FIX_00001: Mouse speed is uneven and slower in windowed mode vs fullscreen mode. // FIX_00001: Mouse speed is uneven and slower in windowed mode vs fullscreen mode.
} }
else else
@ -431,12 +431,12 @@ static __inline int handle_keypad_enter_hack(const SDL_Event *event)
void fullscreen_toggle_and_change_driver(void) void fullscreen_toggle_and_change_driver(void)
{ {
// FIX_00002: New Toggle Windowed/FullScreen system now simpler and will // FIX_00002: New Toggle Windowed/FullScreen system now simpler and will
// dynamically change for Windib or Directx driver. Windowed/Fullscreen // dynamically change for Windib or Directx driver. Windowed/Fullscreen
// toggle also made available from menu. // toggle also made available from menu.
// Replace attempt_fullscreen_toggle(SDL_Surface **surface, Uint32 *flags) // Replace attempt_fullscreen_toggle(SDL_Surface **surface, Uint32 *flags)
int32_t x,y; int32_t x,y;
x = surface->w; x = surface->w;
y = surface->h; y = surface->h;
@ -462,8 +462,8 @@ static int sdl_key_filter(const SDL_Event *event)
// FIX_00005: Mouse pointer can be toggled on/off (see mouse menu or use CTRL-M) // FIX_00005: Mouse pointer can be toggled on/off (see mouse menu or use CTRL-M)
// This is usefull to move the duke window when playing in window mode. // This is usefull to move the duke window when playing in window mode.
if (SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_ON) if (SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_ON)
{ {
SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(1); SDL_ShowCursor(1);
@ -491,9 +491,9 @@ static int sdl_key_filter(const SDL_Event *event)
lastkey=(scancodes[SDLK_LALT]&0xff)+0x80; // Simulating Key up (not extended) lastkey=(scancodes[SDLK_LALT]&0xff)+0x80; // Simulating Key up (not extended)
keyhandler(); keyhandler();
SDL_SetModState(KMOD_NONE); // SDL doesnt see we are releasing the ALT-ENTER keys SDL_SetModState(KMOD_NONE); // SDL doesnt see we are releasing the ALT-ENTER keys
return(0); return(0);
} }
if (!handle_keypad_enter_hack(event)) if (!handle_keypad_enter_hack(event))
lastkey = scancodes[event->key.keysym.sym]; lastkey = scancodes[event->key.keysym.sym];
@ -546,7 +546,7 @@ static int root_sdl_event_filter(const SDL_Event *event)
return(sdl_mouse_button_filter((const SDL_MouseButtonEvent*)event)); return(sdl_mouse_button_filter((const SDL_MouseButtonEvent*)event));
case SDL_QUIT: case SDL_QUIT:
/* !!! rcg TEMP */ /* !!! rcg TEMP */
Error(EXIT_SUCCESS, "Exit through SDL\n"); Error(EXIT_SUCCESS, "Exit through SDL\n");
default: default:
//printf("This event is not handled: %d\n",event->type); //printf("This event is not handled: %d\n",event->type);
break; break;
@ -662,7 +662,7 @@ int _joystick_update(void)
int _joystick_axis(int axis) int _joystick_axis(int axis)
{ {
if (joystick == NULL) if (joystick == NULL)
{ {
return(0); return(0);
} }
@ -672,7 +672,7 @@ int _joystick_axis(int axis)
int _joystick_hat(int hat) int _joystick_hat(int hat)
{ {
if (joystick == NULL) if (joystick == NULL)
{ {
return(-1); return(-1);
} }
@ -753,28 +753,28 @@ void _platform_init(int argc, char **argv, const char *title, const char *ico
//TODO: //TODO:
//TODO ( "[Todo: handle -netmode <int>]" ) //TODO ( "[Todo: handle -netmode <int>]" )
Setup_StableNetworking(); Setup_StableNetworking();
} }
} }
} }
if (SDL_Init(SDL_INIT_VIDEO) == -1){ if (SDL_Init(SDL_INIT_VIDEO) == -1){
Error(EXIT_FAILURE, "BUILDSDL: SDL_Init() failed!\nBUILDSDL: SDL_GetError() says \"%s\".\n", SDL_GetError()); Error(EXIT_FAILURE, "BUILDSDL: SDL_Init() failed!\nBUILDSDL: SDL_GetError() says \"%s\".\n", SDL_GetError());
} }
// Set up the correct renderer // Set up the correct renderer
// Becarfull setenv can't reach dll in VC++ // Becarfull setenv can't reach dll in VC++
// A way to proceed is to integrate the SDL libs // A way to proceed is to integrate the SDL libs
// in the exe instead. // in the exe instead.
// FIX_00004: SDL.dll and SDL_Mixer.dll are now integrated within the exe // FIX_00004: SDL.dll and SDL_Mixer.dll are now integrated within the exe
// (this also makes the Windib/Directx driver switching easier with SDL) // (this also makes the Windib/Directx driver switching easier with SDL)
// This requires to recompile the whole sdl and sdl mixer with the lib // This requires to recompile the whole sdl and sdl mixer with the lib
// switch instead of the default dll switch. // switch instead of the default dll switch.
putenv("SDL_VIDEO_CENTERED=1"); putenv("SDL_VIDEO_CENTERED=1");
if (title == NULL) if (title == NULL)
@ -895,12 +895,12 @@ void _platform_init(int argc, char **argv, const char *title, const char *ico
scancodes[SDLK_PAGEDOWN] = 0xE051; scancodes[SDLK_PAGEDOWN] = 0xE051;
scancodes[SDLK_INSERT] = 0xE052; scancodes[SDLK_INSERT] = 0xE052;
scancodes[SDLK_DELETE] = 0xE053; scancodes[SDLK_DELETE] = 0xE053;
output_sdl_versions(); output_sdl_versions();
output_driver_info(); output_driver_info();
printf("Video Driver: '%s'.\n", SDL_VideoDriverName(dummyString, 20)); printf("Video Driver: '%s'.\n", SDL_VideoDriverName(dummyString, 20));
@ -909,11 +909,11 @@ void _platform_init(int argc, char **argv, const char *title, const char *ico
// Capture BMP of the current frame // Capture BMP of the current frame
int screencapture(char *filename, uint8_t inverseit) int screencapture(char *filename, uint8_t inverseit)
{ {
// FIX_00006: better naming system for screenshots + message when pic is taken. // FIX_00006: better naming system for screenshots + message when pic is taken.
// Use ./screenshots folder. Screenshot code rerwritten. Faster and // Use ./screenshots folder. Screenshot code rerwritten. Faster and
// makes smaller files. Doesn't freeze or lag the game anymore. // makes smaller files. Doesn't freeze or lag the game anymore.
SDL_SaveBMP(surface, filename); SDL_SaveBMP(surface, filename);
return 0; return 0;
} /* screencapture */ } /* screencapture */
@ -928,7 +928,7 @@ void setvmode(int mode)
} else } else
printf("setvmode(0x%x) is unsupported in SDL driver.\n", mode); printf("setvmode(0x%x) is unsupported in SDL driver.\n", mode);
} }
int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim) int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim)
{ {
@ -941,13 +941,13 @@ int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim)
colorkey = 0; // index in this image to be transparent colorkey = 0; // index in this image to be transparent
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey); SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
SDL_WM_SetIcon(image,NULL); SDL_WM_SetIcon(image,NULL);
if (daxdim > MAXXDIM || daydim > MAXYDIM) if (daxdim > MAXXDIM || daydim > MAXYDIM)
{ {
printf("Resolution %dx%d is too high. Changed to %dx%d\n", daxdim, daydim, MAXXDIM,MAXYDIM); printf("Resolution %dx%d is too high. Changed to %dx%d\n", daxdim, daydim, MAXXDIM,MAXYDIM);
daxdim = MAXXDIM; daxdim = MAXXDIM;
daydim = MAXYDIM; daydim = MAXYDIM;
} }
getvalidvesamodes(); getvalidvesamodes();
@ -1052,8 +1052,8 @@ static __inline void add_user_defined_resolution(void)
/* rockbox hack */ /* rockbox hack */
add_vesa_mode("rockbox", LCD_WIDTH, LCD_HEIGHT); add_vesa_mode("rockbox", LCD_WIDTH, LCD_HEIGHT);
add_vesa_mode("rockbox", LCD_HEIGHT, LCD_WIDTH); add_vesa_mode("rockbox", LCD_HEIGHT, LCD_WIDTH);
if (envr == NULL) if (envr == NULL)
return; return;
@ -1111,7 +1111,7 @@ static __inline void cull_large_vesa_modes(void)
int32_t max_w; int32_t max_w;
int32_t max_h; int32_t max_h;
int i; int i;
get_max_screen_res(&max_w, &max_h); get_max_screen_res(&max_w, &max_h);
printf("Setting resolution ceiling to (%dx%d).\n", max_w, max_h); printf("Setting resolution ceiling to (%dx%d).\n", max_w, max_h);
@ -1139,7 +1139,7 @@ static __inline void cull_duplicate_vesa_modes(void)
} }
} }
} }
} }
#define swap_macro(tmp, x, y) { tmp = x; x = y; y = tmp; } #define swap_macro(tmp, x, y) { tmp = x; x = y; y = tmp; }
@ -1196,7 +1196,7 @@ static __inline void output_vesa_modelist(void)
} /* for */ } /* for */
printf("Final sorted modelist:%s", buffer); printf("Final sorted modelist:%s", buffer);
} }
void getvalidvesamodes(void) void getvalidvesamodes(void)
@ -1233,37 +1233,37 @@ void getvalidvesamodes(void)
/* print it out for debugging purposes... */ /* print it out for debugging purposes... */
output_vesa_modelist(); output_vesa_modelist();
} }
uint8_t lastPalette[768]; uint8_t lastPalette[768];
void WriteTranslucToFile(void){ void WriteTranslucToFile(void){
uint8_t buffer[65535*4]; uint8_t buffer[65535*4];
uint8_t tga_header[18]; uint8_t tga_header[18];
uint8_t* transPointer = transluc; uint8_t* transPointer = transluc;
uint8_t* bufferPointer = buffer; uint8_t* bufferPointer = buffer;
int i; int i;
FILE* file; FILE* file;
for (i=0; i < 65535; i++) { for (i=0; i < 65535; i++) {
bufferPointer[0] = (lastPalette[(*transPointer)*3+0]) / 63.0 * 255; bufferPointer[0] = (lastPalette[(*transPointer)*3+0]) / 63.0 * 255;
bufferPointer[1] = (lastPalette[(*transPointer)*3+1]) / 63.0 * 255; bufferPointer[1] = (lastPalette[(*transPointer)*3+1]) / 63.0 * 255;
bufferPointer[2] = (lastPalette[(*transPointer)*3+2]) / 63.0 * 255; bufferPointer[2] = (lastPalette[(*transPointer)*3+2]) / 63.0 * 255;
bufferPointer[3] = 255; bufferPointer[3] = 255;
printf("%d,",*transPointer); printf("%d,",*transPointer);
if (i%255 ==0) if (i%255 ==0)
printf("\n"); printf("\n");
transPointer +=1; transPointer +=1;
bufferPointer+=4; bufferPointer+=4;
} }
file = fopen("/transluc.tga", "w"); file = fopen("/transluc.tga", "w");
memset(tga_header, 0, 18); memset(tga_header, 0, 18);
tga_header[2] = 2; tga_header[2] = 2;
tga_header[12] = (256 & 0x00FF); tga_header[12] = (256 & 0x00FF);
@ -1271,23 +1271,23 @@ void WriteTranslucToFile(void){
tga_header[14] = (256 & 0x00FF) ; tga_header[14] = (256 & 0x00FF) ;
tga_header[15] =(256 & 0xFF00) / 256; tga_header[15] =(256 & 0xFF00) / 256;
tga_header[16] = 32 ; tga_header[16] = 32 ;
fwrite(&tga_header, 18, sizeof(uint8_t), file); fwrite(&tga_header, 18, sizeof(uint8_t), file);
fwrite(buffer, 65535, 4, file); fwrite(buffer, 65535, 4, file);
fclose(file); fclose(file);
} }
void WritePaletteToFile(uint8_t* palette,const char* filename,int width, int height){ void WritePaletteToFile(uint8_t* palette,const char* filename,int width, int height){
uint8_t tga_header[18]; uint8_t tga_header[18];
uint8_t* buffer; uint8_t* buffer;
uint8_t* palettePointer = palette; uint8_t* palettePointer = palette;
uint8_t* bufferPointer ; uint8_t* bufferPointer ;
int i; int i;
FILE* file = fopen(filename, "w"); FILE* file = fopen(filename, "w");
memset(tga_header, 0, 18); memset(tga_header, 0, 18);
tga_header[2] = 2; tga_header[2] = 2;
tga_header[12] = (width & 0x00FF); tga_header[12] = (width & 0x00FF);
@ -1295,30 +1295,30 @@ void WritePaletteToFile(uint8_t* palette,const char* filename,int width, int hei
tga_header[14] = (height & 0x00FF) ; tga_header[14] = (height & 0x00FF) ;
tga_header[15] =(height & 0xFF00) / 256; tga_header[15] =(height & 0xFF00) / 256;
tga_header[16] = 32 ; tga_header[16] = 32 ;
fwrite(&tga_header, 18, sizeof(uint8_t), file); fwrite(&tga_header, 18, sizeof(uint8_t), file);
bufferPointer = buffer = malloc(width*height*4); bufferPointer = buffer = malloc(width*height*4);
for (i = 0 ; i < width*height ; i++) for (i = 0 ; i < width*height ; i++)
{ {
bufferPointer[0] = palettePointer[0] / 63.0 * 255; bufferPointer[0] = palettePointer[0] / 63.0 * 255;
bufferPointer[1] = palettePointer[1] / 63.0 * 255; bufferPointer[1] = palettePointer[1] / 63.0 * 255;
bufferPointer[2] = palettePointer[2] / 63.0 * 255; bufferPointer[2] = palettePointer[2] / 63.0 * 255;
bufferPointer[3] = 255; bufferPointer[3] = 255;
bufferPointer += 4; bufferPointer += 4;
palettePointer+= 3; palettePointer+= 3;
} }
fwrite(buffer, width*height, 4, file); fwrite(buffer, width*height, 4, file);
fclose(file); fclose(file);
free(buffer); free(buffer);
} }
void WriteLastPaletteToFile(){ void WriteLastPaletteToFile(void){
WritePaletteToFile(lastPalette,"lastPalette.tga",16,16); WritePaletteToFile(lastPalette,"lastPalette.tga",16,16);
} }
@ -1342,18 +1342,18 @@ int VBE_setPalette(uint8_t *palettebuffer)
uint8_t *p = palettebuffer; uint8_t *p = palettebuffer;
int i; int i;
//static updated=0; //static updated=0;
//if (updated >=1 ) //if (updated >=1 )
// return ; // return ;
//WritePaletteToFile(palettebuffer,"lastPalette.tga",16,16); //WritePaletteToFile(palettebuffer,"lastPalette.tga",16,16);
//updated++; //updated++;
//CODE EXPLORATION //CODE EXPLORATION
//Used only to write the last palette to file. //Used only to write the last palette to file.
memcpy(lastPalette, palettebuffer, 768); memcpy(lastPalette, palettebuffer, 768);
for (i = 0; i < 256; i++){ for (i = 0; i < 256; i++){
/* doesn't map perfectly */ /* doesn't map perfectly */
sdlp->b = (Uint8) (*p << 2) | (*p >> 4); sdlp->b = (Uint8) (*p << 2) | (*p >> 4);
@ -1383,10 +1383,10 @@ int VBE_getPalette(int32_t start, int32_t num, uint8_t *palettebuffer)
*p++ = (Uint8) ((((float) sdlp->r) / 255.0) * 63.0); *p++ = (Uint8) ((((float) sdlp->r) / 255.0) * 63.0);
*p++ = sdlp->unused; /* This byte is unused in both SDL and BUILD. */ *p++ = sdlp->unused; /* This byte is unused in both SDL and BUILD. */
sdlp++; sdlp++;
} }
return(1); return(1);
} }
void _uninitengine(void) void _uninitengine(void)
@ -1464,13 +1464,13 @@ void _nextpage(void)
_handle_events(); _handle_events();
SDL_UpdateRect(surface, 0, 0, 0, 0); SDL_UpdateRect(surface, 0, 0, 0, 0);
//sprintf(bmpName,"%d.bmp",counter++); //sprintf(bmpName,"%d.bmp",counter++);
//SDL_SaveBMP(surface,bmpName); //SDL_SaveBMP(surface,bmpName);
//if (CLEAR_FRAMEBUFFER) //if (CLEAR_FRAMEBUFFER)
// SDL_FillRect(surface,NULL,0); // SDL_FillRect(surface,NULL,0);
@ -1480,15 +1480,15 @@ void _nextpage(void)
total_rendered_frames = 0; total_rendered_frames = 0;
total_render_time = 1; total_render_time = 1;
last_render_ticks = ticks; last_render_ticks = ticks;
} }
total_rendered_frames++; total_rendered_frames++;
} }
uint8_t readpixel(uint8_t * offset) uint8_t readpixel(uint8_t * offset)
{ {
return *offset; return *offset;
} }
void drawpixel(uint8_t * location, uint8_t pixel) void drawpixel(uint8_t * location, uint8_t pixel)
{ {
@ -1519,7 +1519,7 @@ void fillscreen16(int32_t offset, int32_t color, int32_t blocksize)
pixels = get_framebuffer(); pixels = get_framebuffer();
/* Make this function pageoffset aware - DDOI */ /* Make this function pageoffset aware - DDOI */
if (!pageoffset) { if (!pageoffset) {
offset = offset << 3; offset = offset << 3;
offset += 640*336; offset += 640*336;
} }
@ -1584,7 +1584,7 @@ void drawline16(int32_t XStart, int32_t YStart, int32_t XEnd, int32_t YEnd, uint
dx = XEnd-XStart; dx = XEnd-XStart;
dy = YEnd-YStart; dy = YEnd-YStart;
//Analyse the slope //Analyse the slope
if (dx >= 0) if (dx >= 0)
{ {
@ -1803,7 +1803,7 @@ void (*installusertimercallback(void (*callback)(void)))(void)
inittimer() -- initialise timer inittimer() -- initialise timer
FCS: The tickspersecond parameter is a ratio value that helps replicating FCS: The tickspersecond parameter is a ratio value that helps replicating
oldschool DOS tick per seconds. oldschool DOS tick per seconds.
The way the timer work is: The way the timer work is:
float newSystemTickPerSecond = [0,1] float newSystemTickPerSecond = [0,1]
tickPerSecond on a DOS system = tickspersecond * newSystemTickPerSecond ; tickPerSecond on a DOS system = tickspersecond * newSystemTickPerSecond ;
@ -1812,8 +1812,8 @@ void (*installusertimercallback(void (*callback)(void)))(void)
int inittimer(int tickspersecond) int inittimer(int tickspersecond)
{ {
int64_t t; int64_t t;
if (timerfreq) return 0; // already installed if (timerfreq) return 0; // already installed
//printf("Initialising timer, with tickPerSecond=%d\n",tickspersecond); //printf("Initialising timer, with tickPerSecond=%d\n",tickspersecond);
@ -1831,7 +1831,7 @@ int inittimer(int tickspersecond)
timerlastsample = (int32_t)(t*timerticspersec / timerfreq); timerlastsample = (int32_t)(t*timerticspersec / timerfreq);
usertimercallback = NULL; usertimercallback = NULL;
return 0; return 0;
} }
@ -1853,12 +1853,12 @@ void sampletimer(void)
{ {
int64_t i; int64_t i;
int32_t n; int32_t n;
if (!timerfreq) return; if (!timerfreq) return;
TIMER_GetPlatformTicks(&i); TIMER_GetPlatformTicks(&i);
n = (int32_t)(i*timerticspersec / timerfreq) - timerlastsample; n = (int32_t)(i*timerticspersec / timerfreq) - timerlastsample;
if (n>0) { if (n>0) {
totalclock += n; totalclock += n;
@ -1907,10 +1907,9 @@ int TIMER_GetPlatformTicksInOneSecond(int64_t* t)
*t = 1000; *t = 1000;
return 1; return 1;
} }
void TIMER_GetPlatformTicks(int64_t* t) void TIMER_GetPlatformTicks(int64_t* t)
{ {
*t = SDL_GetTicks(); *t = SDL_GetTicks();
} }
/* end of sdl_driver.c ... */ /* end of sdl_driver.c ... */

View file

@ -96,7 +96,7 @@ void timerhandler(void);
/* resolution inits. sdl_driver.c ... */ /* resolution inits. sdl_driver.c ... */
int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim); int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim);
uint32_t getticks(); uint32_t getticks(void);
void drawline16(int32_t XStart, int32_t YStart, int32_t XEnd, int32_t YEnd, uint8_t Color); void drawline16(int32_t XStart, int32_t YStart, int32_t XEnd, int32_t YEnd, uint8_t Color);
void setcolor16(uint8_t color); void setcolor16(uint8_t color);
@ -106,5 +106,3 @@ void setcolor16(uint8_t color);
void initmultiplayers(uint8_t damultioption, uint8_t dacomrateoption, uint8_t dapriority); void initmultiplayers(uint8_t damultioption, uint8_t dacomrateoption, uint8_t dapriority);
#endif #endif

View file

@ -11,8 +11,8 @@
#include "platform.h" #include "platform.h"
void Setup_UnstableNetworking(); void Setup_UnstableNetworking(void);
void Setup_StableNetworking(); void Setup_StableNetworking(void);
void callcommit(void); void callcommit(void);
void initcrc(void); void initcrc(void);

View file

@ -56,8 +56,12 @@
#define IP_RECVERR SO_BROADCAST #define IP_RECVERR SO_BROADCAST
*/ */
#ifndef stricmp
#define stricmp strcasecmp #define stricmp strcasecmp
#endif
#ifndef strcmpi
#define strcmpi strcasecmp #define strcmpi strcasecmp
#endif
#define S_IREAD S_IRUSR #define S_IREAD S_IRUSR

View file

@ -17,7 +17,7 @@ static int FB_SRC_A, FB_SRC_B, IIR_DEST_A0, IIR_DEST_A1, ACC_SRC_A0, ACC_SRC_A1,
ACC_SRC_B1, IIR_SRC_A0, IIR_SRC_A1, IIR_DEST_B0, IIR_DEST_B1, ACC_SRC_C0, ACC_SRC_B1, IIR_SRC_A0, IIR_SRC_A1, IIR_DEST_B0, IIR_DEST_B1, ACC_SRC_C0,
ACC_SRC_C1, ACC_SRC_D0, ACC_SRC_D1, IIR_SRC_B1, IIR_SRC_B0, MIX_DEST_A0, ACC_SRC_C1, ACC_SRC_D0, ACC_SRC_D1, IIR_SRC_B1, IIR_SRC_B0, MIX_DEST_A0,
MIX_DEST_A1, MIX_DEST_B0, MIX_DEST_B1; MIX_DEST_A1, MIX_DEST_B0, MIX_DEST_B1;
//static long IIR_ALPHA, ACC_COEF_A, ACC_COEF_B, ACC_COEF_C, ACC_COEF_D, IIR_COEF, FB_ALPHA, FB_X, //static long IIR_ALPHA, ACC_COEF_A, ACC_COEF_B, ACC_COEF_C, ACC_COEF_D, IIR_COEF, FB_ALPHA, FB_X,
// IN_COEF_L, IN_COEF_R; // IN_COEF_L, IN_COEF_R;
@ -51,7 +51,7 @@ static inline int cnv_offset(int src)
// extern __stdcall OutputDebugStringA(char *); // extern __stdcall OutputDebugStringA(char *);
static inline void check_buffer() static inline void check_buffer(void)
{ {
int new_delay = cnv_offset(MV_ReverbDelay); int new_delay = cnv_offset(MV_ReverbDelay);
@ -99,7 +99,7 @@ static inline long g_buffer(int iOff, long *ptr) // get
} }
iOff=(iOff*4)+CurrAddr; iOff=(iOff*4)+CurrAddr;
while(iOff>correctDelay-1) while(iOff>correctDelay-1)
{ {
iOff=iOff-correctDelay; iOff=iOff-correctDelay;
} }
@ -141,11 +141,11 @@ static inline void s_buffer1(int iOff,long iVal, long *ptr) // se
} }
iOff=(iOff*4)+CurrAddr+1; iOff=(iOff*4)+CurrAddr+1;
while(iOff>correctDelay-1) while(iOff>correctDelay-1)
{ {
iOff=iOff-correctDelay; iOff=iOff-correctDelay;
} }
while(iOff<0) while(iOff<0)
{ {
iOff=correctDelay-(0-iOff); iOff=correctDelay-(0-iOff);
} }
@ -155,12 +155,12 @@ static inline void s_buffer1(int iOff,long iVal, long *ptr) // se
static inline long MixREVERBLeft(long INPUT_SAMPLE_L, long INPUT_SAMPLE_R, long *ptr) static inline long MixREVERBLeft(long INPUT_SAMPLE_L, long INPUT_SAMPLE_R, long *ptr)
{ {
long ACC0,ACC1,FB_A0,FB_A1,FB_B0,FB_B1; long ACC0,ACC1,FB_A0,FB_A1,FB_B0,FB_B1;
const long IIR_INPUT_A0 = (fp_mul(g_buffer(IIR_SRC_A0, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_L, IN_COEF_L, FRACBITS)); const long IIR_INPUT_A0 = (fp_mul(g_buffer(IIR_SRC_A0, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_L, IN_COEF_L, FRACBITS));
const long IIR_INPUT_A1 = (fp_mul(g_buffer(IIR_SRC_A1, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_R, IN_COEF_R, FRACBITS)); const long IIR_INPUT_A1 = (fp_mul(g_buffer(IIR_SRC_A1, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_R, IN_COEF_R, FRACBITS));
const long IIR_INPUT_B0 = (fp_mul(g_buffer(IIR_SRC_B0, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_L, IN_COEF_L, FRACBITS)); const long IIR_INPUT_B0 = (fp_mul(g_buffer(IIR_SRC_B0, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_L, IN_COEF_L, FRACBITS));
const long IIR_INPUT_B1 = (fp_mul(g_buffer(IIR_SRC_B1, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_R, IN_COEF_R, FRACBITS)); const long IIR_INPUT_B1 = (fp_mul(g_buffer(IIR_SRC_B1, ptr), IIR_COEF, FRACBITS) + fp_mul(INPUT_SAMPLE_R, IN_COEF_R, FRACBITS));
const long one = (1 << FRACBITS); const long one = (1 << FRACBITS);
const long IIR_A0 = fp_mul(IIR_INPUT_A0, IIR_ALPHA, FRACBITS) + fp_mul(g_buffer(IIR_DEST_A0, ptr), (one - IIR_ALPHA), FRACBITS); const long IIR_A0 = fp_mul(IIR_INPUT_A0, IIR_ALPHA, FRACBITS) + fp_mul(g_buffer(IIR_DEST_A0, ptr), (one - IIR_ALPHA), FRACBITS);
const long IIR_A1 = fp_mul(IIR_INPUT_A1, IIR_ALPHA, FRACBITS) + fp_mul(g_buffer(IIR_DEST_A1, ptr), (one - IIR_ALPHA), FRACBITS); const long IIR_A1 = fp_mul(IIR_INPUT_A1, IIR_ALPHA, FRACBITS) + fp_mul(g_buffer(IIR_DEST_A1, ptr), (one - IIR_ALPHA), FRACBITS);
@ -171,7 +171,7 @@ static inline long MixREVERBLeft(long INPUT_SAMPLE_L, long INPUT_SAMPLE_R, long
s_buffer1(IIR_DEST_A1, IIR_A1, ptr); s_buffer1(IIR_DEST_A1, IIR_A1, ptr);
s_buffer1(IIR_DEST_B0, IIR_B0, ptr); s_buffer1(IIR_DEST_B0, IIR_B0, ptr);
s_buffer1(IIR_DEST_B1, IIR_B1, ptr); s_buffer1(IIR_DEST_B1, IIR_B1, ptr);
ACC0 = (fp_mul(g_buffer(ACC_SRC_A0, ptr), ACC_COEF_A, FRACBITS) + ACC0 = (fp_mul(g_buffer(ACC_SRC_A0, ptr), ACC_COEF_A, FRACBITS) +
fp_mul(g_buffer(ACC_SRC_B0, ptr), ACC_COEF_B, FRACBITS) + fp_mul(g_buffer(ACC_SRC_B0, ptr), ACC_COEF_B, FRACBITS) +
fp_mul(g_buffer(ACC_SRC_C0, ptr), ACC_COEF_C, FRACBITS) + fp_mul(g_buffer(ACC_SRC_C0, ptr), ACC_COEF_C, FRACBITS) +
@ -180,24 +180,24 @@ static inline long MixREVERBLeft(long INPUT_SAMPLE_L, long INPUT_SAMPLE_R, long
fp_mul(g_buffer(ACC_SRC_B1, ptr), ACC_COEF_B, FRACBITS) + fp_mul(g_buffer(ACC_SRC_B1, ptr), ACC_COEF_B, FRACBITS) +
fp_mul(g_buffer(ACC_SRC_C1, ptr), ACC_COEF_C, FRACBITS) + fp_mul(g_buffer(ACC_SRC_C1, ptr), ACC_COEF_C, FRACBITS) +
fp_mul(g_buffer(ACC_SRC_D1, ptr), ACC_COEF_D, FRACBITS)); fp_mul(g_buffer(ACC_SRC_D1, ptr), ACC_COEF_D, FRACBITS));
FB_A0 = g_buffer(MIX_DEST_A0 - FB_SRC_A, ptr); FB_A0 = g_buffer(MIX_DEST_A0 - FB_SRC_A, ptr);
FB_A1 = g_buffer(MIX_DEST_A1 - FB_SRC_A, ptr); FB_A1 = g_buffer(MIX_DEST_A1 - FB_SRC_A, ptr);
FB_B0 = g_buffer(MIX_DEST_B0 - FB_SRC_B, ptr); FB_B0 = g_buffer(MIX_DEST_B0 - FB_SRC_B, ptr);
FB_B1 = g_buffer(MIX_DEST_B1 - FB_SRC_B, ptr); FB_B1 = g_buffer(MIX_DEST_B1 - FB_SRC_B, ptr);
s_buffer(MIX_DEST_A0, ACC0 - fp_mul(FB_A0 , FB_ALPHA, FRACBITS), ptr); s_buffer(MIX_DEST_A0, ACC0 - fp_mul(FB_A0 , FB_ALPHA, FRACBITS), ptr);
s_buffer(MIX_DEST_A1, ACC1 - fp_mul(FB_A1 , FB_ALPHA, FRACBITS), ptr); s_buffer(MIX_DEST_A1, ACC1 - fp_mul(FB_A1 , FB_ALPHA, FRACBITS), ptr);
s_buffer(MIX_DEST_B0, fp_mul(FB_ALPHA , ACC0, FRACBITS) - fp_mul(FB_A0, (FB_ALPHA - one), FRACBITS) - fp_mul(FB_B0, FB_X, FRACBITS), ptr); s_buffer(MIX_DEST_B0, fp_mul(FB_ALPHA , ACC0, FRACBITS) - fp_mul(FB_A0, (FB_ALPHA - one), FRACBITS) - fp_mul(FB_B0, FB_X, FRACBITS), ptr);
s_buffer(MIX_DEST_B1, fp_mul(FB_ALPHA , ACC1, FRACBITS) - fp_mul(FB_A1, (FB_ALPHA - one), FRACBITS) - fp_mul(FB_B1, FB_X, FRACBITS), ptr); s_buffer(MIX_DEST_B1, fp_mul(FB_ALPHA , ACC1, FRACBITS) - fp_mul(FB_A1, (FB_ALPHA - one), FRACBITS) - fp_mul(FB_B1, FB_X, FRACBITS), ptr);
iRVBLeft = (g_buffer(MIX_DEST_A0, ptr)+g_buffer(MIX_DEST_B0, ptr)) / 3; iRVBLeft = (g_buffer(MIX_DEST_A0, ptr)+g_buffer(MIX_DEST_B0, ptr)) / 3;
iRVBRight = (g_buffer(MIX_DEST_A1, ptr)+g_buffer(MIX_DEST_B1, ptr)) / 3; iRVBRight = (g_buffer(MIX_DEST_A1, ptr)+g_buffer(MIX_DEST_B1, ptr)) / 3;
CurrAddr++; CurrAddr++;
if(CurrAddr>delay-1) CurrAddr=0; if(CurrAddr>delay-1) CurrAddr=0;
return (long)iRVBLeft; return (long)iRVBLeft;
} }
@ -228,7 +228,7 @@ void MV_FPReverb(int volume)
// OutputDebugStringA(err); // OutputDebugStringA(err);
long scale = (volume << FRACBITS) / MV_MaxVolume; long scale = (volume << FRACBITS) / MV_MaxVolume;
if (MV_Channels == 1) if (MV_Channels == 1)
{ {
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -308,7 +308,7 @@ void MV_16BitReverbFast( const char *src, char *dest, int count, int shift )
short *pdest = (short *)dest; short *pdest = (short *)dest;
const short *psrc = (const short *)src; const short *psrc = (const short *)src;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
pdest[i] = readLE16(psrc + i) >> shift; pdest[i] = readLE16(psrc + i) >> shift;
} }
@ -319,11 +319,11 @@ void MV_8BitReverbFast( const signed char *src, signed char *dest, int count, in
int i; int i;
unsigned char sh = 0x80 - (0x80 >> shift); unsigned char sh = 0x80 - (0x80 >> shift);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
unsigned char a = ((unsigned char) src[i]) >> shift; unsigned char a = ((unsigned char) src[i]) >> shift;
unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7; unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7;
dest[i] = (signed char) (a + sh + c); dest[i] = (signed char) (a + sh + c);
} }
} }

View file

@ -23,8 +23,8 @@ typedef struct console_element
// Private member functions // Private member functions
void CONSOLE_InsertUsedCommand(const char * szUsedCommand); void CONSOLE_InsertUsedCommand(const char * szUsedCommand);
void CONSOLE_ClearUsedCommandList(); void CONSOLE_ClearUsedCommandList(void);
void CONSOLE_RecalculateDirtyBuffer(); void CONSOLE_RecalculateDirtyBuffer(void);
// console argument tracker // console argument tracker
int argc; int argc;
@ -50,7 +50,7 @@ int nConsole_Active = 0;
void CVAR_RegisterDefaultCvarBindings(void); void CVAR_RegisterDefaultCvarBindings(void);
// Initialize the console // Initialize the console
void CONSOLE_Init() void CONSOLE_Init(void)
{ {
CONSOLE_Reset(); CONSOLE_Reset();
@ -63,7 +63,7 @@ void CONSOLE_Init()
CONSOLE_Printf("Type \'HELP\' for help with console Commands."); CONSOLE_Printf("Type \'HELP\' for help with console Commands.");
} }
void CONSOLE_Reset() void CONSOLE_Reset(void)
{ {
CONSOLEELEMENT *pElement; CONSOLEELEMENT *pElement;
CONSOLEELEMENT *pDelElement; CONSOLEELEMENT *pDelElement;
@ -144,7 +144,7 @@ void CONSOLE_HandleInput()
{ {
ud.pause_on = 0; ud.pause_on = 0;
} }
} }
} }
else else
// Bug fix: make sure the frag bar displays after console // Bug fix: make sure the frag bar displays after console
@ -153,7 +153,7 @@ void CONSOLE_HandleInput()
{ {
if ( ud.multimode > 1 && ud.coop != 1 ) if ( ud.multimode > 1 && ud.coop != 1 )
{ {
displayfragbar(); displayfragbar();
} }
if(numplayers<2) if(numplayers<2)
ud.pause_on = 0; ud.pause_on = 0;
@ -169,7 +169,7 @@ void CONSOLE_HandleInput()
return; return;
} }
switch(KB_GetLastScanCode()) switch(KB_GetLastScanCode())
{ {
case sc_Space: case sc_Space:
{ {
@ -221,7 +221,7 @@ void CONSOLE_HandleInput()
case sc_kpad_Enter: case sc_kpad_Enter:
case sc_Enter: case sc_Enter:
{ {
//If console_buffer[0] strlen() != 0 //If console_buffer[0] strlen() != 0
//1. Push the dirty_buffer unto the console_buffer //1. Push the dirty_buffer unto the console_buffer
//2. parse the text //2. parse the text
rb->kbd_input(dirty_buffer, sizeof(dirty_buffer)); rb->kbd_input(dirty_buffer, sizeof(dirty_buffer));
@ -278,7 +278,7 @@ void CONSOLE_HandleInput()
if(p_console_current_view->next != NULL) if(p_console_current_view->next != NULL)
{ {
p_console_current_view = p_console_current_view->next; p_console_current_view = p_console_current_view->next;
} }
else else
{ {
break; break;
@ -351,10 +351,10 @@ void CONSOLE_HandleInput()
} }
KB_ClearLastScanCode(); KB_ClearLastScanCode();
} }
void CONSOLE_Render() void CONSOLE_Render(void)
{ {
if(g_CV_classic) if(g_CV_classic)
{ {
@ -371,7 +371,7 @@ void CONSOLE_Render()
int iYOffset = 3; //offset for the console text int iYOffset = 3; //offset for the console text
CONSOLEELEMENT *pElement; CONSOLEELEMENT *pElement;
y1 = 0; y1 = 0;
y2 = (ydim / 2) - ((ydim / 2)/12); y2 = (ydim / 2) - ((ydim / 2)/12);
// Draw console background // Draw console background
@ -418,9 +418,9 @@ void CONSOLE_Render()
minitext(283, iCurHeight, BUILD_NUMBER, 17,10+16); minitext(283, iCurHeight, BUILD_NUMBER, 17,10+16);
// Draw the cursor //Change the color every second // Draw the cursor //Change the color every second
minitext(iCurWidth, iCurHeight,"_",(time(NULL)%2)+1,10+16); minitext(iCurWidth, iCurHeight,"_",(time(NULL)%2)+1,10+16);
} }
else else
if(g_CV_num_console_lines > 0) if(g_CV_num_console_lines > 0)
{ {
int i, iYOffset = 3; //offset for the console text int i, iYOffset = 3; //offset for the console text
@ -517,7 +517,7 @@ void CONSOLE_InsertUsedCommand(const char * szUsedCommand)
} }
} }
void CONSOLE_ClearUsedCommandList() void CONSOLE_ClearUsedCommandList(void)
{ {
CONSOLEELEMENT *pElement; CONSOLEELEMENT *pElement;
CONSOLEELEMENT *pDelElement; CONSOLEELEMENT *pDelElement;
@ -537,7 +537,7 @@ void CONSOLE_ClearUsedCommandList()
} }
void CONSOLE_RecalculateDirtyBuffer() void CONSOLE_RecalculateDirtyBuffer(void)
{ {
int len; int len;
int l; int l;
@ -605,7 +605,7 @@ void CONSOLE_Printf(const char *newmsg, ...)
} }
// Get the current number of args for this keyword // Get the current number of args for this keyword
int CONSOLE_GetArgc() int CONSOLE_GetArgc(void)
{ {
return argc; return argc;
} }
@ -617,9 +617,9 @@ char * CONSOLE_GetArgv(unsigned int var)
} }
// Is our console showing? // Is our console showing?
int CONSOLE_IsActive() int CONSOLE_IsActive(void)
{ {
return nConsole_Active; return nConsole_Active;
} }
@ -627,4 +627,4 @@ int CONSOLE_IsActive()
void CONSOLE_SetActive(int i) void CONSOLE_SetActive(int i)
{ {
nConsole_Active = (i == 0) ? 0 : 1; nConsole_Active = (i == 0) ? 0 : 1;
} }

View file

@ -3,17 +3,17 @@
// Public member functions // Public member functions
void CONSOLE_Init(); void CONSOLE_Init(void);
void CONSOLE_Reset(); void CONSOLE_Reset(void);
void CONSOLE_Term(); void CONSOLE_Term(void);
void CONSOLE_ParseStartupScript(); void CONSOLE_ParseStartupScript(void);
void CONSOLE_HandleInput(); void CONSOLE_HandleInput(void);
void CONSOLE_Render(); void CONSOLE_Render(void);
void CONSOLE_ParseCommand(char * command); void CONSOLE_ParseCommand(char * command);
void CONSOLE_Printf(const char *newmsg, ...); void CONSOLE_Printf(const char *newmsg, ...);
int CONSOLE_GetArgc(); int CONSOLE_GetArgc(void);
char * CONSOLE_GetArgv(unsigned int var); char * CONSOLE_GetArgv(unsigned int var);
int CONSOLE_IsActive(); int CONSOLE_IsActive(void);
void CONSOLE_SetActive(int i); void CONSOLE_SetActive(int i);
#endif #endif

View file

@ -3,8 +3,8 @@
#include <inttypes.h> #include <inttypes.h>
void CVARDEFS_Init(); void CVARDEFS_Init(void);
void CVARDEFS_Render(); void CVARDEFS_Render(void);
// //
// Function declarations // Function declarations
// //

View file

@ -18,8 +18,8 @@ typedef struct t_cvar_binding
void CVAR_RegisterCvar(const char * varname, const char * varhelp, void* variable, function_t function); void CVAR_RegisterCvar(const char * varname, const char * varhelp, void* variable, function_t function);
int CVAR_GetNumCvarBindings(); int CVAR_GetNumCvarBindings(void);
cvar_binding* CVAR_GetCvarBinding(unsigned int nBinding); cvar_binding* CVAR_GetCvarBinding(unsigned int nBinding);
void CVAR_Render(); void CVAR_Render(void);
#endif #endif

View file

@ -31,6 +31,7 @@ void Shutdown(void);
#endif #endif
#ifdef ROCKBOX #ifdef ROCKBOX
#undef BYTE_ORDER
#ifdef ROCKBOX_LITTLE_ENDIAN #ifdef ROCKBOX_LITTLE_ENDIAN
#define BYTE_ORDER LITTLE_ENDIAN #define BYTE_ORDER LITTLE_ENDIAN
#else #else

View file

@ -67,8 +67,12 @@ typedef float64 appfloat;
// //
//*************************************************************************** //***************************************************************************
#ifndef true
#define true ( 1 == 1 ) #define true ( 1 == 1 )
#endif
#ifndef false
#define false ( ! true ) #define false ( ! true )
#endif
//*************************************************************************** //***************************************************************************
// //

View file

@ -11,7 +11,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. See the GNU General Public License for more details.
@ -60,7 +60,7 @@ int16 IntelShort (int16 l);
int32_t Motoint32_t (int32_t l); int32_t Motoint32_t (int32_t l);
int32_t Intelint32_t (int32_t l); int32_t Intelint32_t (int32_t l);
void HeapSort(uint8_t * base, int32 nel, int32 width, int32 (*compare)(), void (*switcher)()); //void HeapSort(uint8_t * base, int32 nel, int32 width, int32 (*compare)(), void (*switcher)());
#ifdef __cplusplus #ifdef __cplusplus
}; };

View file

@ -172,35 +172,36 @@ float CL_KeyState (kbutton_t *key)
{ {
float val; float val;
qboolean impulsedown, impulseup, down; qboolean impulsedown, impulseup, down;
impulsedown = key->state & 2; impulsedown = key->state & 2;
impulseup = key->state & 4; impulseup = key->state & 4;
down = key->state & 1; down = key->state & 1;
val = 0; val = 0;
if (impulsedown && !impulseup) if (impulsedown && !impulseup) {
if (down) if (down)
val = 0.5; // pressed and held this frame val = 0.5; // pressed and held this frame
else else
val = 0; // I_Error (); val = 0; // I_Error ();
if (impulseup && !impulsedown) } else if (impulseup && !impulsedown) {
if (down) if (down)
val = 0; // I_Error (); val = 0; // I_Error ();
else else
val = 0; // released this frame val = 0; // released this frame
if (!impulsedown && !impulseup) } else if (!impulsedown && !impulseup) {
if (down) if (down)
val = 1.0; // held the entire frame val = 1.0; // held the entire frame
else else
val = 0; // up the entire frame val = 0; // up the entire frame
if (impulsedown && impulseup) } else if (impulsedown && impulseup) {
if (down) if (down)
val = 0.75; // released and re-pressed this frame val = 0.75; // released and re-pressed this frame
else else
val = 0.25; // pressed and released this frame val = 0.25; // pressed and released this frame
}
key->state &= 1; // clear impulses key->state &= 1; // clear impulses
return val; return val;
} }

View file

@ -182,6 +182,9 @@ extern byte *r_skysource;
#define DR_TRANSPARENT 1 #define DR_TRANSPARENT 1
// !!! must be kept the same as in quakeasm.h !!! // !!! must be kept the same as in quakeasm.h !!!
#ifdef TRANSPARENT_COLOR
#undef TRANSPARENT_COLOR
#endif
#define TRANSPARENT_COLOR 0xFF #define TRANSPARENT_COLOR 0xFF
extern void *acolormap; // FIXME: should go away extern void *acolormap; // FIXME: should go away

View file

@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. See the GNU General Public License for more details.
@ -69,11 +69,13 @@ void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
//void VectorNormalizeNoRet (vec3_t v); // uses finvsqrt //void VectorNormalizeNoRet (vec3_t v); // uses finvsqrt
//float VectorNormalize (vec3_t v); // returns vector length //float VectorNormalize (vec3_t v); // returns vector length
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
static inline float InvSqrt( float number ) { static inline float InvSqrt( float number ) {
long i; long i;
float x2, y; float x2, y;
const float threehalfs = 1.5F; const float threehalfs = 1.5F;
x2 = number * 0.5F; x2 = number * 0.5F;
y = number; y = number;
i = * ( long * ) &y; // evil floating point bit level hacking i = * ( long * ) &y; // evil floating point bit level hacking
@ -84,13 +86,14 @@ static inline float InvSqrt( float number ) {
return y; return y;
} }
#pragma GCC diagnostic pop
static inline void VectorNormalizeNoRet (vec3_t v) static inline void VectorNormalizeNoRet (vec3_t v)
{ {
float length, ilength; float length, ilength;
ilength = InvSqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); ilength = InvSqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
v[0] *= ilength; v[0] *= ilength;
v[1] *= ilength; v[1] *= ilength;
v[2] *= ilength; v[2] *= ilength;
@ -110,7 +113,7 @@ static inline float VectorNormalize (vec3_t v)
v[1] *= ilength; v[1] *= ilength;
v[2] *= ilength; v[2] *= ilength;
} }
return length; return length;
} }

View file

@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. See the GNU General Public License for more details.
@ -126,7 +126,7 @@ typedef struct qsocket_s
qboolean disconnected; qboolean disconnected;
qboolean canSend; qboolean canSend;
qboolean sendNext; qboolean sendNext;
int driver; int driver;
int landriver; int landriver;
int socket; int socket;
@ -314,7 +314,7 @@ typedef struct _PollProcedure
{ {
struct _PollProcedure *next; struct _PollProcedure *next;
double nextTime; double nextTime;
void (*procedure)(); void (*procedure)(void *);
void *arg; void *arg;
} PollProcedure; } PollProcedure;

View file

@ -250,7 +250,7 @@ void SV_MoveToGoal (void);
void SV_CheckForNewClients (void); void SV_CheckForNewClients (void);
void SV_RunClients (void); void SV_RunClients (void);
void SV_SaveSpawnparms (); void SV_SaveSpawnparms (void);
#ifdef QUAKE2 #ifdef QUAKE2
void SV_SpawnServer (char *server, char *startspot); void SV_SpawnServer (char *server, char *startspot);
#else #else

View file

@ -165,12 +165,12 @@ extern ScanCode IN_WaitForKey(void);
extern word IN_GetJoyButtonsDB(word joy); extern word IN_GetJoyButtonsDB(word joy);
extern const char *IN_GetScanName(ScanCode); extern const char *IN_GetScanName(ScanCode);
void IN_WaitAndProcessEvents(); void IN_WaitAndProcessEvents(void);
void IN_ProcessEvents(); void IN_ProcessEvents(void);
int IN_MouseButtons (void); int IN_MouseButtons (void);
boolean IN_JoyPresent(); boolean IN_JoyPresent(void);
void IN_SetJoyCurrent(int joyIndex); void IN_SetJoyCurrent(int joyIndex);
int IN_JoyButtons (void); int IN_JoyButtons (void);
void IN_GetJoyDelta(int *dx,int *dy); void IN_GetJoyDelta(int *dx,int *dy);
@ -178,6 +178,6 @@ void IN_GetJoyFineDelta(int *dx, int *dy);
void IN_StartAck(void); void IN_StartAck(void);
boolean IN_CheckAck (void); boolean IN_CheckAck (void);
bool IN_IsInputGrabbed(); bool IN_IsInputGrabbed(void);
void IN_CenterMouse(); void IN_CenterMouse(void);
#endif #endif

View file

@ -17,40 +17,40 @@ extern bool PMSoundInfoPagePadded;
// The last pointer points one byte after the last page. // The last pointer points one byte after the last page.
extern uint8_t **PMPages; extern uint8_t **PMPages;
void PM_Startup(); void PM_Startup(void);
void PM_Shutdown(); void PM_Shutdown(void);
static uint32_t PM_GetPageSize(int page) static inline uint32_t PM_GetPageSize(int page)
{ {
if(page < 0 || page >= ChunksInFile) if(page < 0 || page >= ChunksInFile)
Quit("PM_GetPageSize: Tried to access illegal page: %i", page); Quit("PM_GetPageSize: Tried to access illegal page: %i", page);
return (uint32_t) (PMPages[page + 1] - PMPages[page]); return (uint32_t) (PMPages[page + 1] - PMPages[page]);
} }
static uint8_t *PM_GetPage(int page) static inline uint8_t *PM_GetPage(int page)
{ {
if(page < 0 || page >= ChunksInFile) if(page < 0 || page >= ChunksInFile)
Quit("PM_GetPage: Tried to access illegal page: %i", page); Quit("PM_GetPage: Tried to access illegal page: %i", page);
return PMPages[page]; return PMPages[page];
} }
static uint8_t *PM_GetEnd() static inline uint8_t *PM_GetEnd(void)
{ {
return PMPages[ChunksInFile]; return PMPages[ChunksInFile];
} }
static byte *PM_GetTexture(int wallpic) static inline byte *PM_GetTexture(int wallpic)
{ {
return PM_GetPage(wallpic); return PM_GetPage(wallpic);
} }
static uint16_t *PM_GetSprite(int shapenum) static inline uint16_t *PM_GetSprite(int shapenum)
{ {
// correct alignment is enforced by PM_Startup() // correct alignment is enforced by PM_Startup()
return (uint16_t *) (void *) PM_GetPage(PMSpriteStart + shapenum); return (uint16_t *) (void *) PM_GetPage(PMSpriteStart + shapenum);
} }
static byte *PM_GetSound(int soundpagenum) static inline byte *PM_GetSound(int soundpagenum)
{ {
return PM_GetPage(PMSoundStart + soundpagenum); return PM_GetPage(PMSoundStart + soundpagenum);
} }

View file

@ -96,6 +96,6 @@ void USL_PrintInCenter(const char *s,Rect r);
char *USL_GiveSaveName(word game); char *USL_GiveSaveName(word game);
void US_InitRndT(int randomize); void US_InitRndT(int randomize);
int US_RndT(); int US_RndT(void);
#endif #endif

View file

@ -64,7 +64,7 @@ void VWB_Vlin (int y1, int y2, int x, int color);
#define VWB_HlinScaledCoord VW_Hlin #define VWB_HlinScaledCoord VW_Hlin
#define VWB_VlinScaledCoord VW_Vlin #define VWB_VlinScaledCoord VW_Vlin
void VH_UpdateScreen(); void VH_UpdateScreen(void);
#define VW_UpdateScreen VH_UpdateScreen #define VW_UpdateScreen VH_UpdateScreen
// //
@ -91,7 +91,7 @@ void LatchDrawPic (unsigned x, unsigned y, unsigned picnum);
void LatchDrawPicScaledCoord (unsigned scx, unsigned scy, unsigned picnum); void LatchDrawPicScaledCoord (unsigned scx, unsigned scy, unsigned picnum);
void LoadLatchMem (void); void LoadLatchMem (void);
void VH_Startup(); void VH_Startup(void);
boolean FizzleFade (SDL_Surface *source, int x1, int y1, boolean FizzleFade (SDL_Surface *source, int x1, int y1,
unsigned width, unsigned height, unsigned frames, boolean abortable); unsigned width, unsigned height, unsigned frames, boolean abortable);

View file

@ -961,7 +961,7 @@ void DrawPlayBorder (void);
void DrawStatusBorder (byte color); void DrawStatusBorder (byte color);
void DrawPlayScreen (void); void DrawPlayScreen (void);
void DrawPlayBorderSides (void); void DrawPlayBorderSides (void);
void ShowActStatus(); void ShowActStatus(void);
void PlayDemo (int demonumber); void PlayDemo (int demonumber);
void RecordDemo (void); void RecordDemo (void);
@ -1372,7 +1372,7 @@ void GP2X_ButtonUp(int button);
============================================================================= =============================================================================
*/ */
static fixed FixedMul(fixed a, fixed b) static inline fixed FixedMul(fixed a, fixed b)
{ {
return (fixed)(((int64_t)a * b + 0x8000) >> 16); return (fixed)(((int64_t)a * b + 0x8000) >> 16);
} }
@ -1394,13 +1394,13 @@ static fixed FixedMul(fixed a, fixed b)
#define CHECKMALLOCRESULT(x) if(!(x)) Quit("Out of memory at %s:%i", __FILE__, __LINE__) #define CHECKMALLOCRESULT(x) if(!(x)) Quit("Out of memory at %s:%i", __FILE__, __LINE__)
static char* itoa(int value, char* string, int radix) static inline char* itoa(int value, char* string, int radix)
{ {
sprintf(string, "%d", value); sprintf(string, "%d", value);
return string; return string;
} }
static char* ltoa(long value, char* string, int radix) static inline char* ltoa(long value, char* string, int radix)
{ {
sprintf(string, "%ld", value); sprintf(string, "%ld", value);
return string; return string;
@ -1409,14 +1409,14 @@ static char* ltoa(long value, char* string, int radix)
#define lengthof(x) (sizeof(x) / sizeof(*(x))) #define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define endof(x) ((x) + lengthof(x)) #define endof(x) ((x) + lengthof(x))
static word READWORD(byte **ptr) static inline word READWORD(byte **ptr)
{ {
word val = (*ptr)[0] | (*ptr)[1] << 8; word val = (*ptr)[0] | (*ptr)[1] << 8;
*ptr += 2; *ptr += 2;
return val; return val;
} }
static longword READLONGWORD(byte **ptr) static inline longword READLONGWORD(byte **ptr)
{ {
longword val = (*ptr)[0] | (*ptr)[1] << 8 | (*ptr)[2] << 16 | (*ptr)[3] << 24; longword val = (*ptr)[0] | (*ptr)[1] << 8 | (*ptr)[2] << 16 | (*ptr)[3] << 24;
*ptr += 4; *ptr += 4;
@ -1454,7 +1454,7 @@ static longword READLONGWORD(byte **ptr)
*************************************************************/ *************************************************************/
// The feature flags are stored as a wall in the upper right corner of each level // The feature flags are stored as a wall in the upper right corner of each level
static word GetFeatureFlags() static inline word GetFeatureFlags()
{ {
return ffDataTopRight; return ffDataTopRight;
} }

View file

@ -251,7 +251,7 @@ boolean TransformTile (int tx, int ty, short *dispx, short *dispheight)
==================== ====================
*/ */
int CalcHeight() int CalcHeight(void)
{ {
fixed z = FixedMul(xintercept - viewx, viewcos) fixed z = FixedMul(xintercept - viewx, viewcos)
- FixedMul(yintercept - viewy, viewsin); - FixedMul(yintercept - viewy, viewsin);
@ -275,7 +275,7 @@ byte *postsource;
int postx; int postx;
int postwidth; int postwidth;
void ScalePost() void ScalePost(void)
{ {
int ywcount, yoffs, yw, yd, yendoffs; int ywcount, yoffs, yw, yd, yendoffs;
byte col; byte col;
@ -1091,7 +1091,7 @@ void CalcTics (void)
//========================================================================== //==========================================================================
void AsmRefresh() void AsmRefresh(void)
{ {
int32_t xstep,ystep; int32_t xstep,ystep;
longword xpartial,ypartial; longword xpartial,ypartial;
@ -1517,7 +1517,7 @@ void WallRefresh (void)
ScalePost (); // no more optimization on last post ScalePost (); // no more optimization on last post
} }
void CalcViewVariables() void CalcViewVariables(void)
{ {
viewangle = player->angle; viewangle = player->angle;
midangle = viewangle*(FINEANGLES/ANGLES); midangle = viewangle*(FINEANGLES/ANGLES);

View file

@ -118,10 +118,10 @@ extern CP_iteminfo MainItems;
void US_ControlPanel(ScanCode); void US_ControlPanel(ScanCode);
void EnableEndGameMenuItem(); void EnableEndGameMenuItem(void);
void SetupControlPanel(void); void SetupControlPanel(void);
void SetupSaveGames(); void SetupSaveGames(void);
void CleanupControlPanel(void); void CleanupControlPanel(void);
void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items); void DrawMenu(CP_iteminfo *item_i,CP_itemtype *items);

View file

@ -32,6 +32,13 @@ SDLFLAGS = -I$(SDL_SRCDIR)/include $(filter-out -O%,$(PLUGINFLAGS)) \
-ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations \ -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations \
-D_GNU_SOURCE=1 -D_REENTRANT -DSDL -DELF -w # disable all warnings -D_GNU_SOURCE=1 -D_REENTRANT -DSDL -DELF -w # disable all warnings
# WIP SDLFLAGS for warning deletions
#SDLFLAGS = -I$(SDL_SRCDIR)/include $(filter-out -O%,$(PLUGINFLAGS)) \
#-O3 -Wno-unused-parameter -Xpreprocessor -Wno-undef -Wno-sign-compare \
#-Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable -Wno-unknown-pragmas \
#-ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations \
#-D_GNU_SOURCE=1 -D_REENTRANT -DSDL -DELF
# use FPU on ARMv6 # use FPU on ARMv6
ifeq ($(ARCH_VERSION),6) ifeq ($(ARCH_VERSION),6)
SDLFLAGS += -mfloat-abi=softfp SDLFLAGS += -mfloat-abi=softfp

View file

@ -125,7 +125,7 @@ static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
encoded_len = *audio_len; encoded_len = *audio_len;
encoded = *audio_buf; encoded = *audio_buf;
freeable = *audio_buf; freeable = *audio_buf;
*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) * *audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) *
MS_ADPCM_state.wSamplesPerBlock* MS_ADPCM_state.wSamplesPerBlock*
MS_ADPCM_state.wavefmt.channels*sizeof(Sint16); MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
*audio_buf = (Uint8 *)SDL_malloc(*audio_len); *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
@ -340,7 +340,7 @@ static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
encoded_len = *audio_len; encoded_len = *audio_len;
encoded = *audio_buf; encoded = *audio_buf;
freeable = *audio_buf; freeable = *audio_buf;
*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) * *audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) *
IMA_ADPCM_state.wSamplesPerBlock* IMA_ADPCM_state.wSamplesPerBlock*
IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16); IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
*audio_buf = (Uint8 *)SDL_malloc(*audio_len); *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
@ -413,7 +413,9 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
was_error = 1; was_error = 1;
goto done; goto done;
} }
chunk.data = NULL;
chunk.length = 0;
/* Check the magic header */ /* Check the magic header */
RIFFchunk = SDL_ReadLE32(src); RIFFchunk = SDL_ReadLE32(src);
wavelen = SDL_ReadLE32(src); wavelen = SDL_ReadLE32(src);
@ -432,7 +434,6 @@ SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
headerDiff += sizeof(Uint32); /* for WAVE */ headerDiff += sizeof(Uint32); /* for WAVE */
/* Read the audio data format chunk */ /* Read the audio data format chunk */
chunk.data = NULL;
do { do {
if ( chunk.data != NULL ) { if ( chunk.data != NULL ) {
SDL_free(chunk.data); SDL_free(chunk.data);

View file

@ -29,10 +29,10 @@
/* Math routines from uClibc: http://www.uclibc.org */ /* Math routines from uClibc: http://www.uclibc.org */
#include "math_private.h" #include "math_private.h"
#include "e_sqrt.h" #include "e_sqrt.h"
#include "e_pow.h" //#include "e_pow.h"
#include "e_log.h" //#include "e_log.h"
#define pow(x, y) __ieee754_pow(x, y) //#define pow(x, y) __ieee754_pow(x, y)
#define log(x) __ieee754_log(x) //#define log(x) __ieee754_log(x)
#endif #endif
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
@ -94,7 +94,7 @@ int SDL_SetGamma(float red, float green, float blue)
{ {
int succeeded; int succeeded;
SDL_VideoDevice *video = current_video; SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
succeeded = -1; succeeded = -1;
/* Prefer using SetGammaRamp(), as it's more flexible */ /* Prefer using SetGammaRamp(), as it's more flexible */
@ -120,7 +120,7 @@ int SDL_GetGamma(float *red, float *green, float *blue)
{ {
int succeeded; int succeeded;
SDL_VideoDevice *video = current_video; SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
succeeded = -1; succeeded = -1;
/* Prefer using GetGammaRamp(), as it's more flexible */ /* Prefer using GetGammaRamp(), as it's more flexible */
@ -145,7 +145,7 @@ int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
{ {
int succeeded; int succeeded;
SDL_VideoDevice *video = current_video; SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
SDL_Surface *screen = SDL_PublicSurface; SDL_Surface *screen = SDL_PublicSurface;
/* Verify the screen parameter */ /* Verify the screen parameter */
@ -177,7 +177,7 @@ int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
/* If physical palette has been set independently, use it */ /* If physical palette has been set independently, use it */
if(video->physpal) if(video->physpal)
pal = video->physpal; pal = video->physpal;
SDL_SetPalette(screen, SDL_PHYSPAL, SDL_SetPalette(screen, SDL_PHYSPAL,
pal->colors, 0, pal->ncolors); pal->colors, 0, pal->ncolors);
return 0; return 0;
@ -196,7 +196,7 @@ int SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue)
int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue) int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue)
{ {
SDL_VideoDevice *video = current_video; SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video; SDL_VideoDevice *this = current_video;
/* Lazily allocate the gamma table */ /* Lazily allocate the gamma table */
if ( ! video->gamma ) { if ( ! video->gamma ) {