Updated vio2sf.

CQTexperiment
Chris Moeller 2015-03-14 17:30:00 -07:00
parent df157bd7ce
commit d62a6463af
11 changed files with 1050 additions and 182 deletions

View File

@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
833B1A3E180BAD0200414852 /* isqrt.c in Sources */ = {isa = PBXBuildFile; fileRef = 833B1A3A180BAD0200414852 /* isqrt.c */; };
833B1A3F180BAD0200414852 /* isqrt.h in Headers */ = {isa = PBXBuildFile; fileRef = 833B1A3B180BAD0200414852 /* isqrt.h */; };
83699ABA1AB3D8EB00F5A6E3 /* barray.c in Sources */ = {isa = PBXBuildFile; fileRef = 83699AB81AB3D8EB00F5A6E3 /* barray.c */; };
83699ABB1AB3D8EB00F5A6E3 /* barray.h in Headers */ = {isa = PBXBuildFile; fileRef = 83699AB91AB3D8EB00F5A6E3 /* barray.h */; };
83DD1A0318EA634F00DADA1A /* resampler.c in Sources */ = {isa = PBXBuildFile; fileRef = 83DD1A0118EA634F00DADA1A /* resampler.c */; };
83DD1A0418EA634F00DADA1A /* resampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 83DD1A0218EA634F00DADA1A /* resampler.h */; };
83DE0C14180A9BD400269051 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 83DE0C12180A9BD400269051 /* InfoPlist.strings */; };
@ -55,6 +57,8 @@
/* Begin PBXFileReference section */
833B1A3A180BAD0200414852 /* isqrt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = isqrt.c; sourceTree = "<group>"; };
833B1A3B180BAD0200414852 /* isqrt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = isqrt.h; sourceTree = "<group>"; };
83699AB81AB3D8EB00F5A6E3 /* barray.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = barray.c; sourceTree = "<group>"; };
83699AB91AB3D8EB00F5A6E3 /* barray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = barray.h; sourceTree = "<group>"; };
83DD1A0118EA634F00DADA1A /* resampler.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = resampler.c; sourceTree = "<group>"; };
83DD1A0218EA634F00DADA1A /* resampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resampler.h; sourceTree = "<group>"; };
83DE0C06180A9BD400269051 /* vio2sf.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = vio2sf.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@ -173,6 +177,8 @@
83DE0C45180A9CA400269051 /* desmume */ = {
isa = PBXGroup;
children = (
83699AB81AB3D8EB00F5A6E3 /* barray.c */,
83699AB91AB3D8EB00F5A6E3 /* barray.h */,
83DD1A0118EA634F00DADA1A /* resampler.c */,
83DD1A0218EA634F00DADA1A /* resampler.h */,
833B1A3A180BAD0200414852 /* isqrt.c */,
@ -241,6 +247,7 @@
83DD1A0418EA634F00DADA1A /* resampler.h in Headers */,
83DE0C89180A9CA400269051 /* config.h in Headers */,
83DE0C8D180A9CA400269051 /* debug.h in Headers */,
83699ABB1AB3D8EB00F5A6E3 /* barray.h in Headers */,
83DE0C98180A9CA400269051 /* mem.h in Headers */,
83DE0C90180A9CA400269051 /* FIFO.h in Headers */,
83DE0C92180A9CA400269051 /* GPU.h in Headers */,
@ -325,6 +332,7 @@
83DE0CA6180A9CA400269051 /* thumb_tabdef.inc in Sources */,
83DE0C96180A9CA400269051 /* mc.c in Sources */,
83DE0C91180A9CA400269051 /* GPU.c in Sources */,
83699ABA1AB3D8EB00F5A6E3 /* barray.c in Sources */,
83DE0CA4180A9CA400269051 /* thumb_instructions.c in Sources */,
83DE0C84180A9CA400269051 /* armcpu.c in Sources */,
83DE0C94180A9CA400269051 /* matrix.c in Sources */,

View File

@ -44,6 +44,8 @@
#include "registers.h"
#include "isqrt.h"
#include "barray.h"
#if VIO2SF_GPU_ENABLE
#include "render3D.h"
#else
@ -543,6 +545,14 @@ u8 FASTCALL MMU_read8(NDS_state *state, u32 proc, u32 adr)
return WIFI_read16(&state->wifiMac,adr) & 0xFF;
}
#endif
if (state->array_rom_coverage)
{
if (state->MMU->MMU_MEM[proc][(adr>>20)&0xFF] == state->MMU->CART_ROM)
{
bit_array_set(state->array_rom_coverage, (adr & state->MMU->MMU_MASK[proc][(adr>>20)&0xFF]) / 4);
}
}
return state->MMU->MMU_MEM[proc][(adr>>20)&0xFF][adr&state->MMU->MMU_MASK[proc][(adr>>20)&0xFF]];
}
@ -618,7 +628,15 @@ u16 FASTCALL MMU_read16(NDS_state *state, u32 proc, u32 adr)
}
}
/* Returns data from memory */
if (state->array_rom_coverage)
{
if (state->MMU->MMU_MEM[proc][(adr>>20)&0xFF] == state->MMU->CART_ROM)
{
bit_array_set(state->array_rom_coverage, (adr & state->MMU->MMU_MASK[proc][(adr>>20)&0xFF]) / 4);
}
}
/* Returns data from memory */
return T1ReadWord(state->MMU->MMU_MEM[proc][(adr >> 20) & 0xFF], adr & state->MMU->MMU_MASK[proc][(adr >> 20) & 0xFF]);
}
@ -792,6 +810,14 @@ u32 FASTCALL MMU_read32(NDS_state *state, u32 proc, u32 adr)
}
}
if (state->array_rom_coverage)
{
if (state->MMU->MMU_MEM[proc][(adr>>20)&0xFF] == state->MMU->CART_ROM)
{
bit_array_set(state->array_rom_coverage, (adr & state->MMU->MMU_MASK[proc][(adr>>20)&0xFF]) / 4);
}
}
/* Returns data from memory */
return T1ReadLong(state->MMU->MMU_MEM[proc][(adr >> 20) & 0xFF], adr & state->MMU->MMU_MASK[proc][(adr >> 20) & 0xFF]);
}

View File

@ -29,6 +29,8 @@
//#include "cflash.h"
#include "spu_exports.h"
#include "barray.h"
//#include "ROMReader.h"
/* the count of bytes copied from the firmware into memory */
@ -245,6 +247,13 @@ NDS_header * NDS_getROMHeader(NDS_state *state)
header->logoCRC16 = T1ReadWord(state->MMU->CART_ROM, 348);
header->headerCRC16 = T1ReadWord(state->MMU->CART_ROM, 350);
memcpy(header->reserved, state->MMU->CART_ROM + 352, 160);
if (state->array_rom_coverage)
{
int i;
for (i = 0; i < 0x200 / 4; ++i)
bit_array_set(state->array_rom_coverage, i);
}
return header;
@ -284,6 +293,8 @@ void NDS_Reset( NDS_state *state)
for(i = 0; i < (header->ARM9binSize>>2); ++i)
{
if (state->array_rom_coverage)
bit_array_set(state->array_rom_coverage, src/4);
MMU_write32(state, 0, dst, T1ReadLong(state->MMU->CART_ROM, src));
dst += 4;
src += 4;
@ -294,6 +305,8 @@ void NDS_Reset( NDS_state *state)
for(i = 0; i < (header->ARM7binSize>>2); ++i)
{
if (state->array_rom_coverage)
bit_array_set(state->array_rom_coverage, src/4);
MMU_write32(state, 1, dst, T1ReadLong(state->MMU->CART_ROM, src));
dst += 4;
src += 4;

View File

@ -78,8 +78,8 @@ const unsigned char arm_cond_table[16*16] = {
0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20,
};
armcpu_t NDS_ARM7;
armcpu_t NDS_ARM9;
/*armcpu_t NDS_ARM7;
armcpu_t NDS_ARM9;*/
#define SWAP(a, b, c) do \
{ \

View File

@ -0,0 +1,212 @@
#include "barray.h"
#include <string.h>
void * bit_array_create(size_t size)
{
size_t bsize = ((size + 7) >> 3) + sizeof(size_t);
void * ret = calloc(1, bsize);
if (ret) *(size_t *)ret = size;
return ret;
}
void bit_array_destroy(void * array)
{
if (array) free(array);
}
void * bit_array_dup(const void * array)
{
if (array)
{
const size_t * size = (const size_t *) array;
size_t bsize = ((*size + 7) >> 3) + sizeof(*size);
void * ret = malloc(bsize);
if (ret) memcpy(ret, array, bsize);
return ret;
}
return NULL;
}
void bit_array_reset(void * array)
{
if (array)
{
size_t * size = (size_t *) array;
size_t bsize = (*size + 7) >> 3;
memset(size + 1, 0, bsize);
}
}
size_t bit_array_size(const void * array)
{
if (array)
{
return *(const size_t *) array;
}
return 0;
}
size_t bit_array_count(const void * array)
{
if (array)
{
size_t i;
size_t count = 0;
const size_t * size = (const size_t *) array;
for (i = 0; i < *size; ++i)
count += bit_array_test(array, i);
return count;
}
return 0;
}
void bit_array_set(void * array, size_t bit)
{
if (array)
{
size_t * size = (size_t *) array;
if (bit < *size)
{
unsigned char * ptr = (unsigned char *)(size + 1);
ptr[bit >> 3] |= (1U << (bit & 7));
}
}
}
void bit_array_set_range(void * array, size_t bit, size_t count)
{
if (array && count)
{
size_t * size = (size_t *) array;
if (bit < *size)
{
unsigned char * ptr = (unsigned char *)(size + 1);
size_t i;
for (i = bit; i < *size && i < bit + count; ++i)
ptr[i >> 3] |= (1U << (i & 7));
}
}
}
int bit_array_test(const void * array, size_t bit)
{
if (array)
{
const size_t * size = (const size_t *) array;
if (bit < *size)
{
const unsigned char * ptr = (const unsigned char *)(size + 1);
if (ptr[bit >> 3] & (1U << (bit & 7)))
{
return 1;
}
}
}
return 0;
}
int bit_array_test_range(const void * array, size_t bit, size_t count)
{
if (array)
{
const size_t * size = (const size_t *) array;
if (bit < *size)
{
const unsigned char * ptr = (const unsigned char *)(size + 1);
if ((bit & 7) && (count > 8))
{
while ((bit < *size) && count && (bit & 7))
{
if (ptr[bit >> 3] & (1U << (bit & 7))) return 1;
bit++;
count--;
}
}
if (!(bit & 7))
{
while (((*size - bit) >= 8) && (count >= 8))
{
if (ptr[bit >> 3]) return 1;
bit += 8;
count -= 8;
}
}
while ((bit < *size) && count)
{
if (ptr[bit >> 3] & (1U << (bit & 7))) return 1;
bit++;
count--;
}
}
}
return 0;
}
void bit_array_clear(void * array, size_t bit)
{
if (array)
{
size_t * size = (size_t *) array;
if (bit < *size)
{
unsigned char * ptr = (unsigned char *)(size + 1);
ptr[bit >> 3] &= ~(1U << (bit & 7));
}
}
}
void bit_array_clear_range(void * array, size_t bit, size_t count)
{
if (array && count)
{
size_t * size = (size_t *) array;
if (bit < *size)
{
unsigned char * ptr = (unsigned char *)(size + 1);
size_t i;
for (i = bit; i < *size && i < bit + count; ++i)
ptr[i >> 3] &= ~(1U << (i & 7));
}
}
}
void bit_array_merge(void * dest, const void * source, size_t offset)
{
if (dest && source)
{
size_t * dsize = (size_t *) dest;
const size_t * ssize = (const size_t *) source;
size_t soffset = 0;
while (offset < *dsize && soffset < *ssize)
{
if (bit_array_test(source, soffset))
{
bit_array_set(dest, offset);
}
soffset++;
offset++;
}
}
}
void bit_array_mask(void * dest, const void * source, size_t offset)
{
if (dest && source)
{
size_t * dsize = (size_t *) dest;
const size_t * ssize = (const size_t *) source;
size_t soffset = 0;
while (offset < *dsize && soffset < *ssize)
{
if (bit_array_test(source, soffset))
{
bit_array_clear(dest, offset);
}
soffset++;
offset++;
}
}
}

View File

@ -0,0 +1,55 @@
#ifndef _B_ARRAY_H_
#define _B_ARRAY_H_
#include <stdlib.h>
#ifdef BARRAY_DECORATE
#define PASTE(a,b) a ## b
#define EVALUATE(a,b) PASTE(a,b)
#define bit_array_create EVALUATE(BARRAY_DECORATE,_bit_array_create)
#define bit_array_destroy EVALUATE(BARRAY_DECORATE,_bit_array_destroy)
#define bit_array_dup EVALUATE(BARRAY_DECORATE,_bit_array_dup)
#define bit_array_size EVALUATE(BARRAY_DECORATE,_bit_array_size)
#define bit_array_reset EVALUATE(BARRAY_DECORATE,_bit_array_reset)
#define bit_array_count EVALUATE(BARRAY_DECORATE,_bit_array_count)
#define bit_array_set EVALUATE(BARRAY_DECORATE,_bit_array_set)
#define bit_array_set_range EVALUATE(BARRAY_DECORATE,_bit_array_set_range)
#define bit_array_test EVALUATE(BARRAY_DECORATE,_bit_array_test)
#define bit_array_test_range EVALUATE(BARRAY_DECORATE,_bit_array_test_range)
#define bit_array_clear EVALUATE(BARRAY_DECORATE,_bit_array_clear)
#define bit_array_clear_range EVALUATE(BARRAY_DECORATE,_bit_array_clear_range)
#define bit_array_merge EVALUATE(BARRAY_DECORATE,_bit_array_merge)
#define bit_array_mask EVALUATE(BARRAY_DECORATE,_bit_array_mask)
#endif
#ifdef __cplusplus
extern "C" {
#endif
void * bit_array_create(size_t size);
void bit_array_destroy(void * array);
void * bit_array_dup(const void * array);
size_t bit_array_size(const void * array);
void bit_array_reset(void * array);
size_t bit_array_count(const void * array);
void bit_array_set(void * array, size_t bit);
void bit_array_set_range(void * array, size_t bit, size_t count);
int bit_array_test(const void * array, size_t bit);
int bit_array_test_range(const void * array, size_t bit, size_t count);
void bit_array_clear(void * array, size_t bit);
void bit_array_clear_range(void * array, size_t bit, size_t count);
void bit_array_merge(void * array, const void * source, size_t offset);
void bit_array_mask(void * array, const void * source, size_t offset);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -13,18 +13,16 @@
#define resampler_set_quality EVALUATE(RESAMPLER_DECORATE,_resampler_set_quality)
#define resampler_get_free_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_free_count)
#define resampler_write_sample EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample)
#define resampler_write_sample_fixed EVALUATE(RESAMPLER_DECORATE,_resampler_write_sample_fixed)
#define resampler_set_rate EVALUATE(RESAMPLER_DECORATE,_resampler_set_rate)
#define resampler_ready EVALUATE(RESAMPLER_DECORATE,_resampler_ready)
#define resampler_clear EVALUATE(RESAMPLER_DECORATE,_resampler_clear)
#define resampler_get_sample_count EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample_count)
#define resampler_get_sample EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample)
#define resampler_get_sample_float EVALUATE(RESAMPLER_DECORATE,_resampler_get_sample_float)
#define resampler_remove_sample EVALUATE(RESAMPLER_DECORATE,_resampler_remove_sample)
#endif
#ifdef __cplusplus
extern "C" {
#endif
void resampler_init(void);
void * resampler_create(void);
@ -38,24 +36,23 @@ enum
RESAMPLER_QUALITY_ZOH = 0,
RESAMPLER_QUALITY_BLEP = 1,
RESAMPLER_QUALITY_LINEAR = 2,
RESAMPLER_QUALITY_CUBIC = 3,
RESAMPLER_QUALITY_SINC = 4,
RESAMPLER_QUALITY_MAX = 4
RESAMPLER_QUALITY_BLAM = 3,
RESAMPLER_QUALITY_CUBIC = 4,
RESAMPLER_QUALITY_SINC = 5,
RESAMPLER_QUALITY_MAX = 5
};
void resampler_set_quality(void *, int quality);
int resampler_get_free_count(void *);
void resampler_write_sample(void *, int sample);
void resampler_write_sample(void *, short sample);
void resampler_write_sample_fixed(void *, int sample, unsigned char depth);
void resampler_set_rate( void *, double new_factor );
int resampler_ready(void *);
void resampler_clear(void *);
int resampler_get_sample_count(void *);
int resampler_get_sample(void *);
void resampler_remove_sample(void *);
#ifdef __cplusplus
}
#endif
float resampler_get_sample_float(void *);
void resampler_remove_sample(void *, int decay);
#endif

View File

@ -16,6 +16,7 @@
#include "armcpu.h"
#include "cp15.h"
#include "spu_exports.h"
#include "barray.h"
#include "state.h"
@ -279,12 +280,16 @@ void state_deinit(struct NDS_state *state)
state->MainScreen = NULL;
if (state->SubScreen) free(state->SubScreen);
state->SubScreen = NULL;
if (state->array_rom_coverage) bit_array_destroy(state->array_rom_coverage);
state->array_rom_coverage = NULL;
}
void state_setrom(struct NDS_state *state, u8 * rom, u32 rom_size)
void state_setrom(struct NDS_state *state, u8 * rom, u32 rom_size, unsigned int enable_coverage_checking)
{
assert(!(rom_size & (rom_size - 1)));
NDS_SetROM(state, rom, rom_size - 1);
if (enable_coverage_checking)
state->array_rom_coverage = bit_array_create(rom_size / 4);
NDS_Reset(state);
state->execute = TRUE;
}

View File

@ -77,13 +77,15 @@ typedef struct NDS_state
s16 *sample_buffer;
unsigned long sample_pointer;
unsigned long sample_size;
void * array_rom_coverage;
} NDS_state;
int state_init(NDS_state *state);
void state_deinit(NDS_state *state);
void state_setrom(NDS_state *state, u8 * rom, u32 rom_size);
void state_setrom(NDS_state *state, u8 * rom, u32 rom_size, unsigned int enable_coverage_checking);
void state_loadstate(NDS_state *state, const u8 * ss, u32 ss_size);

View File

@ -1099,10 +1099,12 @@ static int usf_info(void * context, const char * name, const char * value)
resampling_int = 1;
else if ([resampling isEqualToString:@"linear"])
resampling_int = 2;
else if ([resampling isEqualToString:@"cubic"])
else if ([resampling isEqualToString:@"blam"])
resampling_int = 3;
else if ([resampling isEqualToString:@"sinc"])
else if ([resampling isEqualToString:@"cubic"])
resampling_int = 4;
else if ([resampling isEqualToString:@"sinc"])
resampling_int = 5;
core->dwInterpolation = resampling_int;
core->dwChannelMute = 0;
@ -1121,7 +1123,7 @@ static int usf_info(void * context, const char * name, const char * value)
emulatorExtra = state.rom;
if ( state.rom )
state_setrom(core, state.rom, (u32) state.rom_size );
state_setrom(core, state.rom, (u32) state.rom_size, 0 );
state_loadstate(core, state.state, (u32) state.state_size);