mirror of
https://github.com/libretro/Genesis-Plus-GX.git
synced 2024-11-23 08:19:39 +00:00
commit
8aed64c2ac
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
psp2/*.o
|
||||
psp2/*.elf
|
||||
psp2/*.velf
|
||||
psp2/build_vita/*
|
||||
psp2/*.a
|
@ -34,7 +34,7 @@ int _ilog(unsigned int v){
|
||||
}
|
||||
|
||||
/* 32 bit float (not IEEE; nonnormalized mantissa +
|
||||
biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
|
||||
biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm
|
||||
Why not IEEE? It's just not that important here. */
|
||||
|
||||
#define VQ_FEXP 10
|
||||
@ -77,12 +77,12 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
|
||||
long length=l[i];
|
||||
if(length>0){
|
||||
ogg_uint32_t entry=marker[length];
|
||||
|
||||
|
||||
/* when we claim a node for an entry, we also claim the nodes
|
||||
below it (pruning off the imagined tree that may have dangled
|
||||
from it) as well as blocking the use of any nodes directly
|
||||
above for leaves */
|
||||
|
||||
|
||||
/* update ourself */
|
||||
if(length<32 && (entry>>length)){
|
||||
/* error condition; the lengths must specify an overpopulated tree */
|
||||
@ -90,12 +90,12 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
|
||||
return(NULL);
|
||||
}
|
||||
r[count++]=entry;
|
||||
|
||||
|
||||
/* Look to see if the next shorter marker points to the node
|
||||
above. if so, update it and repeat. */
|
||||
{
|
||||
for(j=length;j>0;j--){
|
||||
|
||||
|
||||
if(marker[j]&1){
|
||||
/* have to jump branches */
|
||||
if(j==1)
|
||||
@ -108,7 +108,7 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
|
||||
marker[j]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* prune the tree; the implicit invariant says all the longer
|
||||
markers were dangling from our just-taken node. Dangle them
|
||||
from our *new* node. */
|
||||
@ -121,7 +121,7 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){
|
||||
}else
|
||||
if(sparsecount==0)count++;
|
||||
}
|
||||
|
||||
|
||||
/* bitreverse the words because our bitwise packer/unpacker is LSb
|
||||
endian */
|
||||
for(i=0,count=0;i<n;i++){
|
||||
@ -210,18 +210,18 @@ ogg_int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap,
|
||||
int indexdiv=1;
|
||||
for(k=0;k<b->dim;k++){
|
||||
int index= (j/indexdiv)%quantvals;
|
||||
int point=0;
|
||||
ogg_int32_t point=0;
|
||||
int val=VFLOAT_MULTI(delta,delpoint,
|
||||
abs(b->quantlist[index]),&point);
|
||||
|
||||
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
|
||||
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
|
||||
|
||||
|
||||
if(b->q_sequencep){
|
||||
last=val;
|
||||
last=val;
|
||||
lastpoint=point;
|
||||
}
|
||||
|
||||
|
||||
if(sparsemap){
|
||||
r[sparsemap[count]*b->dim+k]=val;
|
||||
rp[sparsemap[count]*b->dim+k]=point;
|
||||
@ -244,15 +244,15 @@ ogg_int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap,
|
||||
int lastpoint=0;
|
||||
|
||||
for(k=0;k<b->dim;k++){
|
||||
int point=0;
|
||||
ogg_int32_t point=0;
|
||||
int val=VFLOAT_MULTI(delta,delpoint,
|
||||
abs(b->quantlist[j*b->dim+k]),&point);
|
||||
|
||||
val=VFLOAT_ADD(mindel,minpoint,val,point,&point);
|
||||
val=VFLOAT_ADD(last,lastpoint,val,point,&point);
|
||||
|
||||
|
||||
if(b->q_sequencep){
|
||||
last=val;
|
||||
last=val;
|
||||
lastpoint=point;
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ ogg_int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap,
|
||||
for(j=0;j<n*b->dim;j++)
|
||||
if(rp[j]<*maxpoint)
|
||||
r[j]>>=*maxpoint-rp[j];
|
||||
|
||||
|
||||
_ogg_free(rp);
|
||||
return(r);
|
||||
}
|
||||
@ -324,7 +324,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
|
||||
int i,j,n=0,tabn;
|
||||
int *sortindex;
|
||||
memset(c,0,sizeof(*c));
|
||||
|
||||
|
||||
/* count actually used entries */
|
||||
for(i=0;i<s->entries;i++)
|
||||
if(s->lengthlist[i]>0)
|
||||
@ -335,20 +335,20 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
|
||||
c->dim=s->dim;
|
||||
|
||||
if(n>0){
|
||||
/* two different remappings go on here.
|
||||
|
||||
/* two different remappings go on here.
|
||||
|
||||
First, we collapse the likely sparse codebook down only to
|
||||
actually represented values/words. This collapsing needs to be
|
||||
indexed as map-valueless books are used to encode original entry
|
||||
positions as integers.
|
||||
|
||||
|
||||
Second, we reorder all vectors, including the entry index above,
|
||||
by sorted bitreversed codeword to allow treeless decode. */
|
||||
|
||||
|
||||
/* perform sort */
|
||||
ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries);
|
||||
ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n);
|
||||
|
||||
|
||||
if(codes==NULL)goto err_out;
|
||||
|
||||
for(i=0;i<n;i++){
|
||||
@ -369,29 +369,29 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
|
||||
for(i=0;i<n;i++)
|
||||
c->codelist[sortindex[i]]=codes[i];
|
||||
_ogg_free(codes);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint);
|
||||
c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index));
|
||||
|
||||
|
||||
for(n=0,i=0;i<s->entries;i++)
|
||||
if(s->lengthlist[i]>0)
|
||||
c->dec_index[sortindex[n++]]=i;
|
||||
|
||||
|
||||
c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths));
|
||||
for(n=0,i=0;i<s->entries;i++)
|
||||
if(s->lengthlist[i]>0)
|
||||
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i];
|
||||
|
||||
|
||||
c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */
|
||||
if(c->dec_firsttablen<5)c->dec_firsttablen=5;
|
||||
if(c->dec_firsttablen>8)c->dec_firsttablen=8;
|
||||
|
||||
|
||||
tabn=1<<c->dec_firsttablen;
|
||||
c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable));
|
||||
c->dec_maxlength=0;
|
||||
|
||||
|
||||
for(i=0;i<n;i++){
|
||||
if(c->dec_maxlength<c->dec_codelengths[i])
|
||||
c->dec_maxlength=c->dec_codelengths[i];
|
||||
@ -401,26 +401,26 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
|
||||
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* now fill in 'unused' entries in the firsttable with hi/lo search
|
||||
hints for the non-direct-hits */
|
||||
{
|
||||
ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen);
|
||||
long lo=0,hi=0;
|
||||
|
||||
|
||||
for(i=0;i<tabn;i++){
|
||||
ogg_uint32_t word=i<<(32-c->dec_firsttablen);
|
||||
if(c->dec_firsttable[bitreverse(word)]==0){
|
||||
while((lo+1)<n && c->codelist[lo+1]<=word)lo++;
|
||||
while( hi<n && word>=(c->codelist[hi]&mask))hi++;
|
||||
|
||||
|
||||
/* we only actually have 15 bits per hint to play with here.
|
||||
In order to overflow gracefully (nothing breaks, efficiency
|
||||
just drops), encode as the difference from the extremes. */
|
||||
{
|
||||
unsigned long loval=lo;
|
||||
unsigned long hival=n-hi;
|
||||
|
||||
|
||||
if(loval>0x7fff)loval=0x7fff;
|
||||
if(hival>0x7fff)hival=0x7fff;
|
||||
c->dec_firsttable[bitreverse(word)]=
|
||||
@ -436,4 +436,3 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){
|
||||
vorbis_book_clear(c);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ INLINE void WRITE_LONG(void *address, uint32 data)
|
||||
atex = atex_table[(ATTR >> 29) & 7]; \
|
||||
src = (uint32 *)&bg_pattern_cache[((ATTR & 0x03FF0000) >> 9 | (ATTR & 0x18000000) >> 10 | (LINE)) ^ ((ATTR & 0x10000000) >> 22)];
|
||||
|
||||
/*
|
||||
/*
|
||||
One column = 2 tiles
|
||||
Two pattern attributes are written in VRAM as two consecutives 16-bit words:
|
||||
|
||||
@ -264,7 +264,7 @@ INLINE void WRITE_LONG(void *address, uint32 data)
|
||||
/* This might be faster or slower than original method, depending on */
|
||||
/* architecture (x86, PowerPC), cache size, memory access speed, etc... */
|
||||
|
||||
#ifdef LSB_FIRST
|
||||
#ifdef LSB_FIRST
|
||||
#define DRAW_BG_TILE(SRC_A, SRC_B) \
|
||||
*lb++ = table[((SRC_B << 8) & 0xff00) | (SRC_A & 0xff)]; \
|
||||
*lb++ = table[(SRC_B & 0xff00) | ((SRC_A >> 8) & 0xff)]; \
|
||||
@ -279,7 +279,7 @@ INLINE void WRITE_LONG(void *address, uint32 data)
|
||||
#endif
|
||||
|
||||
#ifdef ALIGN_LONG
|
||||
#ifdef LSB_FIRST
|
||||
#ifdef LSB_FIRST
|
||||
#define DRAW_BG_COLUMN(ATTR, LINE, SRC_A, SRC_B) \
|
||||
GET_LSB_TILE(ATTR, LINE) \
|
||||
SRC_A = READ_LONG((uint32 *)lb); \
|
||||
@ -325,7 +325,7 @@ INLINE void WRITE_LONG(void *address, uint32 data)
|
||||
DRAW_BG_TILE(SRC_A, SRC_B) \
|
||||
SRC_A = READ_LONG((uint32 *)lb); \
|
||||
SRC_B = (src[1] | atex); \
|
||||
DRAW_BG_TILE(SRC_A, SRC_B)
|
||||
DRAW_BG_TILE(SRC_A, SRC_B)
|
||||
#define DRAW_BG_COLUMN_IM2(ATTR, LINE, SRC_A, SRC_B) \
|
||||
GET_MSB_TILE_IM2(ATTR, LINE) \
|
||||
SRC_A = READ_LONG((uint32 *)lb); \
|
||||
@ -343,7 +343,7 @@ INLINE void WRITE_LONG(void *address, uint32 data)
|
||||
DRAW_BG_TILE(SRC_A, SRC_B)
|
||||
#endif
|
||||
#else /* NOT ALIGNED */
|
||||
#ifdef LSB_FIRST
|
||||
#ifdef LSB_FIRST
|
||||
#define DRAW_BG_COLUMN(ATTR, LINE, SRC_A, SRC_B) \
|
||||
GET_LSB_TILE(ATTR, LINE) \
|
||||
SRC_A = *(uint32 *)(lb); \
|
||||
@ -470,8 +470,11 @@ INLINE void WRITE_LONG(void *address, uint32 data)
|
||||
|
||||
/* 5:5:5 RGB */
|
||||
#elif defined(USE_15BPP_RENDERING)
|
||||
#if defined(USE_ABGR)
|
||||
#define MAKE_PIXEL(r,g,b) ((1 << 15) | (b) << 11 | ((b) >> 3) << 10 | (g) << 6 | ((g) >> 3) << 5 | (r) << 1 | (r) >> 3)
|
||||
#else
|
||||
#define MAKE_PIXEL(r,g,b) ((1 << 15) | (r) << 11 | ((r) >> 3) << 10 | (g) << 6 | ((g) >> 3) << 5 | (b) << 1 | (b) >> 3)
|
||||
|
||||
#endif
|
||||
/* 5:6:5 RGB */
|
||||
#elif defined(USE_16BPP_RENDERING)
|
||||
#define MAKE_PIXEL(r,g,b) ((r) << 12 | ((r) >> 3) << 11 | (g) << 7 | ((g) >> 2) << 5 | (b) << 1 | (b) >> 3)
|
||||
@ -573,7 +576,7 @@ static uint8 linebuf[2][0x200];
|
||||
static uint8 spr_ovr;
|
||||
|
||||
/* Sprite parsing lists */
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
uint16 ypos;
|
||||
uint16 xpos;
|
||||
@ -620,7 +623,7 @@ static void make_name_lut(void)
|
||||
if ((vrow > height) || vcol > width)
|
||||
{
|
||||
/* Invalid settings (unused) */
|
||||
name_lut[i] = -1;
|
||||
name_lut[i] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -691,8 +694,8 @@ static uint32 make_lut_bg(uint32 bx, uint32 ax)
|
||||
int bf = (bx & 0x7F);
|
||||
int bp = (bx & 0x40);
|
||||
int b = (bx & 0x0F);
|
||||
|
||||
int af = (ax & 0x7F);
|
||||
|
||||
int af = (ax & 0x7F);
|
||||
int ap = (ax & 0x40);
|
||||
int a = (ax & 0x0F);
|
||||
|
||||
@ -712,8 +715,8 @@ static uint32 make_lut_bg_ste(uint32 bx, uint32 ax)
|
||||
int bf = (bx & 0x7F);
|
||||
int bp = (bx & 0x40);
|
||||
int b = (bx & 0x0F);
|
||||
|
||||
int af = (ax & 0x7F);
|
||||
|
||||
int af = (ax & 0x7F);
|
||||
int ap = (ax & 0x40);
|
||||
int a = (ax & 0x0F);
|
||||
|
||||
@ -761,7 +764,7 @@ static uint32 make_lut_bgobj(uint32 bx, uint32 sx)
|
||||
int bs = (bx & 0x80);
|
||||
int bp = (bx & 0x40);
|
||||
int b = (bx & 0x0F);
|
||||
|
||||
|
||||
int sf = (sx & 0x3F);
|
||||
int sp = (sx & 0x40);
|
||||
int s = (sx & 0x0F);
|
||||
@ -897,7 +900,7 @@ static uint32 make_lut_bgobj_ste(uint32 bx, uint32 sx)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
c = (bf | bi);
|
||||
}
|
||||
}
|
||||
@ -914,7 +917,7 @@ static uint32 make_lut_bgobj_ste(uint32 bx, uint32 sx)
|
||||
static uint32 make_lut_bgobj_m4(uint32 bx, uint32 sx)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
||||
int bf = (bx & 0x3F);
|
||||
int bs = (bx & 0x80);
|
||||
int bp = (bx & 0x20);
|
||||
@ -971,7 +974,7 @@ static void palette_init(void)
|
||||
/* GG mode : xxxx (0-15) */
|
||||
/* */
|
||||
/* with x = original CRAM value (2, 3 or 4-bit) */
|
||||
/* (*) 2-bit CRAM value is expanded to 4-bit */
|
||||
/* (*) 2-bit CRAM value is expanded to 4-bit */
|
||||
/************************************************/
|
||||
|
||||
/* Initialize Mode 5 pixel color look-up tables */
|
||||
@ -1308,7 +1311,7 @@ void render_bg_m3(int line)
|
||||
do
|
||||
{
|
||||
color = pg[*nt++ << 3];
|
||||
|
||||
|
||||
*lb++ = 0x10 | ((color >> 4) & 0x0F);
|
||||
*lb++ = 0x10 | ((color >> 4) & 0x0F);
|
||||
*lb++ = 0x10 | ((color >> 4) & 0x0F);
|
||||
@ -1346,7 +1349,7 @@ void render_bg_m3x(int line)
|
||||
do
|
||||
{
|
||||
color = pg[*nt++ << 3];
|
||||
|
||||
|
||||
*lb++ = 0x10 | ((color >> 4) & 0x0F);
|
||||
*lb++ = 0x10 | ((color >> 4) & 0x0F);
|
||||
*lb++ = 0x10 | ((color >> 4) & 0x0F);
|
||||
@ -1394,10 +1397,10 @@ void render_bg_m4(int line)
|
||||
int column;
|
||||
uint16 *nt;
|
||||
uint32 attr, atex, *src;
|
||||
|
||||
|
||||
/* 32 x 8 pixels */
|
||||
int width = 32;
|
||||
|
||||
|
||||
/* Horizontal scrolling */
|
||||
int index = ((reg[0] & 0x40) && (line < 0x10)) ? 0x100 : reg[0x08];
|
||||
int shift = index & 7;
|
||||
@ -1422,7 +1425,7 @@ void render_bg_m4(int line)
|
||||
{
|
||||
/* Vertical scroll mask */
|
||||
v_line = v_line % 256;
|
||||
|
||||
|
||||
/* Pattern name Table */
|
||||
nt = (uint16 *)&vram[(0x3700 & nt_mask) + ((v_line >> 3) << 6)];
|
||||
}
|
||||
@ -1727,7 +1730,7 @@ void render_bg_m5_vs(int line)
|
||||
atbuf = nt[index & pf_col_mask];
|
||||
DRAW_COLUMN(atbuf, v_line)
|
||||
}
|
||||
|
||||
|
||||
if (w == (line >= a))
|
||||
{
|
||||
/* Window takes up entire line */
|
||||
@ -1755,7 +1758,7 @@ void render_bg_m5_vs(int line)
|
||||
#else
|
||||
shift = (xscroll >> 16) & 0x0F;
|
||||
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(shift)
|
||||
{
|
||||
@ -2315,7 +2318,7 @@ void render_bg_m5(int line)
|
||||
|
||||
/* Plane B name table */
|
||||
nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)];
|
||||
|
||||
|
||||
/* Pattern row index */
|
||||
v_line = (v_line & 7) << 3;
|
||||
|
||||
@ -2330,7 +2333,7 @@ void render_bg_m5(int line)
|
||||
atbuf = nt[(index-1) & pf_col_mask];
|
||||
DRAW_BG_COLUMN(atbuf, v_line, xscroll, yscroll)
|
||||
}
|
||||
|
||||
|
||||
for(column = 0; column < width; column++, index++)
|
||||
{
|
||||
atbuf = nt[index & pf_col_mask];
|
||||
@ -2555,7 +2558,7 @@ void render_bg_m5_im2(int line)
|
||||
|
||||
/* Window vertical range (cell 0-31) */
|
||||
int a = (reg[18] & 0x1F) << 3;
|
||||
|
||||
|
||||
/* Window position (0=top, 1=bottom) */
|
||||
int w = (reg[18] >> 7) & 1;
|
||||
|
||||
@ -2714,7 +2717,7 @@ void render_bg_m5_im2_vs(int line)
|
||||
|
||||
/* Window vertical range (cell 0-31) */
|
||||
uint32 a = (reg[18] & 0x1F) << 3;
|
||||
|
||||
|
||||
/* Window position (0=top, 1=bottom) */
|
||||
uint32 w = (reg[18] >> 7) & 1;
|
||||
|
||||
@ -3037,7 +3040,7 @@ void render_obj_m4(int line)
|
||||
|
||||
/* Default sprite width */
|
||||
int width = 8;
|
||||
|
||||
|
||||
/* Sprite Generator address mask (LSB is masked for 8x16 sprites) */
|
||||
uint16 sg_mask = (~0x1C0 ^ (reg[6] << 6)) & (~((reg[1] & 0x02) >> 1));
|
||||
|
||||
@ -3099,7 +3102,7 @@ void render_obj_m4(int line)
|
||||
{
|
||||
/* Draw sprite pattern (zoomed sprites are rendered at half speed) */
|
||||
DRAW_SPRITE_TILE_ACCURATE_2X(end,0,lut[5])
|
||||
|
||||
|
||||
/* 315-5124 VDP specific */
|
||||
if (system_hw < SYSTEM_SMS2)
|
||||
{
|
||||
@ -3697,7 +3700,7 @@ void parse_satb_m4(int line)
|
||||
|
||||
/* Y position */
|
||||
int ypos;
|
||||
|
||||
|
||||
/* Sprite list for next line */
|
||||
object_info_t *object_info = obj_info[(line + 1) & 1];
|
||||
|
||||
@ -3837,11 +3840,11 @@ void parse_satb_m5(int line)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update sprite list (only name, attribute & xpos are parsed from VRAM) */
|
||||
/* Update sprite list (only name, attribute & xpos are parsed from VRAM) */
|
||||
object_info->attr = p[link + 2];
|
||||
object_info->xpos = p[link + 3] & 0x1ff;
|
||||
object_info->ypos = ypos;
|
||||
object_info->size = size & 0x0f;
|
||||
object_info->size = size & 0x0f;
|
||||
|
||||
/* Increment Sprite count */
|
||||
++count;
|
||||
@ -3851,7 +3854,7 @@ void parse_satb_m5(int line)
|
||||
}
|
||||
}
|
||||
|
||||
/* Read link data from internal SAT cache */
|
||||
/* Read link data from internal SAT cache */
|
||||
link = (q[link + 1] & 0x7F) << 2;
|
||||
|
||||
/* Stop parsing if link data points to first entry (#0) or after the last entry (#64 in H32 mode, #80 in H40 mode) */
|
||||
|
@ -51,11 +51,17 @@
|
||||
|
||||
/* 5:5:5 RGB */
|
||||
#elif defined(USE_15BPP_RENDERING)
|
||||
#if defined(USE_ABGR)
|
||||
#define PIXEL(r,g,b) ((1 << 15) | ((b) << 10) | ((g) << 5) | (r))
|
||||
#define GET_B(pixel) (((pixel) & 0x7c00) >> 10)
|
||||
#define GET_G(pixel) (((pixel) & 0x03e0) >> 5)
|
||||
#define GET_R(pixel) (((pixel) & 0x001f) >> 0)
|
||||
#else
|
||||
#define PIXEL(r,g,b) ((1 << 15) | ((r) << 10) | ((g) << 5) | (b))
|
||||
#define GET_R(pixel) (((pixel) & 0x7c00) >> 10)
|
||||
#define GET_G(pixel) (((pixel) & 0x03e0) >> 5)
|
||||
#define GET_B(pixel) (((pixel) & 0x001f) >> 0)
|
||||
|
||||
#endif
|
||||
/* 5:6:5 RGB */
|
||||
#elif defined(USE_16BPP_RENDERING)
|
||||
#define PIXEL(r,g,b) (((r) << 11) | ((g) << 5) | (b))
|
||||
@ -134,4 +140,3 @@ extern void (*parse_satb)(int line);
|
||||
extern void (*update_bg_pattern_cache)(int index);
|
||||
|
||||
#endif /* _RENDER_H_ */
|
||||
|
||||
|
180
psp2/Makefile
Normal file
180
psp2/Makefile
Normal file
@ -0,0 +1,180 @@
|
||||
|
||||
# Makefile for genplus SDL
|
||||
#
|
||||
# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
|
||||
# modified by Eke-Eke <eke_eke31@yahoo.fr>
|
||||
#
|
||||
# Defines :
|
||||
# -DLSB_FIRST : for little endian systems.
|
||||
# -DLOGERROR : enable message logging
|
||||
# -DLOGVDP : enable VDP debug messages
|
||||
# -DLOGSOUND : enable AUDIO debug messages
|
||||
# -DLOG_SCD : enable SCD debug messages
|
||||
# -DLOG_CDD : enable CDD debug messages
|
||||
# -DLOG_CDC : enable CDC debug messages
|
||||
# -DLOG_PCM : enable PCM debug messages
|
||||
# -DLOGSOUND : enable AUDIO debug messages
|
||||
# -D8BPP_RENDERING - configure for 8-bit pixels (RGB332)
|
||||
# -D15BPP_RENDERING - configure for 15-bit pixels (RGB555)
|
||||
# -D16BPP_RENDERING - configure for 16-bit pixels (RGB565)
|
||||
# -D32BPP_RENDERING - configure for 32-bit pixels (RGB888)
|
||||
|
||||
NAME = gen_vita
|
||||
PSP_APP_NAME=GENPLUSGXVITA
|
||||
PSP_APP_VER=1.7.5
|
||||
|
||||
CC = arm-vita-eabi-gcc
|
||||
CFLAGS = -O3 -fomit-frame-pointer -Wall -Wno-strict-aliasing -ansi -std=c11 \
|
||||
-pedantic-errors -fno-unwind-tables -fno-asynchronous-unwind-tables -ftree-vectorize \
|
||||
-mfloat-abi=hard -ffast-math -fsingle-precision-constant -ftree-vectorizer-verbose=2 -fopt-info-vec-optimized -funroll-loops
|
||||
#-g -ggdb -pg
|
||||
#-fomit-frame-pointer
|
||||
LDFLAGS = -Wl,-q
|
||||
DEFINES = -DPSP_APP_NAME=\"$(PSP_APP_NAME)\" -DPSP_APP_VER=\"$(PSP_APP_VER)\" \
|
||||
-DLSB_FIRST -DUSE_15BPP_RENDERING -DUSE_LIBTREMOR -DALT_RENDERER -DALIGN_LONG -DHAVE_ALLOCA_H -DUSE_ABGR
|
||||
SRCDIR = ../core
|
||||
INCLUDES = -I$(SRCDIR) -I$(SRCDIR)/z80 -I$(SRCDIR)/m68k -I$(SRCDIR)/sound -I$(SRCDIR)/input_hw -I$(SRCDIR)/cart_hw -I$(SRCDIR)/cart_hw/svp -I$(SRCDIR)/cd_hw -I$(SRCDIR)/ntsc -I$(SRCDIR)/tremor -I$(SRCDIR)/../psp2
|
||||
LIBS = -lpsplib -lvita2d -lfreetype -lpng -lz -lm -lSceDisplay_stub -lSceGxm_stub \
|
||||
-lSceCtrl_stub -lSceAudio_stub -lSceRtc_stub -lScePower_stub -lSceAppUtil_stub
|
||||
#-ldebugnet -lSceNet_stub -lSceNetCtl_stub
|
||||
|
||||
OBJDIR = ./build_vita
|
||||
|
||||
OBJECTS = $(OBJDIR)/z80.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/m68kcpu.o \
|
||||
$(OBJDIR)/s68kcpu.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/genesis.o \
|
||||
$(OBJDIR)/vdp_ctrl.o \
|
||||
$(OBJDIR)/vdp_render.o \
|
||||
$(OBJDIR)/system.o \
|
||||
$(OBJDIR)/io_ctrl.o \
|
||||
$(OBJDIR)/mem68k.o \
|
||||
$(OBJDIR)/memz80.o \
|
||||
$(OBJDIR)/membnk.o \
|
||||
$(OBJDIR)/state.o \
|
||||
$(OBJDIR)/loadrom.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/input.o \
|
||||
$(OBJDIR)/gamepad.o \
|
||||
$(OBJDIR)/lightgun.o \
|
||||
$(OBJDIR)/mouse.o \
|
||||
$(OBJDIR)/activator.o \
|
||||
$(OBJDIR)/xe_1ap.o \
|
||||
$(OBJDIR)/teamplayer.o \
|
||||
$(OBJDIR)/paddle.o \
|
||||
$(OBJDIR)/sportspad.o \
|
||||
$(OBJDIR)/terebi_oekaki.o \
|
||||
$(OBJDIR)/graphic_board.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/sound.o \
|
||||
$(OBJDIR)/sn76489.o \
|
||||
$(OBJDIR)/ym2413.o \
|
||||
$(OBJDIR)/ym2612.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/blip_buf.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/eq.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/sram.o \
|
||||
$(OBJDIR)/svp.o \
|
||||
$(OBJDIR)/ssp16.o \
|
||||
$(OBJDIR)/ggenie.o \
|
||||
$(OBJDIR)/areplay.o \
|
||||
$(OBJDIR)/eeprom_93c.o \
|
||||
$(OBJDIR)/eeprom_i2c.o \
|
||||
$(OBJDIR)/eeprom_spi.o \
|
||||
$(OBJDIR)/md_cart.o \
|
||||
$(OBJDIR)/sms_cart.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/scd.o \
|
||||
$(OBJDIR)/cdd.o \
|
||||
$(OBJDIR)/cdc.o \
|
||||
$(OBJDIR)/gfx.o \
|
||||
$(OBJDIR)/pcm.o \
|
||||
$(OBJDIR)/cd_cart.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/sms_ntsc.o \
|
||||
$(OBJDIR)/md_ntsc.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/main.o \
|
||||
$(OBJDIR)/emumain.o \
|
||||
$(OBJDIR)/menu.o \
|
||||
$(OBJDIR)/config.o \
|
||||
$(OBJDIR)/error.o \
|
||||
$(OBJDIR)/unzip.o \
|
||||
$(OBJDIR)/fileio.o
|
||||
|
||||
OBJECTS += $(OBJDIR)/bitwise.o \
|
||||
$(OBJDIR)/block.o \
|
||||
$(OBJDIR)/codebook.o \
|
||||
$(OBJDIR)/floor0.o \
|
||||
$(OBJDIR)/floor1.o \
|
||||
$(OBJDIR)/framing.o \
|
||||
$(OBJDIR)/info.o \
|
||||
$(OBJDIR)/mapping0.o \
|
||||
$(OBJDIR)/mdct.o \
|
||||
$(OBJDIR)/registry.o \
|
||||
$(OBJDIR)/res012.o \
|
||||
$(OBJDIR)/sharedbook.o \
|
||||
$(OBJDIR)/synthesis.o \
|
||||
$(OBJDIR)/vorbisfile.o \
|
||||
$(OBJDIR)/window.o
|
||||
|
||||
|
||||
all: $(NAME).velf
|
||||
|
||||
$(NAME).velf: $(NAME).elf
|
||||
#advice from xyzz strip before create elf
|
||||
arm-vita-eabi-strip -g $<
|
||||
#i put db.json there use your location
|
||||
vita-elf-create $< $@ db.json
|
||||
|
||||
$(NAME).elf: $(OBJDIR) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
|
||||
|
||||
$(OBJDIR) :
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/%.c $(SRCDIR)/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/sound/%.c $(SRCDIR)/sound/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/input_hw/%.c $(SRCDIR)/input_hw/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/%.c $(SRCDIR)/cart_hw/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/svp/%.c
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cart_hw/svp/%.c $(SRCDIR)/cart_hw/svp/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/cd_hw/%.c $(SRCDIR)/cd_hw/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/z80/%.c $(SRCDIR)/z80/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/m68k/%.c
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/ntsc/%.c $(SRCDIR)/ntsc/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/tremor/%.c $(SRCDIR)/tremor/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/tremor/%.c
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
$(OBJDIR)/%.o : $(SRCDIR)/../psp2/%.c $(SRCDIR)/../psp2/%.h
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(NAME).velf $(NAME).elf
|
54
psp2/config.c
Normal file
54
psp2/config.c
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
t_config config;
|
||||
|
||||
void set_config_defaults(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* sound options */
|
||||
config.psg_preamp = 150;
|
||||
config.fm_preamp = 100;
|
||||
config.hq_fm = 0;
|
||||
config.psgBoostNoise = 1;
|
||||
config.filter = 1;
|
||||
config.low_freq = 200;
|
||||
config.high_freq = 8000;
|
||||
config.lg = 1.0;
|
||||
config.mg = 1.0;
|
||||
config.hg = 1.0;
|
||||
config.lp_range = 0x9999; /* 0.6 in 16.16 fixed point */
|
||||
config.dac_bits = 14;
|
||||
config.ym2413 = 2; /* = AUTO (0 = always OFF, 1 = always ON) */
|
||||
config.mono = 0;
|
||||
|
||||
/* system options */
|
||||
config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */
|
||||
config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */
|
||||
config.vdp_mode = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
|
||||
config.master_clock = 0; /* = AUTO (1 = NTSC, 2 = PAL) */
|
||||
config.force_dtack = 0;
|
||||
config.addr_error = 1;
|
||||
config.bios = 0;
|
||||
config.lock_on = 0; /* = OFF (can be TYPE_SK, TYPE_GG & TYPE_AR) */
|
||||
config.ntsc = 0;
|
||||
config.lcd = 0; /* 0.8 fixed point */
|
||||
|
||||
/* display options */
|
||||
config.overscan = 0; /* 3 = all borders (0 = no borders , 1 = vertical borders only, 2 = horizontal borders only) */
|
||||
config.gg_extra = 0; /* 1 = show extended Game Gear screen (256x192) */
|
||||
config.render = 0; /* 1 = double resolution output (only when interlaced mode 2 is enabled) */
|
||||
|
||||
/* controllers options */
|
||||
input.system[0] = SYSTEM_GAMEPAD;
|
||||
input.system[1] = SYSTEM_GAMEPAD;
|
||||
config.gun_cursor[0] = 1;
|
||||
config.gun_cursor[1] = 1;
|
||||
config.invert_mouse = 0;
|
||||
for (i=0;i<MAX_INPUTS;i++)
|
||||
{
|
||||
/* autodetected control pad type */
|
||||
config.input[i].padtype = DEVICE_PAD2B | DEVICE_PAD3B | DEVICE_PAD6B;
|
||||
}
|
||||
}
|
57
psp2/config.h
Normal file
57
psp2/config.h
Normal file
@ -0,0 +1,57 @@
|
||||
|
||||
#ifndef _CONFIG_H_
|
||||
#define _CONFIG_H_
|
||||
|
||||
#define MAX_INPUTS 8
|
||||
#define MAX_KEYS 8
|
||||
#define MAXPATHLEN 1024
|
||||
|
||||
/****************************************************************************
|
||||
* Config Option
|
||||
*
|
||||
****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint8 padtype;
|
||||
} t_input_config;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 hq_fm;
|
||||
uint8 filter;
|
||||
uint8 psgBoostNoise;
|
||||
uint8 dac_bits;
|
||||
uint8 ym2413;
|
||||
int16 psg_preamp;
|
||||
int16 fm_preamp;
|
||||
uint32 lp_range;
|
||||
int16 low_freq;
|
||||
int16 high_freq;
|
||||
int16 lg;
|
||||
int16 mg;
|
||||
int16 hg;
|
||||
uint8 mono;
|
||||
uint8 system;
|
||||
uint8 region_detect;
|
||||
uint8 vdp_mode;
|
||||
uint8 master_clock;
|
||||
uint8 force_dtack;
|
||||
uint8 addr_error;
|
||||
uint8 bios;
|
||||
uint8 lock_on;
|
||||
uint8 hot_swap;
|
||||
uint8 invert_mouse;
|
||||
uint8 gun_cursor[2];
|
||||
uint8 overscan;
|
||||
uint8 gg_extra;
|
||||
uint8 ntsc;
|
||||
uint8 lcd;
|
||||
uint8 render;
|
||||
t_input_config input[MAX_INPUTS];
|
||||
} t_config;
|
||||
|
||||
/* Global variables */
|
||||
extern t_config config;
|
||||
extern void set_config_defaults(void);
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
4466
psp2/db.json
Normal file
4466
psp2/db.json
Normal file
File diff suppressed because it is too large
Load Diff
442
psp2/emumain.c
Normal file
442
psp2/emumain.c
Normal file
@ -0,0 +1,442 @@
|
||||
#include "emumain.h"
|
||||
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#include "time.h"
|
||||
#include <psp2/rtc.h>
|
||||
|
||||
#define SCE_KERNEL_OK 0
|
||||
|
||||
#include "psplib/pl_rewind.h"
|
||||
#include "psplib/pl_file.h"
|
||||
#include "psplib/pl_snd.h"
|
||||
#include "psplib/pl_perf.h"
|
||||
#include "psplib/pl_util.h"
|
||||
#include "psplib/pl_psp.h"
|
||||
#include "psplib/video.h"
|
||||
#include "psplib/ctrl.h"
|
||||
|
||||
#include "shared.h"
|
||||
#include "sound.h"
|
||||
#include "system.h"
|
||||
#include "md_ntsc.h"
|
||||
#include "sms_ntsc.h"
|
||||
|
||||
//#include <debugnet.h>
|
||||
|
||||
#define ip_server "192.168.1.130"
|
||||
#define port_server 18194
|
||||
|
||||
PspImage *Screen;
|
||||
pl_rewind Rewinder;
|
||||
|
||||
static pl_perf_counter FpsCounter;
|
||||
static int ClearScreen;
|
||||
static int ScreenX, ScreenY, ScreenW, ScreenH;
|
||||
static int TicksPerUpdate;
|
||||
static u32 TicksPerSecond;
|
||||
static u64 LastTick;
|
||||
static u64 CurrentTick;
|
||||
static int Frame;
|
||||
|
||||
static int Rewinding;
|
||||
|
||||
extern pl_file_path CurrentGame;
|
||||
extern EmulatorOptions Options;
|
||||
extern const u64 ButtonMask[];
|
||||
extern const int ButtonMapId[];
|
||||
extern struct ButtonConfig ActiveConfig;
|
||||
extern char *ScreenshotPath;
|
||||
|
||||
static short soundbuffer[SOUND_SAMPLES*2*10];
|
||||
static int soundPosWrite = 0;
|
||||
static int soundPosRead = 0;
|
||||
static SceUID console_mtx;
|
||||
|
||||
|
||||
|
||||
static inline void RenderVideo();
|
||||
static void AudioCallback(pl_snd_sample* buf,
|
||||
unsigned int samples,
|
||||
void *userdata);
|
||||
void MixerCallback(int16 **stream, int16 **output, int length);
|
||||
md_ntsc_t *md_ntsc;
|
||||
sms_ntsc_t *sms_ntsc;
|
||||
|
||||
int bEmulate;
|
||||
|
||||
void osd_input_update()
|
||||
{
|
||||
|
||||
/* Reset input */
|
||||
input.pad[0] = 0;
|
||||
input.analog[0][0] = 0x7F;
|
||||
|
||||
static SceCtrlData pad;
|
||||
static int autofire_status = 0;
|
||||
|
||||
/* Check the input */
|
||||
if (pspCtrlPollControls(&pad))
|
||||
{
|
||||
if (--autofire_status < 0)
|
||||
autofire_status = Options.AutoFire;
|
||||
|
||||
/* Parse input */
|
||||
int i, on, code;
|
||||
for (i = 0; ButtonMapId[i] >= 0; i++)
|
||||
{
|
||||
code = ActiveConfig.ButtonMap[ButtonMapId[i]];
|
||||
on = (pad.buttons & ButtonMask[i]) == ButtonMask[i];
|
||||
|
||||
/* Check to see if a button set is pressed. If so, unset it, so it */
|
||||
/* doesn't trigger any other combination presses. */
|
||||
if (on) pad.buttons &= ~ButtonMask[i];
|
||||
|
||||
if (code & AFI)
|
||||
{
|
||||
if (on && (autofire_status == 0))
|
||||
input.pad[0] |= CODE_MASK(code);
|
||||
continue;
|
||||
}
|
||||
else if (code & JOY)
|
||||
{
|
||||
if (on) {
|
||||
input.pad[0] |= CODE_MASK(code);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (code & SYS)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
if (CODE_MASK(code) == (INPUT_START))
|
||||
input.system[0] |= INPUT_START;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (code & SPC)
|
||||
{
|
||||
switch (CODE_MASK(code))
|
||||
{
|
||||
case SPC_MENU:
|
||||
if (on) bEmulate=0;
|
||||
break;
|
||||
case SPC_REWIND:
|
||||
Rewinding = on;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void InitEmulator()
|
||||
{
|
||||
|
||||
//debugNetInit(ip_server,port_server,DEBUG);
|
||||
|
||||
set_config_defaults();
|
||||
|
||||
ClearScreen = 0;
|
||||
|
||||
/* Initialize screen buffer */
|
||||
Screen = pspImageCreateVram(720, 576, PSP_IMAGE_16BPP);
|
||||
|
||||
// pspImageClear(Screen, 0x8000);
|
||||
|
||||
console_mtx = sceKernelCreateSema("sound_sema", 0, 0, 1, 0);
|
||||
/*if (console_mtx > 0) {
|
||||
debugNetPrintf(DEBUG,"Sound Mutex UID: 0x%08X\n", console_mtx);
|
||||
}*/
|
||||
|
||||
/* Set up bitmap structure */
|
||||
memset(&bitmap, 0, sizeof(t_bitmap));
|
||||
bitmap.width = Screen->Width;
|
||||
bitmap.height = Screen->Height;
|
||||
bitmap.pitch = (bitmap.width * 2);
|
||||
bitmap.data = (unsigned char *)Screen->Pixels;
|
||||
bitmap.viewport.changed = 3;
|
||||
|
||||
pl_snd_set_callback(0, AudioCallback, NULL);
|
||||
}
|
||||
|
||||
void RunEmulator()
|
||||
{
|
||||
float ratio;
|
||||
//debugNetPrintf(DEBUG,"RunEmulator\n");
|
||||
|
||||
pspImageClear(Screen, 0);
|
||||
//debugNetPrintf(DEBUG,"ImageClear\n");
|
||||
|
||||
|
||||
if(bitmap.viewport.changed & 1)
|
||||
{
|
||||
bitmap.viewport.changed &= ~1;
|
||||
|
||||
/* source bitmap */
|
||||
Screen->Viewport.Width = bitmap.viewport.w+2*bitmap.viewport.x;
|
||||
Screen->Viewport.Height = bitmap.viewport.h+2*bitmap.viewport.y;
|
||||
|
||||
}
|
||||
|
||||
/* Recompute screen size/position */
|
||||
switch (Options.DisplayMode)
|
||||
{
|
||||
default:
|
||||
case DISPLAY_MODE_UNSCALED:
|
||||
ScreenW = Screen->Viewport.Width;
|
||||
ScreenH = Screen->Viewport.Height;
|
||||
break;
|
||||
case DISPLAY_MODE_FIT_HEIGHT:
|
||||
ratio = (float)SCR_HEIGHT / (float)Screen->Viewport.Height;
|
||||
ScreenW = (float)bitmap.viewport.w * ratio - 2;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_FILL_SCREEN:
|
||||
ScreenW = SCR_WIDTH;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_2X:
|
||||
ScreenW = Screen->Viewport.Width*2;
|
||||
ScreenH = Screen->Viewport.Height*2;
|
||||
break;
|
||||
case DISPLAY_MODE_3X:
|
||||
ScreenW = Screen->Viewport.Width*3;
|
||||
ScreenH = Screen->Viewport.Height*3;
|
||||
break;
|
||||
}
|
||||
//debugNetPrintf(DEBUG,"screensize %d %d\n" ,Screen->Viewport.Width ,Screen->Viewport.Height);
|
||||
|
||||
ScreenX = (SCR_WIDTH / 2) - (ScreenW / 2);
|
||||
ScreenY = (SCR_HEIGHT / 2) - (ScreenH / 2);
|
||||
|
||||
/* Init performance counter */
|
||||
pl_perf_init_counter(&FpsCounter);
|
||||
|
||||
/* Recompute update frequency */
|
||||
TicksPerSecond = sceRtcGetTickResolution();
|
||||
if (Options.UpdateFreq)
|
||||
{
|
||||
TicksPerUpdate = TicksPerSecond
|
||||
/ (Options.UpdateFreq / (Options.Frameskip + 1));
|
||||
sceRtcGetCurrentTick(&LastTick);
|
||||
}
|
||||
Frame = 0;
|
||||
ClearScreen = 2;
|
||||
Rewinding = 0;
|
||||
|
||||
//pl_rewind_realloc(&Rewinder);
|
||||
|
||||
int frames_until_save = 0;
|
||||
|
||||
/* Resume sound */
|
||||
pl_snd_resume(0);
|
||||
|
||||
/* Wait for V. refresh */
|
||||
pspVideoWaitVSync();
|
||||
|
||||
bEmulate = 1;
|
||||
/* Main emulation loop */
|
||||
while (!ExitPSP&&bEmulate)
|
||||
{
|
||||
/* Rewind/save state */
|
||||
/*if (!Rewinding)
|
||||
{
|
||||
if (--frames_until_save <= 0)
|
||||
{
|
||||
frames_until_save = Options.RewindSaveRate;
|
||||
pl_rewind_save(&Rewinder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frames_until_save = Options.RewindSaveRate;
|
||||
if (!pl_rewind_restore(&Rewinder))
|
||||
continue;
|
||||
}*/
|
||||
|
||||
/* Run the system emulation for a frame */
|
||||
if (++Frame <= Options.Frameskip)
|
||||
{
|
||||
/* Skip frame */
|
||||
if (system_hw == SYSTEM_MCD)
|
||||
{
|
||||
system_frame_scd(1);
|
||||
}
|
||||
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||
{
|
||||
system_frame_gen(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
system_frame_sms(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (system_hw == SYSTEM_MCD)
|
||||
{
|
||||
system_frame_scd(0);
|
||||
}
|
||||
else if ((system_hw & SYSTEM_PBC) == SYSTEM_MD)
|
||||
{
|
||||
system_frame_gen(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
system_frame_sms(0);
|
||||
}
|
||||
|
||||
Frame = 0;
|
||||
/* Display */
|
||||
if(bitmap.viewport.changed & 1)
|
||||
{
|
||||
bitmap.viewport.changed &= ~1;
|
||||
|
||||
/* source bitmap */
|
||||
Screen->Viewport.Width = bitmap.viewport.w+2*bitmap.viewport.x;
|
||||
Screen->Viewport.Height = bitmap.viewport.h+2*bitmap.viewport.y;
|
||||
|
||||
/* Recompute screen size/position */
|
||||
switch (Options.DisplayMode)
|
||||
{
|
||||
default:
|
||||
case DISPLAY_MODE_UNSCALED:
|
||||
ScreenW = Screen->Viewport.Width;
|
||||
ScreenH = Screen->Viewport.Height;
|
||||
break;
|
||||
case DISPLAY_MODE_FIT_HEIGHT:
|
||||
ratio = (float)SCR_HEIGHT / (float)Screen->Viewport.Height;
|
||||
ScreenW = (float)bitmap.viewport.w * ratio - 2;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_FILL_SCREEN:
|
||||
ScreenW = SCR_WIDTH;
|
||||
ScreenH = SCR_HEIGHT;
|
||||
break;
|
||||
case DISPLAY_MODE_2X:
|
||||
ScreenW = Screen->Viewport.Width*2;
|
||||
ScreenH = Screen->Viewport.Height*2;
|
||||
break;
|
||||
case DISPLAY_MODE_3X:
|
||||
ScreenW = Screen->Viewport.Width*3;
|
||||
ScreenH = Screen->Viewport.Height*3;
|
||||
break;
|
||||
}
|
||||
|
||||
ScreenX = (SCR_WIDTH / 2) - (ScreenW / 2);
|
||||
ScreenY = (SCR_HEIGHT / 2) - (ScreenH / 2);
|
||||
|
||||
}
|
||||
//debugNetPrintf(DEBUG,"main %d %d \n",soundPosRead,soundPosWrite);
|
||||
int size = audio_update(&soundbuffer[soundPosRead])*2;
|
||||
//debugNetPrintf(DEBUG,"filling %d \n",size);
|
||||
|
||||
soundPosRead +=size;
|
||||
if(soundPosRead+size>=(SOUND_SAMPLES*2*10)){
|
||||
soundPosRead = 0;
|
||||
}
|
||||
if((soundPosRead-soundPosWrite)>=(SOUND_SAMPLES*2)||(soundPosRead-soundPosWrite)<0){
|
||||
sceKernelSignalSema(console_mtx, 1); //lock
|
||||
}
|
||||
RenderVideo();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Stop sound */
|
||||
pl_snd_pause(0);
|
||||
}
|
||||
|
||||
void TrashEmulator()
|
||||
{
|
||||
pl_rewind_destroy(&Rewinder);
|
||||
|
||||
/* Trash screen */
|
||||
if (Screen) pspImageDestroy(Screen);
|
||||
|
||||
if (CurrentGame[0] != '\0')
|
||||
{
|
||||
/* Release emulation resources */
|
||||
audio_shutdown();
|
||||
error_shutdown();
|
||||
}
|
||||
//debugNetFinish();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RenderVideo()
|
||||
{
|
||||
/* Update the display */
|
||||
pspVideoBegin();
|
||||
|
||||
/* Clear the buffer first, if necessary */
|
||||
if (ClearScreen >= 0)
|
||||
{
|
||||
ClearScreen--;
|
||||
pspVideoClearScreen();
|
||||
}
|
||||
|
||||
pspVideoPutImage(Screen, ScreenX, ScreenY, ScreenW, ScreenH);
|
||||
|
||||
/* Show FPS counter */
|
||||
if (Options.ShowFps)
|
||||
{
|
||||
static char fps_display[32];
|
||||
sprintf(fps_display, " %3.02f", pl_perf_update_counter(&FpsCounter));
|
||||
|
||||
int width = pspFontGetTextWidth(&PspStockFont, fps_display);
|
||||
int height = pspFontGetLineHeight(&PspStockFont);
|
||||
|
||||
pspVideoFillRect(SCR_WIDTH - width, 0, SCR_WIDTH, height, PSP_COLOR_BLACK);
|
||||
pspVideoPrint(&PspStockFont, SCR_WIDTH - width, 0, fps_display, PSP_COLOR_WHITE);
|
||||
}
|
||||
|
||||
pspVideoEnd();
|
||||
|
||||
/* Wait if needed */
|
||||
if (Options.UpdateFreq)
|
||||
{
|
||||
do { sceRtcGetCurrentTick(&CurrentTick); }
|
||||
while (CurrentTick - LastTick < TicksPerUpdate);
|
||||
LastTick = CurrentTick;
|
||||
}
|
||||
|
||||
/* Wait for VSync signal */
|
||||
if (Options.VSync)
|
||||
pspVideoWaitVSync();
|
||||
|
||||
/* Swap buffers */
|
||||
pspVideoSwapBuffers();
|
||||
}
|
||||
|
||||
static void AudioCallback(pl_snd_sample *buf,
|
||||
unsigned int samples,
|
||||
void *userdata)
|
||||
{
|
||||
int i;
|
||||
//debugNetPrintf(DEBUG,"wait %d %d \n",totalSamples,samples);
|
||||
if (!Rewinding)
|
||||
{
|
||||
short* ptr_s = (short*)buf;
|
||||
//debugNetPrintf(DEBUG,"wait %d %d \n",soundPosRead,soundPosWrite);
|
||||
if((soundPosRead-soundPosWrite)<SOUND_SAMPLES*2){
|
||||
sceKernelWaitSema(console_mtx, 1, 0); //lock
|
||||
//debugNetPrintf(DEBUG,"start %d %d \n",soundPosRead,soundPosWrite);
|
||||
}
|
||||
memcpy(ptr_s,&soundbuffer[soundPosWrite],sizeof(short)*samples*2);
|
||||
soundPosWrite +=samples*2;
|
||||
if(soundPosWrite+(samples*2)>=(SOUND_SAMPLES*2*10)){
|
||||
soundPosWrite = 0;
|
||||
}
|
||||
}
|
||||
else /* Render silence */
|
||||
for (i = 0; i < samples; i++)
|
||||
buf[i].stereo.l = buf[i].stereo.r = 0;
|
||||
}
|
77
psp2/emumain.h
Normal file
77
psp2/emumain.h
Normal file
@ -0,0 +1,77 @@
|
||||
#ifndef _EMUMAIN_H
|
||||
#define _EMUMAIN_H
|
||||
|
||||
|
||||
#define int32 int32_t
|
||||
#define int16 int16_t
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
#define ScePspDateTime SceDateTime
|
||||
|
||||
#define SOUND_FREQUENCY 48000
|
||||
#define SOUND_SAMPLES 832
|
||||
|
||||
void InitEmulator();
|
||||
void RunEmulator();
|
||||
void TrashEmulator();
|
||||
|
||||
#define DISPLAY_MODE_UNSCALED 0
|
||||
#define DISPLAY_MODE_FIT_HEIGHT 1
|
||||
#define DISPLAY_MODE_FILL_SCREEN 2
|
||||
#define DISPLAY_MODE_2X 3
|
||||
#define DISPLAY_MODE_3X 4
|
||||
|
||||
#define JOY 0x10000
|
||||
#define SYS 0x20000
|
||||
#define SPC 0x40000
|
||||
#define AFI 0x80000
|
||||
|
||||
#define CODE_MASK(x) (x & 0xffff)
|
||||
|
||||
#define SPC_MENU 1
|
||||
#define SPC_REWIND 2
|
||||
|
||||
#define MAP_BUTTONS 18
|
||||
|
||||
#define MAP_ANALOG_UP 0
|
||||
#define MAP_ANALOG_DOWN 1
|
||||
#define MAP_ANALOG_LEFT 2
|
||||
#define MAP_ANALOG_RIGHT 3
|
||||
#define MAP_BUTTON_UP 4
|
||||
#define MAP_BUTTON_DOWN 5
|
||||
#define MAP_BUTTON_LEFT 6
|
||||
#define MAP_BUTTON_RIGHT 7
|
||||
#define MAP_BUTTON_SQUARE 8
|
||||
#define MAP_BUTTON_CROSS 9
|
||||
#define MAP_BUTTON_CIRCLE 10
|
||||
#define MAP_BUTTON_TRIANGLE 11
|
||||
#define MAP_BUTTON_LTRIGGER 12
|
||||
#define MAP_BUTTON_RTRIGGER 13
|
||||
#define MAP_BUTTON_SELECT 14
|
||||
#define MAP_BUTTON_START 15
|
||||
#define MAP_BUTTON_LRTRIGGERS 16
|
||||
#define MAP_BUTTON_STARTSELECT 17
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ShowFps;
|
||||
int ControlMode;
|
||||
int ClockFreq;
|
||||
int DisplayMode;
|
||||
int VSync;
|
||||
int UpdateFreq;
|
||||
int Frameskip;
|
||||
int VertStrip;
|
||||
int SoundEngine;
|
||||
int SoundBoost;
|
||||
int AutoFire;
|
||||
int RewindSaveRate;
|
||||
int RewindReplayDelay;
|
||||
} EmulatorOptions;
|
||||
|
||||
struct ButtonConfig
|
||||
{
|
||||
unsigned int ButtonMap[MAP_BUTTONS];
|
||||
};
|
||||
|
||||
#endif // _EMUMAIN_H
|
35
psp2/error.c
Normal file
35
psp2/error.c
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
error.c --
|
||||
Error logging
|
||||
*/
|
||||
|
||||
#include "osd.h"
|
||||
|
||||
static FILE *error_log;
|
||||
|
||||
void error_init(void)
|
||||
{
|
||||
#ifdef LOGERROR
|
||||
error_log = fopen("error.log","w");
|
||||
#endif
|
||||
}
|
||||
|
||||
void error_shutdown(void)
|
||||
{
|
||||
#ifdef LOGERROR
|
||||
if(error_log) fclose(error_log);
|
||||
#endif
|
||||
}
|
||||
|
||||
void error(char *format, ...)
|
||||
{
|
||||
#ifdef LOGERROR
|
||||
if (log_error)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
if(error_log) vfprintf(error_log, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
}
|
10
psp2/error.h
Normal file
10
psp2/error.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _ERROR_H_
|
||||
#define _ERROR_H_
|
||||
|
||||
/* Function prototypes */
|
||||
void error_init(void);
|
||||
void error_shutdown(void);
|
||||
void error(char *format, ...);
|
||||
|
||||
#endif /* _ERROR_H_ */
|
||||
|
154
psp2/fileio.c
Normal file
154
psp2/fileio.c
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* fileio.c
|
||||
*
|
||||
* Load a normal file, or ZIP/GZ archive into ROM buffer.
|
||||
* Returns loaded ROM size (zero if an error occured)
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald
|
||||
* modified by Eke-Eke (Genesis Plus GX)
|
||||
*
|
||||
* Redistribution and use of this code or any derivative works are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions may not be sold, nor may they be used in a commercial
|
||||
* product or activity.
|
||||
*
|
||||
* - Redistributions that are modified from the original source must include the
|
||||
* complete source code, including the source code for all components used by a
|
||||
* binary built from the modified sources. However, as a special exception, the
|
||||
* source code distributed need not include anything that is normally distributed
|
||||
* (in either source or binary form) with the major components (compiler, kernel,
|
||||
* and so on) of the operating system on which the executable runs, unless that
|
||||
* component itself accompanies the executable.
|
||||
*
|
||||
* - Redistributions 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.
|
||||
*
|
||||
* 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 "shared.h"
|
||||
#include <zlib.h>
|
||||
|
||||
static int check_zip(char *filename);
|
||||
|
||||
int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
if(check_zip(filename))
|
||||
{
|
||||
unz_file_info info;
|
||||
int ret = 0;
|
||||
char fname[256];
|
||||
|
||||
/* Attempt to open the archive */
|
||||
unzFile *fd = unzOpen(filename);
|
||||
if (!fd) return 0;
|
||||
|
||||
/* Go to first file in archive */
|
||||
ret = unzGoToFirstFile(fd);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get file informations and update filename */
|
||||
ret = unzGetCurrentFileInfo(fd, &info, fname, 256, NULL, 0, NULL, 0);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compressed filename extension */
|
||||
if (extension)
|
||||
{
|
||||
strncpy(extension, &fname[strlen(fname) - 3], 3);
|
||||
extension[3] = 0;
|
||||
}
|
||||
|
||||
/* Open the file for reading */
|
||||
ret = unzOpenCurrentFile(fd);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Retrieve uncompressed file size */
|
||||
size = info.uncompressed_size;
|
||||
if(size > maxsize)
|
||||
{
|
||||
size = maxsize;
|
||||
}
|
||||
|
||||
/* Read (decompress) the file */
|
||||
ret = unzReadCurrentFile(fd, buffer, size);
|
||||
if(ret != size)
|
||||
{
|
||||
unzCloseCurrentFile(fd);
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Close the current file */
|
||||
ret = unzCloseCurrentFile(fd);
|
||||
if(ret != UNZ_OK)
|
||||
{
|
||||
unzClose(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Close the archive */
|
||||
ret = unzClose(fd);
|
||||
if(ret != UNZ_OK) return 0;
|
||||
}
|
||||
/*else
|
||||
{
|
||||
gzFile *gd = gzopen(filename, "rb");
|
||||
if (!gd) return 0;
|
||||
|
||||
size = gzread(gd, buffer, maxsize);
|
||||
|
||||
if (extension)
|
||||
{
|
||||
strncpy(extension, &filename[strlen(filename) - 3], 3);
|
||||
extension[3] = 0;
|
||||
}
|
||||
|
||||
gzclose(gd);
|
||||
}*/
|
||||
|
||||
/* Return loaded ROM size */
|
||||
return size;
|
||||
}
|
||||
|
||||
/*
|
||||
Verifies if a file is a ZIP archive or not.
|
||||
Returns: 1= ZIP archive, 0= not a ZIP archive
|
||||
*/
|
||||
static int check_zip(char *filename)
|
||||
{
|
||||
uint8 buf[2];
|
||||
FILE *fd = fopen(filename, "rb");
|
||||
if(!fd) return (0);
|
||||
fread(buf, 2, 1, fd);
|
||||
fclose(fd);
|
||||
if(memcmp(buf, "PK", 2) == 0) return (1);
|
||||
return (0);
|
||||
}
|
48
psp2/fileio.h
Normal file
48
psp2/fileio.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* fileio.c
|
||||
*
|
||||
* Load a normal file, or ZIP/GZ archive.
|
||||
* Returns loaded ROM size (zero if an error occured)
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald
|
||||
* modified by Eke-Eke (Genesis Plus GX)
|
||||
*
|
||||
* Redistribution and use of this code or any derivative works are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions may not be sold, nor may they be used in a commercial
|
||||
* product or activity.
|
||||
*
|
||||
* - Redistributions that are modified from the original source must include the
|
||||
* complete source code, including the source code for all components used by a
|
||||
* binary built from the modified sources. However, as a special exception, the
|
||||
* source code distributed need not include anything that is normally distributed
|
||||
* (in either source or binary form) with the major components (compiler, kernel,
|
||||
* and so on) of the operating system on which the executable runs, unless that
|
||||
* component itself accompanies the executable.
|
||||
*
|
||||
* - Redistributions 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef _FILEIO_H_
|
||||
#define _FILEIO_H_
|
||||
|
||||
/* Function prototypes */
|
||||
extern int load_archive(char *filename, unsigned char *buffer, int maxsize, char *extension);
|
||||
|
||||
#endif /* _FILEIO_H_ */
|
50
psp2/main.c
Normal file
50
psp2/main.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <psp2/moduleinfo.h>
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#include "psplib/pl_snd.h"
|
||||
#include "psplib/video.h"
|
||||
#include "psplib/pl_psp.h"
|
||||
#include "psplib/ctrl.h"
|
||||
#include <vita2d.h>
|
||||
|
||||
#include "menu.h"
|
||||
#include "emumain.h"
|
||||
|
||||
|
||||
PSP2_MODULE_INFO(0,1,PSP_APP_NAME)
|
||||
//PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER)
|
||||
|
||||
static void ExitCallback(void* arg)
|
||||
{
|
||||
ExitPSP = 1;
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
/* Initialize PSP */
|
||||
pl_psp_init("cache0:/GENPlusVITA/");
|
||||
pl_snd_init(SOUND_SAMPLES, 1);
|
||||
pspCtrlInit();
|
||||
pspVideoInit();
|
||||
|
||||
/* Initialize callbacks */
|
||||
pl_psp_register_callback(PSP_EXIT_CALLBACK,
|
||||
ExitCallback,
|
||||
NULL);
|
||||
pl_psp_start_callback_thread();
|
||||
|
||||
/* Start emulation */
|
||||
InitMenu();
|
||||
DisplayMenu();
|
||||
TrashMenu();
|
||||
|
||||
/* Release PSP resources */
|
||||
pl_snd_shutdown();
|
||||
pspVideoShutdown();
|
||||
pl_psp_shutdown();
|
||||
|
||||
return(0);
|
||||
}
|
11
psp2/main.h
Normal file
11
psp2/main.h
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
#ifndef _MAIN_H_
|
||||
#define _MAIN_H_
|
||||
|
||||
#define MAX_INPUTS 8
|
||||
|
||||
extern int debug_on;
|
||||
extern int log_error;
|
||||
extern int sdl_input_update(void);
|
||||
|
||||
#endif /* _MAIN_H_ */
|
1289
psp2/menu.c
Normal file
1289
psp2/menu.c
Normal file
File diff suppressed because it is too large
Load Diff
8
psp2/menu.h
Normal file
8
psp2/menu.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _MENU_H
|
||||
#define _MENU_H
|
||||
|
||||
void InitMenu();
|
||||
void DisplayMenu();
|
||||
void TrashMenu();
|
||||
|
||||
#endif
|
34
psp2/osd.h
Normal file
34
psp2/osd.h
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
#ifndef _OSD_H_
|
||||
#define _OSD_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "shared.h"
|
||||
#include "config.h"
|
||||
#include "error.h"
|
||||
#include "unzip.h"
|
||||
#include "fileio.h"
|
||||
|
||||
extern void osd_input_update(void);
|
||||
|
||||
|
||||
#define GG_ROM "./ggenie.bin"
|
||||
#define AR_ROM "./areplay.bin"
|
||||
#define SK_ROM "./sk.bin"
|
||||
#define SK_UPMEM "./sk2chip.bin"
|
||||
#define CD_BIOS_US "./bios_CD_U.bin"
|
||||
#define CD_BIOS_EU "./bios_CD_E.bin"
|
||||
#define CD_BIOS_JP "./bios_CD_J.bin"
|
||||
#define MD_BIOS "./bios_MD.bin"
|
||||
#define MS_BIOS_US "./bios_U.sms"
|
||||
#define MS_BIOS_EU "./bios_E.sms"
|
||||
#define MS_BIOS_JP "./bios_J.sms"
|
||||
#define GG_BIOS "./bios.gg"
|
||||
|
||||
#endif /* _OSD_H_ */
|
1294
psp2/unzip.c
Normal file
1294
psp2/unzip.c
Normal file
File diff suppressed because it is too large
Load Diff
273
psp2/unzip.h
Normal file
273
psp2/unzip.h
Normal file
@ -0,0 +1,273 @@
|
||||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 0.15 beta, Mar 19th, 1998,
|
||||
|
||||
Copyright (C) 1998 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
Encryption and multi volume ZipFile (span) are not supported.
|
||||
Old compressions used by old PKZip 1.x are not supported
|
||||
|
||||
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
|
||||
CAN CHANGE IN FUTURE VERSION !!
|
||||
I WAIT FEEDBACK at mail info@winimage.com
|
||||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||
|
||||
Condition of use and distribution are the same than zlib :
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* for more info about .ZIP format, see
|
||||
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||
PkWare has also a specification at :
|
||||
ftp://ftp.pkware.com/probdesc.zip */
|
||||
|
||||
#ifndef _unz_H
|
||||
#define _unz_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef _ZLIB_H
|
||||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||
from (void*) without cast */
|
||||
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||
typedef unzFile__ *unzFile;
|
||||
#else
|
||||
typedef voidp unzFile;
|
||||
#endif
|
||||
|
||||
|
||||
#define UNZ_OK (0)
|
||||
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||
#define UNZ_ERRNO (Z_ERRNO)
|
||||
#define UNZ_EOF (0)
|
||||
#define UNZ_PARAMERROR (-102)
|
||||
#define UNZ_BADZIPFILE (-103)
|
||||
#define UNZ_INTERNALERROR (-104)
|
||||
#define UNZ_CRCERROR (-105)
|
||||
|
||||
/* tm_unz contain date/time info */
|
||||
typedef struct tm_unz_s
|
||||
{
|
||||
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||
uInt tm_mday; /* day of the month - [1,31] */
|
||||
uInt tm_mon; /* months since January - [0,11] */
|
||||
uInt tm_year; /* years - [1980..2044] */
|
||||
} tm_unz;
|
||||
|
||||
/* unz_global_info structure contain global data about the ZIPfile
|
||||
These data comes from the end of central dir */
|
||||
typedef struct unz_global_info_s
|
||||
{
|
||||
uLong number_entry; /* total number of entries in
|
||||
the central dir on this disk */
|
||||
uLong size_comment; /* size of the global comment of the zipfile */
|
||||
} unz_global_info;
|
||||
|
||||
|
||||
/* unz_file_info contain information about a file in the zipfile */
|
||||
typedef struct unz_file_info_s
|
||||
{
|
||||
uLong version; /* version made by 2 bytes */
|
||||
uLong version_needed; /* version needed to extract 2 bytes */
|
||||
uLong flag; /* general purpose bit flag 2 bytes */
|
||||
uLong compression_method; /* compression method 2 bytes */
|
||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||
uLong crc; /* crc-32 4 bytes */
|
||||
uLong compressed_size; /* compressed size 4 bytes */
|
||||
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||
uLong size_filename; /* filename length 2 bytes */
|
||||
uLong size_file_extra; /* extra field length 2 bytes */
|
||||
uLong size_file_comment; /* file comment length 2 bytes */
|
||||
|
||||
uLong disk_num_start; /* disk number start 2 bytes */
|
||||
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||
uLong external_fa; /* external file attributes 4 bytes */
|
||||
|
||||
tm_unz tmu_date;
|
||||
} unz_file_info;
|
||||
|
||||
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||
const char* fileName2,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Compare two filename (fileName1,fileName2).
|
||||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||
or strcasecmp)
|
||||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||
(like 1 on Unix, 2 on Windows)
|
||||
*/
|
||||
|
||||
|
||||
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||
/*
|
||||
Open a Zip file. path contain the full pathname (by example,
|
||||
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||
"zlib/zlib111.zip".
|
||||
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||
return value is NULL.
|
||||
Else, the return value is a unzFile Handle, usable with other function
|
||||
of this unzip package.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzClose OF((unzFile file));
|
||||
/*
|
||||
Close a ZipFile opened with unzipOpen.
|
||||
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||
unz_global_info *pglobal_info));
|
||||
/*
|
||||
Write info about the ZipFile in the *pglobal_info structure.
|
||||
No preparation of the structure is needed
|
||||
return UNZ_OK if there is no problem. */
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||
char *szComment,
|
||||
uLong uSizeBuf));
|
||||
/*
|
||||
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||
uSizeBuf is the size of the szComment buffer.
|
||||
return the number of byte copied or an error code <0
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* Unzip package allow you browse the directory of the zipfile */
|
||||
|
||||
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the first file.
|
||||
return UNZ_OK if there is no problem
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||
/*
|
||||
Set the current file of the zipfile to the next file.
|
||||
return UNZ_OK if there is no problem
|
||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||
const char *szFileName,
|
||||
int iCaseSensitivity));
|
||||
/*
|
||||
Try locate the file szFileName in the zipfile.
|
||||
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||
|
||||
return value :
|
||||
UNZ_OK if the file is found. It becomes the current file.
|
||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||
unz_file_info *pfile_info,
|
||||
char *szFileName,
|
||||
uLong fileNameBufferSize,
|
||||
void *extraField,
|
||||
uLong extraFieldBufferSize,
|
||||
char *szComment,
|
||||
uLong commentBufferSize));
|
||||
/*
|
||||
Get Info about the current file
|
||||
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||
the current file
|
||||
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||
(fileNameBufferSize is the size of the buffer)
|
||||
if extraField!=NULL, the extra field information will be copied in extraField
|
||||
(extraFieldBufferSize is the size of the buffer).
|
||||
This is the Central-header version of the extra field
|
||||
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||
(commentBufferSize is the size of the buffer)
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
/* for reading the content of the current zipfile, you can open it, read data
|
||||
from it, and close it (you can close it before reading all the file)
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Open for reading data the current file in the zipfile.
|
||||
If there is no error, the return value is UNZ_OK.
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||
/*
|
||||
Close the file in zip opened with unzOpenCurrentFile
|
||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||
buf contain buffer where data must be copied
|
||||
len the size of buf.
|
||||
|
||||
return the number of byte copied if somes bytes are copied
|
||||
return 0 if the end of file was reached
|
||||
return <0 with error code if there is an error
|
||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||
*/
|
||||
|
||||
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||
/*
|
||||
Give the current position in uncompressed data
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzeof OF((unzFile file));
|
||||
/*
|
||||
return 1 if the end of file was reached, 0 elsewhere
|
||||
*/
|
||||
|
||||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||
voidp buf,
|
||||
unsigned len));
|
||||
/*
|
||||
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||
This is the local-header version of the extra field (sometimes, there is
|
||||
more info in the local-header version than in the central-header)
|
||||
|
||||
if buf==NULL, it return the size of the local extra field
|
||||
|
||||
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||
buf.
|
||||
the return value is the number of bytes copied in buf, or (if <0)
|
||||
the error code
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _unz_H */
|
Loading…
Reference in New Issue
Block a user