You better believe it, it's a whitespace trim, and line conversions, eol settings comming up.
This commit is contained in:
parent
454a1a233d
commit
b248000efb
154
src/Sound.cpp
154
src/Sound.cpp
|
@ -76,11 +76,11 @@ class Gba_Pcm_Fifo {
|
|||
public:
|
||||
int which;
|
||||
Gba_Pcm pcm;
|
||||
|
||||
|
||||
void write_control( int data );
|
||||
void write_fifo( int data );
|
||||
void timer_overflowed( int which_timer );
|
||||
|
||||
|
||||
// public only so save state routines can access it
|
||||
int readIndex;
|
||||
int count;
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
u8 fifo [32];
|
||||
int dac;
|
||||
private:
|
||||
|
||||
|
||||
int timer;
|
||||
bool enabled;
|
||||
};
|
||||
|
@ -115,11 +115,11 @@ void Gba_Pcm::init()
|
|||
void Gba_Pcm::apply_control( int idx )
|
||||
{
|
||||
shift = ~ioMem [SGCNT0_H] >> (2 + idx) & 1;
|
||||
|
||||
|
||||
int ch = 0;
|
||||
if ( (soundEnableFlag >> idx & 0x100) && (ioMem [NR52] & 0x80) )
|
||||
ch = ioMem [SGCNT0_H+1] >> (idx * 4) & 3;
|
||||
|
||||
|
||||
Blip_Buffer* out = 0;
|
||||
switch ( ch )
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ void Gba_Pcm::apply_control( int idx )
|
|||
case 2: out = stereo_buffer->left(); break;
|
||||
case 3: out = stereo_buffer->center(); break;
|
||||
}
|
||||
|
||||
|
||||
if ( output != out )
|
||||
{
|
||||
if ( output )
|
||||
|
@ -145,7 +145,7 @@ void Gba_Pcm::end_frame( blip_time_t time )
|
|||
last_time -= time;
|
||||
if ( last_time < -2048 )
|
||||
last_time = -2048;
|
||||
|
||||
|
||||
if ( output )
|
||||
output->set_modified();
|
||||
}
|
||||
|
@ -155,27 +155,27 @@ void Gba_Pcm::update( int dac )
|
|||
if ( output )
|
||||
{
|
||||
blip_time_t time = blip_time();
|
||||
|
||||
|
||||
dac = (s8) dac >> shift;
|
||||
int delta = dac - last_amp;
|
||||
if ( delta )
|
||||
{
|
||||
last_amp = dac;
|
||||
|
||||
|
||||
int filter = 0;
|
||||
if ( soundInterpolation )
|
||||
{
|
||||
// base filtering on how long since last sample was output
|
||||
int period = time - last_time;
|
||||
|
||||
|
||||
int idx = (unsigned) period / 512;
|
||||
if ( idx >= 3 )
|
||||
idx = 3;
|
||||
|
||||
|
||||
static int const filters [4] = { 0, 0, 1, 2 };
|
||||
filter = filters [idx];
|
||||
}
|
||||
|
||||
|
||||
pcm_synth [filter].offset( time, delta, output );
|
||||
}
|
||||
last_time = time;
|
||||
|
@ -201,7 +201,7 @@ void Gba_Pcm_Fifo::timer_overflowed( int which_timer )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read next sample from FIFO
|
||||
count--;
|
||||
dac = fifo [readIndex];
|
||||
|
@ -214,7 +214,7 @@ void Gba_Pcm_Fifo::write_control( int data )
|
|||
{
|
||||
enabled = (data & 0x0300) ? true : false;
|
||||
timer = (data & 0x0400) ? 1 : 0;
|
||||
|
||||
|
||||
if ( data & 0x0800 )
|
||||
{
|
||||
// Reset
|
||||
|
@ -224,7 +224,7 @@ void Gba_Pcm_Fifo::write_control( int data )
|
|||
dac = 0;
|
||||
memset( fifo, 0, sizeof fifo );
|
||||
}
|
||||
|
||||
|
||||
pcm.apply_control( which );
|
||||
pcm.update( dac );
|
||||
}
|
||||
|
@ -268,11 +268,11 @@ void soundEvent(u32 address, u8 data)
|
|||
{
|
||||
ioMem[address] = data;
|
||||
gb_apu->write_register( blip_time(), gb_addr, data );
|
||||
|
||||
|
||||
if ( address == NR52 )
|
||||
apply_control();
|
||||
}
|
||||
|
||||
|
||||
// TODO: what about byte writes to SGCNT0_H etc.?
|
||||
}
|
||||
|
||||
|
@ -280,17 +280,17 @@ static void apply_volume( bool apu_only = false )
|
|||
{
|
||||
if ( !apu_only )
|
||||
soundVolume_ = soundVolume;
|
||||
|
||||
|
||||
// Emulator volume
|
||||
static float const vols [6] = { 1, 2, 3, 4, 0.25, 0.5 };
|
||||
double const volume = vols [soundVolume_];
|
||||
|
||||
|
||||
if ( gb_apu )
|
||||
{
|
||||
static float const apu_vols [4] = { 0.25, 0.5, 1, 0.25 };
|
||||
gb_apu->volume( volume * apu_vols [ioMem [SGCNT0_H] & 3] );
|
||||
}
|
||||
|
||||
|
||||
if ( !apu_only )
|
||||
{
|
||||
for ( int i = 0; i < 3; i++ )
|
||||
|
@ -313,24 +313,24 @@ void soundEvent(u32 address, u16 data)
|
|||
case SGCNT0_H:
|
||||
write_SGCNT0_H( data );
|
||||
break;
|
||||
|
||||
|
||||
case FIFOA_L:
|
||||
case FIFOA_H:
|
||||
pcm [0].write_fifo( data );
|
||||
WRITE16LE( &ioMem[address], data );
|
||||
break;
|
||||
|
||||
|
||||
case FIFOB_L:
|
||||
case FIFOB_H:
|
||||
pcm [1].write_fifo( data );
|
||||
WRITE16LE( &ioMem[address], data );
|
||||
break;
|
||||
|
||||
|
||||
case 0x88:
|
||||
data &= 0xC3FF;
|
||||
WRITE16LE( &ioMem[address], data );
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
soundEvent( address & ~1, (u8) (data ) ); // even
|
||||
soundEvent( address | 1, (u8) (data >> 8) ); // odd
|
||||
|
@ -348,7 +348,7 @@ static void end_frame( blip_time_t time )
|
|||
{
|
||||
pcm [0].pcm.end_frame( time );
|
||||
pcm [1].pcm.end_frame( time );
|
||||
|
||||
|
||||
gb_apu ->end_frame( time );
|
||||
stereo_buffer->end_frame( time );
|
||||
}
|
||||
|
@ -357,10 +357,10 @@ static void flush_samples()
|
|||
{
|
||||
// soundBufferLen should have a whole number of sample pairs
|
||||
assert( soundBufferLen % (2 * sizeof *soundFinalWave) == 0 );
|
||||
|
||||
|
||||
// number of samples in output buffer
|
||||
int const out_buf_size = soundBufferLen / sizeof *soundFinalWave;
|
||||
|
||||
|
||||
// Keep filling and writing soundFinalWave until it can't be fully filled
|
||||
while ( stereo_buffer->samples_avail() >= out_buf_size )
|
||||
{
|
||||
|
@ -378,10 +378,10 @@ static void flush_samples()
|
|||
static void apply_filtering()
|
||||
{
|
||||
soundFiltering_ = soundFiltering;
|
||||
|
||||
|
||||
int const base_freq = (int) (32768 - soundFiltering_ * 16384);
|
||||
int const nyquist = stereo_buffer->sample_rate() / 2;
|
||||
|
||||
|
||||
for ( int i = 0; i < 3; i++ )
|
||||
{
|
||||
int cutoff = base_freq >> i;
|
||||
|
@ -397,12 +397,12 @@ static void soundTick()
|
|||
{
|
||||
// Run sound hardware to present
|
||||
end_frame( SOUND_CLOCK_TICKS );
|
||||
|
||||
|
||||
flush_samples();
|
||||
|
||||
|
||||
if ( soundFiltering_ != soundFiltering )
|
||||
apply_filtering();
|
||||
|
||||
|
||||
if ( soundVolume_ != soundVolume )
|
||||
apply_volume();
|
||||
}
|
||||
|
@ -414,10 +414,10 @@ static void apply_muting()
|
|||
{
|
||||
if ( !stereo_buffer || !ioMem )
|
||||
return;
|
||||
|
||||
|
||||
// PCM
|
||||
apply_control();
|
||||
|
||||
|
||||
if ( gb_apu )
|
||||
{
|
||||
// APU
|
||||
|
@ -435,10 +435,10 @@ static void apply_muting()
|
|||
static void reset_apu()
|
||||
{
|
||||
gb_apu->reset( gb_apu->mode_agb, true );
|
||||
|
||||
|
||||
if ( stereo_buffer )
|
||||
stereo_buffer->clear();
|
||||
|
||||
|
||||
soundTicks = SOUND_CLOCK_TICKS;
|
||||
}
|
||||
|
||||
|
@ -446,32 +446,32 @@ static void remake_stereo_buffer()
|
|||
{
|
||||
if ( !ioMem )
|
||||
return;
|
||||
|
||||
|
||||
// Clears pointers kept to old stereo_buffer
|
||||
pcm [0].pcm.init();
|
||||
pcm [1].pcm.init();
|
||||
|
||||
|
||||
// Stereo_Buffer
|
||||
delete stereo_buffer;
|
||||
stereo_buffer = 0;
|
||||
|
||||
|
||||
stereo_buffer = new Stereo_Buffer; // TODO: handle out of memory
|
||||
long const sample_rate = 44100 / soundQuality;
|
||||
stereo_buffer->set_sample_rate( sample_rate ); // TODO: handle out of memory
|
||||
stereo_buffer->clock_rate( gb_apu->clock_rate );
|
||||
|
||||
|
||||
// PCM
|
||||
pcm [0].which = 0;
|
||||
pcm [1].which = 1;
|
||||
apply_filtering();
|
||||
|
||||
|
||||
// APU
|
||||
if ( !gb_apu )
|
||||
{
|
||||
gb_apu = new Gb_Apu; // TODO: handle out of memory
|
||||
reset_apu();
|
||||
}
|
||||
|
||||
|
||||
apply_muting();
|
||||
apply_volume();
|
||||
}
|
||||
|
@ -523,16 +523,16 @@ int soundGetEnable()
|
|||
void soundReset()
|
||||
{
|
||||
systemSoundReset();
|
||||
|
||||
|
||||
remake_stereo_buffer();
|
||||
reset_apu();
|
||||
|
||||
|
||||
setsoundPaused(true);
|
||||
SOUND_CLOCK_TICKS = SOUND_CLOCK_TICKS_;
|
||||
soundTicks = SOUND_CLOCK_TICKS_;
|
||||
|
||||
|
||||
soundNextPosition = 0;
|
||||
|
||||
|
||||
soundEvent( NR52, (u8) 0x80 );
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ bool soundInit()
|
|||
{
|
||||
if ( !systemSoundInit() )
|
||||
return false;
|
||||
|
||||
|
||||
soundPaused = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -553,10 +553,10 @@ void soundSetQuality(int quality)
|
|||
{
|
||||
if ( !soundOffFlag )
|
||||
soundShutdown();
|
||||
|
||||
|
||||
soundQuality = quality;
|
||||
soundNextPosition = 0;
|
||||
|
||||
|
||||
if ( !soundOffFlag )
|
||||
soundInit();
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ void soundSetQuality(int quality)
|
|||
soundQuality = quality;
|
||||
soundNextPosition = 0;
|
||||
}
|
||||
|
||||
|
||||
remake_stereo_buffer();
|
||||
}
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ static int dummy_state [16];
|
|||
|
||||
static struct {
|
||||
gb_apu_state_t apu;
|
||||
|
||||
|
||||
// old state
|
||||
u8 soundDSAValue;
|
||||
int soundDSBValue;
|
||||
|
@ -656,7 +656,7 @@ static variable_desc old_gba_state [] =
|
|||
SKIP( int, soundDSBTimer ),
|
||||
LOAD( u8 [32], pcm [1].fifo ),
|
||||
LOAD( int, state.soundDSBValue ),
|
||||
|
||||
|
||||
// skipped manually
|
||||
//LOAD( int, soundBuffer[0][0], 6*735 },
|
||||
//LOAD( int, soundFinalWave[0], 2*735 },
|
||||
|
@ -681,45 +681,45 @@ static variable_desc gba_state [] =
|
|||
LOAD( int, pcm [0].writeIndex ),
|
||||
LOAD(u8[32],pcm[0].fifo ),
|
||||
LOAD( int, pcm [0].dac ),
|
||||
|
||||
|
||||
SKIP( int [4], room_for_expansion ),
|
||||
|
||||
|
||||
LOAD( int, pcm [1].readIndex ),
|
||||
LOAD( int, pcm [1].count ),
|
||||
LOAD( int, pcm [1].writeIndex ),
|
||||
LOAD(u8[32],pcm[1].fifo ),
|
||||
LOAD( int, pcm [1].dac ),
|
||||
|
||||
|
||||
SKIP( int [4], room_for_expansion ),
|
||||
|
||||
|
||||
// APU
|
||||
LOAD( u8 [0x40], state.apu.regs ), // last values written to registers and wave RAM (both banks)
|
||||
LOAD( int, state.apu.frame_time ), // clocks until next frame sequencer action
|
||||
LOAD( int, state.apu.frame_phase ), // next step frame sequencer will run
|
||||
|
||||
|
||||
LOAD( int, state.apu.sweep_freq ), // sweep's internal frequency register
|
||||
LOAD( int, state.apu.sweep_delay ), // clocks until next sweep action
|
||||
LOAD( int, state.apu.sweep_enabled ),
|
||||
LOAD( int, state.apu.sweep_neg ), // obscure internal flag
|
||||
LOAD( int, state.apu.noise_divider ),
|
||||
LOAD( int, state.apu.wave_buf ), // last read byte of wave RAM
|
||||
|
||||
|
||||
LOAD( int [4], state.apu.delay ), // clocks until next channel action
|
||||
LOAD( int [4], state.apu.length_ctr ),
|
||||
LOAD( int [4], state.apu.phase ), // square/wave phase, noise LFSR
|
||||
LOAD( int [4], state.apu.enabled ), // internal enabled flag
|
||||
|
||||
|
||||
LOAD( int [3], state.apu.env_delay ), // clocks until next envelope action
|
||||
LOAD( int [3], state.apu.env_volume ),
|
||||
LOAD( int [3], state.apu.env_enabled ),
|
||||
|
||||
|
||||
SKIP( int [13], room_for_expansion ),
|
||||
|
||||
|
||||
// Emulator
|
||||
LOAD( int, soundEnableFlag ),
|
||||
|
||||
|
||||
SKIP( int [15], room_for_expansion ),
|
||||
|
||||
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -727,13 +727,13 @@ static variable_desc gba_state [] =
|
|||
static void skip_read( gzFile in, int count )
|
||||
{
|
||||
char buf [512];
|
||||
|
||||
|
||||
while ( count )
|
||||
{
|
||||
int n = sizeof buf;
|
||||
if ( n > count )
|
||||
n = count;
|
||||
|
||||
|
||||
count -= n;
|
||||
utilGzRead( in, buf, n );
|
||||
}
|
||||
|
@ -742,10 +742,10 @@ static void skip_read( gzFile in, int count )
|
|||
void soundSaveGame( gzFile out )
|
||||
{
|
||||
gb_apu->save_state( &state.apu );
|
||||
|
||||
|
||||
// Be sure areas for expansion get written as zero
|
||||
memset( dummy_state, 0, sizeof dummy_state );
|
||||
|
||||
|
||||
utilWriteData( out, gba_state );
|
||||
}
|
||||
|
||||
|
@ -754,7 +754,7 @@ static void soundReadGameOld( gzFile in, int version )
|
|||
// Read main data
|
||||
utilReadData( in, old_gba_state );
|
||||
skip_read( in, 6*735 + 2*735 );
|
||||
|
||||
|
||||
// Copy APU regs
|
||||
static int const regs_to_copy [] = {
|
||||
NR10, NR11, NR12, NR13, NR14,
|
||||
|
@ -763,24 +763,24 @@ static void soundReadGameOld( gzFile in, int version )
|
|||
NR41, NR42, NR43, NR44,
|
||||
NR50, NR51, NR52, -1
|
||||
};
|
||||
|
||||
|
||||
ioMem [NR52] |= 0x80; // old sound played even when this wasn't set (power on)
|
||||
|
||||
|
||||
for ( int i = 0; regs_to_copy [i] >= 0; i++ )
|
||||
state.apu.regs [gba_to_gb_sound( regs_to_copy [i] ) - 0xFF10] = ioMem [regs_to_copy [i]];
|
||||
|
||||
|
||||
// Copy wave RAM to both banks
|
||||
memcpy( &state.apu.regs [0x20], &ioMem [0x90], 0x10 );
|
||||
memcpy( &state.apu.regs [0x30], &ioMem [0x90], 0x10 );
|
||||
|
||||
|
||||
// Read both banks of wave RAM if available
|
||||
if ( version >= SAVE_GAME_VERSION_3 )
|
||||
utilReadData( in, old_gba_state2 );
|
||||
|
||||
|
||||
// Restore PCM
|
||||
pcm [0].dac = state.soundDSAValue;
|
||||
pcm [1].dac = state.soundDSBValue;
|
||||
|
||||
|
||||
int quality = utilReadInt( in ); // ignore this crap
|
||||
}
|
||||
|
||||
|
@ -791,14 +791,14 @@ void soundReadGame( gzFile in, int version )
|
|||
// Prepare APU and default state
|
||||
reset_apu();
|
||||
gb_apu->save_state( &state.apu );
|
||||
|
||||
|
||||
if ( version > SAVE_GAME_VERSION_9 )
|
||||
utilReadData( in, gba_state );
|
||||
else
|
||||
soundReadGameOld( in, version );
|
||||
|
||||
|
||||
gb_apu->load_state( state.apu );
|
||||
write_SGCNT0_H( READ16LE( &ioMem [SGCNT0_H] ) & 0x770F );
|
||||
|
||||
|
||||
apply_muting();
|
||||
}
|
||||
|
|
7966
src/agb/GBA.cpp
7966
src/agb/GBA.cpp
File diff suppressed because it is too large
Load Diff
320
src/agb/GBA.h
320
src/agb/GBA.h
|
@ -1,160 +1,160 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_GBA_H
|
||||
#define VBA_GBA_H
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
#define SAVE_GAME_VERSION_1 1
|
||||
#define SAVE_GAME_VERSION_2 2
|
||||
#define SAVE_GAME_VERSION_3 3
|
||||
#define SAVE_GAME_VERSION_4 4
|
||||
#define SAVE_GAME_VERSION_5 5
|
||||
#define SAVE_GAME_VERSION_6 6
|
||||
#define SAVE_GAME_VERSION_7 7
|
||||
#define SAVE_GAME_VERSION_8 8
|
||||
#define SAVE_GAME_VERSION_9 9
|
||||
#define SAVE_GAME_VERSION_10 10
|
||||
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10
|
||||
|
||||
typedef struct {
|
||||
u8 *address;
|
||||
u32 mask;
|
||||
} memoryMap;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u8 B3;
|
||||
u8 B2;
|
||||
u8 B1;
|
||||
u8 B0;
|
||||
#else
|
||||
u8 B0;
|
||||
u8 B1;
|
||||
u8 B2;
|
||||
u8 B3;
|
||||
#endif
|
||||
} B;
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u16 W1;
|
||||
u16 W0;
|
||||
#else
|
||||
u16 W0;
|
||||
u16 W1;
|
||||
#endif
|
||||
} W;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
volatile u32 I;
|
||||
#else
|
||||
u32 I;
|
||||
#endif
|
||||
} reg_pair;
|
||||
|
||||
#ifndef NO_GBA_MAP
|
||||
extern memoryMap map[256];
|
||||
#endif
|
||||
|
||||
extern reg_pair reg[45];
|
||||
extern u8 biosProtected[4];
|
||||
|
||||
extern bool N_FLAG;
|
||||
extern bool Z_FLAG;
|
||||
extern bool C_FLAG;
|
||||
extern bool V_FLAG;
|
||||
extern bool armIrqEnable;
|
||||
extern bool armState;
|
||||
extern int armMode;
|
||||
extern void (*cpuSaveGameFunc)(u32,u8);
|
||||
|
||||
#ifdef BKPT_SUPPORT
|
||||
extern u8 freezeWorkRAM[0x40000];
|
||||
extern u8 freezeInternalRAM[0x8000];
|
||||
extern u8 freezeVRAM[0x18000];
|
||||
extern u8 freezeOAM[0x400];
|
||||
extern u8 freezePRAM[0x400];
|
||||
extern bool debugger_last;
|
||||
extern int oldreg[17];
|
||||
extern char oldbuffer[10];
|
||||
#endif
|
||||
|
||||
extern bool CPUReadGSASnapshot(const char *);
|
||||
extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *);
|
||||
extern bool CPUWriteBatteryFile(const char *);
|
||||
extern bool CPUReadBatteryFile(const char *);
|
||||
extern bool CPUExportEepromFile(const char *);
|
||||
extern bool CPUImportEepromFile(const char *);
|
||||
extern bool CPUWritePNGFile(const char *);
|
||||
extern bool CPUWriteBMPFile(const char *);
|
||||
extern void CPUCleanUp();
|
||||
extern void CPUUpdateRender();
|
||||
extern void CPUUpdateRenderBuffers(bool);
|
||||
extern bool CPUReadMemState(char *, int);
|
||||
extern bool CPUReadState(const char *);
|
||||
extern bool CPUWriteMemState(char *, int);
|
||||
extern bool CPUWriteState(const char *);
|
||||
extern int CPULoadRom(const char *);
|
||||
extern void doMirroring(bool);
|
||||
extern void CPUUpdateRegister(u32, u16);
|
||||
extern void applyTimer ();
|
||||
extern void CPUInit(const char *,bool);
|
||||
extern void CPUReset();
|
||||
extern void CPULoop(int);
|
||||
extern void CPUCheckDMA(int,int);
|
||||
extern bool CPUIsGBAImage(const char *);
|
||||
extern bool CPUIsZipFile(const char *);
|
||||
#ifdef PROFILING
|
||||
#include "prof/prof.h"
|
||||
extern void cpuProfil(profile_segment *seg);
|
||||
extern void cpuEnableProfiling(int hz);
|
||||
#endif
|
||||
|
||||
extern struct EmulatedSystem GBASystem;
|
||||
|
||||
#define R13_IRQ 18
|
||||
#define R14_IRQ 19
|
||||
#define SPSR_IRQ 20
|
||||
#define R13_USR 26
|
||||
#define R14_USR 27
|
||||
#define R13_SVC 28
|
||||
#define R14_SVC 29
|
||||
#define SPSR_SVC 30
|
||||
#define R13_ABT 31
|
||||
#define R14_ABT 32
|
||||
#define SPSR_ABT 33
|
||||
#define R13_UND 34
|
||||
#define R14_UND 35
|
||||
#define SPSR_UND 36
|
||||
#define R8_FIQ 37
|
||||
#define R9_FIQ 38
|
||||
#define R10_FIQ 39
|
||||
#define R11_FIQ 40
|
||||
#define R12_FIQ 41
|
||||
#define R13_FIQ 42
|
||||
#define R14_FIQ 43
|
||||
#define SPSR_FIQ 44
|
||||
|
||||
#include "../Cheats.h"
|
||||
#include "../Globals.h"
|
||||
#include "../EEprom.h"
|
||||
#include "../Flash.h"
|
||||
|
||||
#endif //VBA_GBA_H
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_GBA_H
|
||||
#define VBA_GBA_H
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
#define SAVE_GAME_VERSION_1 1
|
||||
#define SAVE_GAME_VERSION_2 2
|
||||
#define SAVE_GAME_VERSION_3 3
|
||||
#define SAVE_GAME_VERSION_4 4
|
||||
#define SAVE_GAME_VERSION_5 5
|
||||
#define SAVE_GAME_VERSION_6 6
|
||||
#define SAVE_GAME_VERSION_7 7
|
||||
#define SAVE_GAME_VERSION_8 8
|
||||
#define SAVE_GAME_VERSION_9 9
|
||||
#define SAVE_GAME_VERSION_10 10
|
||||
#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10
|
||||
|
||||
typedef struct {
|
||||
u8 *address;
|
||||
u32 mask;
|
||||
} memoryMap;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u8 B3;
|
||||
u8 B2;
|
||||
u8 B1;
|
||||
u8 B0;
|
||||
#else
|
||||
u8 B0;
|
||||
u8 B1;
|
||||
u8 B2;
|
||||
u8 B3;
|
||||
#endif
|
||||
} B;
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u16 W1;
|
||||
u16 W0;
|
||||
#else
|
||||
u16 W0;
|
||||
u16 W1;
|
||||
#endif
|
||||
} W;
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
volatile u32 I;
|
||||
#else
|
||||
u32 I;
|
||||
#endif
|
||||
} reg_pair;
|
||||
|
||||
#ifndef NO_GBA_MAP
|
||||
extern memoryMap map[256];
|
||||
#endif
|
||||
|
||||
extern reg_pair reg[45];
|
||||
extern u8 biosProtected[4];
|
||||
|
||||
extern bool N_FLAG;
|
||||
extern bool Z_FLAG;
|
||||
extern bool C_FLAG;
|
||||
extern bool V_FLAG;
|
||||
extern bool armIrqEnable;
|
||||
extern bool armState;
|
||||
extern int armMode;
|
||||
extern void (*cpuSaveGameFunc)(u32,u8);
|
||||
|
||||
#ifdef BKPT_SUPPORT
|
||||
extern u8 freezeWorkRAM[0x40000];
|
||||
extern u8 freezeInternalRAM[0x8000];
|
||||
extern u8 freezeVRAM[0x18000];
|
||||
extern u8 freezeOAM[0x400];
|
||||
extern u8 freezePRAM[0x400];
|
||||
extern bool debugger_last;
|
||||
extern int oldreg[17];
|
||||
extern char oldbuffer[10];
|
||||
#endif
|
||||
|
||||
extern bool CPUReadGSASnapshot(const char *);
|
||||
extern bool CPUWriteGSASnapshot(const char *, const char *, const char *, const char *);
|
||||
extern bool CPUWriteBatteryFile(const char *);
|
||||
extern bool CPUReadBatteryFile(const char *);
|
||||
extern bool CPUExportEepromFile(const char *);
|
||||
extern bool CPUImportEepromFile(const char *);
|
||||
extern bool CPUWritePNGFile(const char *);
|
||||
extern bool CPUWriteBMPFile(const char *);
|
||||
extern void CPUCleanUp();
|
||||
extern void CPUUpdateRender();
|
||||
extern void CPUUpdateRenderBuffers(bool);
|
||||
extern bool CPUReadMemState(char *, int);
|
||||
extern bool CPUReadState(const char *);
|
||||
extern bool CPUWriteMemState(char *, int);
|
||||
extern bool CPUWriteState(const char *);
|
||||
extern int CPULoadRom(const char *);
|
||||
extern void doMirroring(bool);
|
||||
extern void CPUUpdateRegister(u32, u16);
|
||||
extern void applyTimer ();
|
||||
extern void CPUInit(const char *,bool);
|
||||
extern void CPUReset();
|
||||
extern void CPULoop(int);
|
||||
extern void CPUCheckDMA(int,int);
|
||||
extern bool CPUIsGBAImage(const char *);
|
||||
extern bool CPUIsZipFile(const char *);
|
||||
#ifdef PROFILING
|
||||
#include "prof/prof.h"
|
||||
extern void cpuProfil(profile_segment *seg);
|
||||
extern void cpuEnableProfiling(int hz);
|
||||
#endif
|
||||
|
||||
extern struct EmulatedSystem GBASystem;
|
||||
|
||||
#define R13_IRQ 18
|
||||
#define R14_IRQ 19
|
||||
#define SPSR_IRQ 20
|
||||
#define R13_USR 26
|
||||
#define R14_USR 27
|
||||
#define R13_SVC 28
|
||||
#define R14_SVC 29
|
||||
#define SPSR_SVC 30
|
||||
#define R13_ABT 31
|
||||
#define R14_ABT 32
|
||||
#define SPSR_ABT 33
|
||||
#define R13_UND 34
|
||||
#define R14_UND 35
|
||||
#define SPSR_UND 36
|
||||
#define R8_FIQ 37
|
||||
#define R9_FIQ 38
|
||||
#define R10_FIQ 39
|
||||
#define R11_FIQ 40
|
||||
#define R12_FIQ 41
|
||||
#define R13_FIQ 42
|
||||
#define R14_FIQ 43
|
||||
#define SPSR_FIQ 44
|
||||
|
||||
#include "../Cheats.h"
|
||||
#include "../Globals.h"
|
||||
#include "../EEprom.h"
|
||||
#include "../Flash.h"
|
||||
|
||||
#endif //VBA_GBA_H
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
int coeff[32] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
|
||||
|
||||
u32 line0[240];
|
||||
u32 line1[240];
|
||||
u32 line2[240];
|
||||
u32 line3[240];
|
||||
u32 lineOBJ[240];
|
||||
u32 lineOBJWin[240];
|
||||
u32 lineMix[240];
|
||||
bool gfxInWin0[240];
|
||||
bool gfxInWin1[240];
|
||||
int lineOBJpixleft[128];
|
||||
|
||||
int gfxBG2Changed = 0;
|
||||
int gfxBG3Changed = 0;
|
||||
|
||||
int gfxBG2X = 0;
|
||||
int gfxBG2Y = 0;
|
||||
int gfxBG2LastX = 0;
|
||||
int gfxBG2LastY = 0;
|
||||
int gfxBG3X = 0;
|
||||
int gfxBG3Y = 0;
|
||||
int gfxBG3LastX = 0;
|
||||
int gfxBG3LastY = 0;
|
||||
int gfxLastVCOUNT = 0;
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
int coeff[32] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
|
||||
|
||||
u32 line0[240];
|
||||
u32 line1[240];
|
||||
u32 line2[240];
|
||||
u32 line3[240];
|
||||
u32 lineOBJ[240];
|
||||
u32 lineOBJWin[240];
|
||||
u32 lineMix[240];
|
||||
bool gfxInWin0[240];
|
||||
bool gfxInWin1[240];
|
||||
int lineOBJpixleft[128];
|
||||
|
||||
int gfxBG2Changed = 0;
|
||||
int gfxBG3Changed = 0;
|
||||
|
||||
int gfxBG2X = 0;
|
||||
int gfxBG2Y = 0;
|
||||
int gfxBG2LastX = 0;
|
||||
int gfxBG2LastY = 0;
|
||||
int gfxBG3X = 0;
|
||||
int gfxBG3Y = 0;
|
||||
int gfxBG3LastX = 0;
|
||||
int gfxBG3LastY = 0;
|
||||
int gfxLastVCOUNT = 0;
|
||||
|
|
3204
src/agb/GBAGfx.h
3204
src/agb/GBAGfx.h
File diff suppressed because it is too large
Load Diff
2166
src/agb/GBALink.cpp
2166
src/agb/GBALink.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,124 +1,124 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include<winsock.h>
|
||||
|
||||
#ifndef LINKH
|
||||
#define LINKH
|
||||
#define LINK_PARENTLOST 0x80
|
||||
#define UNSUPPORTED -1
|
||||
#define MULTIPLAYER 0
|
||||
#define NORMAL8 1
|
||||
#define NORMAL32 2
|
||||
#define UART 3
|
||||
#define JOYBUS 4
|
||||
#define GP 5
|
||||
#define RFU_INIT 0
|
||||
#define RFU_COMM 1
|
||||
#define RFU_SEND 2
|
||||
#define RFU_RECV 3
|
||||
|
||||
typedef struct {
|
||||
WORD linkdata[4];
|
||||
WORD linkcmd[4];
|
||||
WORD numtransfers;
|
||||
int lastlinktime;
|
||||
unsigned char numgbas;
|
||||
unsigned char linkflags;
|
||||
int rfu_q[4];
|
||||
u8 rfu_request[4];
|
||||
int rfu_linktime[4];
|
||||
u32 rfu_bdata[4][7];
|
||||
u32 rfu_data[4][32];
|
||||
} LINKDATA;
|
||||
|
||||
class lserver{
|
||||
int numbytes;
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
//timeval udptimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int counter;
|
||||
int done;
|
||||
public:
|
||||
int howmanytimes;
|
||||
SOCKET tcpsocket[4];
|
||||
SOCKADDR_IN udpaddr[4];
|
||||
lserver(void);
|
||||
int Init(void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
};
|
||||
|
||||
class lclient{
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int numbytes;
|
||||
public:
|
||||
bool oncesend;
|
||||
SOCKADDR_IN serverinfo;
|
||||
SOCKET noblock;
|
||||
int numtransfers;
|
||||
lclient(void);
|
||||
int Init(LPHOSTENT, void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
void CheckConn(void);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SOCKET tcpsocket;
|
||||
//SOCKET udpsocket;
|
||||
int numgbas;
|
||||
HANDLE thread;
|
||||
u8 type;
|
||||
u8 server;
|
||||
bool terminate;
|
||||
bool connected;
|
||||
bool speed;
|
||||
bool active;
|
||||
} LANLINKDATA;
|
||||
|
||||
extern void LinkUpdate(void);
|
||||
extern void LinkChildStop(void);
|
||||
extern void LinkChildSend(u16);
|
||||
extern int openLinkLog(void);
|
||||
extern void closeLinkLog();
|
||||
extern void CloseLanLink(void);
|
||||
extern char *MakeInstanceFilename(const char *Input);
|
||||
|
||||
extern LANLINKDATA lanlink;
|
||||
extern FILE *linklogfile;
|
||||
extern int vbaid;
|
||||
extern int linklog;
|
||||
extern bool adapter;
|
||||
extern bool linkenable;
|
||||
extern int linktimeout;
|
||||
extern lclient lc;
|
||||
extern int linkid;
|
||||
|
||||
#endif
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include<winsock.h>
|
||||
|
||||
#ifndef LINKH
|
||||
#define LINKH
|
||||
#define LINK_PARENTLOST 0x80
|
||||
#define UNSUPPORTED -1
|
||||
#define MULTIPLAYER 0
|
||||
#define NORMAL8 1
|
||||
#define NORMAL32 2
|
||||
#define UART 3
|
||||
#define JOYBUS 4
|
||||
#define GP 5
|
||||
#define RFU_INIT 0
|
||||
#define RFU_COMM 1
|
||||
#define RFU_SEND 2
|
||||
#define RFU_RECV 3
|
||||
|
||||
typedef struct {
|
||||
WORD linkdata[4];
|
||||
WORD linkcmd[4];
|
||||
WORD numtransfers;
|
||||
int lastlinktime;
|
||||
unsigned char numgbas;
|
||||
unsigned char linkflags;
|
||||
int rfu_q[4];
|
||||
u8 rfu_request[4];
|
||||
int rfu_linktime[4];
|
||||
u32 rfu_bdata[4][7];
|
||||
u32 rfu_data[4][32];
|
||||
} LINKDATA;
|
||||
|
||||
class lserver{
|
||||
int numbytes;
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
//timeval udptimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int counter;
|
||||
int done;
|
||||
public:
|
||||
int howmanytimes;
|
||||
SOCKET tcpsocket[4];
|
||||
SOCKADDR_IN udpaddr[4];
|
||||
lserver(void);
|
||||
int Init(void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
};
|
||||
|
||||
class lclient{
|
||||
fd_set fdset;
|
||||
timeval wsocktimeout;
|
||||
char inbuffer[256], outbuffer[256];
|
||||
int *intinbuffer;
|
||||
u16 *u16inbuffer;
|
||||
int *intoutbuffer;
|
||||
u16 *u16outbuffer;
|
||||
int numbytes;
|
||||
public:
|
||||
bool oncesend;
|
||||
SOCKADDR_IN serverinfo;
|
||||
SOCKET noblock;
|
||||
int numtransfers;
|
||||
lclient(void);
|
||||
int Init(LPHOSTENT, void*);
|
||||
void Send(void);
|
||||
void Recv(void);
|
||||
void CheckConn(void);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SOCKET tcpsocket;
|
||||
//SOCKET udpsocket;
|
||||
int numgbas;
|
||||
HANDLE thread;
|
||||
u8 type;
|
||||
u8 server;
|
||||
bool terminate;
|
||||
bool connected;
|
||||
bool speed;
|
||||
bool active;
|
||||
} LANLINKDATA;
|
||||
|
||||
extern void LinkUpdate(void);
|
||||
extern void LinkChildStop(void);
|
||||
extern void LinkChildSend(u16);
|
||||
extern int openLinkLog(void);
|
||||
extern void closeLinkLog();
|
||||
extern void CloseLanLink(void);
|
||||
extern char *MakeInstanceFilename(const char *Input);
|
||||
|
||||
extern LANLINKDATA lanlink;
|
||||
extern FILE *linklogfile;
|
||||
extern int vbaid;
|
||||
extern int linklog;
|
||||
extern bool adapter;
|
||||
extern bool linkenable;
|
||||
extern int linktimeout;
|
||||
extern lclient lc;
|
||||
extern int linkid;
|
||||
|
||||
#endif
|
||||
|
|
1478
src/agb/GBAinline.h
1478
src/agb/GBAinline.h
File diff suppressed because it is too large
Load Diff
|
@ -1,99 +1,99 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "GBA.h"
|
||||
#include "../Globals.h"
|
||||
#include "../Port.h"
|
||||
|
||||
#define debuggerWriteHalfWord(addr, value) \
|
||||
WRITE16LE((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], (value))
|
||||
|
||||
#define debuggerReadHalfWord(addr) \
|
||||
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
||||
|
||||
static bool agbPrintEnabled = false;
|
||||
static bool agbPrintProtect = false;
|
||||
|
||||
bool agbPrintWrite(u32 address, u16 value)
|
||||
{
|
||||
if(agbPrintEnabled) {
|
||||
if(address == 0x9fe2ffe) { // protect
|
||||
agbPrintProtect = (value != 0);
|
||||
debuggerWriteHalfWord(address, value);
|
||||
return true;
|
||||
} else {
|
||||
if(agbPrintProtect &&
|
||||
((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure
|
||||
|| (address >= 0x8fd0000 && address <= 0x8fdffff)
|
||||
|| (address >= 0x9fd0000 && address <= 0x9fdffff))) {
|
||||
debuggerWriteHalfWord(address, value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void agbPrintReset()
|
||||
{
|
||||
agbPrintProtect = false;
|
||||
}
|
||||
|
||||
void agbPrintEnable(bool enable)
|
||||
{
|
||||
agbPrintEnabled = enable;
|
||||
}
|
||||
|
||||
bool agbPrintIsEnabled()
|
||||
{
|
||||
return agbPrintEnabled;
|
||||
}
|
||||
|
||||
extern void (*dbgOutput)(const char *, u32);
|
||||
|
||||
void agbPrintFlush()
|
||||
{
|
||||
u16 get = debuggerReadHalfWord(0x9fe20fc);
|
||||
u16 put = debuggerReadHalfWord(0x9fe20fe);
|
||||
|
||||
u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16);
|
||||
if(address != 0xfd0000 && address != 0x1fd0000) {
|
||||
dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
|
||||
// get rid of the text otherwise we will continue to be called
|
||||
debuggerWriteHalfWord(0x9fe20fc, put);
|
||||
return;
|
||||
}
|
||||
|
||||
u8 *data = &rom[address];
|
||||
|
||||
while(get != put) {
|
||||
char c = data[get++];
|
||||
char s[2];
|
||||
s[0] = c;
|
||||
s[1] = 0;
|
||||
|
||||
if(systemVerbose & VERBOSE_AGBPRINT)
|
||||
dbgOutput(s, 0);
|
||||
if(c == '\n')
|
||||
break;
|
||||
}
|
||||
debuggerWriteHalfWord(0x9fe20fc, get);
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "GBA.h"
|
||||
#include "../Globals.h"
|
||||
#include "../Port.h"
|
||||
|
||||
#define debuggerWriteHalfWord(addr, value) \
|
||||
WRITE16LE((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask], (value))
|
||||
|
||||
#define debuggerReadHalfWord(addr) \
|
||||
READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
|
||||
|
||||
static bool agbPrintEnabled = false;
|
||||
static bool agbPrintProtect = false;
|
||||
|
||||
bool agbPrintWrite(u32 address, u16 value)
|
||||
{
|
||||
if(agbPrintEnabled) {
|
||||
if(address == 0x9fe2ffe) { // protect
|
||||
agbPrintProtect = (value != 0);
|
||||
debuggerWriteHalfWord(address, value);
|
||||
return true;
|
||||
} else {
|
||||
if(agbPrintProtect &&
|
||||
((address >= 0x9fe20f8 && address <= 0x9fe20ff) // control structure
|
||||
|| (address >= 0x8fd0000 && address <= 0x8fdffff)
|
||||
|| (address >= 0x9fd0000 && address <= 0x9fdffff))) {
|
||||
debuggerWriteHalfWord(address, value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void agbPrintReset()
|
||||
{
|
||||
agbPrintProtect = false;
|
||||
}
|
||||
|
||||
void agbPrintEnable(bool enable)
|
||||
{
|
||||
agbPrintEnabled = enable;
|
||||
}
|
||||
|
||||
bool agbPrintIsEnabled()
|
||||
{
|
||||
return agbPrintEnabled;
|
||||
}
|
||||
|
||||
extern void (*dbgOutput)(const char *, u32);
|
||||
|
||||
void agbPrintFlush()
|
||||
{
|
||||
u16 get = debuggerReadHalfWord(0x9fe20fc);
|
||||
u16 put = debuggerReadHalfWord(0x9fe20fe);
|
||||
|
||||
u32 address = (debuggerReadHalfWord(0x9fe20fa) << 16);
|
||||
if(address != 0xfd0000 && address != 0x1fd0000) {
|
||||
dbgOutput("Did you forget to call AGBPrintInit?\n", 0);
|
||||
// get rid of the text otherwise we will continue to be called
|
||||
debuggerWriteHalfWord(0x9fe20fc, put);
|
||||
return;
|
||||
}
|
||||
|
||||
u8 *data = &rom[address];
|
||||
|
||||
while(get != put) {
|
||||
char c = data[get++];
|
||||
char s[2];
|
||||
s[0] = c;
|
||||
s[1] = 0;
|
||||
|
||||
if(systemVerbose & VERBOSE_AGBPRINT)
|
||||
dbgOutput(s, 0);
|
||||
if(c == '\n')
|
||||
break;
|
||||
}
|
||||
debuggerWriteHalfWord(0x9fe20fc, get);
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_AGBPRINT_H
|
||||
#define VBA_AGBPRINT_H
|
||||
extern void agbPrintEnable(bool);
|
||||
extern bool agbPrintIsEnabled();
|
||||
extern void agbPrintReset();
|
||||
extern bool agbPrintWrite(u32, u16);
|
||||
extern void agbPrintFlush();
|
||||
#endif
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_AGBPRINT_H
|
||||
#define VBA_AGBPRINT_H
|
||||
extern void agbPrintEnable(bool);
|
||||
extern bool agbPrintIsEnabled();
|
||||
extern void agbPrintReset();
|
||||
extern bool agbPrintWrite(u32, u16);
|
||||
extern void agbPrintFlush();
|
||||
#endif
|
||||
|
|
|
@ -1,227 +1,227 @@
|
|||
#include "gbafilter.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern int systemColorDepth;
|
||||
extern int systemRedShift;
|
||||
extern int systemGreenShift;
|
||||
extern int systemBlueShift;
|
||||
|
||||
extern u16 systemColorMap16[0x10000];
|
||||
extern u32 systemColorMap32[0x10000];
|
||||
|
||||
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
||||
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
||||
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
||||
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
|
||||
|
||||
// output R G B
|
||||
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
||||
8, 16, 8, // green
|
||||
0, 8, 16};// blue
|
||||
|
||||
inline void swap(short & a, short & b)
|
||||
{
|
||||
short temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
if (red > 31) red = 31;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
if (blue > 31) blue = 31;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
if (green > 31) green = 31;
|
||||
|
||||
pix = red << systemRedShift;
|
||||
pix += green << systemGreenShift;
|
||||
pix += blue << systemBlueShift;
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
void gbafilter_pal32(u32 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
red = ((int(temp[0]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
//green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
green = ((int(temp[1]) * 160) >> 14) + 32;
|
||||
|
||||
//pix = red << redshift;
|
||||
//pix += green << greenshift;
|
||||
//pix += blue << blueshift;
|
||||
|
||||
pix = red << (systemRedShift - 3);
|
||||
pix += green << (systemGreenShift - 3);
|
||||
pix += blue << (systemBlueShift - 3);
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
// for palette mode to work with the three spoony filters in 32bpp depth
|
||||
|
||||
void gbafilter_pad(u8 * buf, int count)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
} part;
|
||||
unsigned whole;
|
||||
}
|
||||
mask;
|
||||
|
||||
mask.whole = 0x1f << systemRedShift;
|
||||
mask.whole += 0x1f << systemGreenShift;
|
||||
mask.whole += 0x1f << systemBlueShift;
|
||||
|
||||
switch (systemColorDepth)
|
||||
{
|
||||
case 24:
|
||||
while (count--)
|
||||
{
|
||||
*buf++ &= mask.part.r;
|
||||
*buf++ &= mask.part.g;
|
||||
*buf++ &= mask.part.b;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
while (count--)
|
||||
{
|
||||
*((u32*)buf) &= mask.whole;
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void UpdateSystemColorMaps(int lcd)
|
||||
{
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000);
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
#include "gbafilter.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
extern int systemColorDepth;
|
||||
extern int systemRedShift;
|
||||
extern int systemGreenShift;
|
||||
extern int systemBlueShift;
|
||||
|
||||
extern u16 systemColorMap16[0x10000];
|
||||
extern u32 systemColorMap32[0x10000];
|
||||
|
||||
static const unsigned char curve[32] = { 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x10, 0x12,
|
||||
0x14, 0x16, 0x18, 0x1c, 0x20, 0x28, 0x30, 0x38,
|
||||
0x40, 0x48, 0x50, 0x58, 0x60, 0x68, 0x70, 0x80,
|
||||
0x88, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0};
|
||||
|
||||
// output R G B
|
||||
static const unsigned char influence[3 * 3] = { 16, 4, 4, // red
|
||||
8, 16, 8, // green
|
||||
0, 8, 16};// blue
|
||||
|
||||
inline void swap(short & a, short & b)
|
||||
{
|
||||
short temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
if (red > 31) red = 31;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
if (blue > 31) blue = 31;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
if (green > 31) green = 31;
|
||||
|
||||
pix = red << systemRedShift;
|
||||
pix += green << systemGreenShift;
|
||||
pix += blue << systemBlueShift;
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
void gbafilter_pal32(u32 * buf, int count)
|
||||
{
|
||||
short temp[3 * 3], s;
|
||||
unsigned pix;
|
||||
u8 red, green, blue;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
pix = *buf;
|
||||
|
||||
s = curve[(pix >> systemGreenShift) & 0x1f];
|
||||
temp[3] = s * influence[3];
|
||||
temp[4] = s * influence[4];
|
||||
temp[5] = s * influence[5];
|
||||
|
||||
s = curve[(pix >> systemRedShift) & 0x1f];
|
||||
temp[0] = s * influence[0];
|
||||
temp[1] = s * influence[1];
|
||||
temp[2] = s * influence[2];
|
||||
|
||||
s = curve[(pix >> systemBlueShift) & 0x1f];
|
||||
temp[6] = s * influence[6];
|
||||
temp[7] = s * influence[7];
|
||||
temp[8] = s * influence[8];
|
||||
|
||||
if (temp[0] < temp[3]) swap(temp[0], temp[3]);
|
||||
if (temp[0] < temp[6]) swap(temp[0], temp[6]);
|
||||
if (temp[3] < temp[6]) swap(temp[3], temp[6]);
|
||||
temp[3] <<= 1;
|
||||
temp[0] <<= 2;
|
||||
temp[0] += temp[3] + temp[6];
|
||||
|
||||
//red = ((int(temp[0]) * 160) >> 17) + 4;
|
||||
red = ((int(temp[0]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[2] < temp[5]) swap(temp[2], temp[5]);
|
||||
if (temp[2] < temp[8]) swap(temp[2], temp[8]);
|
||||
if (temp[5] < temp[8]) swap(temp[5], temp[8]);
|
||||
temp[5] <<= 1;
|
||||
temp[2] <<= 2;
|
||||
temp[2] += temp[5] + temp[8];
|
||||
|
||||
//blue = ((int(temp[2]) * 160) >> 17) + 4;
|
||||
blue = ((int(temp[2]) * 160) >> 14) + 32;
|
||||
|
||||
if (temp[1] < temp[4]) swap(temp[1], temp[4]);
|
||||
if (temp[1] < temp[7]) swap(temp[1], temp[7]);
|
||||
if (temp[4] < temp[7]) swap(temp[4], temp[7]);
|
||||
temp[4] <<= 1;
|
||||
temp[1] <<= 2;
|
||||
temp[1] += temp[4] + temp[7];
|
||||
|
||||
//green = ((int(temp[1]) * 160) >> 17) + 4;
|
||||
green = ((int(temp[1]) * 160) >> 14) + 32;
|
||||
|
||||
//pix = red << redshift;
|
||||
//pix += green << greenshift;
|
||||
//pix += blue << blueshift;
|
||||
|
||||
pix = red << (systemRedShift - 3);
|
||||
pix += green << (systemGreenShift - 3);
|
||||
pix += blue << (systemBlueShift - 3);
|
||||
|
||||
*buf++ = pix;
|
||||
}
|
||||
}
|
||||
|
||||
// for palette mode to work with the three spoony filters in 32bpp depth
|
||||
|
||||
void gbafilter_pad(u8 * buf, int count)
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
} part;
|
||||
unsigned whole;
|
||||
}
|
||||
mask;
|
||||
|
||||
mask.whole = 0x1f << systemRedShift;
|
||||
mask.whole += 0x1f << systemGreenShift;
|
||||
mask.whole += 0x1f << systemBlueShift;
|
||||
|
||||
switch (systemColorDepth)
|
||||
{
|
||||
case 24:
|
||||
while (count--)
|
||||
{
|
||||
*buf++ &= mask.part.r;
|
||||
*buf++ &= mask.part.g;
|
||||
*buf++ &= mask.part.b;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
while (count--)
|
||||
{
|
||||
*((u32*)buf) &= mask.whole;
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void UpdateSystemColorMaps(int lcd)
|
||||
{
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap16[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal(systemColorMap16, 0x10000);
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
{
|
||||
for(int i = 0; i < 0x10000; i++) {
|
||||
systemColorMap32[i] = ((i & 0x1f) << systemRedShift) |
|
||||
(((i & 0x3e0) >> 5) << systemGreenShift) |
|
||||
(((i & 0x7c00) >> 10) << systemBlueShift);
|
||||
}
|
||||
if (lcd == 1) gbafilter_pal32(systemColorMap32, 0x10000);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "../System.h"
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count);
|
||||
void gbafilter_pal32(u32 * buf, int count);
|
||||
void gbafilter_pad(u8 * buf, int count);
|
||||
#include "../System.h"
|
||||
|
||||
void gbafilter_pal(u16 * buf, int count);
|
||||
void gbafilter_pal32(u32 * buf, int count);
|
||||
void gbafilter_pad(u8 * buf, int count);
|
||||
|
|
10898
src/dmg/GB.cpp
10898
src/dmg/GB.cpp
File diff suppressed because it is too large
Load Diff
128
src/dmg/gb.h
128
src/dmg/gb.h
|
@ -1,64 +1,64 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_GB_GB_H
|
||||
#define VBA_GB_GB_H
|
||||
|
||||
#define C_FLAG 0x10
|
||||
#define H_FLAG 0x20
|
||||
#define N_FLAG 0x40
|
||||
#define Z_FLAG 0x80
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u8 B1, B0;
|
||||
#else
|
||||
u8 B0,B1;
|
||||
#endif
|
||||
} B;
|
||||
u16 W;
|
||||
} gbRegister;
|
||||
|
||||
extern bool gbLoadRom(const char *);
|
||||
extern void gbEmulate(int);
|
||||
extern void gbWriteMemory(register u16, register u8);
|
||||
extern void gbDrawLine();
|
||||
extern bool gbIsGameboyRom(const char *);
|
||||
extern void gbSoundReset();
|
||||
extern void gbSoundSetQuality(int);
|
||||
extern void gbGetHardwareType();
|
||||
extern void gbReset();
|
||||
extern void gbCleanUp();
|
||||
extern void gbCPUInit(const char *,bool);
|
||||
extern bool gbWriteBatteryFile(const char *);
|
||||
extern bool gbWriteBatteryFile(const char *, bool);
|
||||
extern bool gbReadBatteryFile(const char *);
|
||||
extern bool gbWriteSaveState(const char *);
|
||||
extern bool gbWriteMemSaveState(char *, int);
|
||||
extern bool gbReadSaveState(const char *);
|
||||
extern bool gbReadMemSaveState(char *, int);
|
||||
extern void gbSgbRenderBorder();
|
||||
extern bool gbWritePNGFile(const char *);
|
||||
extern bool gbWriteBMPFile(const char *);
|
||||
extern bool gbReadGSASnapshot(const char *);
|
||||
|
||||
extern struct EmulatedSystem GBSystem;
|
||||
|
||||
#endif
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_GB_GB_H
|
||||
#define VBA_GB_GB_H
|
||||
|
||||
#define C_FLAG 0x10
|
||||
#define H_FLAG 0x20
|
||||
#define N_FLAG 0x40
|
||||
#define Z_FLAG 0x80
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
u8 B1, B0;
|
||||
#else
|
||||
u8 B0,B1;
|
||||
#endif
|
||||
} B;
|
||||
u16 W;
|
||||
} gbRegister;
|
||||
|
||||
extern bool gbLoadRom(const char *);
|
||||
extern void gbEmulate(int);
|
||||
extern void gbWriteMemory(register u16, register u8);
|
||||
extern void gbDrawLine();
|
||||
extern bool gbIsGameboyRom(const char *);
|
||||
extern void gbSoundReset();
|
||||
extern void gbSoundSetQuality(int);
|
||||
extern void gbGetHardwareType();
|
||||
extern void gbReset();
|
||||
extern void gbCleanUp();
|
||||
extern void gbCPUInit(const char *,bool);
|
||||
extern bool gbWriteBatteryFile(const char *);
|
||||
extern bool gbWriteBatteryFile(const char *, bool);
|
||||
extern bool gbReadBatteryFile(const char *);
|
||||
extern bool gbWriteSaveState(const char *);
|
||||
extern bool gbWriteMemSaveState(char *, int);
|
||||
extern bool gbReadSaveState(const char *);
|
||||
extern bool gbReadMemSaveState(char *, int);
|
||||
extern void gbSgbRenderBorder();
|
||||
extern bool gbWritePNGFile(const char *);
|
||||
extern bool gbWriteBMPFile(const char *);
|
||||
extern bool gbReadGSASnapshot(const char *);
|
||||
|
||||
extern struct EmulatedSystem GBSystem;
|
||||
|
||||
#endif
|
||||
|
|
1044
src/dmg/gbCheats.cpp
1044
src/dmg/gbCheats.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,62 +1,62 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef __VBA_GB_GBCHEATS_H
|
||||
#define __VBA_GB_GBCHEATS_H
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
struct gbXxCheat {
|
||||
char cheatDesc[100];
|
||||
char cheatCode[20];
|
||||
};
|
||||
|
||||
struct gbCheat {
|
||||
char cheatCode[20];
|
||||
char cheatDesc[32];
|
||||
u16 address;
|
||||
int code;
|
||||
u8 compare;
|
||||
u8 value;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
void gbCheatsSaveGame(gzFile);
|
||||
void gbCheatsReadGame(gzFile, int);
|
||||
void gbCheatsSaveCheatList(const char *);
|
||||
bool gbCheatsLoadCheatList(const char *);
|
||||
bool gbCheatReadGSCodeFile(const char *);
|
||||
|
||||
bool gbAddGsCheat(const char *, const char*);
|
||||
bool gbAddGgCheat(const char *, const char*);
|
||||
void gbCheatRemove(int);
|
||||
void gbCheatRemoveAll();
|
||||
void gbCheatEnable(int);
|
||||
void gbCheatDisable(int);
|
||||
u8 gbCheatRead(u16);
|
||||
void gbCheatWrite(bool);
|
||||
bool gbVerifyGsCode(const char *code);
|
||||
bool gbVerifyGgCode(const char *code);
|
||||
|
||||
|
||||
extern int gbCheatNumber;
|
||||
extern gbCheat gbCheatList[100];
|
||||
extern bool gbCheatMap[0x10000];
|
||||
#endif
|
||||
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef __VBA_GB_GBCHEATS_H
|
||||
#define __VBA_GB_GBCHEATS_H
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
struct gbXxCheat {
|
||||
char cheatDesc[100];
|
||||
char cheatCode[20];
|
||||
};
|
||||
|
||||
struct gbCheat {
|
||||
char cheatCode[20];
|
||||
char cheatDesc[32];
|
||||
u16 address;
|
||||
int code;
|
||||
u8 compare;
|
||||
u8 value;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
void gbCheatsSaveGame(gzFile);
|
||||
void gbCheatsReadGame(gzFile, int);
|
||||
void gbCheatsSaveCheatList(const char *);
|
||||
bool gbCheatsLoadCheatList(const char *);
|
||||
bool gbCheatReadGSCodeFile(const char *);
|
||||
|
||||
bool gbAddGsCheat(const char *, const char*);
|
||||
bool gbAddGgCheat(const char *, const char*);
|
||||
void gbCheatRemove(int);
|
||||
void gbCheatRemoveAll();
|
||||
void gbCheatEnable(int);
|
||||
void gbCheatDisable(int);
|
||||
u8 gbCheatRead(u16);
|
||||
void gbCheatWrite(bool);
|
||||
bool gbVerifyGsCode(const char *code);
|
||||
bool gbVerifyGgCode(const char *code);
|
||||
|
||||
|
||||
extern int gbCheatNumber;
|
||||
extern gbCheat gbCheatList[100];
|
||||
extern bool gbCheatMap[0x10000];
|
||||
#endif
|
||||
|
||||
|
|
2920
src/dmg/gbCodes.h
2920
src/dmg/gbCodes.h
File diff suppressed because it is too large
Load Diff
2582
src/dmg/gbCodesCB.h
2582
src/dmg/gbCodesCB.h
File diff suppressed because it is too large
Load Diff
|
@ -1,249 +1,249 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../System.h"
|
||||
#include "gbGlobals.h"
|
||||
|
||||
typedef struct {
|
||||
u8 mask;
|
||||
u8 value;
|
||||
const char *mnen;
|
||||
} GBOPCODE;
|
||||
|
||||
#define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff]
|
||||
|
||||
static const char *registers[] =
|
||||
{ "B", "C", "D", "E", "H", "L", "(HL)", "A" };
|
||||
|
||||
static const char *registers16[] =
|
||||
{ "BC", "DE", "HL", "SP", // for some operations
|
||||
"BC", "DE", "HL", "AF" }; // for push/pop
|
||||
|
||||
static const char *cond[] =
|
||||
{ "NZ", "Z", "NC", "C" };
|
||||
|
||||
static char hexDigits[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
static GBOPCODE opcodes[] = {
|
||||
{ 0xff, 0x00, "NOP" },
|
||||
{ 0xcf, 0x01, "LD %R4,%W" },
|
||||
{ 0xff, 0x02, "LD (BC),A" },
|
||||
{ 0xcf, 0x03, "INC %R4" },
|
||||
{ 0xc7, 0x04, "INC %r3" },
|
||||
{ 0xc7, 0x05, "DEC %r3" },
|
||||
{ 0xc7, 0x06, "LD %r3,%B" },
|
||||
{ 0xff, 0x07, "RLCA" },
|
||||
{ 0xff, 0x08, "LD (%W),SP" },
|
||||
{ 0xcf, 0x09, "ADD HL,%R4" },
|
||||
{ 0xff, 0x0a, "LD A,(BC)" },
|
||||
{ 0xcf, 0x0b, "DEC %R4" },
|
||||
{ 0xff, 0x0f, "RRCA" },
|
||||
{ 0xff, 0x10, "STOP" },
|
||||
{ 0xff, 0x12, "LD (DE),A" },
|
||||
{ 0xff, 0x17, "RLA" },
|
||||
{ 0xff, 0x18, "JR %d" },
|
||||
{ 0xff, 0x1a, "LD A,(DE)" },
|
||||
{ 0xff, 0x1f, "RRA" },
|
||||
{ 0xe7, 0x20, "JR %c3,%d" },
|
||||
{ 0xff, 0x22, "LDI (HL),A" },
|
||||
{ 0xff, 0x27, "DAA" },
|
||||
{ 0xff, 0x2a, "LDI A,(HL)" },
|
||||
{ 0xff, 0x2f, "CPL" },
|
||||
{ 0xff, 0x32, "LDD (HL),A" },
|
||||
{ 0xff, 0x37, "SCF" },
|
||||
{ 0xff, 0x3a, "LDD A,(HL)" },
|
||||
{ 0xff, 0x3f, "CCF" },
|
||||
{ 0xff, 0x76, "HALT" },
|
||||
{ 0xc0, 0x40, "LD %r3,%r0" },
|
||||
{ 0xf8, 0x80, "ADD A,%r0" },
|
||||
{ 0xf8, 0x88, "ADC A,%r0" },
|
||||
{ 0xf8, 0x90, "SUB %r0" },
|
||||
{ 0xf8, 0x98, "SBC A,%r0" },
|
||||
{ 0xf8, 0xa0, "AND %r0" },
|
||||
{ 0xf8, 0xa8, "XOR %r0" },
|
||||
{ 0xf8, 0xb0, "OR %r0" },
|
||||
{ 0xf8, 0xb8, "CP %r0" },
|
||||
{ 0xe7, 0xc0, "RET %c3" },
|
||||
{ 0xcf, 0xc1, "POP %t4" },
|
||||
{ 0xe7, 0xc2, "JP %c3,%W" },
|
||||
{ 0xff, 0xc3, "JP %W" },
|
||||
{ 0xe7, 0xc4, "CALL %c3,%W" },
|
||||
{ 0xcf, 0xc5, "PUSH %t4" },
|
||||
{ 0xff, 0xc6, "ADD A,%B" },
|
||||
{ 0xc7, 0xc7, "RST %P" },
|
||||
{ 0xff, 0xc9, "RET" },
|
||||
{ 0xff, 0xcd, "CALL %W" },
|
||||
{ 0xff, 0xce, "ADC %B" },
|
||||
{ 0xff, 0xd6, "SUB %B" },
|
||||
{ 0xff, 0xd9, "RETI" },
|
||||
{ 0xff, 0xde, "SBC %B" },
|
||||
{ 0xff, 0xe0, "LD (FF%B),A" },
|
||||
{ 0xff, 0xe2, "LD (FF00h+C),A" },
|
||||
{ 0xff, 0xe6, "AND %B" },
|
||||
{ 0xff, 0xe8, "ADD SP,%D" },
|
||||
{ 0xff, 0xe9, "LD PC,HL" },
|
||||
{ 0xff, 0xea, "LD (%W),A" },
|
||||
{ 0xff, 0xee, "XOR %B" },
|
||||
{ 0xff, 0xf0, "LD A,(FF%B)" },
|
||||
{ 0xff, 0xf2, "LD A,(FF00h+C)" },
|
||||
{ 0xff, 0xf3, "DI" },
|
||||
{ 0xff, 0xf6, "OR %B" },
|
||||
{ 0xff, 0xf8, "LD HL,SP%D" },
|
||||
{ 0xff, 0xf9, "LD SP,HL" },
|
||||
{ 0xff, 0xfa, "LD A,(%W)" },
|
||||
{ 0xff, 0xfb, "EI" },
|
||||
{ 0xff, 0xfe, "CP %B" },
|
||||
{ 0x00, 0x00, "DB %B" }
|
||||
};
|
||||
|
||||
static GBOPCODE cbOpcodes[] = {
|
||||
{ 0xf8, 0x00, "RLC %r0" },
|
||||
{ 0xf8, 0x08, "RRC %r0" },
|
||||
{ 0xf8, 0x10, "RL %r0" },
|
||||
{ 0xf8, 0x18, "RR %r0" },
|
||||
{ 0xf8, 0x20, "SLA %r0" },
|
||||
{ 0xf8, 0x28, "SRA %r0" },
|
||||
{ 0xf8, 0x30, "SWAP %r0" },
|
||||
{ 0xf8, 0x38, "SRL %r0" },
|
||||
{ 0xc0, 0x40, "BIT %b,%r0" },
|
||||
{ 0xc0, 0x80, "RES %b,%r0" },
|
||||
{ 0xc0, 0xc0, "SET %b,%r0" },
|
||||
{ 0x00, 0x00, "DB CBh,%B" }
|
||||
};
|
||||
|
||||
static char *addHex(char *p, u8 value)
|
||||
{
|
||||
*p++ = hexDigits[value >> 4];
|
||||
*p++ = hexDigits[value & 15];
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *addHex16(char *p, u16 value)
|
||||
{
|
||||
p = addHex(p, value>>8);
|
||||
return addHex(p, value & 255);
|
||||
}
|
||||
|
||||
static char *addStr(char *p, const char *s)
|
||||
{
|
||||
while(*s) {
|
||||
*p++ = *s++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
int gbDis(char *buffer, u16 address)
|
||||
{
|
||||
char *p = buffer;
|
||||
int instr = 1;
|
||||
u16 addr = address;
|
||||
sprintf(p, "%04x ", address);
|
||||
p += 12;
|
||||
|
||||
u8 opcode = GB_READ(address);
|
||||
address++;
|
||||
const char *mnen;
|
||||
GBOPCODE *op;
|
||||
if(opcode == 0xcb) {
|
||||
opcode = GB_READ(address);
|
||||
address++;
|
||||
instr++;
|
||||
op = cbOpcodes;
|
||||
} else {
|
||||
op = opcodes;
|
||||
}
|
||||
while(op->value != (opcode & op->mask)) op++;
|
||||
mnen = op->mnen;
|
||||
|
||||
u8 b0, b1;
|
||||
s8 disp;
|
||||
int shift;
|
||||
|
||||
while(*mnen) {
|
||||
if(*mnen == '%') {
|
||||
mnen++;
|
||||
switch(*mnen++) {
|
||||
case 'W':
|
||||
b0 = GB_READ(address);
|
||||
address++;
|
||||
b1 = GB_READ(address);
|
||||
address++;
|
||||
p = addHex16(p, b0|b1<<8);
|
||||
instr += 2;
|
||||
*p++ = 'h';
|
||||
break;
|
||||
case 'B':
|
||||
p = addHex(p, GB_READ(address));
|
||||
*p++ = 'h';
|
||||
address++;
|
||||
instr++;
|
||||
break;
|
||||
case 'D':
|
||||
disp = GB_READ(address);
|
||||
if(disp >= 0)
|
||||
*p++ = '+';
|
||||
p += sprintf(p, "%d", disp);
|
||||
instr++;
|
||||
break;
|
||||
case 'd':
|
||||
disp = GB_READ(address);
|
||||
address++;
|
||||
p = addHex16(p, address+disp);
|
||||
*p++ = 'h';
|
||||
instr++;
|
||||
break;
|
||||
case 'b':
|
||||
// kind of a hack, but it works :-)
|
||||
*p++ = hexDigits[(opcode >> 3) & 7];
|
||||
break;
|
||||
case 'r':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, registers[(opcode >> shift) & 7]);
|
||||
break;
|
||||
case 'R':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, registers16[(opcode >> shift) & 3]);
|
||||
break;
|
||||
case 't':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, registers16[4+((opcode >> shift) & 3)]);
|
||||
break;
|
||||
case 'P':
|
||||
p = addHex(p, ((opcode >> 3) & 7) * 8);
|
||||
break;
|
||||
case 'c':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, cond[(opcode >> shift) & 3]);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
*p++ = *mnen++;
|
||||
}
|
||||
for(int i = 0; i < instr; i++) {
|
||||
u16 a = addr + i;
|
||||
addHex(buffer+5+i*2, GB_READ(a));
|
||||
}
|
||||
*p = 0;
|
||||
return instr;
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../System.h"
|
||||
#include "gbGlobals.h"
|
||||
|
||||
typedef struct {
|
||||
u8 mask;
|
||||
u8 value;
|
||||
const char *mnen;
|
||||
} GBOPCODE;
|
||||
|
||||
#define GB_READ(x) gbMemoryMap[(x)>>12][(x)&0xfff]
|
||||
|
||||
static const char *registers[] =
|
||||
{ "B", "C", "D", "E", "H", "L", "(HL)", "A" };
|
||||
|
||||
static const char *registers16[] =
|
||||
{ "BC", "DE", "HL", "SP", // for some operations
|
||||
"BC", "DE", "HL", "AF" }; // for push/pop
|
||||
|
||||
static const char *cond[] =
|
||||
{ "NZ", "Z", "NC", "C" };
|
||||
|
||||
static char hexDigits[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
|
||||
static GBOPCODE opcodes[] = {
|
||||
{ 0xff, 0x00, "NOP" },
|
||||
{ 0xcf, 0x01, "LD %R4,%W" },
|
||||
{ 0xff, 0x02, "LD (BC),A" },
|
||||
{ 0xcf, 0x03, "INC %R4" },
|
||||
{ 0xc7, 0x04, "INC %r3" },
|
||||
{ 0xc7, 0x05, "DEC %r3" },
|
||||
{ 0xc7, 0x06, "LD %r3,%B" },
|
||||
{ 0xff, 0x07, "RLCA" },
|
||||
{ 0xff, 0x08, "LD (%W),SP" },
|
||||
{ 0xcf, 0x09, "ADD HL,%R4" },
|
||||
{ 0xff, 0x0a, "LD A,(BC)" },
|
||||
{ 0xcf, 0x0b, "DEC %R4" },
|
||||
{ 0xff, 0x0f, "RRCA" },
|
||||
{ 0xff, 0x10, "STOP" },
|
||||
{ 0xff, 0x12, "LD (DE),A" },
|
||||
{ 0xff, 0x17, "RLA" },
|
||||
{ 0xff, 0x18, "JR %d" },
|
||||
{ 0xff, 0x1a, "LD A,(DE)" },
|
||||
{ 0xff, 0x1f, "RRA" },
|
||||
{ 0xe7, 0x20, "JR %c3,%d" },
|
||||
{ 0xff, 0x22, "LDI (HL),A" },
|
||||
{ 0xff, 0x27, "DAA" },
|
||||
{ 0xff, 0x2a, "LDI A,(HL)" },
|
||||
{ 0xff, 0x2f, "CPL" },
|
||||
{ 0xff, 0x32, "LDD (HL),A" },
|
||||
{ 0xff, 0x37, "SCF" },
|
||||
{ 0xff, 0x3a, "LDD A,(HL)" },
|
||||
{ 0xff, 0x3f, "CCF" },
|
||||
{ 0xff, 0x76, "HALT" },
|
||||
{ 0xc0, 0x40, "LD %r3,%r0" },
|
||||
{ 0xf8, 0x80, "ADD A,%r0" },
|
||||
{ 0xf8, 0x88, "ADC A,%r0" },
|
||||
{ 0xf8, 0x90, "SUB %r0" },
|
||||
{ 0xf8, 0x98, "SBC A,%r0" },
|
||||
{ 0xf8, 0xa0, "AND %r0" },
|
||||
{ 0xf8, 0xa8, "XOR %r0" },
|
||||
{ 0xf8, 0xb0, "OR %r0" },
|
||||
{ 0xf8, 0xb8, "CP %r0" },
|
||||
{ 0xe7, 0xc0, "RET %c3" },
|
||||
{ 0xcf, 0xc1, "POP %t4" },
|
||||
{ 0xe7, 0xc2, "JP %c3,%W" },
|
||||
{ 0xff, 0xc3, "JP %W" },
|
||||
{ 0xe7, 0xc4, "CALL %c3,%W" },
|
||||
{ 0xcf, 0xc5, "PUSH %t4" },
|
||||
{ 0xff, 0xc6, "ADD A,%B" },
|
||||
{ 0xc7, 0xc7, "RST %P" },
|
||||
{ 0xff, 0xc9, "RET" },
|
||||
{ 0xff, 0xcd, "CALL %W" },
|
||||
{ 0xff, 0xce, "ADC %B" },
|
||||
{ 0xff, 0xd6, "SUB %B" },
|
||||
{ 0xff, 0xd9, "RETI" },
|
||||
{ 0xff, 0xde, "SBC %B" },
|
||||
{ 0xff, 0xe0, "LD (FF%B),A" },
|
||||
{ 0xff, 0xe2, "LD (FF00h+C),A" },
|
||||
{ 0xff, 0xe6, "AND %B" },
|
||||
{ 0xff, 0xe8, "ADD SP,%D" },
|
||||
{ 0xff, 0xe9, "LD PC,HL" },
|
||||
{ 0xff, 0xea, "LD (%W),A" },
|
||||
{ 0xff, 0xee, "XOR %B" },
|
||||
{ 0xff, 0xf0, "LD A,(FF%B)" },
|
||||
{ 0xff, 0xf2, "LD A,(FF00h+C)" },
|
||||
{ 0xff, 0xf3, "DI" },
|
||||
{ 0xff, 0xf6, "OR %B" },
|
||||
{ 0xff, 0xf8, "LD HL,SP%D" },
|
||||
{ 0xff, 0xf9, "LD SP,HL" },
|
||||
{ 0xff, 0xfa, "LD A,(%W)" },
|
||||
{ 0xff, 0xfb, "EI" },
|
||||
{ 0xff, 0xfe, "CP %B" },
|
||||
{ 0x00, 0x00, "DB %B" }
|
||||
};
|
||||
|
||||
static GBOPCODE cbOpcodes[] = {
|
||||
{ 0xf8, 0x00, "RLC %r0" },
|
||||
{ 0xf8, 0x08, "RRC %r0" },
|
||||
{ 0xf8, 0x10, "RL %r0" },
|
||||
{ 0xf8, 0x18, "RR %r0" },
|
||||
{ 0xf8, 0x20, "SLA %r0" },
|
||||
{ 0xf8, 0x28, "SRA %r0" },
|
||||
{ 0xf8, 0x30, "SWAP %r0" },
|
||||
{ 0xf8, 0x38, "SRL %r0" },
|
||||
{ 0xc0, 0x40, "BIT %b,%r0" },
|
||||
{ 0xc0, 0x80, "RES %b,%r0" },
|
||||
{ 0xc0, 0xc0, "SET %b,%r0" },
|
||||
{ 0x00, 0x00, "DB CBh,%B" }
|
||||
};
|
||||
|
||||
static char *addHex(char *p, u8 value)
|
||||
{
|
||||
*p++ = hexDigits[value >> 4];
|
||||
*p++ = hexDigits[value & 15];
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *addHex16(char *p, u16 value)
|
||||
{
|
||||
p = addHex(p, value>>8);
|
||||
return addHex(p, value & 255);
|
||||
}
|
||||
|
||||
static char *addStr(char *p, const char *s)
|
||||
{
|
||||
while(*s) {
|
||||
*p++ = *s++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
int gbDis(char *buffer, u16 address)
|
||||
{
|
||||
char *p = buffer;
|
||||
int instr = 1;
|
||||
u16 addr = address;
|
||||
sprintf(p, "%04x ", address);
|
||||
p += 12;
|
||||
|
||||
u8 opcode = GB_READ(address);
|
||||
address++;
|
||||
const char *mnen;
|
||||
GBOPCODE *op;
|
||||
if(opcode == 0xcb) {
|
||||
opcode = GB_READ(address);
|
||||
address++;
|
||||
instr++;
|
||||
op = cbOpcodes;
|
||||
} else {
|
||||
op = opcodes;
|
||||
}
|
||||
while(op->value != (opcode & op->mask)) op++;
|
||||
mnen = op->mnen;
|
||||
|
||||
u8 b0, b1;
|
||||
s8 disp;
|
||||
int shift;
|
||||
|
||||
while(*mnen) {
|
||||
if(*mnen == '%') {
|
||||
mnen++;
|
||||
switch(*mnen++) {
|
||||
case 'W':
|
||||
b0 = GB_READ(address);
|
||||
address++;
|
||||
b1 = GB_READ(address);
|
||||
address++;
|
||||
p = addHex16(p, b0|b1<<8);
|
||||
instr += 2;
|
||||
*p++ = 'h';
|
||||
break;
|
||||
case 'B':
|
||||
p = addHex(p, GB_READ(address));
|
||||
*p++ = 'h';
|
||||
address++;
|
||||
instr++;
|
||||
break;
|
||||
case 'D':
|
||||
disp = GB_READ(address);
|
||||
if(disp >= 0)
|
||||
*p++ = '+';
|
||||
p += sprintf(p, "%d", disp);
|
||||
instr++;
|
||||
break;
|
||||
case 'd':
|
||||
disp = GB_READ(address);
|
||||
address++;
|
||||
p = addHex16(p, address+disp);
|
||||
*p++ = 'h';
|
||||
instr++;
|
||||
break;
|
||||
case 'b':
|
||||
// kind of a hack, but it works :-)
|
||||
*p++ = hexDigits[(opcode >> 3) & 7];
|
||||
break;
|
||||
case 'r':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, registers[(opcode >> shift) & 7]);
|
||||
break;
|
||||
case 'R':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, registers16[(opcode >> shift) & 3]);
|
||||
break;
|
||||
case 't':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, registers16[4+((opcode >> shift) & 3)]);
|
||||
break;
|
||||
case 'P':
|
||||
p = addHex(p, ((opcode >> 3) & 7) * 8);
|
||||
break;
|
||||
case 'c':
|
||||
shift = *mnen++ - '0';
|
||||
p = addStr(p, cond[(opcode >> shift) & 3]);
|
||||
break;
|
||||
}
|
||||
} else
|
||||
*p++ = *mnen++;
|
||||
}
|
||||
for(int i = 0; i < instr; i++) {
|
||||
u16 a = addr + i;
|
||||
addHex(buffer+5+i*2, GB_READ(a));
|
||||
}
|
||||
*p = 0;
|
||||
return instr;
|
||||
}
|
||||
|
|
1202
src/dmg/gbGfx.cpp
1202
src/dmg/gbGfx.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,57 +1,57 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include "../agb/GBA.h"
|
||||
|
||||
u8 *gbMemoryMap[16];
|
||||
|
||||
int gbRomSizeMask = 0;
|
||||
int gbRomSize = 0;
|
||||
int gbRamSizeMask = 0;
|
||||
int gbRamSize = 0;
|
||||
int gbTAMA5ramSize = 0;
|
||||
|
||||
u8 *gbMemory = NULL;
|
||||
u8 *gbVram = NULL;
|
||||
u8 *gbRom = NULL;
|
||||
u8 *gbRam = NULL;
|
||||
u8 *gbWram = NULL;
|
||||
u16 *gbLineBuffer = NULL;
|
||||
u8 *gbTAMA5ram = NULL;
|
||||
|
||||
u16 gbPalette[128];
|
||||
u8 gbBgp[4] = { 0, 1, 2, 3};
|
||||
u8 gbObp0[4] = { 0, 1, 2, 3};
|
||||
u8 gbObp1[4] = { 0, 1, 2, 3};
|
||||
int gbWindowLine = -1;
|
||||
|
||||
bool genericflashcardEnable = false;
|
||||
int gbCgbMode = 0;
|
||||
|
||||
u16 gbColorFilter[32768];
|
||||
int gbColorOption = 0;
|
||||
int gbPaletteOption = 0;
|
||||
int gbEmulatorType = 0;
|
||||
int gbBorderOn = 1;
|
||||
int gbBorderAutomatic = 0;
|
||||
int gbBorderLineSkip = 160;
|
||||
int gbBorderRowSkip = 0;
|
||||
int gbBorderColumnSkip = 0;
|
||||
int gbDmaTicks = 0;
|
||||
|
||||
u8 (*gbSerialFunction)(u8) = NULL;
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include "../agb/GBA.h"
|
||||
|
||||
u8 *gbMemoryMap[16];
|
||||
|
||||
int gbRomSizeMask = 0;
|
||||
int gbRomSize = 0;
|
||||
int gbRamSizeMask = 0;
|
||||
int gbRamSize = 0;
|
||||
int gbTAMA5ramSize = 0;
|
||||
|
||||
u8 *gbMemory = NULL;
|
||||
u8 *gbVram = NULL;
|
||||
u8 *gbRom = NULL;
|
||||
u8 *gbRam = NULL;
|
||||
u8 *gbWram = NULL;
|
||||
u16 *gbLineBuffer = NULL;
|
||||
u8 *gbTAMA5ram = NULL;
|
||||
|
||||
u16 gbPalette[128];
|
||||
u8 gbBgp[4] = { 0, 1, 2, 3};
|
||||
u8 gbObp0[4] = { 0, 1, 2, 3};
|
||||
u8 gbObp1[4] = { 0, 1, 2, 3};
|
||||
int gbWindowLine = -1;
|
||||
|
||||
bool genericflashcardEnable = false;
|
||||
int gbCgbMode = 0;
|
||||
|
||||
u16 gbColorFilter[32768];
|
||||
int gbColorOption = 0;
|
||||
int gbPaletteOption = 0;
|
||||
int gbEmulatorType = 0;
|
||||
int gbBorderOn = 1;
|
||||
int gbBorderAutomatic = 0;
|
||||
int gbBorderLineSkip = 160;
|
||||
int gbBorderRowSkip = 0;
|
||||
int gbBorderColumnSkip = 0;
|
||||
int gbDmaTicks = 0;
|
||||
|
||||
u8 (*gbSerialFunction)(u8) = NULL;
|
||||
|
|
|
@ -1,89 +1,89 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
extern int gbRomSizeMask;
|
||||
extern int gbRomSize;
|
||||
extern int gbRamSize;
|
||||
extern int gbRamSizeMask;
|
||||
extern int gbTAMA5ramSize;
|
||||
|
||||
extern bool useBios;
|
||||
extern bool skipBios;
|
||||
extern u8 *bios;
|
||||
|
||||
extern u8 *gbRom;
|
||||
extern u8 *gbRam;
|
||||
extern u8 *gbVram;
|
||||
extern u8 *gbWram;
|
||||
extern u8 *gbMemory;
|
||||
extern u16 *gbLineBuffer;
|
||||
extern u8 *gbTAMA5ram;
|
||||
|
||||
extern u8 *gbMemoryMap[16];
|
||||
|
||||
extern int gbFrameSkip;
|
||||
extern u16 gbColorFilter[32768];
|
||||
extern int gbColorOption;
|
||||
extern int gbPaletteOption;
|
||||
extern int gbEmulatorType;
|
||||
extern int gbBorderOn;
|
||||
extern int gbBorderAutomatic;
|
||||
extern int gbCgbMode;
|
||||
extern int gbSgbMode;
|
||||
extern int gbWindowLine;
|
||||
extern int gbSpeed;
|
||||
extern u8 gbBgp[4];
|
||||
extern u8 gbObp0[4];
|
||||
extern u8 gbObp1[4];
|
||||
extern u16 gbPalette[128];
|
||||
extern bool gbScreenOn;
|
||||
extern bool gbDrawWindow;
|
||||
extern u8 gbSCYLine[300];
|
||||
// gbSCXLine is used for the emulation (bug) of the SX change
|
||||
// found in the Artic Zone game.
|
||||
extern u8 gbSCXLine[300];
|
||||
// gbBgpLine is used for the emulation of the
|
||||
// Prehistorik Man's title screen scroller.
|
||||
extern u8 gbBgpLine[300];
|
||||
extern u8 gbObp0Line [300];
|
||||
extern u8 gbObp1Line [300];
|
||||
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
|
||||
extern u8 gbSpritesTicks[300];
|
||||
|
||||
extern u8 register_LCDC;
|
||||
extern u8 register_LY;
|
||||
extern u8 register_SCY;
|
||||
extern u8 register_SCX;
|
||||
extern u8 register_WY;
|
||||
extern u8 register_WX;
|
||||
extern u8 register_VBK;
|
||||
extern u8 oldRegister_WY;
|
||||
|
||||
extern int emulating;
|
||||
extern bool genericflashcardEnable;
|
||||
|
||||
extern int gbBorderLineSkip;
|
||||
extern int gbBorderRowSkip;
|
||||
extern int gbBorderColumnSkip;
|
||||
extern int gbDmaTicks;
|
||||
|
||||
extern void gbRenderLine();
|
||||
extern void gbDrawSprites(bool);
|
||||
|
||||
extern u8 (*gbSerialFunction)(u8);
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
extern int gbRomSizeMask;
|
||||
extern int gbRomSize;
|
||||
extern int gbRamSize;
|
||||
extern int gbRamSizeMask;
|
||||
extern int gbTAMA5ramSize;
|
||||
|
||||
extern bool useBios;
|
||||
extern bool skipBios;
|
||||
extern u8 *bios;
|
||||
|
||||
extern u8 *gbRom;
|
||||
extern u8 *gbRam;
|
||||
extern u8 *gbVram;
|
||||
extern u8 *gbWram;
|
||||
extern u8 *gbMemory;
|
||||
extern u16 *gbLineBuffer;
|
||||
extern u8 *gbTAMA5ram;
|
||||
|
||||
extern u8 *gbMemoryMap[16];
|
||||
|
||||
extern int gbFrameSkip;
|
||||
extern u16 gbColorFilter[32768];
|
||||
extern int gbColorOption;
|
||||
extern int gbPaletteOption;
|
||||
extern int gbEmulatorType;
|
||||
extern int gbBorderOn;
|
||||
extern int gbBorderAutomatic;
|
||||
extern int gbCgbMode;
|
||||
extern int gbSgbMode;
|
||||
extern int gbWindowLine;
|
||||
extern int gbSpeed;
|
||||
extern u8 gbBgp[4];
|
||||
extern u8 gbObp0[4];
|
||||
extern u8 gbObp1[4];
|
||||
extern u16 gbPalette[128];
|
||||
extern bool gbScreenOn;
|
||||
extern bool gbDrawWindow;
|
||||
extern u8 gbSCYLine[300];
|
||||
// gbSCXLine is used for the emulation (bug) of the SX change
|
||||
// found in the Artic Zone game.
|
||||
extern u8 gbSCXLine[300];
|
||||
// gbBgpLine is used for the emulation of the
|
||||
// Prehistorik Man's title screen scroller.
|
||||
extern u8 gbBgpLine[300];
|
||||
extern u8 gbObp0Line [300];
|
||||
extern u8 gbObp1Line [300];
|
||||
// gbSpritesTicks is used for the emulation of Parodius' Laser Beam.
|
||||
extern u8 gbSpritesTicks[300];
|
||||
|
||||
extern u8 register_LCDC;
|
||||
extern u8 register_LY;
|
||||
extern u8 register_SCY;
|
||||
extern u8 register_SCX;
|
||||
extern u8 register_WY;
|
||||
extern u8 register_WX;
|
||||
extern u8 register_VBK;
|
||||
extern u8 oldRegister_WY;
|
||||
|
||||
extern int emulating;
|
||||
extern bool genericflashcardEnable;
|
||||
|
||||
extern int gbBorderLineSkip;
|
||||
extern int gbBorderRowSkip;
|
||||
extern int gbBorderColumnSkip;
|
||||
extern int gbDmaTicks;
|
||||
|
||||
extern void gbRenderLine();
|
||||
extern void gbDrawSprites(bool);
|
||||
|
||||
extern u8 (*gbSerialFunction)(u8);
|
||||
|
|
3434
src/dmg/gbMemory.cpp
3434
src/dmg/gbMemory.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,206 +1,206 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct mapperMBC1 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperMemoryModel;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
int mapperRomBank0Remapping;
|
||||
};
|
||||
|
||||
struct mapperMBC2 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
};
|
||||
|
||||
struct mapperMBC3 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int mapperClockLatch;
|
||||
int mapperClockRegister;
|
||||
int mapperSeconds;
|
||||
int mapperMinutes;
|
||||
int mapperHours;
|
||||
int mapperDays;
|
||||
int mapperControl;
|
||||
int mapperLSeconds;
|
||||
int mapperLMinutes;
|
||||
int mapperLHours;
|
||||
int mapperLDays;
|
||||
int mapperLControl;
|
||||
time_t mapperLastTime;
|
||||
};
|
||||
|
||||
struct mapperMBC5 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
int isRumbleCartridge;
|
||||
};
|
||||
|
||||
struct mapperMBC7 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int cs;
|
||||
int sk;
|
||||
int state;
|
||||
int buffer;
|
||||
int idle;
|
||||
int count;
|
||||
int code;
|
||||
int address;
|
||||
int writeEnable;
|
||||
int value;
|
||||
};
|
||||
|
||||
struct mapperHuC1 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperMemoryModel;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
};
|
||||
|
||||
struct mapperHuC3 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int mapperAddress;
|
||||
int mapperRAMFlag;
|
||||
int mapperRAMValue;
|
||||
int mapperRegister1;
|
||||
int mapperRegister2;
|
||||
int mapperRegister3;
|
||||
int mapperRegister4;
|
||||
int mapperRegister5;
|
||||
int mapperRegister6;
|
||||
int mapperRegister7;
|
||||
int mapperRegister8;
|
||||
};
|
||||
|
||||
struct mapperTAMA5 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int mapperRamByteSelect;
|
||||
int mapperCommandNumber;
|
||||
int mapperLastCommandNumber;
|
||||
int mapperCommands[0x10];
|
||||
int mapperRegister;
|
||||
int mapperClockLatch;
|
||||
int mapperClockRegister;
|
||||
int mapperSeconds;
|
||||
int mapperMinutes;
|
||||
int mapperHours;
|
||||
int mapperDays;
|
||||
int mapperMonths;
|
||||
int mapperYears;
|
||||
int mapperControl;
|
||||
int mapperLSeconds;
|
||||
int mapperLMinutes;
|
||||
int mapperLHours;
|
||||
int mapperLDays;
|
||||
int mapperLMonths;
|
||||
int mapperLYears;
|
||||
int mapperLControl;
|
||||
time_t mapperLastTime;
|
||||
};
|
||||
|
||||
struct mapperMMM01 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperMemoryModel;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
int mapperRomBank0Remapping;
|
||||
};
|
||||
|
||||
struct mapperGS3 {
|
||||
int mapperROMBank;
|
||||
};
|
||||
|
||||
extern mapperMBC1 gbDataMBC1;
|
||||
extern mapperMBC2 gbDataMBC2;
|
||||
extern mapperMBC3 gbDataMBC3;
|
||||
extern mapperMBC5 gbDataMBC5;
|
||||
extern mapperHuC1 gbDataHuC1;
|
||||
extern mapperHuC3 gbDataHuC3;
|
||||
extern mapperTAMA5 gbDataTAMA5;
|
||||
extern mapperMMM01 gbDataMMM01;
|
||||
extern mapperGS3 gbDataGS3;
|
||||
|
||||
void mapperMBC1ROM(u16,u8);
|
||||
void mapperMBC1RAM(u16,u8);
|
||||
u8 mapperMBC1ReadRAM(u16);
|
||||
void mapperMBC2ROM(u16,u8);
|
||||
void mapperMBC2RAM(u16,u8);
|
||||
void mapperMBC3ROM(u16,u8);
|
||||
void mapperMBC3RAM(u16,u8);
|
||||
u8 mapperMBC3ReadRAM(u16);
|
||||
void mapperMBC5ROM(u16,u8);
|
||||
void mapperMBC5RAM(u16,u8);
|
||||
u8 mapperMBC5ReadRAM(u16);
|
||||
void mapperMBC7ROM(u16,u8);
|
||||
void mapperMBC7RAM(u16,u8);
|
||||
u8 mapperMBC7ReadRAM(u16);
|
||||
void mapperHuC1ROM(u16,u8);
|
||||
void mapperHuC1RAM(u16,u8);
|
||||
void mapperHuC3ROM(u16,u8);
|
||||
void mapperHuC3RAM(u16,u8);
|
||||
u8 mapperHuC3ReadRAM(u16);
|
||||
void mapperTAMA5RAM(u16,u8);
|
||||
u8 mapperTAMA5ReadRAM(u16);
|
||||
void memoryUpdateTAMA5Clock();
|
||||
void mapperMMM01ROM(u16,u8);
|
||||
void mapperMMM01RAM(u16,u8);
|
||||
void mapperGGROM(u16,u8);
|
||||
void mapperGS3ROM(u16,u8);
|
||||
//extern void (*mapper)(u16,u8);
|
||||
//extern void (*mapperRAM)(u16,u8);
|
||||
//extern u8 (*mapperReadRAM)(u16);
|
||||
|
||||
extern void memoryUpdateMapMBC1();
|
||||
extern void memoryUpdateMapMBC2();
|
||||
extern void memoryUpdateMapMBC3();
|
||||
extern void memoryUpdateMapMBC5();
|
||||
extern void memoryUpdateMapMBC7();
|
||||
extern void memoryUpdateMapHuC1();
|
||||
extern void memoryUpdateMapHuC3();
|
||||
extern void memoryUpdateMapTAMA5();
|
||||
extern void memoryUpdateMapMMM01();
|
||||
extern void memoryUpdateMapGS3();
|
||||
|
||||
|
||||
|
||||
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004-2006 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct mapperMBC1 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperMemoryModel;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
int mapperRomBank0Remapping;
|
||||
};
|
||||
|
||||
struct mapperMBC2 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
};
|
||||
|
||||
struct mapperMBC3 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int mapperClockLatch;
|
||||
int mapperClockRegister;
|
||||
int mapperSeconds;
|
||||
int mapperMinutes;
|
||||
int mapperHours;
|
||||
int mapperDays;
|
||||
int mapperControl;
|
||||
int mapperLSeconds;
|
||||
int mapperLMinutes;
|
||||
int mapperLHours;
|
||||
int mapperLDays;
|
||||
int mapperLControl;
|
||||
time_t mapperLastTime;
|
||||
};
|
||||
|
||||
struct mapperMBC5 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
int isRumbleCartridge;
|
||||
};
|
||||
|
||||
struct mapperMBC7 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int cs;
|
||||
int sk;
|
||||
int state;
|
||||
int buffer;
|
||||
int idle;
|
||||
int count;
|
||||
int code;
|
||||
int address;
|
||||
int writeEnable;
|
||||
int value;
|
||||
};
|
||||
|
||||
struct mapperHuC1 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperMemoryModel;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
};
|
||||
|
||||
struct mapperHuC3 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int mapperAddress;
|
||||
int mapperRAMFlag;
|
||||
int mapperRAMValue;
|
||||
int mapperRegister1;
|
||||
int mapperRegister2;
|
||||
int mapperRegister3;
|
||||
int mapperRegister4;
|
||||
int mapperRegister5;
|
||||
int mapperRegister6;
|
||||
int mapperRegister7;
|
||||
int mapperRegister8;
|
||||
};
|
||||
|
||||
struct mapperTAMA5 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperRAMAddress;
|
||||
int mapperRamByteSelect;
|
||||
int mapperCommandNumber;
|
||||
int mapperLastCommandNumber;
|
||||
int mapperCommands[0x10];
|
||||
int mapperRegister;
|
||||
int mapperClockLatch;
|
||||
int mapperClockRegister;
|
||||
int mapperSeconds;
|
||||
int mapperMinutes;
|
||||
int mapperHours;
|
||||
int mapperDays;
|
||||
int mapperMonths;
|
||||
int mapperYears;
|
||||
int mapperControl;
|
||||
int mapperLSeconds;
|
||||
int mapperLMinutes;
|
||||
int mapperLHours;
|
||||
int mapperLDays;
|
||||
int mapperLMonths;
|
||||
int mapperLYears;
|
||||
int mapperLControl;
|
||||
time_t mapperLastTime;
|
||||
};
|
||||
|
||||
struct mapperMMM01 {
|
||||
int mapperRAMEnable;
|
||||
int mapperROMBank;
|
||||
int mapperRAMBank;
|
||||
int mapperMemoryModel;
|
||||
int mapperROMHighAddress;
|
||||
int mapperRAMAddress;
|
||||
int mapperRomBank0Remapping;
|
||||
};
|
||||
|
||||
struct mapperGS3 {
|
||||
int mapperROMBank;
|
||||
};
|
||||
|
||||
extern mapperMBC1 gbDataMBC1;
|
||||
extern mapperMBC2 gbDataMBC2;
|
||||
extern mapperMBC3 gbDataMBC3;
|
||||
extern mapperMBC5 gbDataMBC5;
|
||||
extern mapperHuC1 gbDataHuC1;
|
||||
extern mapperHuC3 gbDataHuC3;
|
||||
extern mapperTAMA5 gbDataTAMA5;
|
||||
extern mapperMMM01 gbDataMMM01;
|
||||
extern mapperGS3 gbDataGS3;
|
||||
|
||||
void mapperMBC1ROM(u16,u8);
|
||||
void mapperMBC1RAM(u16,u8);
|
||||
u8 mapperMBC1ReadRAM(u16);
|
||||
void mapperMBC2ROM(u16,u8);
|
||||
void mapperMBC2RAM(u16,u8);
|
||||
void mapperMBC3ROM(u16,u8);
|
||||
void mapperMBC3RAM(u16,u8);
|
||||
u8 mapperMBC3ReadRAM(u16);
|
||||
void mapperMBC5ROM(u16,u8);
|
||||
void mapperMBC5RAM(u16,u8);
|
||||
u8 mapperMBC5ReadRAM(u16);
|
||||
void mapperMBC7ROM(u16,u8);
|
||||
void mapperMBC7RAM(u16,u8);
|
||||
u8 mapperMBC7ReadRAM(u16);
|
||||
void mapperHuC1ROM(u16,u8);
|
||||
void mapperHuC1RAM(u16,u8);
|
||||
void mapperHuC3ROM(u16,u8);
|
||||
void mapperHuC3RAM(u16,u8);
|
||||
u8 mapperHuC3ReadRAM(u16);
|
||||
void mapperTAMA5RAM(u16,u8);
|
||||
u8 mapperTAMA5ReadRAM(u16);
|
||||
void memoryUpdateTAMA5Clock();
|
||||
void mapperMMM01ROM(u16,u8);
|
||||
void mapperMMM01RAM(u16,u8);
|
||||
void mapperGGROM(u16,u8);
|
||||
void mapperGS3ROM(u16,u8);
|
||||
//extern void (*mapper)(u16,u8);
|
||||
//extern void (*mapperRAM)(u16,u8);
|
||||
//extern u8 (*mapperReadRAM)(u16);
|
||||
|
||||
extern void memoryUpdateMapMBC1();
|
||||
extern void memoryUpdateMapMBC2();
|
||||
extern void memoryUpdateMapMBC3();
|
||||
extern void memoryUpdateMapMBC5();
|
||||
extern void memoryUpdateMapMBC7();
|
||||
extern void memoryUpdateMapHuC1();
|
||||
extern void memoryUpdateMapHuC3();
|
||||
extern void memoryUpdateMapTAMA5();
|
||||
extern void memoryUpdateMapMMM01();
|
||||
extern void memoryUpdateMapGS3();
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,229 +1,229 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include "../agb/GBA.h"
|
||||
|
||||
u8 gbPrinterStatus = 0;
|
||||
int gbPrinterState = 0;
|
||||
u8 gbPrinterData[0x280*9];
|
||||
u8 gbPrinterPacket[0x400];
|
||||
int gbPrinterCount = 0;
|
||||
int gbPrinterDataCount = 0;
|
||||
int gbPrinterDataSize = 0;
|
||||
int gbPrinterResult = 0;
|
||||
|
||||
bool gbPrinterCheckCRC()
|
||||
{
|
||||
u16 crc = 0;
|
||||
|
||||
for(int i = 2; i < (6+gbPrinterDataSize); i++) {
|
||||
crc += gbPrinterPacket[i];
|
||||
}
|
||||
|
||||
int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] +
|
||||
(gbPrinterPacket[7+gbPrinterDataSize]<<8);
|
||||
|
||||
return msgCrc == crc;
|
||||
}
|
||||
|
||||
void gbPrinterReset()
|
||||
{
|
||||
gbPrinterState = 0;
|
||||
gbPrinterDataSize = 0;
|
||||
gbPrinterDataCount = 0;
|
||||
gbPrinterCount = 0;
|
||||
gbPrinterStatus = 0;
|
||||
gbPrinterResult = 0;
|
||||
}
|
||||
|
||||
void gbPrinterShowData()
|
||||
{
|
||||
systemGbPrint(gbPrinterData,
|
||||
gbPrinterPacket[6],
|
||||
gbPrinterPacket[7],
|
||||
gbPrinterPacket[8],
|
||||
gbPrinterPacket[9]);
|
||||
/*
|
||||
allegro_init();
|
||||
install_keyboard();
|
||||
set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0);
|
||||
PALETTE pal;
|
||||
pal[0].r = 255;
|
||||
pal[0].g = 255;
|
||||
pal[0].b = 255;
|
||||
pal[1].r = 168;
|
||||
pal[1].g = 168;
|
||||
pal[1].b = 168;
|
||||
pal[2].r = 96;
|
||||
pal[2].g = 96;
|
||||
pal[2].b = 96;
|
||||
pal[3].r = 0;
|
||||
pal[3].g = 0;
|
||||
pal[3].b = 0;
|
||||
set_palette(pal);
|
||||
acquire_screen();
|
||||
u8 *data = gbPrinterData;
|
||||
for(int y = 0; y < 0x12; y++) {
|
||||
for(int x = 0; x < 0x14; x++) {
|
||||
for(int k = 0; k < 8; k++) {
|
||||
int a = *data++;
|
||||
int b = *data++;
|
||||
for(int j = 0; j < 8; j++) {
|
||||
int mask = 1 << (7-j);
|
||||
int c = 0;
|
||||
if(a & mask)
|
||||
c++;
|
||||
if(b & mask)
|
||||
c+=2;
|
||||
putpixel(screen, x*8+j, y*8+k, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
release_screen();
|
||||
while(!keypressed()) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void gbPrinterReceiveData()
|
||||
{
|
||||
if(gbPrinterPacket[3]) { // compressed
|
||||
u8 *data = &gbPrinterPacket[6];
|
||||
u8 *dest = &gbPrinterData[gbPrinterDataCount];
|
||||
int len = 0;
|
||||
while(len < gbPrinterDataSize) {
|
||||
u8 control = *data++;
|
||||
if(control & 0x80) { // repeated data
|
||||
control &= 0x7f;
|
||||
control += 2;
|
||||
memset(dest, *data++, control);
|
||||
len += control;
|
||||
dest += control;
|
||||
} else { // raw data
|
||||
control++;
|
||||
memcpy(dest, data, control);
|
||||
dest += control;
|
||||
data += control;
|
||||
len += control;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memcpy(&gbPrinterData[gbPrinterDataCount],
|
||||
&gbPrinterPacket[6],
|
||||
gbPrinterDataSize);
|
||||
gbPrinterDataCount += gbPrinterDataSize;
|
||||
}
|
||||
}
|
||||
|
||||
void gbPrinterCommand()
|
||||
{
|
||||
switch(gbPrinterPacket[2]) {
|
||||
case 0x01:
|
||||
// reset/initialize packet
|
||||
gbPrinterDataCount = 0;
|
||||
gbPrinterStatus = 0;
|
||||
break;
|
||||
case 0x02:
|
||||
// print packet
|
||||
gbPrinterShowData();
|
||||
break;
|
||||
case 0x04:
|
||||
// data packet
|
||||
gbPrinterReceiveData();
|
||||
break;
|
||||
case 0x0f:
|
||||
// NUL packet
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u8 gbPrinterSend(u8 b)
|
||||
{
|
||||
switch(gbPrinterState) {
|
||||
case 0:
|
||||
gbPrinterCount = 0;
|
||||
// receiving preamble
|
||||
if(b == 0x88) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
} else {
|
||||
// todo: handle failure
|
||||
gbPrinterReset();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// receiving preamble
|
||||
if(b == 0x33) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
} else {
|
||||
// todo: handle failure
|
||||
gbPrinterReset();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// receiving header
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
if(gbPrinterCount == 6) {
|
||||
gbPrinterState++;
|
||||
gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// receiving data
|
||||
if(gbPrinterDataSize) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
if(gbPrinterCount == (6+gbPrinterDataSize)) {
|
||||
gbPrinterState++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
gbPrinterState++;
|
||||
// intentionally move to next if no data to receive
|
||||
case 4:
|
||||
// receiving CRC
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
break;
|
||||
case 5:
|
||||
// receiving CRC-2
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
if(gbPrinterCheckCRC()) {
|
||||
gbPrinterCommand();
|
||||
}
|
||||
gbPrinterState++;
|
||||
break;
|
||||
case 6:
|
||||
// receiving dummy 1
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterResult = 0x81;
|
||||
gbPrinterState++;
|
||||
break;
|
||||
case 7:
|
||||
// receiving dummy 2
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterResult = gbPrinterStatus;
|
||||
gbPrinterState = 0;
|
||||
gbPrinterCount = 0;
|
||||
break;
|
||||
}
|
||||
return gbPrinterResult;
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include "../agb/GBA.h"
|
||||
|
||||
u8 gbPrinterStatus = 0;
|
||||
int gbPrinterState = 0;
|
||||
u8 gbPrinterData[0x280*9];
|
||||
u8 gbPrinterPacket[0x400];
|
||||
int gbPrinterCount = 0;
|
||||
int gbPrinterDataCount = 0;
|
||||
int gbPrinterDataSize = 0;
|
||||
int gbPrinterResult = 0;
|
||||
|
||||
bool gbPrinterCheckCRC()
|
||||
{
|
||||
u16 crc = 0;
|
||||
|
||||
for(int i = 2; i < (6+gbPrinterDataSize); i++) {
|
||||
crc += gbPrinterPacket[i];
|
||||
}
|
||||
|
||||
int msgCrc = gbPrinterPacket[6+gbPrinterDataSize] +
|
||||
(gbPrinterPacket[7+gbPrinterDataSize]<<8);
|
||||
|
||||
return msgCrc == crc;
|
||||
}
|
||||
|
||||
void gbPrinterReset()
|
||||
{
|
||||
gbPrinterState = 0;
|
||||
gbPrinterDataSize = 0;
|
||||
gbPrinterDataCount = 0;
|
||||
gbPrinterCount = 0;
|
||||
gbPrinterStatus = 0;
|
||||
gbPrinterResult = 0;
|
||||
}
|
||||
|
||||
void gbPrinterShowData()
|
||||
{
|
||||
systemGbPrint(gbPrinterData,
|
||||
gbPrinterPacket[6],
|
||||
gbPrinterPacket[7],
|
||||
gbPrinterPacket[8],
|
||||
gbPrinterPacket[9]);
|
||||
/*
|
||||
allegro_init();
|
||||
install_keyboard();
|
||||
set_gfx_mode(GFX_AUTODETECT, 160, 144, 0, 0);
|
||||
PALETTE pal;
|
||||
pal[0].r = 255;
|
||||
pal[0].g = 255;
|
||||
pal[0].b = 255;
|
||||
pal[1].r = 168;
|
||||
pal[1].g = 168;
|
||||
pal[1].b = 168;
|
||||
pal[2].r = 96;
|
||||
pal[2].g = 96;
|
||||
pal[2].b = 96;
|
||||
pal[3].r = 0;
|
||||
pal[3].g = 0;
|
||||
pal[3].b = 0;
|
||||
set_palette(pal);
|
||||
acquire_screen();
|
||||
u8 *data = gbPrinterData;
|
||||
for(int y = 0; y < 0x12; y++) {
|
||||
for(int x = 0; x < 0x14; x++) {
|
||||
for(int k = 0; k < 8; k++) {
|
||||
int a = *data++;
|
||||
int b = *data++;
|
||||
for(int j = 0; j < 8; j++) {
|
||||
int mask = 1 << (7-j);
|
||||
int c = 0;
|
||||
if(a & mask)
|
||||
c++;
|
||||
if(b & mask)
|
||||
c+=2;
|
||||
putpixel(screen, x*8+j, y*8+k, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
release_screen();
|
||||
while(!keypressed()) {
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void gbPrinterReceiveData()
|
||||
{
|
||||
if(gbPrinterPacket[3]) { // compressed
|
||||
u8 *data = &gbPrinterPacket[6];
|
||||
u8 *dest = &gbPrinterData[gbPrinterDataCount];
|
||||
int len = 0;
|
||||
while(len < gbPrinterDataSize) {
|
||||
u8 control = *data++;
|
||||
if(control & 0x80) { // repeated data
|
||||
control &= 0x7f;
|
||||
control += 2;
|
||||
memset(dest, *data++, control);
|
||||
len += control;
|
||||
dest += control;
|
||||
} else { // raw data
|
||||
control++;
|
||||
memcpy(dest, data, control);
|
||||
dest += control;
|
||||
data += control;
|
||||
len += control;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memcpy(&gbPrinterData[gbPrinterDataCount],
|
||||
&gbPrinterPacket[6],
|
||||
gbPrinterDataSize);
|
||||
gbPrinterDataCount += gbPrinterDataSize;
|
||||
}
|
||||
}
|
||||
|
||||
void gbPrinterCommand()
|
||||
{
|
||||
switch(gbPrinterPacket[2]) {
|
||||
case 0x01:
|
||||
// reset/initialize packet
|
||||
gbPrinterDataCount = 0;
|
||||
gbPrinterStatus = 0;
|
||||
break;
|
||||
case 0x02:
|
||||
// print packet
|
||||
gbPrinterShowData();
|
||||
break;
|
||||
case 0x04:
|
||||
// data packet
|
||||
gbPrinterReceiveData();
|
||||
break;
|
||||
case 0x0f:
|
||||
// NUL packet
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
u8 gbPrinterSend(u8 b)
|
||||
{
|
||||
switch(gbPrinterState) {
|
||||
case 0:
|
||||
gbPrinterCount = 0;
|
||||
// receiving preamble
|
||||
if(b == 0x88) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
} else {
|
||||
// todo: handle failure
|
||||
gbPrinterReset();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
// receiving preamble
|
||||
if(b == 0x33) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
} else {
|
||||
// todo: handle failure
|
||||
gbPrinterReset();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// receiving header
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
if(gbPrinterCount == 6) {
|
||||
gbPrinterState++;
|
||||
gbPrinterDataSize = gbPrinterPacket[4] + (gbPrinterPacket[5]<<8);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// receiving data
|
||||
if(gbPrinterDataSize) {
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
if(gbPrinterCount == (6+gbPrinterDataSize)) {
|
||||
gbPrinterState++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
gbPrinterState++;
|
||||
// intentionally move to next if no data to receive
|
||||
case 4:
|
||||
// receiving CRC
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterState++;
|
||||
break;
|
||||
case 5:
|
||||
// receiving CRC-2
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
if(gbPrinterCheckCRC()) {
|
||||
gbPrinterCommand();
|
||||
}
|
||||
gbPrinterState++;
|
||||
break;
|
||||
case 6:
|
||||
// receiving dummy 1
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterResult = 0x81;
|
||||
gbPrinterState++;
|
||||
break;
|
||||
case 7:
|
||||
// receiving dummy 2
|
||||
gbPrinterPacket[gbPrinterCount++] = b;
|
||||
gbPrinterResult = gbPrinterStatus;
|
||||
gbPrinterState = 0;
|
||||
gbPrinterCount = 0;
|
||||
break;
|
||||
}
|
||||
return gbPrinterResult;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
extern u8 gbPrinterSend(u8 b);
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
extern u8 gbPrinterSend(u8 b);
|
||||
|
|
1834
src/dmg/gbSGB.cpp
1834
src/dmg/gbSGB.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,39 +1,39 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
void gbSgbInit();
|
||||
void gbSgbShutdown();
|
||||
void gbSgbCommand();
|
||||
void gbSgbResetPacketState();
|
||||
void gbSgbReset();
|
||||
void gbSgbDoBitTransfer(u8);
|
||||
void gbSgbSaveGame(gzFile);
|
||||
void gbSgbReadGame(gzFile, int version);
|
||||
void gbSgbRenderBorder();
|
||||
|
||||
extern u8 gbSgbATF[20*18];
|
||||
extern int gbSgbMode;
|
||||
extern int gbSgbMask;
|
||||
extern int gbSgbMultiplayer;
|
||||
extern u8 gbSgbNextController;
|
||||
extern int gbSgbPacketTimeout;
|
||||
extern u8 gbSgbReadingController;
|
||||
extern int gbSgbFourPlayers;
|
||||
|
||||
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
void gbSgbInit();
|
||||
void gbSgbShutdown();
|
||||
void gbSgbCommand();
|
||||
void gbSgbResetPacketState();
|
||||
void gbSgbReset();
|
||||
void gbSgbDoBitTransfer(u8);
|
||||
void gbSgbSaveGame(gzFile);
|
||||
void gbSgbReadGame(gzFile, int version);
|
||||
void gbSgbRenderBorder();
|
||||
|
||||
extern u8 gbSgbATF[20*18];
|
||||
extern int gbSgbMode;
|
||||
extern int gbSgbMask;
|
||||
extern int gbSgbMultiplayer;
|
||||
extern u8 gbSgbNextController;
|
||||
extern int gbSgbPacketTimeout;
|
||||
extern u8 gbSgbReadingController;
|
||||
extern int gbSgbFourPlayers;
|
||||
|
||||
|
||||
|
|
|
@ -1,412 +1,412 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
// Copyright (C) 2007-2008 VBA-M development team
|
||||
// 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, 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.
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#include "../System.h"
|
||||
#include "../Util.h"
|
||||
#include "gbGlobals.h"
|
||||
#include "gbSound.h"
|
||||
|
||||
#include "gb_apu/Gb_Apu.h"
|
||||
#include "gb_apu/Effects_Buffer.h"
|
||||
|
||||
static Gb_Apu* gb_apu;
|
||||
static Simple_Effects_Buffer* stereo_buffer;
|
||||
|
||||
extern u16 soundFinalWave[1470];
|
||||
extern int soundVolume;
|
||||
|
||||
extern int gbHardware;
|
||||
|
||||
extern void soundResume();
|
||||
|
||||
extern int soundBufferLen;
|
||||
extern int soundQuality;
|
||||
extern bool soundPaused;
|
||||
extern int soundTicks;
|
||||
extern int SOUND_CLOCK_TICKS;
|
||||
extern u32 soundNextPosition;
|
||||
|
||||
extern int soundDebug;
|
||||
|
||||
extern bool soundEcho;
|
||||
extern bool soundLowPass;
|
||||
extern bool soundReverse;
|
||||
extern bool soundOffFlag;
|
||||
|
||||
int const ticks_to_time = 2 * GB_APU_OVERCLOCK;
|
||||
|
||||
static inline blip_time_t blip_time()
|
||||
{
|
||||
return (SOUND_CLOCK_TICKS - soundTicks) * ticks_to_time;
|
||||
}
|
||||
|
||||
u8 gbSoundRead( u16 address )
|
||||
{
|
||||
if ( gb_apu && address >= NR10 && address <= 0xFF3F )
|
||||
return gb_apu->read_register( blip_time(), address );
|
||||
|
||||
return gbMemory[address];
|
||||
}
|
||||
|
||||
void gbSoundEvent(register u16 address, register int data)
|
||||
{
|
||||
int freq = 0;
|
||||
|
||||
gbMemory[address] = data;
|
||||
|
||||
#ifndef FINAL_VERSION
|
||||
if(soundDebug) {
|
||||
// don't translate. debug only
|
||||
log("Sound event: %08lx %02x\n", address, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( gb_apu && address >= NR10 && address <= 0xFF3F )
|
||||
gb_apu->write_register( blip_time(), address, data );
|
||||
}
|
||||
|
||||
static void end_frame( blip_time_t time )
|
||||
{
|
||||
gb_apu ->end_frame( time );
|
||||
stereo_buffer->end_frame( time );
|
||||
}
|
||||
|
||||
static void flush_samples()
|
||||
{
|
||||
// number of samples in output buffer
|
||||
int const out_buf_size = soundBufferLen / sizeof *soundFinalWave;
|
||||
|
||||
// Keep filling and writing soundFinalWave until it can't be fully filled
|
||||
while ( stereo_buffer->samples_avail() >= out_buf_size )
|
||||
{
|
||||
stereo_buffer->read_samples( (blip_sample_t*) soundFinalWave, out_buf_size );
|
||||
if(systemSoundOn)
|
||||
{
|
||||
if(soundPaused)
|
||||
soundResume();
|
||||
|
||||
systemWriteDataToSoundBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int const chan_count = 4;
|
||||
|
||||
gb_effects_config_t gb_effects_config;
|
||||
static gb_effects_config_t gb_effects_config_current;
|
||||
|
||||
static void apply_effects()
|
||||
{
|
||||
gb_effects_config_current = gb_effects_config;
|
||||
|
||||
stereo_buffer->config().enabled = gb_effects_config_current.enabled;
|
||||
stereo_buffer->config().echo = gb_effects_config_current.echo;
|
||||
stereo_buffer->config().stereo = gb_effects_config_current.stereo;
|
||||
stereo_buffer->config().surround = gb_effects_config_current.surround;
|
||||
stereo_buffer->apply_config();
|
||||
|
||||
for ( int i = 0; i < chan_count; i++ )
|
||||
{
|
||||
Multi_Buffer::channel_t ch = stereo_buffer->channel( i );
|
||||
gb_apu->set_output( ch.center, ch.left, ch.right, i );
|
||||
}
|
||||
}
|
||||
|
||||
void gbSoundTick()
|
||||
{
|
||||
if ( systemSoundOn && gb_apu && stereo_buffer )
|
||||
{
|
||||
// Run sound hardware to present
|
||||
end_frame( SOUND_CLOCK_TICKS * ticks_to_time );
|
||||
|
||||
flush_samples();
|
||||
|
||||
gb_effects_config.enabled = soundEcho;
|
||||
|
||||
// Update effects config if it was changed
|
||||
if ( memcmp( &gb_effects_config_current, &gb_effects_config,
|
||||
sizeof gb_effects_config ) )
|
||||
apply_effects();
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_apu()
|
||||
{
|
||||
// Use DMG or CGB sound differences based on type of game
|
||||
gb_apu->reset( gbHardware & 1 ? gb_apu->mode_dmg : gb_apu->mode_cgb );
|
||||
|
||||
if ( stereo_buffer )
|
||||
stereo_buffer->clear();
|
||||
|
||||
soundTicks = SOUND_CLOCK_TICKS;
|
||||
}
|
||||
|
||||
static void remake_stereo_buffer()
|
||||
{
|
||||
// Stereo_Buffer
|
||||
delete stereo_buffer;
|
||||
stereo_buffer = 0;
|
||||
|
||||
stereo_buffer = new Simple_Effects_Buffer; // TODO: handle out of memory
|
||||
stereo_buffer->set_sample_rate( 44100 / soundQuality ); // TODO: handle out of memory
|
||||
stereo_buffer->clock_rate( gb_apu->clock_rate );
|
||||
|
||||
// APU
|
||||
static int const chan_types [chan_count] = {
|
||||
Multi_Buffer::wave_type+1, Multi_Buffer::wave_type+2,
|
||||
Multi_Buffer::wave_type+3, Multi_Buffer::mixed_type+1
|
||||
};
|
||||
stereo_buffer->set_channel_count( chan_count, chan_types );
|
||||
|
||||
if ( !gb_apu )
|
||||
{
|
||||
gb_apu = new Gb_Apu;
|
||||
reset_apu();
|
||||
}
|
||||
|
||||
apply_effects();
|
||||
}
|
||||
|
||||
void gbSoundReset()
|
||||
{
|
||||
gb_effects_config.echo = 0.20f;
|
||||
gb_effects_config.stereo = 0.15f;
|
||||
gb_effects_config.surround = false;
|
||||
|
||||
SOUND_CLOCK_TICKS = 20000;
|
||||
|
||||
remake_stereo_buffer();
|
||||
reset_apu();
|
||||
|
||||
soundPaused = 1;
|
||||
soundNextPosition = 0;
|
||||
|
||||
// don't translate
|
||||
#ifndef FINAL_VERSION
|
||||
if(soundDebug) {
|
||||
log("*** Sound Init ***\n");
|
||||
}
|
||||
#endif
|
||||
gbSoundEvent(0xff10, 0x80);
|
||||
gbSoundEvent(0xff11, 0xbf);
|
||||
gbSoundEvent(0xff12, 0xf3);
|
||||
gbSoundEvent(0xff14, 0xbf);
|
||||
gbSoundEvent(0xff16, 0x3f);
|
||||
gbSoundEvent(0xff17, 0x00);
|
||||
gbSoundEvent(0xff19, 0xbf);
|
||||
|
||||
gbSoundEvent(0xff1a, 0x7f);
|
||||
gbSoundEvent(0xff1b, 0xff);
|
||||
gbSoundEvent(0xff1c, 0xbf);
|
||||
gbSoundEvent(0xff1e, 0xbf);
|
||||
|
||||
gbSoundEvent(0xff20, 0xff);
|
||||
gbSoundEvent(0xff21, 0x00);
|
||||
gbSoundEvent(0xff22, 0x00);
|
||||
gbSoundEvent(0xff23, 0xbf);
|
||||
gbSoundEvent(0xff24, 0x77);
|
||||
gbSoundEvent(0xff25, 0xf3);
|
||||
|
||||
if (gbHardware & 0x4)
|
||||
gbSoundEvent(0xff26, 0xf0);
|
||||
else
|
||||
gbSoundEvent(0xff26, 0xf1);
|
||||
|
||||
// don't translate
|
||||
#ifndef FINAL_VERSION
|
||||
if(soundDebug) {
|
||||
log("*** Sound Init Complete ***\n");
|
||||
}
|
||||
#endif
|
||||
int addr = 0xff30;
|
||||
|
||||
while(addr < 0xff40) {
|
||||
gbMemory[addr++] = 0x00;
|
||||
gbMemory[addr++] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
extern bool soundInit();
|
||||
extern void soundShutdown();
|
||||
|
||||
void gbSoundSetQuality(int quality)
|
||||
{
|
||||
if ( soundQuality != quality )
|
||||
{
|
||||
if ( systemCanChangeSoundQuality() )
|
||||
{
|
||||
if ( !soundOffFlag )
|
||||
soundShutdown();
|
||||
|
||||
soundQuality = quality;
|
||||
soundNextPosition = 0;
|
||||
|
||||
if ( !soundOffFlag )
|
||||
soundInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
soundQuality = quality;
|
||||
soundNextPosition = 0;
|
||||
}
|
||||
|
||||
remake_stereo_buffer();
|
||||
}
|
||||
}
|
||||
|
||||
static char dummy_buf [735 * 2];
|
||||
|
||||
#define SKIP( type, name ) { dummy_buf, sizeof (type) }
|
||||
|
||||
// funny expr at end ensures that type matches type of variable
|
||||
#define LOAD( type, name ) { &name, sizeof (name) + (&name - (type*) &name) }
|
||||
|
||||
static variable_desc gbsound_format [] =
|
||||
{
|
||||
SKIP( int, soundPaused ),
|
||||
SKIP( int, soundPlay ),
|
||||
SKIP( int, soundTicks ),
|
||||
SKIP( int, SOUND_CLOCK_TICKS ),
|
||||
SKIP( int, soundLevel1 ),
|
||||
SKIP( int, soundLevel2 ),
|
||||
SKIP( int, soundBalance ),
|
||||
SKIP( int, soundMasterOn ),
|
||||
SKIP( int, soundIndex ),
|
||||
SKIP( int, soundVIN ),
|
||||
SKIP( int, soundOn [0] ),
|
||||
SKIP( int, soundATL [0] ),
|
||||
SKIP( int, sound1Skip ),
|
||||
SKIP( int, soundIndex [0] ),
|
||||
SKIP( int, sound1Continue ),
|
||||
SKIP( int, soundEnvelopeVolume [0] ),
|
||||
SKIP( int, soundEnvelopeATL [0] ),
|
||||
SKIP( int, sound1EnvelopeATLReload ),
|
||||
SKIP( int, sound1EnvelopeUpDown ),
|
||||
SKIP( int, sound1SweepATL ),
|
||||
SKIP( int, sound1SweepATLReload ),
|
||||
SKIP( int, sound1SweepSteps ),
|
||||
SKIP( int, sound1SweepUpDown ),
|
||||
SKIP( int, sound1SweepStep ),
|
||||
SKIP( int, soundOn [1] ),
|
||||
SKIP( int, soundATL [1] ),
|
||||
SKIP( int, sound2Skip ),
|
||||
SKIP( int, soundIndex [1] ),
|
||||
SKIP( int, sound2Continue ),
|
||||
SKIP( int, soundEnvelopeVolume [1] ),
|
||||
SKIP( int, soundEnvelopeATL [1] ),
|
||||
SKIP( int, sound2EnvelopeATLReload ),
|
||||
SKIP( int, sound2EnvelopeUpDown ),
|
||||
SKIP( int, soundOn [2] ),
|
||||
SKIP( int, soundATL [2] ),
|
||||
SKIP( int, sound3Skip ),
|
||||
SKIP( int, soundIndex [2] ),
|
||||
SKIP( int, sound3Continue ),
|
||||
SKIP( int, sound3OutputLevel ),
|
||||
SKIP( int, soundOn [3] ),
|
||||
SKIP( int, soundATL [3] ),
|
||||
SKIP( int, sound4Skip ),
|
||||
SKIP( int, soundIndex [3] ),
|
||||
SKIP( int, sound4Clock ),
|
||||
SKIP( int, sound4ShiftRight ),
|
||||
SKIP( int, sound4ShiftSkip ),
|
||||
SKIP( int, sound4ShiftIndex ),
|
||||
SKIP( int, sound4NSteps ),
|
||||
SKIP( int, sound4CountDown ),
|
||||
SKIP( int, sound4Continue ),
|
||||
SKIP( int, soundEnvelopeVolume [2] ),
|
||||
SKIP( int, soundEnvelopeATL [2] ),
|
||||
SKIP( int, sound4EnvelopeATLReload ),
|
||||
SKIP( int, sound4EnvelopeUpDown ),
|
||||
SKIP( int, soundEnableFlag ),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static variable_desc gbsound_format2 [] =
|
||||
{
|
||||
SKIP( int, sound1ATLreload ),
|
||||
SKIP( int, freq1low ),
|
||||
SKIP( int, freq1high ),
|
||||
SKIP( int, sound2ATLreload ),
|
||||
SKIP( int, freq2low ),
|
||||
SKIP( int, freq2high ),
|
||||
SKIP( int, sound3ATLreload ),
|
||||
SKIP( int, freq3low ),
|
||||
SKIP( int, freq3high ),
|
||||
SKIP( int, sound4ATLreload ),
|
||||
SKIP( int, freq4 ),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static variable_desc gbsound_format3 [] =
|
||||
{
|
||||
SKIP( u8[2*735], soundBuffer ),
|
||||
SKIP( u8[2*735], soundBuffer ),
|
||||
SKIP( u16[735], soundFinalWave ),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
void gbSoundSaveGame(gzFile gzFile)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
enum {
|
||||
nr10 = 0,
|
||||
nr11, nr12, nr13, nr14,
|
||||
nr20, nr21, nr22, nr23, nr24,
|
||||
nr30, nr31, nr32, nr33, nr34,
|
||||
nr40, nr41, nr42, nr43, nr44,
|
||||
nr50, nr51, nr52
|
||||
};
|
||||
|
||||
void gbSoundReadGame(int version,gzFile gzFile)
|
||||
{
|
||||
return; // TODO: apparently GB save states don't work in the main emulator
|
||||
|
||||
// Load state
|
||||
utilReadData( gzFile, gbsound_format );
|
||||
|
||||
if ( version >= 11 )
|
||||
utilReadData( gzFile, gbsound_format2 );
|
||||
|
||||
utilReadData( gzFile, gbsound_format3 );
|
||||
|
||||
int quality = 1;
|
||||
if ( version >= 7 )
|
||||
quality = utilReadInt( gzFile );
|
||||
|
||||
gbSoundSetQuality( quality );
|
||||
|
||||
// Convert to format Gb_Apu uses
|
||||
reset_apu();
|
||||
gb_apu_state_t s;
|
||||
gb_apu->save_state( &s ); // use fresh values for anything not restored
|
||||
|
||||
// Only some registers are properly preserved
|
||||
static int const regs_to_copy [] = {
|
||||
nr10, nr11, nr12, nr21, nr22, nr30, nr32, nr42, nr43, nr50, nr51, nr52, -1
|
||||
};
|
||||
for ( int i = 0; regs_to_copy [i] >= 0; i++ )
|
||||
s.regs [regs_to_copy [i]] = gbMemory [0xFF10 + regs_to_copy [i]];
|
||||
|
||||
memcpy( &s.regs [0x20], &gbMemory [0xFF30], 0x10 ); // wave
|
||||
|
||||
gb_apu->load_state( s );
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005-2006 Forgotten and the VBA development team
|
||||
// Copyright (C) 2007-2008 VBA-M development team
|
||||
// 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, 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.
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#include "../System.h"
|
||||
#include "../Util.h"
|
||||
#include "gbGlobals.h"
|
||||
#include "gbSound.h"
|
||||
|
||||
#include "gb_apu/Gb_Apu.h"
|
||||
#include "gb_apu/Effects_Buffer.h"
|
||||
|
||||
static Gb_Apu* gb_apu;
|
||||
static Simple_Effects_Buffer* stereo_buffer;
|
||||
|
||||
extern u16 soundFinalWave[1470];
|
||||
extern int soundVolume;
|
||||
|
||||
extern int gbHardware;
|
||||
|
||||
extern void soundResume();
|
||||
|
||||
extern int soundBufferLen;
|
||||
extern int soundQuality;
|
||||
extern bool soundPaused;
|
||||
extern int soundTicks;
|
||||
extern int SOUND_CLOCK_TICKS;
|
||||
extern u32 soundNextPosition;
|
||||
|
||||
extern int soundDebug;
|
||||
|
||||
extern bool soundEcho;
|
||||
extern bool soundLowPass;
|
||||
extern bool soundReverse;
|
||||
extern bool soundOffFlag;
|
||||
|
||||
int const ticks_to_time = 2 * GB_APU_OVERCLOCK;
|
||||
|
||||
static inline blip_time_t blip_time()
|
||||
{
|
||||
return (SOUND_CLOCK_TICKS - soundTicks) * ticks_to_time;
|
||||
}
|
||||
|
||||
u8 gbSoundRead( u16 address )
|
||||
{
|
||||
if ( gb_apu && address >= NR10 && address <= 0xFF3F )
|
||||
return gb_apu->read_register( blip_time(), address );
|
||||
|
||||
return gbMemory[address];
|
||||
}
|
||||
|
||||
void gbSoundEvent(register u16 address, register int data)
|
||||
{
|
||||
int freq = 0;
|
||||
|
||||
gbMemory[address] = data;
|
||||
|
||||
#ifndef FINAL_VERSION
|
||||
if(soundDebug) {
|
||||
// don't translate. debug only
|
||||
log("Sound event: %08lx %02x\n", address, data);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( gb_apu && address >= NR10 && address <= 0xFF3F )
|
||||
gb_apu->write_register( blip_time(), address, data );
|
||||
}
|
||||
|
||||
static void end_frame( blip_time_t time )
|
||||
{
|
||||
gb_apu ->end_frame( time );
|
||||
stereo_buffer->end_frame( time );
|
||||
}
|
||||
|
||||
static void flush_samples()
|
||||
{
|
||||
// number of samples in output buffer
|
||||
int const out_buf_size = soundBufferLen / sizeof *soundFinalWave;
|
||||
|
||||
// Keep filling and writing soundFinalWave until it can't be fully filled
|
||||
while ( stereo_buffer->samples_avail() >= out_buf_size )
|
||||
{
|
||||
stereo_buffer->read_samples( (blip_sample_t*) soundFinalWave, out_buf_size );
|
||||
if(systemSoundOn)
|
||||
{
|
||||
if(soundPaused)
|
||||
soundResume();
|
||||
|
||||
systemWriteDataToSoundBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int const chan_count = 4;
|
||||
|
||||
gb_effects_config_t gb_effects_config;
|
||||
static gb_effects_config_t gb_effects_config_current;
|
||||
|
||||
static void apply_effects()
|
||||
{
|
||||
gb_effects_config_current = gb_effects_config;
|
||||
|
||||
stereo_buffer->config().enabled = gb_effects_config_current.enabled;
|
||||
stereo_buffer->config().echo = gb_effects_config_current.echo;
|
||||
stereo_buffer->config().stereo = gb_effects_config_current.stereo;
|
||||
stereo_buffer->config().surround = gb_effects_config_current.surround;
|
||||
stereo_buffer->apply_config();
|
||||
|
||||
for ( int i = 0; i < chan_count; i++ )
|
||||
{
|
||||
Multi_Buffer::channel_t ch = stereo_buffer->channel( i );
|
||||
gb_apu->set_output( ch.center, ch.left, ch.right, i );
|
||||
}
|
||||
}
|
||||
|
||||
void gbSoundTick()
|
||||
{
|
||||
if ( systemSoundOn && gb_apu && stereo_buffer )
|
||||
{
|
||||
// Run sound hardware to present
|
||||
end_frame( SOUND_CLOCK_TICKS * ticks_to_time );
|
||||
|
||||
flush_samples();
|
||||
|
||||
gb_effects_config.enabled = soundEcho;
|
||||
|
||||
// Update effects config if it was changed
|
||||
if ( memcmp( &gb_effects_config_current, &gb_effects_config,
|
||||
sizeof gb_effects_config ) )
|
||||
apply_effects();
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_apu()
|
||||
{
|
||||
// Use DMG or CGB sound differences based on type of game
|
||||
gb_apu->reset( gbHardware & 1 ? gb_apu->mode_dmg : gb_apu->mode_cgb );
|
||||
|
||||
if ( stereo_buffer )
|
||||
stereo_buffer->clear();
|
||||
|
||||
soundTicks = SOUND_CLOCK_TICKS;
|
||||
}
|
||||
|
||||
static void remake_stereo_buffer()
|
||||
{
|
||||
// Stereo_Buffer
|
||||
delete stereo_buffer;
|
||||
stereo_buffer = 0;
|
||||
|
||||
stereo_buffer = new Simple_Effects_Buffer; // TODO: handle out of memory
|
||||
stereo_buffer->set_sample_rate( 44100 / soundQuality ); // TODO: handle out of memory
|
||||
stereo_buffer->clock_rate( gb_apu->clock_rate );
|
||||
|
||||
// APU
|
||||
static int const chan_types [chan_count] = {
|
||||
Multi_Buffer::wave_type+1, Multi_Buffer::wave_type+2,
|
||||
Multi_Buffer::wave_type+3, Multi_Buffer::mixed_type+1
|
||||
};
|
||||
stereo_buffer->set_channel_count( chan_count, chan_types );
|
||||
|
||||
if ( !gb_apu )
|
||||
{
|
||||
gb_apu = new Gb_Apu;
|
||||
reset_apu();
|
||||
}
|
||||
|
||||
apply_effects();
|
||||
}
|
||||
|
||||
void gbSoundReset()
|
||||
{
|
||||
gb_effects_config.echo = 0.20f;
|
||||
gb_effects_config.stereo = 0.15f;
|
||||
gb_effects_config.surround = false;
|
||||
|
||||
SOUND_CLOCK_TICKS = 20000;
|
||||
|
||||
remake_stereo_buffer();
|
||||
reset_apu();
|
||||
|
||||
soundPaused = 1;
|
||||
soundNextPosition = 0;
|
||||
|
||||
// don't translate
|
||||
#ifndef FINAL_VERSION
|
||||
if(soundDebug) {
|
||||
log("*** Sound Init ***\n");
|
||||
}
|
||||
#endif
|
||||
gbSoundEvent(0xff10, 0x80);
|
||||
gbSoundEvent(0xff11, 0xbf);
|
||||
gbSoundEvent(0xff12, 0xf3);
|
||||
gbSoundEvent(0xff14, 0xbf);
|
||||
gbSoundEvent(0xff16, 0x3f);
|
||||
gbSoundEvent(0xff17, 0x00);
|
||||
gbSoundEvent(0xff19, 0xbf);
|
||||
|
||||
gbSoundEvent(0xff1a, 0x7f);
|
||||
gbSoundEvent(0xff1b, 0xff);
|
||||
gbSoundEvent(0xff1c, 0xbf);
|
||||
gbSoundEvent(0xff1e, 0xbf);
|
||||
|
||||
gbSoundEvent(0xff20, 0xff);
|
||||
gbSoundEvent(0xff21, 0x00);
|
||||
gbSoundEvent(0xff22, 0x00);
|
||||
gbSoundEvent(0xff23, 0xbf);
|
||||
gbSoundEvent(0xff24, 0x77);
|
||||
gbSoundEvent(0xff25, 0xf3);
|
||||
|
||||
if (gbHardware & 0x4)
|
||||
gbSoundEvent(0xff26, 0xf0);
|
||||
else
|
||||
gbSoundEvent(0xff26, 0xf1);
|
||||
|
||||
// don't translate
|
||||
#ifndef FINAL_VERSION
|
||||
if(soundDebug) {
|
||||
log("*** Sound Init Complete ***\n");
|
||||
}
|
||||
#endif
|
||||
int addr = 0xff30;
|
||||
|
||||
while(addr < 0xff40) {
|
||||
gbMemory[addr++] = 0x00;
|
||||
gbMemory[addr++] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
extern bool soundInit();
|
||||
extern void soundShutdown();
|
||||
|
||||
void gbSoundSetQuality(int quality)
|
||||
{
|
||||
if ( soundQuality != quality )
|
||||
{
|
||||
if ( systemCanChangeSoundQuality() )
|
||||
{
|
||||
if ( !soundOffFlag )
|
||||
soundShutdown();
|
||||
|
||||
soundQuality = quality;
|
||||
soundNextPosition = 0;
|
||||
|
||||
if ( !soundOffFlag )
|
||||
soundInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
soundQuality = quality;
|
||||
soundNextPosition = 0;
|
||||
}
|
||||
|
||||
remake_stereo_buffer();
|
||||
}
|
||||
}
|
||||
|
||||
static char dummy_buf [735 * 2];
|
||||
|
||||
#define SKIP( type, name ) { dummy_buf, sizeof (type) }
|
||||
|
||||
// funny expr at end ensures that type matches type of variable
|
||||
#define LOAD( type, name ) { &name, sizeof (name) + (&name - (type*) &name) }
|
||||
|
||||
static variable_desc gbsound_format [] =
|
||||
{
|
||||
SKIP( int, soundPaused ),
|
||||
SKIP( int, soundPlay ),
|
||||
SKIP( int, soundTicks ),
|
||||
SKIP( int, SOUND_CLOCK_TICKS ),
|
||||
SKIP( int, soundLevel1 ),
|
||||
SKIP( int, soundLevel2 ),
|
||||
SKIP( int, soundBalance ),
|
||||
SKIP( int, soundMasterOn ),
|
||||
SKIP( int, soundIndex ),
|
||||
SKIP( int, soundVIN ),
|
||||
SKIP( int, soundOn [0] ),
|
||||
SKIP( int, soundATL [0] ),
|
||||
SKIP( int, sound1Skip ),
|
||||
SKIP( int, soundIndex [0] ),
|
||||
SKIP( int, sound1Continue ),
|
||||
SKIP( int, soundEnvelopeVolume [0] ),
|
||||
SKIP( int, soundEnvelopeATL [0] ),
|
||||
SKIP( int, sound1EnvelopeATLReload ),
|
||||
SKIP( int, sound1EnvelopeUpDown ),
|
||||
SKIP( int, sound1SweepATL ),
|
||||
SKIP( int, sound1SweepATLReload ),
|
||||
SKIP( int, sound1SweepSteps ),
|
||||
SKIP( int, sound1SweepUpDown ),
|
||||
SKIP( int, sound1SweepStep ),
|
||||
SKIP( int, soundOn [1] ),
|
||||
SKIP( int, soundATL [1] ),
|
||||
SKIP( int, sound2Skip ),
|
||||
SKIP( int, soundIndex [1] ),
|
||||
SKIP( int, sound2Continue ),
|
||||
SKIP( int, soundEnvelopeVolume [1] ),
|
||||
SKIP( int, soundEnvelopeATL [1] ),
|
||||
SKIP( int, sound2EnvelopeATLReload ),
|
||||
SKIP( int, sound2EnvelopeUpDown ),
|
||||
SKIP( int, soundOn [2] ),
|
||||
SKIP( int, soundATL [2] ),
|
||||
SKIP( int, sound3Skip ),
|
||||
SKIP( int, soundIndex [2] ),
|
||||
SKIP( int, sound3Continue ),
|
||||
SKIP( int, sound3OutputLevel ),
|
||||
SKIP( int, soundOn [3] ),
|
||||
SKIP( int, soundATL [3] ),
|
||||
SKIP( int, sound4Skip ),
|
||||
SKIP( int, soundIndex [3] ),
|
||||
SKIP( int, sound4Clock ),
|
||||
SKIP( int, sound4ShiftRight ),
|
||||
SKIP( int, sound4ShiftSkip ),
|
||||
SKIP( int, sound4ShiftIndex ),
|
||||
SKIP( int, sound4NSteps ),
|
||||
SKIP( int, sound4CountDown ),
|
||||
SKIP( int, sound4Continue ),
|
||||
SKIP( int, soundEnvelopeVolume [2] ),
|
||||
SKIP( int, soundEnvelopeATL [2] ),
|
||||
SKIP( int, sound4EnvelopeATLReload ),
|
||||
SKIP( int, sound4EnvelopeUpDown ),
|
||||
SKIP( int, soundEnableFlag ),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static variable_desc gbsound_format2 [] =
|
||||
{
|
||||
SKIP( int, sound1ATLreload ),
|
||||
SKIP( int, freq1low ),
|
||||
SKIP( int, freq1high ),
|
||||
SKIP( int, sound2ATLreload ),
|
||||
SKIP( int, freq2low ),
|
||||
SKIP( int, freq2high ),
|
||||
SKIP( int, sound3ATLreload ),
|
||||
SKIP( int, freq3low ),
|
||||
SKIP( int, freq3high ),
|
||||
SKIP( int, sound4ATLreload ),
|
||||
SKIP( int, freq4 ),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static variable_desc gbsound_format3 [] =
|
||||
{
|
||||
SKIP( u8[2*735], soundBuffer ),
|
||||
SKIP( u8[2*735], soundBuffer ),
|
||||
SKIP( u16[735], soundFinalWave ),
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
void gbSoundSaveGame(gzFile gzFile)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
enum {
|
||||
nr10 = 0,
|
||||
nr11, nr12, nr13, nr14,
|
||||
nr20, nr21, nr22, nr23, nr24,
|
||||
nr30, nr31, nr32, nr33, nr34,
|
||||
nr40, nr41, nr42, nr43, nr44,
|
||||
nr50, nr51, nr52
|
||||
};
|
||||
|
||||
void gbSoundReadGame(int version,gzFile gzFile)
|
||||
{
|
||||
return; // TODO: apparently GB save states don't work in the main emulator
|
||||
|
||||
// Load state
|
||||
utilReadData( gzFile, gbsound_format );
|
||||
|
||||
if ( version >= 11 )
|
||||
utilReadData( gzFile, gbsound_format2 );
|
||||
|
||||
utilReadData( gzFile, gbsound_format3 );
|
||||
|
||||
int quality = 1;
|
||||
if ( version >= 7 )
|
||||
quality = utilReadInt( gzFile );
|
||||
|
||||
gbSoundSetQuality( quality );
|
||||
|
||||
// Convert to format Gb_Apu uses
|
||||
reset_apu();
|
||||
gb_apu_state_t s;
|
||||
gb_apu->save_state( &s ); // use fresh values for anything not restored
|
||||
|
||||
// Only some registers are properly preserved
|
||||
static int const regs_to_copy [] = {
|
||||
nr10, nr11, nr12, nr21, nr22, nr30, nr32, nr42, nr43, nr50, nr51, nr52, -1
|
||||
};
|
||||
for ( int i = 0; regs_to_copy [i] >= 0; i++ )
|
||||
s.regs [regs_to_copy [i]] = gbMemory [0xFF10 + regs_to_copy [i]];
|
||||
|
||||
memcpy( &s.regs [0x20], &gbMemory [0xFF30], 0x10 ); // wave
|
||||
|
||||
gb_apu->load_state( s );
|
||||
}
|
||||
|
|
|
@ -1,74 +1,74 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#define NR10 0xff10
|
||||
#define NR11 0xff11
|
||||
#define NR12 0xff12
|
||||
#define NR13 0xff13
|
||||
#define NR14 0xff14
|
||||
#define NR21 0xff16
|
||||
#define NR22 0xff17
|
||||
#define NR23 0xff18
|
||||
#define NR24 0xff19
|
||||
#define NR30 0xff1a
|
||||
#define NR31 0xff1b
|
||||
#define NR32 0xff1c
|
||||
#define NR33 0xff1d
|
||||
#define NR34 0xff1e
|
||||
#define NR41 0xff20
|
||||
#define NR42 0xff21
|
||||
#define NR43 0xff22
|
||||
#define NR44 0xff23
|
||||
#define NR50 0xff24
|
||||
#define NR51 0xff25
|
||||
#define NR52 0xff26
|
||||
|
||||
#define SOUND_EVENT(address,value) \
|
||||
gbSoundEvent(address,value)
|
||||
|
||||
extern void gbSoundTick();
|
||||
extern void gbSoundPause();
|
||||
extern void gbSoundResume();
|
||||
extern void gbSoundEnable(int);
|
||||
extern void gbSoundDisable(int);
|
||||
extern int gbSoundGetEnable();
|
||||
extern void gbSoundReset();
|
||||
extern void gbSoundSaveGame(gzFile);
|
||||
extern void gbSoundReadGame(int,gzFile);
|
||||
extern void gbSoundEvent(register u16, register int);
|
||||
extern void gbSoundSetQuality(int);
|
||||
|
||||
extern u8 gbSoundRead(u16 address);
|
||||
|
||||
extern int soundTicks;
|
||||
extern int soundQuality;
|
||||
extern int SOUND_CLOCK_TICKS;
|
||||
|
||||
struct gb_effects_config_t
|
||||
{
|
||||
bool enabled; // false = disable all effects
|
||||
|
||||
float echo; // 0.0 = none, 1.0 = lots
|
||||
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
|
||||
bool surround; // true = put some channels in back
|
||||
};
|
||||
|
||||
// Can be changed at any time, probably from another thread too.
|
||||
// Sound will notice changes during next 1/100 second.
|
||||
extern gb_effects_config_t gb_effects_config;
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#define NR10 0xff10
|
||||
#define NR11 0xff11
|
||||
#define NR12 0xff12
|
||||
#define NR13 0xff13
|
||||
#define NR14 0xff14
|
||||
#define NR21 0xff16
|
||||
#define NR22 0xff17
|
||||
#define NR23 0xff18
|
||||
#define NR24 0xff19
|
||||
#define NR30 0xff1a
|
||||
#define NR31 0xff1b
|
||||
#define NR32 0xff1c
|
||||
#define NR33 0xff1d
|
||||
#define NR34 0xff1e
|
||||
#define NR41 0xff20
|
||||
#define NR42 0xff21
|
||||
#define NR43 0xff22
|
||||
#define NR44 0xff23
|
||||
#define NR50 0xff24
|
||||
#define NR51 0xff25
|
||||
#define NR52 0xff26
|
||||
|
||||
#define SOUND_EVENT(address,value) \
|
||||
gbSoundEvent(address,value)
|
||||
|
||||
extern void gbSoundTick();
|
||||
extern void gbSoundPause();
|
||||
extern void gbSoundResume();
|
||||
extern void gbSoundEnable(int);
|
||||
extern void gbSoundDisable(int);
|
||||
extern int gbSoundGetEnable();
|
||||
extern void gbSoundReset();
|
||||
extern void gbSoundSaveGame(gzFile);
|
||||
extern void gbSoundReadGame(int,gzFile);
|
||||
extern void gbSoundEvent(register u16, register int);
|
||||
extern void gbSoundSetQuality(int);
|
||||
|
||||
extern u8 gbSoundRead(u16 address);
|
||||
|
||||
extern int soundTicks;
|
||||
extern int soundQuality;
|
||||
extern int SOUND_CLOCK_TICKS;
|
||||
|
||||
struct gb_effects_config_t
|
||||
{
|
||||
bool enabled; // false = disable all effects
|
||||
|
||||
float echo; // 0.0 = none, 1.0 = lots
|
||||
float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
|
||||
bool surround; // true = put some channels in back
|
||||
};
|
||||
|
||||
// Can be changed at any time, probably from another thread too.
|
||||
// Sound will notice changes during next 1/100 second.
|
||||
extern gb_effects_config_t gb_effects_config;
|
||||
|
|
|
@ -37,18 +37,18 @@ Blip_Buffer::Blip_Buffer()
|
|||
clock_rate_ = 0;
|
||||
bass_freq_ = 16;
|
||||
length_ = 0;
|
||||
|
||||
|
||||
// assumptions code makes about implementation-defined features
|
||||
#ifndef NDEBUG
|
||||
// right shift of negative value preserves sign
|
||||
buf_t_ i = -0x7FFFFFFE;
|
||||
assert( (i >> 1) == -0x3FFFFFFF );
|
||||
|
||||
|
||||
// casting to short truncates to 16 bits and sign-extends
|
||||
i = 0x18000;
|
||||
assert( (short) i == -0x8000 );
|
||||
#endif
|
||||
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ Blip_Buffer::blargg_err_t Blip_Buffer::set_sample_rate( long new_rate, int msec
|
|||
assert( 0 );
|
||||
return "Internal (tried to resize Silent_Blip_Buffer)";
|
||||
}
|
||||
|
||||
|
||||
// start with maximum length that resampled time can represent
|
||||
long new_size = (ULONG_MAX >> BLIP_BUFFER_ACCURACY) - blip_buffer_extra_ - 64;
|
||||
if ( msec != blip_max_length )
|
||||
|
@ -96,7 +96,7 @@ Blip_Buffer::blargg_err_t Blip_Buffer::set_sample_rate( long new_rate, int msec
|
|||
else
|
||||
assert( 0 ); // fails if requested buffer length exceeds limit
|
||||
}
|
||||
|
||||
|
||||
if ( buffer_size_ != new_size )
|
||||
{
|
||||
void* p = realloc( buffer_, (new_size + blip_buffer_extra_) * sizeof *buffer_ );
|
||||
|
@ -104,23 +104,23 @@ Blip_Buffer::blargg_err_t Blip_Buffer::set_sample_rate( long new_rate, int msec
|
|||
return "Out of memory";
|
||||
buffer_ = (buf_t_*) p;
|
||||
}
|
||||
|
||||
|
||||
buffer_size_ = new_size;
|
||||
assert( buffer_size_ != silent_buf_size ); // size should never happen to match this
|
||||
|
||||
|
||||
// update things based on the sample rate
|
||||
sample_rate_ = new_rate;
|
||||
length_ = new_size * 1000 / new_rate - 1;
|
||||
if ( msec )
|
||||
assert( length_ == msec ); // ensure length is same as that passed in
|
||||
|
||||
|
||||
// update these since they depend on sample rate
|
||||
if ( clock_rate_ )
|
||||
clock_rate( clock_rate_ );
|
||||
bass_freq( bass_freq_ );
|
||||
|
||||
|
||||
clear();
|
||||
|
||||
|
||||
return 0; // success
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ blip_time_t Blip_Buffer::count_clocks( long count ) const
|
|||
assert( 0 ); // sample rate and clock rates must be set first
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ( count > buffer_size_ )
|
||||
count = buffer_size_;
|
||||
blip_resampled_time_t time = (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY;
|
||||
|
@ -177,7 +177,7 @@ void Blip_Buffer::remove_samples( long count )
|
|||
if ( count )
|
||||
{
|
||||
remove_silence( count );
|
||||
|
||||
|
||||
// copy remaining samples to beginning and clear old samples
|
||||
long remain = samples_avail() + blip_buffer_extra_;
|
||||
memmove( buffer_, buffer_ + count, remain * sizeof *buffer_ );
|
||||
|
@ -219,12 +219,12 @@ static void gen_sinc( float* out, int count, double oversample, double treble, d
|
|||
{
|
||||
if ( cutoff >= 0.999 )
|
||||
cutoff = 0.999;
|
||||
|
||||
|
||||
if ( treble < -300.0 )
|
||||
treble = -300.0;
|
||||
if ( treble > 5.0 )
|
||||
treble = 5.0;
|
||||
|
||||
|
||||
double const maxh = 4096.0;
|
||||
double const rolloff = pow( 10.0, 1.0 / (maxh * 20.0) * treble / (1.0 - cutoff) );
|
||||
double const pow_a_n = pow( rolloff, maxh - maxh * cutoff );
|
||||
|
@ -236,12 +236,12 @@ static void gen_sinc( float* out, int count, double oversample, double treble, d
|
|||
double cos_nc_angle = cos( maxh * cutoff * angle );
|
||||
double cos_nc1_angle = cos( (maxh * cutoff - 1.0) * angle );
|
||||
double cos_angle = cos( angle );
|
||||
|
||||
|
||||
c = c * pow_a_n - rolloff * cos_nc1_angle + cos_nc_angle;
|
||||
double d = 1.0 + rolloff * (rolloff - cos_angle - cos_angle);
|
||||
double b = 2.0 - cos_angle - cos_angle;
|
||||
double a = 1.0 - cos_angle - cos_nc_angle + cos_nc1_angle;
|
||||
|
||||
|
||||
out [i] = (float) ((a * d + c * b) / (b * d)); // a / b + c / d
|
||||
}
|
||||
}
|
||||
|
@ -255,9 +255,9 @@ void blip_eq_t::generate( float* out, int count ) const
|
|||
if ( cutoff_freq )
|
||||
oversample = half_rate / cutoff_freq;
|
||||
double cutoff = rolloff_freq * oversample / half_rate;
|
||||
|
||||
|
||||
gen_sinc( out, count, blip_res * oversample, treble, cutoff );
|
||||
|
||||
|
||||
// apply (half of) hamming window
|
||||
double to_fraction = PI / (count - 1);
|
||||
for ( int i = count; i--; )
|
||||
|
@ -282,7 +282,7 @@ void Blip_Synth_::adjust_impulse()
|
|||
impulses [size - blip_res + p] += (short) error;
|
||||
//printf( "error: %ld\n", error );
|
||||
}
|
||||
|
||||
|
||||
//for ( int i = blip_res; i--; printf( "\n" ) )
|
||||
// for ( int j = 0; j < width / 2; j++ )
|
||||
// printf( "%5ld,", impulses [j * blip_res + i + 1] );
|
||||
|
@ -291,31 +291,31 @@ void Blip_Synth_::adjust_impulse()
|
|||
void Blip_Synth_::treble_eq( blip_eq_t const& eq )
|
||||
{
|
||||
float fimpulse [blip_res / 2 * (blip_widest_impulse_ - 1) + blip_res * 2];
|
||||
|
||||
|
||||
int const half_size = blip_res / 2 * (width - 1);
|
||||
eq.generate( &fimpulse [blip_res], half_size );
|
||||
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
// need mirror slightly past center for calculation
|
||||
for ( i = blip_res; i--; )
|
||||
fimpulse [blip_res + half_size + i] = fimpulse [blip_res + half_size - 1 - i];
|
||||
|
||||
|
||||
// starts at 0
|
||||
for ( i = 0; i < blip_res; i++ )
|
||||
fimpulse [i] = 0.0f;
|
||||
|
||||
|
||||
// find rescale factor
|
||||
double total = 0.0;
|
||||
for ( i = 0; i < half_size; i++ )
|
||||
total += fimpulse [blip_res + i];
|
||||
|
||||
|
||||
//double const base_unit = 44800.0 - 128 * 18; // allows treble up to +0 dB
|
||||
//double const base_unit = 37888.0; // allows treble to +5 dB
|
||||
double const base_unit = 32768.0; // necessary for blip_unscaled to work
|
||||
double rescale = base_unit / 2 / total;
|
||||
kernel_unit = (long) base_unit;
|
||||
|
||||
|
||||
// integrate, first difference, rescale, convert to int
|
||||
double sum = 0.0;
|
||||
double next = 0.0;
|
||||
|
@ -327,7 +327,7 @@ void Blip_Synth_::treble_eq( blip_eq_t const& eq )
|
|||
next += fimpulse [i + blip_res];
|
||||
}
|
||||
adjust_impulse();
|
||||
|
||||
|
||||
// volume might require rescaling
|
||||
double vol = volume_unit_;
|
||||
if ( vol )
|
||||
|
@ -344,26 +344,26 @@ void Blip_Synth_::volume_unit( double new_unit )
|
|||
// use default eq if it hasn't been set yet
|
||||
if ( !kernel_unit )
|
||||
treble_eq( -8.0 );
|
||||
|
||||
|
||||
volume_unit_ = new_unit;
|
||||
double factor = new_unit * (1L << blip_sample_bits) / kernel_unit;
|
||||
|
||||
|
||||
if ( factor > 0.0 )
|
||||
{
|
||||
int shift = 0;
|
||||
|
||||
|
||||
// if unit is really small, might need to attenuate kernel
|
||||
while ( factor < 2.0 )
|
||||
{
|
||||
shift++;
|
||||
factor *= 2.0;
|
||||
}
|
||||
|
||||
|
||||
if ( shift )
|
||||
{
|
||||
kernel_unit >>= shift;
|
||||
assert( kernel_unit > 0 ); // fails if volume unit is too low
|
||||
|
||||
|
||||
// keep values positive to avoid round-towards-zero of sign-preserving
|
||||
// right shift for negative values
|
||||
long offset = 0x8000 + (1 << (shift - 1));
|
||||
|
@ -384,7 +384,7 @@ long Blip_Buffer::read_samples( blip_sample_t* out_, long max_samples, int stere
|
|||
long count = samples_avail();
|
||||
if ( count > max_samples )
|
||||
count = max_samples;
|
||||
|
||||
|
||||
if ( count )
|
||||
{
|
||||
int const bass = BLIP_READER_BASS( *this );
|
||||
|
@ -392,7 +392,7 @@ long Blip_Buffer::read_samples( blip_sample_t* out_, long max_samples, int stere
|
|||
BLIP_READER_ADJ_( reader, count );
|
||||
blip_sample_t* BLIP_RESTRICT out = out_ + count;
|
||||
blip_long offset = (blip_long) -count;
|
||||
|
||||
|
||||
if ( !stereo )
|
||||
{
|
||||
do
|
||||
|
@ -415,9 +415,9 @@ long Blip_Buffer::read_samples( blip_sample_t* out_, long max_samples, int stere
|
|||
}
|
||||
while ( ++offset );
|
||||
}
|
||||
|
||||
|
||||
BLIP_READER_END( reader, *this );
|
||||
|
||||
|
||||
remove_samples( count );
|
||||
}
|
||||
return count;
|
||||
|
@ -430,9 +430,9 @@ void Blip_Buffer::mix_samples( blip_sample_t const* in, long count )
|
|||
assert( 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
buf_t_* out = buffer_ + (offset_ >> BLIP_BUFFER_ACCURACY) + blip_widest_impulse_ / 2;
|
||||
|
||||
|
||||
int const sample_shift = blip_sample_bits - 16;
|
||||
int prev = 0;
|
||||
while ( count-- )
|
||||
|
@ -458,7 +458,7 @@ void Blip_Buffer::save_state( blip_buffer_state_t* out )
|
|||
void Blip_Buffer::load_state( blip_buffer_state_t const& in )
|
||||
{
|
||||
clear( false );
|
||||
|
||||
|
||||
offset_ = in.offset_;
|
||||
reader_accum_ = in.reader_accum_;
|
||||
memcpy( buffer_, in.buf, sizeof in.buf );
|
||||
|
|
|
@ -26,81 +26,81 @@ struct blip_buffer_state_t;
|
|||
class Blip_Buffer {
|
||||
public:
|
||||
typedef const char* blargg_err_t;
|
||||
|
||||
|
||||
// Sets output sample rate and buffer length in milliseconds (1/1000 sec, defaults
|
||||
// to 1/4 second) and clears buffer. If there isn't enough memory, leaves buffer
|
||||
// untouched and returns "Out of memory", otherwise returns NULL.
|
||||
blargg_err_t set_sample_rate( long samples_per_sec, int msec_length = 1000 / 4 );
|
||||
|
||||
|
||||
// Sets number of source time units per second
|
||||
void clock_rate( long clocks_per_sec );
|
||||
|
||||
|
||||
// Ends current time frame of specified duration and makes its samples available
|
||||
// (along with any still-unread samples) for reading with read_samples(). Begins
|
||||
// a new time frame at the end of the current frame.
|
||||
void end_frame( blip_time_t time );
|
||||
|
||||
|
||||
// Reads at most 'max_samples' out of buffer into 'dest', removing them from from
|
||||
// the buffer. Returns number of samples actually read and removed. If stereo is
|
||||
// true, increments 'dest' one extra time after writing each sample, to allow
|
||||
// easy interleving of two channels into a stereo output buffer.
|
||||
long read_samples( blip_sample_t* dest, long max_samples, int stereo = 0 );
|
||||
|
||||
|
||||
// Additional features
|
||||
|
||||
// Removes all available samples and clear buffer to silence. If 'entire_buffer' is
|
||||
// false, just clears out any samples waiting rather than the entire buffer.
|
||||
void clear( int entire_buffer = 1 );
|
||||
|
||||
|
||||
// Number of samples available for reading with read_samples()
|
||||
long samples_avail() const;
|
||||
|
||||
|
||||
// Removes 'count' samples from those waiting to be read
|
||||
void remove_samples( long count );
|
||||
|
||||
|
||||
// Sets frequency high-pass filter frequency, where higher values reduce bass more
|
||||
void bass_freq( int frequency );
|
||||
|
||||
|
||||
// Current output sample rate
|
||||
long sample_rate() const;
|
||||
|
||||
|
||||
// Length of buffer in milliseconds
|
||||
int length() const;
|
||||
|
||||
|
||||
// Number of source time units per second
|
||||
long clock_rate() const;
|
||||
|
||||
|
||||
// Experimental features
|
||||
|
||||
|
||||
// Saves state, including high-pass filter and tails of last deltas.
|
||||
// All samples must have been read from buffer before calling this.
|
||||
void save_state( blip_buffer_state_t* out );
|
||||
|
||||
|
||||
// Loads state. State must have been saved from Blip_Buffer with same
|
||||
// settings during same run of program. States can NOT be stored on disk.
|
||||
// Clears buffer before loading state.
|
||||
void load_state( blip_buffer_state_t const& in );
|
||||
|
||||
|
||||
// Number of samples delay from synthesis to samples read out
|
||||
int output_latency() const;
|
||||
|
||||
|
||||
// Counts number of clocks needed until 'count' samples will be available.
|
||||
// If buffer can't even hold 'count' samples, returns number of clocks until
|
||||
// buffer becomes full.
|
||||
blip_time_t count_clocks( long count ) const;
|
||||
|
||||
|
||||
// Number of raw samples that can be mixed within frame of specified duration.
|
||||
long count_samples( blip_time_t duration ) const;
|
||||
|
||||
|
||||
// Mixes in 'count' samples from 'buf_in'
|
||||
void mix_samples( blip_sample_t const* buf_in, long count );
|
||||
|
||||
|
||||
|
||||
|
||||
// Signals that sound has been added to buffer. Could be done automatically in
|
||||
// Blip_Synth, but that would affect performance more, as you can arrange that
|
||||
// this is called only once per time frame rather than for every delta.
|
||||
void set_modified() { modified_ = this; }
|
||||
|
||||
|
||||
// not documented yet
|
||||
blip_ulong unsettled() const;
|
||||
Blip_Buffer* clear_modified() { Blip_Buffer* b = modified_; modified_ = 0; return b; }
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
public:
|
||||
Blip_Buffer();
|
||||
~Blip_Buffer();
|
||||
|
||||
|
||||
// Deprecated
|
||||
typedef blip_resampled_time_t resampled_time_t;
|
||||
blargg_err_t sample_rate( long r ) { return set_sample_rate( r ); }
|
||||
|
@ -165,24 +165,24 @@ private:
|
|||
int const blip_buffer_extra_ = blip_widest_impulse_ + 2;
|
||||
int const blip_res = 1 << BLIP_PHASE_BITS;
|
||||
class blip_eq_t;
|
||||
|
||||
|
||||
class Blip_Synth_Fast_ {
|
||||
public:
|
||||
Blip_Buffer* buf;
|
||||
int last_amp;
|
||||
int delta_factor;
|
||||
|
||||
|
||||
void volume_unit( double );
|
||||
Blip_Synth_Fast_();
|
||||
void treble_eq( blip_eq_t const& ) { }
|
||||
};
|
||||
|
||||
|
||||
class Blip_Synth_ {
|
||||
public:
|
||||
Blip_Buffer* buf;
|
||||
int last_amp;
|
||||
int delta_factor;
|
||||
|
||||
|
||||
void volume_unit( double );
|
||||
Blip_Synth_( short* impulses, int width );
|
||||
void treble_eq( blip_eq_t const& );
|
||||
|
@ -208,14 +208,14 @@ class Blip_Synth {
|
|||
public:
|
||||
// Sets overall volume of waveform
|
||||
void volume( double v ) { impl.volume_unit( v * (1.0 / (range < 0 ? -range : range)) ); }
|
||||
|
||||
|
||||
// Configures low-pass filter (see blip_buffer.txt)
|
||||
void treble_eq( blip_eq_t const& eq ) { impl.treble_eq( eq ); }
|
||||
|
||||
|
||||
// Gets/sets Blip_Buffer used for output
|
||||
Blip_Buffer* output() const { return impl.buf; }
|
||||
void output( Blip_Buffer* b ) { impl.buf = b; impl.last_amp = 0; }
|
||||
|
||||
|
||||
// Updates amplitude of waveform at given time. Using this requires a separate
|
||||
// Blip_Synth for each waveform.
|
||||
void update( blip_time_t time, int amplitude );
|
||||
|
@ -227,10 +227,10 @@ public:
|
|||
// The actual change in amplitude is delta * (volume / range)
|
||||
void offset( blip_time_t, int delta, Blip_Buffer* ) const;
|
||||
void offset( blip_time_t t, int delta ) const { offset( t, delta, impl.buf ); }
|
||||
|
||||
|
||||
// Works directly in terms of fractional output samples. Contact author for more info.
|
||||
void offset_resampled( blip_resampled_time_t, int delta, Blip_Buffer* ) const;
|
||||
|
||||
|
||||
// Same as offset(), except code is inlined for higher performance
|
||||
void offset_inline( blip_time_t t, int delta, Blip_Buffer* buf ) const {
|
||||
offset_resampled( t * buf->factor_ + buf->offset_, delta, buf );
|
||||
|
@ -238,7 +238,7 @@ public:
|
|||
void offset_inline( blip_time_t t, int delta ) const {
|
||||
offset_resampled( t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf );
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
#if BLIP_BUFFER_FAST
|
||||
Blip_Synth_Fast_ impl;
|
||||
|
@ -257,10 +257,10 @@ public:
|
|||
// Logarithmic rolloff to treble dB at half sampling rate. Negative values reduce
|
||||
// treble, small positive values (0 to 5.0) increase treble.
|
||||
blip_eq_t( double treble_db = 0 );
|
||||
|
||||
|
||||
// See blip_buffer.txt
|
||||
blip_eq_t( double treble, long rolloff_freq, long sample_rate, long cutoff_freq = 0 );
|
||||
|
||||
|
||||
private:
|
||||
double treble;
|
||||
long rolloff_freq;
|
||||
|
@ -281,7 +281,7 @@ public:
|
|||
blargg_err_t set_sample_rate( long samples_per_sec, int msec_length );
|
||||
blip_time_t count_clocks( long count ) const;
|
||||
void mix_samples( blip_sample_t const* buf, long count );
|
||||
|
||||
|
||||
Silent_Blip_Buffer();
|
||||
};
|
||||
|
||||
|
@ -393,21 +393,21 @@ inline void Blip_Synth<quality,range>::offset_resampled( blip_resampled_time_t t
|
|||
// If this assertion fails, it means that an attempt was made to add a delta
|
||||
// at a negative time or past the end of the buffer.
|
||||
assert( (blip_long) (time >> BLIP_BUFFER_ACCURACY) < blip_buf->buffer_size_ );
|
||||
|
||||
|
||||
delta *= impl.delta_factor;
|
||||
blip_long* BLIP_RESTRICT buf = blip_buf->buffer_ + (time >> BLIP_BUFFER_ACCURACY);
|
||||
int phase = (int) (time >> (BLIP_BUFFER_ACCURACY - BLIP_PHASE_BITS) & (blip_res - 1));
|
||||
|
||||
#if BLIP_BUFFER_FAST
|
||||
blip_long left = buf [0] + delta;
|
||||
|
||||
|
||||
// Kind of crappy, but doing shift after multiply results in overflow.
|
||||
// Alternate way of delaying multiply by delta_factor results in worse
|
||||
// sub-sample resolution.
|
||||
blip_long right = (delta >> BLIP_PHASE_BITS) * phase;
|
||||
left -= right;
|
||||
right += buf [1];
|
||||
|
||||
|
||||
buf [0] = left;
|
||||
buf [1] = right;
|
||||
#else
|
||||
|
@ -415,17 +415,17 @@ inline void Blip_Synth<quality,range>::offset_resampled( blip_resampled_time_t t
|
|||
int const fwd = (blip_widest_impulse_ - quality) / 2;
|
||||
int const rev = fwd + quality - 2;
|
||||
int const mid = quality / 2 - 1;
|
||||
|
||||
|
||||
imp_t const* BLIP_RESTRICT imp = impulses + blip_res - phase;
|
||||
|
||||
|
||||
#if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \
|
||||
defined (__x86_64__) || defined (__ia64__) || defined (__i386__)
|
||||
|
||||
|
||||
// this straight forward version gave in better code on GCC for x86
|
||||
|
||||
|
||||
#define ADD_IMP( out, in ) \
|
||||
buf [out] += (blip_long) imp [blip_res * (in)] * delta
|
||||
|
||||
|
||||
#define BLIP_FWD( i ) {\
|
||||
ADD_IMP( fwd + i, i );\
|
||||
ADD_IMP( fwd + 1 + i, i + 1 );\
|
||||
|
@ -446,16 +446,16 @@ inline void Blip_Synth<quality,range>::offset_resampled( blip_resampled_time_t t
|
|||
if ( quality > 12 ) BLIP_REV( 6 )
|
||||
if ( quality > 8 ) BLIP_REV( 4 )
|
||||
BLIP_REV( 2 )
|
||||
|
||||
|
||||
ADD_IMP( rev , 1 );
|
||||
ADD_IMP( rev + 1, 0 );
|
||||
|
||||
|
||||
#undef ADD_IMP
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
// for RISC processors, help compiler by reading ahead of writes
|
||||
|
||||
|
||||
#define BLIP_FWD( i ) {\
|
||||
blip_long t0 = i0 * delta + buf [fwd + i];\
|
||||
blip_long t1 = imp [blip_res * (i + 1)] * delta + buf [fwd + 1 + i];\
|
||||
|
@ -470,7 +470,7 @@ inline void Blip_Synth<quality,range>::offset_resampled( blip_resampled_time_t t
|
|||
buf [rev - r] = t0;\
|
||||
buf [rev + 1 - r] = t1;\
|
||||
}
|
||||
|
||||
|
||||
blip_long i0 = *imp;
|
||||
BLIP_FWD( 0 )
|
||||
if ( quality > 8 ) BLIP_FWD( 2 )
|
||||
|
@ -486,13 +486,13 @@ inline void Blip_Synth<quality,range>::offset_resampled( blip_resampled_time_t t
|
|||
if ( quality > 12 ) BLIP_REV( 6 )
|
||||
if ( quality > 8 ) BLIP_REV( 4 )
|
||||
BLIP_REV( 2 )
|
||||
|
||||
|
||||
blip_long t0 = i0 * delta + buf [rev ];
|
||||
blip_long t1 = *imp * delta + buf [rev + 1];
|
||||
buf [rev ] = t0;
|
||||
buf [rev + 1] = t1;
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,31 +13,31 @@ public:
|
|||
// To reduce memory usage, fewer buffers can be used (with a best-fit
|
||||
// approach if there are too few), and maximum echo delay can be reduced
|
||||
Effects_Buffer( int max_bufs = 32, long echo_size = 24 * 1024L );
|
||||
|
||||
|
||||
struct pan_vol_t
|
||||
{
|
||||
float vol; // 0.0 = silent, 0.5 = half volume, 1.0 = normal
|
||||
float pan; // -1.0 = left, 0.0 = center, +1.0 = right
|
||||
};
|
||||
|
||||
|
||||
// Global configuration
|
||||
struct config_t
|
||||
{
|
||||
bool enabled; // false = disable all effects
|
||||
|
||||
|
||||
// Current sound is echoed at adjustable left/right delay,
|
||||
// with reduced treble and volume (feedback).
|
||||
// with reduced treble and volume (feedback).
|
||||
float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent
|
||||
int delay [2]; // left, right delays (msec)
|
||||
float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony
|
||||
pan_vol_t side_chans [2]; // left and right side channel volume and pan
|
||||
};
|
||||
config_t& config() { return config_; }
|
||||
|
||||
|
||||
// Limits of delay (msec)
|
||||
int min_delay() const;
|
||||
int max_delay() const;
|
||||
|
||||
|
||||
// Per-channel configuration. Two or more channels with matching parameters are
|
||||
// optimized to internally use the same buffer.
|
||||
struct chan_config_t : pan_vol_t
|
||||
|
@ -49,10 +49,10 @@ public:
|
|||
bool echo; // false = channel doesn't have any echo
|
||||
};
|
||||
chan_config_t& chan_config( int i ) { return chans [i + extra_chans].cfg; }
|
||||
|
||||
|
||||
// Apply any changes made to config() and chan_config()
|
||||
virtual void apply_config();
|
||||
|
||||
|
||||
public:
|
||||
~Effects_Buffer();
|
||||
blargg_err_t set_sample_rate( long samples_per_sec, int msec = blip_default_length );
|
||||
|
@ -72,9 +72,9 @@ private:
|
|||
config_t config_;
|
||||
long clock_rate_;
|
||||
int bass_freq_;
|
||||
|
||||
|
||||
blargg_long echo_size;
|
||||
|
||||
|
||||
struct chan_t
|
||||
{
|
||||
fixed_t vol [stereo];
|
||||
|
@ -82,35 +82,35 @@ private:
|
|||
channel_t channel;
|
||||
};
|
||||
blargg_vector<chan_t> chans;
|
||||
|
||||
|
||||
struct buf_t : Tracked_Blip_Buffer
|
||||
{
|
||||
fixed_t vol [stereo];
|
||||
bool echo;
|
||||
|
||||
|
||||
void* operator new ( size_t, void* p ) { return p; }
|
||||
void operator delete ( void* ) { }
|
||||
|
||||
|
||||
~buf_t() { }
|
||||
};
|
||||
buf_t* bufs;
|
||||
int bufs_size;
|
||||
int bufs_max; // bufs_size <= bufs_max, to limit memory usage
|
||||
Stereo_Mixer mixer;
|
||||
|
||||
|
||||
struct {
|
||||
long delay [stereo];
|
||||
fixed_t treble;
|
||||
fixed_t feedback;
|
||||
fixed_t low_pass [stereo];
|
||||
} s;
|
||||
|
||||
|
||||
blargg_vector<fixed_t> echo;
|
||||
blargg_long echo_pos;
|
||||
|
||||
|
||||
bool no_effects;
|
||||
bool no_echo;
|
||||
|
||||
|
||||
void assign_buffers();
|
||||
void clear_echo();
|
||||
void mix_effects( blip_sample_t* out, int pair_count );
|
||||
|
@ -129,10 +129,10 @@ public:
|
|||
bool surround; // true = put some channels in back
|
||||
};
|
||||
config_t& config() { return config_; }
|
||||
|
||||
|
||||
// Apply any changes made to config()
|
||||
void apply_config();
|
||||
|
||||
|
||||
public:
|
||||
Simple_Effects_Buffer();
|
||||
private:
|
||||
|
|
|
@ -39,13 +39,13 @@ void Gb_Apu::set_output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* ri
|
|||
// Must be silent (all NULL), mono (left and right NULL), or stereo (none NULL)
|
||||
require( !center || (center && !left && !right) || (center && left && right) );
|
||||
require( (unsigned) osc <= osc_count ); // fails if you pass invalid osc index
|
||||
|
||||
|
||||
if ( !center || !left || !right )
|
||||
{
|
||||
left = center;
|
||||
right = center;
|
||||
}
|
||||
|
||||
|
||||
int i = (unsigned) osc % osc_count;
|
||||
do
|
||||
{
|
||||
|
@ -90,12 +90,12 @@ void Gb_Apu::reset_regs()
|
|||
{
|
||||
for ( int i = 0; i < 0x20; i++ )
|
||||
regs [i] = 0;
|
||||
|
||||
|
||||
square1.reset();
|
||||
square2.reset();
|
||||
wave .reset();
|
||||
noise .reset();
|
||||
|
||||
|
||||
apply_volume();
|
||||
}
|
||||
|
||||
|
@ -110,15 +110,15 @@ void Gb_Apu::reset_lengths()
|
|||
void Gb_Apu::reduce_clicks( bool reduce )
|
||||
{
|
||||
reduce_clicks_ = reduce;
|
||||
|
||||
|
||||
// Click reduction makes DAC off generate same output as volume 0
|
||||
int dac_off_amp = 0;
|
||||
if ( reduce && wave.mode != mode_agb ) // AGB already eliminates clicks
|
||||
dac_off_amp = -Gb_Osc::dac_bias;
|
||||
|
||||
|
||||
for ( int i = 0; i < osc_count; i++ )
|
||||
oscs [i]->dac_off_amp = dac_off_amp;
|
||||
|
||||
|
||||
// AGB always eliminates clicks on wave channel using same method
|
||||
if ( wave.mode == mode_agb )
|
||||
wave.dac_off_amp = -Gb_Osc::dac_bias;
|
||||
|
@ -133,15 +133,15 @@ void Gb_Apu::reset( mode_t mode, bool agb_wave )
|
|||
for ( int i = 0; i < osc_count; i++ )
|
||||
oscs [i]->mode = mode;
|
||||
reduce_clicks( reduce_clicks_ );
|
||||
|
||||
|
||||
// Reset state
|
||||
frame_time = 0;
|
||||
last_time = 0;
|
||||
frame_phase = 0;
|
||||
|
||||
|
||||
reset_regs();
|
||||
reset_lengths();
|
||||
|
||||
|
||||
// Load initial wave RAM
|
||||
static byte const initial_wave [2] [16] = {
|
||||
{0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C,0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA},
|
||||
|
@ -167,12 +167,12 @@ void Gb_Apu::set_tempo( double t )
|
|||
Gb_Apu::Gb_Apu()
|
||||
{
|
||||
wave.wave_ram = ®s [wave_ram - start_addr];
|
||||
|
||||
|
||||
oscs [0] = &square1;
|
||||
oscs [1] = &square2;
|
||||
oscs [2] = &wave;
|
||||
oscs [3] = &noise;
|
||||
|
||||
|
||||
for ( int i = osc_count; --i >= 0; )
|
||||
{
|
||||
Gb_Osc& o = *oscs [i];
|
||||
|
@ -185,7 +185,7 @@ Gb_Apu::Gb_Apu()
|
|||
o.good_synth = &good_synth;
|
||||
o.med_synth = &med_synth;
|
||||
}
|
||||
|
||||
|
||||
reduce_clicks_ = false;
|
||||
set_tempo( 1.0 );
|
||||
volume_ = 1.0;
|
||||
|
@ -200,16 +200,16 @@ void Gb_Apu::run_until_( blip_time_t end_time )
|
|||
blip_time_t time = end_time;
|
||||
if ( time > frame_time )
|
||||
time = frame_time;
|
||||
|
||||
|
||||
square1.run( last_time, time );
|
||||
square2.run( last_time, time );
|
||||
wave .run( last_time, time );
|
||||
noise .run( last_time, time );
|
||||
last_time = time;
|
||||
|
||||
|
||||
if ( time == end_time )
|
||||
break;
|
||||
|
||||
|
||||
// run frame sequencer
|
||||
frame_time += frame_period * Gb_Osc::clk_mul;
|
||||
switch ( frame_phase++ )
|
||||
|
@ -226,7 +226,7 @@ void Gb_Apu::run_until_( blip_time_t end_time )
|
|||
wave .clock_length();
|
||||
noise .clock_length();
|
||||
break;
|
||||
|
||||
|
||||
case 7:
|
||||
// 64 Hz
|
||||
frame_phase = 0;
|
||||
|
@ -248,10 +248,10 @@ void Gb_Apu::end_frame( blip_time_t end_time )
|
|||
{
|
||||
if ( end_time > last_time )
|
||||
run_until( end_time );
|
||||
|
||||
|
||||
frame_time -= end_time;
|
||||
assert( frame_time >= 0 );
|
||||
|
||||
|
||||
last_time -= end_time;
|
||||
assert( last_time >= 0 );
|
||||
}
|
||||
|
@ -287,28 +287,28 @@ void Gb_Apu::apply_stereo()
|
|||
void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
||||
{
|
||||
require( (unsigned) data < 0x100 );
|
||||
|
||||
|
||||
int reg = addr - start_addr;
|
||||
if ( (unsigned) reg >= register_count )
|
||||
{
|
||||
require( false );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( addr < status_reg && !(regs [status_reg - start_addr] & power_mask) )
|
||||
{
|
||||
// Power is off
|
||||
|
||||
|
||||
// length counters can only be written in DMG mode
|
||||
if ( wave.mode != mode_dmg || (reg != 1 && reg != 5+1 && reg != 10+1 && reg != 15+1) )
|
||||
return;
|
||||
|
||||
|
||||
if ( reg < 10 )
|
||||
data &= 0x3F; // clear square duty
|
||||
}
|
||||
|
||||
|
||||
run_until( time );
|
||||
|
||||
|
||||
if ( addr >= wave_ram )
|
||||
{
|
||||
wave.write( addr, data );
|
||||
|
@ -317,7 +317,7 @@ void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
|||
{
|
||||
int old_data = regs [reg];
|
||||
regs [reg] = data;
|
||||
|
||||
|
||||
if ( addr < vol_reg )
|
||||
{
|
||||
// Oscillator
|
||||
|
@ -328,7 +328,7 @@ void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
|||
// Master volume
|
||||
for ( int i = osc_count; --i >= 0; )
|
||||
silence_osc( *oscs [i] );
|
||||
|
||||
|
||||
apply_volume();
|
||||
}
|
||||
else if ( addr == stereo_reg )
|
||||
|
@ -342,11 +342,11 @@ void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
|||
frame_phase = 0;
|
||||
for ( int i = osc_count; --i >= 0; )
|
||||
silence_osc( *oscs [i] );
|
||||
|
||||
|
||||
reset_regs();
|
||||
if ( wave.mode != mode_dmg )
|
||||
reset_lengths();
|
||||
|
||||
|
||||
regs [status_reg - start_addr] = data;
|
||||
}
|
||||
}
|
||||
|
@ -355,17 +355,17 @@ void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
|
|||
int Gb_Apu::read_register( blip_time_t time, unsigned addr )
|
||||
{
|
||||
run_until( time );
|
||||
|
||||
|
||||
int reg = addr - start_addr;
|
||||
if ( (unsigned) reg >= register_count )
|
||||
{
|
||||
require( false );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if ( addr >= wave_ram )
|
||||
return wave.read( addr );
|
||||
|
||||
|
||||
// Value read back has some bits always set
|
||||
static byte const masks [] = {
|
||||
0x80,0x3F,0x00,0xFF,0xBF,
|
||||
|
@ -379,7 +379,7 @@ int Gb_Apu::read_register( blip_time_t time, unsigned addr )
|
|||
if ( wave.agb_mask && (reg == 10 || reg == 12) )
|
||||
mask = 0x1F; // extra implemented bits in wave regs on AGB
|
||||
int data = regs [reg] | mask;
|
||||
|
||||
|
||||
// Status register
|
||||
if ( addr == status_reg )
|
||||
{
|
||||
|
@ -389,6 +389,6 @@ int Gb_Apu::read_register( blip_time_t time, unsigned addr )
|
|||
data |= (int) wave .enabled << 2;
|
||||
data |= (int) noise .enabled << 3;
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ struct gb_apu_state_t;
|
|||
class Gb_Apu {
|
||||
public:
|
||||
// Basics
|
||||
|
||||
|
||||
// Clock rate that sound hardware runs at.
|
||||
enum { clock_rate = 4194304 * GB_APU_OVERCLOCK };
|
||||
|
||||
|
||||
// Sets buffer(s) to generate sound into. If left and right are NULL, output is mono.
|
||||
// If all are NULL, no output is generated but other emulation still runs.
|
||||
// If chan is specified, only that channel's output is changed, otherwise all are.
|
||||
enum { osc_count = 4 }; // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise
|
||||
void set_output( Blip_Buffer* center, Blip_Buffer* left = NULL, Blip_Buffer* right = NULL,
|
||||
int chan = osc_count );
|
||||
|
||||
|
||||
// Resets hardware to initial power on state BEFORE boot ROM runs. Mode selects
|
||||
// sound hardware. Additional AGB wave features are enabled separately.
|
||||
enum mode_t {
|
||||
|
@ -30,38 +30,38 @@ public:
|
|||
mode_agb // Game Boy Advance
|
||||
};
|
||||
void reset( mode_t mode = mode_cgb, bool agb_wave = false );
|
||||
|
||||
|
||||
// Reads and writes must be within the start_addr to end_addr range, inclusive.
|
||||
// Addresses outside this range are not mapped to the sound hardware.
|
||||
enum { start_addr = 0xFF10 };
|
||||
enum { end_addr = 0xFF3F };
|
||||
enum { register_count = end_addr - start_addr + 1 };
|
||||
|
||||
|
||||
// Times are specified as the number of clocks since the beginning of the
|
||||
// current time frame.
|
||||
|
||||
|
||||
// Emulates CPU write of data to addr at specified time.
|
||||
void write_register( blip_time_t time, unsigned addr, int data );
|
||||
|
||||
|
||||
// Emulates CPU read from addr at specified time.
|
||||
int read_register( blip_time_t time, unsigned addr );
|
||||
|
||||
|
||||
// Emulates sound hardware up to specified time, ends current time frame, then
|
||||
// starts a new frame at time 0.
|
||||
void end_frame( blip_time_t frame_length );
|
||||
|
||||
|
||||
// Sound adjustments
|
||||
|
||||
|
||||
// Sets overall volume, where 1.0 is normal.
|
||||
void volume( double );
|
||||
|
||||
|
||||
// If true, reduces clicking by disabling DAC biasing. Note that this reduces
|
||||
// emulation accuracy, since the clicks are authentic.
|
||||
void reduce_clicks( bool reduce = true );
|
||||
|
||||
|
||||
// Sets treble equalization.
|
||||
void treble_eq( blip_eq_t const& );
|
||||
|
||||
|
||||
// Treble and bass values for various hardware.
|
||||
enum {
|
||||
speaker_treble = -47, // speaker on system
|
||||
|
@ -73,24 +73,24 @@ public:
|
|||
agb_treble = 0,
|
||||
agb_bass = 30
|
||||
};
|
||||
|
||||
|
||||
// Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the
|
||||
// tempo in a game music player.
|
||||
void set_tempo( double );
|
||||
|
||||
|
||||
// Save states
|
||||
|
||||
// Saves full emulation state to state_out. Data format is portable and
|
||||
// includes some extra space to avoid expansion in case more state needs
|
||||
// to be stored in the future.
|
||||
void save_state( gb_apu_state_t* state_out );
|
||||
|
||||
|
||||
// Loads state. You should call reset() BEFORE this.
|
||||
blargg_err_t load_state( gb_apu_state_t const& in );
|
||||
|
||||
public:
|
||||
Gb_Apu();
|
||||
|
||||
|
||||
// Use set_output() in place of these
|
||||
BLARGG_DEPRECATED void output ( Blip_Buffer* c ) { set_output( c, c, c ); }
|
||||
BLARGG_DEPRECATED void output ( Blip_Buffer* c, Blip_Buffer* l, Blip_Buffer* r ) { set_output( c, l, r ); }
|
||||
|
@ -101,13 +101,13 @@ private:
|
|||
// noncopyable
|
||||
Gb_Apu( const Gb_Apu& );
|
||||
Gb_Apu& operator = ( const Gb_Apu& );
|
||||
|
||||
|
||||
Gb_Osc* oscs [osc_count];
|
||||
blip_time_t last_time; // time sound emulator has been run to
|
||||
blip_time_t frame_period; // clocks between each frame sequencer step
|
||||
double volume_;
|
||||
bool reduce_clicks_;
|
||||
|
||||
|
||||
Gb_Sweep_Square square1;
|
||||
Gb_Square square2;
|
||||
Gb_Wave wave;
|
||||
|
@ -116,11 +116,11 @@ private:
|
|||
int frame_phase; // phase of next frame sequencer step
|
||||
enum { regs_size = register_count + 0x10 };
|
||||
BOOST::uint8_t regs [regs_size];// last values written to registers
|
||||
|
||||
|
||||
// large objects after everything else
|
||||
Gb_Osc::Good_Synth good_synth;
|
||||
Gb_Osc::Med_Synth med_synth;
|
||||
|
||||
|
||||
void reset_lengths();
|
||||
void reset_regs();
|
||||
int calc_output( int osc ) const;
|
||||
|
@ -150,32 +150,32 @@ struct gb_apu_state_t
|
|||
// to be written directly to disk.
|
||||
typedef unsigned char val_t [4];
|
||||
#endif
|
||||
|
||||
|
||||
enum { format0 = 0x50414247 };
|
||||
|
||||
|
||||
val_t format; // format of all following data
|
||||
val_t version; // later versions just add fields to end
|
||||
|
||||
|
||||
unsigned char regs [0x40];
|
||||
val_t frame_time;
|
||||
val_t frame_phase;
|
||||
|
||||
|
||||
val_t sweep_freq;
|
||||
val_t sweep_delay;
|
||||
val_t sweep_enabled;
|
||||
val_t sweep_neg;
|
||||
val_t noise_divider;
|
||||
val_t wave_buf;
|
||||
|
||||
|
||||
val_t delay [4];
|
||||
val_t length_ctr [4];
|
||||
val_t phase [4];
|
||||
val_t enabled [4];
|
||||
|
||||
|
||||
val_t env_delay [3];
|
||||
val_t env_volume [3];
|
||||
val_t env_enabled [3];
|
||||
|
||||
|
||||
val_t unused [13]; // for future expansion
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
|||
#define REFLECT( x, y ) (save ? (io->y) = (x) : (x) = (io->y) )
|
||||
#else
|
||||
#define REFLECT( x, y ) (save ? set_val( io->y, x ) : (void) ((x) = get_val( io->y )))
|
||||
|
||||
|
||||
static blargg_ulong get_val( byte const* p )
|
||||
{
|
||||
return p [3] * 0x1000000 + p [2] * 0x10000 + p [1] * 0x100 + p [0];
|
||||
|
@ -41,34 +41,34 @@ inline const char* Gb_Apu::save_load( gb_apu_state_t* io, bool save )
|
|||
#if !GB_APU_CUSTOM_STATE
|
||||
assert( sizeof (gb_apu_state_t) == 256 );
|
||||
#endif
|
||||
|
||||
|
||||
int format = io->format0;
|
||||
REFLECT( format, format );
|
||||
if ( format != io->format0 )
|
||||
return "Unsupported sound save state format";
|
||||
|
||||
|
||||
int version = 0;
|
||||
REFLECT( version, version );
|
||||
|
||||
|
||||
// Registers and wave RAM
|
||||
assert( regs_size == sizeof io->regs );
|
||||
if ( save )
|
||||
memcpy( io->regs, regs, sizeof io->regs );
|
||||
else
|
||||
memcpy( regs, io->regs, sizeof regs );
|
||||
|
||||
|
||||
// Frame sequencer
|
||||
REFLECT( frame_time, frame_time );
|
||||
REFLECT( frame_phase, frame_phase );
|
||||
|
||||
|
||||
REFLECT( square1.sweep_freq, sweep_freq );
|
||||
REFLECT( square1.sweep_delay, sweep_delay );
|
||||
REFLECT( square1.sweep_enabled, sweep_enabled );
|
||||
REFLECT( square1.sweep_neg, sweep_neg );
|
||||
|
||||
|
||||
REFLECT( noise.divider, noise_divider );
|
||||
REFLECT( wave.sample_buf, wave_buf );
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ inline void Gb_Apu::save_load2( gb_apu_state_t* io, bool save )
|
|||
REFLECT( osc.length_ctr, length_ctr [i] );
|
||||
REFLECT( osc.phase, phase [i] );
|
||||
REFLECT( osc.enabled, enabled [i] );
|
||||
|
||||
|
||||
if ( i != 2 )
|
||||
{
|
||||
int j = min( i, 2 );
|
||||
|
@ -98,7 +98,7 @@ void Gb_Apu::save_state( gb_apu_state_t* out )
|
|||
{
|
||||
(void) save_load( out, true );
|
||||
save_load2( out, true );
|
||||
|
||||
|
||||
#if !GB_APU_CUSTOM_STATE
|
||||
memset( out->unused, 0, sizeof out->unused );
|
||||
#endif
|
||||
|
@ -108,11 +108,11 @@ blargg_err_t Gb_Apu::load_state( gb_apu_state_t const& in )
|
|||
{
|
||||
RETURN_ERR( save_load( CONST_CAST(gb_apu_state_t*,&in), false ) );
|
||||
save_load2( CONST_CAST(gb_apu_state_t*,&in), false );
|
||||
|
||||
|
||||
apply_stereo();
|
||||
synth_volume( 0 ); // suppress output for the moment
|
||||
run_until_( last_time ); // get last_amp updated
|
||||
apply_volume(); // now use correct volume
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ void Gb_Sweep_Square::calc_sweep( bool update )
|
|||
int const delta = sweep_freq >> shift;
|
||||
sweep_neg = (regs [0] & 0x08) != 0;
|
||||
int const freq = sweep_freq + (sweep_neg ? -delta : delta);
|
||||
|
||||
|
||||
if ( freq > 0x7FF )
|
||||
{
|
||||
enabled = false;
|
||||
|
@ -92,7 +92,7 @@ void Gb_Sweep_Square::calc_sweep( bool update )
|
|||
else if ( shift && update )
|
||||
{
|
||||
sweep_freq = freq;
|
||||
|
||||
|
||||
regs [3] = freq & 0xFF;
|
||||
regs [4] = (regs [4] & ~0x07) | (freq >> 8 & 0x07);
|
||||
}
|
||||
|
@ -132,13 +132,13 @@ int Gb_Wave::access( unsigned addr ) const
|
|||
int Gb_Osc::write_trig( int frame_phase, int max_len, int old_data )
|
||||
{
|
||||
int data = regs [4];
|
||||
|
||||
|
||||
if ( (frame_phase & 1) && !(old_data & length_enabled) && length_ctr )
|
||||
{
|
||||
if ( (data & length_enabled) || cgb_02 )
|
||||
length_ctr--;
|
||||
}
|
||||
|
||||
|
||||
if ( data & trigger_mask )
|
||||
{
|
||||
enabled = true;
|
||||
|
@ -149,10 +149,10 @@ int Gb_Osc::write_trig( int frame_phase, int max_len, int old_data )
|
|||
length_ctr--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !length_ctr )
|
||||
enabled = false;
|
||||
|
||||
|
||||
return data & trigger_mask;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ inline void Gb_Env::zombie_volume( int old, int data )
|
|||
if ( old & 7 )
|
||||
v++;
|
||||
}
|
||||
|
||||
|
||||
v = 16 - v;
|
||||
}
|
||||
else if ( (old & 0x0F) == 8 )
|
||||
|
@ -185,7 +185,7 @@ inline void Gb_Env::zombie_volume( int old, int data )
|
|||
v++;
|
||||
else if ( !(old & 8) )
|
||||
v += 2;
|
||||
|
||||
|
||||
if ( (old ^ data) & 8 )
|
||||
v = 16 - v;
|
||||
}
|
||||
|
@ -195,26 +195,26 @@ inline void Gb_Env::zombie_volume( int old, int data )
|
|||
bool Gb_Env::write_register( int frame_phase, int reg, int old, int data )
|
||||
{
|
||||
int const max_len = 64;
|
||||
|
||||
|
||||
switch ( reg )
|
||||
{
|
||||
case 1:
|
||||
length_ctr = max_len - (data & (max_len - 1));
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
if ( !dac_enabled() )
|
||||
enabled = false;
|
||||
|
||||
|
||||
zombie_volume( old, data );
|
||||
|
||||
|
||||
if ( (data & 7) && env_delay == 8 )
|
||||
{
|
||||
env_delay = 1;
|
||||
clock_envelope(); // TODO: really happens at next length clock
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 4:
|
||||
if ( write_trig( frame_phase, max_len, old ) )
|
||||
{
|
||||
|
@ -252,7 +252,7 @@ inline void Gb_Sweep_Square::write_register( int frame_phase, int reg, int old_d
|
|||
{
|
||||
if ( reg == 0 && sweep_enabled && sweep_neg && !(data & 0x08) )
|
||||
enabled = false; // sweep negate disabled after used
|
||||
|
||||
|
||||
if ( Gb_Square::write_register( frame_phase, reg, old_data, data ) )
|
||||
{
|
||||
sweep_freq = frequency();
|
||||
|
@ -277,18 +277,18 @@ void Gb_Wave::corrupt_wave()
|
|||
inline void Gb_Wave::write_register( int frame_phase, int reg, int old_data, int data )
|
||||
{
|
||||
int const max_len = 256;
|
||||
|
||||
|
||||
switch ( reg )
|
||||
{
|
||||
case 0:
|
||||
if ( !dac_enabled() )
|
||||
enabled = false;
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
length_ctr = max_len - data;
|
||||
break;
|
||||
|
||||
|
||||
case 4:
|
||||
bool was_enabled = enabled;
|
||||
if ( write_trig( frame_phase, max_len, old_data ) )
|
||||
|
@ -298,7 +298,7 @@ inline void Gb_Wave::write_register( int frame_phase, int reg, int old_data, int
|
|||
else if ( mode == Gb_Apu::mode_dmg && was_enabled &&
|
||||
(unsigned) (delay - 2 * clk_mul) < 2 * clk_mul )
|
||||
corrupt_wave();
|
||||
|
||||
|
||||
phase = 0;
|
||||
delay = period() + 6 * clk_mul;
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ void Gb_Square::run( blip_time_t time, blip_time_t end_time )
|
|||
duty = 8 - duty;
|
||||
}
|
||||
int ph = (this->phase + duty_offset) & 7;
|
||||
|
||||
|
||||
// Determine what will be generated
|
||||
int vol = 0;
|
||||
Blip_Buffer* const out = this->output;
|
||||
|
@ -345,18 +345,18 @@ void Gb_Square::run( blip_time_t time, blip_time_t end_time )
|
|||
{
|
||||
if ( enabled )
|
||||
vol = this->volume;
|
||||
|
||||
|
||||
amp = -dac_bias;
|
||||
if ( mode == Gb_Apu::mode_agb )
|
||||
amp = -(vol >> 1);
|
||||
|
||||
|
||||
// Play inaudible frequencies as constant amplitude
|
||||
if ( frequency() >= 0x7FA && delay < 32 * clk_mul )
|
||||
{
|
||||
amp += (vol * duty) >> 3;
|
||||
vol = 0;
|
||||
}
|
||||
|
||||
|
||||
if ( ph < duty )
|
||||
{
|
||||
amp += vol;
|
||||
|
@ -365,7 +365,7 @@ void Gb_Square::run( blip_time_t time, blip_time_t end_time )
|
|||
}
|
||||
update_amp( time, amp );
|
||||
}
|
||||
|
||||
|
||||
// Generate wave
|
||||
time += delay;
|
||||
if ( time < end_time )
|
||||
|
@ -393,7 +393,7 @@ void Gb_Square::run( blip_time_t time, blip_time_t end_time )
|
|||
time += per;
|
||||
}
|
||||
while ( time < end_time );
|
||||
|
||||
|
||||
if ( delta != vol )
|
||||
last_amp -= delta;
|
||||
}
|
||||
|
@ -407,34 +407,34 @@ void Gb_Square::run( blip_time_t time, blip_time_t end_time )
|
|||
static unsigned run_lfsr( unsigned s, unsigned mask, int count )
|
||||
{
|
||||
bool const optimized = true; // set to false to use only unoptimized loop in middle
|
||||
|
||||
|
||||
// optimization used in several places:
|
||||
// ((s & (1 << b)) << n) ^ ((s & (1 << b)) << (n + 1)) = (s & (1 << b)) * (3 << n)
|
||||
|
||||
|
||||
if ( mask == 0x4000 && optimized )
|
||||
{
|
||||
if ( count >= 32767 )
|
||||
count %= 32767;
|
||||
|
||||
|
||||
// Convert from Fibonacci to Galois configuration,
|
||||
// shifted left 1 bit
|
||||
s ^= (s & 1) * 0x8000;
|
||||
|
||||
|
||||
// Each iteration is equivalent to clocking LFSR 255 times
|
||||
while ( (count -= 255) > 0 )
|
||||
s ^= ((s & 0xE) << 12) ^ ((s & 0xE) << 11) ^ (s >> 3);
|
||||
count += 255;
|
||||
|
||||
|
||||
// Each iteration is equivalent to clocking LFSR 15 times
|
||||
// (interesting similarity to single clocking below)
|
||||
while ( (count -= 15) > 0 )
|
||||
s ^= ((s & 2) * (3 << 13)) ^ (s >> 1);
|
||||
count += 15;
|
||||
|
||||
|
||||
// Remaining singles
|
||||
while ( --count >= 0 )
|
||||
s = ((s & 2) * (3 << 13)) ^ (s >> 1);
|
||||
|
||||
|
||||
// Convert back to Fibonacci configuration
|
||||
s &= 0x7FFF;
|
||||
}
|
||||
|
@ -452,29 +452,29 @@ static unsigned run_lfsr( unsigned s, unsigned mask, int count )
|
|||
if ( !count )
|
||||
count = 127; // must run at least once
|
||||
}
|
||||
|
||||
|
||||
// Need to keep one extra bit of history
|
||||
s = s << 1 & 0xFF;
|
||||
|
||||
|
||||
// Convert from Fibonacci to Galois configuration,
|
||||
// shifted left 2 bits
|
||||
s ^= (s & 2) * 0x80;
|
||||
|
||||
|
||||
// Each iteration is equivalent to clocking LFSR 7 times
|
||||
// (interesting similarity to single clocking below)
|
||||
while ( (count -= 7) > 0 )
|
||||
s ^= ((s & 4) * (3 << 5)) ^ (s >> 1);
|
||||
count += 7;
|
||||
|
||||
|
||||
// Remaining singles
|
||||
while ( --count >= 0 )
|
||||
s = ((s & 4) * (3 << 5)) ^ (s >> 1);
|
||||
|
||||
|
||||
// Convert back to Fibonacci configuration and
|
||||
// repeat last 8 bits above significant 7
|
||||
s = (s << 7 & 0x7F80) | (s >> 1 & 0x7F);
|
||||
}
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -490,28 +490,28 @@ void Gb_Noise::run( blip_time_t time, blip_time_t end_time )
|
|||
{
|
||||
if ( enabled )
|
||||
vol = this->volume;
|
||||
|
||||
|
||||
amp = -dac_bias;
|
||||
if ( mode == Gb_Apu::mode_agb )
|
||||
amp = -(vol >> 1);
|
||||
|
||||
|
||||
if ( !(phase & 1) )
|
||||
{
|
||||
amp += vol;
|
||||
vol = -vol;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// AGB negates final output
|
||||
if ( mode == Gb_Apu::mode_agb )
|
||||
{
|
||||
vol = -vol;
|
||||
amp = -amp;
|
||||
}
|
||||
|
||||
|
||||
update_amp( time, amp );
|
||||
}
|
||||
|
||||
|
||||
// Run timer and calculate time of next LFSR clock
|
||||
static byte const period1s [8] = { 1, 2, 4, 6, 8, 10, 12, 14 };
|
||||
int const period1 = period1s [regs [3] & 7] * clk_mul;
|
||||
|
@ -519,18 +519,18 @@ void Gb_Noise::run( blip_time_t time, blip_time_t end_time )
|
|||
int extra = (end_time - time) - delay;
|
||||
int const per2 = this->period2();
|
||||
time += delay + ((divider ^ (per2 >> 1)) & (per2 - 1)) * period1;
|
||||
|
||||
|
||||
int count = (extra < 0 ? 0 : (extra + period1 - 1) / period1);
|
||||
divider = (divider - count) & period2_mask;
|
||||
delay = count * period1 - extra;
|
||||
}
|
||||
|
||||
|
||||
// Generate wave
|
||||
if ( time < end_time )
|
||||
{
|
||||
unsigned const mask = this->lfsr_mask();
|
||||
unsigned bits = this->phase;
|
||||
|
||||
|
||||
int per = period2( period1 * 8 );
|
||||
if ( period2_index() >= 0xE )
|
||||
{
|
||||
|
@ -560,7 +560,7 @@ void Gb_Noise::run( blip_time_t time, blip_time_t end_time )
|
|||
time += per;
|
||||
}
|
||||
while ( time < end_time );
|
||||
|
||||
|
||||
if ( delta == vol )
|
||||
last_amp += delta;
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ void Gb_Wave::run( blip_time_t time, blip_time_t end_time )
|
|||
int const volume_shift = 2;
|
||||
int const volume_idx = regs [2] >> 5 & (agb_mask | 3); // 2 bits on DMG/CGB, 3 on AGB
|
||||
int const volume_mul = volumes [volume_idx];
|
||||
|
||||
|
||||
// Determine what will be generated
|
||||
int playing = false;
|
||||
Blip_Buffer* const out = this->output;
|
||||
|
@ -586,27 +586,27 @@ void Gb_Wave::run( blip_time_t time, blip_time_t end_time )
|
|||
{
|
||||
// Play inaudible frequencies as constant amplitude
|
||||
amp = 8 << 4; // really depends on average of all samples in wave
|
||||
|
||||
|
||||
// if delay is larger, constant amplitude won't start yet
|
||||
if ( frequency() <= 0x7FB || delay > 15 * clk_mul )
|
||||
{
|
||||
if ( volume_mul )
|
||||
playing = (int) enabled;
|
||||
|
||||
|
||||
amp = (sample_buf << (phase << 2 & 4) & 0xF0) * playing;
|
||||
}
|
||||
|
||||
|
||||
amp = ((amp * volume_mul) >> (volume_shift + 4)) - dac_bias;
|
||||
}
|
||||
update_amp( time, amp );
|
||||
}
|
||||
|
||||
|
||||
// Generate wave
|
||||
time += delay;
|
||||
if ( time < end_time )
|
||||
{
|
||||
byte const* wave = this->wave_ram;
|
||||
|
||||
|
||||
// wave size and bank
|
||||
int const size20_mask = 0x20;
|
||||
int const flags = regs [0] & agb_mask;
|
||||
|
@ -617,10 +617,10 @@ void Gb_Wave::run( blip_time_t time, blip_time_t end_time )
|
|||
swap_banks = flags & size20_mask;
|
||||
wave += bank_size/2 - (swap_banks >> 1);
|
||||
}
|
||||
|
||||
|
||||
int ph = this->phase ^ swap_banks;
|
||||
ph = (ph + 1) & wave_mask; // pre-advance
|
||||
|
||||
|
||||
int const per = this->period();
|
||||
if ( !playing )
|
||||
{
|
||||
|
@ -638,10 +638,10 @@ void Gb_Wave::run( blip_time_t time, blip_time_t end_time )
|
|||
// Extract nybble
|
||||
int nybble = wave [ph >> 1] << (ph << 2 & 4) & 0xF0;
|
||||
ph = (ph + 1) & wave_mask;
|
||||
|
||||
|
||||
// Scale by volume
|
||||
int amp = (nybble * volume_mul) >> (volume_shift + 4);
|
||||
|
||||
|
||||
int delta = amp - lamp;
|
||||
if ( delta )
|
||||
{
|
||||
|
@ -654,11 +654,11 @@ void Gb_Wave::run( blip_time_t time, blip_time_t end_time )
|
|||
this->last_amp = lamp - dac_bias;
|
||||
}
|
||||
ph = (ph - 1) & wave_mask; // undo pre-advance and mask position
|
||||
|
||||
|
||||
// Keep track of last byte read
|
||||
if ( enabled )
|
||||
sample_buf = wave [ph >> 1];
|
||||
|
||||
|
||||
this->phase = ph ^ swap_banks; // undo swapped banks
|
||||
}
|
||||
delay = time - end_time;
|
||||
|
|
|
@ -17,17 +17,17 @@
|
|||
|
||||
class Gb_Osc {
|
||||
protected:
|
||||
|
||||
|
||||
// 11-bit frequency in NRx3 and NRx4
|
||||
int frequency() const { return (regs [4] & 7) * 0x100 + regs [3]; }
|
||||
|
||||
|
||||
void update_amp( blip_time_t, int new_amp );
|
||||
int write_trig( int frame_phase, int max_len, int old_data );
|
||||
public:
|
||||
|
||||
|
||||
enum { clk_mul = GB_APU_OVERCLOCK };
|
||||
enum { dac_bias = 7 };
|
||||
|
||||
|
||||
Blip_Buffer* outputs [4];// NULL, right, left, center
|
||||
Blip_Buffer* output; // where to output sound
|
||||
BOOST::uint8_t* regs; // osc's 5 registers
|
||||
|
@ -38,12 +38,12 @@ public:
|
|||
typedef Blip_Synth<blip_med_quality ,1> Med_Synth;
|
||||
Good_Synth const* good_synth;
|
||||
Med_Synth const* med_synth;
|
||||
|
||||
|
||||
int delay; // clocks until frequency timer expires
|
||||
int length_ctr; // length counter
|
||||
unsigned phase; // waveform phase (or equivalent)
|
||||
bool enabled; // internal enabled flag
|
||||
|
||||
|
||||
void clock_length();
|
||||
void reset();
|
||||
};
|
||||
|
@ -53,10 +53,10 @@ public:
|
|||
int env_delay;
|
||||
int volume;
|
||||
bool env_enabled;
|
||||
|
||||
|
||||
void clock_envelope();
|
||||
bool write_register( int frame_phase, int reg, int old_data, int data );
|
||||
|
||||
|
||||
void reset()
|
||||
{
|
||||
env_delay = 0;
|
||||
|
@ -75,7 +75,7 @@ class Gb_Square : public Gb_Env {
|
|||
public:
|
||||
bool write_register( int frame_phase, int reg, int old_data, int data );
|
||||
void run( blip_time_t, blip_time_t );
|
||||
|
||||
|
||||
void reset()
|
||||
{
|
||||
Gb_Env::reset();
|
||||
|
@ -95,7 +95,7 @@ public:
|
|||
|
||||
void clock_sweep();
|
||||
void write_register( int frame_phase, int reg, int old_data, int data );
|
||||
|
||||
|
||||
void reset()
|
||||
{
|
||||
sweep_freq = 0;
|
||||
|
@ -107,19 +107,19 @@ public:
|
|||
private:
|
||||
enum { period_mask = 0x70 };
|
||||
enum { shift_mask = 0x07 };
|
||||
|
||||
|
||||
void calc_sweep( bool update );
|
||||
void reload_sweep_timer();
|
||||
};
|
||||
|
||||
class Gb_Noise : public Gb_Env {
|
||||
public:
|
||||
|
||||
|
||||
int divider; // noise has more complex frequency divider setup
|
||||
|
||||
|
||||
void run( blip_time_t, blip_time_t );
|
||||
void write_register( int frame_phase, int reg, int old_data, int data );
|
||||
|
||||
|
||||
void reset()
|
||||
{
|
||||
divider = 0;
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
}
|
||||
private:
|
||||
enum { period2_mask = 0x1FFFF };
|
||||
|
||||
|
||||
int period2_index() const { return regs [3] >> 4; }
|
||||
int period2( int base = 8 ) const { return base << period2_index(); }
|
||||
unsigned lfsr_mask() const { return (regs [3] & 0x08) ? ~0x4040 : ~0x4000; }
|
||||
|
@ -137,39 +137,39 @@ private:
|
|||
class Gb_Wave : public Gb_Osc {
|
||||
public:
|
||||
int sample_buf; // last wave RAM byte read (hardware has this as well)
|
||||
|
||||
|
||||
void write_register( int frame_phase, int reg, int old_data, int data );
|
||||
void run( blip_time_t, blip_time_t );
|
||||
|
||||
|
||||
// Reads/writes wave RAM
|
||||
int read( unsigned addr ) const;
|
||||
void write( unsigned addr, int data );
|
||||
|
||||
|
||||
void reset()
|
||||
{
|
||||
sample_buf = 0;
|
||||
Gb_Osc::reset();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
enum { bank40_mask = 0x40 };
|
||||
enum { bank_size = 32 };
|
||||
|
||||
|
||||
int agb_mask; // 0xFF if AGB features enabled, 0 otherwise
|
||||
BOOST::uint8_t* wave_ram; // 32 bytes (64 nybbles), stored in APU
|
||||
|
||||
|
||||
friend class Gb_Apu;
|
||||
|
||||
|
||||
// Frequency timer period
|
||||
int period() const { return (2048 - frequency()) * (2 * clk_mul); }
|
||||
|
||||
|
||||
// Non-zero if DAC is enabled
|
||||
int dac_enabled() const { return regs [0] & 0x80; }
|
||||
|
||||
|
||||
void corrupt_wave();
|
||||
|
||||
|
||||
BOOST::uint8_t* wave_bank() const { return &wave_ram [(~regs [0] & bank40_mask) >> 2 & agb_mask]; }
|
||||
|
||||
|
||||
// Wave index that would be accessed, or -1 if no access would occur
|
||||
int access( unsigned addr ) const;
|
||||
};
|
||||
|
|
|
@ -178,7 +178,7 @@ long Stereo_Buffer::read_samples( blip_sample_t* out, long out_size )
|
|||
if ( pair_count )
|
||||
{
|
||||
mixer.read_pairs( out, pair_count );
|
||||
|
||||
|
||||
if ( samples_avail() <= 0 || immediate_removal() )
|
||||
{
|
||||
for ( int i = bufs_size; --i >= 0; )
|
||||
|
@ -219,7 +219,7 @@ void Stereo_Mixer::mix_mono( blip_sample_t* out_, int count )
|
|||
int const bass = BLIP_READER_BASS( *bufs [2] );
|
||||
BLIP_READER_BEGIN( center, *bufs [2] );
|
||||
BLIP_READER_ADJ_( center, samples_read );
|
||||
|
||||
|
||||
typedef blip_sample_t stereo_blip_sample_t [stereo];
|
||||
stereo_blip_sample_t* BLIP_RESTRICT out = (stereo_blip_sample_t*) out_ + count;
|
||||
int offset = -count;
|
||||
|
@ -228,33 +228,33 @@ void Stereo_Mixer::mix_mono( blip_sample_t* out_, int count )
|
|||
blargg_long s = BLIP_READER_READ( center );
|
||||
BLIP_READER_NEXT_IDX_( center, bass, offset );
|
||||
BLIP_CLAMP( s, s );
|
||||
|
||||
|
||||
out [offset] [0] = (blip_sample_t) s;
|
||||
out [offset] [1] = (blip_sample_t) s;
|
||||
}
|
||||
while ( ++offset );
|
||||
|
||||
|
||||
BLIP_READER_END( center, *bufs [2] );
|
||||
}
|
||||
|
||||
void Stereo_Mixer::mix_stereo( blip_sample_t* out_, int count )
|
||||
{
|
||||
blip_sample_t* BLIP_RESTRICT out = out_ + count * stereo;
|
||||
|
||||
|
||||
// do left + center and right + center separately to reduce register load
|
||||
Tracked_Blip_Buffer* const* buf = &bufs [2];
|
||||
while ( true ) // loop runs twice
|
||||
{
|
||||
--buf;
|
||||
--out;
|
||||
|
||||
|
||||
int const bass = BLIP_READER_BASS( *bufs [2] );
|
||||
BLIP_READER_BEGIN( side, **buf );
|
||||
BLIP_READER_BEGIN( center, *bufs [2] );
|
||||
|
||||
|
||||
BLIP_READER_ADJ_( side, samples_read );
|
||||
BLIP_READER_ADJ_( center, samples_read );
|
||||
|
||||
|
||||
int offset = -count;
|
||||
do
|
||||
{
|
||||
|
@ -263,17 +263,17 @@ void Stereo_Mixer::mix_stereo( blip_sample_t* out_, int count )
|
|||
BLIP_READER_NEXT_IDX_( side, bass, offset );
|
||||
BLIP_READER_NEXT_IDX_( center, bass, offset );
|
||||
BLIP_CLAMP( s, s );
|
||||
|
||||
|
||||
++offset; // before write since out is decremented to slightly before end
|
||||
out [offset * stereo] = (blip_sample_t) s;
|
||||
}
|
||||
while ( offset );
|
||||
|
||||
|
||||
BLIP_READER_END( side, **buf );
|
||||
|
||||
|
||||
if ( buf != bufs )
|
||||
continue;
|
||||
|
||||
|
||||
// only end center once
|
||||
BLIP_READER_END( center, *bufs [2] );
|
||||
break;
|
||||
|
|
|
@ -13,14 +13,14 @@ class Multi_Buffer {
|
|||
public:
|
||||
Multi_Buffer( int samples_per_frame );
|
||||
virtual ~Multi_Buffer() { }
|
||||
|
||||
|
||||
// Sets the number of channels available and optionally their types
|
||||
// (type information used by Effects_Buffer)
|
||||
enum { type_index_mask = 0xFF };
|
||||
enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type };
|
||||
virtual blargg_err_t set_channel_count( int, int const* types = 0 );
|
||||
int channel_count() const { return channel_count_; }
|
||||
|
||||
|
||||
// Gets indexed channel, from 0 to channel count - 1
|
||||
struct channel_t {
|
||||
Blip_Buffer* center;
|
||||
|
@ -28,31 +28,31 @@ public:
|
|||
Blip_Buffer* right;
|
||||
};
|
||||
virtual channel_t channel( int index ) BLARGG_PURE( ; )
|
||||
|
||||
|
||||
// See Blip_Buffer.h
|
||||
virtual blargg_err_t set_sample_rate( long rate, int msec = blip_default_length ) BLARGG_PURE( ; )
|
||||
virtual void clock_rate( long ) BLARGG_PURE( { } )
|
||||
virtual void bass_freq( int ) BLARGG_PURE( { } )
|
||||
virtual void clear() BLARGG_PURE( { } )
|
||||
long sample_rate() const;
|
||||
|
||||
|
||||
// Length of buffer, in milliseconds
|
||||
int length() const;
|
||||
|
||||
|
||||
// See Blip_Buffer.h
|
||||
virtual void end_frame( blip_time_t ) BLARGG_PURE( { } )
|
||||
|
||||
|
||||
// Number of samples per output frame (1 = mono, 2 = stereo)
|
||||
int samples_per_frame() const;
|
||||
|
||||
|
||||
// Count of changes to channel configuration. Incremented whenever
|
||||
// a change is made to any of the Blip_Buffers for any channel.
|
||||
unsigned channels_changed_count() { return channels_changed_count_; }
|
||||
|
||||
|
||||
// See Blip_Buffer.h
|
||||
virtual long read_samples( blip_sample_t*, long ) BLARGG_PURE( { return 0; } )
|
||||
virtual long samples_avail() const BLARGG_PURE( { return 0; } )
|
||||
|
||||
|
||||
public:
|
||||
BLARGG_DISABLE_NOTHROW
|
||||
void disable_immediate_removal() { immediate_removal_ = false; }
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
// noncopyable
|
||||
Multi_Buffer( const Multi_Buffer& );
|
||||
Multi_Buffer& operator = ( const Multi_Buffer& );
|
||||
|
||||
|
||||
unsigned channels_changed_count_;
|
||||
long sample_rate_;
|
||||
int length_;
|
||||
|
@ -81,7 +81,7 @@ class Mono_Buffer : public Multi_Buffer {
|
|||
public:
|
||||
// Buffer used for all channels
|
||||
Blip_Buffer* center() { return &buf; }
|
||||
|
||||
|
||||
public:
|
||||
Mono_Buffer();
|
||||
~Mono_Buffer();
|
||||
|
@ -100,13 +100,13 @@ public:
|
|||
// Non-zero if buffer still has non-silent samples in it. Requires that you call
|
||||
// set_modified() appropriately.
|
||||
blip_ulong non_silent() const;
|
||||
|
||||
|
||||
// remove_samples( samples_avail() )
|
||||
void remove_all_samples();
|
||||
|
||||
|
||||
public:
|
||||
BLARGG_DISABLE_NOTHROW
|
||||
|
||||
|
||||
long read_samples( blip_sample_t*, long );
|
||||
void remove_silence( long );
|
||||
void remove_samples( long );
|
||||
|
@ -117,12 +117,12 @@ public:
|
|||
blip_long last_non_silence;
|
||||
void remove_( long );
|
||||
};
|
||||
|
||||
|
||||
class Stereo_Mixer {
|
||||
public:
|
||||
Tracked_Blip_Buffer* bufs [3];
|
||||
blargg_long samples_read;
|
||||
|
||||
|
||||
Stereo_Mixer() : samples_read( 0 ) { }
|
||||
void read_pairs( blip_sample_t* out, int count );
|
||||
private:
|
||||
|
@ -133,12 +133,12 @@ public:
|
|||
// Uses three buffers (one for center) and outputs stereo sample pairs.
|
||||
class Stereo_Buffer : public Multi_Buffer {
|
||||
public:
|
||||
|
||||
|
||||
// Buffers used for all channels
|
||||
Blip_Buffer* center() { return &bufs [2]; }
|
||||
Blip_Buffer* left() { return &bufs [0]; }
|
||||
Blip_Buffer* right() { return &bufs [1]; }
|
||||
|
||||
|
||||
public:
|
||||
Stereo_Buffer();
|
||||
~Stereo_Buffer();
|
||||
|
@ -148,10 +148,10 @@ public:
|
|||
void clear();
|
||||
channel_t channel( int ) { return chan; }
|
||||
void end_frame( blip_time_t );
|
||||
|
||||
|
||||
long samples_avail() const { return (bufs [0].samples_avail() - mixer.samples_read) * 2; }
|
||||
long read_samples( blip_sample_t*, long );
|
||||
|
||||
|
||||
private:
|
||||
enum { bufs_size = 3 };
|
||||
typedef Tracked_Blip_Buffer buf_t;
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
typedef struct see_blargg_common_h int8_t;
|
||||
typedef struct see_blargg_common_h uint8_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if USHRT_MAX == 0xFFFF
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
typedef struct see_blargg_common_h int16_t;
|
||||
typedef struct see_blargg_common_h uint16_t;
|
||||
#endif
|
||||
|
||||
|
||||
#if ULONG_MAX == 0xFFFFFFFF
|
||||
typedef long int32_t;
|
||||
typedef unsigned long uint32_t;
|
||||
|
|
280
src/fex.h
280
src/fex.h
|
@ -1,140 +1,140 @@
|
|||
/* Compressed file archive C interface (also usable from C++) */
|
||||
|
||||
/* File_Extractor 0.4.3 */
|
||||
#ifndef FEX_H
|
||||
#define FEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Error string returned by library functions, or NULL if no error (success).
|
||||
If function takes fex_err_t* err_out, it sets *err_out to NULL on success,
|
||||
otherwise error string, or you can pass NULL if you don't care about exact
|
||||
cause of error (these functions still report error by returning NULL). */
|
||||
typedef const char* fex_err_t;
|
||||
|
||||
/* First parameter of most extractor_ functions is a pointer to the
|
||||
File_Extractor being acted on. */
|
||||
typedef struct File_Extractor File_Extractor;
|
||||
|
||||
|
||||
/**** Basics ****/
|
||||
|
||||
/* Opens archive and returns pointer to it, or NULL if error. */
|
||||
File_Extractor* fex_open( const char* path, fex_err_t* err_out );
|
||||
|
||||
/* True if at end of archive. */
|
||||
int fex_done( File_Extractor const* );
|
||||
|
||||
/* Name of current file. */
|
||||
const char* fex_name( File_Extractor* );
|
||||
|
||||
/* Size of current file. */
|
||||
long fex_size( File_Extractor const* );
|
||||
|
||||
/* Extracts n bytes and writes them to *out. Returns error if all n
|
||||
bytes couldn't be extracted (due to end of file or read error). */
|
||||
fex_err_t fex_read( File_Extractor*, void* out, long n );
|
||||
|
||||
/* Goes to next file in archive (skips directories). */
|
||||
fex_err_t fex_next( File_Extractor* );
|
||||
|
||||
/* Closes archive and frees memory. */
|
||||
void fex_close( File_Extractor* );
|
||||
|
||||
|
||||
/**** Advanced ****/
|
||||
|
||||
/* Goes back to first file in archive. */
|
||||
fex_err_t fex_rewind( File_Extractor* );
|
||||
|
||||
/* Hints to fex_next() that no file extraction will occur, speeding scanning
|
||||
of some archive types. */
|
||||
void fex_scan_only( File_Extractor* );
|
||||
|
||||
/* Modification date of current file (MS-DOS format). */
|
||||
unsigned long fex_dos_date( File_Extractor const* );
|
||||
|
||||
/* Number of bytes remaining to be read from current file. */
|
||||
long fex_remain( File_Extractor const* );
|
||||
|
||||
/* Reads at most n bytes and returns number actually read, or negative if error. */
|
||||
long fex_read_avail( File_Extractor*, void* out, long n );
|
||||
|
||||
/* Extracts first n bytes and ignores rest. Faster than a normal read since it
|
||||
doesn't need to read any more data. Must not be called twice in a row. */
|
||||
fex_err_t fex_read_once( File_Extractor*, void* out, long n );
|
||||
|
||||
/* Loads file data into memory (if not already) and returns pointer to it, or
|
||||
NULL if error. Pointer is valid until fex_next(), fex_rewind(), or fex_close() are
|
||||
called. Will return same pointer if called more than once. */
|
||||
const unsigned char* fex_data( File_Extractor*, fex_err_t* err_out );
|
||||
|
||||
|
||||
/**** Archive types ****/
|
||||
|
||||
/* fex_type_t is a pointer to this structure. For example, fex_zip_type->extension is
|
||||
"ZIP" and ex_zip_type->new_fex() is equilvant to 'new Zip_Extractor' (in C++). */
|
||||
struct fex_type_t_
|
||||
{
|
||||
const char* extension; /* file extension/type */
|
||||
File_Extractor* (*new_fex)();
|
||||
};
|
||||
|
||||
/* Archive type constants for each supported file type */
|
||||
extern struct fex_type_t_ const
|
||||
fex_7z_type [1], /* .7z (7-zip) */
|
||||
fex_gz_type [1], /* .gz (gzip) */
|
||||
/*fex_rar_type [1],*/ /* .rar */
|
||||
fex_zip_type [1], /* .zip */
|
||||
fex_bin_type [1]; /* binary file, possibly gzipped */
|
||||
typedef struct fex_type_t_ const* fex_type_t;
|
||||
|
||||
/* Array of supported archive types, with NULL entry at end. */
|
||||
fex_type_t const* fex_type_list();
|
||||
|
||||
/* Type of archive this extractor handles. */
|
||||
fex_type_t fex_type( File_Extractor const* );
|
||||
|
||||
|
||||
/******** Advanced opening ********/
|
||||
|
||||
/* Error returned if file is wrong type */
|
||||
extern const char fex_wrong_file_type [29];
|
||||
|
||||
/* Determines likely archive type based on first four bytes of file. Returns string
|
||||
containing proper file suffix (i.e. "ZIP", "GZ", etc.) or "" (empty string) if file
|
||||
header is not recognized. */
|
||||
const char* fex_identify_header( void const* header );
|
||||
|
||||
/* Gets corresponding archive type for file path or extension passed in. Returns NULL
|
||||
if type isn't recognized. */
|
||||
fex_type_t fex_identify_extension( const char* path_or_extension );
|
||||
|
||||
/* Determines file type based on filename extension, or file header (if extension
|
||||
isn't recognized). Returns NULL if unrecognized or error. */
|
||||
fex_type_t fex_identify_file( const char* path, fex_err_t* err_out );
|
||||
|
||||
/* Opens archive of specific type and returns pointer to it, or NULL if error. */
|
||||
File_Extractor* fex_open_type( fex_type_t, const char* path, fex_err_t* err_out );
|
||||
|
||||
|
||||
/******** User data ********/
|
||||
|
||||
/* Sets/gets pointer to data you want to associate with this extractor.
|
||||
You can use this for whatever you want. */
|
||||
void fex_set_user_data( File_Extractor*, void* new_user_data );
|
||||
void* fex_user_data( File_Extractor const* );
|
||||
|
||||
/* Registers cleanup function to be called when closing extractor, or NULL to
|
||||
clear it. Passes user_data (see above) to cleanup function. */
|
||||
typedef void (*fex_user_cleanup_t)( void* user_data );
|
||||
void fex_set_user_cleanup( File_Extractor*, fex_user_cleanup_t func );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* Compressed file archive C interface (also usable from C++) */
|
||||
|
||||
/* File_Extractor 0.4.3 */
|
||||
#ifndef FEX_H
|
||||
#define FEX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Error string returned by library functions, or NULL if no error (success).
|
||||
If function takes fex_err_t* err_out, it sets *err_out to NULL on success,
|
||||
otherwise error string, or you can pass NULL if you don't care about exact
|
||||
cause of error (these functions still report error by returning NULL). */
|
||||
typedef const char* fex_err_t;
|
||||
|
||||
/* First parameter of most extractor_ functions is a pointer to the
|
||||
File_Extractor being acted on. */
|
||||
typedef struct File_Extractor File_Extractor;
|
||||
|
||||
|
||||
/**** Basics ****/
|
||||
|
||||
/* Opens archive and returns pointer to it, or NULL if error. */
|
||||
File_Extractor* fex_open( const char* path, fex_err_t* err_out );
|
||||
|
||||
/* True if at end of archive. */
|
||||
int fex_done( File_Extractor const* );
|
||||
|
||||
/* Name of current file. */
|
||||
const char* fex_name( File_Extractor* );
|
||||
|
||||
/* Size of current file. */
|
||||
long fex_size( File_Extractor const* );
|
||||
|
||||
/* Extracts n bytes and writes them to *out. Returns error if all n
|
||||
bytes couldn't be extracted (due to end of file or read error). */
|
||||
fex_err_t fex_read( File_Extractor*, void* out, long n );
|
||||
|
||||
/* Goes to next file in archive (skips directories). */
|
||||
fex_err_t fex_next( File_Extractor* );
|
||||
|
||||
/* Closes archive and frees memory. */
|
||||
void fex_close( File_Extractor* );
|
||||
|
||||
|
||||
/**** Advanced ****/
|
||||
|
||||
/* Goes back to first file in archive. */
|
||||
fex_err_t fex_rewind( File_Extractor* );
|
||||
|
||||
/* Hints to fex_next() that no file extraction will occur, speeding scanning
|
||||
of some archive types. */
|
||||
void fex_scan_only( File_Extractor* );
|
||||
|
||||
/* Modification date of current file (MS-DOS format). */
|
||||
unsigned long fex_dos_date( File_Extractor const* );
|
||||
|
||||
/* Number of bytes remaining to be read from current file. */
|
||||
long fex_remain( File_Extractor const* );
|
||||
|
||||
/* Reads at most n bytes and returns number actually read, or negative if error. */
|
||||
long fex_read_avail( File_Extractor*, void* out, long n );
|
||||
|
||||
/* Extracts first n bytes and ignores rest. Faster than a normal read since it
|
||||
doesn't need to read any more data. Must not be called twice in a row. */
|
||||
fex_err_t fex_read_once( File_Extractor*, void* out, long n );
|
||||
|
||||
/* Loads file data into memory (if not already) and returns pointer to it, or
|
||||
NULL if error. Pointer is valid until fex_next(), fex_rewind(), or fex_close() are
|
||||
called. Will return same pointer if called more than once. */
|
||||
const unsigned char* fex_data( File_Extractor*, fex_err_t* err_out );
|
||||
|
||||
|
||||
/**** Archive types ****/
|
||||
|
||||
/* fex_type_t is a pointer to this structure. For example, fex_zip_type->extension is
|
||||
"ZIP" and ex_zip_type->new_fex() is equilvant to 'new Zip_Extractor' (in C++). */
|
||||
struct fex_type_t_
|
||||
{
|
||||
const char* extension; /* file extension/type */
|
||||
File_Extractor* (*new_fex)();
|
||||
};
|
||||
|
||||
/* Archive type constants for each supported file type */
|
||||
extern struct fex_type_t_ const
|
||||
fex_7z_type [1], /* .7z (7-zip) */
|
||||
fex_gz_type [1], /* .gz (gzip) */
|
||||
/*fex_rar_type [1],*/ /* .rar */
|
||||
fex_zip_type [1], /* .zip */
|
||||
fex_bin_type [1]; /* binary file, possibly gzipped */
|
||||
typedef struct fex_type_t_ const* fex_type_t;
|
||||
|
||||
/* Array of supported archive types, with NULL entry at end. */
|
||||
fex_type_t const* fex_type_list();
|
||||
|
||||
/* Type of archive this extractor handles. */
|
||||
fex_type_t fex_type( File_Extractor const* );
|
||||
|
||||
|
||||
/******** Advanced opening ********/
|
||||
|
||||
/* Error returned if file is wrong type */
|
||||
extern const char fex_wrong_file_type [29];
|
||||
|
||||
/* Determines likely archive type based on first four bytes of file. Returns string
|
||||
containing proper file suffix (i.e. "ZIP", "GZ", etc.) or "" (empty string) if file
|
||||
header is not recognized. */
|
||||
const char* fex_identify_header( void const* header );
|
||||
|
||||
/* Gets corresponding archive type for file path or extension passed in. Returns NULL
|
||||
if type isn't recognized. */
|
||||
fex_type_t fex_identify_extension( const char* path_or_extension );
|
||||
|
||||
/* Determines file type based on filename extension, or file header (if extension
|
||||
isn't recognized). Returns NULL if unrecognized or error. */
|
||||
fex_type_t fex_identify_file( const char* path, fex_err_t* err_out );
|
||||
|
||||
/* Opens archive of specific type and returns pointer to it, or NULL if error. */
|
||||
File_Extractor* fex_open_type( fex_type_t, const char* path, fex_err_t* err_out );
|
||||
|
||||
|
||||
/******** User data ********/
|
||||
|
||||
/* Sets/gets pointer to data you want to associate with this extractor.
|
||||
You can use this for whatever you want. */
|
||||
void fex_set_user_data( File_Extractor*, void* new_user_data );
|
||||
void* fex_user_data( File_Extractor const* );
|
||||
|
||||
/* Registers cleanup function to be called when closing extractor, or NULL to
|
||||
clear it. Passes user_data (see above) to cleanup function. */
|
||||
typedef void (*fex_user_cleanup_t)( void* user_data );
|
||||
void fex_set_user_cleanup( File_Extractor*, fex_user_cleanup_t func );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
444
src/fex_mini.cpp
444
src/fex_mini.cpp
|
@ -1,222 +1,222 @@
|
|||
// Minimal implementation of fex.h. Supports gzipped files if you have zlib
|
||||
// available and HAVE_ZLIB_H is defined.
|
||||
|
||||
// File_Extractor 0.4.3. http://www.slack.net/~ant/
|
||||
|
||||
#include "fex.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 2007 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef HAVE_ZLIB_H
|
||||
#define FILE_GZ( norm, gz ) norm
|
||||
#define FILE_READ( ptr, size, file ) fread( ptr, 1, size, file )
|
||||
#else
|
||||
#define FILE_GZ( norm, gz ) gz
|
||||
#define FILE_READ( ptr, size, file ) gzread( file, ptr, size )
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
static const char* get_gzip_size( const char* path, long* eof )
|
||||
{
|
||||
FILE* file = fopen( path, "rb" );
|
||||
if ( !file )
|
||||
return "Couldn't open file";
|
||||
|
||||
unsigned char buf [4];
|
||||
if ( fread( buf, 2, 1, file ) > 0 && buf [0] == 0x1F && buf [1] == 0x8B )
|
||||
{
|
||||
fseek( file, -4, SEEK_END );
|
||||
fread( buf, 4, 1, file );
|
||||
*eof = buf [3] * 0x1000000 + buf [2] * 0x10000 + buf [1] * 0x100 + buf [0];
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek( file, 0, SEEK_END );
|
||||
*eof = ftell( file );
|
||||
}
|
||||
const char* err = (ferror( file ) || feof( file )) ? "Couldn't get file size" : 0;
|
||||
fclose( file );
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char fex_wrong_file_type [] = "Archive format not supported";
|
||||
|
||||
struct File_Extractor
|
||||
{
|
||||
FILE_GZ(FILE*,gzFile) file;
|
||||
int done;
|
||||
long size;
|
||||
void* data; // file data read into memory, ot 0 if not read
|
||||
void* user_data;
|
||||
fex_user_cleanup_t user_cleanup;
|
||||
|
||||
char* name() const { return (char*) (this + 1); }
|
||||
};
|
||||
|
||||
// Always identify as single file extractor
|
||||
fex_type_t_ const fex_bin_type [1] = {{ "" , 0 }};
|
||||
const char* fex_identify_header ( void const* ) { return ""; }
|
||||
fex_type_t fex_identify_extension( const char* ) { return fex_bin_type; }
|
||||
fex_type_t fex_identify_file ( const char*, fex_err_t* e ) { if ( e ) *e = 0; return fex_bin_type; }
|
||||
|
||||
static fex_err_t fex_open_( const char* path, File_Extractor** fe_out )
|
||||
{
|
||||
*fe_out = 0;
|
||||
|
||||
// name
|
||||
const char* name = strrchr( path, '\\' ); // DOS
|
||||
if ( !name )
|
||||
name = strrchr( path, '/' ); // UNIX
|
||||
if ( !name )
|
||||
name = strrchr( path, ':' ); // Mac
|
||||
if ( !name )
|
||||
name = path;
|
||||
|
||||
// allocate space for struct and name
|
||||
long name_size = strlen( name ) + 1;
|
||||
File_Extractor* fe = (File_Extractor*) malloc( sizeof (File_Extractor) + name_size );
|
||||
if ( !fe ) return "Out of memory";
|
||||
|
||||
fe->done = 0;
|
||||
fe->data = 0;
|
||||
fe->user_data = 0;
|
||||
fe->user_cleanup = 0;
|
||||
memcpy( fe->name(), name, name_size );
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
// get gzip size BEFORE opening file
|
||||
const char* err = get_gzip_size( path, &fe->size );
|
||||
if ( err )
|
||||
{
|
||||
free( fe );
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
// open file
|
||||
fe->file = FILE_GZ(fopen,gzopen)( path, "rb" );
|
||||
if ( !fe->file )
|
||||
{
|
||||
free( fe );
|
||||
return "Couldn't open file";
|
||||
}
|
||||
|
||||
// get normal size
|
||||
#ifndef HAVE_ZLIB_H
|
||||
fseek( fe->file, 0, SEEK_END );
|
||||
fe->size = ftell( fe->file );
|
||||
rewind( fe->file );
|
||||
#endif
|
||||
|
||||
*fe_out = fe;
|
||||
return 0;
|
||||
}
|
||||
|
||||
File_Extractor* fex_open( const char* path, fex_err_t* err_out )
|
||||
{
|
||||
File_Extractor* fe;
|
||||
fex_err_t err = fex_open_( path, &fe );
|
||||
if ( err_out )
|
||||
*err_out = err;
|
||||
return fe;
|
||||
}
|
||||
|
||||
File_Extractor* fex_open_type( fex_type_t, const char* path, fex_err_t* err_out )
|
||||
{
|
||||
return fex_open( path, err_out );
|
||||
}
|
||||
|
||||
void* fex_user_data ( File_Extractor const* fe ) { return fe->user_data; }
|
||||
void fex_set_user_data ( File_Extractor* fe, void* new_user_data ) { fe->user_data = new_user_data; }
|
||||
void fex_set_user_cleanup ( File_Extractor* fe, fex_user_cleanup_t func ) { fe->user_cleanup = func; }
|
||||
|
||||
fex_type_t fex_type ( File_Extractor const* ) { return fex_bin_type; }
|
||||
int fex_done ( File_Extractor const* fe ) { return fe->done; }
|
||||
const char* fex_name ( File_Extractor* fe ) { return fe->name(); }
|
||||
unsigned long fex_dos_date ( File_Extractor const* ) { return 0; }
|
||||
long fex_size ( File_Extractor const* fe ) { return fe->size; }
|
||||
long fex_remain ( File_Extractor const* fe ) { return fe->size - FILE_GZ(ftell,gztell)( fe->file ); }
|
||||
void fex_scan_only ( File_Extractor* ) { }
|
||||
fex_err_t fex_read_once ( File_Extractor* fe, void* out, long count ) { return fex_read( fe, out, count ); }
|
||||
long fex_read_avail ( File_Extractor* fe, void* out, long count ) { return FILE_READ( out, count, fe->file ); }
|
||||
|
||||
fex_err_t fex_read( File_Extractor* fe, void* out, long count )
|
||||
{
|
||||
if ( count == (long) FILE_READ( out, count, fe->file ) )
|
||||
return 0;
|
||||
|
||||
if ( FILE_GZ(feof,gzeof)( fe->file ) )
|
||||
return "Unexpected end of file";
|
||||
|
||||
return "Couldn't read from file";
|
||||
}
|
||||
|
||||
fex_err_t fex_next( File_Extractor* fe )
|
||||
{
|
||||
fe->done = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fex_err_t fex_rewind( File_Extractor* fe )
|
||||
{
|
||||
fe->done = 0;
|
||||
FILE_GZ(rewind,gzrewind)( fe->file );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static fex_err_t fex_data_( File_Extractor* fe )
|
||||
{
|
||||
if ( !fe->data )
|
||||
{
|
||||
fe->data = malloc( fe->size );
|
||||
if ( !fe->data ) return "Out of memory";
|
||||
|
||||
fex_err_t err = fex_read( fe, fe->data, fe->size );
|
||||
if ( err )
|
||||
{
|
||||
free( fe->data );
|
||||
return err;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const unsigned char* fex_data( File_Extractor* fe, fex_err_t* err_out )
|
||||
{
|
||||
fex_err_t err = fex_data_( fe );
|
||||
if ( err_out )
|
||||
*err_out = err;
|
||||
return (const unsigned char*) fe->data;
|
||||
}
|
||||
|
||||
void fex_close( File_Extractor* fe )
|
||||
{
|
||||
if ( fe )
|
||||
{
|
||||
free( fe->data );
|
||||
FILE_GZ(fclose,gzclose)( fe->file );
|
||||
|
||||
if ( fe->user_cleanup )
|
||||
fe->user_cleanup( fe->user_data );
|
||||
|
||||
free( fe );
|
||||
}
|
||||
}
|
||||
// Minimal implementation of fex.h. Supports gzipped files if you have zlib
|
||||
// available and HAVE_ZLIB_H is defined.
|
||||
|
||||
// File_Extractor 0.4.3. http://www.slack.net/~ant/
|
||||
|
||||
#include "fex.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Copyright (C) 2007 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
||||
details. You should have received a copy of the GNU Lesser General Public
|
||||
License along with this module; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
||||
|
||||
#ifndef HAVE_ZLIB_H
|
||||
#define FILE_GZ( norm, gz ) norm
|
||||
#define FILE_READ( ptr, size, file ) fread( ptr, 1, size, file )
|
||||
#else
|
||||
#define FILE_GZ( norm, gz ) gz
|
||||
#define FILE_READ( ptr, size, file ) gzread( file, ptr, size )
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
static const char* get_gzip_size( const char* path, long* eof )
|
||||
{
|
||||
FILE* file = fopen( path, "rb" );
|
||||
if ( !file )
|
||||
return "Couldn't open file";
|
||||
|
||||
unsigned char buf [4];
|
||||
if ( fread( buf, 2, 1, file ) > 0 && buf [0] == 0x1F && buf [1] == 0x8B )
|
||||
{
|
||||
fseek( file, -4, SEEK_END );
|
||||
fread( buf, 4, 1, file );
|
||||
*eof = buf [3] * 0x1000000 + buf [2] * 0x10000 + buf [1] * 0x100 + buf [0];
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek( file, 0, SEEK_END );
|
||||
*eof = ftell( file );
|
||||
}
|
||||
const char* err = (ferror( file ) || feof( file )) ? "Couldn't get file size" : 0;
|
||||
fclose( file );
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char fex_wrong_file_type [] = "Archive format not supported";
|
||||
|
||||
struct File_Extractor
|
||||
{
|
||||
FILE_GZ(FILE*,gzFile) file;
|
||||
int done;
|
||||
long size;
|
||||
void* data; // file data read into memory, ot 0 if not read
|
||||
void* user_data;
|
||||
fex_user_cleanup_t user_cleanup;
|
||||
|
||||
char* name() const { return (char*) (this + 1); }
|
||||
};
|
||||
|
||||
// Always identify as single file extractor
|
||||
fex_type_t_ const fex_bin_type [1] = {{ "" , 0 }};
|
||||
const char* fex_identify_header ( void const* ) { return ""; }
|
||||
fex_type_t fex_identify_extension( const char* ) { return fex_bin_type; }
|
||||
fex_type_t fex_identify_file ( const char*, fex_err_t* e ) { if ( e ) *e = 0; return fex_bin_type; }
|
||||
|
||||
static fex_err_t fex_open_( const char* path, File_Extractor** fe_out )
|
||||
{
|
||||
*fe_out = 0;
|
||||
|
||||
// name
|
||||
const char* name = strrchr( path, '\\' ); // DOS
|
||||
if ( !name )
|
||||
name = strrchr( path, '/' ); // UNIX
|
||||
if ( !name )
|
||||
name = strrchr( path, ':' ); // Mac
|
||||
if ( !name )
|
||||
name = path;
|
||||
|
||||
// allocate space for struct and name
|
||||
long name_size = strlen( name ) + 1;
|
||||
File_Extractor* fe = (File_Extractor*) malloc( sizeof (File_Extractor) + name_size );
|
||||
if ( !fe ) return "Out of memory";
|
||||
|
||||
fe->done = 0;
|
||||
fe->data = 0;
|
||||
fe->user_data = 0;
|
||||
fe->user_cleanup = 0;
|
||||
memcpy( fe->name(), name, name_size );
|
||||
|
||||
#ifdef HAVE_ZLIB_H
|
||||
// get gzip size BEFORE opening file
|
||||
const char* err = get_gzip_size( path, &fe->size );
|
||||
if ( err )
|
||||
{
|
||||
free( fe );
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
// open file
|
||||
fe->file = FILE_GZ(fopen,gzopen)( path, "rb" );
|
||||
if ( !fe->file )
|
||||
{
|
||||
free( fe );
|
||||
return "Couldn't open file";
|
||||
}
|
||||
|
||||
// get normal size
|
||||
#ifndef HAVE_ZLIB_H
|
||||
fseek( fe->file, 0, SEEK_END );
|
||||
fe->size = ftell( fe->file );
|
||||
rewind( fe->file );
|
||||
#endif
|
||||
|
||||
*fe_out = fe;
|
||||
return 0;
|
||||
}
|
||||
|
||||
File_Extractor* fex_open( const char* path, fex_err_t* err_out )
|
||||
{
|
||||
File_Extractor* fe;
|
||||
fex_err_t err = fex_open_( path, &fe );
|
||||
if ( err_out )
|
||||
*err_out = err;
|
||||
return fe;
|
||||
}
|
||||
|
||||
File_Extractor* fex_open_type( fex_type_t, const char* path, fex_err_t* err_out )
|
||||
{
|
||||
return fex_open( path, err_out );
|
||||
}
|
||||
|
||||
void* fex_user_data ( File_Extractor const* fe ) { return fe->user_data; }
|
||||
void fex_set_user_data ( File_Extractor* fe, void* new_user_data ) { fe->user_data = new_user_data; }
|
||||
void fex_set_user_cleanup ( File_Extractor* fe, fex_user_cleanup_t func ) { fe->user_cleanup = func; }
|
||||
|
||||
fex_type_t fex_type ( File_Extractor const* ) { return fex_bin_type; }
|
||||
int fex_done ( File_Extractor const* fe ) { return fe->done; }
|
||||
const char* fex_name ( File_Extractor* fe ) { return fe->name(); }
|
||||
unsigned long fex_dos_date ( File_Extractor const* ) { return 0; }
|
||||
long fex_size ( File_Extractor const* fe ) { return fe->size; }
|
||||
long fex_remain ( File_Extractor const* fe ) { return fe->size - FILE_GZ(ftell,gztell)( fe->file ); }
|
||||
void fex_scan_only ( File_Extractor* ) { }
|
||||
fex_err_t fex_read_once ( File_Extractor* fe, void* out, long count ) { return fex_read( fe, out, count ); }
|
||||
long fex_read_avail ( File_Extractor* fe, void* out, long count ) { return FILE_READ( out, count, fe->file ); }
|
||||
|
||||
fex_err_t fex_read( File_Extractor* fe, void* out, long count )
|
||||
{
|
||||
if ( count == (long) FILE_READ( out, count, fe->file ) )
|
||||
return 0;
|
||||
|
||||
if ( FILE_GZ(feof,gzeof)( fe->file ) )
|
||||
return "Unexpected end of file";
|
||||
|
||||
return "Couldn't read from file";
|
||||
}
|
||||
|
||||
fex_err_t fex_next( File_Extractor* fe )
|
||||
{
|
||||
fe->done = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
fex_err_t fex_rewind( File_Extractor* fe )
|
||||
{
|
||||
fe->done = 0;
|
||||
FILE_GZ(rewind,gzrewind)( fe->file );
|
||||
return 0;
|
||||
}
|
||||
|
||||
static fex_err_t fex_data_( File_Extractor* fe )
|
||||
{
|
||||
if ( !fe->data )
|
||||
{
|
||||
fe->data = malloc( fe->size );
|
||||
if ( !fe->data ) return "Out of memory";
|
||||
|
||||
fex_err_t err = fex_read( fe, fe->data, fe->size );
|
||||
if ( err )
|
||||
{
|
||||
free( fe->data );
|
||||
return err;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const unsigned char* fex_data( File_Extractor* fe, fex_err_t* err_out )
|
||||
{
|
||||
fex_err_t err = fex_data_( fe );
|
||||
if ( err_out )
|
||||
*err_out = err;
|
||||
return (const unsigned char*) fe->data;
|
||||
}
|
||||
|
||||
void fex_close( File_Extractor* fe )
|
||||
{
|
||||
if ( fe )
|
||||
{
|
||||
free( fe->data );
|
||||
FILE_GZ(fclose,gzclose)( fe->file );
|
||||
|
||||
if ( fe->user_cleanup )
|
||||
fe->user_cleanup( fe->user_data );
|
||||
|
||||
free( fe );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,168 +1,168 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
#include "../../Util.h"
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void hq3x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq3x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
unsigned int LUT16to32[65536];
|
||||
unsigned int RGBtoYUV[65536];
|
||||
}
|
||||
|
||||
void InitLUTs(void)
|
||||
{
|
||||
int i, j, k, r, g, b, Y, u, v;
|
||||
|
||||
for (i=0; i<65536; i++)
|
||||
LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
for (j=0; j<64; j++)
|
||||
for (k=0; k<32; k++)
|
||||
{
|
||||
r = i << 3;
|
||||
g = j << 2;
|
||||
b = k << 3;
|
||||
Y = (r + g + b) >> 2;
|
||||
u = 128 + ((r - b) >> 2);
|
||||
v = 128 + ((-r + 2*g -b)>>3);
|
||||
RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v;
|
||||
}
|
||||
}
|
||||
|
||||
int hq3xinited=0;
|
||||
extern int realsystemRedShift, realsystemBlueShift;
|
||||
|
||||
//16 bit input, see below for 32 bit input
|
||||
void hq3x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2) );
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *12)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 3;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*3;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hq3x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
|
||||
void hq4x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
//16 bit input, see below for 32 bit input
|
||||
void hq4x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *16)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 4;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*4;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void convert32bpp_16bpp(unsigned char *pIn, unsigned int width)
|
||||
{
|
||||
for (unsigned int i = 0; i < width; i+=4)
|
||||
{
|
||||
unsigned int p4 = ((unsigned int)pIn[i+2] << 16) | (unsigned int) (pIn[i+1] << 8) | pIn[i+0];
|
||||
unsigned short p2 = ((p4 >> 8)&0xF800) | ((p4 >> 5)&0x07E0) | ((p4 >> 3)&0x001F);
|
||||
pIn[i/2] = (p2 >> 0);
|
||||
pIn[i/2+1] = (p2 >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
convert32bpp_16bpp(pIn, srcPitch*Yres);
|
||||
hq3x32(pIn, srcPitch/2, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
|
||||
void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
convert32bpp_16bpp(pIn, srcPitch*Yres);
|
||||
hq4x32(pIn, srcPitch/2, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2005 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
#include "../../Util.h"
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void hq3x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq3x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_16(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
void hq4x_32(unsigned char*, unsigned char*, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
|
||||
unsigned int LUT16to32[65536];
|
||||
unsigned int RGBtoYUV[65536];
|
||||
}
|
||||
|
||||
void InitLUTs(void)
|
||||
{
|
||||
int i, j, k, r, g, b, Y, u, v;
|
||||
|
||||
for (i=0; i<65536; i++)
|
||||
LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3);
|
||||
|
||||
for (i=0; i<32; i++)
|
||||
for (j=0; j<64; j++)
|
||||
for (k=0; k<32; k++)
|
||||
{
|
||||
r = i << 3;
|
||||
g = j << 2;
|
||||
b = k << 3;
|
||||
Y = (r + g + b) >> 2;
|
||||
u = 128 + ((r - b) >> 2);
|
||||
v = 128 + ((-r + 2*g -b)>>3);
|
||||
RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v;
|
||||
}
|
||||
}
|
||||
|
||||
int hq3xinited=0;
|
||||
extern int realsystemRedShift, realsystemBlueShift;
|
||||
|
||||
//16 bit input, see below for 32 bit input
|
||||
void hq3x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2) );
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *12)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 3;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*3;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hq3x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq3x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
|
||||
void hq4x16(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_16( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
}
|
||||
|
||||
//16 bit input, see below for 32 bit input
|
||||
void hq4x32(unsigned char * pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char * pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres)
|
||||
{
|
||||
if (!hq3xinited)
|
||||
{
|
||||
InitLUTs();
|
||||
hq3xinited=1;
|
||||
}
|
||||
hq4x_32( pIn, pOut, Xres, Yres, dstPitch, srcPitch - (Xres *2));
|
||||
if (realsystemRedShift == 3)
|
||||
{ // damn you opengl...
|
||||
int offset = (dstPitch - (Xres *16)) / 4;
|
||||
unsigned int *p = (unsigned int *)pOut;
|
||||
Yres *= 4;
|
||||
while(Yres--)
|
||||
{
|
||||
for(int i=0;i<Xres*4;i++)
|
||||
{
|
||||
*p = (*p & 0xFF0000) >> 16 |
|
||||
(*p & 0x0000FF) << 16 |
|
||||
(*p & 0x00FF00);
|
||||
p++;
|
||||
}
|
||||
p += offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void convert32bpp_16bpp(unsigned char *pIn, unsigned int width)
|
||||
{
|
||||
for (unsigned int i = 0; i < width; i+=4)
|
||||
{
|
||||
unsigned int p4 = ((unsigned int)pIn[i+2] << 16) | (unsigned int) (pIn[i+1] << 8) | pIn[i+0];
|
||||
unsigned short p2 = ((p4 >> 8)&0xF800) | ((p4 >> 5)&0x07E0) | ((p4 >> 3)&0x001F);
|
||||
pIn[i/2] = (p2 >> 0);
|
||||
pIn[i/2+1] = (p2 >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
convert32bpp_16bpp(pIn, srcPitch*Yres);
|
||||
hq3x32(pIn, srcPitch/2, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
|
||||
void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
convert32bpp_16bpp(pIn, srcPitch*Yres);
|
||||
hq4x32(pIn, srcPitch/2, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,73 +1,73 @@
|
|||
;Copyright (C) 1997-2007 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )
|
||||
;
|
||||
;http://www.zsnes.com
|
||||
;http://sourceforge.net/projects/zsnes
|
||||
;https://zsnes.bountysource.com
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;version 2 as published by the Free Software Foundation.
|
||||
;
|
||||
;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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
%ifdef __AMD64__
|
||||
bits 64
|
||||
%else
|
||||
bits 32
|
||||
%endif
|
||||
|
||||
%ifdef MACHO
|
||||
section .text align=16
|
||||
section .data align=4
|
||||
section .bss align=4
|
||||
%endif
|
||||
|
||||
%ifdef ELF
|
||||
|
||||
%imacro newsym 1
|
||||
GLOBAL %1
|
||||
%1:
|
||||
%endmacro
|
||||
%imacro newsym 2+
|
||||
GLOBAL %1
|
||||
%1: %2
|
||||
%endmacro
|
||||
%define EXTSYM EXTERN
|
||||
|
||||
section .note.GNU-stack noalloc noexec nowrite progbits
|
||||
|
||||
%else
|
||||
|
||||
%imacro newsym 1
|
||||
GLOBAL _%1
|
||||
_%1:
|
||||
%1:
|
||||
%endmacro
|
||||
%imacro newsym 2+
|
||||
GLOBAL _%1
|
||||
_%1:
|
||||
%1: %2
|
||||
%endmacro
|
||||
%imacro EXTSYM 1-*
|
||||
%rep %0
|
||||
EXTERN _%1
|
||||
%define %1 _%1
|
||||
%rotate 1
|
||||
%endrep
|
||||
%endmacro
|
||||
%endif
|
||||
|
||||
%macro ALIGN32 0
|
||||
times ($$-$) & 1Fh nop ; Long word alignment
|
||||
%endmacro
|
||||
%macro ALIGN16 0
|
||||
times ($$-$) & 1Fh nop ; Long word alignment
|
||||
%endmacro
|
||||
;Copyright (C) 1997-2007 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )
|
||||
;
|
||||
;http://www.zsnes.com
|
||||
;http://sourceforge.net/projects/zsnes
|
||||
;https://zsnes.bountysource.com
|
||||
;
|
||||
;This program is free software; you can redistribute it and/or
|
||||
;modify it under the terms of the GNU General Public License
|
||||
;version 2 as published by the Free Software Foundation.
|
||||
;
|
||||
;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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
|
||||
%ifdef __AMD64__
|
||||
bits 64
|
||||
%else
|
||||
bits 32
|
||||
%endif
|
||||
|
||||
%ifdef MACHO
|
||||
section .text align=16
|
||||
section .data align=4
|
||||
section .bss align=4
|
||||
%endif
|
||||
|
||||
%ifdef ELF
|
||||
|
||||
%imacro newsym 1
|
||||
GLOBAL %1
|
||||
%1:
|
||||
%endmacro
|
||||
%imacro newsym 2+
|
||||
GLOBAL %1
|
||||
%1: %2
|
||||
%endmacro
|
||||
%define EXTSYM EXTERN
|
||||
|
||||
section .note.GNU-stack noalloc noexec nowrite progbits
|
||||
|
||||
%else
|
||||
|
||||
%imacro newsym 1
|
||||
GLOBAL _%1
|
||||
_%1:
|
||||
%1:
|
||||
%endmacro
|
||||
%imacro newsym 2+
|
||||
GLOBAL _%1
|
||||
_%1:
|
||||
%1: %2
|
||||
%endmacro
|
||||
%imacro EXTSYM 1-*
|
||||
%rep %0
|
||||
EXTERN _%1
|
||||
%define %1 _%1
|
||||
%rotate 1
|
||||
%endrep
|
||||
%endmacro
|
||||
%endif
|
||||
|
||||
%macro ALIGN32 0
|
||||
times ($$-$) & 1Fh nop ; Long word alignment
|
||||
%endmacro
|
||||
%macro ALIGN16 0
|
||||
times ($$-$) & 1Fh nop ; Long word alignment
|
||||
%endmacro
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,449 +1,449 @@
|
|||
/*
|
||||
VisualBoyAdvance - a Game Boy & Game Boy Advance emulator
|
||||
|
||||
Copyright (C) 2008 VBA-M development team
|
||||
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
hq filter by Maxim Stepin ( http://hiend3d.com )
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _16BIT
|
||||
#ifdef _32BIT
|
||||
#error _16BIT and _32BIT defined at the same time!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _16BIT
|
||||
#define SIZE_PIXEL 2 // 16bit = 2 bytes
|
||||
#define COLORTYPE unsigned short
|
||||
#define RGBtoYUV RGBtoYUV_16
|
||||
#define Interp1 Interp1_16
|
||||
#define Interp2 Interp2_16
|
||||
#define Interp3 Interp3_16
|
||||
#define Interp4 Interp4_16
|
||||
#define Interp5 Interp5_16
|
||||
#define Interp6 Interp6_16
|
||||
#define Interp7 Interp7_16
|
||||
#define Interp8 Interp8_16
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _32BIT
|
||||
#define SIZE_PIXEL 4 // 32bit = 4 bytes
|
||||
#define COLORTYPE unsigned int
|
||||
#define RGBtoYUV RGBtoYUV_32
|
||||
#define Interp1 Interp1_32
|
||||
#define Interp2 Interp2_32
|
||||
#define Interp3 Interp3_32
|
||||
#define Interp4 Interp4_32
|
||||
#define Interp5 Interp5_32
|
||||
#define Interp6 Interp6_32
|
||||
#define Interp7 Interp7_32
|
||||
#define Interp8 Interp8_32
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _HQ3X
|
||||
|
||||
#define _MAGNIFICATION 3
|
||||
|
||||
#define PIXEL00_1M Interp1( pOut, c[5], c[1] );
|
||||
#define PIXEL00_1U Interp1( pOut, c[5], c[2] );
|
||||
#define PIXEL00_1L Interp1( pOut, c[5], c[4] );
|
||||
#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_4 Interp4( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_5 Interp5( pOut, c[4], c[2] );
|
||||
#define PIXEL00_C *((COLORTYPE*)(pOut)) = c[5];
|
||||
|
||||
#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_3 Interp3( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] );
|
||||
#define PIXEL01_C *((COLORTYPE*)(pOut+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL02_1M Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3] );
|
||||
#define PIXEL02_1U Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL02_1R Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL02_2 Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_4 Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] );
|
||||
#define PIXEL02_C *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_3 Interp3( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_6 Interp1( pOut+dstPitch, c[4], c[5] );
|
||||
#define PIXEL10_C *((COLORTYPE*)(pOut+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL11 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL12_1 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_3 Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_6 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] );
|
||||
#define PIXEL12_C *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL20_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] );
|
||||
#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] );
|
||||
#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] );
|
||||
#define PIXEL20_2 Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, c[8], c[4] );
|
||||
#define PIXEL20_C *((COLORTYPE*)(pOut+dstPitch+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_3 Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] );
|
||||
#define PIXEL21_C *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL22_1M Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9] );
|
||||
#define PIXEL22_1D Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL22_1R Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL22_2 Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_4 Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_5 Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8] );
|
||||
#define PIXEL22_C *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#endif // #ifdef _HQ3X
|
||||
|
||||
|
||||
|
||||
#ifdef _HQ4X
|
||||
|
||||
#define _MAGNIFICATION 4
|
||||
|
||||
#define PIXEL00_0 *((COLORTYPE*)(pOut)) = c[5];
|
||||
#define PIXEL00_11 Interp1(pOut, c[5], c[4]);
|
||||
#define PIXEL00_12 Interp1(pOut, c[5], c[2]);
|
||||
#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]);
|
||||
#define PIXEL00_50 Interp5(pOut, c[2], c[4]);
|
||||
#define PIXEL00_80 Interp8(pOut, c[5], c[1]);
|
||||
#define PIXEL00_81 Interp8(pOut, c[5], c[4]);
|
||||
#define PIXEL00_82 Interp8(pOut, c[5], c[2]);
|
||||
|
||||
#define PIXEL01_0 *((COLORTYPE*)(pOut+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL01_10 Interp1(pOut+SIZE_PIXEL, c[5], c[1]);
|
||||
#define PIXEL01_12 Interp1(pOut+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL01_14 Interp1(pOut+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL01_21 Interp2(pOut+SIZE_PIXEL, c[2], c[5], c[4]);
|
||||
#define PIXEL01_31 Interp3(pOut+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL01_50 Interp5(pOut+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL01_60 Interp6(pOut+SIZE_PIXEL, c[5], c[2], c[4]);
|
||||
#define PIXEL01_61 Interp6(pOut+SIZE_PIXEL, c[5], c[2], c[1]);
|
||||
#define PIXEL01_82 Interp8(pOut+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL01_83 Interp8(pOut+SIZE_PIXEL, c[2], c[4]);
|
||||
|
||||
#define PIXEL02_0 *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL02_10 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL02_11 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL02_13 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL02_21 Interp2(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5], c[6]);
|
||||
#define PIXEL02_32 Interp3(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL02_50 Interp5(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL02_60 Interp6(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6]);
|
||||
#define PIXEL02_61 Interp6(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[3]);
|
||||
#define PIXEL02_81 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL02_83 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]);
|
||||
|
||||
#define PIXEL03_0 *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL03_11 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL03_12 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL03_20 Interp2(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6]);
|
||||
#define PIXEL03_50 Interp5(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]);
|
||||
#define PIXEL03_80 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL03_81 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL03_82 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
|
||||
#define PIXEL10_0 *((COLORTYPE*)(pOut+dstPitch)) = c[5];
|
||||
#define PIXEL10_10 Interp1(pOut+dstPitch, c[5], c[1]);
|
||||
#define PIXEL10_11 Interp1(pOut+dstPitch, c[5], c[4]);
|
||||
#define PIXEL10_13 Interp1(pOut+dstPitch, c[4], c[5]);
|
||||
#define PIXEL10_21 Interp2(pOut+dstPitch, c[4], c[5], c[2]);
|
||||
#define PIXEL10_32 Interp3(pOut+dstPitch, c[5], c[2]);
|
||||
#define PIXEL10_50 Interp5(pOut+dstPitch, c[4], c[5]);
|
||||
#define PIXEL10_60 Interp6(pOut+dstPitch, c[5], c[4], c[2]);
|
||||
#define PIXEL10_61 Interp6(pOut+dstPitch, c[5], c[4], c[1]);
|
||||
#define PIXEL10_81 Interp8(pOut+dstPitch, c[5], c[4]);
|
||||
#define PIXEL10_83 Interp8(pOut+dstPitch, c[4], c[2]);
|
||||
|
||||
#define PIXEL11_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL11_30 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[1]);
|
||||
#define PIXEL11_31 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL11_32 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL11_70 Interp7(pOut+dstPitch+SIZE_PIXEL, c[5], c[4], c[2]);
|
||||
|
||||
#define PIXEL12_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL12_30 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL12_31 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL12_32 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL12_70 Interp7(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[2]);
|
||||
|
||||
#define PIXEL13_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL13_10 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL13_12 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL13_14 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL13_21 Interp2(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5], c[2]);
|
||||
#define PIXEL13_31 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL13_50 Interp5(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL13_60 Interp6(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[2]);
|
||||
#define PIXEL13_61 Interp6(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[3]);
|
||||
#define PIXEL13_82 Interp8(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL13_83 Interp8(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[2]);
|
||||
|
||||
#define PIXEL20_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch)) = c[5];
|
||||
#define PIXEL20_10 Interp1(pOut+dstPitch+dstPitch, c[5], c[7]);
|
||||
#define PIXEL20_12 Interp1(pOut+dstPitch+dstPitch, c[5], c[4]);
|
||||
#define PIXEL20_14 Interp1(pOut+dstPitch+dstPitch, c[4], c[5]);
|
||||
#define PIXEL20_21 Interp2(pOut+dstPitch+dstPitch, c[4], c[5], c[8]);
|
||||
#define PIXEL20_31 Interp3(pOut+dstPitch+dstPitch, c[5], c[8]);
|
||||
#define PIXEL20_50 Interp5(pOut+dstPitch+dstPitch, c[4], c[5]);
|
||||
#define PIXEL20_60 Interp6(pOut+dstPitch+dstPitch, c[5], c[4], c[8]);
|
||||
#define PIXEL20_61 Interp6(pOut+dstPitch+dstPitch, c[5], c[4], c[7]);
|
||||
#define PIXEL20_82 Interp8(pOut+dstPitch+dstPitch, c[5], c[4]);
|
||||
#define PIXEL20_83 Interp8(pOut+dstPitch+dstPitch, c[4], c[8]);
|
||||
|
||||
#define PIXEL21_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL21_30 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[7]);
|
||||
#define PIXEL21_31 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL21_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL21_70 Interp7(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4], c[8]);
|
||||
#define PIXEL22_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL22_30 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL22_31 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL22_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL22_70 Interp7(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8]);
|
||||
|
||||
#define PIXEL23_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL23_10 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL23_11 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL23_13 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL23_21 Interp2(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5], c[8]);
|
||||
#define PIXEL23_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL23_50 Interp5(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL23_60 Interp6(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8]);
|
||||
#define PIXEL23_61 Interp6(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[9]);
|
||||
#define PIXEL23_81 Interp8(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL23_83 Interp8(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8]);
|
||||
|
||||
#define PIXEL30_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch)) = c[5];
|
||||
#define PIXEL30_11 Interp1(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8]);
|
||||
#define PIXEL30_12 Interp1(pOut+dstPitch+dstPitch+dstPitch, c[5], c[4]);
|
||||
#define PIXEL30_20 Interp2(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8], c[4]);
|
||||
#define PIXEL30_50 Interp5(pOut+dstPitch+dstPitch+dstPitch, c[8], c[4]);
|
||||
#define PIXEL30_80 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[7]);
|
||||
#define PIXEL30_81 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8]);
|
||||
#define PIXEL30_82 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[4]);
|
||||
|
||||
#define PIXEL31_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL31_10 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[7]);
|
||||
#define PIXEL31_11 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL31_13 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL31_21 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5], c[4]);
|
||||
#define PIXEL31_32 Interp3(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL31_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL31_60 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8], c[4]);
|
||||
#define PIXEL31_61 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8], c[7]);
|
||||
#define PIXEL31_81 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL31_83 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[4]);
|
||||
|
||||
#define PIXEL32_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL32_10 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL32_12 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL32_14 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL32_21 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5], c[6]);
|
||||
#define PIXEL32_31 Interp3(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL32_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL32_60 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[6]);
|
||||
#define PIXEL32_61 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[9]);
|
||||
#define PIXEL32_82 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL32_83 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[6]);
|
||||
|
||||
#define PIXEL33_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL33_11 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL33_12 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL33_20 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[6]);
|
||||
#define PIXEL33_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[8], c[6]);
|
||||
#define PIXEL33_80 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL33_81 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL33_82 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
|
||||
#endif // #ifdef _HQ4X
|
||||
|
||||
|
||||
|
||||
// function header
|
||||
#ifdef _16BIT
|
||||
#ifdef _HQ3X
|
||||
void hq3x16(
|
||||
#endif
|
||||
#ifdef _HQ4X
|
||||
void hq4x16(
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _32BIT
|
||||
#ifdef _HQ3X
|
||||
void hq3x32(
|
||||
#endif
|
||||
#ifdef _HQ4X
|
||||
void hq4x32(
|
||||
#endif
|
||||
#endif
|
||||
|
||||
unsigned char *pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char *pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres )
|
||||
{
|
||||
unsigned int yuv[10]; // yuv[0] not used
|
||||
// yuv[1-9] allows reusage of calculated YUV values
|
||||
int x, y;
|
||||
unsigned int linePlus, lineMinus;
|
||||
|
||||
COLORTYPE c[10]; // c[0] not used
|
||||
// +----+----+----+
|
||||
// | | | |
|
||||
// | c1 | c2 | c3 |
|
||||
// +----+----+----+
|
||||
// | | | |
|
||||
// | c4 | c5 | c6 |
|
||||
// +----+----+----+
|
||||
// | | | |
|
||||
// | c7 | c8 | c9 |
|
||||
// +----+----+----+
|
||||
|
||||
for (y=0; y<Yres; y++)
|
||||
{
|
||||
if( y == 0 ) {
|
||||
linePlus = srcPitch;
|
||||
lineMinus = 0;
|
||||
} else if( y == ( Yres - 1 ) ) {
|
||||
linePlus = 0;
|
||||
lineMinus = srcPitch;
|
||||
} else {
|
||||
linePlus = srcPitch;
|
||||
lineMinus = srcPitch;
|
||||
}
|
||||
|
||||
for (x=0; x<Xres; x++)
|
||||
{
|
||||
c[2] = *((COLORTYPE*)(pIn - lineMinus));
|
||||
c[5] = *((COLORTYPE*)(pIn ));
|
||||
c[8] = *((COLORTYPE*)(pIn + linePlus ));
|
||||
|
||||
if (x>0)
|
||||
{
|
||||
// upper border possible:
|
||||
c[1] = *((COLORTYPE*)(pIn - lineMinus - SIZE_PIXEL));
|
||||
|
||||
c[4] = *((COLORTYPE*)(pIn - SIZE_PIXEL));
|
||||
|
||||
// lower border possible:
|
||||
c[7] = *((COLORTYPE*)(pIn + linePlus - SIZE_PIXEL));
|
||||
}
|
||||
else
|
||||
{ // left border
|
||||
c[1] = c[2];
|
||||
c[4] = c[5];
|
||||
c[7] = c[8];
|
||||
}
|
||||
|
||||
if (x<Xres-1)
|
||||
{
|
||||
// upper border possible:
|
||||
c[3] = *((COLORTYPE*)(pIn - lineMinus + SIZE_PIXEL));
|
||||
|
||||
c[6] = *((COLORTYPE*)(pIn + SIZE_PIXEL));
|
||||
|
||||
// lower border possible:
|
||||
c[9] = *((COLORTYPE*)(pIn + linePlus + SIZE_PIXEL));
|
||||
}
|
||||
else
|
||||
{ // right border
|
||||
c[3] = c[2];
|
||||
c[6] = c[5];
|
||||
c[9] = c[8];
|
||||
}
|
||||
|
||||
unsigned int pattern = 0;
|
||||
unsigned int flag = 1;
|
||||
|
||||
yuv[5] = RGBtoYUV( c[5] );
|
||||
|
||||
for( unsigned char k = 1; k <= 9; k++)
|
||||
{
|
||||
if( k == 5 ) continue;
|
||||
|
||||
if( c[k] != c[5] )
|
||||
{
|
||||
// pre-calculating the YUV-values for every pixel does
|
||||
// not speed up the process
|
||||
yuv[k] = RGBtoYUV( c[k] );
|
||||
|
||||
if( ( abs_32((yuv[5] & 0x00FF0000) - (yuv[k] & 0x00FF0000)) > 0x00300000 ) ||
|
||||
( abs_32((yuv[5] & 0x0000FF00) - (yuv[k] & 0x0000FF00)) > 0x00000700 ) ||
|
||||
( abs_32((yuv[5] & 0x000000FF) - (yuv[k] & 0x000000FF)) > 0x00000006 )
|
||||
) {
|
||||
pattern |= flag;
|
||||
}
|
||||
}
|
||||
flag <<= 1;
|
||||
}
|
||||
|
||||
#ifdef _HQ3X
|
||||
#include "hq3x_pattern.h"
|
||||
#endif
|
||||
|
||||
#ifdef _HQ4X
|
||||
#include "hq4x_pattern.h"
|
||||
#endif
|
||||
|
||||
pIn += SIZE_PIXEL;
|
||||
pOut += _MAGNIFICATION * SIZE_PIXEL;
|
||||
}
|
||||
pIn += srcPitch - ( Xres * SIZE_PIXEL );
|
||||
pOut += dstPitch - ( _MAGNIFICATION * Xres * SIZE_PIXEL );
|
||||
pOut += ( _MAGNIFICATION - 1 ) * dstPitch;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _32BIT
|
||||
#ifdef _HQ3X
|
||||
void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
hq3x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
#endif
|
||||
#ifdef _HQ4X
|
||||
void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
hq4x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef SIZE_PIXEL
|
||||
#undef COLORTYPE
|
||||
#undef _MAGNIFICATION
|
||||
#undef RGBtoYUV
|
||||
#undef Interp1
|
||||
#undef Interp2
|
||||
#undef Interp3
|
||||
#undef Interp4
|
||||
#undef Interp5
|
||||
#undef Interp6
|
||||
#undef Interp7
|
||||
#undef Interp8
|
||||
/*
|
||||
VisualBoyAdvance - a Game Boy & Game Boy Advance emulator
|
||||
|
||||
Copyright (C) 2008 VBA-M development team
|
||||
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
hq filter by Maxim Stepin ( http://hiend3d.com )
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _16BIT
|
||||
#ifdef _32BIT
|
||||
#error _16BIT and _32BIT defined at the same time!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _16BIT
|
||||
#define SIZE_PIXEL 2 // 16bit = 2 bytes
|
||||
#define COLORTYPE unsigned short
|
||||
#define RGBtoYUV RGBtoYUV_16
|
||||
#define Interp1 Interp1_16
|
||||
#define Interp2 Interp2_16
|
||||
#define Interp3 Interp3_16
|
||||
#define Interp4 Interp4_16
|
||||
#define Interp5 Interp5_16
|
||||
#define Interp6 Interp6_16
|
||||
#define Interp7 Interp7_16
|
||||
#define Interp8 Interp8_16
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _32BIT
|
||||
#define SIZE_PIXEL 4 // 32bit = 4 bytes
|
||||
#define COLORTYPE unsigned int
|
||||
#define RGBtoYUV RGBtoYUV_32
|
||||
#define Interp1 Interp1_32
|
||||
#define Interp2 Interp2_32
|
||||
#define Interp3 Interp3_32
|
||||
#define Interp4 Interp4_32
|
||||
#define Interp5 Interp5_32
|
||||
#define Interp6 Interp6_32
|
||||
#define Interp7 Interp7_32
|
||||
#define Interp8 Interp8_32
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _HQ3X
|
||||
|
||||
#define _MAGNIFICATION 3
|
||||
|
||||
#define PIXEL00_1M Interp1( pOut, c[5], c[1] );
|
||||
#define PIXEL00_1U Interp1( pOut, c[5], c[2] );
|
||||
#define PIXEL00_1L Interp1( pOut, c[5], c[4] );
|
||||
#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_4 Interp4( pOut, c[5], c[4], c[2] );
|
||||
#define PIXEL00_5 Interp5( pOut, c[4], c[2] );
|
||||
#define PIXEL00_C *((COLORTYPE*)(pOut)) = c[5];
|
||||
|
||||
#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_3 Interp3( pOut+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL01_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] );
|
||||
#define PIXEL01_C *((COLORTYPE*)(pOut+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL02_1M Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3] );
|
||||
#define PIXEL02_1U Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2] );
|
||||
#define PIXEL02_1R Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL02_2 Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_4 Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] );
|
||||
#define PIXEL02_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] );
|
||||
#define PIXEL02_C *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_3 Interp3( pOut+dstPitch, c[5], c[4] );
|
||||
#define PIXEL10_6 Interp1( pOut+dstPitch, c[4], c[5] );
|
||||
#define PIXEL10_C *((COLORTYPE*)(pOut+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL11 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL12_1 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_3 Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL12_6 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] );
|
||||
#define PIXEL12_C *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL20_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] );
|
||||
#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] );
|
||||
#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] );
|
||||
#define PIXEL20_2 Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] );
|
||||
#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, c[8], c[4] );
|
||||
#define PIXEL20_C *((COLORTYPE*)(pOut+dstPitch+dstPitch)) = c[5];
|
||||
|
||||
#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_3 Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL21_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] );
|
||||
#define PIXEL21_C *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#define PIXEL22_1M Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9] );
|
||||
#define PIXEL22_1D Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8] );
|
||||
#define PIXEL22_1R Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] );
|
||||
#define PIXEL22_2 Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_4 Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] );
|
||||
#define PIXEL22_5 Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8] );
|
||||
#define PIXEL22_C *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
|
||||
#endif // #ifdef _HQ3X
|
||||
|
||||
|
||||
|
||||
#ifdef _HQ4X
|
||||
|
||||
#define _MAGNIFICATION 4
|
||||
|
||||
#define PIXEL00_0 *((COLORTYPE*)(pOut)) = c[5];
|
||||
#define PIXEL00_11 Interp1(pOut, c[5], c[4]);
|
||||
#define PIXEL00_12 Interp1(pOut, c[5], c[2]);
|
||||
#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]);
|
||||
#define PIXEL00_50 Interp5(pOut, c[2], c[4]);
|
||||
#define PIXEL00_80 Interp8(pOut, c[5], c[1]);
|
||||
#define PIXEL00_81 Interp8(pOut, c[5], c[4]);
|
||||
#define PIXEL00_82 Interp8(pOut, c[5], c[2]);
|
||||
|
||||
#define PIXEL01_0 *((COLORTYPE*)(pOut+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL01_10 Interp1(pOut+SIZE_PIXEL, c[5], c[1]);
|
||||
#define PIXEL01_12 Interp1(pOut+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL01_14 Interp1(pOut+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL01_21 Interp2(pOut+SIZE_PIXEL, c[2], c[5], c[4]);
|
||||
#define PIXEL01_31 Interp3(pOut+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL01_50 Interp5(pOut+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL01_60 Interp6(pOut+SIZE_PIXEL, c[5], c[2], c[4]);
|
||||
#define PIXEL01_61 Interp6(pOut+SIZE_PIXEL, c[5], c[2], c[1]);
|
||||
#define PIXEL01_82 Interp8(pOut+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL01_83 Interp8(pOut+SIZE_PIXEL, c[2], c[4]);
|
||||
|
||||
#define PIXEL02_0 *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL02_10 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL02_11 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL02_13 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL02_21 Interp2(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5], c[6]);
|
||||
#define PIXEL02_32 Interp3(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL02_50 Interp5(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5]);
|
||||
#define PIXEL02_60 Interp6(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6]);
|
||||
#define PIXEL02_61 Interp6(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[3]);
|
||||
#define PIXEL02_81 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL02_83 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]);
|
||||
|
||||
#define PIXEL03_0 *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL03_11 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL03_12 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL03_20 Interp2(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6]);
|
||||
#define PIXEL03_50 Interp5(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]);
|
||||
#define PIXEL03_80 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL03_81 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL03_82 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
|
||||
#define PIXEL10_0 *((COLORTYPE*)(pOut+dstPitch)) = c[5];
|
||||
#define PIXEL10_10 Interp1(pOut+dstPitch, c[5], c[1]);
|
||||
#define PIXEL10_11 Interp1(pOut+dstPitch, c[5], c[4]);
|
||||
#define PIXEL10_13 Interp1(pOut+dstPitch, c[4], c[5]);
|
||||
#define PIXEL10_21 Interp2(pOut+dstPitch, c[4], c[5], c[2]);
|
||||
#define PIXEL10_32 Interp3(pOut+dstPitch, c[5], c[2]);
|
||||
#define PIXEL10_50 Interp5(pOut+dstPitch, c[4], c[5]);
|
||||
#define PIXEL10_60 Interp6(pOut+dstPitch, c[5], c[4], c[2]);
|
||||
#define PIXEL10_61 Interp6(pOut+dstPitch, c[5], c[4], c[1]);
|
||||
#define PIXEL10_81 Interp8(pOut+dstPitch, c[5], c[4]);
|
||||
#define PIXEL10_83 Interp8(pOut+dstPitch, c[4], c[2]);
|
||||
|
||||
#define PIXEL11_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL11_30 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[1]);
|
||||
#define PIXEL11_31 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL11_32 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL11_70 Interp7(pOut+dstPitch+SIZE_PIXEL, c[5], c[4], c[2]);
|
||||
|
||||
#define PIXEL12_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL12_30 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL12_31 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL12_32 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL12_70 Interp7(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[2]);
|
||||
|
||||
#define PIXEL13_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL13_10 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]);
|
||||
#define PIXEL13_12 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL13_14 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL13_21 Interp2(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5], c[2]);
|
||||
#define PIXEL13_31 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]);
|
||||
#define PIXEL13_50 Interp5(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL13_60 Interp6(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[2]);
|
||||
#define PIXEL13_61 Interp6(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[3]);
|
||||
#define PIXEL13_82 Interp8(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL13_83 Interp8(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[2]);
|
||||
|
||||
#define PIXEL20_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch)) = c[5];
|
||||
#define PIXEL20_10 Interp1(pOut+dstPitch+dstPitch, c[5], c[7]);
|
||||
#define PIXEL20_12 Interp1(pOut+dstPitch+dstPitch, c[5], c[4]);
|
||||
#define PIXEL20_14 Interp1(pOut+dstPitch+dstPitch, c[4], c[5]);
|
||||
#define PIXEL20_21 Interp2(pOut+dstPitch+dstPitch, c[4], c[5], c[8]);
|
||||
#define PIXEL20_31 Interp3(pOut+dstPitch+dstPitch, c[5], c[8]);
|
||||
#define PIXEL20_50 Interp5(pOut+dstPitch+dstPitch, c[4], c[5]);
|
||||
#define PIXEL20_60 Interp6(pOut+dstPitch+dstPitch, c[5], c[4], c[8]);
|
||||
#define PIXEL20_61 Interp6(pOut+dstPitch+dstPitch, c[5], c[4], c[7]);
|
||||
#define PIXEL20_82 Interp8(pOut+dstPitch+dstPitch, c[5], c[4]);
|
||||
#define PIXEL20_83 Interp8(pOut+dstPitch+dstPitch, c[4], c[8]);
|
||||
|
||||
#define PIXEL21_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL21_30 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[7]);
|
||||
#define PIXEL21_31 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL21_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL21_70 Interp7(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4], c[8]);
|
||||
#define PIXEL22_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL22_30 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL22_31 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL22_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL22_70 Interp7(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8]);
|
||||
|
||||
#define PIXEL23_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL23_10 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL23_11 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL23_13 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL23_21 Interp2(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5], c[8]);
|
||||
#define PIXEL23_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL23_50 Interp5(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]);
|
||||
#define PIXEL23_60 Interp6(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8]);
|
||||
#define PIXEL23_61 Interp6(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[9]);
|
||||
#define PIXEL23_81 Interp8(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL23_83 Interp8(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8]);
|
||||
|
||||
#define PIXEL30_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch)) = c[5];
|
||||
#define PIXEL30_11 Interp1(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8]);
|
||||
#define PIXEL30_12 Interp1(pOut+dstPitch+dstPitch+dstPitch, c[5], c[4]);
|
||||
#define PIXEL30_20 Interp2(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8], c[4]);
|
||||
#define PIXEL30_50 Interp5(pOut+dstPitch+dstPitch+dstPitch, c[8], c[4]);
|
||||
#define PIXEL30_80 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[7]);
|
||||
#define PIXEL30_81 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8]);
|
||||
#define PIXEL30_82 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[4]);
|
||||
|
||||
#define PIXEL31_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL31_10 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[7]);
|
||||
#define PIXEL31_11 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL31_13 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL31_21 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5], c[4]);
|
||||
#define PIXEL31_32 Interp3(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4]);
|
||||
#define PIXEL31_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL31_60 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8], c[4]);
|
||||
#define PIXEL31_61 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8], c[7]);
|
||||
#define PIXEL31_81 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL31_83 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[4]);
|
||||
|
||||
#define PIXEL32_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL32_10 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL32_12 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL32_14 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL32_21 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5], c[6]);
|
||||
#define PIXEL32_31 Interp3(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL32_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5]);
|
||||
#define PIXEL32_60 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[6]);
|
||||
#define PIXEL32_61 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[9]);
|
||||
#define PIXEL32_82 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL32_83 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[6]);
|
||||
|
||||
#define PIXEL33_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5];
|
||||
#define PIXEL33_11 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL33_12 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
#define PIXEL33_20 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[6]);
|
||||
#define PIXEL33_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[8], c[6]);
|
||||
#define PIXEL33_80 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]);
|
||||
#define PIXEL33_81 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]);
|
||||
#define PIXEL33_82 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]);
|
||||
|
||||
#endif // #ifdef _HQ4X
|
||||
|
||||
|
||||
|
||||
// function header
|
||||
#ifdef _16BIT
|
||||
#ifdef _HQ3X
|
||||
void hq3x16(
|
||||
#endif
|
||||
#ifdef _HQ4X
|
||||
void hq4x16(
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _32BIT
|
||||
#ifdef _HQ3X
|
||||
void hq3x32(
|
||||
#endif
|
||||
#ifdef _HQ4X
|
||||
void hq4x32(
|
||||
#endif
|
||||
#endif
|
||||
|
||||
unsigned char *pIn, unsigned int srcPitch,
|
||||
unsigned char *,
|
||||
unsigned char *pOut, unsigned int dstPitch,
|
||||
int Xres, int Yres )
|
||||
{
|
||||
unsigned int yuv[10]; // yuv[0] not used
|
||||
// yuv[1-9] allows reusage of calculated YUV values
|
||||
int x, y;
|
||||
unsigned int linePlus, lineMinus;
|
||||
|
||||
COLORTYPE c[10]; // c[0] not used
|
||||
// +----+----+----+
|
||||
// | | | |
|
||||
// | c1 | c2 | c3 |
|
||||
// +----+----+----+
|
||||
// | | | |
|
||||
// | c4 | c5 | c6 |
|
||||
// +----+----+----+
|
||||
// | | | |
|
||||
// | c7 | c8 | c9 |
|
||||
// +----+----+----+
|
||||
|
||||
for (y=0; y<Yres; y++)
|
||||
{
|
||||
if( y == 0 ) {
|
||||
linePlus = srcPitch;
|
||||
lineMinus = 0;
|
||||
} else if( y == ( Yres - 1 ) ) {
|
||||
linePlus = 0;
|
||||
lineMinus = srcPitch;
|
||||
} else {
|
||||
linePlus = srcPitch;
|
||||
lineMinus = srcPitch;
|
||||
}
|
||||
|
||||
for (x=0; x<Xres; x++)
|
||||
{
|
||||
c[2] = *((COLORTYPE*)(pIn - lineMinus));
|
||||
c[5] = *((COLORTYPE*)(pIn ));
|
||||
c[8] = *((COLORTYPE*)(pIn + linePlus ));
|
||||
|
||||
if (x>0)
|
||||
{
|
||||
// upper border possible:
|
||||
c[1] = *((COLORTYPE*)(pIn - lineMinus - SIZE_PIXEL));
|
||||
|
||||
c[4] = *((COLORTYPE*)(pIn - SIZE_PIXEL));
|
||||
|
||||
// lower border possible:
|
||||
c[7] = *((COLORTYPE*)(pIn + linePlus - SIZE_PIXEL));
|
||||
}
|
||||
else
|
||||
{ // left border
|
||||
c[1] = c[2];
|
||||
c[4] = c[5];
|
||||
c[7] = c[8];
|
||||
}
|
||||
|
||||
if (x<Xres-1)
|
||||
{
|
||||
// upper border possible:
|
||||
c[3] = *((COLORTYPE*)(pIn - lineMinus + SIZE_PIXEL));
|
||||
|
||||
c[6] = *((COLORTYPE*)(pIn + SIZE_PIXEL));
|
||||
|
||||
// lower border possible:
|
||||
c[9] = *((COLORTYPE*)(pIn + linePlus + SIZE_PIXEL));
|
||||
}
|
||||
else
|
||||
{ // right border
|
||||
c[3] = c[2];
|
||||
c[6] = c[5];
|
||||
c[9] = c[8];
|
||||
}
|
||||
|
||||
unsigned int pattern = 0;
|
||||
unsigned int flag = 1;
|
||||
|
||||
yuv[5] = RGBtoYUV( c[5] );
|
||||
|
||||
for( unsigned char k = 1; k <= 9; k++)
|
||||
{
|
||||
if( k == 5 ) continue;
|
||||
|
||||
if( c[k] != c[5] )
|
||||
{
|
||||
// pre-calculating the YUV-values for every pixel does
|
||||
// not speed up the process
|
||||
yuv[k] = RGBtoYUV( c[k] );
|
||||
|
||||
if( ( abs_32((yuv[5] & 0x00FF0000) - (yuv[k] & 0x00FF0000)) > 0x00300000 ) ||
|
||||
( abs_32((yuv[5] & 0x0000FF00) - (yuv[k] & 0x0000FF00)) > 0x00000700 ) ||
|
||||
( abs_32((yuv[5] & 0x000000FF) - (yuv[k] & 0x000000FF)) > 0x00000006 )
|
||||
) {
|
||||
pattern |= flag;
|
||||
}
|
||||
}
|
||||
flag <<= 1;
|
||||
}
|
||||
|
||||
#ifdef _HQ3X
|
||||
#include "hq3x_pattern.h"
|
||||
#endif
|
||||
|
||||
#ifdef _HQ4X
|
||||
#include "hq4x_pattern.h"
|
||||
#endif
|
||||
|
||||
pIn += SIZE_PIXEL;
|
||||
pOut += _MAGNIFICATION * SIZE_PIXEL;
|
||||
}
|
||||
pIn += srcPitch - ( Xres * SIZE_PIXEL );
|
||||
pOut += dstPitch - ( _MAGNIFICATION * Xres * SIZE_PIXEL );
|
||||
pOut += ( _MAGNIFICATION - 1 ) * dstPitch;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _32BIT
|
||||
#ifdef _HQ3X
|
||||
void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
hq3x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
#endif
|
||||
#ifdef _HQ4X
|
||||
void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres)
|
||||
{
|
||||
hq4x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef SIZE_PIXEL
|
||||
#undef COLORTYPE
|
||||
#undef _MAGNIFICATION
|
||||
#undef RGBtoYUV
|
||||
#undef Interp1
|
||||
#undef Interp2
|
||||
#undef Interp3
|
||||
#undef Interp4
|
||||
#undef Interp5
|
||||
#undef Interp6
|
||||
#undef Interp7
|
||||
#undef Interp8
|
||||
|
|
|
@ -1,64 +1,64 @@
|
|||
/*
|
||||
VisualBoyAdvance - a Game Boy & Game Boy Advance emulator
|
||||
|
||||
Copyright (C) 2008 VBA-M development team
|
||||
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
hq filter by Maxim Stepin ( http://hiend3d.com )
|
||||
*/
|
||||
|
||||
|
||||
#include "hq_shared.h"
|
||||
|
||||
|
||||
#define _16BIT
|
||||
#define _HQ3X
|
||||
// hq3x, 16bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ3X
|
||||
|
||||
#define _HQ4X
|
||||
// hq4x, 16bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ4X
|
||||
#undef _16BIT
|
||||
|
||||
|
||||
#define _32BIT
|
||||
#define _HQ3X
|
||||
// hq3x, 32bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ3X
|
||||
|
||||
#define _HQ4X
|
||||
// hq4x, 32bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ4X
|
||||
#undef _32BIT
|
||||
|
||||
|
||||
|
||||
#undef GMASK
|
||||
#undef RBMASK
|
||||
#undef GSHIFT1MASK
|
||||
#undef RBSHIFT1MASK
|
||||
#undef GSHIFT2MASK
|
||||
#undef RBSHIFT2MASK
|
||||
#undef GSHIFT3MASK
|
||||
#undef RBSHIFT3MASK
|
||||
#undef GSHIFT4MASK
|
||||
#undef RBSHIFT4MASK
|
||||
/*
|
||||
VisualBoyAdvance - a Game Boy & Game Boy Advance emulator
|
||||
|
||||
Copyright (C) 2008 VBA-M development team
|
||||
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
hq filter by Maxim Stepin ( http://hiend3d.com )
|
||||
*/
|
||||
|
||||
|
||||
#include "hq_shared.h"
|
||||
|
||||
|
||||
#define _16BIT
|
||||
#define _HQ3X
|
||||
// hq3x, 16bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ3X
|
||||
|
||||
#define _HQ4X
|
||||
// hq4x, 16bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ4X
|
||||
#undef _16BIT
|
||||
|
||||
|
||||
#define _32BIT
|
||||
#define _HQ3X
|
||||
// hq3x, 32bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ3X
|
||||
|
||||
#define _HQ4X
|
||||
// hq4x, 32bit
|
||||
#include "hq_base.h"
|
||||
#undef _HQ4X
|
||||
#undef _32BIT
|
||||
|
||||
|
||||
|
||||
#undef GMASK
|
||||
#undef RBMASK
|
||||
#undef GSHIFT1MASK
|
||||
#undef RBSHIFT1MASK
|
||||
#undef GSHIFT2MASK
|
||||
#undef RBSHIFT2MASK
|
||||
#undef GSHIFT3MASK
|
||||
#undef RBSHIFT3MASK
|
||||
#undef GSHIFT4MASK
|
||||
#undef RBSHIFT4MASK
|
||||
|
|
|
@ -1,445 +1,445 @@
|
|||
/*
|
||||
VisualBoyAdvance - a Game Boy & Game Boy Advance emulator
|
||||
|
||||
Copyright (C) 2008 VBA-M development team
|
||||
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
hq filter by Maxim Stepin ( http://hiend3d.com )
|
||||
*/
|
||||
|
||||
#ifdef RGB555
|
||||
// 5 bits for green
|
||||
#define GMASK 0x03E0
|
||||
#define RBMASK 0x7C1F
|
||||
// MASK << 1
|
||||
#define GSHIFT1MASK 0x000007C0
|
||||
#define RBSHIFT1MASK 0x0000F83E
|
||||
// MASK << 2
|
||||
#define GSHIFT2MASK 0x00000F80
|
||||
#define RBSHIFT2MASK 0x0001F07C
|
||||
// MASK << 3
|
||||
#define GSHIFT3MASK 0x00001F00
|
||||
#define RBSHIFT3MASK 0x0003E0F8
|
||||
// MASK << 4
|
||||
#define GSHIFT4MASK 0x00003E00
|
||||
#define RBSHIFT4MASK 0x0007C1F0
|
||||
#else
|
||||
// RGB565
|
||||
// 6 bits for green
|
||||
#define GMASK 0x07E0
|
||||
#define RBMASK 0xF81F
|
||||
#define GSHIFT1MASK 0x00000FC0
|
||||
#define RBSHIFT1MASK 0x0001F03E
|
||||
#define GSHIFT2MASK 0x00001F80
|
||||
#define RBSHIFT2MASK 0x0003E07C
|
||||
#define GSHIFT3MASK 0x00003F00
|
||||
#define RBSHIFT3MASK 0x0007C0F8
|
||||
#define GSHIFT4MASK 0x00007E00
|
||||
#define RBSHIFT4MASK 0x000F81F0
|
||||
#endif
|
||||
|
||||
|
||||
// we only need the 32bit version because our YUV format has 32bits
|
||||
#define abs_32( value ) ( value & 0x7FFFFFFF )
|
||||
|
||||
|
||||
inline bool Diff( unsigned int YUV1, unsigned int YUV2 )
|
||||
{
|
||||
if( YUV1 == YUV2 ) return false; // Save some processing power
|
||||
|
||||
return
|
||||
( abs_32((YUV1 & 0x00FF0000) - (YUV2 & 0x00FF0000)) > 0x00300000 ) ||
|
||||
( abs_32((YUV1 & 0x0000FF00) - (YUV2 & 0x0000FF00)) > 0x00000700 ) ||
|
||||
( abs_32((YUV1 & 0x000000FF) - (YUV2 & 0x000000FF)) > 0x00000006 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===============
|
||||
// 32bit routines:
|
||||
// ===============
|
||||
|
||||
// ( c1*3 + c2 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp1_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 3 ) + \
|
||||
( (c2) & 0x00FF00 ) \
|
||||
) & 0x0003FC00 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 3 ) + \
|
||||
( (c2) & 0xFF00FF ) \
|
||||
) & 0x03FC03FC ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + c2 + c3 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp2_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 2 ) + \
|
||||
( (c2) & 0x00FF00 ) + \
|
||||
( (c3) & 0x00FF00 ) \
|
||||
) & 0x0003FC00 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 2 ) + \
|
||||
( (c2) & 0xFF00FF ) + \
|
||||
( (c3) & 0xFF00FF ) \
|
||||
) & 0x03FC03FC ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*7 + c2 ) / 8
|
||||
// hq3x, hq4x
|
||||
#define Interp3_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 7 ) + \
|
||||
( (c2) & 0x00FF00 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 7 ) + \
|
||||
( (c2) & 0xFF00FF ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + (c2+c3)*7 ) / 16
|
||||
// hq3x, not used by hq4x
|
||||
#define Interp4_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( ( ( (c1) & 0x00FF00 ) * 2 ) + ( ( ( (c2) & 0x00FF00 ) + ( (c3) & 0x00FF00 ) ) * 7 ) ) & 0x000FF000 ) + \
|
||||
( ( ( ( (c1) & 0xFF00FF ) * 2 ) + ( ( ( (c2) & 0xFF00FF ) + ( (c3) & 0xFF00FF ) ) * 7 ) ) & 0x0FF00FF0 ) \
|
||||
) >> 4 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1 + c2 ) / 2
|
||||
// hq3x, hq4x
|
||||
#define Interp5_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( (c1) & 0x00FF00 ) + \
|
||||
( (c2) & 0x00FF00 ) \
|
||||
) & 0x0001FE00 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( (c1) & 0xFF00FF ) + \
|
||||
( (c2) & 0xFF00FF ) \
|
||||
) & 0x01FE01FE ) \
|
||||
) >> 1 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp6_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 5 ) + \
|
||||
( ( (c2) & 0x00FF00 ) * 2 ) + \
|
||||
( (c3) & 0x00FF00 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 5 ) + \
|
||||
( ( (c2) & 0xFF00FF ) * 2 ) + \
|
||||
( (c3) & 0xFF00FF ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*6 + c2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp7_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 6 ) + \
|
||||
( (c2) & 0x00FF00 ) + \
|
||||
( (c3) & 0x00FF00 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 6 ) + \
|
||||
( (c2) & 0xFF00FF ) + \
|
||||
( (c3) & 0xFF00FF ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*3 ) / 8
|
||||
// hq4x
|
||||
#define Interp8_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 5 ) + \
|
||||
( ( (c2) & 0x00FF00 ) * 3 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 5 ) + \
|
||||
( ( (c2) & 0xFF00FF ) * 3 ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// 32 bit input color
|
||||
// 0x00YYUUVV return value
|
||||
inline unsigned int RGBtoYUV_32( unsigned int c )
|
||||
{
|
||||
// Division through 3 slows down the emulation about 10% !!!
|
||||
|
||||
register unsigned char r, g, b;
|
||||
b = c & 0x0000FF;
|
||||
g = ( c & 0x00FF00 ) >> 8;
|
||||
r = c >> 16;
|
||||
return ( (r + g + b) << 14 ) +
|
||||
( ( r - b + 512 ) << 4 ) +
|
||||
( ( 2*g - r - b ) >> 3 ) + 128;
|
||||
|
||||
// unoptimized:
|
||||
//unsigned char r, g, b, Y, u, v;
|
||||
//b = (c & 0x000000FF);
|
||||
//g = (c & 0x0000FF00) >> 8;
|
||||
//r = (c & 0x00FF0000) >> 16;
|
||||
//Y = (r + g + b) >> 2;
|
||||
//u = 128 + ((r - b) >> 2);
|
||||
//v = 128 + ((-r + 2*g -b)>>3);
|
||||
//return (Y<<16) + (u<<8) + v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===============
|
||||
// 16bit routines:
|
||||
// ===============
|
||||
|
||||
// ( c1*3 + c2 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp1_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 3 ) + \
|
||||
( (c2) & GMASK ) \
|
||||
) & GSHIFT2MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 3 ) + \
|
||||
( (c2) & RBMASK ) \
|
||||
) & RBSHIFT2MASK ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + c2 + c3 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp2_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 2 ) + \
|
||||
( (c2) & GMASK ) + \
|
||||
( (c3) & GMASK ) \
|
||||
) & GSHIFT2MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 2 ) + \
|
||||
( (c2) & RBMASK ) + \
|
||||
( (c3) & RBMASK ) \
|
||||
) & RBSHIFT2MASK ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*7 + c2 ) / 8
|
||||
// hq3x, hq4x
|
||||
#define Interp3_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 7 ) + \
|
||||
( (c2) & GMASK ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 7 ) + \
|
||||
( (c2) & RBMASK ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + (c2+c3)*7 ) / 16
|
||||
// hq3x, not used by hq4x
|
||||
#define Interp4_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( ( ( (c1) & GMASK ) * 2 ) + ( ( ( (c2) & GMASK ) + ( (c3) & GMASK ) ) * 7 ) ) & GSHIFT4MASK ) + \
|
||||
( ( ( ( (c1) & RBMASK ) * 2 ) + ( ( ( (c2) & RBMASK ) + ( (c3) & RBMASK ) ) * 7 ) ) & RBSHIFT4MASK ) \
|
||||
) >> 4 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1 + c2 ) / 2
|
||||
// hq3x, hq4x
|
||||
#define Interp5_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( (c1) & GMASK ) + \
|
||||
( (c2) & GMASK ) \
|
||||
) & GSHIFT1MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( (c1) & RBMASK ) + \
|
||||
( (c2) & RBMASK ) \
|
||||
) & RBSHIFT1MASK ) \
|
||||
) >> 1 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp6_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 5 ) + \
|
||||
( ( (c2) & GMASK ) * 2 ) + \
|
||||
( (c3) & GMASK ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 5 ) + \
|
||||
( ( (c2) & RBMASK ) * 2 ) + \
|
||||
( (c3) & RBMASK ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*6 + c2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp7_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 6 ) + \
|
||||
( (c2) & GMASK ) + \
|
||||
( (c3) & GMASK ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 6 ) + \
|
||||
( (c2) & RBMASK ) + \
|
||||
( (c3) & RBMASK ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*3 ) / 8
|
||||
// hq4x
|
||||
#define Interp8_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 5 ) + \
|
||||
( ( (c2) & GMASK ) * 3 ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 5 ) + \
|
||||
( ( (c2) & RBMASK ) * 3 ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// 16 bit input color
|
||||
// 0x00YYUUVV return value
|
||||
inline unsigned int RGBtoYUV_16( unsigned short c )
|
||||
{
|
||||
// Division through 3 slows down the emulation about 10% !!!
|
||||
|
||||
register unsigned char r, g, b;
|
||||
#ifdef RGB555
|
||||
r = ( c & 0x7C00 ) >> 7;
|
||||
g = ( c & 0x03E0 ) >> 2;
|
||||
b = ( c & 0x001F ) << 3;
|
||||
#else
|
||||
r = ( c & 0xF800 ) >> 8;
|
||||
g = ( c & 0x07E0 ) >> 3;
|
||||
b = ( c & 0x001F ) << 3;
|
||||
#endif
|
||||
|
||||
return ( (r + g + b) << 14 ) +
|
||||
( ( r - b + 512 ) << 4 ) +
|
||||
( ( 2*g - r - b ) >> 3 ) + 128;
|
||||
}
|
||||
/*
|
||||
VisualBoyAdvance - a Game Boy & Game Boy Advance emulator
|
||||
|
||||
Copyright (C) 2008 VBA-M development team
|
||||
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
hq filter by Maxim Stepin ( http://hiend3d.com )
|
||||
*/
|
||||
|
||||
#ifdef RGB555
|
||||
// 5 bits for green
|
||||
#define GMASK 0x03E0
|
||||
#define RBMASK 0x7C1F
|
||||
// MASK << 1
|
||||
#define GSHIFT1MASK 0x000007C0
|
||||
#define RBSHIFT1MASK 0x0000F83E
|
||||
// MASK << 2
|
||||
#define GSHIFT2MASK 0x00000F80
|
||||
#define RBSHIFT2MASK 0x0001F07C
|
||||
// MASK << 3
|
||||
#define GSHIFT3MASK 0x00001F00
|
||||
#define RBSHIFT3MASK 0x0003E0F8
|
||||
// MASK << 4
|
||||
#define GSHIFT4MASK 0x00003E00
|
||||
#define RBSHIFT4MASK 0x0007C1F0
|
||||
#else
|
||||
// RGB565
|
||||
// 6 bits for green
|
||||
#define GMASK 0x07E0
|
||||
#define RBMASK 0xF81F
|
||||
#define GSHIFT1MASK 0x00000FC0
|
||||
#define RBSHIFT1MASK 0x0001F03E
|
||||
#define GSHIFT2MASK 0x00001F80
|
||||
#define RBSHIFT2MASK 0x0003E07C
|
||||
#define GSHIFT3MASK 0x00003F00
|
||||
#define RBSHIFT3MASK 0x0007C0F8
|
||||
#define GSHIFT4MASK 0x00007E00
|
||||
#define RBSHIFT4MASK 0x000F81F0
|
||||
#endif
|
||||
|
||||
|
||||
// we only need the 32bit version because our YUV format has 32bits
|
||||
#define abs_32( value ) ( value & 0x7FFFFFFF )
|
||||
|
||||
|
||||
inline bool Diff( unsigned int YUV1, unsigned int YUV2 )
|
||||
{
|
||||
if( YUV1 == YUV2 ) return false; // Save some processing power
|
||||
|
||||
return
|
||||
( abs_32((YUV1 & 0x00FF0000) - (YUV2 & 0x00FF0000)) > 0x00300000 ) ||
|
||||
( abs_32((YUV1 & 0x0000FF00) - (YUV2 & 0x0000FF00)) > 0x00000700 ) ||
|
||||
( abs_32((YUV1 & 0x000000FF) - (YUV2 & 0x000000FF)) > 0x00000006 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===============
|
||||
// 32bit routines:
|
||||
// ===============
|
||||
|
||||
// ( c1*3 + c2 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp1_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 3 ) + \
|
||||
( (c2) & 0x00FF00 ) \
|
||||
) & 0x0003FC00 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 3 ) + \
|
||||
( (c2) & 0xFF00FF ) \
|
||||
) & 0x03FC03FC ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + c2 + c3 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp2_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 2 ) + \
|
||||
( (c2) & 0x00FF00 ) + \
|
||||
( (c3) & 0x00FF00 ) \
|
||||
) & 0x0003FC00 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 2 ) + \
|
||||
( (c2) & 0xFF00FF ) + \
|
||||
( (c3) & 0xFF00FF ) \
|
||||
) & 0x03FC03FC ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*7 + c2 ) / 8
|
||||
// hq3x, hq4x
|
||||
#define Interp3_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 7 ) + \
|
||||
( (c2) & 0x00FF00 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 7 ) + \
|
||||
( (c2) & 0xFF00FF ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + (c2+c3)*7 ) / 16
|
||||
// hq3x, not used by hq4x
|
||||
#define Interp4_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( ( ( (c1) & 0x00FF00 ) * 2 ) + ( ( ( (c2) & 0x00FF00 ) + ( (c3) & 0x00FF00 ) ) * 7 ) ) & 0x000FF000 ) + \
|
||||
( ( ( ( (c1) & 0xFF00FF ) * 2 ) + ( ( ( (c2) & 0xFF00FF ) + ( (c3) & 0xFF00FF ) ) * 7 ) ) & 0x0FF00FF0 ) \
|
||||
) >> 4 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1 + c2 ) / 2
|
||||
// hq3x, hq4x
|
||||
#define Interp5_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( (c1) & 0x00FF00 ) + \
|
||||
( (c2) & 0x00FF00 ) \
|
||||
) & 0x0001FE00 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( (c1) & 0xFF00FF ) + \
|
||||
( (c2) & 0xFF00FF ) \
|
||||
) & 0x01FE01FE ) \
|
||||
) >> 1 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp6_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 5 ) + \
|
||||
( ( (c2) & 0x00FF00 ) * 2 ) + \
|
||||
( (c3) & 0x00FF00 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 5 ) + \
|
||||
( ( (c2) & 0xFF00FF ) * 2 ) + \
|
||||
( (c3) & 0xFF00FF ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*6 + c2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp7_32( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 6 ) + \
|
||||
( (c2) & 0x00FF00 ) + \
|
||||
( (c3) & 0x00FF00 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 6 ) + \
|
||||
( (c2) & 0xFF00FF ) + \
|
||||
( (c3) & 0xFF00FF ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*3 ) / 8
|
||||
// hq4x
|
||||
#define Interp8_32( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned int *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & 0x00FF00 ) * 5 ) + \
|
||||
( ( (c2) & 0x00FF00 ) * 3 ) \
|
||||
) & 0x0007F800 ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & 0xFF00FF ) * 5 ) + \
|
||||
( ( (c2) & 0xFF00FF ) * 3 ) \
|
||||
) & 0x07F807F8 ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// 32 bit input color
|
||||
// 0x00YYUUVV return value
|
||||
inline unsigned int RGBtoYUV_32( unsigned int c )
|
||||
{
|
||||
// Division through 3 slows down the emulation about 10% !!!
|
||||
|
||||
register unsigned char r, g, b;
|
||||
b = c & 0x0000FF;
|
||||
g = ( c & 0x00FF00 ) >> 8;
|
||||
r = c >> 16;
|
||||
return ( (r + g + b) << 14 ) +
|
||||
( ( r - b + 512 ) << 4 ) +
|
||||
( ( 2*g - r - b ) >> 3 ) + 128;
|
||||
|
||||
// unoptimized:
|
||||
//unsigned char r, g, b, Y, u, v;
|
||||
//b = (c & 0x000000FF);
|
||||
//g = (c & 0x0000FF00) >> 8;
|
||||
//r = (c & 0x00FF0000) >> 16;
|
||||
//Y = (r + g + b) >> 2;
|
||||
//u = 128 + ((r - b) >> 2);
|
||||
//v = 128 + ((-r + 2*g -b)>>3);
|
||||
//return (Y<<16) + (u<<8) + v;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ===============
|
||||
// 16bit routines:
|
||||
// ===============
|
||||
|
||||
// ( c1*3 + c2 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp1_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 3 ) + \
|
||||
( (c2) & GMASK ) \
|
||||
) & GSHIFT2MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 3 ) + \
|
||||
( (c2) & RBMASK ) \
|
||||
) & RBSHIFT2MASK ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + c2 + c3 ) / 4
|
||||
// hq3x, hq4x
|
||||
#define Interp2_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 2 ) + \
|
||||
( (c2) & GMASK ) + \
|
||||
( (c3) & GMASK ) \
|
||||
) & GSHIFT2MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 2 ) + \
|
||||
( (c2) & RBMASK ) + \
|
||||
( (c3) & RBMASK ) \
|
||||
) & RBSHIFT2MASK ) \
|
||||
) >> 2 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*7 + c2 ) / 8
|
||||
// hq3x, hq4x
|
||||
#define Interp3_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 7 ) + \
|
||||
( (c2) & GMASK ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 7 ) + \
|
||||
( (c2) & RBMASK ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*2 + (c2+c3)*7 ) / 16
|
||||
// hq3x, not used by hq4x
|
||||
#define Interp4_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( ( ( (c1) & GMASK ) * 2 ) + ( ( ( (c2) & GMASK ) + ( (c3) & GMASK ) ) * 7 ) ) & GSHIFT4MASK ) + \
|
||||
( ( ( ( (c1) & RBMASK ) * 2 ) + ( ( ( (c2) & RBMASK ) + ( (c3) & RBMASK ) ) * 7 ) ) & RBSHIFT4MASK ) \
|
||||
) >> 4 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1 + c2 ) / 2
|
||||
// hq3x, hq4x
|
||||
#define Interp5_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( (c1) & GMASK ) + \
|
||||
( (c2) & GMASK ) \
|
||||
) & GSHIFT1MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( (c1) & RBMASK ) + \
|
||||
( (c2) & RBMASK ) \
|
||||
) & RBSHIFT1MASK ) \
|
||||
) >> 1 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp6_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 5 ) + \
|
||||
( ( (c2) & GMASK ) * 2 ) + \
|
||||
( (c3) & GMASK ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 5 ) + \
|
||||
( ( (c2) & RBMASK ) * 2 ) + \
|
||||
( (c3) & RBMASK ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*6 + c2 + c3 ) / 8
|
||||
// hq4x
|
||||
#define Interp7_16( pc, c1, c2, c3 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) == (c3) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 6 ) + \
|
||||
( (c2) & GMASK ) + \
|
||||
( (c3) & GMASK ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 6 ) + \
|
||||
( (c2) & RBMASK ) + \
|
||||
( (c3) & RBMASK ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// ( c1*5 + c2*3 ) / 8
|
||||
// hq4x
|
||||
#define Interp8_16( pc, c1, c2 ) \
|
||||
( \
|
||||
*( (unsigned short *)(pc) ) = \
|
||||
( (c1) == (c2) ) ? c1 : \
|
||||
( \
|
||||
( ( \
|
||||
( ( (c1) & GMASK ) * 5 ) + \
|
||||
( ( (c2) & GMASK ) * 3 ) \
|
||||
) & GSHIFT3MASK ) \
|
||||
+ \
|
||||
( ( \
|
||||
( ( (c1) & RBMASK ) * 5 ) + \
|
||||
( ( (c2) & RBMASK ) * 3 ) \
|
||||
) & RBSHIFT3MASK ) \
|
||||
) >> 3 \
|
||||
)
|
||||
|
||||
|
||||
// 16 bit input color
|
||||
// 0x00YYUUVV return value
|
||||
inline unsigned int RGBtoYUV_16( unsigned short c )
|
||||
{
|
||||
// Division through 3 slows down the emulation about 10% !!!
|
||||
|
||||
register unsigned char r, g, b;
|
||||
#ifdef RGB555
|
||||
r = ( c & 0x7C00 ) >> 7;
|
||||
g = ( c & 0x03E0 ) >> 2;
|
||||
b = ( c & 0x001F ) << 3;
|
||||
#else
|
||||
r = ( c & 0xF800 ) >> 8;
|
||||
g = ( c & 0x07E0 ) >> 3;
|
||||
b = ( c & 0x001F ) << 3;
|
||||
#endif
|
||||
|
||||
return ( (r + g + b) << 14 ) +
|
||||
( ( r - b + 512 ) << 4 ) +
|
||||
( ( 2*g - r - b ) >> 3 ) + 128;
|
||||
}
|
||||
|
|
|
@ -1,85 +1,85 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "EmuManager.h"
|
||||
|
||||
|
||||
EmuManager::EmuManager()
|
||||
: romBuffer( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EmuManager::~EmuManager()
|
||||
{
|
||||
if( romBuffer != 0 ) {
|
||||
free( romBuffer );
|
||||
romBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EmuManager::setROM( QString &file )
|
||||
{
|
||||
romPath = file;
|
||||
}
|
||||
|
||||
|
||||
QString &EmuManager::getROM()
|
||||
{
|
||||
return romPath;
|
||||
}
|
||||
|
||||
|
||||
bool EmuManager::loadROM()
|
||||
{
|
||||
// validate ROM
|
||||
if( romPath.isEmpty() ) return false;
|
||||
|
||||
QFile file( romPath );
|
||||
|
||||
if( !file.exists() ) return false;
|
||||
|
||||
qint64 size = file.size();
|
||||
if( ( size == 0 ) || ( size > 0x2000000 /* 32MB */ ) ) return false;
|
||||
|
||||
// TODO: add further validation
|
||||
|
||||
// read ROM into memory
|
||||
if( !file.open( QIODevice::ReadOnly ) ) return false;
|
||||
|
||||
if( romBuffer != 0 ) {
|
||||
// resize the buffer
|
||||
unsigned char *temp;
|
||||
temp = (unsigned char *)realloc( romBuffer, size );
|
||||
if( temp == 0 ) {
|
||||
free( romBuffer );
|
||||
return false;
|
||||
} else {
|
||||
romBuffer = temp;
|
||||
}
|
||||
} else {
|
||||
// create the buffer
|
||||
romBuffer = (unsigned char *)malloc( size );
|
||||
if( romBuffer == 0 ) return false;
|
||||
}
|
||||
|
||||
if( -1 == file.read( (char *)romBuffer, size ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "EmuManager.h"
|
||||
|
||||
|
||||
EmuManager::EmuManager()
|
||||
: romBuffer( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
EmuManager::~EmuManager()
|
||||
{
|
||||
if( romBuffer != 0 ) {
|
||||
free( romBuffer );
|
||||
romBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EmuManager::setROM( QString &file )
|
||||
{
|
||||
romPath = file;
|
||||
}
|
||||
|
||||
|
||||
QString &EmuManager::getROM()
|
||||
{
|
||||
return romPath;
|
||||
}
|
||||
|
||||
|
||||
bool EmuManager::loadROM()
|
||||
{
|
||||
// validate ROM
|
||||
if( romPath.isEmpty() ) return false;
|
||||
|
||||
QFile file( romPath );
|
||||
|
||||
if( !file.exists() ) return false;
|
||||
|
||||
qint64 size = file.size();
|
||||
if( ( size == 0 ) || ( size > 0x2000000 /* 32MB */ ) ) return false;
|
||||
|
||||
// TODO: add further validation
|
||||
|
||||
// read ROM into memory
|
||||
if( !file.open( QIODevice::ReadOnly ) ) return false;
|
||||
|
||||
if( romBuffer != 0 ) {
|
||||
// resize the buffer
|
||||
unsigned char *temp;
|
||||
temp = (unsigned char *)realloc( romBuffer, size );
|
||||
if( temp == 0 ) {
|
||||
free( romBuffer );
|
||||
return false;
|
||||
} else {
|
||||
romBuffer = temp;
|
||||
}
|
||||
} else {
|
||||
// create the buffer
|
||||
romBuffer = (unsigned char *)malloc( size );
|
||||
if( romBuffer == 0 ) return false;
|
||||
}
|
||||
|
||||
if( -1 == file.read( (char *)romBuffer, size ) ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef EMUMANAGER_H
|
||||
#define EMUMANAGER_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
// class to abstract emulation control
|
||||
class EmuManager
|
||||
{
|
||||
public:
|
||||
EmuManager();
|
||||
~EmuManager();
|
||||
|
||||
void setROM( QString &file );
|
||||
QString &getROM();
|
||||
|
||||
bool loadROM();
|
||||
|
||||
private:
|
||||
QString romPath;
|
||||
unsigned char *romBuffer;
|
||||
};
|
||||
|
||||
#endif // #ifndef EMUMANAGER_H
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef EMUMANAGER_H
|
||||
#define EMUMANAGER_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
// class to abstract emulation control
|
||||
class EmuManager
|
||||
{
|
||||
public:
|
||||
EmuManager();
|
||||
~EmuManager();
|
||||
|
||||
void setROM( QString &file );
|
||||
QString &getROM();
|
||||
|
||||
bool loadROM();
|
||||
|
||||
private:
|
||||
QString romPath;
|
||||
unsigned char *romBuffer;
|
||||
};
|
||||
|
||||
#endif // #ifndef EMUMANAGER_H
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "GraphicsOutput.h"
|
||||
|
||||
|
||||
GraphicsOutput::GraphicsOutput( QWidget *parent)
|
||||
: QGLWidget( parent ),
|
||||
m_api( NONE )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GraphicsOutput::~GraphicsOutput()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool GraphicsOutput::setAPI( GraphicsOutput::DISPLAY_API api )
|
||||
{
|
||||
if( ( api == OPENGL ) && ( !QGLFormat::hasOpenGL() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_api = api;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GraphicsOutput::DISPLAY_API GraphicsOutput::getAPI()
|
||||
{
|
||||
return m_api;
|
||||
}
|
||||
|
||||
|
||||
void GraphicsOutput::render()
|
||||
{
|
||||
repaint(); // immediately calls paintEvent()
|
||||
}
|
||||
|
||||
|
||||
void GraphicsOutput::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
if( m_api == NONE ) return;
|
||||
|
||||
QPainter painter;
|
||||
|
||||
painter.begin( this );
|
||||
|
||||
painter.setRenderHint( QPainter::Antialiasing ); // enable AA if supported by OpenGL device
|
||||
|
||||
painter.setRenderHint( QPainter::TextAntialiasing );
|
||||
|
||||
painter.setRenderHint( QPainter::HighQualityAntialiasing );
|
||||
|
||||
painter.fillRect( rect(), QBrush( QColor( 0xFF, 0x00, 0x00 ), Qt::SolidPattern ) );
|
||||
|
||||
painter.setPen( QColor( 0x00, 0x00, 0xFF ) );
|
||||
painter.drawEllipse( rect() );
|
||||
|
||||
static unsigned int counter = 0;
|
||||
static QTime firstTime = QTime::currentTime();
|
||||
|
||||
int tDiff = firstTime.secsTo( QTime::currentTime() );
|
||||
|
||||
int fps = 0;
|
||||
|
||||
if( tDiff != 0 ) {
|
||||
fps = counter / tDiff;
|
||||
}
|
||||
|
||||
painter.setPen( QColor( 0x00, 0xFF, 0x00 ) );
|
||||
painter.setFont( QFont( "Arial", 14, QFont::Bold ) );
|
||||
painter.drawText( rect(), Qt::AlignCenter, "Frame Number " + QString::number( counter++ ) +
|
||||
"\nFPS: " + QString::number( fps ) );
|
||||
|
||||
painter.end();
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "GraphicsOutput.h"
|
||||
|
||||
|
||||
GraphicsOutput::GraphicsOutput( QWidget *parent)
|
||||
: QGLWidget( parent ),
|
||||
m_api( NONE )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GraphicsOutput::~GraphicsOutput()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool GraphicsOutput::setAPI( GraphicsOutput::DISPLAY_API api )
|
||||
{
|
||||
if( ( api == OPENGL ) && ( !QGLFormat::hasOpenGL() ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_api = api;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GraphicsOutput::DISPLAY_API GraphicsOutput::getAPI()
|
||||
{
|
||||
return m_api;
|
||||
}
|
||||
|
||||
|
||||
void GraphicsOutput::render()
|
||||
{
|
||||
repaint(); // immediately calls paintEvent()
|
||||
}
|
||||
|
||||
|
||||
void GraphicsOutput::paintEvent( QPaintEvent *event )
|
||||
{
|
||||
if( m_api == NONE ) return;
|
||||
|
||||
QPainter painter;
|
||||
|
||||
painter.begin( this );
|
||||
|
||||
painter.setRenderHint( QPainter::Antialiasing ); // enable AA if supported by OpenGL device
|
||||
|
||||
painter.setRenderHint( QPainter::TextAntialiasing );
|
||||
|
||||
painter.setRenderHint( QPainter::HighQualityAntialiasing );
|
||||
|
||||
painter.fillRect( rect(), QBrush( QColor( 0xFF, 0x00, 0x00 ), Qt::SolidPattern ) );
|
||||
|
||||
painter.setPen( QColor( 0x00, 0x00, 0xFF ) );
|
||||
painter.drawEllipse( rect() );
|
||||
|
||||
static unsigned int counter = 0;
|
||||
static QTime firstTime = QTime::currentTime();
|
||||
|
||||
int tDiff = firstTime.secsTo( QTime::currentTime() );
|
||||
|
||||
int fps = 0;
|
||||
|
||||
if( tDiff != 0 ) {
|
||||
fps = counter / tDiff;
|
||||
}
|
||||
|
||||
painter.setPen( QColor( 0x00, 0xFF, 0x00 ) );
|
||||
painter.setFont( QFont( "Arial", 14, QFont::Bold ) );
|
||||
painter.drawText( rect(), Qt::AlignCenter, "Frame Number " + QString::number( counter++ ) +
|
||||
"\nFPS: " + QString::number( fps ) );
|
||||
|
||||
painter.end();
|
||||
}
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef GRAPHICSOUTPUT_H
|
||||
#define GRAPHICSOUTPUT_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
// this class uses a QGLWidget with QPainter, which uses OpenGL acceleration if supported
|
||||
class GraphicsOutput : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphicsOutput( QWidget *parent );
|
||||
~GraphicsOutput();
|
||||
|
||||
enum DISPLAY_API
|
||||
{
|
||||
NONE,
|
||||
QPAINTER,
|
||||
OPENGL,
|
||||
DIRECT3D
|
||||
};
|
||||
|
||||
bool setAPI( DISPLAY_API api );
|
||||
DISPLAY_API getAPI();
|
||||
|
||||
public slots:
|
||||
void render();
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent *event );
|
||||
|
||||
private:
|
||||
DISPLAY_API m_api;
|
||||
};
|
||||
|
||||
#endif // #ifndef GRAPHICSOUTPUT_H
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef GRAPHICSOUTPUT_H
|
||||
#define GRAPHICSOUTPUT_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
// this class uses a QGLWidget with QPainter, which uses OpenGL acceleration if supported
|
||||
class GraphicsOutput : public QGLWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GraphicsOutput( QWidget *parent );
|
||||
~GraphicsOutput();
|
||||
|
||||
enum DISPLAY_API
|
||||
{
|
||||
NONE,
|
||||
QPAINTER,
|
||||
OPENGL,
|
||||
DIRECT3D
|
||||
};
|
||||
|
||||
bool setAPI( DISPLAY_API api );
|
||||
DISPLAY_API getAPI();
|
||||
|
||||
public slots:
|
||||
void render();
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent *event );
|
||||
|
||||
private:
|
||||
DISPLAY_API m_api;
|
||||
};
|
||||
|
||||
#endif // #ifndef GRAPHICSOUTPUT_H
|
||||
|
|
|
@ -1,139 +1,139 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "MainOptions.h"
|
||||
|
||||
VideoOptionsPage::VideoOptionsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGroupBox *RenderGroup = new QGroupBox(tr("Renderer Selection"));
|
||||
QLabel *RenderLabel = new QLabel(tr("Renderer:"));
|
||||
QComboBox *RenderCombo = new QComboBox;
|
||||
RenderCombo->addItem("OpenGL");
|
||||
//RenderCombo->addItem(tr("D3D"));
|
||||
RenderCombo->addItem("QPainter");
|
||||
|
||||
QHBoxLayout *RenderLayout = new QHBoxLayout;
|
||||
RenderLayout->addWidget(RenderLabel);
|
||||
RenderLayout->addWidget(RenderCombo);
|
||||
|
||||
QVBoxLayout *configLayout = new QVBoxLayout;
|
||||
configLayout->addLayout(RenderLayout);
|
||||
RenderGroup->setLayout(configLayout);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(RenderGroup);
|
||||
mainLayout->addStretch(1);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
|
||||
InputOptionsPage::InputOptionsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGroupBox *InputGroup = new QGroupBox(tr("Input Keys"));
|
||||
|
||||
QLabel *StartLabel = new QLabel(tr("Start:"));
|
||||
QLineEdit *StartEdit = new QLineEdit;
|
||||
|
||||
QLabel *SelectLabel = new QLabel(tr("Select:"));
|
||||
QLineEdit *SelectEdit = new QLineEdit;
|
||||
|
||||
QLabel *UpLabel = new QLabel(tr("Up:"));
|
||||
QLineEdit *UpEdit = new QLineEdit;
|
||||
|
||||
QLabel *DownLabel = new QLabel(tr("Down:"));
|
||||
QLineEdit *DownEdit = new QLineEdit;
|
||||
|
||||
QLabel *LeftLabel = new QLabel(tr("Left:"));
|
||||
QLineEdit *LeftEdit = new QLineEdit;
|
||||
|
||||
QLabel *RightLabel = new QLabel(tr("Right:"));
|
||||
QLineEdit *RightEdit = new QLineEdit;
|
||||
|
||||
QLabel *ALabel = new QLabel(tr("A:"));
|
||||
QLineEdit *AEdit = new QLineEdit;
|
||||
|
||||
QLabel *BLabel = new QLabel(tr("B:"));
|
||||
QLineEdit *BEdit = new QLineEdit;
|
||||
|
||||
QLabel *LLabel = new QLabel(tr("L:"));
|
||||
QLineEdit *LEdit = new QLineEdit;
|
||||
|
||||
QLabel *RLabel = new QLabel(tr("R:"));
|
||||
QLineEdit *REdit = new QLineEdit;
|
||||
|
||||
QLabel *GSLabel = new QLabel(tr("Gameshark:"));
|
||||
QLineEdit *GSEdit = new QLineEdit;
|
||||
|
||||
QLabel *SpeedUpLabel = new QLabel(tr("Speed Up:"));
|
||||
QLineEdit *SpeedUpEdit = new QLineEdit;
|
||||
|
||||
QLabel *ScreenshotLabel = new QLabel(tr("Screenshot:"));
|
||||
QLineEdit *ScreenshotEdit = new QLineEdit;
|
||||
|
||||
QCheckBox *MultipleAssignCheckBox = new QCheckBox(tr("Multiple key assignments"));
|
||||
|
||||
|
||||
|
||||
QGridLayout *InputLayout = new QGridLayout;
|
||||
InputLayout->addWidget(StartLabel, 0, 0);
|
||||
InputLayout->addWidget(StartEdit, 0, 1);
|
||||
InputLayout->addWidget(SelectLabel, 1, 0);
|
||||
InputLayout->addWidget(SelectEdit, 1, 1);
|
||||
InputLayout->addWidget(UpLabel, 2, 0);
|
||||
InputLayout->addWidget(UpEdit, 2, 1);
|
||||
InputLayout->addWidget(DownLabel, 3, 0);
|
||||
InputLayout->addWidget(DownEdit, 3, 1);
|
||||
InputLayout->addWidget(LeftLabel, 4, 0);
|
||||
InputLayout->addWidget(LeftEdit, 4, 1);
|
||||
InputLayout->addWidget(RightLabel, 5, 0);
|
||||
InputLayout->addWidget(RightEdit, 5, 1);
|
||||
InputLayout->addWidget(ALabel, 6, 0);
|
||||
InputLayout->addWidget(AEdit, 6, 1);
|
||||
InputLayout->addWidget(BLabel, 7, 0);
|
||||
InputLayout->addWidget(BEdit, 7, 1);
|
||||
InputLayout->addWidget(LLabel, 8, 0);
|
||||
InputLayout->addWidget(LEdit, 8, 1);
|
||||
InputLayout->addWidget(RLabel, 9, 0);
|
||||
InputLayout->addWidget(REdit, 9, 1);
|
||||
InputLayout->addWidget(GSLabel, 0, 2);
|
||||
InputLayout->addWidget(GSEdit, 0, 3);
|
||||
InputLayout->addWidget(SpeedUpLabel, 1, 2);
|
||||
InputLayout->addWidget(SpeedUpEdit, 1, 3);
|
||||
InputLayout->addWidget(ScreenshotLabel, 2, 2);
|
||||
InputLayout->addWidget(ScreenshotEdit, 2, 3);
|
||||
InputLayout->addWidget(MultipleAssignCheckBox, 3, 2);
|
||||
|
||||
|
||||
|
||||
InputGroup->setLayout(InputLayout);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(InputGroup);
|
||||
mainLayout->addSpacing(12);
|
||||
mainLayout->addStretch(1);
|
||||
setLayout(mainLayout);
|
||||
|
||||
}
|
||||
|
||||
|
||||
SoundOptionsPage::SoundOptionsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "MainOptions.h"
|
||||
|
||||
VideoOptionsPage::VideoOptionsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGroupBox *RenderGroup = new QGroupBox(tr("Renderer Selection"));
|
||||
QLabel *RenderLabel = new QLabel(tr("Renderer:"));
|
||||
QComboBox *RenderCombo = new QComboBox;
|
||||
RenderCombo->addItem("OpenGL");
|
||||
//RenderCombo->addItem(tr("D3D"));
|
||||
RenderCombo->addItem("QPainter");
|
||||
|
||||
QHBoxLayout *RenderLayout = new QHBoxLayout;
|
||||
RenderLayout->addWidget(RenderLabel);
|
||||
RenderLayout->addWidget(RenderCombo);
|
||||
|
||||
QVBoxLayout *configLayout = new QVBoxLayout;
|
||||
configLayout->addLayout(RenderLayout);
|
||||
RenderGroup->setLayout(configLayout);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(RenderGroup);
|
||||
mainLayout->addStretch(1);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
|
||||
InputOptionsPage::InputOptionsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QGroupBox *InputGroup = new QGroupBox(tr("Input Keys"));
|
||||
|
||||
QLabel *StartLabel = new QLabel(tr("Start:"));
|
||||
QLineEdit *StartEdit = new QLineEdit;
|
||||
|
||||
QLabel *SelectLabel = new QLabel(tr("Select:"));
|
||||
QLineEdit *SelectEdit = new QLineEdit;
|
||||
|
||||
QLabel *UpLabel = new QLabel(tr("Up:"));
|
||||
QLineEdit *UpEdit = new QLineEdit;
|
||||
|
||||
QLabel *DownLabel = new QLabel(tr("Down:"));
|
||||
QLineEdit *DownEdit = new QLineEdit;
|
||||
|
||||
QLabel *LeftLabel = new QLabel(tr("Left:"));
|
||||
QLineEdit *LeftEdit = new QLineEdit;
|
||||
|
||||
QLabel *RightLabel = new QLabel(tr("Right:"));
|
||||
QLineEdit *RightEdit = new QLineEdit;
|
||||
|
||||
QLabel *ALabel = new QLabel(tr("A:"));
|
||||
QLineEdit *AEdit = new QLineEdit;
|
||||
|
||||
QLabel *BLabel = new QLabel(tr("B:"));
|
||||
QLineEdit *BEdit = new QLineEdit;
|
||||
|
||||
QLabel *LLabel = new QLabel(tr("L:"));
|
||||
QLineEdit *LEdit = new QLineEdit;
|
||||
|
||||
QLabel *RLabel = new QLabel(tr("R:"));
|
||||
QLineEdit *REdit = new QLineEdit;
|
||||
|
||||
QLabel *GSLabel = new QLabel(tr("Gameshark:"));
|
||||
QLineEdit *GSEdit = new QLineEdit;
|
||||
|
||||
QLabel *SpeedUpLabel = new QLabel(tr("Speed Up:"));
|
||||
QLineEdit *SpeedUpEdit = new QLineEdit;
|
||||
|
||||
QLabel *ScreenshotLabel = new QLabel(tr("Screenshot:"));
|
||||
QLineEdit *ScreenshotEdit = new QLineEdit;
|
||||
|
||||
QCheckBox *MultipleAssignCheckBox = new QCheckBox(tr("Multiple key assignments"));
|
||||
|
||||
|
||||
|
||||
QGridLayout *InputLayout = new QGridLayout;
|
||||
InputLayout->addWidget(StartLabel, 0, 0);
|
||||
InputLayout->addWidget(StartEdit, 0, 1);
|
||||
InputLayout->addWidget(SelectLabel, 1, 0);
|
||||
InputLayout->addWidget(SelectEdit, 1, 1);
|
||||
InputLayout->addWidget(UpLabel, 2, 0);
|
||||
InputLayout->addWidget(UpEdit, 2, 1);
|
||||
InputLayout->addWidget(DownLabel, 3, 0);
|
||||
InputLayout->addWidget(DownEdit, 3, 1);
|
||||
InputLayout->addWidget(LeftLabel, 4, 0);
|
||||
InputLayout->addWidget(LeftEdit, 4, 1);
|
||||
InputLayout->addWidget(RightLabel, 5, 0);
|
||||
InputLayout->addWidget(RightEdit, 5, 1);
|
||||
InputLayout->addWidget(ALabel, 6, 0);
|
||||
InputLayout->addWidget(AEdit, 6, 1);
|
||||
InputLayout->addWidget(BLabel, 7, 0);
|
||||
InputLayout->addWidget(BEdit, 7, 1);
|
||||
InputLayout->addWidget(LLabel, 8, 0);
|
||||
InputLayout->addWidget(LEdit, 8, 1);
|
||||
InputLayout->addWidget(RLabel, 9, 0);
|
||||
InputLayout->addWidget(REdit, 9, 1);
|
||||
InputLayout->addWidget(GSLabel, 0, 2);
|
||||
InputLayout->addWidget(GSEdit, 0, 3);
|
||||
InputLayout->addWidget(SpeedUpLabel, 1, 2);
|
||||
InputLayout->addWidget(SpeedUpEdit, 1, 3);
|
||||
InputLayout->addWidget(ScreenshotLabel, 2, 2);
|
||||
InputLayout->addWidget(ScreenshotEdit, 2, 3);
|
||||
InputLayout->addWidget(MultipleAssignCheckBox, 3, 2);
|
||||
|
||||
|
||||
|
||||
InputGroup->setLayout(InputLayout);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(InputGroup);
|
||||
mainLayout->addSpacing(12);
|
||||
mainLayout->addStretch(1);
|
||||
setLayout(mainLayout);
|
||||
|
||||
}
|
||||
|
||||
|
||||
SoundOptionsPage::SoundOptionsPage(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef MAINOPTIONS_H
|
||||
#define MAINOPTIONS_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
class VideoOptionsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoOptionsPage(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class InputOptionsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputOptionsPage(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class SoundOptionsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SoundOptionsPage(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef MAINOPTIONS_H
|
||||
#define MAINOPTIONS_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
class VideoOptionsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoOptionsPage(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class InputOptionsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputOptionsPage(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
class SoundOptionsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SoundOptionsPage(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,383 +1,383 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "MainWnd.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "configdialog.h"
|
||||
#include "sidewidget_cheats.h"
|
||||
|
||||
|
||||
MainWnd::MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent )
|
||||
: QMainWindow( parent ),
|
||||
translator( trans ),
|
||||
settings( settings ),
|
||||
fileMenu( 0 ),
|
||||
settingsMenu( 0 ),
|
||||
toolsMenu( 0 ),
|
||||
helpMenu( 0 ),
|
||||
enableTranslationAct( 0 ),
|
||||
dockWidget_cheats( 0 ),
|
||||
emuManager( 0 ),
|
||||
graphicsOutput( 0 )
|
||||
{
|
||||
createDisplay();
|
||||
setMinimumSize( 320, 240 );
|
||||
setWindowTitle( "VBA-M" );
|
||||
|
||||
createDockWidgets();
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
loadSettings();
|
||||
|
||||
emuManager = new EmuManager();
|
||||
}
|
||||
|
||||
|
||||
MainWnd::~MainWnd()
|
||||
{
|
||||
if( emuManager != 0 ) {
|
||||
delete emuManager;
|
||||
emuManager = 0;
|
||||
}
|
||||
|
||||
if( graphicsOutput != 0 ) {
|
||||
delete graphicsOutput;
|
||||
graphicsOutput = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::loadSettings()
|
||||
{
|
||||
QVariant v;
|
||||
|
||||
v = settings->value( "MainWnd/geometry");
|
||||
if( v.isValid() ) {
|
||||
restoreGeometry( v.toByteArray() );
|
||||
}
|
||||
|
||||
v = settings->value( "MainWnd/state" );
|
||||
if( v.isValid() ) {
|
||||
restoreState( v.toByteArray() );
|
||||
}
|
||||
|
||||
v = settings->value( "App/language_file" );
|
||||
if( v.isValid() ) {
|
||||
languageFile = v.toString();
|
||||
if( loadTranslation() ) {
|
||||
// only enable language if it loaded correctly
|
||||
v = settings->value( "App/language_enable" );
|
||||
enableTranslation( v.toBool() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::saveSettings()
|
||||
{
|
||||
QVariant v;
|
||||
|
||||
v = saveGeometry();
|
||||
settings->setValue( "MainWnd/geometry", v );
|
||||
|
||||
// state of toolbars and dock widgets
|
||||
// all memorizable widgets need an objectName!
|
||||
v = saveState();
|
||||
settings->setValue( "MainWnd/state", v );
|
||||
|
||||
v = enableTranslationAct->isChecked();
|
||||
settings->setValue( "App/language_enable", v );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::createActions()
|
||||
{
|
||||
bool enabled, checked;
|
||||
|
||||
|
||||
if( enableTranslationAct != 0 ) {
|
||||
enabled = enableTranslationAct->isEnabled(); // memorize state
|
||||
checked = enableTranslationAct->isChecked();
|
||||
delete enableTranslationAct;
|
||||
enableTranslationAct = 0;
|
||||
} else {
|
||||
enabled = false;
|
||||
checked = false;
|
||||
}
|
||||
enableTranslationAct = new QAction( tr( "Enable translation" ), this );
|
||||
enableTranslationAct->setEnabled( enabled );
|
||||
enableTranslationAct->setCheckable( true );
|
||||
enableTranslationAct->setChecked( checked );
|
||||
connect( enableTranslationAct, SIGNAL( toggled( bool ) ), this, SLOT( enableTranslation( bool ) ) );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::createMenus()
|
||||
{
|
||||
if( fileMenu ) {
|
||||
delete fileMenu;
|
||||
fileMenu = 0;
|
||||
}
|
||||
|
||||
if( settingsMenu ) {
|
||||
delete settingsMenu;
|
||||
settingsMenu = 0;
|
||||
}
|
||||
|
||||
if( toolsMenu ) {
|
||||
delete toolsMenu;
|
||||
toolsMenu = 0;
|
||||
}
|
||||
|
||||
if( helpMenu ) {
|
||||
delete helpMenu;
|
||||
helpMenu = 0;
|
||||
}
|
||||
|
||||
|
||||
// File menu
|
||||
fileMenu = menuBar()->addMenu( tr( "File" ) );
|
||||
fileMenu->addAction( QIcon( ":/resources/open.png" ), tr( "Open ROM" ), this, SLOT( showOpenROM() ) );
|
||||
fileMenu->addAction( QIcon( ":/resources/exit.png" ), tr( "Exit" ), this, SLOT( close() ) );
|
||||
|
||||
|
||||
// Settings menu
|
||||
settingsMenu = menuBar()->addMenu( tr( "Settings" ) );
|
||||
settingsMenu->addAction( QIcon( ":/resources/settings.png" ), tr( "Main options..." ), this, SLOT( showMainOptions() ) );
|
||||
settingsMenu->addAction( QIcon( ":/resources/locale.png" ), tr( "Select language..." ), this, SLOT( selectLanguage() ) );
|
||||
settingsMenu->addAction( enableTranslationAct );
|
||||
|
||||
|
||||
// Tools menu
|
||||
toolsMenu = menuBar()->addMenu( tr( "Tools" ) );
|
||||
QAction *toggleCheats = dockWidget_cheats->toggleViewAction();
|
||||
toggleCheats->setText( tr( "Show cheats sidebar" ) );
|
||||
toolsMenu->addAction( toggleCheats ) ;
|
||||
|
||||
|
||||
// Help menu
|
||||
helpMenu = menuBar()->addMenu( tr( "Help" ) );
|
||||
|
||||
helpMenu->addAction( QIcon( ":/resources/vba-m.png" ), tr( "About VBA-M..." ), this, SLOT( showAbout() ) );
|
||||
helpMenu->addAction( QIcon( ":/resources/gl.png" ), tr( "About OpenGL..." ), this, SLOT( showAboutOpenGL() ) );
|
||||
helpMenu->addAction( QIcon( ":/resources/qt_logo.png" ), tr( "About Qt..." ), qApp, SLOT( aboutQt() ) );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::createDockWidgets()
|
||||
{
|
||||
if( dockWidget_cheats != 0 ) {
|
||||
delete dockWidget_cheats;
|
||||
dockWidget_cheats = 0;
|
||||
}
|
||||
|
||||
// Cheat Widget
|
||||
dockWidget_cheats = new QDockWidget( tr( "Cheats" ), this );
|
||||
dockWidget_cheats->setObjectName( "dockWidget_cheats" ); // necessary for MainWnd::saveState
|
||||
SideWidget_Cheats *sw_cheats = new SideWidget_Cheats( dockWidget_cheats );
|
||||
dockWidget_cheats->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
dockWidget_cheats->setWidget( sw_cheats );
|
||||
addDockWidget( Qt::LeftDockWidgetArea, dockWidget_cheats );
|
||||
dockWidget_cheats->hide();
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::createDisplay()
|
||||
{
|
||||
if( graphicsOutput != 0 ) {
|
||||
delete graphicsOutput;
|
||||
graphicsOutput = 0;
|
||||
}
|
||||
|
||||
graphicsOutput = new GraphicsOutput( this );
|
||||
|
||||
if( !graphicsOutput->setAPI( GraphicsOutput::QPAINTER ) ) return false;
|
||||
|
||||
setCentralWidget( graphicsOutput );
|
||||
|
||||
QTimer *timer = new QTimer( this );
|
||||
connect( timer, SIGNAL( timeout() ), graphicsOutput, SLOT( render() ) );
|
||||
timer->start( 15 ); // set to 0 for idle time processing
|
||||
// 1000 / 60 = 60 fps, but only results to 40 fps in reality.
|
||||
// possible workaround: call timer more often and return or wait if too early
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::closeEvent( QCloseEvent * )
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::selectLanguage()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select language" ),
|
||||
"lang",
|
||||
tr( "Language files (*.qm)" ) );
|
||||
|
||||
if( file.isNull() ) return false;
|
||||
|
||||
languageFile = file;
|
||||
|
||||
bool ret = loadTranslation();
|
||||
ret &= enableTranslation( true );
|
||||
|
||||
if( ret == false ) {
|
||||
QMessageBox::critical( this, tr( "Error!" ), tr( "Language file can not be loaded!" ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::loadTranslation()
|
||||
{
|
||||
settings->setValue( "App/language_file", languageFile );
|
||||
if( !languageFile.endsWith( tr( ".qm" ), Qt::CaseInsensitive ) ) return false;
|
||||
QString file = languageFile;
|
||||
|
||||
// remove current translation
|
||||
enableTranslation( false );
|
||||
if( *translator != 0 ) {
|
||||
delete *translator;
|
||||
*translator = 0;
|
||||
}
|
||||
|
||||
file.chop( 3 ); // remove file extension ".qm"
|
||||
|
||||
// load new translation
|
||||
*translator = new QTranslator();
|
||||
bool ret = (*translator)->load( file );
|
||||
enableTranslationAct->setEnabled( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::enableTranslation( bool enable )
|
||||
{
|
||||
if( enable ) {
|
||||
if( *translator != 0 ) {
|
||||
qApp->installTranslator( *translator );
|
||||
enableTranslationAct->setChecked( true );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if( *translator != 0 ) {
|
||||
qApp->removeTranslator( *translator );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// apply translation
|
||||
// the user might have to restart the application to apply changes completely
|
||||
QByteArray windowState = saveState();
|
||||
createDockWidgets();
|
||||
createActions();
|
||||
createMenus();
|
||||
restoreState( windowState );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showAbout()
|
||||
{
|
||||
QString info( "VisualBoyAdvance-M\n" );
|
||||
info += tr( "Version" ) + " " + VERSION_STR + "\n";
|
||||
|
||||
info += tr( "Compile date:" ) + " " + __DATE__ + "\n";
|
||||
|
||||
// translators may use this string to give informations about the language file
|
||||
info += "\n" + tr ( "No language file loaded." ) + "\n";
|
||||
|
||||
info += "\n" + tr ( "This program is licensed under terms of the GNU General Public License." );
|
||||
|
||||
QMessageBox::about( this, tr( "About VBA-M" ), info );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showOpenROM()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select ROM" ),
|
||||
"",
|
||||
tr( "Game Boy Advance ROMs (*.gba);;All Files (*.*)" ) );
|
||||
|
||||
if( file.isNull() ) return;
|
||||
|
||||
emuManager->setROM( file );
|
||||
if( !emuManager->loadROM() ) {
|
||||
QMessageBox::critical( this, tr( "Error!" ), tr( "Can not load ROM!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: start emulation
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showMainOptions()
|
||||
{
|
||||
ConfigDialog dialog;
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showAboutOpenGL()
|
||||
{
|
||||
QString info;
|
||||
if( QGLFormat::hasOpenGL() ) {
|
||||
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
|
||||
if( flags & QGLFormat::OpenGL_Version_2_1 ) {
|
||||
info = tr( "OpenGL version 2.1 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_2_0 ) {
|
||||
info = tr( "OpenGL version 2.0 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_5 ) {
|
||||
info = tr( "OpenGL version 1.5 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_4 ) {
|
||||
info = tr( "OpenGL version 1.4 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_3 ) {
|
||||
info = tr( "OpenGL version 1.3 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_2 ) {
|
||||
info = tr( "OpenGL version 1.2 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_1 ) {
|
||||
info = tr( "OpenGL version 1.1 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_None ) {
|
||||
info = tr( "OpenGL is NOT available!" );
|
||||
}
|
||||
} else {
|
||||
info = tr( "OpenGL is NOT available!" );
|
||||
}
|
||||
|
||||
QMessageBox *test = new QMessageBox( QMessageBox::NoIcon, tr( "About OpenGL" ), info, QMessageBox::NoButton, this );
|
||||
test->setWindowIcon( QIcon( ":/resources/gl.png" ) );
|
||||
test->show();
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "MainWnd.h"
|
||||
|
||||
#include "version.h"
|
||||
#include "configdialog.h"
|
||||
#include "sidewidget_cheats.h"
|
||||
|
||||
|
||||
MainWnd::MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent )
|
||||
: QMainWindow( parent ),
|
||||
translator( trans ),
|
||||
settings( settings ),
|
||||
fileMenu( 0 ),
|
||||
settingsMenu( 0 ),
|
||||
toolsMenu( 0 ),
|
||||
helpMenu( 0 ),
|
||||
enableTranslationAct( 0 ),
|
||||
dockWidget_cheats( 0 ),
|
||||
emuManager( 0 ),
|
||||
graphicsOutput( 0 )
|
||||
{
|
||||
createDisplay();
|
||||
setMinimumSize( 320, 240 );
|
||||
setWindowTitle( "VBA-M" );
|
||||
|
||||
createDockWidgets();
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
loadSettings();
|
||||
|
||||
emuManager = new EmuManager();
|
||||
}
|
||||
|
||||
|
||||
MainWnd::~MainWnd()
|
||||
{
|
||||
if( emuManager != 0 ) {
|
||||
delete emuManager;
|
||||
emuManager = 0;
|
||||
}
|
||||
|
||||
if( graphicsOutput != 0 ) {
|
||||
delete graphicsOutput;
|
||||
graphicsOutput = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::loadSettings()
|
||||
{
|
||||
QVariant v;
|
||||
|
||||
v = settings->value( "MainWnd/geometry");
|
||||
if( v.isValid() ) {
|
||||
restoreGeometry( v.toByteArray() );
|
||||
}
|
||||
|
||||
v = settings->value( "MainWnd/state" );
|
||||
if( v.isValid() ) {
|
||||
restoreState( v.toByteArray() );
|
||||
}
|
||||
|
||||
v = settings->value( "App/language_file" );
|
||||
if( v.isValid() ) {
|
||||
languageFile = v.toString();
|
||||
if( loadTranslation() ) {
|
||||
// only enable language if it loaded correctly
|
||||
v = settings->value( "App/language_enable" );
|
||||
enableTranslation( v.toBool() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::saveSettings()
|
||||
{
|
||||
QVariant v;
|
||||
|
||||
v = saveGeometry();
|
||||
settings->setValue( "MainWnd/geometry", v );
|
||||
|
||||
// state of toolbars and dock widgets
|
||||
// all memorizable widgets need an objectName!
|
||||
v = saveState();
|
||||
settings->setValue( "MainWnd/state", v );
|
||||
|
||||
v = enableTranslationAct->isChecked();
|
||||
settings->setValue( "App/language_enable", v );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::createActions()
|
||||
{
|
||||
bool enabled, checked;
|
||||
|
||||
|
||||
if( enableTranslationAct != 0 ) {
|
||||
enabled = enableTranslationAct->isEnabled(); // memorize state
|
||||
checked = enableTranslationAct->isChecked();
|
||||
delete enableTranslationAct;
|
||||
enableTranslationAct = 0;
|
||||
} else {
|
||||
enabled = false;
|
||||
checked = false;
|
||||
}
|
||||
enableTranslationAct = new QAction( tr( "Enable translation" ), this );
|
||||
enableTranslationAct->setEnabled( enabled );
|
||||
enableTranslationAct->setCheckable( true );
|
||||
enableTranslationAct->setChecked( checked );
|
||||
connect( enableTranslationAct, SIGNAL( toggled( bool ) ), this, SLOT( enableTranslation( bool ) ) );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::createMenus()
|
||||
{
|
||||
if( fileMenu ) {
|
||||
delete fileMenu;
|
||||
fileMenu = 0;
|
||||
}
|
||||
|
||||
if( settingsMenu ) {
|
||||
delete settingsMenu;
|
||||
settingsMenu = 0;
|
||||
}
|
||||
|
||||
if( toolsMenu ) {
|
||||
delete toolsMenu;
|
||||
toolsMenu = 0;
|
||||
}
|
||||
|
||||
if( helpMenu ) {
|
||||
delete helpMenu;
|
||||
helpMenu = 0;
|
||||
}
|
||||
|
||||
|
||||
// File menu
|
||||
fileMenu = menuBar()->addMenu( tr( "File" ) );
|
||||
fileMenu->addAction( QIcon( ":/resources/open.png" ), tr( "Open ROM" ), this, SLOT( showOpenROM() ) );
|
||||
fileMenu->addAction( QIcon( ":/resources/exit.png" ), tr( "Exit" ), this, SLOT( close() ) );
|
||||
|
||||
|
||||
// Settings menu
|
||||
settingsMenu = menuBar()->addMenu( tr( "Settings" ) );
|
||||
settingsMenu->addAction( QIcon( ":/resources/settings.png" ), tr( "Main options..." ), this, SLOT( showMainOptions() ) );
|
||||
settingsMenu->addAction( QIcon( ":/resources/locale.png" ), tr( "Select language..." ), this, SLOT( selectLanguage() ) );
|
||||
settingsMenu->addAction( enableTranslationAct );
|
||||
|
||||
|
||||
// Tools menu
|
||||
toolsMenu = menuBar()->addMenu( tr( "Tools" ) );
|
||||
QAction *toggleCheats = dockWidget_cheats->toggleViewAction();
|
||||
toggleCheats->setText( tr( "Show cheats sidebar" ) );
|
||||
toolsMenu->addAction( toggleCheats ) ;
|
||||
|
||||
|
||||
// Help menu
|
||||
helpMenu = menuBar()->addMenu( tr( "Help" ) );
|
||||
|
||||
helpMenu->addAction( QIcon( ":/resources/vba-m.png" ), tr( "About VBA-M..." ), this, SLOT( showAbout() ) );
|
||||
helpMenu->addAction( QIcon( ":/resources/gl.png" ), tr( "About OpenGL..." ), this, SLOT( showAboutOpenGL() ) );
|
||||
helpMenu->addAction( QIcon( ":/resources/qt_logo.png" ), tr( "About Qt..." ), qApp, SLOT( aboutQt() ) );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::createDockWidgets()
|
||||
{
|
||||
if( dockWidget_cheats != 0 ) {
|
||||
delete dockWidget_cheats;
|
||||
dockWidget_cheats = 0;
|
||||
}
|
||||
|
||||
// Cheat Widget
|
||||
dockWidget_cheats = new QDockWidget( tr( "Cheats" ), this );
|
||||
dockWidget_cheats->setObjectName( "dockWidget_cheats" ); // necessary for MainWnd::saveState
|
||||
SideWidget_Cheats *sw_cheats = new SideWidget_Cheats( dockWidget_cheats );
|
||||
dockWidget_cheats->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
dockWidget_cheats->setWidget( sw_cheats );
|
||||
addDockWidget( Qt::LeftDockWidgetArea, dockWidget_cheats );
|
||||
dockWidget_cheats->hide();
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::createDisplay()
|
||||
{
|
||||
if( graphicsOutput != 0 ) {
|
||||
delete graphicsOutput;
|
||||
graphicsOutput = 0;
|
||||
}
|
||||
|
||||
graphicsOutput = new GraphicsOutput( this );
|
||||
|
||||
if( !graphicsOutput->setAPI( GraphicsOutput::QPAINTER ) ) return false;
|
||||
|
||||
setCentralWidget( graphicsOutput );
|
||||
|
||||
QTimer *timer = new QTimer( this );
|
||||
connect( timer, SIGNAL( timeout() ), graphicsOutput, SLOT( render() ) );
|
||||
timer->start( 15 ); // set to 0 for idle time processing
|
||||
// 1000 / 60 = 60 fps, but only results to 40 fps in reality.
|
||||
// possible workaround: call timer more often and return or wait if too early
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::closeEvent( QCloseEvent * )
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::selectLanguage()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select language" ),
|
||||
"lang",
|
||||
tr( "Language files (*.qm)" ) );
|
||||
|
||||
if( file.isNull() ) return false;
|
||||
|
||||
languageFile = file;
|
||||
|
||||
bool ret = loadTranslation();
|
||||
ret &= enableTranslation( true );
|
||||
|
||||
if( ret == false ) {
|
||||
QMessageBox::critical( this, tr( "Error!" ), tr( "Language file can not be loaded!" ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::loadTranslation()
|
||||
{
|
||||
settings->setValue( "App/language_file", languageFile );
|
||||
if( !languageFile.endsWith( tr( ".qm" ), Qt::CaseInsensitive ) ) return false;
|
||||
QString file = languageFile;
|
||||
|
||||
// remove current translation
|
||||
enableTranslation( false );
|
||||
if( *translator != 0 ) {
|
||||
delete *translator;
|
||||
*translator = 0;
|
||||
}
|
||||
|
||||
file.chop( 3 ); // remove file extension ".qm"
|
||||
|
||||
// load new translation
|
||||
*translator = new QTranslator();
|
||||
bool ret = (*translator)->load( file );
|
||||
enableTranslationAct->setEnabled( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool MainWnd::enableTranslation( bool enable )
|
||||
{
|
||||
if( enable ) {
|
||||
if( *translator != 0 ) {
|
||||
qApp->installTranslator( *translator );
|
||||
enableTranslationAct->setChecked( true );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if( *translator != 0 ) {
|
||||
qApp->removeTranslator( *translator );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// apply translation
|
||||
// the user might have to restart the application to apply changes completely
|
||||
QByteArray windowState = saveState();
|
||||
createDockWidgets();
|
||||
createActions();
|
||||
createMenus();
|
||||
restoreState( windowState );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showAbout()
|
||||
{
|
||||
QString info( "VisualBoyAdvance-M\n" );
|
||||
info += tr( "Version" ) + " " + VERSION_STR + "\n";
|
||||
|
||||
info += tr( "Compile date:" ) + " " + __DATE__ + "\n";
|
||||
|
||||
// translators may use this string to give informations about the language file
|
||||
info += "\n" + tr ( "No language file loaded." ) + "\n";
|
||||
|
||||
info += "\n" + tr ( "This program is licensed under terms of the GNU General Public License." );
|
||||
|
||||
QMessageBox::about( this, tr( "About VBA-M" ), info );
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showOpenROM()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select ROM" ),
|
||||
"",
|
||||
tr( "Game Boy Advance ROMs (*.gba);;All Files (*.*)" ) );
|
||||
|
||||
if( file.isNull() ) return;
|
||||
|
||||
emuManager->setROM( file );
|
||||
if( !emuManager->loadROM() ) {
|
||||
QMessageBox::critical( this, tr( "Error!" ), tr( "Can not load ROM!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: start emulation
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showMainOptions()
|
||||
{
|
||||
ConfigDialog dialog;
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
|
||||
void MainWnd::showAboutOpenGL()
|
||||
{
|
||||
QString info;
|
||||
if( QGLFormat::hasOpenGL() ) {
|
||||
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
|
||||
if( flags & QGLFormat::OpenGL_Version_2_1 ) {
|
||||
info = tr( "OpenGL version 2.1 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_2_0 ) {
|
||||
info = tr( "OpenGL version 2.0 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_5 ) {
|
||||
info = tr( "OpenGL version 1.5 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_4 ) {
|
||||
info = tr( "OpenGL version 1.4 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_3 ) {
|
||||
info = tr( "OpenGL version 1.3 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_2 ) {
|
||||
info = tr( "OpenGL version 1.2 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_1_1 ) {
|
||||
info = tr( "OpenGL version 1.1 is present." );
|
||||
} else
|
||||
if( flags & QGLFormat::OpenGL_Version_None ) {
|
||||
info = tr( "OpenGL is NOT available!" );
|
||||
}
|
||||
} else {
|
||||
info = tr( "OpenGL is NOT available!" );
|
||||
}
|
||||
|
||||
QMessageBox *test = new QMessageBox( QMessageBox::NoIcon, tr( "About OpenGL" ), info, QMessageBox::NoButton, this );
|
||||
test->setWindowIcon( QIcon( ":/resources/gl.png" ) );
|
||||
test->show();
|
||||
}
|
||||
|
|
136
src/qt/MainWnd.h
136
src/qt/MainWnd.h
|
@ -1,68 +1,68 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef MAINWND_H
|
||||
#define MAINWND_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
#include "EmuManager.h"
|
||||
#include "GraphicsOutput.h"
|
||||
|
||||
class MainWnd : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent = 0 );
|
||||
~MainWnd();
|
||||
|
||||
public slots:
|
||||
void closeEvent( QCloseEvent * );
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
bool loadTranslation();
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createDockWidgets();
|
||||
bool createDisplay();
|
||||
|
||||
QTranslator **translator;
|
||||
QString languageFile;
|
||||
QSettings *settings;
|
||||
QMenu *fileMenu;
|
||||
QMenu *settingsMenu;
|
||||
QAction *enableTranslationAct;
|
||||
QMenu *toolsMenu;
|
||||
QMenu *helpMenu;
|
||||
QDockWidget *dockWidget_cheats;
|
||||
EmuManager *emuManager;
|
||||
GraphicsOutput *graphicsOutput;
|
||||
|
||||
private slots:
|
||||
bool selectLanguage();
|
||||
bool enableTranslation( bool enable );
|
||||
void showAbout();
|
||||
void showAboutOpenGL();
|
||||
void showOpenROM();
|
||||
void showMainOptions();
|
||||
};
|
||||
|
||||
#endif // #ifndef MAINWND_H
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef MAINWND_H
|
||||
#define MAINWND_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
#include "EmuManager.h"
|
||||
#include "GraphicsOutput.h"
|
||||
|
||||
class MainWnd : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWnd( QTranslator **trans, QSettings *settings, QWidget *parent = 0 );
|
||||
~MainWnd();
|
||||
|
||||
public slots:
|
||||
void closeEvent( QCloseEvent * );
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
bool loadTranslation();
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createDockWidgets();
|
||||
bool createDisplay();
|
||||
|
||||
QTranslator **translator;
|
||||
QString languageFile;
|
||||
QSettings *settings;
|
||||
QMenu *fileMenu;
|
||||
QMenu *settingsMenu;
|
||||
QAction *enableTranslationAct;
|
||||
QMenu *toolsMenu;
|
||||
QMenu *helpMenu;
|
||||
QDockWidget *dockWidget_cheats;
|
||||
EmuManager *emuManager;
|
||||
GraphicsOutput *graphicsOutput;
|
||||
|
||||
private slots:
|
||||
bool selectLanguage();
|
||||
bool enableTranslation( bool enable );
|
||||
void showAbout();
|
||||
void showAboutOpenGL();
|
||||
void showOpenROM();
|
||||
void showMainOptions();
|
||||
};
|
||||
|
||||
#endif // #ifndef MAINWND_H
|
||||
|
|
|
@ -1,97 +1,97 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "configdialog.h"
|
||||
|
||||
#include "MainOptions.h"
|
||||
|
||||
ConfigDialog::ConfigDialog()
|
||||
{
|
||||
// close button
|
||||
QPushButton *closeButton = new QPushButton( tr( "Close" ) );
|
||||
closeButton->setMaximumSize( closeButton->sizeHint() );
|
||||
connect( closeButton, SIGNAL( clicked() ), this, SLOT( close() ) );
|
||||
|
||||
// settings
|
||||
pagesWidget = new QStackedWidget;
|
||||
pagesWidget->addWidget( new VideoOptionsPage( pagesWidget ) );
|
||||
pagesWidget->addWidget( new SoundOptionsPage( pagesWidget ) );
|
||||
pagesWidget->addWidget( new InputOptionsPage( pagesWidget ) );
|
||||
|
||||
// item box
|
||||
contentsWidget = new QListWidget;
|
||||
contentsWidget->setViewMode( QListView::IconMode );
|
||||
contentsWidget->setIconSize( QSize( 64, 64 ) );
|
||||
contentsWidget->setUniformItemSizes( true ); // enable optimizations
|
||||
contentsWidget->setMovement( QListView::Static );
|
||||
contentsWidget->setResizeMode( QListView::Adjust );
|
||||
contentsWidget->setFlow( QListView::TopToBottom );
|
||||
contentsWidget->setSpacing( 8 );
|
||||
createIcons();
|
||||
contentsWidget->setCurrentRow( 0 );
|
||||
// set optimal width
|
||||
int width = contentsWidget->sizeHintForColumn( 0 ) + 16; // not 100% accurate yet!
|
||||
contentsWidget->setMinimumWidth( width );
|
||||
contentsWidget->setMaximumWidth( width );
|
||||
|
||||
// set up layout
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout;
|
||||
verticalLayout->addWidget( pagesWidget );
|
||||
verticalLayout->addWidget( closeButton, 0, Qt::AlignRight );
|
||||
|
||||
QHBoxLayout *horizontalLayout = new QHBoxLayout( this );
|
||||
horizontalLayout->addWidget( contentsWidget );
|
||||
horizontalLayout->addLayout( verticalLayout );
|
||||
|
||||
|
||||
setWindowTitle(tr("Options"));
|
||||
setWindowIcon( QIcon( ":/resources/settings.png" ) );
|
||||
}
|
||||
|
||||
void ConfigDialog::createIcons()
|
||||
{
|
||||
QListWidgetItem *VideoButton = new QListWidgetItem(contentsWidget); // automatically inserts item into parent
|
||||
VideoButton->setIcon(QIcon(":/resources/video.png"));
|
||||
VideoButton->setText(tr("Video"));
|
||||
VideoButton->setTextAlignment(Qt::AlignHCenter);
|
||||
VideoButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
QListWidgetItem *SoundButton = new QListWidgetItem(contentsWidget);
|
||||
SoundButton->setIcon(QIcon(":/resources/sound.png"));
|
||||
SoundButton->setText(tr("Sound"));
|
||||
SoundButton->setTextAlignment(Qt::AlignHCenter);
|
||||
SoundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
QListWidgetItem *InputButton = new QListWidgetItem(contentsWidget);
|
||||
InputButton->setIcon(QIcon(":/resources/input.png"));
|
||||
InputButton->setText(tr("Input"));
|
||||
InputButton->setTextAlignment(Qt::AlignHCenter);
|
||||
InputButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
connect(contentsWidget,
|
||||
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
|
||||
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
if (!current)
|
||||
current = previous;
|
||||
|
||||
pagesWidget->setCurrentIndex(contentsWidget->row(current));
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "configdialog.h"
|
||||
|
||||
#include "MainOptions.h"
|
||||
|
||||
ConfigDialog::ConfigDialog()
|
||||
{
|
||||
// close button
|
||||
QPushButton *closeButton = new QPushButton( tr( "Close" ) );
|
||||
closeButton->setMaximumSize( closeButton->sizeHint() );
|
||||
connect( closeButton, SIGNAL( clicked() ), this, SLOT( close() ) );
|
||||
|
||||
// settings
|
||||
pagesWidget = new QStackedWidget;
|
||||
pagesWidget->addWidget( new VideoOptionsPage( pagesWidget ) );
|
||||
pagesWidget->addWidget( new SoundOptionsPage( pagesWidget ) );
|
||||
pagesWidget->addWidget( new InputOptionsPage( pagesWidget ) );
|
||||
|
||||
// item box
|
||||
contentsWidget = new QListWidget;
|
||||
contentsWidget->setViewMode( QListView::IconMode );
|
||||
contentsWidget->setIconSize( QSize( 64, 64 ) );
|
||||
contentsWidget->setUniformItemSizes( true ); // enable optimizations
|
||||
contentsWidget->setMovement( QListView::Static );
|
||||
contentsWidget->setResizeMode( QListView::Adjust );
|
||||
contentsWidget->setFlow( QListView::TopToBottom );
|
||||
contentsWidget->setSpacing( 8 );
|
||||
createIcons();
|
||||
contentsWidget->setCurrentRow( 0 );
|
||||
// set optimal width
|
||||
int width = contentsWidget->sizeHintForColumn( 0 ) + 16; // not 100% accurate yet!
|
||||
contentsWidget->setMinimumWidth( width );
|
||||
contentsWidget->setMaximumWidth( width );
|
||||
|
||||
// set up layout
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout;
|
||||
verticalLayout->addWidget( pagesWidget );
|
||||
verticalLayout->addWidget( closeButton, 0, Qt::AlignRight );
|
||||
|
||||
QHBoxLayout *horizontalLayout = new QHBoxLayout( this );
|
||||
horizontalLayout->addWidget( contentsWidget );
|
||||
horizontalLayout->addLayout( verticalLayout );
|
||||
|
||||
|
||||
setWindowTitle(tr("Options"));
|
||||
setWindowIcon( QIcon( ":/resources/settings.png" ) );
|
||||
}
|
||||
|
||||
void ConfigDialog::createIcons()
|
||||
{
|
||||
QListWidgetItem *VideoButton = new QListWidgetItem(contentsWidget); // automatically inserts item into parent
|
||||
VideoButton->setIcon(QIcon(":/resources/video.png"));
|
||||
VideoButton->setText(tr("Video"));
|
||||
VideoButton->setTextAlignment(Qt::AlignHCenter);
|
||||
VideoButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
QListWidgetItem *SoundButton = new QListWidgetItem(contentsWidget);
|
||||
SoundButton->setIcon(QIcon(":/resources/sound.png"));
|
||||
SoundButton->setText(tr("Sound"));
|
||||
SoundButton->setTextAlignment(Qt::AlignHCenter);
|
||||
SoundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
QListWidgetItem *InputButton = new QListWidgetItem(contentsWidget);
|
||||
InputButton->setIcon(QIcon(":/resources/input.png"));
|
||||
InputButton->setText(tr("Input"));
|
||||
InputButton->setTextAlignment(Qt::AlignHCenter);
|
||||
InputButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
|
||||
connect(contentsWidget,
|
||||
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
|
||||
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
if (!current)
|
||||
current = previous;
|
||||
|
||||
pagesWidget->setCurrentIndex(contentsWidget->row(current));
|
||||
}
|
||||
|
|
|
@ -1,41 +1,41 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef CONFIGDIALOG_H
|
||||
#define CONFIGDIALOG_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
class ConfigDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigDialog();
|
||||
|
||||
public slots:
|
||||
void changePage( QListWidgetItem *current, QListWidgetItem *previous );
|
||||
|
||||
private:
|
||||
void createIcons();
|
||||
|
||||
QListWidget *contentsWidget;
|
||||
QStackedWidget *pagesWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef CONFIGDIALOG_H
|
||||
#define CONFIGDIALOG_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
class ConfigDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigDialog();
|
||||
|
||||
public slots:
|
||||
void changePage( QListWidgetItem *current, QListWidgetItem *previous );
|
||||
|
||||
private:
|
||||
void createIcons();
|
||||
|
||||
QListWidget *contentsWidget;
|
||||
QStackedWidget *pagesWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include "MainWnd.h"
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
QApplication theApp( argc, argv );
|
||||
// create/open ini file for settings
|
||||
QSettings settings( "vba-m.ini", QSettings::IniFormat, &theApp );
|
||||
QTranslator *translator = 0;
|
||||
|
||||
MainWnd *mainWnd = new MainWnd( &translator, &settings, 0 );
|
||||
mainWnd->show();
|
||||
|
||||
return theApp.exec();
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include "MainWnd.h"
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
QApplication theApp( argc, argv );
|
||||
// create/open ini file for settings
|
||||
QSettings settings( "vba-m.ini", QSettings::IniFormat, &theApp );
|
||||
QTranslator *translator = 0;
|
||||
|
||||
MainWnd *mainWnd = new MainWnd( &translator, &settings, 0 );
|
||||
mainWnd->show();
|
||||
|
||||
return theApp.exec();
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
#endif // #ifndef MAIN_H
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
#endif // #ifndef MAIN_H
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef PRECOMPILE_H
|
||||
#define PRECOMPILE_H
|
||||
|
||||
#if defined __cplusplus
|
||||
// Add C++ includes here
|
||||
#include <QtGui/QtGui>
|
||||
#include <QtOpenGL/QtOpenGL>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#endif // #ifndef PRECOMPILE_H
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#ifndef PRECOMPILE_H
|
||||
#define PRECOMPILE_H
|
||||
|
||||
#if defined __cplusplus
|
||||
// Add C++ includes here
|
||||
#include <QtGui/QtGui>
|
||||
#include <QtOpenGL/QtOpenGL>
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#endif // #ifndef PRECOMPILE_H
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
#include "sidewidget_cheats.h"
|
||||
|
||||
SideWidget_Cheats::SideWidget_Cheats( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
ui.setupUi( this );
|
||||
}
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
#include "sidewidget_cheats.h"
|
||||
|
||||
SideWidget_Cheats::SideWidget_Cheats( QWidget *parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
ui.setupUi( this );
|
||||
}
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
#ifndef SIDEWIDGET_CHEAT_H
|
||||
#define SIDEWIDGET_CHEAT_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
#include "ui_sidewidget_cheats.h"
|
||||
|
||||
class SideWidget_Cheats : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SideWidget_Cheats( QWidget *parent = 0 );
|
||||
|
||||
private:
|
||||
Ui::sidewidget_cheats ui;
|
||||
};
|
||||
|
||||
#endif // #ifndef SIDEWIDGET_CHEAT_H
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
#ifndef SIDEWIDGET_CHEAT_H
|
||||
#define SIDEWIDGET_CHEAT_H
|
||||
|
||||
#include "precompile.h"
|
||||
|
||||
#include "ui_sidewidget_cheats.h"
|
||||
|
||||
class SideWidget_Cheats : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SideWidget_Cheats( QWidget *parent = 0 );
|
||||
|
||||
private:
|
||||
Ui::sidewidget_cheats ui;
|
||||
};
|
||||
|
||||
#endif // #ifndef SIDEWIDGET_CHEAT_H
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
// Windows VERSIONINFO compatible
|
||||
#define VERSION 0,0,0,0
|
||||
|
||||
#define VERSION_STR "SVN"
|
||||
|
||||
#endif
|
||||
// VBA-M, A Nintendo Handheld Console Emulator
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
//
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
// Windows VERSIONINFO compatible
|
||||
#define VERSION 0,0,0,0
|
||||
|
||||
#define VERSION_STR "SVN"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1020,7 +1020,7 @@ void sdlInitVideo() {
|
|||
screenWidth = destWidth;
|
||||
screenHeight = destHeight;
|
||||
}
|
||||
|
||||
|
||||
surface = SDL_SetVideoMode(screenWidth, screenHeight, 0, flags);
|
||||
|
||||
if(surface == NULL) {
|
||||
|
@ -1601,7 +1601,7 @@ int main(int argc, char **argv)
|
|||
|
||||
char buf[1024];
|
||||
struct stat s;
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
// Get home dir
|
||||
homeDir = getenv("HOME");
|
||||
|
@ -2097,7 +2097,7 @@ void drawSpeed(u8 *screen, int pitch, int x, int y)
|
|||
sprintf(buffer, "%3d%%(%d, %d fps)", systemSpeed,
|
||||
systemFrameSkip,
|
||||
showRenderedFrames);
|
||||
|
||||
|
||||
drawText(screen, pitch, x, y, buffer, showSpeedTransparent);
|
||||
}
|
||||
|
||||
|
|
1340
src/sdl/filters.cpp
1340
src/sdl/filters.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,61 +1,61 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004-2008 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_SDL_FILTERS_H
|
||||
#define VBA_SDL_FILTERS_H
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
//
|
||||
// Screen filters
|
||||
//
|
||||
|
||||
// List of available filters
|
||||
enum Filter { kStretch1x, kStretch2x, k2xSaI, kSuper2xSaI, kSuperEagle, kPixelate,
|
||||
kAdMame2x, kBilinear, kBilinearPlus, kScanlines, kScanlinesTV,
|
||||
klq2x, khq2x, kStretch3x, khq3x, kStretch4x, khq4x, kInvalidFilter };
|
||||
|
||||
// Function pointer type for a filter function
|
||||
typedef void(*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int);
|
||||
|
||||
// Initialize a filter and get the corresponding filter function pointer
|
||||
FilterFunc initFilter(const Filter f, const int colorDepth, const int srcWidth);
|
||||
|
||||
// Get the enlarge factor of a filter
|
||||
int getFilterEnlargeFactor(const Filter f);
|
||||
|
||||
// Get the display name for a filter
|
||||
char* getFilterName(const Filter f);
|
||||
|
||||
//
|
||||
// Interframe filters
|
||||
//
|
||||
|
||||
// List of available IFB filters
|
||||
enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter };
|
||||
|
||||
// Function pointer type for an IFB filter function
|
||||
typedef void(*IFBFilterFunc)(u8*, u32, int, int);
|
||||
|
||||
// Initialize an IFB filter and get the corresponding filter function pointer
|
||||
IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth);
|
||||
|
||||
// Get the display name for an IFB filter
|
||||
char* getIFBFilterName(const IFBFilter f);
|
||||
|
||||
#endif // VBA_SDL_FILTERS_H
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004-2008 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef VBA_SDL_FILTERS_H
|
||||
#define VBA_SDL_FILTERS_H
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
//
|
||||
// Screen filters
|
||||
//
|
||||
|
||||
// List of available filters
|
||||
enum Filter { kStretch1x, kStretch2x, k2xSaI, kSuper2xSaI, kSuperEagle, kPixelate,
|
||||
kAdMame2x, kBilinear, kBilinearPlus, kScanlines, kScanlinesTV,
|
||||
klq2x, khq2x, kStretch3x, khq3x, kStretch4x, khq4x, kInvalidFilter };
|
||||
|
||||
// Function pointer type for a filter function
|
||||
typedef void(*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int);
|
||||
|
||||
// Initialize a filter and get the corresponding filter function pointer
|
||||
FilterFunc initFilter(const Filter f, const int colorDepth, const int srcWidth);
|
||||
|
||||
// Get the enlarge factor of a filter
|
||||
int getFilterEnlargeFactor(const Filter f);
|
||||
|
||||
// Get the display name for a filter
|
||||
char* getFilterName(const Filter f);
|
||||
|
||||
//
|
||||
// Interframe filters
|
||||
//
|
||||
|
||||
// List of available IFB filters
|
||||
enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter };
|
||||
|
||||
// Function pointer type for an IFB filter function
|
||||
typedef void(*IFBFilterFunc)(u8*, u32, int, int);
|
||||
|
||||
// Initialize an IFB filter and get the corresponding filter function pointer
|
||||
IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth);
|
||||
|
||||
// Get the display name for an IFB filter
|
||||
char* getIFBFilterName(const IFBFilter f);
|
||||
|
||||
#endif // VBA_SDL_FILTERS_H
|
||||
|
|
2120
src/sdl/getopt.c
2120
src/sdl/getopt.c
File diff suppressed because it is too large
Load Diff
282
src/sdl/getopt.h
282
src/sdl/getopt.h
|
@ -1,141 +1,141 @@
|
|||
/* Declarations for getopt.
|
||||
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
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, 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. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
|
||||
undefined, we haven't run the autoconf check so provide the
|
||||
declaration without arguments. If it is 0, we checked and failed
|
||||
to find the declaration so provide a fully prototyped one. If it
|
||||
is 1, we found it so don't provide any declaration at all. */
|
||||
#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
# if !defined (HAVE_DECL_GETOPT)
|
||||
extern int getopt ();
|
||||
# endif
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* getopt.h */
|
||||
/* Declarations for getopt.
|
||||
Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: The canonical source of this file is maintained with the GNU C Library.
|
||||
Bugs can be reported to bug-glibc@gnu.org.
|
||||
|
||||
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, 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. */
|
||||
|
||||
#ifndef _GETOPT_H
|
||||
#define _GETOPT_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* For communication from `getopt' to the caller.
|
||||
When `getopt' finds an option that takes an argument,
|
||||
the argument value is returned here.
|
||||
Also, when `ordering' is RETURN_IN_ORDER,
|
||||
each non-option ARGV-element is returned here. */
|
||||
|
||||
extern char *optarg;
|
||||
|
||||
/* Index in ARGV of the next element to be scanned.
|
||||
This is used for communication to and from the caller
|
||||
and for communication between successive calls to `getopt'.
|
||||
|
||||
On entry to `getopt', zero means this is the first call; initialize.
|
||||
|
||||
When `getopt' returns -1, this is the index of the first of the
|
||||
non-option elements that the caller should itself scan.
|
||||
|
||||
Otherwise, `optind' communicates from one call to the next
|
||||
how much of ARGV has been scanned so far. */
|
||||
|
||||
extern int optind;
|
||||
|
||||
/* Callers store zero here to inhibit the error message `getopt' prints
|
||||
for unrecognized options. */
|
||||
|
||||
extern int opterr;
|
||||
|
||||
/* Set to an option character which was unrecognized. */
|
||||
|
||||
extern int optopt;
|
||||
|
||||
/* Describe the long-named options requested by the application.
|
||||
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
|
||||
of `struct option' terminated by an element containing a name which is
|
||||
zero.
|
||||
|
||||
The field `has_arg' is:
|
||||
no_argument (or 0) if the option does not take an argument,
|
||||
required_argument (or 1) if the option requires an argument,
|
||||
optional_argument (or 2) if the option takes an optional argument.
|
||||
|
||||
If the field `flag' is not NULL, it points to a variable that is set
|
||||
to the value given in the field `val' when the option is found, but
|
||||
left unchanged if the option is not found.
|
||||
|
||||
To have a long-named option do something other than set an `int' to
|
||||
a compiled-in constant, such as set a value from `optarg', set the
|
||||
option's `flag' field to zero and its `val' field to a nonzero
|
||||
value (the equivalent single-letter option character, if there is
|
||||
one). For long options that have a zero `flag' field, `getopt'
|
||||
returns the contents of the `val' field. */
|
||||
|
||||
struct option
|
||||
{
|
||||
#if defined (__STDC__) && __STDC__
|
||||
const char *name;
|
||||
#else
|
||||
char *name;
|
||||
#endif
|
||||
/* has_arg can't be an enum because some compilers complain about
|
||||
type mismatches in all the code that assumes it is an int. */
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
/* Names for the values of the `has_arg' field of `struct option'. */
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#if defined (__STDC__) && __STDC__
|
||||
/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
|
||||
undefined, we haven't run the autoconf check so provide the
|
||||
declaration without arguments. If it is 0, we checked and failed
|
||||
to find the declaration so provide a fully prototyped one. If it
|
||||
is 1, we found it so don't provide any declaration at all. */
|
||||
#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
|
||||
/* Many other libraries have conflicting prototypes for getopt, with
|
||||
differences in the consts, in stdlib.h. To avoid compilation
|
||||
errors, only prototype getopt for the GNU C library. */
|
||||
extern int getopt (int argc, char *const *argv, const char *shortopts);
|
||||
#else /* not __GNU_LIBRARY__ */
|
||||
# if !defined (HAVE_DECL_GETOPT)
|
||||
extern int getopt ();
|
||||
# endif
|
||||
#endif /* __GNU_LIBRARY__ */
|
||||
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
extern int getopt_long_only (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
/* Internal only. Users should not call this directly. */
|
||||
extern int _getopt_internal (int argc, char *const *argv,
|
||||
const char *shortopts,
|
||||
const struct option *longopts, int *longind,
|
||||
int long_only);
|
||||
#else /* not __STDC__ */
|
||||
extern int getopt ();
|
||||
extern int getopt_long ();
|
||||
extern int getopt_long_only ();
|
||||
|
||||
extern int _getopt_internal ();
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* getopt.h */
|
||||
|
|
|
@ -1,190 +1,190 @@
|
|||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: This source is derived from an old version taken from the GNU C
|
||||
Library (glibc).
|
||||
|
||||
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, 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. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
NOTE: This source is derived from an old version taken from the GNU C
|
||||
Library (glibc).
|
||||
|
||||
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, 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. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#if !defined __STDC__ || !__STDC__
|
||||
/* This is a separate conditional since some stdc systems
|
||||
reject `defined (const)'. */
|
||||
#ifndef const
|
||||
#define const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
actually compiling the library itself. This code is part of the GNU C
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
and linking in this code is a waste when using the GNU C library
|
||||
(especially if it is a shared library). Rather than having every GNU
|
||||
program understand `configure --with-gnu-libc' and omit the object files,
|
||||
it is simpler to just do this in the source for each such file. */
|
||||
|
||||
#define GETOPT_INTERFACE_VERSION 2
|
||||
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
|
||||
#include <gnu-versions.h>
|
||||
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
|
||||
#define ELIDE_CODE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ELIDE_CODE
|
||||
|
||||
|
||||
/* This needs to come after some library #include
|
||||
to get __GNU_LIBRARY__ defined. */
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
int
|
||||
getopt_long (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
|
||||
}
|
||||
|
||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||
If an option that starts with '-' (not '--') doesn't match a long option,
|
||||
but does match a short option, it is parsed as a short option
|
||||
instead. */
|
||||
|
||||
int
|
||||
getopt_long_only (argc, argv, options, long_options, opt_index)
|
||||
int argc;
|
||||
char *const *argv;
|
||||
const char *options;
|
||||
const struct option *long_options;
|
||||
int *opt_index;
|
||||
{
|
||||
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
|
||||
}
|
||||
|
||||
|
||||
#endif /* Not ELIDE_CODE. */
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int c;
|
||||
int digit_optind = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int this_option_optind = optind ? optind : 1;
|
||||
int option_index = 0;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"add", 1, 0, 0},
|
||||
{"append", 0, 0, 0},
|
||||
{"delete", 1, 0, 0},
|
||||
{"verbose", 0, 0, 0},
|
||||
{"create", 0, 0, 0},
|
||||
{"file", 1, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 0:
|
||||
printf ("option %s", long_options[option_index].name);
|
||||
if (optarg)
|
||||
printf (" with arg %s", optarg);
|
||||
printf ("\n");
|
||||
break;
|
||||
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||
printf ("digits occur in two different argv-elements.\n");
|
||||
digit_optind = this_option_optind;
|
||||
printf ("option %c\n", c);
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
printf ("option a\n");
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
printf ("option b\n");
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf ("option c with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
printf ("option d with value `%s'\n", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
printf ("non-option ARGV-elements: ");
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
|
|
296
src/sdl/text.cpp
296
src/sdl/text.cpp
|
@ -1,148 +1,148 @@
|
|||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Ben Parnell
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Code originally from fceu/drawing.h file, adapted by Forgotten
|
||||
*/
|
||||
#include "../System.h"
|
||||
|
||||
extern int RGB_LOW_BITS_MASK;
|
||||
|
||||
static const u8 fontdata2[2048] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e,0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e,0x36,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x1c,0x3e,0x1c,0x7f,0x7f,0x3e,0x1c,0x3e,0x08,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x3e,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xf0,0xe0,0xf0,0xbe,0x33,0x33,0x33,0x1e,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0xfc,0xcc,0xfc,0x0c,0x0c,0x0e,0x0f,0x07,0xfe,0xc6,0xfe,0xc6,0xc6,0xe6,0x67,0x03,0x99,0x5a,0x3c,0xe7,0xe7,0x3c,0x5a,0x99,0x01,0x07,0x1f,0x7f,0x1f,0x07,0x01,0x00,0x40,0x70,0x7c,0x7f,0x7c,0x70,0x40,0x00,0x18,0x3c,0x7e,0x18,0x18,0x7e,0x3c,0x18,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,0xfe,0xdb,0xdb,0xde,0xd8,0xd8,0xd8,0x00,0x7c,0xc6,0x1c,0x36,0x36,0x1c,0x33,0x1e,0x00,0x00,0x00,0x00,0x7e,0x7e,0x7e,0x00,0x18,0x3c,0x7e,0x18,0x7e,0x3c,0x18,0xff,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x18,0x30,0x7f,0x30,0x18,0x00,0x00,0x00,0x0c,0x06,0x7f,0x06,0x0c,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0x7e,0x3c,0x18,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x1e,0x1e,0x0c,0x0c,0x00,0x0c,0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7f,0x36,0x7f,0x36,0x36,0x00,0x0c,0x3e,0x03,0x1e,0x30,0x1f,0x0c,0x00,0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00,0x1c,0x36,0x1c,0x6e,0x3b,0x33,0x6e,0x00,0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0x06,0x06,0x06,0x0c,0x18,0x00,0x06,0x0c,0x18,0x18,0x18,0x0c,0x06,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x06,0x00,0x00,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00,0x3e,0x63,0x73,0x7b,0x6f,0x67,0x3e,0x00,0x0c,0x0e,0x0c,0x0c,0x0c,0x0c,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x06,0x33,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x30,0x33,0x1e,0x00,0x38,0x3c,0x36,0x33,0x7f,0x30,0x78,0x00,0x3f,0x03,0x1f,0x30,0x30,0x33,0x1e,0x00,0x1c,0x06,0x03,0x1f,0x33,0x33,0x1e,0x00,0x3f,0x33,0x30,0x18,0x0c,0x0c,0x0c,0x00,0x1e,0x33,0x33,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x33,0x3e,0x30,0x18,0x0e,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x06,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x00,0x00,0x00,0x3f,0x00,0x00,0x3f,0x00,0x00,0x06,0x0c,0x18,0x30,0x18,0x0c,0x06,0x00,0x1e,0x33,0x30,0x18,0x0c,0x00,0x0c,0x00,
|
||||
0x3e,0x63,0x7b,0x7b,0x7b,0x03,0x1e,0x00,0x0c,0x1e,0x33,0x33,0x3f,0x33,0x33,0x00,0x3f,0x66,0x66,0x3e,0x66,0x66,0x3f,0x00,0x3c,0x66,0x03,0x03,0x03,0x66,0x3c,0x00,0x1f,0x36,0x66,0x66,0x66,0x36,0x1f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x46,0x7f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x06,0x0f,0x00,0x3c,0x66,0x03,0x03,0x73,0x66,0x7c,0x00,0x33,0x33,0x33,0x3f,0x33,0x33,0x33,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x78,0x30,0x30,0x30,0x33,0x33,0x1e,0x00,0x67,0x66,0x36,0x1e,0x36,0x66,0x67,0x00,0x0f,0x06,0x06,0x06,0x46,0x66,0x7f,0x00,0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x00,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x00,0x1c,0x36,0x63,0x63,0x63,0x36,0x1c,0x00,0x3f,0x66,0x66,0x3e,0x06,0x06,0x0f,0x00,0x1e,0x33,0x33,0x33,0x3b,0x1e,0x38,0x00,0x3f,0x66,0x66,0x3e,0x36,0x66,0x67,0x00,0x1e,0x33,0x07,0x0e,0x38,0x33,0x1e,0x00,0x3f,0x2d,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x00,0x33,0x33,0x33,0x33,0x33,0x1e,0x0c,0x00,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00,0x33,0x33,0x33,0x1e,0x0c,0x0c,0x1e,0x00,0x7f,0x63,0x31,0x18,0x4c,0x66,0x7f,0x00,0x1e,0x06,0x06,0x06,0x06,0x06,0x1e,0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00,0x1e,0x18,0x18,0x18,0x18,0x18,0x1e,0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
|
||||
0x0c,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x30,0x3e,0x33,0x6e,0x00,0x07,0x06,0x06,0x3e,0x66,0x66,0x3b,0x00,0x00,0x00,0x1e,0x33,0x03,0x33,0x1e,0x00,0x38,0x30,0x30,0x3e,0x33,0x33,0x6e,0x00,0x00,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x1c,0x36,0x06,0x0f,0x06,0x06,0x0f,0x00,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x1f,0x07,0x06,0x36,0x6e,0x66,0x66,0x67,0x00,0x0c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x30,0x00,0x30,0x30,0x30,0x33,0x33,0x1e,0x07,0x06,0x66,0x36,0x1e,0x36,0x67,0x00,0x0e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x33,0x7f,0x7f,0x6b,0x63,0x00,0x00,0x00,0x1f,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x1e,0x33,0x33,0x33,0x1e,0x00,0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x0f,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x78,0x00,0x00,0x3b,0x6e,0x66,0x06,0x0f,0x00,0x00,0x00,0x3e,0x03,0x1e,0x30,0x1f,0x00,0x08,0x0c,0x3e,0x0c,0x0c,0x2c,0x18,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x6e,0x00,0x00,0x00,0x33,0x33,0x33,0x1e,0x0c,0x00,0x00,0x00,0x63,0x6b,0x7f,0x7f,0x36,0x00,0x00,0x00,0x63,0x36,0x1c,0x36,0x63,0x00,0x00,0x00,0x33,0x33,0x33,0x3e,0x30,0x1f,0x00,0x00,0x3f,0x19,0x0c,0x26,0x3f,0x00,0x38,0x0c,0x0c,0x07,0x0c,0x0c,0x38,0x00,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x07,0x0c,0x0c,0x38,0x0c,0x0c,0x07,0x00,0x6e,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00,
|
||||
0x1e,0x33,0x03,0x33,0x1e,0x18,0x30,0x1e,0x00,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x38,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x7e,0xc3,0x3c,0x60,0x7c,0x66,0xfc,0x00,0x33,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x07,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x0c,0x0c,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x00,0x00,0x1e,0x03,0x03,0x1e,0x30,0x1c,0x7e,0xc3,0x3c,0x66,0x7e,0x06,0x3c,0x00,0x33,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x07,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x33,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x3e,0x63,0x1c,0x18,0x18,0x18,0x3c,0x00,0x07,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x63,0x1c,0x36,0x63,0x7f,0x63,0x63,0x00,0x0c,0x0c,0x00,0x1e,0x33,0x3f,0x33,0x00,0x38,0x00,0x3f,0x06,0x1e,0x06,0x3f,0x00,0x00,0x00,0xfe,0x30,0xfe,0x33,0xfe,0x00,0x7c,0x36,0x33,0x7f,0x33,0x33,0x73,0x00,0x1e,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x07,0x00,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x07,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x33,0x00,0x33,0x33,0x3e,0x30,0x1f,0xc3,0x18,0x3c,0x66,0x66,0x3c,0x18,0x00,0x33,0x00,0x33,0x33,0x33,0x33,0x1e,0x00,0x18,0x18,0x7e,0x03,0x03,0x7e,0x18,0x18,0x1c,0x36,0x26,0x0f,0x06,0x67,0x3f,0x00,0x33,0x33,0x1e,0x3f,0x0c,0x3f,0x0c,0x0c,0x1f,0x33,0x33,0x5f,0x63,0xf3,0x63,0xe3,0x70,0xd8,0x18,0x3c,0x18,0x18,0x1b,0x0e,
|
||||
0x38,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x1c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x38,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x38,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x1f,0x00,0x1f,0x33,0x33,0x33,0x00,0x3f,0x00,0x33,0x37,0x3f,0x3b,0x33,0x00,0x3c,0x36,0x36,0x7c,0x00,0x7e,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x3e,0x00,0x00,0x0c,0x00,0x0c,0x06,0x03,0x33,0x1e,0x00,0x00,0x00,0x00,0x3f,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x30,0x00,0x00,0xc3,0x63,0x33,0x7b,0xcc,0x66,0x33,0xf0,0xc3,0x63,0x33,0xdb,0xec,0xf6,0xf3,0xc0,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0xcc,0x66,0x33,0x66,0xcc,0x00,0x00,0x00,0x33,0x66,0xcc,0x66,0x33,0x00,0x00,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xdb,0xee,0xdb,0x77,0xdb,0xee,0xdb,0x77,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0x6f,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x7f,0x6c,0x6c,0x6c,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x7f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6f,0x60,0x7f,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0x7f,0x00,0x00,0x00,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,
|
||||
0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0x0c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xef,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xec,0x6c,0x6c,0x6c,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0xef,0x00,0xef,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xfc,0x00,0x00,0x00,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xfc,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xff,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x6e,0x3b,0x13,0x3b,0x6e,0x00,0x00,0x1e,0x33,0x1f,0x33,0x1f,0x03,0x03,0x00,0x3f,0x33,0x03,0x03,0x03,0x03,0x00,0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00,0x3f,0x33,0x06,0x0c,0x06,0x33,0x3f,0x00,0x00,0x00,0x7e,0x1b,0x1b,0x1b,0x0e,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x06,0x03,0x00,0x6e,0x3b,0x18,0x18,0x18,0x18,0x00,0x3f,0x0c,0x1e,0x33,0x33,0x1e,0x0c,0x3f,0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00,0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x38,0x0c,0x18,0x3e,0x33,0x33,0x1e,0x00,0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00,0x60,0x30,0x7e,0xdb,0xdb,0x7e,0x06,0x03,0x1c,0x06,0x03,0x1f,0x03,0x06,0x1c,0x00,0x1e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x3f,0x00,0x3f,0x00,0x3f,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x3f,0x00,0x06,0x0c,0x18,0x0c,0x06,0x00,0x3f,0x00,0x18,0x0c,0x06,0x0c,0x18,0x00,0x3f,0x00,0x70,0xd8,0xd8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x0e,0x0c,0x0c,0x00,0x3f,0x00,0x0c,0x0c,0x00,0x00,0x6e,0x3b,0x00,0x6e,0x3b,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xf0,0x30,0x30,0x30,0x37,0x36,0x3c,0x38,0x1e,0x36,0x36,0x36,0x36,0x00,0x00,0x00,0x0e,0x18,0x0c,0x06,0x1e,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
|
||||
void drawText(u8 *screen, int pitch, int x, int y,
|
||||
const char *string, bool trans)
|
||||
{
|
||||
screen += y*pitch;
|
||||
int inc = 2;
|
||||
switch(systemColorDepth) {
|
||||
case 24:
|
||||
inc = 3;
|
||||
break;
|
||||
case 32:
|
||||
inc = 4;
|
||||
break;
|
||||
}
|
||||
screen += x*inc;
|
||||
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
u16 mask = ~RGB_LOW_BITS_MASK;
|
||||
int h, w;
|
||||
u16 *s = (u16 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s++) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
if(trans) {
|
||||
if(on)
|
||||
*s = ((0xf) << systemRedShift) +
|
||||
((*s & mask) >>1);
|
||||
} else {
|
||||
if(on)
|
||||
*s = (0x1f) << systemRedShift;
|
||||
}
|
||||
}
|
||||
scr += pitch;
|
||||
s = (u16 *)scr;
|
||||
}
|
||||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
int h, w;
|
||||
u8 *s = (u8 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s+=3) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
if(trans) {
|
||||
if(on) {
|
||||
u32 color = (0x1f) << systemRedShift;
|
||||
*s = ((color & 255)>>1)+(*s>>1);
|
||||
*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
|
||||
*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
|
||||
}
|
||||
} else {
|
||||
if(on) {
|
||||
u32 color = (0x1f) << systemRedShift;
|
||||
*s = (color & 255);
|
||||
*(s+1) = (color >> 8) & 255;
|
||||
*(s+2) = (color >> 16) & 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
scr += pitch;
|
||||
s = (u8 *)scr;
|
||||
}
|
||||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
int h, w;
|
||||
u32 mask = 0xfefefe;
|
||||
u32 *s = (u32 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s++) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
if(trans) {
|
||||
if(on)
|
||||
*s = ((0xf) << systemRedShift) + ((*s & mask)>>1);
|
||||
} else {
|
||||
if(on)
|
||||
*s = (0x1f) << systemRedShift;
|
||||
}
|
||||
}
|
||||
scr += pitch;
|
||||
s = (u32 *)scr;
|
||||
}
|
||||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2002 Ben Parnell
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* Code originally from fceu/drawing.h file, adapted by Forgotten
|
||||
*/
|
||||
#include "../System.h"
|
||||
|
||||
extern int RGB_LOW_BITS_MASK;
|
||||
|
||||
static const u8 fontdata2[2048] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x81,0xa5,0x81,0xbd,0x99,0x81,0x7e,0x7e,0xff,0xdb,0xff,0xc3,0xe7,0xff,0x7e,0x36,0x7f,0x7f,0x7f,0x3e,0x1c,0x08,0x00,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x08,0x00,0x1c,0x3e,0x1c,0x7f,0x7f,0x3e,0x1c,0x3e,0x08,0x08,0x1c,0x3e,0x7f,0x3e,0x1c,0x3e,0x00,0x00,0x18,0x3c,0x3c,0x18,0x00,0x00,0xff,0xff,0xe7,0xc3,0xc3,0xe7,0xff,0xff,0x00,0x3c,0x66,0x42,0x42,0x66,0x3c,0x00,0xff,0xc3,0x99,0xbd,0xbd,0x99,0xc3,0xff,0xf0,0xe0,0xf0,0xbe,0x33,0x33,0x33,0x1e,0x3c,0x66,0x66,0x66,0x3c,0x18,0x7e,0x18,0xfc,0xcc,0xfc,0x0c,0x0c,0x0e,0x0f,0x07,0xfe,0xc6,0xfe,0xc6,0xc6,0xe6,0x67,0x03,0x99,0x5a,0x3c,0xe7,0xe7,0x3c,0x5a,0x99,0x01,0x07,0x1f,0x7f,0x1f,0x07,0x01,0x00,0x40,0x70,0x7c,0x7f,0x7c,0x70,0x40,0x00,0x18,0x3c,0x7e,0x18,0x18,0x7e,0x3c,0x18,0x66,0x66,0x66,0x66,0x66,0x00,0x66,0x00,0xfe,0xdb,0xdb,0xde,0xd8,0xd8,0xd8,0x00,0x7c,0xc6,0x1c,0x36,0x36,0x1c,0x33,0x1e,0x00,0x00,0x00,0x00,0x7e,0x7e,0x7e,0x00,0x18,0x3c,0x7e,0x18,0x7e,0x3c,0x18,0xff,0x18,0x3c,0x7e,0x18,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x7e,0x3c,0x18,0x00,0x00,0x18,0x30,0x7f,0x30,0x18,0x00,0x00,0x00,0x0c,0x06,0x7f,0x06,0x0c,0x00,0x00,0x00,0x00,0x03,0x03,0x03,0x7f,0x00,0x00,0x00,0x24,0x66,0xff,0x66,0x24,0x00,0x00,0x00,0x18,0x3c,0x7e,0xff,0xff,0x00,0x00,0x00,0xff,0xff,0x7e,0x3c,0x18,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x1e,0x1e,0x0c,0x0c,0x00,0x0c,0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7f,0x36,0x7f,0x36,0x36,0x00,0x0c,0x3e,0x03,0x1e,0x30,0x1f,0x0c,0x00,0x00,0x63,0x33,0x18,0x0c,0x66,0x63,0x00,0x1c,0x36,0x1c,0x6e,0x3b,0x33,0x6e,0x00,0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x18,0x0c,0x06,0x06,0x06,0x0c,0x18,0x00,0x06,0x0c,0x18,0x18,0x18,0x0c,0x06,0x00,0x00,0x66,0x3c,0xff,0x3c,0x66,0x00,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x06,0x00,0x00,0x00,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00,0x3e,0x63,0x73,0x7b,0x6f,0x67,0x3e,0x00,0x0c,0x0e,0x0c,0x0c,0x0c,0x0c,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x06,0x33,0x3f,0x00,0x1e,0x33,0x30,0x1c,0x30,0x33,0x1e,0x00,0x38,0x3c,0x36,0x33,0x7f,0x30,0x78,0x00,0x3f,0x03,0x1f,0x30,0x30,0x33,0x1e,0x00,0x1c,0x06,0x03,0x1f,0x33,0x33,0x1e,0x00,0x3f,0x33,0x30,0x18,0x0c,0x0c,0x0c,0x00,0x1e,0x33,0x33,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x33,0x3e,0x30,0x18,0x0e,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x00,0x00,0x0c,0x0c,0x06,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x00,0x00,0x00,0x3f,0x00,0x00,0x3f,0x00,0x00,0x06,0x0c,0x18,0x30,0x18,0x0c,0x06,0x00,0x1e,0x33,0x30,0x18,0x0c,0x00,0x0c,0x00,
|
||||
0x3e,0x63,0x7b,0x7b,0x7b,0x03,0x1e,0x00,0x0c,0x1e,0x33,0x33,0x3f,0x33,0x33,0x00,0x3f,0x66,0x66,0x3e,0x66,0x66,0x3f,0x00,0x3c,0x66,0x03,0x03,0x03,0x66,0x3c,0x00,0x1f,0x36,0x66,0x66,0x66,0x36,0x1f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x46,0x7f,0x00,0x7f,0x46,0x16,0x1e,0x16,0x06,0x0f,0x00,0x3c,0x66,0x03,0x03,0x73,0x66,0x7c,0x00,0x33,0x33,0x33,0x3f,0x33,0x33,0x33,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x78,0x30,0x30,0x30,0x33,0x33,0x1e,0x00,0x67,0x66,0x36,0x1e,0x36,0x66,0x67,0x00,0x0f,0x06,0x06,0x06,0x46,0x66,0x7f,0x00,0x63,0x77,0x7f,0x7f,0x6b,0x63,0x63,0x00,0x63,0x67,0x6f,0x7b,0x73,0x63,0x63,0x00,0x1c,0x36,0x63,0x63,0x63,0x36,0x1c,0x00,0x3f,0x66,0x66,0x3e,0x06,0x06,0x0f,0x00,0x1e,0x33,0x33,0x33,0x3b,0x1e,0x38,0x00,0x3f,0x66,0x66,0x3e,0x36,0x66,0x67,0x00,0x1e,0x33,0x07,0x0e,0x38,0x33,0x1e,0x00,0x3f,0x2d,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x33,0x33,0x33,0x33,0x33,0x33,0x3f,0x00,0x33,0x33,0x33,0x33,0x33,0x1e,0x0c,0x00,0x63,0x63,0x63,0x6b,0x7f,0x77,0x63,0x00,0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x00,0x33,0x33,0x33,0x1e,0x0c,0x0c,0x1e,0x00,0x7f,0x63,0x31,0x18,0x4c,0x66,0x7f,0x00,0x1e,0x06,0x06,0x06,0x06,0x06,0x1e,0x00,0x03,0x06,0x0c,0x18,0x30,0x60,0x40,0x00,0x1e,0x18,0x18,0x18,0x18,0x18,0x1e,0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
|
||||
0x0c,0x0c,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x30,0x3e,0x33,0x6e,0x00,0x07,0x06,0x06,0x3e,0x66,0x66,0x3b,0x00,0x00,0x00,0x1e,0x33,0x03,0x33,0x1e,0x00,0x38,0x30,0x30,0x3e,0x33,0x33,0x6e,0x00,0x00,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x1c,0x36,0x06,0x0f,0x06,0x06,0x0f,0x00,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x1f,0x07,0x06,0x36,0x6e,0x66,0x66,0x67,0x00,0x0c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x30,0x00,0x30,0x30,0x30,0x33,0x33,0x1e,0x07,0x06,0x66,0x36,0x1e,0x36,0x67,0x00,0x0e,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x33,0x7f,0x7f,0x6b,0x63,0x00,0x00,0x00,0x1f,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x1e,0x33,0x33,0x33,0x1e,0x00,0x00,0x00,0x3b,0x66,0x66,0x3e,0x06,0x0f,0x00,0x00,0x6e,0x33,0x33,0x3e,0x30,0x78,0x00,0x00,0x3b,0x6e,0x66,0x06,0x0f,0x00,0x00,0x00,0x3e,0x03,0x1e,0x30,0x1f,0x00,0x08,0x0c,0x3e,0x0c,0x0c,0x2c,0x18,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x6e,0x00,0x00,0x00,0x33,0x33,0x33,0x1e,0x0c,0x00,0x00,0x00,0x63,0x6b,0x7f,0x7f,0x36,0x00,0x00,0x00,0x63,0x36,0x1c,0x36,0x63,0x00,0x00,0x00,0x33,0x33,0x33,0x3e,0x30,0x1f,0x00,0x00,0x3f,0x19,0x0c,0x26,0x3f,0x00,0x38,0x0c,0x0c,0x07,0x0c,0x0c,0x38,0x00,0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,0x07,0x0c,0x0c,0x38,0x0c,0x0c,0x07,0x00,0x6e,0x3b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00,
|
||||
0x1e,0x33,0x03,0x33,0x1e,0x18,0x30,0x1e,0x00,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x38,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x7e,0xc3,0x3c,0x60,0x7c,0x66,0xfc,0x00,0x33,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x07,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x0c,0x0c,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x00,0x00,0x1e,0x03,0x03,0x1e,0x30,0x1c,0x7e,0xc3,0x3c,0x66,0x7e,0x06,0x3c,0x00,0x33,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x07,0x00,0x1e,0x33,0x3f,0x03,0x1e,0x00,0x33,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x3e,0x63,0x1c,0x18,0x18,0x18,0x3c,0x00,0x07,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x63,0x1c,0x36,0x63,0x7f,0x63,0x63,0x00,0x0c,0x0c,0x00,0x1e,0x33,0x3f,0x33,0x00,0x38,0x00,0x3f,0x06,0x1e,0x06,0x3f,0x00,0x00,0x00,0xfe,0x30,0xfe,0x33,0xfe,0x00,0x7c,0x36,0x33,0x7f,0x33,0x33,0x73,0x00,0x1e,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x33,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x07,0x00,0x1e,0x33,0x33,0x1e,0x00,0x1e,0x33,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x07,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x33,0x00,0x33,0x33,0x3e,0x30,0x1f,0xc3,0x18,0x3c,0x66,0x66,0x3c,0x18,0x00,0x33,0x00,0x33,0x33,0x33,0x33,0x1e,0x00,0x18,0x18,0x7e,0x03,0x03,0x7e,0x18,0x18,0x1c,0x36,0x26,0x0f,0x06,0x67,0x3f,0x00,0x33,0x33,0x1e,0x3f,0x0c,0x3f,0x0c,0x0c,0x1f,0x33,0x33,0x5f,0x63,0xf3,0x63,0xe3,0x70,0xd8,0x18,0x3c,0x18,0x18,0x1b,0x0e,
|
||||
0x38,0x00,0x1e,0x30,0x3e,0x33,0x7e,0x00,0x1c,0x00,0x0e,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x38,0x00,0x1e,0x33,0x33,0x1e,0x00,0x00,0x38,0x00,0x33,0x33,0x33,0x7e,0x00,0x00,0x1f,0x00,0x1f,0x33,0x33,0x33,0x00,0x3f,0x00,0x33,0x37,0x3f,0x3b,0x33,0x00,0x3c,0x36,0x36,0x7c,0x00,0x7e,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x3e,0x00,0x00,0x0c,0x00,0x0c,0x06,0x03,0x33,0x1e,0x00,0x00,0x00,0x00,0x3f,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x3f,0x30,0x30,0x00,0x00,0xc3,0x63,0x33,0x7b,0xcc,0x66,0x33,0xf0,0xc3,0x63,0x33,0xdb,0xec,0xf6,0xf3,0xc0,0x18,0x18,0x00,0x18,0x18,0x18,0x18,0x00,0x00,0xcc,0x66,0x33,0x66,0xcc,0x00,0x00,0x00,0x33,0x66,0xcc,0x66,0x33,0x00,0x00,0x44,0x11,0x44,0x11,0x44,0x11,0x44,0x11,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xdb,0xee,0xdb,0x77,0xdb,0xee,0xdb,0x77,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x18,0x18,0x18,0x18,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0x6f,0x6c,0x6c,0x6c,0x00,0x00,0x00,0x00,0x7f,0x6c,0x6c,0x6c,0x00,0x00,0x1f,0x18,0x1f,0x18,0x18,0x18,0x6c,0x6c,0x6f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x7f,0x60,0x6f,0x6c,0x6c,0x6c,0x6c,0x6c,0x6f,0x60,0x7f,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0x7f,0x00,0x00,0x00,0x18,0x18,0x1f,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0x18,0x18,0x18,
|
||||
0x18,0x18,0x18,0x18,0xf8,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x18,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0xf8,0x18,0xf8,0x18,0x18,0x18,0x6c,0x6c,0x6c,0x6c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0x0c,0xec,0x6c,0x6c,0x6c,0x6c,0x6c,0xef,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xef,0x6c,0x6c,0x6c,0x6c,0x6c,0xec,0x0c,0xec,0x6c,0x6c,0x6c,0x00,0x00,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0xef,0x00,0xef,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x00,0xff,0x00,0x00,0x00,0x6c,0x6c,0x6c,0x6c,0xff,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xff,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xfc,0x00,0x00,0x00,0x18,0x18,0xf8,0x18,0xf8,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0xf8,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0xfc,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0xff,0x6c,0x6c,0x6c,0x18,0x18,0xff,0x18,0xff,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x18,0x18,0x18,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x6e,0x3b,0x13,0x3b,0x6e,0x00,0x00,0x1e,0x33,0x1f,0x33,0x1f,0x03,0x03,0x00,0x3f,0x33,0x03,0x03,0x03,0x03,0x00,0x00,0x7f,0x36,0x36,0x36,0x36,0x36,0x00,0x3f,0x33,0x06,0x0c,0x06,0x33,0x3f,0x00,0x00,0x00,0x7e,0x1b,0x1b,0x1b,0x0e,0x00,0x00,0x66,0x66,0x66,0x66,0x3e,0x06,0x03,0x00,0x6e,0x3b,0x18,0x18,0x18,0x18,0x00,0x3f,0x0c,0x1e,0x33,0x33,0x1e,0x0c,0x3f,0x1c,0x36,0x63,0x7f,0x63,0x36,0x1c,0x00,0x1c,0x36,0x63,0x63,0x36,0x36,0x77,0x00,0x38,0x0c,0x18,0x3e,0x33,0x33,0x1e,0x00,0x00,0x00,0x7e,0xdb,0xdb,0x7e,0x00,0x00,0x60,0x30,0x7e,0xdb,0xdb,0x7e,0x06,0x03,0x1c,0x06,0x03,0x1f,0x03,0x06,0x1c,0x00,0x1e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x3f,0x00,0x3f,0x00,0x3f,0x00,0x00,0x0c,0x0c,0x3f,0x0c,0x0c,0x00,0x3f,0x00,0x06,0x0c,0x18,0x0c,0x06,0x00,0x3f,0x00,0x18,0x0c,0x06,0x0c,0x18,0x00,0x3f,0x00,0x70,0xd8,0xd8,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x0e,0x0c,0x0c,0x00,0x3f,0x00,0x0c,0x0c,0x00,0x00,0x6e,0x3b,0x00,0x6e,0x3b,0x00,0x00,0x1c,0x36,0x36,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0xf0,0x30,0x30,0x30,0x37,0x36,0x3c,0x38,0x1e,0x36,0x36,0x36,0x36,0x00,0x00,0x00,0x0e,0x18,0x0c,0x06,0x1e,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
|
||||
void drawText(u8 *screen, int pitch, int x, int y,
|
||||
const char *string, bool trans)
|
||||
{
|
||||
screen += y*pitch;
|
||||
int inc = 2;
|
||||
switch(systemColorDepth) {
|
||||
case 24:
|
||||
inc = 3;
|
||||
break;
|
||||
case 32:
|
||||
inc = 4;
|
||||
break;
|
||||
}
|
||||
screen += x*inc;
|
||||
|
||||
switch(systemColorDepth) {
|
||||
case 16:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
u16 mask = ~RGB_LOW_BITS_MASK;
|
||||
int h, w;
|
||||
u16 *s = (u16 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s++) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
if(trans) {
|
||||
if(on)
|
||||
*s = ((0xf) << systemRedShift) +
|
||||
((*s & mask) >>1);
|
||||
} else {
|
||||
if(on)
|
||||
*s = (0x1f) << systemRedShift;
|
||||
}
|
||||
}
|
||||
scr += pitch;
|
||||
s = (u16 *)scr;
|
||||
}
|
||||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
int h, w;
|
||||
u8 *s = (u8 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s+=3) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
if(trans) {
|
||||
if(on) {
|
||||
u32 color = (0x1f) << systemRedShift;
|
||||
*s = ((color & 255)>>1)+(*s>>1);
|
||||
*(s+1) = (((color >> 8) & 255)>>1)+(*(s+1)>>1);
|
||||
*(s+2) = (((color >> 16) & 255)>>1)+(*(s+2)>>1);
|
||||
}
|
||||
} else {
|
||||
if(on) {
|
||||
u32 color = (0x1f) << systemRedShift;
|
||||
*s = (color & 255);
|
||||
*(s+1) = (color >> 8) & 255;
|
||||
*(s+2) = (color >> 16) & 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
scr += pitch;
|
||||
s = (u8 *)scr;
|
||||
}
|
||||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
{
|
||||
while(*string) {
|
||||
char c = *string++;
|
||||
u8 *scr = screen;
|
||||
|
||||
int h, w;
|
||||
u32 mask = 0xfefefe;
|
||||
u32 *s = (u32 *)scr;
|
||||
for (h = 0; h < 8; h++) {
|
||||
for (w = 0; w < 8; w++, s++) {
|
||||
int on = (fontdata2[(c<<3)+h]>>w)&1;
|
||||
|
||||
if(trans) {
|
||||
if(on)
|
||||
*s = ((0xf) << systemRedShift) + ((*s & mask)>>1);
|
||||
} else {
|
||||
if(on)
|
||||
*s = (0x1f) << systemRedShift;
|
||||
}
|
||||
}
|
||||
scr += pitch;
|
||||
s = (u32 *)scr;
|
||||
}
|
||||
screen += inc*8;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
extern void drawText(u8 *, int, int, int, const char *, bool);
|
||||
// -*- C++ -*-
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 1999-2003 Forgotten
|
||||
// Copyright (C) 2004 Forgotten and the VBA development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
extern void drawText(u8 *, int, int, int, const char *, bool);
|
||||
|
|
|
@ -137,7 +137,7 @@ bool AVIWrite::CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorB
|
|||
settings[0],
|
||||
NULL
|
||||
);
|
||||
|
||||
|
||||
AVISaveOptionsFree( 1, settings );
|
||||
if( FAILED( err ) ) {
|
||||
m_failed = true;
|
||||
|
@ -293,7 +293,7 @@ bool AVIWrite::AddAudioFrame( LPVOID soundData )
|
|||
m_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
m_sampleCounter += m_audioFrameSize / m_audioBlockAlign;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,107 +1,107 @@
|
|||
#include "stdafx.h"
|
||||
#include "BIOSDialog.h"
|
||||
|
||||
|
||||
// BIOSDialog dialog
|
||||
|
||||
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
|
||||
|
||||
BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(BIOSDialog::IDD, pParent)
|
||||
, m_enableBIOS_GB(FALSE)
|
||||
, m_enableBIOS_GBA(FALSE)
|
||||
, m_skipLogo(FALSE)
|
||||
, m_pathGB(_T(""))
|
||||
, m_pathGBA(_T(""))
|
||||
{
|
||||
}
|
||||
|
||||
BIOSDialog::~BIOSDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void BIOSDialog::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB);
|
||||
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
|
||||
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
|
||||
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
|
||||
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
|
||||
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
|
||||
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
|
||||
|
||||
if( pDX->m_bSaveAndValidate == TRUE ) {
|
||||
// disable BIOS usage when it does not exist
|
||||
if( !fileExists( m_pathGBA ) ) {
|
||||
m_enableBIOS_GBA = FALSE;
|
||||
}
|
||||
if( !fileExists( m_pathGB ) ) {
|
||||
m_enableBIOS_GB = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
|
||||
ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath)
|
||||
ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// BIOSDialog message handlers
|
||||
|
||||
void BIOSDialog::OnBnClickedSelectGbBiosPath()
|
||||
{
|
||||
CString current;
|
||||
m_editGB.GetWindowText( current );
|
||||
if( !fileExists( current ) ) {
|
||||
current = _T("");
|
||||
}
|
||||
|
||||
CFileDialog dlg(
|
||||
TRUE,
|
||||
NULL,
|
||||
current,
|
||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||
this,
|
||||
0 );
|
||||
|
||||
if( IDOK == dlg.DoModal() ) {
|
||||
m_editGB.SetWindowText( dlg.GetPathName() );
|
||||
}
|
||||
}
|
||||
|
||||
void BIOSDialog::OnBnClickedSelectGbaBiosPath()
|
||||
{
|
||||
CString current;
|
||||
m_editGBA.GetWindowText( current );
|
||||
if( !fileExists( current ) ) {
|
||||
current = _T("");
|
||||
}
|
||||
|
||||
CFileDialog dlg(
|
||||
TRUE,
|
||||
NULL,
|
||||
current,
|
||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||
this,
|
||||
0 );
|
||||
|
||||
if( IDOK == dlg.DoModal() ) {
|
||||
m_editGBA.SetWindowText( dlg.GetPathName() );
|
||||
}
|
||||
}
|
||||
|
||||
bool BIOSDialog::fileExists(CString& file)
|
||||
{
|
||||
CFileStatus stat;
|
||||
BOOL retVal = CFile::GetStatus( file, stat );
|
||||
bool noFile = false;
|
||||
if( retVal == TRUE ) {
|
||||
noFile |= ( stat.m_attribute & CFile::directory ) != 0;
|
||||
}
|
||||
return ( retVal == TRUE ) && !noFile;
|
||||
}
|
||||
#include "stdafx.h"
|
||||
#include "BIOSDialog.h"
|
||||
|
||||
|
||||
// BIOSDialog dialog
|
||||
|
||||
IMPLEMENT_DYNAMIC(BIOSDialog, CDialog)
|
||||
|
||||
BIOSDialog::BIOSDialog(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(BIOSDialog::IDD, pParent)
|
||||
, m_enableBIOS_GB(FALSE)
|
||||
, m_enableBIOS_GBA(FALSE)
|
||||
, m_skipLogo(FALSE)
|
||||
, m_pathGB(_T(""))
|
||||
, m_pathGBA(_T(""))
|
||||
{
|
||||
}
|
||||
|
||||
BIOSDialog::~BIOSDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void BIOSDialog::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Check(pDX, IDC_ENABLE_GB_BIOS, m_enableBIOS_GB);
|
||||
DDX_Check(pDX, IDC_ENABLE_GBA_BIOS, m_enableBIOS_GBA);
|
||||
DDX_Check(pDX, IDC_SKIP_BOOT_LOGO, m_skipLogo);
|
||||
DDX_Text(pDX, IDC_GB_BIOS_PATH, m_pathGB);
|
||||
DDX_Text(pDX, IDC_GBA_BIOS_PATH, m_pathGBA);
|
||||
DDX_Control(pDX, IDC_GB_BIOS_PATH, m_editGB);
|
||||
DDX_Control(pDX, IDC_GBA_BIOS_PATH, m_editGBA);
|
||||
|
||||
if( pDX->m_bSaveAndValidate == TRUE ) {
|
||||
// disable BIOS usage when it does not exist
|
||||
if( !fileExists( m_pathGBA ) ) {
|
||||
m_enableBIOS_GBA = FALSE;
|
||||
}
|
||||
if( !fileExists( m_pathGB ) ) {
|
||||
m_enableBIOS_GB = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(BIOSDialog, CDialog)
|
||||
ON_BN_CLICKED(IDC_SELECT_GB_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbBiosPath)
|
||||
ON_BN_CLICKED(IDC_SELECT_GBA_BIOS_PATH, &BIOSDialog::OnBnClickedSelectGbaBiosPath)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// BIOSDialog message handlers
|
||||
|
||||
void BIOSDialog::OnBnClickedSelectGbBiosPath()
|
||||
{
|
||||
CString current;
|
||||
m_editGB.GetWindowText( current );
|
||||
if( !fileExists( current ) ) {
|
||||
current = _T("");
|
||||
}
|
||||
|
||||
CFileDialog dlg(
|
||||
TRUE,
|
||||
NULL,
|
||||
current,
|
||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||
this,
|
||||
0 );
|
||||
|
||||
if( IDOK == dlg.DoModal() ) {
|
||||
m_editGB.SetWindowText( dlg.GetPathName() );
|
||||
}
|
||||
}
|
||||
|
||||
void BIOSDialog::OnBnClickedSelectGbaBiosPath()
|
||||
{
|
||||
CString current;
|
||||
m_editGBA.GetWindowText( current );
|
||||
if( !fileExists( current ) ) {
|
||||
current = _T("");
|
||||
}
|
||||
|
||||
CFileDialog dlg(
|
||||
TRUE,
|
||||
NULL,
|
||||
current,
|
||||
OFN_DONTADDTORECENT | OFN_FILEMUSTEXIST,
|
||||
_T("BIOS Files (*.bin;*.rom)|*.bin;*.rom|All Files (*.*)|*.*||"),
|
||||
this,
|
||||
0 );
|
||||
|
||||
if( IDOK == dlg.DoModal() ) {
|
||||
m_editGBA.SetWindowText( dlg.GetPathName() );
|
||||
}
|
||||
}
|
||||
|
||||
bool BIOSDialog::fileExists(CString& file)
|
||||
{
|
||||
CFileStatus stat;
|
||||
BOOL retVal = CFile::GetStatus( file, stat );
|
||||
bool noFile = false;
|
||||
if( retVal == TRUE ) {
|
||||
noFile |= ( stat.m_attribute & CFile::directory ) != 0;
|
||||
}
|
||||
return ( retVal == TRUE ) && !noFile;
|
||||
}
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
#pragma once
|
||||
#include "afxwin.h"
|
||||
|
||||
|
||||
// BIOSDialog dialog
|
||||
|
||||
class BIOSDialog : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(BIOSDialog)
|
||||
|
||||
public:
|
||||
BIOSDialog(CWnd* pParent = NULL); // standard constructor
|
||||
virtual ~BIOSDialog();
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_BIOS };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
CEdit m_editGB;
|
||||
CEdit m_editGBA;
|
||||
bool fileExists(CString& file);
|
||||
afx_msg void OnBnClickedSelectGbBiosPath();
|
||||
afx_msg void OnBnClickedSelectGbaBiosPath();
|
||||
public:
|
||||
BOOL m_enableBIOS_GB;
|
||||
BOOL m_enableBIOS_GBA;
|
||||
BOOL m_skipLogo;
|
||||
CString m_pathGB;
|
||||
CString m_pathGBA;
|
||||
};
|
||||
#pragma once
|
||||
#include "afxwin.h"
|
||||
|
||||
|
||||
// BIOSDialog dialog
|
||||
|
||||
class BIOSDialog : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(BIOSDialog)
|
||||
|
||||
public:
|
||||
BIOSDialog(CWnd* pParent = NULL); // standard constructor
|
||||
virtual ~BIOSDialog();
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_BIOS };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
CEdit m_editGB;
|
||||
CEdit m_editGBA;
|
||||
bool fileExists(CString& file);
|
||||
afx_msg void OnBnClickedSelectGbBiosPath();
|
||||
afx_msg void OnBnClickedSelectGbaBiosPath();
|
||||
public:
|
||||
BOOL m_enableBIOS_GB;
|
||||
BOOL m_enableBIOS_GBA;
|
||||
BOOL m_skipLogo;
|
||||
CString m_pathGB;
|
||||
CString m_pathGBA;
|
||||
};
|
||||
|
|
|
@ -49,7 +49,7 @@ private:
|
|||
HANDLE dsbEvent;
|
||||
WAVEFORMATEX wfx; // Primary buffer wave format
|
||||
int soundBufferTotalLen;
|
||||
|
||||
|
||||
public:
|
||||
DirectSound();
|
||||
virtual ~DirectSound();
|
||||
|
@ -72,7 +72,7 @@ DirectSound::DirectSound()
|
|||
dsbNotify = NULL;
|
||||
dsbEvent = NULL;
|
||||
|
||||
soundBufferTotalLen = 14700;
|
||||
soundBufferTotalLen = 14700;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -84,11 +84,11 @@ BOOL Directories::OnInitDialog()
|
|||
{
|
||||
CDialog::OnInitDialog();
|
||||
CString p;
|
||||
|
||||
|
||||
p = regQueryStringValue("romdir", NULL);
|
||||
if(!p.IsEmpty())
|
||||
GetDlgItem(IDC_ROM_PATH)->SetWindowText(p);
|
||||
|
||||
|
||||
p = regQueryStringValue("gbcromdir", NULL);
|
||||
if(!p.IsEmpty())
|
||||
GetDlgItem(IDC_GBCROM_PATH)->SetWindowText(p);
|
||||
|
@ -287,7 +287,7 @@ CString Directories::browseForDir(CString title)
|
|||
|
||||
// returns true if the directory does exist
|
||||
bool Directories::directoryDoesExist(const char *directory)
|
||||
{
|
||||
{
|
||||
HANDLE hDir;
|
||||
hDir = CreateFile(
|
||||
directory,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,80 +1,80 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "afxwin.h"
|
||||
#include "Display.h"
|
||||
|
||||
|
||||
#ifndef NO_D3D
|
||||
#pragma comment( lib, "d3d9.lib" )
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
#define DIRECT3D_VERSION 0x0900
|
||||
#include <d3d9.h>
|
||||
#endif
|
||||
|
||||
|
||||
// FullscreenSettings dialog
|
||||
|
||||
class FullscreenSettings : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(FullscreenSettings)
|
||||
|
||||
public:
|
||||
FullscreenSettings(CWnd* pParent = NULL); // standard constructor
|
||||
virtual ~FullscreenSettings();
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_FULLSCREEN };
|
||||
|
||||
// Call this function to select the API for the display mode enumeration.
|
||||
void setAPI( DISPLAY_TYPE type );
|
||||
afx_msg void OnCbnSelchangeComboDevice();
|
||||
afx_msg void OnCbnSelchangeComboColorDepth();
|
||||
afx_msg void OnCbnSelchangeComboResolution();
|
||||
|
||||
unsigned int m_device;
|
||||
unsigned int m_colorDepth;
|
||||
unsigned int m_width;
|
||||
unsigned int m_height;
|
||||
unsigned int m_refreshRate;
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual void OnOK();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
DISPLAY_TYPE api;
|
||||
bool failed;
|
||||
|
||||
#ifndef NO_D3D
|
||||
LPDIRECT3D9 pD3D;
|
||||
#endif
|
||||
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
CComboBox combo_device;
|
||||
CComboBox combo_resolution;
|
||||
CComboBox combo_color_depth;
|
||||
CComboBox combo_refresh_rate;
|
||||
};
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 2008 VBA-M development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "afxwin.h"
|
||||
#include "Display.h"
|
||||
|
||||
|
||||
#ifndef NO_D3D
|
||||
#pragma comment( lib, "d3d9.lib" )
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEBUG_INFO
|
||||
#endif
|
||||
#define DIRECT3D_VERSION 0x0900
|
||||
#include <d3d9.h>
|
||||
#endif
|
||||
|
||||
|
||||
// FullscreenSettings dialog
|
||||
|
||||
class FullscreenSettings : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(FullscreenSettings)
|
||||
|
||||
public:
|
||||
FullscreenSettings(CWnd* pParent = NULL); // standard constructor
|
||||
virtual ~FullscreenSettings();
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_FULLSCREEN };
|
||||
|
||||
// Call this function to select the API for the display mode enumeration.
|
||||
void setAPI( DISPLAY_TYPE type );
|
||||
afx_msg void OnCbnSelchangeComboDevice();
|
||||
afx_msg void OnCbnSelchangeComboColorDepth();
|
||||
afx_msg void OnCbnSelchangeComboResolution();
|
||||
|
||||
unsigned int m_device;
|
||||
unsigned int m_colorDepth;
|
||||
unsigned int m_width;
|
||||
unsigned int m_height;
|
||||
unsigned int m_refreshRate;
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual void OnOK();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
DISPLAY_TYPE api;
|
||||
bool failed;
|
||||
|
||||
#ifndef NO_D3D
|
||||
LPDIRECT3D9 pD3D;
|
||||
#endif
|
||||
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
CComboBox combo_device;
|
||||
CComboBox combo_resolution;
|
||||
CComboBox combo_color_depth;
|
||||
CComboBox combo_refresh_rate;
|
||||
};
|
||||
|
|
|
@ -1015,13 +1015,13 @@ void GBCheatList::OnNMDblclkCheatList(NMHDR *pNMHDR, LRESULT *pResult)
|
|||
int selection = m_list.GetSelectionMark();
|
||||
// get index value of corresponding code in cheatlist
|
||||
if( selection == -1 ) return;
|
||||
|
||||
|
||||
LVITEM item;
|
||||
ZeroMemory( &item, sizeof(item) );
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = selection;
|
||||
if( FALSE == m_list.GetItem( &item ) ) return;
|
||||
|
||||
|
||||
// modify code
|
||||
INT_PTR res;
|
||||
if( gbVerifyGsCode( gbCheatList[ item.lParam ].cheatCode ) ) {
|
||||
|
|
|
@ -1,448 +1,448 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Creative Labs Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
|
||||
* promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "LoadOAL.h"
|
||||
|
||||
HINSTANCE g_hOpenALDLL = NULL;
|
||||
|
||||
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
|
||||
{
|
||||
if (!lpOALFnTable)
|
||||
return AL_FALSE;
|
||||
|
||||
if (szOALFullPathName)
|
||||
g_hOpenALDLL = LoadLibrary(szOALFullPathName);
|
||||
else
|
||||
g_hOpenALDLL = LoadLibrary("openal32.dll");
|
||||
|
||||
if (!g_hOpenALDLL)
|
||||
return AL_FALSE;
|
||||
|
||||
memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
|
||||
|
||||
// Get function pointers
|
||||
lpOALFnTable->alEnable = (LPALENABLE)GetProcAddress(g_hOpenALDLL, "alEnable");
|
||||
if (lpOALFnTable->alEnable == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alEnable' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDisable = (LPALDISABLE)GetProcAddress(g_hOpenALDLL, "alDisable");
|
||||
if (lpOALFnTable->alDisable == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDisable' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsEnabled = (LPALISENABLED)GetProcAddress(g_hOpenALDLL, "alIsEnabled");
|
||||
if (lpOALFnTable->alIsEnabled == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsEnabled' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)GetProcAddress(g_hOpenALDLL, "alGetBoolean");
|
||||
if (lpOALFnTable->alGetBoolean == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBoolean' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetInteger = (LPALGETINTEGER)GetProcAddress(g_hOpenALDLL, "alGetInteger");
|
||||
if (lpOALFnTable->alGetInteger == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetInteger' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetFloat = (LPALGETFLOAT)GetProcAddress(g_hOpenALDLL, "alGetFloat");
|
||||
if (lpOALFnTable->alGetFloat == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetFloat' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetDouble = (LPALGETDOUBLE)GetProcAddress(g_hOpenALDLL, "alGetDouble");
|
||||
if (lpOALFnTable->alGetDouble == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetDouble' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)GetProcAddress(g_hOpenALDLL, "alGetBooleanv");
|
||||
if (lpOALFnTable->alGetBooleanv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBooleanv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alGetIntegerv");
|
||||
if (lpOALFnTable->alGetIntegerv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetIntegerv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetFloatv = (LPALGETFLOATV)GetProcAddress(g_hOpenALDLL, "alGetFloatv");
|
||||
if (lpOALFnTable->alGetFloatv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetFloatv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)GetProcAddress(g_hOpenALDLL, "alGetDoublev");
|
||||
if (lpOALFnTable->alGetDoublev == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetDoublev' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetString = (LPALGETSTRING)GetProcAddress(g_hOpenALDLL, "alGetString");
|
||||
if (lpOALFnTable->alGetString == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetString' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetError = (LPALGETERROR)GetProcAddress(g_hOpenALDLL, "alGetError");
|
||||
if (lpOALFnTable->alGetError == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetError' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alIsExtensionPresent");
|
||||
if (lpOALFnTable->alIsExtensionPresent == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsExtensionPresent' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alGetProcAddress");
|
||||
if (lpOALFnTable->alGetProcAddress == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetProcAddress' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alGetEnumValue");
|
||||
if (lpOALFnTable->alGetEnumValue == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetEnumValue' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListeneri = (LPALLISTENERI)GetProcAddress(g_hOpenALDLL, "alListeneri");
|
||||
if (lpOALFnTable->alListeneri == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListeneri' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListenerf = (LPALLISTENERF)GetProcAddress(g_hOpenALDLL, "alListenerf");
|
||||
if (lpOALFnTable->alListenerf == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListenerf' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListener3f = (LPALLISTENER3F)GetProcAddress(g_hOpenALDLL, "alListener3f");
|
||||
if (lpOALFnTable->alListener3f == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListener3f' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListenerfv = (LPALLISTENERFV)GetProcAddress(g_hOpenALDLL, "alListenerfv");
|
||||
if (lpOALFnTable->alListenerfv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListenerfv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)GetProcAddress(g_hOpenALDLL, "alGetListeneri");
|
||||
if (lpOALFnTable->alGetListeneri == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListeneri' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)GetProcAddress(g_hOpenALDLL, "alGetListenerf");
|
||||
if (lpOALFnTable->alGetListenerf == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListenerf' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)GetProcAddress(g_hOpenALDLL, "alGetListener3f");
|
||||
if (lpOALFnTable->alGetListener3f == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListener3f' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)GetProcAddress(g_hOpenALDLL, "alGetListenerfv");
|
||||
if (lpOALFnTable->alGetListenerfv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListenerfv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGenSources = (LPALGENSOURCES)GetProcAddress(g_hOpenALDLL, "alGenSources");
|
||||
if (lpOALFnTable->alGenSources == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGenSources' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)GetProcAddress(g_hOpenALDLL, "alDeleteSources");
|
||||
if (lpOALFnTable->alDeleteSources == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDeleteSources' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsSource = (LPALISSOURCE)GetProcAddress(g_hOpenALDLL, "alIsSource");
|
||||
if (lpOALFnTable->alIsSource == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsSource' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcei = (LPALSOURCEI)GetProcAddress(g_hOpenALDLL, "alSourcei");
|
||||
if (lpOALFnTable->alSourcei == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcei' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcef = (LPALSOURCEF)GetProcAddress(g_hOpenALDLL, "alSourcef");
|
||||
if (lpOALFnTable->alSourcef == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcef' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSource3f = (LPALSOURCE3F)GetProcAddress(g_hOpenALDLL, "alSource3f");
|
||||
if (lpOALFnTable->alSource3f == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSource3f' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcefv = (LPALSOURCEFV)GetProcAddress(g_hOpenALDLL, "alSourcefv");
|
||||
if (lpOALFnTable->alSourcefv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcefv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)GetProcAddress(g_hOpenALDLL, "alGetSourcei");
|
||||
if (lpOALFnTable->alGetSourcei == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetSourcei' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)GetProcAddress(g_hOpenALDLL, "alGetSourcef");
|
||||
if (lpOALFnTable->alGetSourcef == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetSourcef' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)GetProcAddress(g_hOpenALDLL, "alGetSourcefv");
|
||||
if (lpOALFnTable->alGetSourcefv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetSourcefv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)GetProcAddress(g_hOpenALDLL, "alSourcePlayv");
|
||||
if (lpOALFnTable->alSourcePlayv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcePlayv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)GetProcAddress(g_hOpenALDLL, "alSourceStopv");
|
||||
if (lpOALFnTable->alSourceStopv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceStopv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)GetProcAddress(g_hOpenALDLL, "alSourcePlay");
|
||||
if (lpOALFnTable->alSourcePlay == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcePlay' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)GetProcAddress(g_hOpenALDLL, "alSourcePause");
|
||||
if (lpOALFnTable->alSourcePause == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcePause' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceStop = (LPALSOURCESTOP)GetProcAddress(g_hOpenALDLL, "alSourceStop");
|
||||
if (lpOALFnTable->alSourceStop == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceStop' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)GetProcAddress(g_hOpenALDLL, "alGenBuffers");
|
||||
if (lpOALFnTable->alGenBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGenBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)GetProcAddress(g_hOpenALDLL, "alDeleteBuffers");
|
||||
if (lpOALFnTable->alDeleteBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDeleteBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsBuffer = (LPALISBUFFER)GetProcAddress(g_hOpenALDLL, "alIsBuffer");
|
||||
if (lpOALFnTable->alIsBuffer == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsBuffer' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alBufferData = (LPALBUFFERDATA)GetProcAddress(g_hOpenALDLL, "alBufferData");
|
||||
if (lpOALFnTable->alBufferData == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alBufferData' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)GetProcAddress(g_hOpenALDLL, "alGetBufferi");
|
||||
if (lpOALFnTable->alGetBufferi == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBufferi' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)GetProcAddress(g_hOpenALDLL, "alGetBufferf");
|
||||
if (lpOALFnTable->alGetBufferf == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBufferf' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceQueueBuffers");
|
||||
if (lpOALFnTable->alSourceQueueBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceQueueBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceUnqueueBuffers");
|
||||
if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)GetProcAddress(g_hOpenALDLL, "alDistanceModel");
|
||||
if (lpOALFnTable->alDistanceModel == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDistanceModel' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)GetProcAddress(g_hOpenALDLL, "alDopplerFactor");
|
||||
if (lpOALFnTable->alDopplerFactor == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDopplerFactor' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)GetProcAddress(g_hOpenALDLL, "alDopplerVelocity");
|
||||
if (lpOALFnTable->alDopplerVelocity == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDopplerVelocity' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetString = (LPALCGETSTRING)GetProcAddress(g_hOpenALDLL, "alcGetString");
|
||||
if (lpOALFnTable->alcGetString == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetString' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alcGetIntegerv");
|
||||
if (lpOALFnTable->alcGetIntegerv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetIntegerv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)GetProcAddress(g_hOpenALDLL, "alcOpenDevice");
|
||||
if (lpOALFnTable->alcOpenDevice == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcOpenDevice' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)GetProcAddress(g_hOpenALDLL, "alcCloseDevice");
|
||||
if (lpOALFnTable->alcCloseDevice == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcCloseDevice' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)GetProcAddress(g_hOpenALDLL, "alcCreateContext");
|
||||
if (lpOALFnTable->alcCreateContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcCreateContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)GetProcAddress(g_hOpenALDLL, "alcMakeContextCurrent");
|
||||
if (lpOALFnTable->alcMakeContextCurrent == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcMakeContextCurrent' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)GetProcAddress(g_hOpenALDLL, "alcProcessContext");
|
||||
if (lpOALFnTable->alcProcessContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcProcessContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)GetProcAddress(g_hOpenALDLL, "alcGetCurrentContext");
|
||||
if (lpOALFnTable->alcGetCurrentContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetCurrentContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)GetProcAddress(g_hOpenALDLL, "alcGetContextsDevice");
|
||||
if (lpOALFnTable->alcGetContextsDevice == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetContextsDevice' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)GetProcAddress(g_hOpenALDLL, "alcSuspendContext");
|
||||
if (lpOALFnTable->alcSuspendContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcSuspendContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)GetProcAddress(g_hOpenALDLL, "alcDestroyContext");
|
||||
if (lpOALFnTable->alcDestroyContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcDestroyContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetError = (LPALCGETERROR)GetProcAddress(g_hOpenALDLL, "alcGetError");
|
||||
if (lpOALFnTable->alcGetError == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetError' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alcIsExtensionPresent");
|
||||
if (lpOALFnTable->alcIsExtensionPresent == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcIsExtensionPresent' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alcGetProcAddress");
|
||||
if (lpOALFnTable->alcGetProcAddress == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetProcAddress' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alcGetEnumValue");
|
||||
if (lpOALFnTable->alcGetEnumValue == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetEnumValue' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
ALvoid UnloadOAL10Library()
|
||||
{
|
||||
// Unload the dll
|
||||
if (g_hOpenALDLL)
|
||||
{
|
||||
FreeLibrary(g_hOpenALDLL);
|
||||
g_hOpenALDLL = NULL;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2006, Creative Labs Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
|
||||
* promote products derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "windows.h"
|
||||
#include "LoadOAL.h"
|
||||
|
||||
HINSTANCE g_hOpenALDLL = NULL;
|
||||
|
||||
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
|
||||
{
|
||||
if (!lpOALFnTable)
|
||||
return AL_FALSE;
|
||||
|
||||
if (szOALFullPathName)
|
||||
g_hOpenALDLL = LoadLibrary(szOALFullPathName);
|
||||
else
|
||||
g_hOpenALDLL = LoadLibrary("openal32.dll");
|
||||
|
||||
if (!g_hOpenALDLL)
|
||||
return AL_FALSE;
|
||||
|
||||
memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
|
||||
|
||||
// Get function pointers
|
||||
lpOALFnTable->alEnable = (LPALENABLE)GetProcAddress(g_hOpenALDLL, "alEnable");
|
||||
if (lpOALFnTable->alEnable == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alEnable' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDisable = (LPALDISABLE)GetProcAddress(g_hOpenALDLL, "alDisable");
|
||||
if (lpOALFnTable->alDisable == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDisable' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsEnabled = (LPALISENABLED)GetProcAddress(g_hOpenALDLL, "alIsEnabled");
|
||||
if (lpOALFnTable->alIsEnabled == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsEnabled' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)GetProcAddress(g_hOpenALDLL, "alGetBoolean");
|
||||
if (lpOALFnTable->alGetBoolean == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBoolean' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetInteger = (LPALGETINTEGER)GetProcAddress(g_hOpenALDLL, "alGetInteger");
|
||||
if (lpOALFnTable->alGetInteger == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetInteger' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetFloat = (LPALGETFLOAT)GetProcAddress(g_hOpenALDLL, "alGetFloat");
|
||||
if (lpOALFnTable->alGetFloat == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetFloat' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetDouble = (LPALGETDOUBLE)GetProcAddress(g_hOpenALDLL, "alGetDouble");
|
||||
if (lpOALFnTable->alGetDouble == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetDouble' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)GetProcAddress(g_hOpenALDLL, "alGetBooleanv");
|
||||
if (lpOALFnTable->alGetBooleanv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBooleanv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alGetIntegerv");
|
||||
if (lpOALFnTable->alGetIntegerv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetIntegerv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetFloatv = (LPALGETFLOATV)GetProcAddress(g_hOpenALDLL, "alGetFloatv");
|
||||
if (lpOALFnTable->alGetFloatv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetFloatv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)GetProcAddress(g_hOpenALDLL, "alGetDoublev");
|
||||
if (lpOALFnTable->alGetDoublev == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetDoublev' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetString = (LPALGETSTRING)GetProcAddress(g_hOpenALDLL, "alGetString");
|
||||
if (lpOALFnTable->alGetString == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetString' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetError = (LPALGETERROR)GetProcAddress(g_hOpenALDLL, "alGetError");
|
||||
if (lpOALFnTable->alGetError == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetError' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alIsExtensionPresent");
|
||||
if (lpOALFnTable->alIsExtensionPresent == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsExtensionPresent' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alGetProcAddress");
|
||||
if (lpOALFnTable->alGetProcAddress == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetProcAddress' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alGetEnumValue");
|
||||
if (lpOALFnTable->alGetEnumValue == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetEnumValue' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListeneri = (LPALLISTENERI)GetProcAddress(g_hOpenALDLL, "alListeneri");
|
||||
if (lpOALFnTable->alListeneri == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListeneri' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListenerf = (LPALLISTENERF)GetProcAddress(g_hOpenALDLL, "alListenerf");
|
||||
if (lpOALFnTable->alListenerf == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListenerf' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListener3f = (LPALLISTENER3F)GetProcAddress(g_hOpenALDLL, "alListener3f");
|
||||
if (lpOALFnTable->alListener3f == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListener3f' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alListenerfv = (LPALLISTENERFV)GetProcAddress(g_hOpenALDLL, "alListenerfv");
|
||||
if (lpOALFnTable->alListenerfv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alListenerfv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)GetProcAddress(g_hOpenALDLL, "alGetListeneri");
|
||||
if (lpOALFnTable->alGetListeneri == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListeneri' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)GetProcAddress(g_hOpenALDLL, "alGetListenerf");
|
||||
if (lpOALFnTable->alGetListenerf == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListenerf' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)GetProcAddress(g_hOpenALDLL, "alGetListener3f");
|
||||
if (lpOALFnTable->alGetListener3f == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListener3f' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)GetProcAddress(g_hOpenALDLL, "alGetListenerfv");
|
||||
if (lpOALFnTable->alGetListenerfv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetListenerfv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGenSources = (LPALGENSOURCES)GetProcAddress(g_hOpenALDLL, "alGenSources");
|
||||
if (lpOALFnTable->alGenSources == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGenSources' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)GetProcAddress(g_hOpenALDLL, "alDeleteSources");
|
||||
if (lpOALFnTable->alDeleteSources == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDeleteSources' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsSource = (LPALISSOURCE)GetProcAddress(g_hOpenALDLL, "alIsSource");
|
||||
if (lpOALFnTable->alIsSource == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsSource' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcei = (LPALSOURCEI)GetProcAddress(g_hOpenALDLL, "alSourcei");
|
||||
if (lpOALFnTable->alSourcei == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcei' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcef = (LPALSOURCEF)GetProcAddress(g_hOpenALDLL, "alSourcef");
|
||||
if (lpOALFnTable->alSourcef == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcef' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSource3f = (LPALSOURCE3F)GetProcAddress(g_hOpenALDLL, "alSource3f");
|
||||
if (lpOALFnTable->alSource3f == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSource3f' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcefv = (LPALSOURCEFV)GetProcAddress(g_hOpenALDLL, "alSourcefv");
|
||||
if (lpOALFnTable->alSourcefv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcefv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)GetProcAddress(g_hOpenALDLL, "alGetSourcei");
|
||||
if (lpOALFnTable->alGetSourcei == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetSourcei' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)GetProcAddress(g_hOpenALDLL, "alGetSourcef");
|
||||
if (lpOALFnTable->alGetSourcef == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetSourcef' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)GetProcAddress(g_hOpenALDLL, "alGetSourcefv");
|
||||
if (lpOALFnTable->alGetSourcefv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetSourcefv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)GetProcAddress(g_hOpenALDLL, "alSourcePlayv");
|
||||
if (lpOALFnTable->alSourcePlayv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcePlayv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)GetProcAddress(g_hOpenALDLL, "alSourceStopv");
|
||||
if (lpOALFnTable->alSourceStopv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceStopv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)GetProcAddress(g_hOpenALDLL, "alSourcePlay");
|
||||
if (lpOALFnTable->alSourcePlay == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcePlay' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)GetProcAddress(g_hOpenALDLL, "alSourcePause");
|
||||
if (lpOALFnTable->alSourcePause == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourcePause' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceStop = (LPALSOURCESTOP)GetProcAddress(g_hOpenALDLL, "alSourceStop");
|
||||
if (lpOALFnTable->alSourceStop == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceStop' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)GetProcAddress(g_hOpenALDLL, "alGenBuffers");
|
||||
if (lpOALFnTable->alGenBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGenBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)GetProcAddress(g_hOpenALDLL, "alDeleteBuffers");
|
||||
if (lpOALFnTable->alDeleteBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDeleteBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alIsBuffer = (LPALISBUFFER)GetProcAddress(g_hOpenALDLL, "alIsBuffer");
|
||||
if (lpOALFnTable->alIsBuffer == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alIsBuffer' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alBufferData = (LPALBUFFERDATA)GetProcAddress(g_hOpenALDLL, "alBufferData");
|
||||
if (lpOALFnTable->alBufferData == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alBufferData' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)GetProcAddress(g_hOpenALDLL, "alGetBufferi");
|
||||
if (lpOALFnTable->alGetBufferi == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBufferi' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)GetProcAddress(g_hOpenALDLL, "alGetBufferf");
|
||||
if (lpOALFnTable->alGetBufferf == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alGetBufferf' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceQueueBuffers");
|
||||
if (lpOALFnTable->alSourceQueueBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceQueueBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceUnqueueBuffers");
|
||||
if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)GetProcAddress(g_hOpenALDLL, "alDistanceModel");
|
||||
if (lpOALFnTable->alDistanceModel == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDistanceModel' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)GetProcAddress(g_hOpenALDLL, "alDopplerFactor");
|
||||
if (lpOALFnTable->alDopplerFactor == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDopplerFactor' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)GetProcAddress(g_hOpenALDLL, "alDopplerVelocity");
|
||||
if (lpOALFnTable->alDopplerVelocity == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alDopplerVelocity' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetString = (LPALCGETSTRING)GetProcAddress(g_hOpenALDLL, "alcGetString");
|
||||
if (lpOALFnTable->alcGetString == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetString' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alcGetIntegerv");
|
||||
if (lpOALFnTable->alcGetIntegerv == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetIntegerv' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)GetProcAddress(g_hOpenALDLL, "alcOpenDevice");
|
||||
if (lpOALFnTable->alcOpenDevice == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcOpenDevice' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)GetProcAddress(g_hOpenALDLL, "alcCloseDevice");
|
||||
if (lpOALFnTable->alcCloseDevice == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcCloseDevice' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)GetProcAddress(g_hOpenALDLL, "alcCreateContext");
|
||||
if (lpOALFnTable->alcCreateContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcCreateContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)GetProcAddress(g_hOpenALDLL, "alcMakeContextCurrent");
|
||||
if (lpOALFnTable->alcMakeContextCurrent == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcMakeContextCurrent' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)GetProcAddress(g_hOpenALDLL, "alcProcessContext");
|
||||
if (lpOALFnTable->alcProcessContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcProcessContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)GetProcAddress(g_hOpenALDLL, "alcGetCurrentContext");
|
||||
if (lpOALFnTable->alcGetCurrentContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetCurrentContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)GetProcAddress(g_hOpenALDLL, "alcGetContextsDevice");
|
||||
if (lpOALFnTable->alcGetContextsDevice == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetContextsDevice' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)GetProcAddress(g_hOpenALDLL, "alcSuspendContext");
|
||||
if (lpOALFnTable->alcSuspendContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcSuspendContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)GetProcAddress(g_hOpenALDLL, "alcDestroyContext");
|
||||
if (lpOALFnTable->alcDestroyContext == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcDestroyContext' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetError = (LPALCGETERROR)GetProcAddress(g_hOpenALDLL, "alcGetError");
|
||||
if (lpOALFnTable->alcGetError == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetError' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alcIsExtensionPresent");
|
||||
if (lpOALFnTable->alcIsExtensionPresent == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcIsExtensionPresent' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alcGetProcAddress");
|
||||
if (lpOALFnTable->alcGetProcAddress == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetProcAddress' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alcGetEnumValue");
|
||||
if (lpOALFnTable->alcGetEnumValue == NULL)
|
||||
{
|
||||
OutputDebugString("Failed to retrieve 'alcGetEnumValue' function address\n");
|
||||
return AL_FALSE;
|
||||
}
|
||||
|
||||
return AL_TRUE;
|
||||
}
|
||||
|
||||
ALvoid UnloadOAL10Library()
|
||||
{
|
||||
// Unload the dll
|
||||
if (g_hOpenALDLL)
|
||||
{
|
||||
FreeLibrary(g_hOpenALDLL);
|
||||
g_hOpenALDLL = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,164 +1,164 @@
|
|||
#include <al.h>
|
||||
#include <alc.h>
|
||||
|
||||
// Open AL Function table definition
|
||||
|
||||
#ifndef _OPENALFNTABLE
|
||||
#define _OPENALFNTABLE
|
||||
|
||||
// AL 1.0 did not define the ALchar and ALCchar types, so define them here
|
||||
// if they don't exist
|
||||
|
||||
#ifndef ALchar
|
||||
#define ALchar char
|
||||
#endif
|
||||
|
||||
#ifndef ALCchar
|
||||
#define ALCchar char
|
||||
#endif
|
||||
|
||||
// Complete list of functions available in AL 1.0 implementations
|
||||
|
||||
typedef void (ALAPIENTRY *LPALENABLE)( ALenum capability );
|
||||
typedef void (ALAPIENTRY *LPALDISABLE)( ALenum capability );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISENABLED)( ALenum capability );
|
||||
typedef const ALchar* (ALAPIENTRY *LPALGETSTRING)( ALenum param );
|
||||
typedef void (ALAPIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data );
|
||||
typedef void (ALAPIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data );
|
||||
typedef void (ALAPIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data );
|
||||
typedef void (ALAPIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data );
|
||||
typedef ALboolean (ALAPIENTRY *LPALGETBOOLEAN)( ALenum param );
|
||||
typedef ALint (ALAPIENTRY *LPALGETINTEGER)( ALenum param );
|
||||
typedef ALfloat (ALAPIENTRY *LPALGETFLOAT)( ALenum param );
|
||||
typedef ALdouble (ALAPIENTRY *LPALGETDOUBLE)( ALenum param );
|
||||
typedef ALenum (ALAPIENTRY *LPALGETERROR)( void );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname );
|
||||
typedef void* (ALAPIENTRY *LPALGETPROCADDRESS)( const ALchar* fname );
|
||||
typedef ALenum (ALAPIENTRY *LPALGETENUMVALUE)( const ALchar* ename );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERF)( ALenum param, ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERI)( ALenum param, ALint value );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources );
|
||||
typedef void (ALAPIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISSOURCE)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value);
|
||||
typedef void (ALAPIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value);
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPLAY)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCESTOP)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEREWIND)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPAUSE)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
typedef void (ALAPIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers );
|
||||
typedef void (ALAPIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISBUFFER)( ALuint bid );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALDOPPLERFACTOR)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALDOPPLERVELOCITY)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel );
|
||||
|
||||
typedef ALCcontext * (ALCAPIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist);
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context );
|
||||
typedef ALCcontext * (ALCAPIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device );
|
||||
typedef ALCenum (ALCAPIENTRY *LPALCGETERROR)( ALCdevice *device );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname );
|
||||
typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname );
|
||||
typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
|
||||
typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
|
||||
typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPALENABLE alEnable;
|
||||
LPALDISABLE alDisable;
|
||||
LPALISENABLED alIsEnabled;
|
||||
LPALGETBOOLEAN alGetBoolean;
|
||||
LPALGETINTEGER alGetInteger;
|
||||
LPALGETFLOAT alGetFloat;
|
||||
LPALGETDOUBLE alGetDouble;
|
||||
LPALGETBOOLEANV alGetBooleanv;
|
||||
LPALGETINTEGERV alGetIntegerv;
|
||||
LPALGETFLOATV alGetFloatv;
|
||||
LPALGETDOUBLEV alGetDoublev;
|
||||
LPALGETSTRING alGetString;
|
||||
LPALGETERROR alGetError;
|
||||
LPALISEXTENSIONPRESENT alIsExtensionPresent;
|
||||
LPALGETPROCADDRESS alGetProcAddress;
|
||||
LPALGETENUMVALUE alGetEnumValue;
|
||||
LPALLISTENERI alListeneri;
|
||||
LPALLISTENERF alListenerf;
|
||||
LPALLISTENER3F alListener3f;
|
||||
LPALLISTENERFV alListenerfv;
|
||||
LPALGETLISTENERI alGetListeneri;
|
||||
LPALGETLISTENERF alGetListenerf;
|
||||
LPALGETLISTENER3F alGetListener3f;
|
||||
LPALGETLISTENERFV alGetListenerfv;
|
||||
LPALGENSOURCES alGenSources;
|
||||
LPALDELETESOURCES alDeleteSources;
|
||||
LPALISSOURCE alIsSource;
|
||||
LPALSOURCEI alSourcei;
|
||||
LPALSOURCEF alSourcef;
|
||||
LPALSOURCE3F alSource3f;
|
||||
LPALSOURCEFV alSourcefv;
|
||||
LPALGETSOURCEI alGetSourcei;
|
||||
LPALGETSOURCEF alGetSourcef;
|
||||
LPALGETSOURCEFV alGetSourcefv;
|
||||
LPALSOURCEPLAYV alSourcePlayv;
|
||||
LPALSOURCESTOPV alSourceStopv;
|
||||
LPALSOURCEPLAY alSourcePlay;
|
||||
LPALSOURCEPAUSE alSourcePause;
|
||||
LPALSOURCESTOP alSourceStop;
|
||||
LPALGENBUFFERS alGenBuffers;
|
||||
LPALDELETEBUFFERS alDeleteBuffers;
|
||||
LPALISBUFFER alIsBuffer;
|
||||
LPALBUFFERDATA alBufferData;
|
||||
LPALGETBUFFERI alGetBufferi;
|
||||
LPALGETBUFFERF alGetBufferf;
|
||||
LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
|
||||
LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
|
||||
LPALDISTANCEMODEL alDistanceModel;
|
||||
LPALDOPPLERFACTOR alDopplerFactor;
|
||||
LPALDOPPLERVELOCITY alDopplerVelocity;
|
||||
LPALCGETSTRING alcGetString;
|
||||
LPALCGETINTEGERV alcGetIntegerv;
|
||||
LPALCOPENDEVICE alcOpenDevice;
|
||||
LPALCCLOSEDEVICE alcCloseDevice;
|
||||
LPALCCREATECONTEXT alcCreateContext;
|
||||
LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
|
||||
LPALCPROCESSCONTEXT alcProcessContext;
|
||||
LPALCGETCURRENTCONTEXT alcGetCurrentContext;
|
||||
LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
|
||||
LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
LPALCDESTROYCONTEXT alcDestroyContext;
|
||||
LPALCGETERROR alcGetError;
|
||||
LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
|
||||
LPALCGETPROCADDRESS alcGetProcAddress;
|
||||
LPALCGETENUMVALUE alcGetEnumValue;
|
||||
} OPENALFNTABLE, *LPOPENALFNTABLE;
|
||||
#endif
|
||||
|
||||
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable);
|
||||
ALvoid UnloadOAL10Library();
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
|
||||
// Open AL Function table definition
|
||||
|
||||
#ifndef _OPENALFNTABLE
|
||||
#define _OPENALFNTABLE
|
||||
|
||||
// AL 1.0 did not define the ALchar and ALCchar types, so define them here
|
||||
// if they don't exist
|
||||
|
||||
#ifndef ALchar
|
||||
#define ALchar char
|
||||
#endif
|
||||
|
||||
#ifndef ALCchar
|
||||
#define ALCchar char
|
||||
#endif
|
||||
|
||||
// Complete list of functions available in AL 1.0 implementations
|
||||
|
||||
typedef void (ALAPIENTRY *LPALENABLE)( ALenum capability );
|
||||
typedef void (ALAPIENTRY *LPALDISABLE)( ALenum capability );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISENABLED)( ALenum capability );
|
||||
typedef const ALchar* (ALAPIENTRY *LPALGETSTRING)( ALenum param );
|
||||
typedef void (ALAPIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data );
|
||||
typedef void (ALAPIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data );
|
||||
typedef void (ALAPIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data );
|
||||
typedef void (ALAPIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data );
|
||||
typedef ALboolean (ALAPIENTRY *LPALGETBOOLEAN)( ALenum param );
|
||||
typedef ALint (ALAPIENTRY *LPALGETINTEGER)( ALenum param );
|
||||
typedef ALfloat (ALAPIENTRY *LPALGETFLOAT)( ALenum param );
|
||||
typedef ALdouble (ALAPIENTRY *LPALGETDOUBLE)( ALenum param );
|
||||
typedef ALenum (ALAPIENTRY *LPALGETERROR)( void );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname );
|
||||
typedef void* (ALAPIENTRY *LPALGETPROCADDRESS)( const ALchar* fname );
|
||||
typedef ALenum (ALAPIENTRY *LPALGETENUMVALUE)( const ALchar* ename );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERF)( ALenum param, ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALLISTENERI)( ALenum param, ALint value );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources );
|
||||
typedef void (ALAPIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISSOURCE)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value);
|
||||
typedef void (ALAPIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value);
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values );
|
||||
typedef void (ALAPIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPLAY)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCESTOP)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEREWIND)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEPAUSE)( ALuint sid );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids );
|
||||
typedef void (ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids );
|
||||
typedef void (ALAPIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers );
|
||||
typedef void (ALAPIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers );
|
||||
typedef ALboolean (ALAPIENTRY *LPALISBUFFER)( ALuint bid );
|
||||
typedef void (ALAPIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value );
|
||||
typedef void (ALAPIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value );
|
||||
typedef void (ALAPIENTRY *LPALDOPPLERFACTOR)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALDOPPLERVELOCITY)( ALfloat value );
|
||||
typedef void (ALAPIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel );
|
||||
|
||||
typedef ALCcontext * (ALCAPIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist);
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context );
|
||||
typedef void (ALCAPIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context );
|
||||
typedef ALCcontext * (ALCAPIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context );
|
||||
typedef ALCdevice * (ALCAPIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device );
|
||||
typedef ALCenum (ALCAPIENTRY *LPALCGETERROR)( ALCdevice *device );
|
||||
typedef ALCboolean (ALCAPIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname );
|
||||
typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname );
|
||||
typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
|
||||
typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
|
||||
typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LPALENABLE alEnable;
|
||||
LPALDISABLE alDisable;
|
||||
LPALISENABLED alIsEnabled;
|
||||
LPALGETBOOLEAN alGetBoolean;
|
||||
LPALGETINTEGER alGetInteger;
|
||||
LPALGETFLOAT alGetFloat;
|
||||
LPALGETDOUBLE alGetDouble;
|
||||
LPALGETBOOLEANV alGetBooleanv;
|
||||
LPALGETINTEGERV alGetIntegerv;
|
||||
LPALGETFLOATV alGetFloatv;
|
||||
LPALGETDOUBLEV alGetDoublev;
|
||||
LPALGETSTRING alGetString;
|
||||
LPALGETERROR alGetError;
|
||||
LPALISEXTENSIONPRESENT alIsExtensionPresent;
|
||||
LPALGETPROCADDRESS alGetProcAddress;
|
||||
LPALGETENUMVALUE alGetEnumValue;
|
||||
LPALLISTENERI alListeneri;
|
||||
LPALLISTENERF alListenerf;
|
||||
LPALLISTENER3F alListener3f;
|
||||
LPALLISTENERFV alListenerfv;
|
||||
LPALGETLISTENERI alGetListeneri;
|
||||
LPALGETLISTENERF alGetListenerf;
|
||||
LPALGETLISTENER3F alGetListener3f;
|
||||
LPALGETLISTENERFV alGetListenerfv;
|
||||
LPALGENSOURCES alGenSources;
|
||||
LPALDELETESOURCES alDeleteSources;
|
||||
LPALISSOURCE alIsSource;
|
||||
LPALSOURCEI alSourcei;
|
||||
LPALSOURCEF alSourcef;
|
||||
LPALSOURCE3F alSource3f;
|
||||
LPALSOURCEFV alSourcefv;
|
||||
LPALGETSOURCEI alGetSourcei;
|
||||
LPALGETSOURCEF alGetSourcef;
|
||||
LPALGETSOURCEFV alGetSourcefv;
|
||||
LPALSOURCEPLAYV alSourcePlayv;
|
||||
LPALSOURCESTOPV alSourceStopv;
|
||||
LPALSOURCEPLAY alSourcePlay;
|
||||
LPALSOURCEPAUSE alSourcePause;
|
||||
LPALSOURCESTOP alSourceStop;
|
||||
LPALGENBUFFERS alGenBuffers;
|
||||
LPALDELETEBUFFERS alDeleteBuffers;
|
||||
LPALISBUFFER alIsBuffer;
|
||||
LPALBUFFERDATA alBufferData;
|
||||
LPALGETBUFFERI alGetBufferi;
|
||||
LPALGETBUFFERF alGetBufferf;
|
||||
LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
|
||||
LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
|
||||
LPALDISTANCEMODEL alDistanceModel;
|
||||
LPALDOPPLERFACTOR alDopplerFactor;
|
||||
LPALDOPPLERVELOCITY alDopplerVelocity;
|
||||
LPALCGETSTRING alcGetString;
|
||||
LPALCGETINTEGERV alcGetIntegerv;
|
||||
LPALCOPENDEVICE alcOpenDevice;
|
||||
LPALCCLOSEDEVICE alcCloseDevice;
|
||||
LPALCCREATECONTEXT alcCreateContext;
|
||||
LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
|
||||
LPALCPROCESSCONTEXT alcProcessContext;
|
||||
LPALCGETCURRENTCONTEXT alcGetCurrentContext;
|
||||
LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
|
||||
LPALCSUSPENDCONTEXT alcSuspendContext;
|
||||
LPALCDESTROYCONTEXT alcDestroyContext;
|
||||
LPALCGETERROR alcGetError;
|
||||
LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
|
||||
LPALCGETPROCADDRESS alcGetProcAddress;
|
||||
LPALCGETENUMVALUE alcGetEnumValue;
|
||||
} OPENALFNTABLE, *LPOPENALFNTABLE;
|
||||
#endif
|
||||
|
||||
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable);
|
||||
ALvoid UnloadOAL10Library();
|
||||
|
|
|
@ -723,7 +723,7 @@ void MainWnd::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
|
|||
void MainWnd::OnMoving(UINT fwSide, LPRECT pRect)
|
||||
{
|
||||
CWnd::OnMoving(fwSide, pRect);
|
||||
|
||||
|
||||
if( emulating ) {
|
||||
soundPause();
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ void MainWnd::OnMoving(UINT fwSide, LPRECT pRect)
|
|||
void MainWnd::OnMove(int x, int y)
|
||||
{
|
||||
CWnd::OnMove(x, y);
|
||||
|
||||
|
||||
if(!theApp.changingVideoSize) {
|
||||
if(this) {
|
||||
if(!IsIconic()) {
|
||||
|
@ -1077,7 +1077,7 @@ bool MainWnd::fileOpenSelect( int system )
|
|||
filter = winLoadFilter( IDS_FILTER_GBROM );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
title = winResLoadString( IDS_SELECT_ROM );
|
||||
|
||||
if( !initialDir.IsEmpty() ) {
|
||||
|
|
|
@ -1768,7 +1768,7 @@ void MainWnd::OnOutputapiOalconfiguration()
|
|||
|
||||
dlg.selectedDevice = theApp.oalDevice;
|
||||
dlg.bufferCount = theApp.oalBufferCount;
|
||||
|
||||
|
||||
if( dlg.DoModal() == IDOK ) {
|
||||
systemSoundShutdown();
|
||||
// do this before changing any values OpenAL
|
||||
|
|
|
@ -344,36 +344,36 @@ void MainWnd::OnToolsRecordStartavirecording()
|
|||
{
|
||||
CString captureBuffer;
|
||||
CString capdir = regQueryStringValue( "aviRecordDir", NULL );
|
||||
|
||||
|
||||
if( capdir.IsEmpty() ) {
|
||||
capdir = getDirFromFile( theApp.filename );
|
||||
}
|
||||
|
||||
|
||||
CString filter = theApp.winLoadFilter( IDS_FILTER_AVI );
|
||||
CString title = winResLoadString( IDS_SELECT_AVI_NAME );
|
||||
|
||||
|
||||
LPCTSTR exts[] = { ".AVI" };
|
||||
|
||||
|
||||
FileDlg dlg( this, "", filter, 1, "AVI", exts, capdir, title, true );
|
||||
|
||||
|
||||
if( dlg.DoModal() == IDCANCEL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
|
||||
theApp.aviRecordName = captureBuffer;
|
||||
theApp.aviRecording = true;
|
||||
|
||||
|
||||
if( dlg.m_ofn.nFileOffset > 0 ) {
|
||||
captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset );
|
||||
}
|
||||
|
||||
|
||||
int len = captureBuffer.GetLength();
|
||||
|
||||
|
||||
if( ( len > 3 ) && captureBuffer[ len - 1 ] == '\\' ) {
|
||||
captureBuffer = captureBuffer.Left( len - 1 );
|
||||
}
|
||||
|
||||
|
||||
regSetStringValue( "aviRecordDir", captureBuffer );
|
||||
|
||||
|
||||
|
|
|
@ -1,91 +1,91 @@
|
|||
// src/win32/OALConfig.cpp : implementation file
|
||||
//
|
||||
|
||||
#ifndef NO_OAL
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OALConfig.h"
|
||||
|
||||
// OpenAL
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
|
||||
|
||||
// OALConfig dialog
|
||||
|
||||
IMPLEMENT_DYNAMIC(OALConfig, CDialog)
|
||||
|
||||
OALConfig::OALConfig(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(OALConfig::IDD, pParent)
|
||||
, selectedDevice(_T(""))
|
||||
, bufferCount(0)
|
||||
{
|
||||
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
|
||||
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
|
||||
}
|
||||
}
|
||||
|
||||
OALConfig::~OALConfig()
|
||||
{
|
||||
}
|
||||
|
||||
void OALConfig::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_DEVICE, m_cbDevice);
|
||||
|
||||
if( !pDX->m_bSaveAndValidate ) {
|
||||
// enumerate devices
|
||||
const ALchar *devices = NULL;
|
||||
devices = ALFunction.alcGetString( NULL, ALC_DEVICE_SPECIFIER );
|
||||
if( strlen( devices ) ) {
|
||||
while( *devices ) {
|
||||
m_cbDevice.AddString( devices );
|
||||
devices += strlen( devices ) + 1;
|
||||
}
|
||||
} else {
|
||||
systemMessage( IDS_OAL_NODEVICE, "There are no sound devices present on this system." );
|
||||
}
|
||||
}
|
||||
DDX_CBString(pDX, IDC_DEVICE, selectedDevice);
|
||||
DDX_Control(pDX, IDC_SLIDER_BUFFERCOUNT, m_sliderBufferCount);
|
||||
DDX_Slider(pDX, IDC_SLIDER_BUFFERCOUNT, bufferCount);
|
||||
DDX_Control(pDX, IDC_BUFFERINFO, m_bufferInfo);
|
||||
}
|
||||
|
||||
|
||||
BOOL OALConfig::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
m_sliderBufferCount.SetRange( 2, 10, FALSE );
|
||||
m_sliderBufferCount.SetTicFreq( 1 );
|
||||
m_sliderBufferCount.SetPos( bufferCount );
|
||||
|
||||
CString info;
|
||||
int pos = m_sliderBufferCount.GetPos();
|
||||
info.Format( _T("%i frames = %.2f ms"), pos, (float)pos / 60.0f * 1000.0f );
|
||||
m_bufferInfo.SetWindowText( info );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(OALConfig, CDialog)
|
||||
ON_WM_HSCROLL()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// OALConfig message handlers
|
||||
|
||||
void OALConfig::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
||||
{
|
||||
CString info;
|
||||
int pos = m_sliderBufferCount.GetPos();
|
||||
info.Format( _T("%i frames = %.2f ms"), pos, (float)pos / 60.0f * 1000.0f );
|
||||
m_bufferInfo.SetWindowText( info );
|
||||
|
||||
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
||||
#endif
|
||||
// src/win32/OALConfig.cpp : implementation file
|
||||
//
|
||||
|
||||
#ifndef NO_OAL
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "OALConfig.h"
|
||||
|
||||
// OpenAL
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
|
||||
|
||||
// OALConfig dialog
|
||||
|
||||
IMPLEMENT_DYNAMIC(OALConfig, CDialog)
|
||||
|
||||
OALConfig::OALConfig(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(OALConfig::IDD, pParent)
|
||||
, selectedDevice(_T(""))
|
||||
, bufferCount(0)
|
||||
{
|
||||
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
|
||||
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
|
||||
}
|
||||
}
|
||||
|
||||
OALConfig::~OALConfig()
|
||||
{
|
||||
}
|
||||
|
||||
void OALConfig::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_DEVICE, m_cbDevice);
|
||||
|
||||
if( !pDX->m_bSaveAndValidate ) {
|
||||
// enumerate devices
|
||||
const ALchar *devices = NULL;
|
||||
devices = ALFunction.alcGetString( NULL, ALC_DEVICE_SPECIFIER );
|
||||
if( strlen( devices ) ) {
|
||||
while( *devices ) {
|
||||
m_cbDevice.AddString( devices );
|
||||
devices += strlen( devices ) + 1;
|
||||
}
|
||||
} else {
|
||||
systemMessage( IDS_OAL_NODEVICE, "There are no sound devices present on this system." );
|
||||
}
|
||||
}
|
||||
DDX_CBString(pDX, IDC_DEVICE, selectedDevice);
|
||||
DDX_Control(pDX, IDC_SLIDER_BUFFERCOUNT, m_sliderBufferCount);
|
||||
DDX_Slider(pDX, IDC_SLIDER_BUFFERCOUNT, bufferCount);
|
||||
DDX_Control(pDX, IDC_BUFFERINFO, m_bufferInfo);
|
||||
}
|
||||
|
||||
|
||||
BOOL OALConfig::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
m_sliderBufferCount.SetRange( 2, 10, FALSE );
|
||||
m_sliderBufferCount.SetTicFreq( 1 );
|
||||
m_sliderBufferCount.SetPos( bufferCount );
|
||||
|
||||
CString info;
|
||||
int pos = m_sliderBufferCount.GetPos();
|
||||
info.Format( _T("%i frames = %.2f ms"), pos, (float)pos / 60.0f * 1000.0f );
|
||||
m_bufferInfo.SetWindowText( info );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(OALConfig, CDialog)
|
||||
ON_WM_HSCROLL()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// OALConfig message handlers
|
||||
|
||||
void OALConfig::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
||||
{
|
||||
CString info;
|
||||
int pos = m_sliderBufferCount.GetPos();
|
||||
info.Format( _T("%i frames = %.2f ms"), pos, (float)pos / 60.0f * 1000.0f );
|
||||
m_bufferInfo.SetWindowText( info );
|
||||
|
||||
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
#ifndef NO_OAL
|
||||
|
||||
#pragma once
|
||||
#include "afxwin.h"
|
||||
|
||||
// OpenAL
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
#include "afxcmn.h"
|
||||
|
||||
|
||||
// OALConfig dialog
|
||||
|
||||
class OALConfig : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(OALConfig)
|
||||
|
||||
public:
|
||||
OALConfig(CWnd* pParent = NULL); // standard constructor
|
||||
virtual ~OALConfig();
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_OAL_CONFIG };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
OPENALFNTABLE ALFunction;
|
||||
CComboBox m_cbDevice;
|
||||
CSliderCtrl m_sliderBufferCount;
|
||||
CStatic m_bufferInfo;
|
||||
public:
|
||||
CString selectedDevice;
|
||||
int bufferCount;
|
||||
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef NO_OAL
|
||||
|
||||
#pragma once
|
||||
#include "afxwin.h"
|
||||
|
||||
// OpenAL
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
#include "afxcmn.h"
|
||||
|
||||
|
||||
// OALConfig dialog
|
||||
|
||||
class OALConfig : public CDialog
|
||||
{
|
||||
DECLARE_DYNAMIC(OALConfig)
|
||||
|
||||
public:
|
||||
OALConfig(CWnd* pParent = NULL); // standard constructor
|
||||
virtual ~OALConfig();
|
||||
|
||||
// Dialog Data
|
||||
enum { IDD = IDD_OAL_CONFIG };
|
||||
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
OPENALFNTABLE ALFunction;
|
||||
CComboBox m_cbDevice;
|
||||
CSliderCtrl m_sliderBufferCount;
|
||||
CStatic m_bufferInfo;
|
||||
public:
|
||||
CString selectedDevice;
|
||||
int bufferCount;
|
||||
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,344 +1,344 @@
|
|||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 2007-2008 VBA-M development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef NO_OAL
|
||||
|
||||
|
||||
// === LOGALL writes very detailed informations to vba-trace.log ===
|
||||
//#define LOGALL
|
||||
|
||||
|
||||
#include "stdafx.h" // includes VBA.h for 'theApp.throttle'
|
||||
|
||||
// Interface
|
||||
#include "Sound.h"
|
||||
|
||||
// OpenAL
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
|
||||
// Windows
|
||||
#include <windows.h> // for 'Sleep' function
|
||||
|
||||
// Internals
|
||||
#include "../Sound.h"
|
||||
#include "../Globals.h" // for 'speedup' and 'synchronize'
|
||||
|
||||
// Debug
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef LOGALL
|
||||
// replace logging functions with comments
|
||||
#define winlog //
|
||||
#define debugState() //
|
||||
#endif
|
||||
|
||||
class OpenAL : public ISound
|
||||
{
|
||||
public:
|
||||
OpenAL();
|
||||
virtual ~OpenAL();
|
||||
|
||||
bool init(); // initialize the sound buffer queue
|
||||
void pause(); // pause the secondary sound buffer
|
||||
void reset(); // stop and reset the secondary sound buffer
|
||||
void resume(); // play/resume the secondary sound buffer
|
||||
void write(); // write the emulated sound to a sound buffer
|
||||
|
||||
private:
|
||||
OPENALFNTABLE ALFunction;
|
||||
bool initialized;
|
||||
bool buffersLoaded;
|
||||
ALCdevice *device;
|
||||
ALCcontext *context;
|
||||
ALuint *buffer;
|
||||
ALuint tempBuffer;
|
||||
ALuint source;
|
||||
int freq;
|
||||
|
||||
#ifdef LOGALL
|
||||
void debugState();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
OpenAL::OpenAL()
|
||||
{
|
||||
initialized = false;
|
||||
buffersLoaded = false;
|
||||
device = NULL;
|
||||
context = NULL;
|
||||
buffer = (ALuint*)malloc( theApp.oalBufferCount * sizeof( ALuint ) );
|
||||
memset( buffer, 0, theApp.oalBufferCount * sizeof( ALuint ) );
|
||||
tempBuffer = 0;
|
||||
source = 0;
|
||||
}
|
||||
|
||||
|
||||
OpenAL::~OpenAL()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
|
||||
ALFunction.alSourceStop( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alSourcei( source, AL_BUFFER, 0 );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alDeleteSources( 1, &source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alDeleteBuffers( theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
free( buffer );
|
||||
|
||||
ALFunction.alcMakeContextCurrent( NULL );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alcDestroyContext( context );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alcCloseDevice( device );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
#ifdef LOGALL
|
||||
void OpenAL::debugState()
|
||||
{
|
||||
|
||||
ALint value = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &value );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
winlog( " soundPaused = %i\n", soundPaused );
|
||||
winlog( " Source:\n" );
|
||||
winlog( " State: " );
|
||||
switch( value )
|
||||
{
|
||||
case AL_INITIAL:
|
||||
winlog( "AL_INITIAL\n" );
|
||||
break;
|
||||
case AL_PLAYING:
|
||||
winlog( "AL_PLAYING\n" );
|
||||
break;
|
||||
case AL_PAUSED:
|
||||
winlog( "AL_PAUSED\n" );
|
||||
break;
|
||||
case AL_STOPPED:
|
||||
winlog( "AL_STOPPED\n" );
|
||||
break;
|
||||
default:
|
||||
winlog( "!unknown!\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_QUEUED, &value );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
winlog( " Buffers in queue: %i\n", value );
|
||||
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &value );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
winlog( " Buffers processed: %i\n", value );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool OpenAL::init()
|
||||
{
|
||||
winlog( "OpenAL::init\n" );
|
||||
assert( initialized == false );
|
||||
|
||||
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
|
||||
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( theApp.oalDevice ) {
|
||||
device = ALFunction.alcOpenDevice( theApp.oalDevice );
|
||||
} else {
|
||||
device = ALFunction.alcOpenDevice( NULL );
|
||||
}
|
||||
assert( device != NULL );
|
||||
|
||||
context = ALFunction.alcCreateContext( device, NULL );
|
||||
assert( context != NULL );
|
||||
|
||||
ALCboolean retVal = ALFunction.alcMakeContextCurrent( context );
|
||||
assert( ALC_TRUE == retVal );
|
||||
|
||||
ALFunction.alGenBuffers( theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alGenSources( 1, &source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
freq = 44100 / soundQuality;
|
||||
|
||||
// calculate the number of samples per frame first
|
||||
// then multiply it with the size of a sample frame (16 bit * stereo)
|
||||
soundBufferLen = ( freq / 60 ) * 4;
|
||||
|
||||
|
||||
setsystemSoundOn( true );
|
||||
initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::resume()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::resume\n" );
|
||||
if( !buffersLoaded ) return;
|
||||
debugState();
|
||||
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( sourceState != AL_PLAYING ) {
|
||||
ALFunction.alSourcePlay( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
debugState();
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::pause()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::pause\n" );
|
||||
if( !buffersLoaded ) return;
|
||||
debugState();
|
||||
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( sourceState == AL_PLAYING ) {
|
||||
ALFunction.alSourcePause( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
debugState();
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::reset()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::reset\n" );
|
||||
if( !buffersLoaded ) return;
|
||||
debugState();
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( sourceState != AL_STOPPED ) {
|
||||
ALFunction.alSourceStop( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
debugState();
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::write()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::write\n" );
|
||||
|
||||
debugState();
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALint nBuffersProcessed = 0;
|
||||
|
||||
if( !buffersLoaded ) {
|
||||
// ==initial buffer filling==
|
||||
winlog( " initial buffer filling\n" );
|
||||
for( int i = 0 ; i < theApp.oalBufferCount ; i++ ) {
|
||||
// Filling the buffers explicitly with silence would be cleaner,
|
||||
// but the very first sample is usually silence anyway.
|
||||
ALFunction.alBufferData( buffer[i], AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
ALFunction.alSourceQueueBuffers( source, theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
buffersLoaded = true;
|
||||
} else {
|
||||
// ==normal buffer refreshing==
|
||||
nBuffersProcessed = 0;
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
if( nBuffersProcessed == theApp.oalBufferCount ) {
|
||||
if( ( theApp.throttle >= 100 ) || ( theApp.throttle == 0 ) ) {
|
||||
// we only want to know about it when we are emulating at full speed (or faster)
|
||||
static int i = 0;
|
||||
log( "OpenAL: Buffers were not refilled fast enough (%i)\n", i++ );
|
||||
}
|
||||
}
|
||||
|
||||
if( !speedup && synchronize && !theApp.throttle ) {
|
||||
// wait until at least one buffer has finished
|
||||
while( nBuffersProcessed == 0 ) {
|
||||
winlog( " waiting...\n" );
|
||||
// wait for about half the time one buffer needs to finish
|
||||
// unoptimized: ( sourceBufferLen * 1000 ) / ( freq * 2 * 2 ) * 1/2
|
||||
Sleep( soundBufferLen / ( freq >> 7 ) );
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
} else {
|
||||
if( nBuffersProcessed == 0 ) return;
|
||||
}
|
||||
|
||||
assert( nBuffersProcessed > 0 );
|
||||
|
||||
// tempBuffer contains the Buffer ID for the unqueued Buffer
|
||||
tempBuffer = 0;
|
||||
ALFunction.alSourceUnqueueBuffers( source, 1, &tempBuffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alBufferData( tempBuffer, AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
// refill buffer
|
||||
ALFunction.alSourceQueueBuffers( source, 1, &tempBuffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
// start playing the source if necessary
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( !soundPaused && ( sourceState != AL_PLAYING ) ) {
|
||||
ALFunction.alSourcePlay( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ISound *newOpenAL()
|
||||
{
|
||||
winlog( "newOpenAL\n" );
|
||||
return new OpenAL();
|
||||
}
|
||||
|
||||
#endif
|
||||
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
|
||||
// Copyright (C) 2007-2008 VBA-M development team
|
||||
|
||||
// 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, 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.
|
||||
|
||||
#ifndef NO_OAL
|
||||
|
||||
|
||||
// === LOGALL writes very detailed informations to vba-trace.log ===
|
||||
//#define LOGALL
|
||||
|
||||
|
||||
#include "stdafx.h" // includes VBA.h for 'theApp.throttle'
|
||||
|
||||
// Interface
|
||||
#include "Sound.h"
|
||||
|
||||
// OpenAL
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "LoadOAL.h"
|
||||
|
||||
// Windows
|
||||
#include <windows.h> // for 'Sleep' function
|
||||
|
||||
// Internals
|
||||
#include "../Sound.h"
|
||||
#include "../Globals.h" // for 'speedup' and 'synchronize'
|
||||
|
||||
// Debug
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef LOGALL
|
||||
// replace logging functions with comments
|
||||
#define winlog //
|
||||
#define debugState() //
|
||||
#endif
|
||||
|
||||
class OpenAL : public ISound
|
||||
{
|
||||
public:
|
||||
OpenAL();
|
||||
virtual ~OpenAL();
|
||||
|
||||
bool init(); // initialize the sound buffer queue
|
||||
void pause(); // pause the secondary sound buffer
|
||||
void reset(); // stop and reset the secondary sound buffer
|
||||
void resume(); // play/resume the secondary sound buffer
|
||||
void write(); // write the emulated sound to a sound buffer
|
||||
|
||||
private:
|
||||
OPENALFNTABLE ALFunction;
|
||||
bool initialized;
|
||||
bool buffersLoaded;
|
||||
ALCdevice *device;
|
||||
ALCcontext *context;
|
||||
ALuint *buffer;
|
||||
ALuint tempBuffer;
|
||||
ALuint source;
|
||||
int freq;
|
||||
|
||||
#ifdef LOGALL
|
||||
void debugState();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
OpenAL::OpenAL()
|
||||
{
|
||||
initialized = false;
|
||||
buffersLoaded = false;
|
||||
device = NULL;
|
||||
context = NULL;
|
||||
buffer = (ALuint*)malloc( theApp.oalBufferCount * sizeof( ALuint ) );
|
||||
memset( buffer, 0, theApp.oalBufferCount * sizeof( ALuint ) );
|
||||
tempBuffer = 0;
|
||||
source = 0;
|
||||
}
|
||||
|
||||
|
||||
OpenAL::~OpenAL()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
|
||||
ALFunction.alSourceStop( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alSourcei( source, AL_BUFFER, 0 );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alDeleteSources( 1, &source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alDeleteBuffers( theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
free( buffer );
|
||||
|
||||
ALFunction.alcMakeContextCurrent( NULL );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alcDestroyContext( context );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alcCloseDevice( device );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
#ifdef LOGALL
|
||||
void OpenAL::debugState()
|
||||
{
|
||||
|
||||
ALint value = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &value );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
winlog( " soundPaused = %i\n", soundPaused );
|
||||
winlog( " Source:\n" );
|
||||
winlog( " State: " );
|
||||
switch( value )
|
||||
{
|
||||
case AL_INITIAL:
|
||||
winlog( "AL_INITIAL\n" );
|
||||
break;
|
||||
case AL_PLAYING:
|
||||
winlog( "AL_PLAYING\n" );
|
||||
break;
|
||||
case AL_PAUSED:
|
||||
winlog( "AL_PAUSED\n" );
|
||||
break;
|
||||
case AL_STOPPED:
|
||||
winlog( "AL_STOPPED\n" );
|
||||
break;
|
||||
default:
|
||||
winlog( "!unknown!\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_QUEUED, &value );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
winlog( " Buffers in queue: %i\n", value );
|
||||
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &value );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
winlog( " Buffers processed: %i\n", value );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool OpenAL::init()
|
||||
{
|
||||
winlog( "OpenAL::init\n" );
|
||||
assert( initialized == false );
|
||||
|
||||
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
|
||||
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( theApp.oalDevice ) {
|
||||
device = ALFunction.alcOpenDevice( theApp.oalDevice );
|
||||
} else {
|
||||
device = ALFunction.alcOpenDevice( NULL );
|
||||
}
|
||||
assert( device != NULL );
|
||||
|
||||
context = ALFunction.alcCreateContext( device, NULL );
|
||||
assert( context != NULL );
|
||||
|
||||
ALCboolean retVal = ALFunction.alcMakeContextCurrent( context );
|
||||
assert( ALC_TRUE == retVal );
|
||||
|
||||
ALFunction.alGenBuffers( theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alGenSources( 1, &source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
freq = 44100 / soundQuality;
|
||||
|
||||
// calculate the number of samples per frame first
|
||||
// then multiply it with the size of a sample frame (16 bit * stereo)
|
||||
soundBufferLen = ( freq / 60 ) * 4;
|
||||
|
||||
|
||||
setsystemSoundOn( true );
|
||||
initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::resume()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::resume\n" );
|
||||
if( !buffersLoaded ) return;
|
||||
debugState();
|
||||
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( sourceState != AL_PLAYING ) {
|
||||
ALFunction.alSourcePlay( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
debugState();
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::pause()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::pause\n" );
|
||||
if( !buffersLoaded ) return;
|
||||
debugState();
|
||||
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( sourceState == AL_PLAYING ) {
|
||||
ALFunction.alSourcePause( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
debugState();
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::reset()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::reset\n" );
|
||||
if( !buffersLoaded ) return;
|
||||
debugState();
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( sourceState != AL_STOPPED ) {
|
||||
ALFunction.alSourceStop( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
debugState();
|
||||
}
|
||||
|
||||
|
||||
void OpenAL::write()
|
||||
{
|
||||
if( !initialized ) return;
|
||||
winlog( "OpenAL::write\n" );
|
||||
|
||||
debugState();
|
||||
|
||||
ALint sourceState = 0;
|
||||
ALint nBuffersProcessed = 0;
|
||||
|
||||
if( !buffersLoaded ) {
|
||||
// ==initial buffer filling==
|
||||
winlog( " initial buffer filling\n" );
|
||||
for( int i = 0 ; i < theApp.oalBufferCount ; i++ ) {
|
||||
// Filling the buffers explicitly with silence would be cleaner,
|
||||
// but the very first sample is usually silence anyway.
|
||||
ALFunction.alBufferData( buffer[i], AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
ALFunction.alSourceQueueBuffers( source, theApp.oalBufferCount, buffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
buffersLoaded = true;
|
||||
} else {
|
||||
// ==normal buffer refreshing==
|
||||
nBuffersProcessed = 0;
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
if( nBuffersProcessed == theApp.oalBufferCount ) {
|
||||
if( ( theApp.throttle >= 100 ) || ( theApp.throttle == 0 ) ) {
|
||||
// we only want to know about it when we are emulating at full speed (or faster)
|
||||
static int i = 0;
|
||||
log( "OpenAL: Buffers were not refilled fast enough (%i)\n", i++ );
|
||||
}
|
||||
}
|
||||
|
||||
if( !speedup && synchronize && !theApp.throttle ) {
|
||||
// wait until at least one buffer has finished
|
||||
while( nBuffersProcessed == 0 ) {
|
||||
winlog( " waiting...\n" );
|
||||
// wait for about half the time one buffer needs to finish
|
||||
// unoptimized: ( sourceBufferLen * 1000 ) / ( freq * 2 * 2 ) * 1/2
|
||||
Sleep( soundBufferLen / ( freq >> 7 ) );
|
||||
ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
} else {
|
||||
if( nBuffersProcessed == 0 ) return;
|
||||
}
|
||||
|
||||
assert( nBuffersProcessed > 0 );
|
||||
|
||||
// tempBuffer contains the Buffer ID for the unqueued Buffer
|
||||
tempBuffer = 0;
|
||||
ALFunction.alSourceUnqueueBuffers( source, 1, &tempBuffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
ALFunction.alBufferData( tempBuffer, AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
|
||||
// refill buffer
|
||||
ALFunction.alSourceQueueBuffers( source, 1, &tempBuffer );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
|
||||
// start playing the source if necessary
|
||||
ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
if( !soundPaused && ( sourceState != AL_PLAYING ) ) {
|
||||
ALFunction.alSourcePlay( source );
|
||||
assert( AL_NO_ERROR == ALFunction.alGetError() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ISound *newOpenAL()
|
||||
{
|
||||
winlog( "newOpenAL\n" );
|
||||
return new OpenAL();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -75,7 +75,7 @@ private:
|
|||
bool failed;
|
||||
GLFONT font;
|
||||
int pitch;
|
||||
GLuint displaylist;
|
||||
GLuint displaylist;
|
||||
u8 *data;
|
||||
GLhandleARB v,f,p,t;
|
||||
DWORD currentAdapter;
|
||||
|
@ -191,7 +191,7 @@ void OpenGLDisplay::cleanup()
|
|||
glDeleteTextures(1, &texture);
|
||||
texture = 0;
|
||||
}
|
||||
|
||||
|
||||
if (displaylist)
|
||||
{
|
||||
glDeleteLists(displaylist, 1);
|
||||
|
@ -301,7 +301,7 @@ bool OpenGLDisplay::initialize()
|
|||
if( theApp.videoOption <= VIDEO_4X )
|
||||
AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
|
||||
else
|
||||
AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );
|
||||
AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );
|
||||
|
||||
int winSizeX = theApp.dest.right - theApp.dest.left;
|
||||
int winSizeY = theApp.dest.bottom - theApp.dest.top;
|
||||
|
@ -327,14 +327,14 @@ bool OpenGLDisplay::initialize()
|
|||
x,y,winSizeX,winSizeY,
|
||||
NULL,
|
||||
0 );
|
||||
|
||||
|
||||
if (!(HWND)*pWnd) {
|
||||
winlog("Error creating Window %08x\n", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
theApp.updateMenuBar();
|
||||
|
||||
|
||||
theApp.adjustDestRect();
|
||||
theApp.mode320Available = FALSE;
|
||||
theApp.mode640Available = FALSE;
|
||||
|
@ -342,7 +342,7 @@ bool OpenGLDisplay::initialize()
|
|||
theApp.mode1024Available = FALSE;
|
||||
theApp.mode1280Available = FALSE;
|
||||
|
||||
|
||||
|
||||
currentAdapter = theApp.fsAdapter;
|
||||
DISPLAY_DEVICE dev;
|
||||
ZeroMemory( &dev, sizeof(dev) );
|
||||
|
@ -376,7 +376,7 @@ bool OpenGLDisplay::initialize()
|
|||
glEnable( GL_TEXTURE_2D );
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
||||
initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );
|
||||
|
||||
setVSync( theApp.vsync );
|
||||
|
@ -409,7 +409,7 @@ bool OpenGLDisplay::initialize()
|
|||
return true;
|
||||
}
|
||||
|
||||
//clear colour buffer
|
||||
//clear colour buffer
|
||||
void OpenGLDisplay::clear()
|
||||
{
|
||||
glClearColor(0.0,0.0,0.0,1.0);
|
||||
|
@ -440,7 +440,7 @@ void OpenGLDisplay::renderlist()
|
|||
|
||||
//main render func
|
||||
void OpenGLDisplay::render()
|
||||
{
|
||||
{
|
||||
clear();
|
||||
|
||||
pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
||||
|
@ -468,11 +468,11 @@ void OpenGLDisplay::render()
|
|||
glPixelStorei( GL_UNPACK_ROW_LENGTH, theApp.sizeX + 1 );
|
||||
}
|
||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,data );
|
||||
|
||||
|
||||
glCallList(displaylist);
|
||||
|
||||
|
||||
|
||||
glCallList(displaylist);
|
||||
|
||||
|
||||
if( theApp.showSpeed ) { // && ( theApp.videoOption > VIDEO_4X ) ) {
|
||||
char buffer[30];
|
||||
if( theApp.showSpeed == 1 ) {
|
||||
|
@ -508,12 +508,12 @@ void OpenGLDisplay::render()
|
|||
theApp.screenMessage = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glFlush();
|
||||
SwapBuffers( hDC );
|
||||
// since OpenGL draws on the back buffer,
|
||||
// we have to swap it to the front buffer to see the content
|
||||
|
||||
|
||||
}
|
||||
|
||||
//resize screen
|
||||
|
|
|
@ -1187,7 +1187,7 @@ int systemGetSensorY()
|
|||
bool systemSoundInit()
|
||||
{
|
||||
systemSoundShutdown();
|
||||
|
||||
|
||||
switch( theApp.audioAPI )
|
||||
{
|
||||
case DIRECTSOUND:
|
||||
|
@ -1219,7 +1219,7 @@ void systemSoundShutdown()
|
|||
}
|
||||
theApp.soundRecording = false;
|
||||
|
||||
|
||||
|
||||
if( theApp.sound ) {
|
||||
delete theApp.sound;
|
||||
theApp.sound = NULL;
|
||||
|
@ -1281,7 +1281,7 @@ void systemWriteDataToSoundBuffer()
|
|||
|
||||
if( theApp.sound ) {
|
||||
theApp.sound->write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool systemCanChangeSoundQuality()
|
||||
|
@ -1803,8 +1803,8 @@ void VBA::updateWindowSize(int value)
|
|||
return;
|
||||
}
|
||||
input->checkKeys();
|
||||
|
||||
|
||||
|
||||
|
||||
changingVideoSize = FALSE;
|
||||
updateWindowSize(videoOption);
|
||||
return;
|
||||
|
|
|
@ -847,7 +847,7 @@
|
|||
#define ID_FILE_OPEN_GBC 40358
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 163
|
||||
|
|
Loading…
Reference in New Issue