mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
UIQ3 update, some makefile unification, rm old configs, stuff
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@569 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
a6e5aa4181
commit
ca482e5de8
66 changed files with 1748 additions and 1377 deletions
|
@ -15,6 +15,7 @@
|
|||
#include "audio_mediaserver.h"
|
||||
#include "debug.h"
|
||||
|
||||
//#define DEBUG_UNDERFLOWS
|
||||
//#undef DEBUGPRINT
|
||||
//#define DEBUGPRINT(x...)
|
||||
|
||||
|
@ -31,16 +32,16 @@ const TInt KMaxUnderflows = 50; // max underflows/API errors we are going allow
|
|||
*
|
||||
*******************************************/
|
||||
|
||||
CGameAudioMS::CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec)
|
||||
: iRate(aRate), iStereo(aStereo), iWritesPerSec(aWritesPerSec)
|
||||
CGameAudioMS::CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume)
|
||||
: iRate(aRate), iStereo(aStereo), iWritesPerSec(aWritesPerSec), iVolume(aVolume)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CGameAudioMS* CGameAudioMS::NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec)
|
||||
CGameAudioMS* CGameAudioMS::NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume)
|
||||
{
|
||||
DEBUGPRINT(_L("CGameAudioMS::NewL(%i, %i, %i)"), aRate, aStereo, aWritesPerSec);
|
||||
CGameAudioMS* self = new(ELeave) CGameAudioMS(aRate, aStereo, aWritesPerSec);
|
||||
DEBUGPRINT(_L("CGameAudioMS::NewL(%i, %i, %i, %i)"), aRate, aStereo, aWritesPerSec, aVolume);
|
||||
CGameAudioMS* self = new(ELeave) CGameAudioMS(aRate, aStereo, aWritesPerSec, aVolume);
|
||||
CleanupStack::PushL(self);
|
||||
self->ConstructL();
|
||||
CleanupStack::Pop(); // self
|
||||
|
@ -85,25 +86,29 @@ void CGameAudioMS::ConstructL()
|
|||
iMdaAudioDataSettings.iCaps = TMdaAudioDataSettings::ESampleRateFixed | iMdaAudioDataSettings.iSampleRate;
|
||||
iMdaAudioDataSettings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting;
|
||||
|
||||
int pcmFrames = iRate / iWritesPerSec;
|
||||
pcmFrames += iRate - (iRate / iWritesPerSec) * iWritesPerSec; // add division remainder too for our buffer size
|
||||
iBufferedFrames = iWritesPerSec / KUpdatesPerSec;
|
||||
iMaxWriteSamples = iRate / iWritesPerSec;
|
||||
if (iRate % iWritesPerSec)
|
||||
iMaxWriteSamples++;
|
||||
int bufferedFrames = iWritesPerSec / KUpdatesPerSec;
|
||||
|
||||
TInt bytesPerFrame = pcmFrames << (iStereo?2:1);
|
||||
iBufferSize = iMaxWriteSamples * (iStereo ? 4 : 2);
|
||||
iBufferSize *= bufferedFrames;
|
||||
for (TInt i=0 ; i<KSoundBuffers ; i++)
|
||||
{
|
||||
iSoundBuffers[i] = HBufC8::NewL(bytesPerFrame * iBufferedFrames);
|
||||
iSoundBuffers[i]->Des().FillZ (bytesPerFrame * iBufferedFrames);
|
||||
iSoundBuffers[i] = HBufC8::NewL(iBufferSize);
|
||||
iSoundBuffers[i]->Des().FillZ (iBufferSize);
|
||||
}
|
||||
|
||||
iCurrentBuffer = 0;
|
||||
iCurrentBufferSize = 0;
|
||||
|
||||
DEBUGPRINT(_L("sound: iMaxWriteSamples: %i, iBufferSize: %i"), iMaxWriteSamples, iBufferSize);
|
||||
|
||||
// here we actually test if we can create and open CMdaAudioOutputStream at all, but really create and use it later.
|
||||
iMdaAudioOutputStream = CMdaAudioOutputStream::NewL(iListener, iServer);
|
||||
if(iMdaAudioOutputStream) {
|
||||
iVolume = iMdaAudioOutputStream->MaxVolume();
|
||||
DEBUGPRINT(_L("MaxVolume: %i"), iVolume);
|
||||
if (iMdaAudioOutputStream) {
|
||||
if (iVolume < 0 || iVolume > iMdaAudioOutputStream->MaxVolume())
|
||||
iVolume = iMdaAudioOutputStream->MaxVolume();
|
||||
delete iMdaAudioOutputStream;
|
||||
iMdaAudioOutputStream = 0;
|
||||
}
|
||||
|
@ -113,11 +118,18 @@ void CGameAudioMS::ConstructL()
|
|||
// to be used when iSoundBuffers are used directly
|
||||
TInt16 *CGameAudioMS::NextFrameL(TInt aPcmFrames)
|
||||
{
|
||||
iCurrentPosition += aPcmFrames << (iStereo?1:0);
|
||||
iCurrentBufferSize += aPcmFrames << (iStereo?2:1);
|
||||
TInt mul = iStereo ? 4 : 2;
|
||||
TInt bytes = aPcmFrames * mul;
|
||||
iCurrentPosition += bytes / 2;
|
||||
iCurrentBufferSize += bytes;
|
||||
|
||||
if (++iFrameCount == iBufferedFrames)
|
||||
if (aPcmFrames > iMaxWriteSamples) {
|
||||
DEBUGPRINT(_L("too many samples: %i > %i"), aPcmFrames, iMaxWriteSamples);
|
||||
}
|
||||
|
||||
if (iCurrentBufferSize + iMaxWriteSamples * mul > iBufferSize)
|
||||
{
|
||||
//DEBUGPRINT(_L("write on iCurrentBufferSize %i"), iCurrentBufferSize);
|
||||
WriteBlockL();
|
||||
}
|
||||
|
||||
|
@ -162,9 +174,9 @@ void CGameAudioMS::WriteBlockL()
|
|||
}
|
||||
}
|
||||
|
||||
iFrameCount = 0;
|
||||
if (++iCurrentBuffer == KSoundBuffers)
|
||||
iCurrentBuffer = 0;
|
||||
iSoundBuffers[iCurrentBuffer]->Des().SetMax();
|
||||
iCurrentPosition = (TInt16*) iSoundBuffers[iCurrentBuffer]->Ptr();
|
||||
iCurrentBufferSize = 0;
|
||||
}
|
||||
|
@ -189,7 +201,6 @@ TInt16 *CGameAudioMS::ResumeL()
|
|||
iListener.iIsOpen = ETrue;
|
||||
iListener.iUnderflowed = 1;
|
||||
iListener.iLastError = 0;
|
||||
iFrameCount = 0;
|
||||
iCurrentBufferSize = 0;
|
||||
iCurrentPosition = (TInt16*) iSoundBuffers[iCurrentBuffer]->Ptr();
|
||||
return iCurrentPosition;
|
||||
|
@ -198,7 +209,9 @@ TInt16 *CGameAudioMS::ResumeL()
|
|||
// handles underflow condition
|
||||
void CGameAudioMS::UnderflowedL()
|
||||
{
|
||||
#ifdef DEBUG_UNDERFLOWS
|
||||
DEBUGPRINT(_L("UnderflowedL()"));
|
||||
#endif
|
||||
|
||||
if (iListener.iLastError != KErrUnderflow)
|
||||
{
|
||||
|
@ -243,23 +256,30 @@ void CGameAudioMS::WaitForOpenToCompleteL()
|
|||
User::LeaveIfError(KErrNotSupported);
|
||||
}
|
||||
|
||||
void CGameAudioMS::ChangeVolume(TInt aUp)
|
||||
TInt CGameAudioMS::ChangeVolume(TInt aUp)
|
||||
{
|
||||
//DEBUGPRINT(_L("CGameAudioMS::ChangeVolume(%i)"), aUp);
|
||||
|
||||
if (iMdaAudioOutputStream) {
|
||||
if (aUp) {
|
||||
if (iVolume < iMdaAudioOutputStream->MaxVolume()) iVolume+=5;
|
||||
iVolume += 5;
|
||||
if (iVolume > iMdaAudioOutputStream->MaxVolume())
|
||||
iVolume = iMdaAudioOutputStream->MaxVolume();
|
||||
} else {
|
||||
if (iVolume > 0) iVolume-=5;
|
||||
iVolume -= 5;
|
||||
if (iVolume < 0) iVolume = 0;
|
||||
}
|
||||
iMdaAudioOutputStream->SetVolume(iVolume);
|
||||
}
|
||||
|
||||
return iVolume;
|
||||
}
|
||||
|
||||
void TGameAudioEventListener::MaoscOpenComplete(TInt aError)
|
||||
{
|
||||
#ifdef DEBUG_UNDERFLOWS
|
||||
DEBUGPRINT(_L("CGameAudioMS::MaoscOpenComplete, error=%d"), aError);
|
||||
#endif
|
||||
|
||||
iIsOpen = ETrue;
|
||||
if(aError) {
|
||||
|
@ -284,7 +304,9 @@ void TGameAudioEventListener::MaoscBufferCopied(TInt aError, const TDesC8& aBuff
|
|||
|
||||
void TGameAudioEventListener::MaoscPlayComplete(TInt aError)
|
||||
{
|
||||
#ifdef DEBUG_UNDERFLOWS
|
||||
DEBUGPRINT(_L("CGameAudioMS::MaoscPlayComplete: %i"), aError);
|
||||
#endif
|
||||
if(aError) {
|
||||
iLastError = aError;
|
||||
iUnderflowed++; // never happened to me while testing, but just in case
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
#ifndef __AUDIO_MEDIASERVER_H
|
||||
#define __AUDIO_MEDIASERVER_H
|
||||
|
||||
#include <Mda\Common\Audio.h>
|
||||
#include <MdaAudioOutputStream.h>
|
||||
#include <mda/common/audio.h>
|
||||
#include <mdaaudiooutputstream.h>
|
||||
|
||||
//#include "audio.h"
|
||||
#include "polledas.h"
|
||||
#include "PolledAS.h"
|
||||
|
||||
const TInt KSoundBuffers = 4;
|
||||
|
||||
|
@ -44,12 +44,12 @@ public: // implements IGameAudio
|
|||
TInt16 *NextFrameL(TInt aPcmFrames);
|
||||
TInt16 *ResumeL();
|
||||
void Pause();
|
||||
void ChangeVolume(TInt aUp);
|
||||
TInt ChangeVolume(TInt aUp);
|
||||
|
||||
public:
|
||||
~CGameAudioMS();
|
||||
CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec);
|
||||
static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec);
|
||||
CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume);
|
||||
static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume);
|
||||
|
||||
protected:
|
||||
void WriteBlockL();
|
||||
|
@ -70,12 +70,12 @@ protected:
|
|||
CPolledActiveScheduler *iScheduler;
|
||||
|
||||
HBufC8* iSoundBuffers[KSoundBuffers];
|
||||
TInt iWritesPerSec;
|
||||
TInt iBufferedFrames;
|
||||
TInt iWritesPerSec; // fps, may be more actual writes
|
||||
TInt iMaxWriteSamples; // max samples per write
|
||||
TInt16* iCurrentPosition;
|
||||
TInt iCurrentBuffer;
|
||||
TInt iCurrentBufferSize;
|
||||
TInt iFrameCount;
|
||||
TInt iCurrentBuffer; // active buffer
|
||||
TInt iCurrentBufferSize; // bytes filled in buffer
|
||||
TInt iBufferSize;
|
||||
CMdaServer* iServer;
|
||||
|
||||
TInt64 iTime;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
@ vim:filetype=armasm
|
||||
@ some color conversion and blitting routines
|
||||
|
||||
@ (c) Copyright 2006, notaz
|
||||
|
@ -693,3 +694,13 @@ vidClear:
|
|||
orr r12, #(240/16-1)<<16
|
||||
b .loopVidClear
|
||||
|
||||
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
.equ EExecSetExceptionHandler, (90)
|
||||
|
||||
.global my_SetExceptionHandler
|
||||
|
||||
my_SetExceptionHandler:
|
||||
mov ip, lr
|
||||
swi EExecSetExceptionHandler
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#include <e32svr.h> // RDebug
|
||||
#include "debug.h"
|
||||
|
||||
//#define LOG_FILE "C:\\logs\\pico.log"
|
||||
#define LOG_FILE _L("D:\\pico.log")
|
||||
|
||||
#ifdef __WINS__
|
||||
|
||||
void ExceptionHandler(TExcType exc) {}
|
||||
|
@ -40,6 +43,7 @@ static const wchar_t * const exception_names[] = {
|
|||
};
|
||||
|
||||
|
||||
#if 0
|
||||
static void getASpace(TUint *code_start, TUint *code_end, TUint *stack_start, TUint *stack_end)
|
||||
{
|
||||
TUint pc, sp;
|
||||
|
@ -63,22 +67,24 @@ static void getASpace(TUint *code_start, TUint *code_end, TUint *stack_start, TU
|
|||
chunk.Close();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// tmp
|
||||
#if defined(__DEBUG_PRINT)
|
||||
extern "C" char *debugString();
|
||||
extern "C" char *PDebugMain();
|
||||
#endif
|
||||
|
||||
// our very own exception handler
|
||||
void ExceptionHandler(TExcType exc)
|
||||
{
|
||||
DEBUGPRINT(_L("ExceptionHandler() called!!!")); // this seems to never be called
|
||||
|
||||
#if 0
|
||||
TUint lr, sp, i;
|
||||
TUint stack_end = 0; // ending address of our stack chunk
|
||||
TUint code_start = 0, code_end = 0; // starting and ending addresses of our code chunk
|
||||
TUint guessed_address = 0;
|
||||
|
||||
DEBUGPRINT(_L("ExceptionHandler()")); // this seems to never be called
|
||||
|
||||
asm volatile ("str lr, %0" : "=m" (lr) );
|
||||
asm volatile ("str sp, %0" : "=m" (sp) );
|
||||
|
||||
|
@ -136,11 +142,11 @@ void ExceptionHandler(TExcType exc)
|
|||
|
||||
// tmp
|
||||
#if defined(__DEBUG_PRINT)
|
||||
char *ps, *cstr = debugString();
|
||||
char *ps, *cstr = PDebugMain();
|
||||
for(ps = cstr; *ps; ps++) {
|
||||
if(*ps == '\n') {
|
||||
*ps = 0;
|
||||
dprintf(cstr);
|
||||
lprintf(cstr);
|
||||
cstr = ps+1;
|
||||
}
|
||||
}
|
||||
|
@ -154,11 +160,34 @@ void ExceptionHandler(TExcType exc)
|
|||
// more descriptive replacement of "KERN-EXEC 3" panic
|
||||
buff1.Format(_L("K-EX3: %S"), &ptrExc);
|
||||
User::Panic(buff1, exc);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // ifdef __WINS__
|
||||
|
||||
|
||||
#if 1 // def __DEBUG_PRINT_C
|
||||
#include <stdarg.h> // va_*
|
||||
#include <stdio.h> // vsprintf
|
||||
|
||||
// debug print from c code
|
||||
extern "C" void lprintf(char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[512];
|
||||
int len;
|
||||
|
||||
va_start(args,format);
|
||||
len = vsprintf(buffer,format,args);
|
||||
va_end(args);
|
||||
if (buffer[len-1] == '\n')
|
||||
buffer[len-1] = 0;
|
||||
|
||||
DEBUGPRINT(_L("%S"), DO_CONV(buffer));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__DEBUG_PRINT) || defined(__WINS__)
|
||||
|
||||
#ifndef __DLL__
|
||||
|
@ -172,24 +201,6 @@ void ExceptionHandler(TExcType exc)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DEBUG_PRINT_C
|
||||
#include <stdarg.h> // va_*
|
||||
#include <stdio.h> // vsprintf
|
||||
|
||||
// debug print from c code
|
||||
extern "C" void dprintf(char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[512];
|
||||
|
||||
va_start(args,format);
|
||||
vsprintf(buffer,format,args);
|
||||
va_end(args);
|
||||
|
||||
DEBUGPRINT(_L("%S"), DO_CONV(buffer));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __DEBUG_PRINT_FILE
|
||||
#include <f32file.h>
|
||||
|
||||
|
@ -201,12 +212,12 @@ void ExceptionHandler(TExcType exc)
|
|||
{
|
||||
// try to open
|
||||
logMutex.CreateLocal();
|
||||
RFs fserv;
|
||||
/*RFs fserv;
|
||||
fserv.Connect();
|
||||
RFile logFile;
|
||||
logFile.Replace(fserv, _L("C:\\logs\\pico.log"), EFileWrite|EFileShareAny);
|
||||
logFile.Replace(fserv, LOG_FILE, EFileWrite|EFileShareAny);
|
||||
logFile.Close();
|
||||
fserv.Close();
|
||||
fserv.Close();*/
|
||||
}
|
||||
|
||||
// debug print to file
|
||||
|
@ -225,7 +236,7 @@ void ExceptionHandler(TExcType exc)
|
|||
|
||||
RThread thisThread;
|
||||
RFile logFile;
|
||||
res = logFile.Open(fserv, _L("C:\\logs\\pico.log"), EFileWrite|EFileShareAny);
|
||||
res = logFile.Open(fserv, LOG_FILE, EFileWrite|EFileShareAny);
|
||||
if(res) goto fail1;
|
||||
|
||||
logFile.Size(size); logFile.Seek(ESeekStart, size);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
void dprintf(char *format, ...);
|
||||
void lprintf(char *format, ...);
|
||||
#endif
|
||||
#else
|
||||
#define DEBUGPRINT(x...)
|
||||
|
|
|
@ -17,14 +17,16 @@
|
|||
#include "debug.h"
|
||||
#include "../Engine.h"
|
||||
|
||||
#include "../../../pico/picoInt.h"
|
||||
#include <Pico/PicoInt.h>
|
||||
#include "../../common/emu.h"
|
||||
#include "../emu.h"
|
||||
#include "vid.h"
|
||||
#include "polledAS.h"
|
||||
#include "PolledAS.h"
|
||||
//#include "audio.h"
|
||||
#include "audio_mediaserver.h"
|
||||
|
||||
#include <EZlib.h>
|
||||
#include "../../../zlib/gzio_symb.h"
|
||||
//#include <ezlib.h>
|
||||
#include <zlib/zlib.h>
|
||||
|
||||
|
||||
//#define BENCHMARK
|
||||
|
@ -78,21 +80,20 @@ const char *actionNames[] = {
|
|||
// globals are allowed, so why not to (ab)use them?
|
||||
//TInt machineUid = 0;
|
||||
int gamestate = PGS_Paused, gamestate_next = PGS_Paused;
|
||||
TPicoConfig *currentConfig = 0;
|
||||
static char noticeMsg[64]; // notice msg to draw
|
||||
char *loadrom_fname = NULL;
|
||||
int loadrom_result = 0;
|
||||
static timeval noticeMsgTime = { 0, 0 }; // when started showing
|
||||
static CGameAudioMS *gameAudio = 0; // the audio object itself
|
||||
static int reset_timing, pico_was_reset;
|
||||
static int state_slot = 0;
|
||||
extern const char *RomFileName;
|
||||
static int reset_timing;
|
||||
extern int pico_was_reset;
|
||||
extern RSemaphore initSemaphore;
|
||||
extern RSemaphore pauseSemaphore;
|
||||
extern RSemaphore loadWaitSemaphore;
|
||||
|
||||
// some forward declarations
|
||||
static void MainInit();
|
||||
static void MainExit();
|
||||
static void DumpMemInfo();
|
||||
void MainOldCleanup();
|
||||
|
||||
|
||||
class TPicoDirectScreenAccess : public MDirectScreenAccess
|
||||
|
@ -128,24 +129,8 @@ public:
|
|||
};
|
||||
|
||||
|
||||
static int snd_excess_add = 0, snd_excess_cnt = 0; // hack
|
||||
|
||||
static void updateSound(void)
|
||||
static void updateSound(int len)
|
||||
{
|
||||
int len = PsndLen;
|
||||
|
||||
snd_excess_cnt += snd_excess_add;
|
||||
if (snd_excess_cnt >= 0x10000) {
|
||||
snd_excess_cnt -= 0x10000;
|
||||
if (PicoOpt&8) {
|
||||
PsndOut[len*2] = PsndOut[len*2-2];
|
||||
PsndOut[len*2+1] = PsndOut[len*2-1];
|
||||
} else {
|
||||
PsndOut[len] = PsndOut[len-1];
|
||||
}
|
||||
len++;
|
||||
}
|
||||
|
||||
PsndOut = gameAudio->NextFrameL(len);
|
||||
if(!PsndOut) { // sound output problems?
|
||||
strcpy(noticeMsg, "SOUND@OUTPUT@ERROR;@SOUND@DISABLED");
|
||||
|
@ -190,12 +175,16 @@ static void TargetEpocGameL()
|
|||
MainInit();
|
||||
buff[0] = 0;
|
||||
|
||||
PicoInit();
|
||||
|
||||
// just to keep the backlight on (works only on UIQ2)
|
||||
//blevent.Set(TRawEvent::EActive);
|
||||
|
||||
// loop?
|
||||
for(;;) {
|
||||
if(gamestate == PGS_Running) {
|
||||
for(;;)
|
||||
{
|
||||
if (gamestate == PGS_Running)
|
||||
{
|
||||
// switch context to other thread
|
||||
User::After(50000);
|
||||
// prepare window and stuff
|
||||
|
@ -217,15 +206,14 @@ static void TargetEpocGameL()
|
|||
if(!noticeMsgTime.tv_sec && pico_was_reset)
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
|
||||
if (PsndOut) {
|
||||
snd_excess_cnt = 0;
|
||||
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
|
||||
}
|
||||
// prepare CD buffer
|
||||
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
|
||||
|
||||
pico_was_reset = 0;
|
||||
reset_timing = 1;
|
||||
|
||||
while(gamestate == PGS_Running) {
|
||||
while (gamestate == PGS_Running)
|
||||
{
|
||||
gettimeofday(&tval, 0);
|
||||
if(reset_timing) {
|
||||
reset_timing = 0;
|
||||
|
@ -242,7 +230,8 @@ static void TargetEpocGameL()
|
|||
}
|
||||
|
||||
// second changed?
|
||||
if(thissec != tval.tv_sec) {
|
||||
if (thissec != tval.tv_sec)
|
||||
{
|
||||
#ifdef BENCHMARK
|
||||
static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4];
|
||||
if(++bench == 10) {
|
||||
|
@ -254,14 +243,14 @@ static void TargetEpocGameL()
|
|||
bench_fps += frames_shown;
|
||||
sprintf(buff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);
|
||||
#else
|
||||
if(currentConfig->iFlags & 2)
|
||||
if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
|
||||
sprintf(buff, "%02i/%02i", frames_shown, frames_done);
|
||||
#endif
|
||||
|
||||
|
||||
thissec = tval.tv_sec;
|
||||
|
||||
if(PsndOut == 0 && currentConfig->iFrameskip >= 0) {
|
||||
if(PsndOut == 0 && currentConfig.Frameskip >= 0) {
|
||||
frames_done = frames_shown = 0;
|
||||
} else {
|
||||
// it is quite common for this implementation to leave 1 fame unfinished
|
||||
|
@ -278,8 +267,10 @@ static void TargetEpocGameL()
|
|||
|
||||
|
||||
lim_time = (frames_done+1) * target_frametime;
|
||||
if(currentConfig->iFrameskip >= 0) { // frameskip enabled
|
||||
for(i = 0; i < currentConfig->iFrameskip; i++) {
|
||||
if (currentConfig.Frameskip >= 0) // frameskip enabled
|
||||
{
|
||||
for (i = 0; i < currentConfig.Frameskip && gamestate == PGS_Running; i++)
|
||||
{
|
||||
CGameWindow::DoKeys();
|
||||
SkipFrame(); frames_done++;
|
||||
if (PsndOut) { // do framelimitting if sound is enabled
|
||||
|
@ -291,13 +282,17 @@ static void TargetEpocGameL()
|
|||
}
|
||||
lim_time += target_frametime;
|
||||
}
|
||||
} else if(tval.tv_usec > lim_time) { // auto frameskip
|
||||
}
|
||||
else if(tval.tv_usec > lim_time) { // auto frameskip
|
||||
// no time left for this frame - skip
|
||||
CGameWindow::DoKeys();
|
||||
SkipFrame(); frames_done++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// we might have lost focus already
|
||||
if (gamestate != PGS_Running) break;
|
||||
|
||||
CGameWindow::DoKeys();
|
||||
PicoFrame();
|
||||
|
||||
|
@ -306,7 +301,7 @@ static void TargetEpocGameL()
|
|||
if(thissec != tval.tv_sec) tval.tv_usec+=1000000;
|
||||
|
||||
// sleep if we are still too fast
|
||||
if(PsndOut != 0 || currentConfig->iFrameskip < 0)
|
||||
if(PsndOut != 0 || currentConfig.Frameskip < 0)
|
||||
{
|
||||
// TODO: check if User::After() is accurate
|
||||
gettimeofday(&tval, 0);
|
||||
|
@ -324,18 +319,36 @@ static void TargetEpocGameL()
|
|||
vidDrawFrame(notice, buff, frames_shown);
|
||||
|
||||
frames_done++; frames_shown++;
|
||||
}
|
||||
} // while
|
||||
|
||||
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
|
||||
|
||||
// save SRAM
|
||||
if((currentConfig->iFlags & 1) && SRam.changed) {
|
||||
saveLoadGame(0, 1);
|
||||
if ((currentConfig.EmuOpt & EOPT_USE_SRAM) && SRam.changed) {
|
||||
emu_SaveLoadGame(0, 1);
|
||||
SRam.changed = 0;
|
||||
}
|
||||
CPolledActiveScheduler::Instance()->Schedule();
|
||||
CGameWindow::FreeResources();
|
||||
} else if(gamestate == PGS_Paused) {
|
||||
}
|
||||
else if(gamestate == PGS_ReloadRom)
|
||||
{
|
||||
loadrom_result = emu_ReloadRom(loadrom_fname);
|
||||
pico_was_reset = 1;
|
||||
if (loadrom_result)
|
||||
gamestate = PGS_Running;
|
||||
else
|
||||
gamestate = PGS_Paused;
|
||||
DEBUGPRINT(_L("done loading ROM, retval=%i"), loadrom_result);
|
||||
loadWaitSemaphore.Signal();
|
||||
User::After(50000);
|
||||
}
|
||||
else if(gamestate == PGS_Paused) {
|
||||
DEBUGPRINT(_L("pausing.."));
|
||||
pauseSemaphore.Wait();
|
||||
} else if(gamestate == PGS_KeyConfig) {
|
||||
}
|
||||
else if(gamestate == PGS_KeyConfig)
|
||||
{
|
||||
// switch context to other thread
|
||||
User::After(50000);
|
||||
// prepare window and stuff
|
||||
|
@ -364,6 +377,10 @@ static void TargetEpocGameL()
|
|||
}
|
||||
}
|
||||
|
||||
// this thread has to close it's own handles,
|
||||
// other one will crash trying to do that
|
||||
PicoExit();
|
||||
|
||||
MainExit();
|
||||
}
|
||||
|
||||
|
@ -373,9 +390,6 @@ static void MainInit()
|
|||
{
|
||||
DEBUGPRINT(_L("\r\n\r\nstarting.."));
|
||||
|
||||
// our thread might have been crashed previously, so many other objects may be still floating around
|
||||
MainOldCleanup();
|
||||
|
||||
DEBUGPRINT(_L("CPolledActiveScheduler::NewL()"));
|
||||
CPolledActiveScheduler::NewL(); // create Polled AS for the sound engine
|
||||
|
||||
|
@ -384,8 +398,7 @@ static void MainInit()
|
|||
DumpMemInfo();
|
||||
|
||||
// try to start pico
|
||||
DEBUGPRINT(_L("PicoInit();"));
|
||||
PicoInit();
|
||||
DEBUGPRINT(_L("PicoInit()"));
|
||||
PicoDrawSetColorFormat(2);
|
||||
PicoWriteSound = updateSound;
|
||||
|
||||
|
@ -403,13 +416,6 @@ static void MainExit()
|
|||
|
||||
DEBUGPRINT(_L("%i: cleaning up.."), (TInt32) thisThread.Id());
|
||||
|
||||
// save SRAM
|
||||
if((currentConfig->iFlags & 1) && SRam.changed) {
|
||||
saveLoadGame(0, 1);
|
||||
SRam.changed = 0;
|
||||
}
|
||||
|
||||
PicoExit();
|
||||
// pauseSemaphore.Close();
|
||||
|
||||
if(gameAudio) delete gameAudio;
|
||||
|
@ -418,20 +424,6 @@ static void MainExit()
|
|||
delete CPolledActiveScheduler::Instance();
|
||||
}
|
||||
|
||||
void MainOldCleanup()
|
||||
{
|
||||
DEBUGPRINT(_L("MainOldCleanup.."));
|
||||
|
||||
// There was previously a handle leak here, so thread stuff was not cleaned
|
||||
// and I thought I would have to do it mself.
|
||||
|
||||
// clean any resources which might be left after a thread crash
|
||||
//CGameWindow::FreeResources(ETrue);
|
||||
|
||||
//if(CPolledActiveScheduler::Instance())
|
||||
// delete CPolledActiveScheduler::Instance();
|
||||
}
|
||||
|
||||
static void DumpMemInfo()
|
||||
{
|
||||
TInt ramSize, ramSizeFree, romSize;
|
||||
|
@ -444,12 +436,20 @@ static void DumpMemInfo()
|
|||
}
|
||||
|
||||
|
||||
extern "C" TInt my_SetExceptionHandler(TInt, TExceptionHandler, TUint32);
|
||||
|
||||
TInt EmuThreadFunction(TAny*)
|
||||
{
|
||||
TInt ret;
|
||||
const TUint32 exs = KExceptionAbort|KExceptionKill|KExceptionUserInterrupt|KExceptionFpe|KExceptionFault|KExceptionInteger|KExceptionDebug;
|
||||
|
||||
DEBUGPRINT(_L("EmuThreadFunction()"));
|
||||
User::SetExceptionHandler(ExceptionHandler, exs/*(TUint32) -1*/); // does not work?
|
||||
DEBUGPRINT(_L("EmuThreadFunction(), def ExceptionHandler %08x, my %08x"),
|
||||
User::ExceptionHandler(), ExceptionHandler);
|
||||
User::SetJustInTime(1);
|
||||
ret = User::SetExceptionHandler(ExceptionHandler, exs/*(TUint32) -1*/); // does not work :(
|
||||
// my_SetExceptionHandler(KCurrentThreadHandle, ExceptionHandler, 0xffffffff);
|
||||
DEBUGPRINT(_L("SetExceptionHandler %i, %08x"), ret, User::ExceptionHandler());
|
||||
User::ModifyExceptionMask(0, exs);
|
||||
|
||||
//TInt pc, sp;
|
||||
//asm volatile ("str pc, %0" : "=m" (pc) );
|
||||
|
@ -479,7 +479,7 @@ TInt EmuThreadFunction(TAny*)
|
|||
|
||||
TRAPD(error, TargetEpocGameL());
|
||||
|
||||
__ASSERT_ALWAYS(!error, User::Panic(_L("Picosmall"), error));
|
||||
__ASSERT_ALWAYS(!error, User::Panic(_L("PicoDrive"), error));
|
||||
delete cleanup;
|
||||
|
||||
DEBUGPRINT(_L("exitting.."));
|
||||
|
@ -586,17 +586,19 @@ void CGameWindow::ConstructResourcesL()
|
|||
// try to start the audio engine
|
||||
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
|
||||
|
||||
if(gamestate == PGS_Running && (currentConfig->iFlags & 4)) {
|
||||
if (gamestate == PGS_Running && (currentConfig.EmuOpt & EOPT_EN_SOUND))
|
||||
{
|
||||
TInt err = 0;
|
||||
if(PsndRate != PsndRate_old || (PicoOpt&11) != (PicoOpt_old&11) || Pico.m.pal != pal_old) {
|
||||
// if rate changed, reset all enabled chips, else reset only those chips, which were recently enabled
|
||||
//sound_reset(PsndRate != PsndRate_old ? PicoOpt : (PicoOpt&(PicoOpt^PicoOpt_old)));
|
||||
sound_rerate();
|
||||
PsndRerate(1);
|
||||
}
|
||||
if(!gameAudio || PsndRate != PsndRate_old || ((PicoOpt&8) ^ (PicoOpt_old&8)) || Pico.m.pal != pal_old) { // rate or stereo or pal/ntsc changed
|
||||
if(gameAudio) delete gameAudio; gameAudio = 0;
|
||||
DEBUGPRINT(_L("starting audio: %i len: %i stereo: %i, pal: %i"), PsndRate, PsndLen, PicoOpt&8, Pico.m.pal);
|
||||
TRAP(err, gameAudio = CGameAudioMS::NewL(PsndRate, (PicoOpt&8) ? 1 : 0, Pico.m.pal ? 50 : 60));
|
||||
TRAP(err, gameAudio = CGameAudioMS::NewL(PsndRate, (PicoOpt&8) ? 1 : 0,
|
||||
Pico.m.pal ? 50 : 60, currentConfig.volume));
|
||||
}
|
||||
if( gameAudio) {
|
||||
TRAP(err, PsndOut = gameAudio->ResumeL());
|
||||
|
@ -678,11 +680,6 @@ void CGameWindow::FreeResources()
|
|||
}
|
||||
|
||||
vidFree();
|
||||
|
||||
// emu might change renderer by itself, so we may need to sync config
|
||||
if(currentConfig && currentConfig->iPicoOpt != PicoOpt) {
|
||||
currentConfig->iFlags |= 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -708,7 +705,7 @@ void CGameWindow::DoKeys(void)
|
|||
const TPicoAreaConfigEntry *e = areaConfig + 1;
|
||||
for(i = 0; !e->rect.IsEmpty(); e++, i++)
|
||||
if(e->rect.Contains(p)) {
|
||||
areaActions = currentConfig->iAreaBinds[i];
|
||||
areaActions = currentConfig.KeyBinds[i+256];
|
||||
break;
|
||||
}
|
||||
//DEBUGPRINT(_L("pointer event: %i %i"), p.iX, p.iY);
|
||||
|
@ -767,7 +764,7 @@ void CGameWindow::DoKeys(void)
|
|||
for(i = 9; i >= 0; i--) {
|
||||
int scan = pressedKeys[i];
|
||||
if(scan) {
|
||||
if(keyFlags[scan] & 1) allActions |= currentConfig->iKeyBinds[scan];
|
||||
if(keyFlags[scan] & 1) allActions |= currentConfig.KeyBinds[scan];
|
||||
if((keyFlags[scan]& 3)==3) forceUpdate = 1;
|
||||
if(keyFlags[scan] & 2) keyFlags[scan] &= ~1;
|
||||
}
|
||||
|
@ -807,7 +804,7 @@ void CGameWindow::DoKeysConfig(TUint &which)
|
|||
const TPicoAreaConfigEntry *e = areaConfig + 1;
|
||||
for(i = 0; e->rect != TRect(0,0,0,0); e++, i++)
|
||||
if(e->rect.Contains(p)) {
|
||||
currentConfig->iAreaBinds[i] ^= currentActCode;
|
||||
currentConfig.KeyBinds[i+256] ^= currentActCode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -822,7 +819,7 @@ void CGameWindow::DoKeysConfig(TUint &which)
|
|||
if(which == 31) {
|
||||
gamestate = PGS_Paused;
|
||||
} else if (scan < 256) {
|
||||
if(!(keyFlags[scan]&0x40)) currentConfig->iKeyBinds[scan] ^= currentActCode;
|
||||
if(!(keyFlags[scan]&0x40)) currentConfig.KeyBinds[scan] ^= currentActCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -844,22 +841,22 @@ void CGameWindow::DoKeysConfig(TUint &which)
|
|||
|
||||
void CGameWindow::RunEvents(TUint32 which)
|
||||
{
|
||||
if(which & 0x4000) currentConfig->iFrameskip = -1;
|
||||
if(which & 0x2000) currentConfig->iFrameskip = 8;
|
||||
if(which & 0x1800) { // save or load (but not both)
|
||||
if (which & 0x4000) currentConfig.Frameskip = -1;
|
||||
if (which & 0x2000) currentConfig.Frameskip = 8;
|
||||
if (which & 0x1800) { // save or load (but not both)
|
||||
if(PsndOut) gameAudio->Pause(); // this may take a while, so we pause sound output
|
||||
|
||||
vidDrawNotice((which & 0x1000) ? "LOADING@GAME" : "SAVING@GAME");
|
||||
saveLoadGame(which & 0x1000);
|
||||
emu_SaveLoadGame(which & 0x1000, 0);
|
||||
|
||||
if(PsndOut) PsndOut = gameAudio->ResumeL();
|
||||
reset_timing = 1;
|
||||
}
|
||||
if(which & 0x0400) gamestate = PGS_Paused;
|
||||
if(which & 0x0200) { // switch renderer
|
||||
if(!(currentConfig->iScreenMode == TPicoConfig::PMFit &&
|
||||
(currentConfig->iScreenRotation == TPicoConfig::PRot0 || currentConfig->iScreenRotation == TPicoConfig::PRot180))) {
|
||||
|
||||
if (which & 0x0400) gamestate = PGS_Paused;
|
||||
if (which & 0x0200) { // switch renderer
|
||||
if (!(currentConfig.scaling == TPicoConfig::PMFit &&
|
||||
(currentConfig.rotation == TPicoConfig::PRot0 || currentConfig.rotation == TPicoConfig::PRot180)))
|
||||
{
|
||||
PicoOpt^=0x10;
|
||||
vidInit(0, 1);
|
||||
|
||||
|
@ -878,111 +875,20 @@ void CGameWindow::RunEvents(TUint32 which)
|
|||
sprintf(noticeMsg, "SAVE@SLOT@%i@SELECTED", state_slot);
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if(which & 0x0020) if(gameAudio) gameAudio->ChangeVolume(0);
|
||||
if(which & 0x0010) if(gameAudio) gameAudio->ChangeVolume(1);
|
||||
if(which & 0x0020) if(gameAudio) currentConfig.volume = gameAudio->ChangeVolume(0);
|
||||
if(which & 0x0010) if(gameAudio) currentConfig.volume = gameAudio->ChangeVolume(1);
|
||||
}
|
||||
|
||||
|
||||
// must use wrappers, or else will run into some weird loader error (see pico/area.c)
|
||||
static size_t fRead2(void *p, size_t _s, size_t _n, void *file)
|
||||
extern "C" void emu_noticeMsgUpdated(void)
|
||||
{
|
||||
return fread(p, _s, _n, (FILE *) file);
|
||||
}
|
||||
|
||||
static size_t fWrite2(void *p, size_t _s, size_t _n, void *file)
|
||||
{
|
||||
return fwrite(p, _s, _n, (FILE *) file);
|
||||
}
|
||||
|
||||
static size_t gzRead2(void *p, size_t, size_t _n, void *file)
|
||||
{
|
||||
return gzread(file, p, _n);
|
||||
}
|
||||
|
||||
static size_t gzWrite2(void *p, size_t, size_t _n, void *file)
|
||||
{
|
||||
return gzwrite(file, p, _n);
|
||||
}
|
||||
|
||||
|
||||
// this function is shared between both threads
|
||||
int saveLoadGame(int load, int sram)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
if(!RomFileName) return -1;
|
||||
|
||||
// make save filename
|
||||
char saveFname[KMaxFileName];
|
||||
strcpy(saveFname, RomFileName);
|
||||
saveFname[KMaxFileName-8] = 0;
|
||||
if(saveFname[strlen(saveFname)-4] == '.') saveFname[strlen(saveFname)-4] = 0;
|
||||
if(sram) strcat(saveFname, ".srm");
|
||||
else {
|
||||
if(state_slot > 0 && state_slot < 10) sprintf(saveFname, "%s.%i", saveFname, state_slot);
|
||||
strcat(saveFname, ".mds");
|
||||
}
|
||||
|
||||
DEBUGPRINT(_L("saveLoad (%i, %i): %S"), load, sram, DO_CONV(saveFname));
|
||||
|
||||
if(sram) {
|
||||
FILE *sramFile;
|
||||
int sram_size = SRam.end-SRam.start+1;
|
||||
if(SRam.reg_back & 4) sram_size=0x2000;
|
||||
if(!SRam.data) return 0; // SRam forcefully disabled for this game
|
||||
if(load) {
|
||||
sramFile = fopen(saveFname, "rb");
|
||||
if(!sramFile) return -1;
|
||||
fread(SRam.data, 1, sram_size, sramFile);
|
||||
fclose(sramFile);
|
||||
} else {
|
||||
// sram save needs some special processing
|
||||
// see if we have anything to save
|
||||
for(; sram_size > 0; sram_size--)
|
||||
if(SRam.data[sram_size-1]) break;
|
||||
|
||||
if(sram_size) {
|
||||
sramFile = fopen(saveFname, "wb");
|
||||
res = fwrite(SRam.data, 1, sram_size, sramFile);
|
||||
res = (res != sram_size) ? -1 : 0;
|
||||
fclose(sramFile);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
void *PmovFile = NULL;
|
||||
// try gzip first
|
||||
if(currentConfig->iFlags & 0x80) {
|
||||
strcat(saveFname, ".gz");
|
||||
if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) {
|
||||
areaRead = gzRead2;
|
||||
areaWrite = gzWrite2;
|
||||
if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY);
|
||||
} else
|
||||
saveFname[strlen(saveFname)-3] = 0;
|
||||
}
|
||||
if(!PmovFile) { // gzip failed or was disabled
|
||||
if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) {
|
||||
areaRead = fRead2;
|
||||
areaWrite = fWrite2;
|
||||
}
|
||||
}
|
||||
if(PmovFile) {
|
||||
PmovState(load ? 6 : 5, PmovFile); // load/save
|
||||
strcpy(noticeMsg, load ? "GAME@LOADED" : "GAME@SAVED");
|
||||
if(areaRead == gzRead2)
|
||||
gzclose(PmovFile);
|
||||
else fclose ((FILE *) PmovFile);
|
||||
PmovFile = 0;
|
||||
if (load) Pico.m.dirtyPal=1;
|
||||
} else {
|
||||
strcpy(noticeMsg, load ? "LOAD@FAILED" : "SAVE@FAILED");
|
||||
res = -1;
|
||||
}
|
||||
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
return res;
|
||||
char *p = noticeMsg;
|
||||
while (*p) {
|
||||
if (*p == ' ') *p = '@';
|
||||
if (*p < '0' || *p > 'Z') { *p = 0; break; }
|
||||
p++;
|
||||
}
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
|
||||
// static class members
|
||||
|
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
#include "vid.h"
|
||||
#include "../Engine.h"
|
||||
#include "../../../pico/picoInt.h"
|
||||
#include <Pico/PicoInt.h>
|
||||
#include "../../common/emu.h"
|
||||
#include "blit.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
// global stuff
|
||||
extern TPicoConfig *currentConfig;
|
||||
extern TPicoAreaConfigEntry areaConfig[];
|
||||
extern const char *actionNames[];
|
||||
|
||||
// main framebuffer
|
||||
static void *screenbuff = 0; // pointer to real device video memory
|
||||
//static
|
||||
extern "C" { unsigned char *framebuff = 0; } // temporary buffer
|
||||
extern "C" { unsigned char *PicoDraw2FB = 0; } // temporary buffer
|
||||
const int framebuffsize = (8+320)*(8+240+8)*2+8*2; // actual framebuffer size (in bytes+to support new rendering mode)
|
||||
|
||||
// drawer function pointers
|
||||
|
@ -87,35 +87,25 @@ static const unsigned long mask_numbers[] = {
|
|||
};
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// Cram functions
|
||||
|
||||
static int EmuCramNull(int cram)
|
||||
{
|
||||
User::Panic(_L("Cram called!!"), 0);
|
||||
return cram;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// PicoScan functions
|
||||
|
||||
static int EmuScan8(unsigned int num, void *sdata)
|
||||
static int EmuScanBegin8(unsigned int num)
|
||||
{
|
||||
DrawLineDest = framebuff + 328*(num+1) + 328*8 + 8;
|
||||
DrawLineDest = PicoDraw2FB + 328*num + 328*8 + 8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int EmuScanFit0(unsigned int num, void *sdata)
|
||||
static int EmuScanEndFit0(unsigned int num)
|
||||
{
|
||||
// 0.75, 168 lines
|
||||
|
||||
static int u = 0, num2 = 0;
|
||||
if(!num) u = num2 = 0;
|
||||
|
||||
DrawLineDest = framebuff + 328*(++num2) + 328*8 + 8;
|
||||
DrawLineDest = PicoDraw2FB + 328*(++num2) + 328*8 + 8;
|
||||
|
||||
u += 6666;
|
||||
|
||||
|
@ -136,7 +126,7 @@ static int EmuScanFit0(unsigned int num, void *sdata)
|
|||
|
||||
static void drawTextM2(int x, int y, const char *text)
|
||||
{
|
||||
unsigned char *vidmem = framebuff + 328*8 + 8;
|
||||
unsigned char *vidmem = PicoDraw2FB + 328*8 + 8;
|
||||
int charmask, i, cx = x, cy;
|
||||
unsigned char *l, *le;
|
||||
|
||||
|
@ -164,7 +154,7 @@ static void drawTextM2(int x, int y, const char *text)
|
|||
|
||||
static void drawTextM2Fat(int x, int y, const char *text)
|
||||
{
|
||||
unsigned char *vidmem = framebuff + 328*8 + 8;
|
||||
unsigned char *vidmem = PicoDraw2FB + 328*8 + 8;
|
||||
int charmask, i, cx = x&~1, cy;
|
||||
unsigned short *l, *le;
|
||||
|
||||
|
@ -257,7 +247,7 @@ static void fillLocalPal(void)
|
|||
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
|
||||
vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);
|
||||
vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40);
|
||||
blockcpy(localPal+0xc0, localPal+0x40, 0x40*4);
|
||||
memcpy32(localPal+0xc0, localPal+0x40, 0x40);
|
||||
localPal[0xe0] = 0x00000000; // reserved pixels for OSD
|
||||
localPal[0xf0] = 0x00ee0000;
|
||||
} else if (rendstatus & 0x20) { // mid-frame palette changes
|
||||
|
@ -273,7 +263,7 @@ static void fillLocalPal(void)
|
|||
// note: the internal 8 pixel border is taken care by asm code
|
||||
static void vidBlit_90(int full)
|
||||
{
|
||||
unsigned char *ps = framebuff+328*8;
|
||||
unsigned char *ps = PicoDraw2FB+328*8;
|
||||
unsigned long *pd = (unsigned long *) screenbuff;
|
||||
|
||||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
@ -291,7 +281,7 @@ static void vidBlit_90(int full)
|
|||
|
||||
static void vidBlit_270(int full)
|
||||
{
|
||||
unsigned char *ps = framebuff+328*8;
|
||||
unsigned char *ps = PicoDraw2FB+328*8;
|
||||
unsigned long *pd = (unsigned long *) screenbuff;
|
||||
|
||||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
@ -310,7 +300,7 @@ static void vidBlit_270(int full)
|
|||
|
||||
static void vidBlitCenter_0(int full)
|
||||
{
|
||||
unsigned char *ps = framebuff+328*8+8;
|
||||
unsigned char *ps = PicoDraw2FB+328*8+8;
|
||||
unsigned long *pd = (unsigned long *) screenbuff;
|
||||
|
||||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
@ -323,7 +313,7 @@ static void vidBlitCenter_0(int full)
|
|||
|
||||
static void vidBlitCenter_180(int full)
|
||||
{
|
||||
unsigned char *ps = framebuff+328*8+8;
|
||||
unsigned char *ps = PicoDraw2FB+328*8+8;
|
||||
unsigned long *pd = (unsigned long *) screenbuff;
|
||||
|
||||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
@ -339,8 +329,8 @@ static void vidBlitFit_0(int full)
|
|||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
||||
if(Pico.video.reg[12]&1)
|
||||
vidConvCpy_center2_40c_0(screenbuff, framebuff+328*8, localPal, 168);
|
||||
else vidConvCpy_center2_32c_0(screenbuff, framebuff+328*8, localPal, 168);
|
||||
vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168);
|
||||
else vidConvCpy_center2_32c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168);
|
||||
if(full) vidClear((unsigned long *)screenbuff + 168*256, 320-168);
|
||||
}
|
||||
|
||||
|
@ -350,8 +340,8 @@ static void vidBlitFit_180(int full)
|
|||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
||||
if(Pico.video.reg[12]&1)
|
||||
vidConvCpy_center2_40c_180(screenbuff, framebuff+328*8, localPal, 168);
|
||||
else vidConvCpy_center2_32c_180(screenbuff, framebuff+328*8-64, localPal, 168);
|
||||
vidConvCpy_center2_40c_180(screenbuff, PicoDraw2FB+328*8, localPal, 168);
|
||||
else vidConvCpy_center2_32c_180(screenbuff, PicoDraw2FB+328*8-64, localPal, 168);
|
||||
if(full) vidClear((unsigned long *)screenbuff + 168*256, 320-168);
|
||||
}
|
||||
|
||||
|
@ -361,8 +351,8 @@ static void vidBlitFit2_0(int full)
|
|||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
||||
if(Pico.video.reg[12]&1)
|
||||
vidConvCpy_center2_40c_0(screenbuff, framebuff+328*8, localPal, 224);
|
||||
else vidConvCpy_center2_32c_0(screenbuff, framebuff+328*8, localPal, 224);
|
||||
vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 224);
|
||||
else vidConvCpy_center2_32c_0(screenbuff, PicoDraw2FB+328*8, localPal, 224);
|
||||
if(full) vidClear((unsigned long *)screenbuff + 224*256, 96);
|
||||
}
|
||||
|
||||
|
@ -372,15 +362,15 @@ static void vidBlitFit2_180(int full)
|
|||
if (Pico.m.dirtyPal) fillLocalPal();
|
||||
|
||||
if(Pico.video.reg[12]&1)
|
||||
vidConvCpy_center2_40c_180(screenbuff, framebuff+328*8, localPal, 224);
|
||||
else vidConvCpy_center2_32c_180(screenbuff, framebuff+328*8-64, localPal, 224);
|
||||
vidConvCpy_center2_40c_180(screenbuff, PicoDraw2FB+328*8, localPal, 224);
|
||||
else vidConvCpy_center2_32c_180(screenbuff, PicoDraw2FB+328*8-64, localPal, 224);
|
||||
if(full) vidClear((unsigned long *)screenbuff + 224*256, 96);
|
||||
}
|
||||
|
||||
|
||||
static void vidBlitCfg(void)
|
||||
{
|
||||
unsigned short *ps = (unsigned short *) framebuff;
|
||||
unsigned short *ps = (unsigned short *) PicoDraw2FB;
|
||||
unsigned long *pd = (unsigned long *) screenbuff;
|
||||
int i;
|
||||
|
||||
|
@ -402,20 +392,17 @@ int vidInit(void *vidmem, int reinit)
|
|||
if(!reinit) {
|
||||
// prepare framebuffer
|
||||
screenbuff = vidmem;
|
||||
framebuff = (unsigned char *) malloc(framebuffsize);
|
||||
PicoDraw2FB = (unsigned char *) malloc(framebuffsize);
|
||||
|
||||
if(!screenbuff) return KErrNotSupported;
|
||||
if(!framebuff) return KErrNoMemory;
|
||||
if(!PicoDraw2FB) return KErrNoMemory;
|
||||
|
||||
memset(framebuff, 0, framebuffsize);
|
||||
|
||||
// Cram function: go and hack Pico so it never gets called
|
||||
PicoCram = EmuCramNull;
|
||||
memset(PicoDraw2FB, 0, framebuffsize);
|
||||
}
|
||||
|
||||
// select suitable blitters
|
||||
vidBlit = vidBlit_270;
|
||||
PicoScan = EmuScan8;
|
||||
PicoScanBegin = EmuScanBegin8;
|
||||
drawTextFps = drawTextFps0;
|
||||
drawTextNotice = drawTextNotice0;
|
||||
|
||||
|
@ -424,12 +411,13 @@ int vidInit(void *vidmem, int reinit)
|
|||
localPal[0xf0] = 0x00ee0000;
|
||||
|
||||
// setup all orientation related stuff
|
||||
if(currentConfig->iScreenRotation == TPicoConfig::PRot0) {
|
||||
if(currentConfig->iScreenMode == TPicoConfig::PMCenter) {
|
||||
if (currentConfig.rotation == TPicoConfig::PRot0)
|
||||
{
|
||||
if (currentConfig.scaling == TPicoConfig::PMCenter) {
|
||||
vidBlit = vidBlitCenter_0;
|
||||
drawTextFps = drawTextFpsCenter0;
|
||||
drawTextNotice = drawTextNoticeCenter0;
|
||||
} else if(currentConfig->iScreenMode == TPicoConfig::PMFit2) {
|
||||
} else if (currentConfig.scaling == TPicoConfig::PMFit2) {
|
||||
vidBlit = vidBlitFit2_0;
|
||||
drawTextFps = drawTextFpsFit2_0;
|
||||
drawTextNotice = drawTextNoticeFit2_0;
|
||||
|
@ -437,16 +425,20 @@ int vidInit(void *vidmem, int reinit)
|
|||
vidBlit = vidBlitFit_0;
|
||||
drawTextFps = drawTextFpsFit0;
|
||||
drawTextNotice = drawTextNoticeFit0;
|
||||
PicoScan = EmuScanFit0;
|
||||
PicoScanEnd = EmuScanEndFit0;
|
||||
}
|
||||
} else if(currentConfig->iScreenRotation == TPicoConfig::PRot90) {
|
||||
} else if (currentConfig.rotation == TPicoConfig::PRot90) {
|
||||
vidBlit = vidBlit_90;
|
||||
} else if(currentConfig->iScreenRotation == TPicoConfig::PRot180) {
|
||||
if(currentConfig->iScreenMode == TPicoConfig::PMCenter) {
|
||||
}
|
||||
else if (currentConfig.rotation == TPicoConfig::PRot180)
|
||||
{
|
||||
if (currentConfig.scaling == TPicoConfig::PMCenter)
|
||||
{
|
||||
vidBlit = vidBlitCenter_180;
|
||||
drawTextFps = drawTextFpsCenter0;
|
||||
drawTextNotice = drawTextNoticeCenter0;
|
||||
} else if(currentConfig->iScreenMode == TPicoConfig::PMFit2) {
|
||||
}
|
||||
else if (currentConfig.scaling == TPicoConfig::PMFit2) {
|
||||
vidBlit = vidBlitFit2_180;
|
||||
drawTextFps = drawTextFpsFit2_0;
|
||||
drawTextNotice = drawTextNoticeFit2_0;
|
||||
|
@ -454,9 +446,10 @@ int vidInit(void *vidmem, int reinit)
|
|||
vidBlit = vidBlitFit_180;
|
||||
drawTextFps = drawTextFpsFit0;
|
||||
drawTextNotice = drawTextNoticeFit0;
|
||||
PicoScan = EmuScanFit0;
|
||||
PicoScanEnd = EmuScanEndFit0;
|
||||
}
|
||||
} else if(currentConfig->iScreenRotation == TPicoConfig::PRot270) {
|
||||
}
|
||||
else if (currentConfig.rotation == TPicoConfig::PRot270) {
|
||||
vidBlit = vidBlit_270;
|
||||
}
|
||||
|
||||
|
@ -469,16 +462,16 @@ int vidInit(void *vidmem, int reinit)
|
|||
|
||||
void vidFree()
|
||||
{
|
||||
free(framebuff);
|
||||
framebuff = 0;
|
||||
free(PicoDraw2FB);
|
||||
PicoDraw2FB = 0;
|
||||
}
|
||||
|
||||
void vidDrawFrame(char *noticeStr, char *fpsStr, int num)
|
||||
{
|
||||
DrawLineDest = framebuff + 328*8 + 8;
|
||||
DrawLineDest = PicoDraw2FB + 328*8 + 8;
|
||||
|
||||
// PicoFrame(); // moved to main loop
|
||||
if(currentConfig->iFlags & 2)
|
||||
if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
|
||||
drawTextFps(fpsStr);
|
||||
drawTextNotice(noticeStr);
|
||||
|
||||
|
@ -489,7 +482,7 @@ void vidDrawFrame(char *noticeStr, char *fpsStr, int num)
|
|||
|
||||
static void drawText0(int x, int y, const char *text, long color)
|
||||
{
|
||||
unsigned short *vidmem=(unsigned short *)framebuff;
|
||||
unsigned short *vidmem=(unsigned short *)PicoDraw2FB;
|
||||
int charmask, i, cx = x, cy;
|
||||
unsigned short *l, *le, dmask=0x0333;
|
||||
|
||||
|
@ -519,7 +512,7 @@ static void drawText0(int x, int y, const char *text, long color)
|
|||
// draws rect with width - 1 and height - 1
|
||||
static void drawRect(const TRect &rc, unsigned short color)
|
||||
{
|
||||
unsigned short *vidmem=(unsigned short *)framebuff;
|
||||
unsigned short *vidmem=(unsigned short *)PicoDraw2FB;
|
||||
|
||||
if(rc.iTl.iX - rc.iBr.iX && rc.iTl.iY - rc.iBr.iY) {
|
||||
int stepX = rc.iTl.iX < rc.iBr.iX ? 1 : -1;
|
||||
|
@ -540,7 +533,7 @@ static void drawRect(const TRect &rc, unsigned short color)
|
|||
// draws fullsize filled rect
|
||||
static void drawRectFilled(const TRect rc, unsigned short color)
|
||||
{
|
||||
unsigned short *vidmem=(unsigned short *)framebuff;
|
||||
unsigned short *vidmem=(unsigned short *)PicoDraw2FB;
|
||||
|
||||
if(rc.iTl.iX - rc.iBr.iX && rc.iTl.iY - rc.iBr.iY) {
|
||||
int stepX = rc.iTl.iX < rc.iBr.iX ? 1 : -1;
|
||||
|
@ -559,7 +552,7 @@ static void drawRectFilled(const TRect rc, unsigned short color)
|
|||
// direction: -1 left, 1 right
|
||||
static void drawArrow0(TPoint p, int direction, unsigned short color)
|
||||
{
|
||||
unsigned short *vidmem=(unsigned short *)framebuff;
|
||||
unsigned short *vidmem=(unsigned short *)PicoDraw2FB;
|
||||
int width = 15;
|
||||
int x = p.iX;
|
||||
int y = p.iY;
|
||||
|
@ -603,7 +596,7 @@ void vidKeyConfigFrame(const TUint whichAction)
|
|||
int i;
|
||||
char buttonNames[128];
|
||||
buttonNames[0] = 0;
|
||||
memset(framebuff, 0, framebuffsize);
|
||||
memset(PicoDraw2FB, 0, framebuffsize);
|
||||
|
||||
unsigned long currentActCode = 1 << whichAction;
|
||||
|
||||
|
@ -611,7 +604,7 @@ void vidKeyConfigFrame(const TUint whichAction)
|
|||
const TPicoAreaConfigEntry *e = areaConfig + 1; i = 0;
|
||||
while(e->rect != TRect(0,0,0,0)) { e++; i++; }
|
||||
for(e--, i--; e->rect != TRect(0,0,0,0); e--, i--)
|
||||
drawRect(e->rect, (currentConfig->iAreaBinds[i] & currentActCode) ? color_red : color_red_dim);
|
||||
drawRect(e->rect, (currentConfig.KeyBinds[i+256] & currentActCode) ? color_red : color_red_dim);
|
||||
|
||||
// action name control
|
||||
drawRectFilled(TRect(72, 2, 168, 20), color_grey); // 96x14
|
||||
|
@ -621,14 +614,14 @@ void vidKeyConfigFrame(const TUint whichAction)
|
|||
drawText0(86, 9, actionNames[whichAction], color_red);
|
||||
|
||||
// draw active button names if there are any
|
||||
for(i = 0; i < 256; i++) {
|
||||
if(currentConfig->iKeyBinds[i] & currentActCode) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (currentConfig.KeyBinds[i] & currentActCode) {
|
||||
if(buttonNames[0]) strcat(buttonNames, ";@");
|
||||
strcat(buttonNames, vidGetScanName(i));
|
||||
}
|
||||
}
|
||||
|
||||
if(buttonNames[0]) {
|
||||
if (buttonNames[0]) {
|
||||
buttonNames[61] = 0; // only 60 chars fit
|
||||
drawText0(6, 48, buttonNames, color_blue);
|
||||
}
|
||||
|
@ -638,7 +631,7 @@ void vidKeyConfigFrame(const TUint whichAction)
|
|||
|
||||
void vidDrawNotice(const char *txt)
|
||||
{
|
||||
if(framebuff) {
|
||||
if(PicoDraw2FB) {
|
||||
drawTextNotice(txt);
|
||||
vidBlit(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue