Commit 420c9473 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 4698af59
......@@ -151,9 +151,10 @@ unsigned int blockNumToAddr(unsigned char chip, unsigned char blockNum)
if(blockNum >= bootBlockStartNum)
{
addr = bootBlockStartNum * 0x10000;
unsigned char bootBlock;
unsigned char bootBlock = blockNum - bootBlockStartNum;
addr = bootBlockStartNum * 0x10000;
bootBlock = blockNum - bootBlockStartNum;
if(bootBlock>=1)
addr+= 0x8000;
if(bootBlock>=2)
......
......@@ -282,8 +282,8 @@ void palette_init16(DWORD dwRBitMask, DWORD dwGBitMask, DWORD dwBBitMask)
case NGPC:
if (dark_filter_level > 0)
{
static const float rgb_max = 15.0f;
static const float rgb_max_inv = 1.0f / rgb_max;
static const float rgb_max = 15.0f;
static const float rgb_max_inv = 1.0f / 15.0f;
float r_float, g_float, b_float;
int r_final, g_final, b_final;
......@@ -462,7 +462,7 @@ int OOWCol; /* placeholder for the outside window color this VSYNC */
unsigned char SprPriLo, SprPriHi, SprPri = 0;
#endif
static inline void set_paletteCol(
static INLINE void set_paletteCol(
unsigned short *palette_table,
unsigned short *sprite,
unsigned short *front,
......@@ -501,7 +501,7 @@ static inline void set_paletteCol(
}
}
static inline void set_paletteBW(
static INLINE void set_paletteBW(
unsigned short *palette_table,
unsigned short *sprite,
unsigned short *front,
......@@ -526,14 +526,14 @@ static inline void set_paletteBW(
}
/* I think there's something wrong with this on the GP2X, because CFC2's intro screen is all red */
static inline void lineClear(TILECACHE *tC, unsigned short col)
static INLINE void lineClear(TILECACHE *tC, unsigned short col)
{
int i;
for(i = 0; i < 21 * 8; i++)
tC->gbp[i] = col;
}
static inline void clipLeftRight(SPRITEDEFS *sprDef, unsigned short OOWCol)
static INLINE void clipLeftRight(SPRITEDEFS *sprDef, unsigned short OOWCol)
{
int i,j;
......@@ -549,7 +549,7 @@ static inline void clipLeftRight(SPRITEDEFS *sprDef, unsigned short OOWCol)
sprDef->gbp[i] = OOWCol;
}
static inline void lineFront(TILECACHE *tC)
static INLINE void lineFront(TILECACHE *tC)
{
int i;
unsigned char a,b;
......@@ -614,7 +614,7 @@ static inline void lineFront(TILECACHE *tC)
}
}
static inline void lineSprite(SPRITEDEFS *sprDefs)
static INLINE void lineSprite(SPRITEDEFS *sprDefs)
{
int i;
SPRITE *spr;
......@@ -746,7 +746,7 @@ static void spriteSort(unsigned int bw)
}
#endif
static inline void spriteSortAll(unsigned int bw)
static INLINE void spriteSortAll(unsigned int bw)
{
unsigned int spriteCode;
unsigned short *pt;
......@@ -860,7 +860,7 @@ static void graphicsBlitInit(void)
#endif
}
static inline void RenderTileCache(TILECACHE *tC, unsigned int bw)
static INLINE void RenderTileCache(TILECACHE *tC, unsigned int bw)
{
int i;
unsigned char line;
......
......@@ -101,10 +101,12 @@ static void check_variables(void)
}
void retro_init(void)
{
char *dir = NULL;
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
/* set up some logging */
init_log(environ_cb);
char *dir = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &dir) && dir)
sprintf(retro_save_directory, "%s%c", dir, path_default_slash_c());
......@@ -113,10 +115,9 @@ void retro_init(void)
check_variables();
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
if(!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt) && log_cb)
log_cb(RETRO_LOG_ERROR, "[could not set RGB565]\n");
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
libretro_supports_input_bitmasks = true;
}
......@@ -337,15 +338,17 @@ bool retro_load_game(const struct retro_game_info *info)
check_variables();
/* TODO: Mappings might need updating
* Size is based on what is exposed in Mednafen NGP */
struct retro_memory_descriptor descs = {
RETRO_MEMDESC_SYSTEM_RAM, mainram, 0, 0, 0, 0, 16384, "RAM"
};
struct retro_memory_map retro_map = {
&descs, 1
};
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retro_map);
{
/* TODO: Mappings might need updating
* Size is based on what is exposed in Mednafen NGP */
struct retro_memory_descriptor descs = {
RETRO_MEMDESC_SYSTEM_RAM, mainram, 0, 0, 0, 0, 16384, "RAM"
};
struct retro_memory_map retro_map = {
&descs, 1
};
environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retro_map);
}
return true;
}
......
......@@ -110,6 +110,14 @@ typedef struct race_state_0x11 race_state_t;
static int state_store(race_state_t *rs)
{
int i = 0;
#ifdef CZ80
extern cz80_struc *RACE_cz80_struc;
extern s32 Z80_ICount;
int size_of_z80;
#elif DRZ80
extern Z80_Regs Z80;
#endif
extern int sndCycles;
/* TLCS-900h Registers */
rs->pc = gen_regsPC;
......@@ -147,20 +155,16 @@ static int state_store(race_state_t *rs)
/* Z80 Registers */
#ifdef CZ80
extern cz80_struc *RACE_cz80_struc;
extern s32 Z80_ICount;
int size_of_z80 =
size_of_z80 =
(uintptr_t)(&(RACE_cz80_struc->CycleSup)) - (uintptr_t)(&(RACE_cz80_struc->BC));
memcpy(&rs->RACE_cz80_struc, RACE_cz80_struc, size_of_z80);
rs->Z80_ICount = Z80_ICount;
rs->PC_offset = Cz80_Get_PC(RACE_cz80_struc);
#elif DRZ80
extern Z80_Regs Z80;
memcpy(&rs->Z80, &Z80, sizeof(Z80));
#endif
/* Sound */
extern int sndCycles;
rs->sndCycles = sndCycles;
memcpy(&rs->toneChip, &toneChip, sizeof(SoundChip));
memcpy(&rs->noiseChip, &noiseChip, sizeof(SoundChip));
......@@ -184,6 +188,14 @@ static int state_store(race_state_t *rs)
static int state_restore(race_state_t *rs)
{
int i = 0;
#ifdef CZ80
extern cz80_struc *RACE_cz80_struc;
extern s32 Z80_ICount;
int size_of_z80;
#elif DRZ80
extern Z80_Regs Z80;
#endif
extern int sndCycles;
/* TLCS-900h Registers */
gen_regsPC = rs->pc;
......@@ -221,21 +233,17 @@ static int state_restore(race_state_t *rs)
/* Z80 Registers */
#ifdef CZ80
extern cz80_struc *RACE_cz80_struc;
extern s32 Z80_ICount;
int size_of_z80 =
size_of_z80 =
(uintptr_t)(&(RACE_cz80_struc->CycleSup)) - (uintptr_t)(&(RACE_cz80_struc->BC));
memcpy(RACE_cz80_struc, &rs->RACE_cz80_struc, size_of_z80);
Z80_ICount = rs->Z80_ICount;
Cz80_Set_PC(RACE_cz80_struc, rs->PC_offset);
#elif DRZ80
extern Z80_Regs Z80;
memcpy(&Z80, &rs->Z80, sizeof(Z80));
#endif
/* Sound */
extern int sndCycles;
sndCycles = rs->sndCycles;
memcpy(&toneChip, &rs->toneChip, sizeof(SoundChip));
memcpy(&noiseChip, &rs->noiseChip, sizeof(SoundChip));
......
......@@ -2927,63 +2927,65 @@ int mulsRMW10(void) // MULS RR,(mem) 10010mmm 01001RRR
static INLINE unsigned short myDivB(unsigned short i, unsigned char j)
{
if (!j)
{
gen_regsSR|= VF;
return (i<<8) | ((i>>8)^0xFF);
}
ldiv_t res;
if (!j)
{
gen_regsSR|= VF;
return (i<<8) | ((i>>8)^0xFF);
}
/* ldiv_t res;
/* ldiv_t res;
if (i >= (0x0200 * j))
{
int diff = i - (0x0200 * j);
int range = 256 - j;
res = ldiv(diff, range);
res.quot = 0x1FF - res.quot;
res.rem = res.rem + j;
}
else
{
res = ldiv(i,j);
}
*/
ldiv_t res = ldiv(i,j);
if (res.quot>0xFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return ((unsigned short)(res.quot & 0xFF)) | ((unsigned short)((res.rem & 0xFF) << 8));
if (i >= (0x0200 * j))
{
int diff = i - (0x0200 * j);
int range = 256 - j;
res = ldiv(diff, range);
res.quot = 0x1FF - res.quot;
res.rem = res.rem + j;
}
else
{
res = ldiv(i,j);
}
*/
res = ldiv(i,j);
if (res.quot>0xFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return ((unsigned short)(res.quot & 0xFF)) | ((unsigned short)((res.rem & 0xFF) << 8));
}
static INLINE unsigned int myDivW(unsigned int i, unsigned short j)
{
if (!j)
{
gen_regsSR|= VF;
return (i<<16) | ((i>>16)^0xFFFF);
}
/* PacMan fix : when j>=128 -> overflow
ldiv_t res;
if (i >= (0x02000000 * (unsigned int)j))
{
int diff = i - (0x02000000 * j);
int range = 0x1000000 - j;
res = ldiv(diff, range);
res.quot = 0x1FFFFFF - res.quot;
res.rem = res.rem + j;
}
else
{
res = ldiv(i,j);
}
*/
ldiv_t res = ldiv(i,j);
if (res.quot>0xFFFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return (res.quot & 0xFFFF) | ((res.rem & 0xFFFF) << 16);
ldiv_t res;
if (!j)
{
gen_regsSR|= VF;
return (i<<16) | ((i>>16)^0xFFFF);
}
/* PacMan fix : when j>=128 -> overflow
ldiv_t res;
if (i >= (0x02000000 * (unsigned int)j))
{
int diff = i - (0x02000000 * j);
int range = 0x1000000 - j;
res = ldiv(diff, range);
res.quot = 0x1FFFFFF - res.quot;
res.rem = res.rem + j;
}
else
{
res = ldiv(i,j);
}
*/
res = ldiv(i,j);
if (res.quot>0xFFFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return (res.quot & 0xFFFF) | ((res.rem & 0xFFFF) << 16);
}
int divRrB(void) // DIV RR,r 11001rrr 01010RRR
......@@ -3043,37 +3045,38 @@ int divRMW10(void) // DIV RR,(mem) 10010mmm 01010RRR
unsigned short myDivsB(signed short i, signed char j)
{
if (!j)
{
gen_regsSR|= VF;
if (i<1)
return (i<<8) | (i^0xFF);
else
return (i<<8);
}
ldiv_t res;
if (!j)
{
gen_regsSR|= VF;
if (i<1)
return (i<<8) | (i^0xFF);
return (i<<8);
}
ldiv_t res = ldiv(i,j);
if (res.quot>0xFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return ((unsigned short)(res.quot & 0xFF)) | ((unsigned short)((res.rem & 0xFF) << 8));
res = ldiv(i,j);
if (res.quot>0xFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return ((unsigned short)(res.quot & 0xFF)) | ((unsigned short)((res.rem & 0xFF) << 8));
}
unsigned int myDivsW(signed int i, signed short j)
{
if (!j)
{
gen_regsSR|= VF;
return (i<<16) | (i^0xFFFF);
}
ldiv_t res;
if (!j)
{
gen_regsSR|= VF;
return (i<<16) | (i^0xFFFF);
}
ldiv_t res = ldiv(i,j);
if (res.quot>0xFFFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return (res.quot & 0xFFFF) | ((res.rem & 0xFFFF) << 16);
res = ldiv(i,j);
if (res.quot>0xFFFF)
gen_regsSR|= VF;
else
gen_regsSR&= ~VF;
return (res.quot & 0xFFFF) | ((res.rem & 0xFFFF) << 16);
}
int divsRrB(void) // DIVS RR,r 11001rrr 01011RRR
......@@ -3931,52 +3934,53 @@ int tset3M30(void) // TSET #3,(mem) 10110mmm 10101xxx
int bs1b(void) // BS1B A,r 11011rrr 00001111
{
unsigned short i = *regW;
unsigned char ret;
unsigned short i = *regW;
if (i==0)
{
gen_regsSR |= VF;
return 4;
}
if (i==0)
{
gen_regsSR |= VF;
return 4;
}
unsigned char ret = 15;
ret = 15;
gen_regsSR &= ~VF;
gen_regsSR &= ~VF;
while (i<0x8000)
{
i = i<<1;
ret -= 1;
}
while (i<0x8000)
{
i = i<<1;
ret -= 1;
}
*cregsB[1] = ret;
return 4;
*cregsB[1] = ret;
return 4;
}
int bs1f(void) // BS1F A,r 11011rrr 00001110
{
unsigned short i = *regW;
unsigned char ret = 0;
unsigned short i = *regW;
if (i==0)
{
gen_regsSR|= VF;
return 4;
}
if (i==0)
{
gen_regsSR|= VF;
return 4;
}
unsigned char ret = 0;
gen_regsSR&= ~VF;
gen_regsSR&= ~VF;
while (!(i&1))
{
i = i>>1;
ret+=1;
}
while (!(i&1))
{
i = i>>1;
ret+=1;
}
*cregsB[1] = ret;
*cregsB[1] = ret;
return 4;
return 4;
}
//////////////////////////////////////////////////////////////////////////////
......@@ -6384,30 +6388,30 @@ void initTimezone(void)
static INLINE int VECT_RTCGET(unsigned int dest)
{
// dest+0 // year
// dest+1 // month all in BCD
// dest+2 // day
// dest+3 // hours
// dest+4 // minutes
// dest+5 // nr year after leap : day of the week
unsigned char *d = get_address(dest);
struct tm *lt;
time_t now = time(NULL);
initTimezone(); //make sure TZ is set up
lt = localtime(&now);
//int year = (lt->tm_year+1900) % 100;
int year = lt->tm_year-100;
d[0] = makeBCD(year);
d[1] = makeBCD(lt->tm_mon+1);
d[2] = makeBCD(lt->tm_mday);
d[3] = makeBCD(lt->tm_hour);
d[4] = makeBCD(lt->tm_min);
d[5] = makeBCD(lt->tm_sec);
d[6] = ((year % 4)<<4)|(lt->tm_wday & 0x0F);
return 100;
// dest+0 // year
// dest+1 // month all in BCD
// dest+2 // day
// dest+3 // hours
// dest+4 // minutes
// dest+5 // nr year after leap : day of the week
unsigned char *d = get_address(dest);
int year;
struct tm *lt;
time_t now = time(NULL);
initTimezone(); //make sure TZ is set up
lt = localtime(&now);
//int year = (lt->tm_year+1900) % 100;
year = lt->tm_year-100;
d[0] = makeBCD(year);
d[1] = makeBCD(lt->tm_mon+1);
d[2] = makeBCD(lt->tm_mday);
d[3] = makeBCD(lt->tm_hour);
d[4] = makeBCD(lt->tm_min);
d[5] = makeBCD(lt->tm_sec);
d[6] = ((year % 4)<<4)|(lt->tm_wday & 0x0F);
return 100;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment