Vast update to the MorphOS port which optimises graphics rendering, esp. efficient handling of color cycling. Also new formatting of source

svn-id: r4732
This commit is contained in:
Ruediger Hanke 2002-08-13 10:24:42 +00:00
parent 9792dc9f67
commit cafc73f949
8 changed files with 1921 additions and 1476 deletions

View File

@ -18,10 +18,10 @@ SIMONOBJS = midi.o simon.o simondebug.o simonitems.o simonres.o simonsys.o simon
OBJS = actor.o akos.o boxes.o config-file.o costume.o gfx.o object.o resource.o \
saveload.o script.o scummvm.o sound.o string.o sys.o verbs.o \
morphos.o morphos_sound.o morphos_start.o morphos_timer.o script_v1.o script_v2.o debug.o gui.o \
imuse.o fmopl.o mixer.o mididrv.o debugrl.o vars.o insane.o \
gameDetector.o init.o resource_v3.o resource_v4.o util.o main.o \
bundle.o $(GUIOBJS) $(SIMONOBJS)
morphos.o morphos_scaler.o morphos_sound.o morphos_start.o morphos_timer.o \
script_v1.o script_v2.o debug.o gui.o imuse.o fmopl.o mixer.o mididrv.o \
debugrl.o vars.o insane.o gameDetector.o init.o resource_v3.o resource_v4.o \
util.o main.o bundle.o $(GUIOBJS) $(SIMONOBJS)
DISTFILES=$(OBJS:.o=.cpp) Makefile scumm.h scummsys.h stdafx.h stdafx.cpp \
windows.cpp debugrl.h whatsnew.txt readme.txt copying.txt \

File diff suppressed because it is too large Load Diff

View File

@ -21,15 +21,22 @@
*
*/
#ifndef MORPHOS_MORPHOS_H
#define MORPHOS_MORPHOS_H
#include <exec/semaphores.h>
#include <devices/amidi.h>
#include <graphics/regions.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <libraries/cdda.h>
#include "morphos_scaler.h"
class OSystem_MorphOS : public OSystem
{
public:
typedef enum { ST_INVALID = 0, ST_NONE, ST_POINT, ST_ADVMAME2X, ST_SUPEREAGLE, ST_SUPER2XSAI } SCALERTYPE;
OSystem_MorphOS( int game_id, SCALERTYPE gfx_mode, bool full_screen );
OSystem_MorphOS(int game_id, SCALERTYPE gfx_mode, bool full_screen);
virtual ~OSystem_MorphOS();
// Set colors of the palette
@ -102,87 +109,66 @@ class OSystem_MorphOS : public OSystem
// Quit
virtual void quit();
static OSystem_MorphOS *create ( int game_id, SCALERTYPE gfx_scaler, bool full_screen );
static uint32 make_color( int pixfmt, int r, int g, int b );
static OSystem_MorphOS *create(int game_id, SCALERTYPE gfx_scaler, bool full_screen);
static void OpenATimer( struct MsgPort **port, struct IORequest **req, ULONG unit );
static SCALERTYPE FindScaler ( const char *ScalerName );
static bool OpenATimer(MsgPort **port, IORequest **req, ULONG unit, bool required = true);
private:
typedef void (*ScalerFunc)( uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height );
typedef enum { CSDSPTYPE_WINDOWED, CSDSPTYPE_FULLSCREEN, CSDSPTYPE_TOGGLE, CSDSPTYPE_KEEP } CS_DSPTYPE;
struct GfxScaler
{
STRPTR gs_Name;
SCALERTYPE gs_Type;
};
static const int MAX_MOUSE_W = 40;
static const int MAX_MOUSE_H = 40;
void create_screen ( CS_DSPTYPE dspType );
void SwitchScalerTo ( SCALERTYPE newScaler );
void Super2xSaI ( uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height );
void SuperEagle ( uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height );
void AdvMame2xScaler ( uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height );
void PointScaler ( uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height );
void CreateScreen(CS_DSPTYPE dspType);
void SwitchScalerTo(SCALERTYPE newScaler);
bool AddUpdateRect(WORD x, WORD y, WORD w, WORD h);
void draw_mouse();
void undraw_mouse();
void DrawMouse();
void UndrawMouse();
/* Display-related attributes */
struct Screen *ScummScreen;
struct Window *ScummWindow;
char ScummWndTitle[ 125 ];
APTR ScummBuffer;
int ScummBufferWidth;
int ScummBufferHeight;
struct ScreenBuffer *ScummScreenBuffer[ 2 ];
struct BitMap *ScummRenderTo;
bool ScummPCMode;
ULONG ScummPaintBuffer;
int ScummScrWidth;
int ScummScrHeight;
int ScummDepth;
bool Scumm16ColFmt16;
UWORD *ScummNoCursor;
ULONG ScummColors[256];
USHORT ScummColors16[256];
WORD ScummWinX;
WORD ScummWinY;
bool ScummDefaultMouse;
bool ScummOrigMouse;
int ScummShakePos;
bool FullScreenMode;
bool ScreenChanged;
/* Scaling-related attributes */
uint32 colorMask;
uint32 lowPixelMask;
uint32 qcolorMask;
uint32 qlowpixelMask;
uint32 redblueMask;
uint32 greenMask;
int PixelsPerMask;
byte *src_line[4];
byte *dst_line[2];
Screen *ScummScreen;
Window *ScummWindow;
char ScummWndTitle[125];
APTR ScummBuffer;
int ScummBufferWidth;
int ScummBufferHeight;
ScreenBuffer *ScummScreenBuffer[2];
BitMap *ScummRenderTo;
ULONG ScummPaintBuffer;
int ScummScrWidth;
int ScummScrHeight;
int ScummDepth;
bool Scumm16ColFmt16;
UWORD *ScummNoCursor;
ULONG ScummColors[256];
USHORT ScummColors16[256];
WORD ScummWinX;
WORD ScummWinY;
bool ScummDefaultMouse;
bool ScummOrigMouse;
int ScummShakePos;
bool FullScreenMode;
bool ScreenChanged;
UWORD **BlockColors;
bool *DirtyBlocks;
Region *UpdateRegion;
Region *NewUpdateRegion;
/* Sound-related attributes */
struct Process *ScummMusicThread;
struct Process *ScummSoundThread;
SoundProc *SoundProc;
void *SoundParam;
Process *ScummMusicThread;
Process *ScummSoundThread;
SoundProc *SoundProc;
void *SoundParam;
/* CD-ROM related attributes */
CDRIVEPTR CDrive;
ULONG CDDATrackOffset;
CDRIVEPTR CDrive;
ULONG CDDATrackOffset;
/* Scaling-related attributes */
SCALERTYPE ScummScaler;
int ScummScale;
static GfxScaler ScummScalers[ 10 ];
MorphOSScaler *Scaler;
/* Mouse cursor-related attributes */
bool MouseVisible, MouseDrawn;
@ -191,28 +177,30 @@ class OSystem_MorphOS : public OSystem
int MouseOldX, MouseOldY;
int MouseOldWidth, MouseOldHeight;
int MouseHotspotX, MouseHotspotY;
byte *MouseImage, MouseBackup[ MAX_MOUSE_W*MAX_MOUSE_H ];
byte *MouseImage, MouseBackup[MAX_MOUSE_W*MAX_MOUSE_H];
/* Timer-related attributes */
struct MsgPort *TimerMsgPort;
struct timerequest *TimerIORequest;
MsgPort *TimerMsgPort;
timerequest *TimerIORequest;
/* Game-related attributes */
int GameID;
};
int morphos_sound_thread( OSystem_MorphOS *syst, ULONG SampleType );
bool init_morphos_music( ULONG MidiUnit );
int morphos_sound_thread(OSystem_MorphOS *syst, ULONG SampleType);
bool init_morphos_music(ULONG MidiUnit);
void exit_morphos_music();
int morphos_main( int argc, char *argv[] );
int morphos_main(int argc, char *argv[]);
extern OSystem_MorphOS *TheSystem;
extern struct SignalSemaphore ScummMusicThreadRunning;
extern struct SignalSemaphore ScummSoundThreadRunning;
extern SignalSemaphore ScummMusicThreadRunning;
extern SignalSemaphore ScummSoundThreadRunning;
extern STRPTR ScummMusicDriver;
extern LONG ScummMidiUnit;
extern struct IOMidiRequest *ScummMidiRequest;
extern struct timerequest *MusicTimerIORequest;
extern IOMidiRequest *ScummMidiRequest;
extern timerequest *MusicTimerIORequest;
#endif

823
morphos/morphos_scaler.cpp Normal file
View File

@ -0,0 +1,823 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*/
#include "stdafx.h"
#include "scumm.h"
#include <exec/types.h>
#include <cybergraphics/cybergraphics.h>
#include <proto/cybergraphics.h>
#include "morphos.h"
#include "morphos_scaler.h"
#define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D))
#define INTERPOLATE(A, B) (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + (A & B & lowPixelMask))
#define Q_INTERPOLATE(A, B, C, D) ((A & qcolorMask) >> 2) + ((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2) + ((((A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask)) >> 2) & qlowpixelMask)
#define SWAP_WORD(word) word = ((word & 0xff) << 8) | (word >> 8)
MorphOSScaler::GfxScaler MorphOSScaler::ScummScalers[11]
= { { "none", "normal", ST_NONE },
{ "Point", "2x", ST_POINT },
{ "AdvMame2x", "advmame2x", ST_ADVMAME2X },
{ "SuperEagle", "supereagle", ST_SUPEREAGLE },
{ "Super2xSaI", "super2xsai", ST_SUPER2XSAI },
{ NULL, NULL, ST_INVALID },
{ NULL, NULL, ST_INVALID },
{ NULL, NULL, ST_INVALID },
{ NULL, NULL, ST_INVALID },
{ NULL, NULL, ST_INVALID },
// This is the end marker ... do not assign a scaler to it!
{ NULL, NULL, ST_INVALID }
};
MorphOSScaler::MorphOSScaler(APTR buffer, int width, int height, ULONG *col_table, UWORD *col_table16, BitMap *bmap)
{
dest = NULL;
handle = NULL;
Buffer = buffer;
BufferWidth = width;
BufferHeight = height;
ScummColors = col_table;
ScummColors16 = col_table16;
/* Initialize scaling stuff */
int minr, ming, minb;
ULONG depth = GetCyberMapAttr(bmap, CYBRMATTR_DEPTH);
if (depth > 16)
{
minr = 1 << 16;
ming = 1 << 8;
minb = 1;
}
else
{
minr = 1 << ((depth == 15) ? 10 : 11);
ming = 1 << 5;
minb = 1;
}
int pixfmt = GetCyberMapAttr(bmap, CYBRMATTR_PIXFMT);
ScummPCMode = false;
if (pixfmt == PIXFMT_RGB15PC || pixfmt == PIXFMT_BGR15PC ||
pixfmt == PIXFMT_RGB16PC || pixfmt == PIXFMT_BGR16PC)
ScummPCMode = true;
colorMask = (MakeColor(pixfmt, 255, 0, 0) - minr) | (MakeColor(pixfmt, 0, 255, 0) - ming) | (MakeColor(pixfmt, 0, 0, 255) - minb);
lowPixelMask = minr | ming | minb;
qcolorMask = (MakeColor(pixfmt, 255, 0, 0) - 3*minr) | (MakeColor(pixfmt, 0, 255, 0) - 3*ming) | (MakeColor(pixfmt, 0, 0, 255) - 3*minb);
qlowpixelMask = (minr * 3) | (ming * 3) | (minb * 3);
redblueMask = MakeColor(pixfmt, 255, 0, 255);
greenMask = MakeColor(pixfmt, 0, 255, 0);
PixelsPerMask = (depth <= 16) ? 2 : 1;
if (PixelsPerMask == 2)
{
colorMask |= (colorMask << 16);
qcolorMask |= (qcolorMask << 16);
lowPixelMask |= (lowPixelMask << 16);
qlowpixelMask |= (qlowpixelMask << 16);
}
}
MorphOSScaler::~MorphOSScaler()
{
Finish();
}
MorphOSScaler *MorphOSScaler::Create(SCALERTYPE scaler_type, APTR buffer, int width, int height, ULONG *col_table, UWORD *col_table16, BitMap *bmap)
{
MorphOSScaler *new_scaler = NULL;
switch (scaler_type)
{
case ST_POINT:
new_scaler = new PointScaler(buffer, width, height, col_table, col_table16, bmap);
break;
case ST_ADVMAME2X:
new_scaler = new AdvMame2xScaler(buffer, width, height, col_table, col_table16, bmap);
break;
case ST_SUPEREAGLE:
new_scaler = new SuperEagleScaler(buffer, width, height, col_table, col_table16, bmap);
break;
case ST_SUPER2XSAI:
new_scaler = new Super2xSaIScaler(buffer, width, height, col_table, col_table16, bmap);
break;
default:
warning("Invalid scaler requested - falling back to Super2xSaI");
new_scaler = new Super2xSaIScaler(buffer, width, height, col_table, col_table16, bmap);
break;
}
return new_scaler;
}
bool MorphOSScaler::Prepare(BitMap *render_bmap)
{
handle = LockBitMapTags(render_bmap, LBMI_BYTESPERPIX, &dest_bpp,
LBMI_BYTESPERROW, &dest_pitch,
LBMI_BASEADDRESS, &dest,
LBMI_PIXFMT, &dest_pixfmt,
TAG_DONE);
return handle != NULL;
}
void MorphOSScaler::Finish()
{
if (handle)
{
UnLockBitMap(handle);
handle = NULL;
}
}
uint32 MorphOSScaler::MakeColor(int pixfmt, int r, int g, int b)
{
uint32 col = 0;
switch (pixfmt)
{
case PIXFMT_RGB15:
case PIXFMT_RGB15PC:
col = (((r*31)/255) << 10) | (((g*31)/255) << 5) | ((b*31)/255);
break;
case PIXFMT_BGR15:
case PIXFMT_BGR15PC:
col = (((b*31)/255) << 10) | (((g*31)/255) << 5) | ((r*31)/255);
break;
case PIXFMT_RGB16:
case PIXFMT_RGB16PC:
col = (((r*31)/255) << 11) | (((g*63)/255) << 5) | ((b*31)/255);
break;
case PIXFMT_BGR16:
case PIXFMT_BGR16PC:
col = (((b*31)/255) << 11) | (((g*63)/255) << 5) | ((r*31)/255);
break;
case PIXFMT_RGB24:
case PIXFMT_ARGB32:
col = (r << 16) | (g << 8) | b;
break;
case PIXFMT_BGR24:
col = (b << 16) | (g << 8) | r;
break;
case PIXFMT_BGRA32:
col = (b << 24) | (g << 16) | (r << 8);
break;
case PIXFMT_RGBA32:
col = (r << 24) | (g << 16) | (b << 8);
break;
default:
error("Unsupported pixel format: %d. Please contact author at tomjoad@muenster.de.", pixfmt);
}
return col;
}
void Super2xSaIScaler::Scale(uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height)
{
unsigned int x, y;
unsigned long color[16];
byte *src;
if (!handle)
return;
src = ((byte *)Buffer)+src_y*BufferWidth+src_x;
/* Point to the first 3 lines. */
src_line[0] = src;
src_line[1] = src;
src_line[2] = src + BufferWidth;
src_line[3] = src + BufferWidth * 2;
dst_line[0] = dest+dest_y*2*dest_pitch+dest_x*2*dest_bpp;
dst_line[1] = dst_line[0]+dest_pitch;
if (PixelsPerMask == 2)
{
byte *sbp;
sbp = src_line[0];
color[0] = ScummColors16[*sbp]; color[1] = color[0]; color[2] = color[0]; color[3] = color[0];
color[4] = color[0]; color[5] = color[0]; color[6] = ScummColors16[*(sbp+1)]; color[7] = ScummColors16[*(sbp+2)];
sbp = src_line[2];
color[8] = ScummColors16[*sbp]; color[9] = color[8]; color[10] = ScummColors16[*(sbp+1)]; color[11] = ScummColors16[*(sbp+2)];
sbp = src_line[3];
color[12] = ScummColors16[*sbp]; color[13] = color[12]; color[14] = ScummColors16[*(sbp+1)]; color[15] = ScummColors16[*(sbp+2)];
}
else
{
byte *lbp;
lbp = src_line[0];
color[0] = ScummColors[*lbp]; color[1] = color[0]; color[2] = color[0]; color[3] = color[0];
color[4] = color[0]; color[5] = color[0]; color[6] = ScummColors[*(lbp+1)]; color[7] = ScummColors[*(lbp+2)];
lbp = src_line[2];
color[8] = ScummColors[*lbp]; color[9] = color[8]; color[10] = ScummColors[*(lbp+1)]; color[11] = ScummColors[*(lbp+2)];
lbp = src_line[3];
color[12] = ScummColors[*lbp]; color[13] = color[12]; color[14] = ScummColors[*(lbp+1)]; color[15] = ScummColors[*(lbp+2)];
}
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
unsigned long product1a, product1b, product2a, product2b;
//--------------------------------------- B0 B1 B2 B3 0 1 2 3
// 4 5* 6 S2 -> 4 5* 6 7
// 1 2 3 S1 8 9 10 11
// A0 A1 A2 A3 12 13 14 15
//--------------------------------------
if (color[9] == color[6] && color[5] != color[10])
{
product2b = color[9];
product1b = product2b;
}
else if (color[5] == color[10] && color[9] != color[6])
{
product2b = color[5];
product1b = product2b;
}
else if (color[5] == color[10] && color[9] == color[6])
{
int r = 0;
r += GET_RESULT(color[6], color[5], color[8], color[13]);
r += GET_RESULT(color[6], color[5], color[4], color[1]);
r += GET_RESULT(color[6], color[5], color[14], color[11]);
r += GET_RESULT(color[6], color[5], color[2], color[7]);
if (r > 0)
product1b = color[6];
else if (r < 0)
product1b = color[5];
else
product1b = INTERPOLATE(color[5], color[6]);
product2b = product1b;
}
else
{
if (color[6] == color[10] && color[10] == color[13] && color[9] != color[14] && color[10] != color[12])
product2b = Q_INTERPOLATE(color[10], color[10], color[10], color[9]);
else if (color[5] == color[9] && color[9] == color[14] && color[13] != color[10] && color[9] != color[15])
product2b = Q_INTERPOLATE(color[9], color[9], color[9], color[10]);
else
product2b = INTERPOLATE(color[9], color[10]);
if (color[6] == color[10] && color[6] == color[1] && color[5] != color[2] && color[6] != color[0])
product1b = Q_INTERPOLATE(color[6], color[6], color[6], color[5]);
else if (color[5] == color[9] && color[5] == color[2] && color[1] != color[6] && color[5] != color[3])
product1b = Q_INTERPOLATE(color[6], color[5], color[5], color[5]);
else
product1b = INTERPOLATE(color[5], color[6]);
}
if (color[5] == color[10] && color[9] != color[6] && color[4] == color[5] && color[5] != color[14])
product2a = INTERPOLATE(color[9], color[5]);
else if (color[5] == color[8] && color[6] == color[5] && color[4] != color[9] && color[5] != color[12])
product2a = INTERPOLATE(color[9], color[5]);
else
product2a = color[9];
if (color[9] == color[6] && color[5] != color[10] && color[8] == color[9] && color[9] != color[2])
product1a = INTERPOLATE(color[9], color[5]);
else if (color[4] == color[9] && color[10] == color[9] && color[8] != color[5] && color[9] != color[0])
product1a = INTERPOLATE(color[9], color[5]);
else
product1a = color[5];
if (PixelsPerMask == 2)
{
if (ScummPCMode)
{
SWAP_WORD(product1a);
SWAP_WORD(product1b);
SWAP_WORD(product2a);
SWAP_WORD(product2b);
}
*((unsigned long *) (&dst_line[0][x * 4])) = (product1a << 16) | product1b;
*((unsigned long *) (&dst_line[1][x * 4])) = (product2a << 16) | product2b;
}
else
{
*((unsigned long *) (&dst_line[0][x * 8])) = product1a;
*((unsigned long *) (&dst_line[0][x * 8 + 4])) = product1b;
*((unsigned long *) (&dst_line[1][x * 8])) = product2a;
*((unsigned long *) (&dst_line[1][x * 8 + 4])) = product2b;
}
/* Move color matrix forward */
color[0] = color[1]; color[4] = color[5]; color[8] = color[9]; color[12] = color[13];
color[1] = color[2]; color[5] = color[6]; color[9] = color[10]; color[13] = color[14];
color[2] = color[3]; color[6] = color[7]; color[10] = color[11]; color[14] = color[15];
if (src_x+x < BufferWidth-3)
{
x += 3;
if (PixelsPerMask == 2)
{
color[3] = ScummColors16[*(src_line[0] + x) ];
color[7] = ScummColors16[*(src_line[1] + x) ];
color[11] = ScummColors16[*(src_line[2] + x) ];
color[15] = ScummColors16[*(src_line[3] + x) ];
}
else
{
color[3] = ScummColors[*(src_line[0] + x)];
color[7] = ScummColors[*(src_line[1] + x)];
color[11] = ScummColors[*(src_line[2] + x)];
color[15] = ScummColors[*(src_line[3] + x)];
}
x -= 3;
}
}
/* We're done with one line, so we shift the source lines up */
src_line[0] = src_line[1];
src_line[1] = src_line[2];
src_line[2] = src_line[3];
/* Read next line */
if (src_y + y + 3 >= BufferHeight)
src_line[3] = src_line[2];
else
src_line[3] = src_line[2] + BufferWidth;
/* Then shift the color matrix up */
if (PixelsPerMask == 2)
{
byte *sbp;
sbp = src_line[0];
color[0] = ScummColors16[*sbp]; color[1] = color[0]; color[2] = ScummColors16[ *(sbp + 1) ]; color[3] = ScummColors16[*(sbp + 2)];
sbp = src_line[1];
color[4] = ScummColors16[*sbp]; color[5] = color[4]; color[6] = ScummColors16[ *(sbp + 1) ]; color[7] = ScummColors16[*(sbp + 2)];
sbp = src_line[2];
color[8] = ScummColors16[*sbp]; color[9] = color[8]; color[10] = ScummColors16[ *(sbp + 1) ]; color[11] = ScummColors16[*(sbp + 2)];
sbp = src_line[3];
color[12] = ScummColors16[*sbp]; color[13] = color[12]; color[14] = ScummColors16[ *(sbp + 1) ]; color[15] = ScummColors16[*(sbp + 2)];
if (src_x + x > 0)
{
color[0] = ScummColors16[src_line[0][-1]];
color[4] = ScummColors16[src_line[1][-1]];
color[8] = ScummColors16[src_line[2][-1]];
color[12] = ScummColors16[src_line[3][-1]];
}
}
else
{
byte *lbp;
lbp = src_line[0];
color[0] = ScummColors[*lbp]; color[1] = color[0]; color[2] = ScummColors[ *(lbp + 1) ]; color[3] = ScummColors[*(lbp+2)];
lbp = src_line[1];
color[4] = ScummColors[*lbp]; color[5] = color[4]; color[6] = ScummColors[ *(lbp + 1) ]; color[7] = ScummColors[*(lbp+2)];
lbp = src_line[2];
color[8] = ScummColors[*lbp]; color[9] = color[8]; color[10] = ScummColors[ *(lbp + 1) ]; color[11] = ScummColors[*(lbp+2)];
lbp = src_line[3];
color[12] = ScummColors[*lbp]; color[13] = color[12]; color[14] = ScummColors[ *(lbp + 1) ]; color[15] = ScummColors[*(lbp+2)];
}
if (src_y + y < BufferHeight - 1)
{
dst_line[0] = dst_line[1]+dest_pitch;
dst_line[1] = dst_line[0]+dest_pitch;
}
}
}
void SuperEagleScaler::Scale(uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height)
{
unsigned int x, y;
unsigned long color[12];
byte *src;
if (!handle)
return;
src = (byte *)Buffer+src_y*BufferWidth+src_x;
/* Point to the first 3 lines. */
src_line[0] = src;
src_line[1] = src;
src_line[2] = src + BufferWidth;
src_line[3] = src + BufferWidth * 2;
dst_line[0] = dest+dest_y*2*dest_pitch+dest_x*2*dest_bpp;
dst_line[1] = dst_line[0]+dest_pitch;
x = 0, y = 0;
if (PixelsPerMask == 2)
{
byte *sbp;
sbp = src_line[0];
color[0] = ScummColors16[*sbp]; color[1] = color[0]; color[2] = color[0]; color[3] = color[0];
color[4] = ScummColors16[*(sbp+1)]; color[5] = ScummColors16[*(sbp+2)];
sbp = src_line[2];
color[6] = ScummColors16[*sbp]; color[7] = color[6]; color[8] = ScummColors16[*(sbp+1)]; color[9] = ScummColors16[*(sbp+2)];
sbp = src_line[3];
color[10] = ScummColors16[*sbp]; color[11] = ScummColors16[*(sbp+1)];
}
else
{
byte *lbp;
lbp = src_line[0];
color[0] = ScummColors[*lbp]; color[1] = color[0]; color[2] = color[0]; color[3] = color[0];
color[4] = ScummColors[*(lbp+1)]; color[5] = ScummColors[*(lbp+2)];
lbp = src_line[2];
color[6] = ScummColors[*lbp]; color[7] = color[6]; color[8] = ScummColors[*(lbp+1)]; color[9] = ScummColors[*(lbp+2)];
lbp = src_line[3];
color[10] = ScummColors[*lbp]; color[11] = ScummColors[*(lbp+1)];
}
for (y = 0; y < height; y++)
{
/* Todo: x = width - 2, x = width - 1 */
for (x = 0; x < width; x++)
{
unsigned long product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2 0 1
// 4 5 6 S2 -> 2 3 4 5
// 1 2 3 S1 6 7 8 9
// A1 A2 10 11
if (color[7] == color[4] && color[3] != color[8])
{
product1b = product2a = color[7];
if ((color[6] == color[7]) || (color[4] == color[1]))
product1a = INTERPOLATE(color[7], INTERPOLATE(color[7], color[3]));
else
product1a = INTERPOLATE(color[3], color[4]);
if ((color[4] == color[5]) || (color[7] == color[10]))
product2b = INTERPOLATE(color[7], INTERPOLATE(color[7], color[8]));
else
product2b = INTERPOLATE(color[7], color[8]);
}
else if (color[3] == color[8] && color[7] != color[4])
{
product2b = product1a = color[3];
if ((color[0] == color[3]) || (color[5] == color[9]))
product1b = INTERPOLATE(color[3], INTERPOLATE(color[3], color[4]));
else
product1b = INTERPOLATE(color[3], color[1]);
if ((color[8] == color[11]) || (color[2] == color[3]))
product2a = INTERPOLATE(color[3], INTERPOLATE(color[3], color[2]));
else
product2a = INTERPOLATE(color[7], color[8]);
}
else if (color[3] == color[8] && color[7] == color[4])
{
register int r = 0;
r += GET_RESULT(color[4], color[3], color[6], color[10]);
r += GET_RESULT(color[4], color[3], color[2], color[0]);
r += GET_RESULT(color[4], color[3], color[11], color[9]);
r += GET_RESULT(color[4], color[3], color[1], color[5]);
if (r > 0)
{
product1b = product2a = color[7];
product1a = product2b = INTERPOLATE(color[3], color[4]);
}
else if (r < 0)
{
product2b = product1a = color[3];
product1b = product2a = INTERPOLATE(color[3], color[4]);
}
else
{
product2b = product1a = color[3];
product1b = product2a = color[7];
}
}
else
{
product2b = product1a = INTERPOLATE(color[7], color[4]);
product2b = Q_INTERPOLATE(color[8], color[8], color[8], product2b);
product1a = Q_INTERPOLATE(color[3], color[3], color[3], product1a);
product2a = product1b = INTERPOLATE(color[3], color[8]);
product2a = Q_INTERPOLATE(color[7], color[7], color[7], product2a);
product1b = Q_INTERPOLATE(color[4], color[4], color[4], product1b);
}
if (PixelsPerMask == 2)
{
if (ScummPCMode)
{
SWAP_WORD(product1a);
SWAP_WORD(product1b);
SWAP_WORD(product2a);
SWAP_WORD(product2b);
}
*((unsigned long *) (&dst_line[0][x * 4])) = (product1a << 16) | product1b;
*((unsigned long *) (&dst_line[1][x * 4])) = (product2a << 16) | product2b;
}
else
{
*((unsigned long *) (&dst_line[0][x * 8])) = product1a;
*((unsigned long *) (&dst_line[0][x * 8 + 4])) = product1b;
*((unsigned long *) (&dst_line[1][x * 8])) = product2a;
*((unsigned long *) (&dst_line[1][x * 8 + 4])) = product2b;
}
/* Move color matrix forward */
color[0] = color[1];
color[2] = color[3]; color[3] = color[4]; color[4] = color[5];
color[6] = color[7]; color[7] = color[8]; color[8] = color[9];
color[10] = color[11];
if (src_x+x < BufferWidth - 2)
{
x += 2;
if (PixelsPerMask == 2)
{
color[1] = ScummColors16[ *(src_line[0] + x) ];
if (src_x+x < BufferWidth-1)
{
color[5] = ScummColors16[*(src_line[1]+x+1)];
color[9] = ScummColors16[*(src_line[2]+x+1)];
}
color[11] = ScummColors16[*(src_line[3]+x)];
}
else
{
color[1] = ScummColors[*(src_line[0]+x)];
if (src_x+x < BufferWidth-1)
{
color[5] = ScummColors[*(src_line[1]+x+1)];
color[9] = ScummColors[ *(src_line[2]+x+1)];
}
color[11] = ScummColors[*(src_line[3]+x)];
}
x -= 2;
}
}
/* We're done with one line, so we shift the source lines up */
src_line[0] = src_line[1];
src_line[1] = src_line[2];
src_line[2] = src_line[3];
/* Read next line */
if (src_y+y+3 >= BufferHeight)
src_line[3] = src_line[2];
else
src_line[3] = src_line[2] + BufferWidth;
/* Then shift the color matrix up */
if (PixelsPerMask == 2)
{
byte *sbp;
sbp = src_line[0];
color[0] = ScummColors16[*sbp]; color[1] = ScummColors16[*(sbp+1)];
sbp = src_line[1];
color[2] = ScummColors16[*sbp]; color[3] = color[2]; color[4] = ScummColors16[*(sbp+1)]; color[5] = ScummColors16[*(sbp+2)];
sbp = src_line[2];
color[6] = ScummColors16[*sbp]; color[7] = color[6]; color[8] = ScummColors16[*(sbp+1)]; color[9] = ScummColors16[*(sbp+2)];
sbp = src_line[3];
color[10] = ScummColors16[*sbp]; color[11] = ScummColors16[*(sbp+1)];
}
else
{
byte *lbp;
lbp = src_line[0];
color[0] = ScummColors[*lbp]; color[1] = ScummColors[*(lbp+1)];
lbp = src_line[1];
color[2] = ScummColors[*lbp]; color[3] = color[2]; color[4] = ScummColors[*(lbp+1)]; color[5] = ScummColors[*(lbp+2)];
lbp = src_line[2];
color[6] = ScummColors[*lbp]; color[7] = color[6]; color[8] = ScummColors[*(lbp+1)]; color[9] = ScummColors[*(lbp+2)];
lbp = src_line[3];
color[10] = ScummColors[*lbp]; color[11] = ScummColors[*(lbp+1)];
}
if (src_y + y < BufferHeight - 1)
{
dst_line[0] = dst_line[1]+dest_pitch;
dst_line[1] = dst_line[0]+dest_pitch;
}
}
}
void AdvMame2xScaler::Scale(uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height)
{
if (!handle)
return;
byte *src = (byte *)Buffer+src_y*BufferWidth+src_x;
src_line[0] = src;
src_line[1] = src;
src_line[2] = src + BufferWidth;
dst_line[0] = dest+dest_y*2*dest_pitch+dest_x*2*dest_bpp;
dst_line[1] = dst_line[0]+dest_pitch;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
uint32 B, D, E, F, H;
if (PixelsPerMask == 2)
{
// short A = *(src + i - nextlineSrc - 1);
B = ScummColors16[src_line[0][x]];
// short C = *(src + i - nextlineSrc + 1);
D = ScummColors16[src_line[1][x-1]];
E = ScummColors16[src_line[1][x]];
F = ScummColors16[src_line[1][x+1]];
// short G = *(src + i + nextlineSrc - 1);
H = ScummColors16[src_line[2][x]];
// short I = *(src + i + nextlineSrc + 1);
}
else
{
// short A = *(src + i - nextlineSrc - 1);
B = ScummColors[src_line[0][x]];
// short C = *(src + i - nextlineSrc + 1);
D = ScummColors[src_line[1][x-1]];
E = ScummColors[src_line[1][x]];
F = ScummColors[src_line[1][x+1]];
// short G = *(src + i + nextlineSrc - 1);
H = ScummColors[src_line[2][x]];
// short I = *(src + i + nextlineSrc + 1);
}
if (PixelsPerMask == 2)
{
if (ScummPCMode)
{
SWAP_WORD(B);
SWAP_WORD(D);
SWAP_WORD(E);
SWAP_WORD(F);
SWAP_WORD(H);
}
*((unsigned long *) (&dst_line[0][x * 4])) = ((D == B && B != F && D != H ? D : E) << 16) | (B == F && B != D && F != H ? F : E);
*((unsigned long *) (&dst_line[1][x * 4])) = ((D == H && D != B && H != F ? D : E) << 16) | (H == F && D != H && B != F ? F : E);
}
else
{
*((unsigned long *) (&dst_line[0][x * 8])) = D == B && B != F && D != H ? D : E;
*((unsigned long *) (&dst_line[0][x * 8 + 4])) = B == F && B != D && F != H ? F : E;
*((unsigned long *) (&dst_line[1][x * 8])) = D == H && D != B && H != F ? D : E;
*((unsigned long *) (&dst_line[1][x * 8 + 4])) = H == F && D != H && B != F ? F : E;
}
}
src_line[0] = src_line[1];
src_line[1] = src_line[2];
if (src_y+y+2 >= BufferHeight)
src_line[2] = src_line[1];
else
src_line[2] = src_line[1] + BufferWidth;
if (src_y+y < BufferHeight-1)
{
dst_line[0] = dst_line[1]+dest_pitch;
dst_line[1] = dst_line[0]+dest_pitch;
}
}
}
void PointScaler::Scale(uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height)
{
byte *src;
uint32 color;
uint32 r, g, b;
uint32 x, y;
if (!handle)
return;
src = (byte *)Buffer+src_y*BufferWidth+src_x;
dst_line[0] = dest+dest_y*2*dest_pitch+dest_x*2*dest_bpp;
dst_line[1] = dst_line[0]+dest_pitch;
for (y = 0; y < height; y++)
{
for (x = 0; x < width; x++)
{
r = (ScummColors[*(src+x)] >> 16) & 0xff;
g = (ScummColors[*(src+x)] >> 8) & 0xff;
b = ScummColors[*(src+x)] & 0xff;
color = MakeColor(dest_pixfmt, r, g, b);
if (PixelsPerMask == 2)
{
if (ScummPCMode)
SWAP_WORD(color);
*((unsigned long *) (&dst_line[0][x * 4])) = (color << 16) | color;
*((unsigned long *) (&dst_line[1][x * 4])) = (color << 16) | color;
}
else
{
*((unsigned long *) (&dst_line[0][x * 8])) = color;
*((unsigned long *) (&dst_line[0][x * 8 + 4])) = color;
*((unsigned long *) (&dst_line[1][x * 8])) = color;
*((unsigned long *) (&dst_line[1][x * 8 + 4])) = color;
}
}
src += BufferWidth;
if (src_y+y < BufferHeight-1)
{
dst_line[0] = dst_line[1]+dest_pitch;
dst_line[1] = dst_line[0]+dest_pitch;
}
}
}
SCALERTYPE MorphOSScaler::FindByName(const char *ScalerName)
{
int scaler = 0;
while (ScummScalers[scaler].gs_Name)
{
if (!stricmp(ScalerName, ScummScalers[scaler].gs_Name))
return ScummScalers[scaler].gs_Type;
scaler++;
}
if (ScummScalers[scaler].gs_Name == NULL)
{
puts("Invalid scaler name. Please use one of the following:");
for (scaler = 0; ScummScalers[scaler].gs_Name != NULL; scaler++)
printf(" %s\n", ScummScalers[scaler].gs_Name);
}
return ST_INVALID;
}
SCALERTYPE MorphOSScaler::FindByIndex(int index)
{
if (index >= 0 && index < 10 && ScummScalers[index].gs_Name)
return ScummScalers[index].gs_Type;
return ST_INVALID;
}
const char *MorphOSScaler::GetParamName(SCALERTYPE type)
{
int scaler = 0;
while (ScummScalers[scaler].gs_Name)
{
if (ScummScalers[scaler].gs_Type == type)
return ScummScalers[scaler].gs_ParamName;
scaler++;
}
return NULL;
}

93
morphos/morphos_scaler.h Normal file
View File

@ -0,0 +1,93 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2002 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*/
#ifndef MORPHOS_MORPHOSSCALER_H
#define MORPHOS_MORPHOSSCALER_H
#include <graphics/gfx.h>
typedef enum { ST_INVALID = 0, ST_NONE, ST_POINT, ST_ADVMAME2X, ST_SUPEREAGLE, ST_SUPER2XSAI } SCALERTYPE;
class MorphOSScaler
{
public:
MorphOSScaler(APTR buffer, int width, int height, ULONG *col_table, UWORD *col_table16, BitMap *bmap);
virtual ~MorphOSScaler();
bool Prepare(BitMap *render_bmap);
void Finish();
virtual void Scale(uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height) = 0;
static MorphOSScaler *Create(SCALERTYPE st, APTR buffer, int width, int height, ULONG *col_table, UWORD *col_table16, BitMap *bmap);
static SCALERTYPE FindByName(const char *ScalerName);
static SCALERTYPE FindByIndex(int index);
static const char *GetParamName(SCALERTYPE type);
protected:
struct GfxScaler
{
STRPTR gs_Name;
STRPTR gs_ParamName;
SCALERTYPE gs_Type;
};
static GfxScaler ScummScalers[11];
static uint32 MakeColor(int pixfmt, int r, int g, int b);
byte *dest;
uint32 dest_bpp;
uint32 dest_pitch;
uint32 dest_pixfmt;
APTR handle;
uint32 colorMask;
uint32 lowPixelMask;
uint32 qcolorMask;
uint32 qlowpixelMask;
uint32 redblueMask;
uint32 greenMask;
int PixelsPerMask;
byte *src_line[4];
byte *dst_line[2];
bool ScummPCMode;
APTR Buffer;
int BufferWidth;
int BufferHeight;
ULONG *ScummColors;
USHORT *ScummColors16;
};
#define DECLARE_SCALER(scaler_name) class scaler_name ## Scaler : public MorphOSScaler \
{ public: scaler_name ## Scaler(APTR buffer, int width, int height, ULONG *col_table, UWORD *col_table16, BitMap *bmap) : MorphOSScaler(buffer, width, height, col_table, col_table16, bmap) {} \
void Scale(uint32 src_x, uint32 src_y, uint32 dest_x, uint32 dest_y, uint32 width, uint32 height); \
};
DECLARE_SCALER(Point)
DECLARE_SCALER(AdvMame2x)
DECLARE_SCALER(SuperEagle)
DECLARE_SCALER(Super2xSaI)
#endif

View File

@ -38,80 +38,80 @@
#define AHI_BUF_SIZE (8*1024)
struct SignalSemaphore ScummMusicThreadRunning;
struct SignalSemaphore ScummSoundThreadRunning;
SignalSemaphore ScummMusicThreadRunning;
SignalSemaphore ScummSoundThreadRunning;
static struct MsgPort *ahiPort = NULL;
static struct AHIRequest *ahiReq[ 2 ] = { NULL, NULL };
static UWORD ahiCurBuf = 0;
static bool ahiReqSent[ 2 ] = { false, false };
static BYTE ahiDevice = -1;
UBYTE ahiUnit = AHI_DEFAULT_UNIT;
static char *ahiBuf[ 2 ] = { NULL, NULL };
static MsgPort *ahiPort = NULL;
static AHIRequest *ahiReq[2] = { NULL, NULL };
static UWORD ahiCurBuf = 0;
static bool ahiReqSent[2] = { false, false };
static BYTE ahiDevice = -1;
UBYTE ahiUnit = AHI_DEFAULT_UNIT;
static char *ahiBuf[2] = { NULL, NULL };
static struct MsgPort *ScummMidiPort = NULL;
struct IOMidiRequest *ScummMidiRequest = NULL;
static struct MsgPort *MusicTimerMsgPort = NULL;
struct timerequest *MusicTimerIORequest = NULL;
static MsgPort *ScummMidiPort = NULL;
IOMidiRequest *ScummMidiRequest = NULL;
static MsgPort *MusicTimerMsgPort = NULL;
timerequest *MusicTimerIORequest = NULL;
bool init_morphos_music( ULONG MidiUnit )
bool init_morphos_music(ULONG MidiUnit)
{
if( ScummMusicDriver && !stricmp( ScummMusicDriver, "-eamidi" ) ) // just as ugly as the line below ...
if (ScummMusicDriver && !stricmp(ScummMusicDriver, "-eamidi")) // just as ugly as the line below ...
{
MidiUnit = ScummMidiUnit; // Ugly fix, but ...
ScummMidiPort = CreateMsgPort();
if( ScummMidiPort )
if (ScummMidiPort)
{
ScummMidiRequest = (struct IOMidiRequest *)CreateIORequest( ScummMidiPort, sizeof( struct IOMidiRequest ) );
if( ScummMidiRequest )
ScummMidiRequest = (IOMidiRequest *) CreateIORequest(ScummMidiPort, sizeof (IOMidiRequest));
if (ScummMidiRequest)
{
ScummMidiRequest->amr_Version = 2;
if( OpenDevice( "amidi.device", MidiUnit, (struct IORequest *)ScummMidiRequest, AMIDIF_MIDISERVER ) )
if (OpenDevice("amidi.device", MidiUnit, (IORequest *) ScummMidiRequest, AMIDIF_MIDISERVER))
{
DeleteIORequest( (struct IORequest *)ScummMidiRequest );
DeleteMsgPort( ScummMidiPort );
DeleteIORequest((IORequest *) ScummMidiRequest);
DeleteMsgPort(ScummMidiPort);
ScummMidiRequest = NULL;
ScummMidiPort = NULL;
}
}
else
{
DeleteMsgPort( ScummMidiPort );
DeleteMsgPort(ScummMidiPort);
ScummMidiPort = NULL;
}
}
if( !ScummMidiRequest )
if (!ScummMidiRequest)
{
warning( "Could not open AMidi - music will not play" );
warning("Could not open AMidi - music will not play");
return false;
}
}
MusicTimerMsgPort = CreateMsgPort();
if( MusicTimerMsgPort )
if (MusicTimerMsgPort)
{
MusicTimerIORequest = (struct timerequest *)CreateIORequest( MusicTimerMsgPort, sizeof( struct timerequest ) );
if( MusicTimerIORequest )
MusicTimerIORequest = (timerequest *) CreateIORequest(MusicTimerMsgPort, sizeof (timerequest));
if (MusicTimerIORequest)
{
if( OpenDevice( "timer.device", UNIT_MICROHZ, (struct IORequest *)MusicTimerIORequest, 0 ) )
if (OpenDevice("timer.device", UNIT_MICROHZ, (IORequest *) MusicTimerIORequest, 0))
{
DeleteIORequest( (struct IORequest *)MusicTimerIORequest );
DeleteMsgPort( MusicTimerMsgPort );
DeleteIORequest((IORequest *) MusicTimerIORequest);
DeleteMsgPort(MusicTimerMsgPort);
MusicTimerIORequest = NULL;
MusicTimerMsgPort = NULL;
}
}
else
{
DeleteMsgPort( MusicTimerMsgPort );
DeleteMsgPort(MusicTimerMsgPort);
MusicTimerMsgPort = NULL;
}
}
if( !MusicTimerIORequest )
if (!MusicTimerIORequest)
{
warning( "Could not open timer device - music will not play" );
warning("Could not open timer device - music will not play");
return false;
}
@ -121,74 +121,74 @@ bool init_morphos_music( ULONG MidiUnit )
void exit_morphos_music()
{
if( ScummMidiRequest )
if (ScummMidiRequest)
{
CloseDevice( (struct IORequest *)ScummMidiRequest );
DeleteIORequest( (struct IORequest *)ScummMidiRequest );
DeleteMsgPort( ScummMidiPort );
CloseDevice((IORequest *) ScummMidiRequest);
DeleteIORequest((IORequest *) ScummMidiRequest);
DeleteMsgPort(ScummMidiPort);
}
if( MusicTimerIORequest )
if (MusicTimerIORequest)
{
CloseDevice( (struct IORequest *)MusicTimerIORequest );
DeleteIORequest( (struct IORequest *)MusicTimerIORequest );
DeleteMsgPort( MusicTimerMsgPort );
CloseDevice((IORequest *) MusicTimerIORequest);
DeleteIORequest((IORequest *) MusicTimerIORequest);
DeleteMsgPort(MusicTimerMsgPort);
}
}
static bool init_morphos_sound()
{
if( !(ahiPort = CreateMsgPort()) )
if (!(ahiPort = CreateMsgPort()))
return false;
if( !(ahiReq[ 0 ] = (struct AHIRequest *)CreateIORequest( ahiPort, sizeof( struct AHIRequest ) )) )
if (!(ahiReq[0] = (AHIRequest *) CreateIORequest(ahiPort, sizeof (AHIRequest))))
{
DeleteMsgPort( ahiPort );
DeleteMsgPort(ahiPort);
ahiPort = NULL;
return false;
}
if( !(ahiReq[ 1 ] = (struct AHIRequest *)AllocVec( sizeof( struct AHIRequest ), MEMF_ANY | MEMF_PUBLIC )) )
if (!(ahiReq[1] = (AHIRequest *) AllocVec(sizeof (AHIRequest), MEMF_PUBLIC)))
{
DeleteIORequest( ahiReq[ 0 ] );
DeleteMsgPort( ahiPort );
ahiReq[ 0 ] = NULL;
DeleteIORequest(ahiReq[0]);
DeleteMsgPort(ahiPort);
ahiReq[0] = NULL;
ahiPort = NULL;
return false;
}
if( !(ahiBuf[ 0 ] = (char *)AllocVec( 2*AHI_BUF_SIZE, MEMF_ANY | MEMF_PUBLIC )) )
if (!(ahiBuf[0] = (char *) AllocVec(2*AHI_BUF_SIZE, MEMF_PUBLIC)))
{
FreeVec( ahiReq[ 1 ] );
DeleteIORequest( ahiReq[ 0 ] );
DeleteMsgPort( ahiPort );
ahiReq[ 0 ] = NULL;
ahiReq[ 1 ] = NULL;
FreeVec(ahiReq[1]);
DeleteIORequest(ahiReq[0]);
DeleteMsgPort(ahiPort);
ahiReq[0] = NULL;
ahiReq[1] = NULL;
ahiPort = NULL;
return false;
}
ahiBuf[ 1 ] = &ahiBuf[ 0 ][ AHI_BUF_SIZE ];
ahiBuf[1] = &ahiBuf[0][AHI_BUF_SIZE];
ahiReq[ 0 ]->ahir_Version = 4;
if( ahiDevice = OpenDevice( AHINAME, 0, (struct IORequest *)ahiReq[ 0 ], 0 ) )
ahiReq[0]->ahir_Version = 4;
if (ahiDevice = OpenDevice(AHINAME, 0, (IORequest *) ahiReq[0], 0))
{
FreeVec( ahiBuf[ 0 ] );
FreeVec( ahiReq[ 1 ] );
DeleteIORequest( ahiReq[ 0 ] );
DeleteMsgPort( ahiPort );
ahiBuf[ 0 ] = NULL;
ahiReq[ 0 ] = NULL;
ahiReq[ 1 ] = NULL;
FreeVec(ahiBuf[0]);
FreeVec(ahiReq[1]);
DeleteIORequest(ahiReq[0]);
DeleteMsgPort(ahiPort);
ahiBuf[0] = NULL;
ahiReq[0] = NULL;
ahiReq[1] = NULL;
ahiPort = NULL;
return false;
}
CopyMem( ahiReq[ 0 ], ahiReq[ 1 ], sizeof( struct AHIRequest ) );
CopyMem(ahiReq[0], ahiReq[1], sizeof (AHIRequest));
ahiCurBuf = 0;
ahiReqSent[ 0 ] = FALSE;
ahiReqSent[ 1 ] = FALSE;
ahiReqSent[0] = FALSE;
ahiReqSent[1] = FALSE;
return true;
}
@ -196,89 +196,89 @@ static bool init_morphos_sound()
static void exit_morphos_sound()
{
if( ahiReq[ 1 ] )
FreeVec( ahiReq[ 1 ] );
if (ahiReq[1])
FreeVec(ahiReq[1]);
if( ahiReq[ 0 ] )
if (ahiReq[0])
{
CloseDevice( (struct IORequest *)ahiReq[ 0 ] );
DeleteIORequest( ahiReq[ 0 ] );
CloseDevice((IORequest *) ahiReq[0]);
DeleteIORequest(ahiReq[0]);
}
if( ahiBuf[ 0 ] )
FreeVec( (APTR)ahiBuf[ 0 ] );
if (ahiBuf[0])
FreeVec((APTR) ahiBuf[0]);
if( ahiPort )
DeleteMsgPort( ahiPort );
if (ahiPort)
DeleteMsgPort(ahiPort);
}
int morphos_sound_thread( OSystem_MorphOS *syst, ULONG SampleType )
int morphos_sound_thread(OSystem_MorphOS *syst, ULONG SampleType)
{
ULONG signals;
bool initialized;
ObtainSemaphore( &ScummSoundThreadRunning );
ObtainSemaphore(&ScummSoundThreadRunning);
initialized = init_morphos_sound();
if( !initialized )
if (!initialized)
{
warning( "Sound could not be initialized. The game may hang at some point (press Ctrl-z then)." );
Wait( SIGBREAKF_CTRL_C );
warning("Sound could not be initialized. The game may hang at some point (press Ctrl-z then).");
Wait(SIGBREAKF_CTRL_C);
}
else
{
for(;;)
for (;;)
{
while( !ahiReqSent[ ahiCurBuf ] || CheckIO( (struct IORequest *)ahiReq[ ahiCurBuf ] ) )
while (!ahiReqSent[ahiCurBuf] || CheckIO((IORequest *) ahiReq[ahiCurBuf]))
{
struct AHIRequest *req = ahiReq[ ahiCurBuf ];
AHIRequest *req = ahiReq[ahiCurBuf];
UWORD ahiOtherBuf = !ahiCurBuf;
if( ahiReqSent[ ahiCurBuf ] )
WaitIO( (struct IORequest *)req );
if (ahiReqSent[ahiCurBuf])
WaitIO((IORequest *) req);
syst->fill_sound( (byte *)ahiBuf[ ahiCurBuf ], AHI_BUF_SIZE );
syst->fill_sound((byte *) ahiBuf[ahiCurBuf], AHI_BUF_SIZE);
req->ahir_Std.io_Message.mn_Node.ln_Pri = 0;
req->ahir_Std.io_Command = CMD_WRITE;
req->ahir_Std.io_Data = ahiBuf[ ahiCurBuf ];
req->ahir_Std.io_Data = ahiBuf[ahiCurBuf];
req->ahir_Std.io_Length = AHI_BUF_SIZE;
req->ahir_Type = SampleType;
req->ahir_Frequency = SAMPLES_PER_SEC;
req->ahir_Position = 0x8000;
req->ahir_Volume = 0x10000;
req->ahir_Link = (ahiReqSent[ ahiOtherBuf ] && !CheckIO( (struct IORequest *)ahiReq[ ahiOtherBuf ] )) ? ahiReq[ ahiOtherBuf ] : NULL;
SendIO( (struct IORequest *)req );
req->ahir_Link = (ahiReqSent[ahiOtherBuf] && !CheckIO((IORequest *) ahiReq[ahiOtherBuf])) ? ahiReq[ahiOtherBuf] : NULL;
SendIO((IORequest *)req);
ahiReqSent[ ahiCurBuf ] = true;
ahiReqSent[ahiCurBuf] = true;
ahiCurBuf = ahiOtherBuf;
}
signals = Wait( SIGBREAKF_CTRL_C | (1 << ahiPort->mp_SigBit) );
signals = Wait(SIGBREAKF_CTRL_C | (1 << ahiPort->mp_SigBit));
if( signals & SIGBREAKF_CTRL_C )
if (signals & SIGBREAKF_CTRL_C)
break;
}
if( ahiReqSent[ ahiCurBuf ] )
if (ahiReqSent[ahiCurBuf])
{
AbortIO( (struct IORequest *)ahiReq[ ahiCurBuf ] );
WaitIO ( (struct IORequest *)ahiReq[ ahiCurBuf ] );
ahiReqSent[ ahiCurBuf ] = false;
AbortIO((IORequest *) ahiReq[ahiCurBuf]);
WaitIO((IORequest *) ahiReq[ahiCurBuf]);
ahiReqSent[ahiCurBuf] = false;
}
if( ahiReqSent[ !ahiCurBuf ] )
if (ahiReqSent[!ahiCurBuf])
{
AbortIO( (struct IORequest *)ahiReq[ !ahiCurBuf ] );
WaitIO ( (struct IORequest *)ahiReq[ !ahiCurBuf ] );
ahiReqSent[ !ahiCurBuf ] = false;
AbortIO((IORequest *) ahiReq[!ahiCurBuf]);
WaitIO((IORequest *) ahiReq[!ahiCurBuf]);
ahiReqSent[!ahiCurBuf] = false;
}
}
exit_morphos_sound();
ReleaseSemaphore( &ScummSoundThreadRunning );
RemTask( NULL );
ReleaseSemaphore(&ScummSoundThreadRunning);
RemTask(NULL);
return 0;
}

View File

@ -37,14 +37,15 @@
#include "stdafx.h"
#include "scumm.h"
#include "morphos.h"
#include "morphos_scaler.h"
extern "C" struct WBStartup *_WBenchMsg;
extern "C" WBStartup *_WBenchMsg;
// For command line parsing
static STRPTR usageTemplate = "STORY/A,DATAPATH/K,WBWINDOW/S,SCALER/K,AMIGA/S,MIDIUNIT/K/N,MUSIC/K,MUSICVOL/K/N,SFXVOL/K/N,TEMPO/K/N,TALKSPEED/K/N,NOSUBTITLES=NST/S";
typedef enum { USG_STORY = 0, USG_DATAPATH, USG_WBWINDOW, USG_SCALER, USG_AMIGA, USG_MIDIUNIT, USG_MUSIC, USG_MUSICVOL, USG_SFXVOL, USG_TEMPO, USG_TALKSPEED, USG_NOSUBTITLES } usageFields;
static LONG args[ 13 ] = { (ULONG)NULL, (ULONG)NULL, FALSE, (ULONG)NULL, false, (ULONG)NULL, (ULONG)NULL, (ULONG)NULL, (ULONG)NULL, (ULONG)NULL, (ULONG)NULL, false };
static struct RDArgs *ScummArgs = NULL;
typedef enum { USG_STORY = 0, USG_DATAPATH, USG_WBWINDOW, USG_SCALER, USG_AMIGA, USG_MIDIUNIT, USG_MUSIC, USG_MUSICVOL, USG_SFXVOL, USG_TEMPO, USG_TALKSPEED, USG_NOSUBTITLES } usageFields;
static LONG args[13] = { (ULONG) NULL, (ULONG) NULL, FALSE, (ULONG) NULL, false, (ULONG) NULL, (ULONG) NULL, (ULONG) NULL, (ULONG) NULL, (ULONG) NULL, (ULONG) NULL, false };
static RDArgs *ScummArgs = NULL;
static char*ScummStory = NULL;
static char*ScummPath = NULL;
@ -54,184 +55,184 @@ static LONG ScummMidiVolume = 0;
static LONG ScummMidiTempo = 0;
static LONG ScummSfxVolume = 0;
static LONG ScummTalkSpeed = 0;
static OSystem_MorphOS::SCALERTYPE ScummGfxScaler = OSystem_MorphOS::ST_INVALID;
static SCALERTYPE ScummGfxScaler = ST_INVALID;
static BPTR OrigDirLock = 0;
struct Library *CDDABase = NULL;
struct Device *TimerBase = NULL;
Library *CDDABase = NULL;
Device *TimerBase = NULL;
OSystem_MorphOS *TheSystem = NULL;
OSystem *OSystem_MorphOS_create( int game_id, int gfx_mode, bool full_screen)
OSystem *OSystem_MorphOS_create(int game_id, int gfx_mode, bool full_screen)
{
if( TheSystem )
if (TheSystem)
delete TheSystem;
OSystem_MorphOS::SCALERTYPE gfx_scaler = OSystem_MorphOS::ST_NONE;
switch( gfx_mode )
SCALERTYPE gfx_scaler = ST_NONE;
switch (gfx_mode)
{
case GFX_DOUBLESIZE:
gfx_scaler = OSystem_MorphOS::ST_POINT;
gfx_scaler = ST_POINT;
break;
case GFX_SUPEREAGLE:
gfx_scaler = OSystem_MorphOS::ST_SUPEREAGLE;
gfx_scaler = ST_SUPEREAGLE;
break;
case GFX_SUPER2XSAI:
gfx_scaler = OSystem_MorphOS::ST_SUPER2XSAI;
gfx_scaler = ST_SUPER2XSAI;
break;
}
TheSystem = OSystem_MorphOS::create( game_id, gfx_scaler, full_screen );
TheSystem = OSystem_MorphOS::create(game_id, gfx_scaler, full_screen);
return TheSystem;
}
void close_resources()
{
if( TheSystem )
if (TheSystem)
delete TheSystem;
if( g_scumm )
if (g_scumm)
delete g_scumm;
if( ScummPath )
FreeVec( ScummPath );
if (ScummPath)
FreeVec(ScummPath);
if( ScummStory )
FreeVec( ScummStory );
if (ScummStory)
FreeVec(ScummStory);
if( ScummArgs )
FreeArgs( ScummArgs );
if (ScummArgs)
FreeArgs(ScummArgs);
if( OrigDirLock )
CurrentDir( OrigDirLock );
if (OrigDirLock)
CurrentDir(OrigDirLock);
if( CDDABase )
CloseLibrary( CDDABase );
if (CDDABase)
CloseLibrary(CDDABase);
}
static STRPTR FindMusicDriver( STRPTR argval )
static STRPTR FindMusicDriver(STRPTR argval)
{
if( !stricmp( argval, "off" ) ) return "-enull";
if( !stricmp( argval, "midi" ) ) return "-eamidi";
if( !stricmp( argval, "midiemu" ) ) return "-emidiemu";
if( !stricmp( argval, "adlib" ) ) return "-eadlib";
if (!stricmp(argval, "off")) return "-enull";
if (!stricmp(argval, "midi")) return "-eamidi";
if (!stricmp(argval, "midiemu")) return "-emidiemu";
if (!stricmp(argval, "adlib")) return "-eadlib";
error( "No such music driver supported. Possible values are off, Midi, MidiEmu and Adlib." );
error("No such music driver supported. Possible values are off, Midi, MidiEmu and Adlib.");
return NULL;
}
static void ReadToolTypes( struct WBArg *OfFile )
static void ReadToolTypes(WBArg *OfFile)
{
struct DiskObject *dobj;
char *ToolValue;
char IconPath[ 256 ];
DiskObject *dobj;
char *ToolValue;
char IconPath[256];
NameFromLock( OfFile->wa_Lock, IconPath, 256 );
AddPart( IconPath, OfFile->wa_Name, 256 );
NameFromLock(OfFile->wa_Lock, IconPath, 256);
AddPart(IconPath, OfFile->wa_Name, 256);
dobj = GetDiskObject( IconPath );
if( dobj == NULL )
dobj = GetDiskObject(IconPath);
if (dobj == NULL)
return;
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "STORY" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "STORY"))
{
if( ScummStory )
FreeVec( ScummStory );
ScummStory = (char *)AllocVec( strlen( ToolValue )+1, MEMF_PUBLIC );
strcpy( ScummStory, ToolValue );
if (ScummStory)
FreeVec(ScummStory);
ScummStory = (char *) AllocVec(strlen(ToolValue)+1, MEMF_PUBLIC);
strcpy(ScummStory, ToolValue);
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "DATAPATH" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "DATAPATH"))
{
if( ScummPath )
FreeVec( ScummPath );
ScummPath = (char *)AllocVec( strlen( ToolValue )+4, MEMF_PUBLIC );
strcpy( ScummPath, "-p" );
strcat( ScummPath, ToolValue );
if (ScummPath)
FreeVec(ScummPath);
ScummPath = (char *) AllocVec(strlen(ToolValue)+4, MEMF_PUBLIC);
strcpy(ScummPath, "-p");
strcat(ScummPath, ToolValue);
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "WBWINDOW" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "WBWINDOW"))
{
if( MatchToolValue( ToolValue, "YES" ) )
args[ USG_WBWINDOW ] = TRUE;
else if( MatchToolValue( ToolValue, "NO" ) )
args[ USG_WBWINDOW ] = FALSE;
if (MatchToolValue(ToolValue, "YES"))
args[USG_WBWINDOW] = TRUE;
else if (MatchToolValue(ToolValue, "NO"))
args[USG_WBWINDOW] = FALSE;
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "SCALER" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "SCALER"))
{
if( (ScummGfxScaler = OSystem_MorphOS::FindScaler( ToolValue )) == OSystem_MorphOS::ST_INVALID )
if ((ScummGfxScaler = MorphOSScaler::FindByName(ToolValue)) == ST_INVALID)
{
FreeDiskObject( dobj );
exit( 1 );
FreeDiskObject(dobj);
exit(1);
}
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MUSIC" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "MUSIC"))
{
if( !(ScummMusicDriver = FindMusicDriver( ToolValue )) )
if (!(ScummMusicDriver = FindMusicDriver(ToolValue)))
{
FreeDiskObject( dobj );
exit( 1 );
FreeDiskObject(dobj);
exit(1);
}
args[ USG_MUSIC ] = (ULONG)&ScummMusicDriver;
args[USG_MUSIC] = (ULONG) &ScummMusicDriver;
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MIDIUNIT" ) )
ScummMidiUnit = atoi( ToolValue );
if( ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "MIDIUNIT"))
ScummMidiUnit = atoi(ToolValue);
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MUSICVOL" ) )
if( ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "MUSICVOL"))
{
int vol = atoi( ToolValue );
if( vol >= 0 && vol <= 100 )
int vol = atoi(ToolValue);
if (vol >= 0 && vol <= 100)
{
ScummMidiVolume = vol;
args[ USG_MUSICVOL ] = (ULONG)&ScummMidiVolume;
args[USG_MUSICVOL] = (ULONG) &ScummMidiVolume;
}
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "SFXVOL" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "SFXVOL"))
{
int vol = atoi( ToolValue );
if( vol >= 0 && vol <= 255 )
int vol = atoi(ToolValue);
if (vol >= 0 && vol <= 255)
{
ScummSfxVolume = vol;
args[ USG_SFXVOL ] = (ULONG)&ScummSfxVolume;
args[USG_SFXVOL] = (ULONG) &ScummSfxVolume;
}
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "TEMPO" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "TEMPO"))
{
ScummMidiTempo = atoi( ToolValue );
args[ USG_TEMPO ] = (ULONG)&ScummMidiTempo;
ScummMidiTempo = atoi(ToolValue);
args[USG_TEMPO] = (ULONG) &ScummMidiTempo;
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "TALKSPEED" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "TALKSPEED"))
{
ScummTalkSpeed = atoi( ToolValue );
args[ USG_TALKSPEED ] = (ULONG)&ScummMidiTempo;
ScummTalkSpeed = atoi(ToolValue);
args[USG_TALKSPEED] = (ULONG) &ScummMidiTempo;
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "SUBTITLES" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "SUBTITLES"))
{
if( MatchToolValue( ToolValue, "YES" ) )
args[ USG_NOSUBTITLES ] = FALSE;
else if( MatchToolValue( ToolValue, "NO" ) )
args[ USG_NOSUBTITLES ] = TRUE;
if (MatchToolValue(ToolValue, "YES"))
args[USG_NOSUBTITLES] = FALSE;
else if (MatchToolValue(ToolValue, "NO"))
args[USG_NOSUBTITLES] = TRUE;
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "AMIGA" ) )
if (ToolValue = (char *) FindToolType(dobj->do_ToolTypes, "AMIGA"))
{
if( MatchToolValue( ToolValue, "YES" ) )
args[ USG_AMIGA ] = FALSE;
else if( MatchToolValue( ToolValue, "NO" ) )
args[ USG_AMIGA ] = TRUE;
if (MatchToolValue(ToolValue, "YES"))
args[USG_AMIGA] = FALSE;
else if (MatchToolValue(ToolValue, "NO"))
args[USG_AMIGA] = TRUE;
}
FreeDiskObject( dobj );
FreeDiskObject(dobj);
}
#undef main
@ -240,120 +241,119 @@ int main()
{
int delta;
int last_time, new_time;
char *argv[ 20 ];
char musicvol[ 6 ], sfxvol[ 6 ], talkspeed[ 12 ], tempo[ 12 ], scaler[ 14 ];
char *SVMScalers[] = { "", "normal", "2x", "advmame2x", "supereagle", "super2xsai" };
char *argv[20];
char musicvol[6], sfxvol[6], talkspeed[12], tempo[12], scaler[14];
int argc = 0;
InitSemaphore( &ScummSoundThreadRunning );
InitSemaphore( &ScummMusicThreadRunning );
InitSemaphore(&ScummSoundThreadRunning);
InitSemaphore(&ScummMusicThreadRunning);
g_scumm = NULL;
atexit( &close_resources );
atexit(&close_resources);
if( _WBenchMsg == NULL )
if (_WBenchMsg == NULL)
{
/* Parse the command line here */
ScummArgs = ReadArgs( usageTemplate, args, NULL );
if( ScummArgs == NULL )
ScummArgs = ReadArgs(usageTemplate, args, NULL);
if (ScummArgs == NULL)
{
puts( "Error in command line - type \"ScummVM ?\" for usage.\n" );
exit( 1 );
puts("Error in command line - type \"ScummVM ?\" for usage.");
exit(1);
}
if( args[ USG_STORY ] )
if (args[USG_STORY])
{
ScummStory = (char *)AllocVec( strlen( (char *)args[ USG_STORY ] )+1, MEMF_PUBLIC );
strcpy( ScummStory, (char *)args[ USG_STORY ] );
ScummStory = (char *) AllocVec(strlen((char *) args[USG_STORY])+1, MEMF_PUBLIC);
strcpy(ScummStory, (char *) args[USG_STORY]);
}
if( args[ USG_DATAPATH ] )
if (args[USG_DATAPATH])
{
ScummPath = (char *)AllocVec( strlen( (char *)args[ USG_DATAPATH ] )+4, MEMF_PUBLIC );
strcpy( ScummPath, "-p" );
strcat( ScummPath, (char *)args[ USG_DATAPATH ] );
ScummPath = (char *) AllocVec(strlen((char *) args[USG_DATAPATH])+4, MEMF_PUBLIC);
strcpy(ScummPath, "-p");
strcat(ScummPath, (char *) args[USG_DATAPATH]);
}
if( args[ USG_SCALER ] )
if (args[USG_SCALER])
{
if( (ScummGfxScaler = OSystem_MorphOS::FindScaler( (char *)args[ USG_SCALER ] )) == OSystem_MorphOS::ST_INVALID )
exit( 1 );
if ((ScummGfxScaler = MorphOSScaler::FindByName((char *) args[USG_SCALER])) == ST_INVALID)
exit(1);
}
if( args[ USG_MUSIC ] )
if (args[USG_MUSIC])
{
if( !(ScummMusicDriver = FindMusicDriver( (char *)args[ USG_MUSIC ] )) )
exit( 1 );
if (!(ScummMusicDriver = FindMusicDriver((char *) args[USG_MUSIC])))
exit(1);
}
if( args[ USG_MIDIUNIT ] )
ScummMidiUnit = *((LONG *)args[ USG_MIDIUNIT ]);
if (args[USG_MIDIUNIT])
ScummMidiUnit = *((LONG *) args[USG_MIDIUNIT]);
if( args[ USG_TEMPO ] )
ScummMidiTempo = *((LONG *)args[ USG_TEMPO ]);
if (args[USG_TEMPO])
ScummMidiTempo = *((LONG *) args[USG_TEMPO]);
if( args[ USG_MUSICVOL ] )
ScummMidiVolume = *((LONG *)args[ USG_MUSICVOL ]);
if (args[USG_MUSICVOL])
ScummMidiVolume = *((LONG *) args[USG_MUSICVOL]);
if( args[ USG_SFXVOL ] )
ScummSfxVolume = *((LONG *)args[ USG_SFXVOL ]);
if (args[USG_SFXVOL])
ScummSfxVolume = *((LONG *) args[USG_SFXVOL]);
if( args[ USG_TALKSPEED ] )
ScummTalkSpeed = *((LONG *)args[ USG_TALKSPEED ]);
if (args[USG_TALKSPEED])
ScummTalkSpeed = *((LONG *) args[USG_TALKSPEED]);
}
else
{
/* We've been started from Workbench */
ReadToolTypes( &_WBenchMsg->sm_ArgList[ 0 ] );
if( _WBenchMsg->sm_NumArgs > 1 )
ReadToolTypes(&_WBenchMsg->sm_ArgList[0]);
if (_WBenchMsg->sm_NumArgs > 1)
{
ReadToolTypes( &_WBenchMsg->sm_ArgList[ 1 ] );
OrigDirLock = CurrentDir( _WBenchMsg->sm_ArgList[ 1 ].wa_Lock );
ReadToolTypes(&_WBenchMsg->sm_ArgList[1]);
OrigDirLock = CurrentDir(_WBenchMsg->sm_ArgList[1].wa_Lock);
}
}
if( ScummPath )
if (ScummPath)
{
char c = ScummPath[ strlen( ScummPath )-1 ];
if( c != '/' && c != ':' )
strcat( ScummPath, "/" );
char c = ScummPath[strlen(ScummPath)-1];
if (c != '/' && c != ':')
strcat(ScummPath, "/");
}
argv[ argc++ ] = "ScummVM";
if( ScummPath ) argv[ argc++ ] = ScummPath;
if( !args[ USG_WBWINDOW ] ) argv[ argc++ ] = "-f";
if( args[ USG_NOSUBTITLES ] ) argv[ argc++ ] = "-n";
if( args[ USG_AMIGA ] ) argv[ argc++ ] = "-a";
if( args[ USG_MUSIC ] ) argv[ argc++ ] = ScummMusicDriver;
if( ScummGfxScaler != OSystem_MorphOS::ST_INVALID )
argv[argc++] = "ScummVM";
if (ScummPath) argv[argc++] = ScummPath;
if (!args[ USG_WBWINDOW ]) argv[argc++] = "-f";
if (args[ USG_NOSUBTITLES ]) argv[argc++] = "-n";
if (args[ USG_AMIGA ]) argv[argc++] = "-a";
if (args[ USG_MUSIC ]) argv[argc++] = ScummMusicDriver;
if (ScummGfxScaler != ST_INVALID)
{
sprintf( scaler, "-g%s", SVMScalers[ (int)ScummGfxScaler ] );
argv[ argc++ ] = scaler;
sprintf(scaler, "-g%s", MorphOSScaler::GetParamName(ScummGfxScaler));
argv[argc++] = scaler;
}
else
argv[ argc++ ] = "-gsuper2xsai";
if( args[ USG_MUSICVOL ] && ScummMidiVolume >= 0 && ScummMidiVolume <= 100 )
argv[argc++] = "-gsuper2xsai";
if (args[USG_MUSICVOL] && ScummMidiVolume >= 0 && ScummMidiVolume <= 100)
{
sprintf( musicvol, "-m%d", ScummMidiVolume );
argv[ argc++ ] = musicvol;
sprintf(musicvol, "-m%d", ScummMidiVolume);
argv[argc++] = musicvol;
}
if( args[ USG_SFXVOL ] && ScummSfxVolume >= 0 && ScummSfxVolume <= 255 )
if (args[USG_SFXVOL] && ScummSfxVolume >= 0 && ScummSfxVolume <= 255)
{
sprintf( sfxvol, "-s%d", ScummSfxVolume );
argv[ argc++ ] = sfxvol;
sprintf(sfxvol, "-s%d", ScummSfxVolume);
argv[argc++] = sfxvol;
}
if( args[ USG_TEMPO ] && ScummMidiTempo > 0 )
if (args[USG_TEMPO] && ScummMidiTempo > 0)
{
sprintf( tempo, "-t%lx", ScummMidiTempo );
argv[ argc++ ] = tempo;
sprintf(tempo, "-t%lx", ScummMidiTempo);
argv[argc++] = tempo;
}
if( args[ USG_TALKSPEED ] && ScummTalkSpeed >= 0 && ScummTalkSpeed <= 255 )
if (args[USG_TALKSPEED] && ScummTalkSpeed >= 0 && ScummTalkSpeed <= 255)
{
sprintf( talkspeed, "-y%d", ScummTalkSpeed );
argv[ argc++ ] = talkspeed;
sprintf(talkspeed, "-y%d", ScummTalkSpeed);
argv[argc++] = talkspeed;
}
argv[ argc++ ] = ScummStory;
argv[argc++] = ScummStory;
return morphos_main( argc, argv );
return morphos_main(argc, argv);
}

View File

@ -152,22 +152,24 @@ void Timer::TimerService(Timer *this_ptr)
if (tmsg->tsm_Interval > 1000)
unit = UNIT_VBLANK;
OSystem_MorphOS::OpenATimer(&timer_slots[timers].ts_Port, (IORequest **) &timer_slots[timers].ts_IORequest, unit);
timer_slots[timers].ts_Callback = tmsg->tsm_Callback;
timer_slots[timers].ts_Interval = tmsg->tsm_Interval;
timer_slots[timers].ts_SignalBit = 1 << timer_slots[timers].ts_Port->mp_SigBit;
if (OSystem_MorphOS::OpenATimer(&timer_slots[timers].ts_Port, (IORequest **) &timer_slots[timers].ts_IORequest, unit))
{
timer_slots[timers].ts_Callback = tmsg->tsm_Callback;
timer_slots[timers].ts_Interval = tmsg->tsm_Interval;
timer_slots[timers].ts_SignalBit = 1 << timer_slots[timers].ts_Port->mp_SigBit;
signal_mask |= timer_slots[timers].ts_SignalBit;
timer_bits |= timer_slots[timers].ts_SignalBit;
signal_mask |= timer_slots[timers].ts_SignalBit;
timer_bits |= timer_slots[timers].ts_SignalBit;
timerequest *req = timer_slots[timers].ts_IORequest;
interval = timer_slots[timers].ts_Interval;
req->tr_node.io_Command = TR_ADDREQUEST;
req->tr_time.tv_secs = interval/1000;
req->tr_time.tv_micro = (interval%1000)*1000;
SendIO(req);
timerequest *req = timer_slots[timers].ts_IORequest;
interval = timer_slots[timers].ts_Interval;
req->tr_node.io_Command = TR_ADDREQUEST;
req->tr_time.tv_secs = interval/1000;
req->tr_time.tv_micro = (interval%1000)*1000;
SendIO(req);
timers++;
timers++;
}
}
break;
@ -216,7 +218,7 @@ void Timer::TimerService(Timer *this_ptr)
(*timer_slots[t].ts_Callback)(interval);
GetSysTime(&end_callback);
SubTime(&end_callback, &start_callback);
interval -= end_callback.tv_sec*1000+end_callback.tv_micro/1000+20;
interval -= end_callback.tv_sec*1000+end_callback.tv_micro/1000+40;
req->tr_node.io_Command = TR_ADDREQUEST;
req->tr_time.tv_secs = interval/1000;