Commit 3e70188a authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups - turn inline functions into static inline functions

parent 722ee974
......@@ -175,7 +175,7 @@ void graphicsBlitEnd(void)
void graphics_paint(void);
#if defined(DO_PERIODIC_FLASH_SAVES)
inline void incFrameCount()
static inline void incFrameCount(void)
{
frameCount++;
}
......@@ -591,10 +591,11 @@ int OOWCol; /* placeholder for the outside window color this VSYNC */
unsigned char SprPriLo, SprPriHi, SprPri = 0;
#endif
inline void set_paletteCol(unsigned short *palette_table,
unsigned short *sprite,
unsigned short *front,
unsigned short *back)
static inline void set_paletteCol(
unsigned short *palette_table,
unsigned short *sprite,
unsigned short *front,
unsigned short *back)
{
int i;
/* initialize palette table
......@@ -631,10 +632,11 @@ inline void set_paletteCol(unsigned short *palette_table,
}
}
inline void set_paletteBW(unsigned short *palette_table,
unsigned short *sprite,
unsigned short *front,
unsigned short *back)
static inline void set_paletteBW(
unsigned short *palette_table,
unsigned short *sprite,
unsigned short *front,
unsigned short *back)
{
int i;
unsigned char *pt = ((unsigned char *)palette_table)-0x0100; /* get b/w color table */
......@@ -655,13 +657,13 @@ inline void set_paletteBW(unsigned short *palette_table,
}
/* I think there's something wrong with this on the GP2X, because CFC2's intro screen is all red */
inline void lineClear(TILECACHE *tC, unsigned short col)
static inline void lineClear(TILECACHE *tC, unsigned short col)
{
for(int i=0; i<21*8; i++)
tC->gbp[i] = col;
}
inline void clipLeftRight(SPRITEDEFS *sprDef, unsigned short OOWCol)
static inline void clipLeftRight(SPRITEDEFS *sprDef, unsigned short OOWCol)
{
int i,j;
......@@ -677,7 +679,7 @@ inline void clipLeftRight(SPRITEDEFS *sprDef, unsigned short OOWCol)
sprDef->gbp[i] = OOWCol;
}
inline void lineFront(TILECACHE *tC)
static inline void lineFront(TILECACHE *tC)
{
int i;
unsigned char a,b;
......@@ -742,7 +744,7 @@ inline void lineFront(TILECACHE *tC)
}
}
inline void lineSprite(SPRITEDEFS *sprDefs)
static inline void lineSprite(SPRITEDEFS *sprDefs)
{
SPRITE *spr;
unsigned short *gb;
......@@ -805,7 +807,7 @@ inline void lineSprite(SPRITEDEFS *sprDefs)
/* sort all the sprites according to their priorities */
#if 0
inline void spriteSort(unsigned int bw)
static void spriteSort(unsigned int bw)
{
unsigned short spriteCode;
unsigned short *pt;
......@@ -873,7 +875,7 @@ inline void spriteSort(unsigned int bw)
}
#endif
inline void spriteSortAll(unsigned int bw)
static inline void spriteSortAll(unsigned int bw)
{
unsigned int spriteCode;
unsigned short *pt;
......@@ -987,7 +989,7 @@ void graphicsBlitInit(void)
#endif
}
inline void RenderTileCache(TILECACHE *tC, unsigned int bw)
static inline void RenderTileCache(TILECACHE *tC, unsigned int bw)
{
int i;
unsigned char line;
......
......@@ -6,28 +6,7 @@
#include "memory.h"
/* address where the state of the input device(s) is stored */
#if 0
unsigned char *InputByte = get_address(0x00006F82);
#endif
unsigned char ngpInputState = 0;
unsigned char *InputByte = &ngpInputState;
#define DIK_UP SDLK_UP
#define DIK_DOWN SDLK_DOWN
#define DIK_LEFT SDLK_LEFT
#define DIK_RIGHT SDLK_RIGHT
#define DIK_SPACE SDLK_a
#define DIK_N SDLK_b
#define DIK_S SDLK_ESCAPE
#define DIK_O SDLK_SPACE
#define DOWN(x) keystates[x]
Uint8 *keystates = NULL;
struct joy_range
{
int minx, maxx, miny, maxy;
} range;
BOOL InitInput(void)
{
......
......@@ -19,7 +19,6 @@
extern unsigned char ngpInputState;
BOOL InitInput(void);
void UpdateInputState(void);
void FreeInput(void);
#endif /* !defined(AFX_INPUT_H__59701BE2_A97A_11D3_8645_00A0241D2A65__INCLUDED_) */
......@@ -37,17 +37,15 @@ extern unsigned char cpurom[]; // Bios ROM image area
/// tlcs 900h memory
//extern unsigned char cpuram[]; // 900h cpu core needs this..
extern unsigned char *cpuram;
unsigned char tlcsMemReadB(unsigned int addr);
unsigned short tlcsMemReadW(unsigned int addr);
unsigned int tlcsMemReadL(unsigned int addr);
void tlcsMemWriteB(unsigned int addr, unsigned char data);
void tlcsMemWriteW(unsigned int addr, unsigned short data);
void tlcsMemWriteL(unsigned int addr, unsigned int data);
void mem_init();
void mem_init(void);
void mem_dump_ram(FILE *output);
//unsigned char *get_address(unsigned int addr);
//unsigned char *get_addressW(unsigned int addr);
#if 0
unsigned char *get_address(unsigned int addr);
unsigned char *get_addressW(unsigned int addr);
#endif
/// gameboy memory
......@@ -141,107 +139,86 @@ unsigned char i8048ExtReadB(unsigned int addr);
void i8048ExtWriteB(unsigned int addr, unsigned char data);
unsigned char i8048PortReadB(unsigned char port);
void i8048PortWriteB(unsigned char port, unsigned char data);
void i8048SetT1();
unsigned char i8048GetT1();
void i8048SetT1(void);
unsigned char i8048GetT1(void);
//
// sm85xx memory functions
//
/*
* sm85xx memory functions
*/
extern unsigned char (*sm85MemReadB)(unsigned short addr);
extern void (*sm85MemWriteB)(unsigned short addr, unsigned char data);
extern unsigned char realBIOSloaded;
inline unsigned char *get_address(unsigned int addr)
static inline unsigned char *get_address(unsigned int addr)
{
addr&= 0x00FFFFFF;
if (addr<0x00200000)
{
if (addr<0x000008a0)
{
//if(((unsigned int)&cpuram[addr] >> 24) == 0xFF)
// dbg_print("1) addr=0x%X returning=0x%X\n", addr, &cpuram[addr]);
return &cpuram[addr];
}
if (addr>0x00003fff && addr<0x00018000)
{
//if((unsigned int)&mainram[addr-0x00004000] >> 24 == 0xFF)
// dbg_print("2) addr=0x%X returning=0x%X\n", addr, &mainram[addr-0x00004000]);
switch (addr) //Thanks Koyote
{
case 0x6F80:
mainram[addr-0x00004000] = 0xFF;
break;
case 0x6F80+1:
mainram[addr-0x00004000] = 0x03;
break;
case 0x6F85:
mainram[addr-0x00004000] = 0x00;
break;
case 0x6F82:
mainram[addr-0x00004000] = ngpInputState;
break;
case 0x6DA2:
mainram[addr-0x00004000] = 0x80;
break;
}
return &mainram[addr-0x00004000];
}
}
else
{
if (addr<0x00400000)
{
return &mainrom[(addr-0x00200000)/*&cartAddrMask*/];
}
if(addr<0x00800000) //Flavor added
{
return 0;
}
if (addr<0x00A00000)
{
return &mainrom[(addr-(0x00800000-0x00200000))/*&cartAddrMask*/];
}
if(addr<0x00FF0000) //Flavor added
{
return 0;
}
//if((unsigned int)&cpurom[addr-0x00ff0000] >> 24 == 0xFF)
// dbg_print("5) addr=0x%X returning=0x%X\n", addr, &cpurom[addr-0x00ff0000]);
return &cpurom[addr-0x00ff0000];
}
//dbg_print("6) addr=0x%X returning=0\n", addr);
return 0; //Flavor ERROR
addr&= 0x00FFFFFF;
if (addr<0x00200000)
{
if (addr<0x000008a0)
{
//if(((unsigned int)&cpuram[addr] >> 24) == 0xFF)
// dbg_print("1) addr=0x%X returning=0x%X\n", addr, &cpuram[addr]);
return &cpuram[addr];
}
if (addr>0x00003fff && addr<0x00018000)
{
//if((unsigned int)&mainram[addr-0x00004000] >> 24 == 0xFF)
// dbg_print("2) addr=0x%X returning=0x%X\n", addr, &mainram[addr-0x00004000]);
switch (addr) //Thanks Koyote
{
case 0x6F80:
mainram[addr-0x00004000] = 0xFF;
break;
case 0x6F80+1:
mainram[addr-0x00004000] = 0x03;
break;
case 0x6F85:
mainram[addr-0x00004000] = 0x00;
break;
case 0x6F82:
mainram[addr-0x00004000] = ngpInputState;
break;
case 0x6DA2:
mainram[addr-0x00004000] = 0x80;
break;
}
return &mainram[addr-0x00004000];
}
}
else
{
if (addr<0x00400000)
{
return &mainrom[(addr-0x00200000)/*&cartAddrMask*/];
}
if(addr<0x00800000) //Flavor added
{
return 0;
}
if (addr<0x00A00000)
{
return &mainrom[(addr-(0x00800000-0x00200000))/*&cartAddrMask*/];
}
if(addr<0x00FF0000) //Flavor added
{
return 0;
}
//if((unsigned int)&cpurom[addr-0x00ff0000] >> 24 == 0xFF)
// dbg_print("5) addr=0x%X returning=0x%X\n", addr, &cpurom[addr-0x00ff0000]);
return &cpurom[addr-0x00ff0000];
}
//dbg_print("6) addr=0x%X returning=0\n", addr);
return 0; //Flavor ERROR
}
/*inline unsigned char *get_addressW(unsigned int addr)
{
addr&= 0x00FFFFFF;
if (addr<0x00200000)
{
if (addr<0x000008a0)
{
return &cpuram[addr];
}
if (addr>0x00003fff && addr<0x00018000)
return &mainram[addr-0x00004000];
return NULL;
}
else
{
return NULL;
}
return NULL; //Flavor ERROR
}*/
// read a byte from a memory address (addr)
inline unsigned char tlcsMemReadB(unsigned int addr)
/* read a byte from a memory address (addr) */
static inline unsigned char tlcsMemReadB(unsigned int addr)
{
addr&= 0x00FFFFFF;
......@@ -298,8 +275,8 @@ inline unsigned char tlcsMemReadB(unsigned int addr)
return 0xFF;
}
// read a word from a memory address (addr)
inline unsigned short tlcsMemReadW(unsigned int addr)
/* read a word from a memory address (addr) */
static inline unsigned short tlcsMemReadW(unsigned int addr)
{
#ifdef TARGET_GP2X
register unsigned short i asm("r0");
......@@ -335,9 +312,8 @@ inline unsigned short tlcsMemReadW(unsigned int addr)
#endif
}
// read a long word from a memory address (addr)
inline unsigned int tlcsMemReadL(unsigned int addr)
/* read a long word from a memory address (addr) */
static inline unsigned int tlcsMemReadL(unsigned int addr)
{
#ifdef TARGET_GP2X
register unsigned int i asm("r0");
......@@ -378,8 +354,8 @@ inline unsigned int tlcsMemReadL(unsigned int addr)
#endif
}
// write a byte (data) to a memory address (addr)
inline void tlcsMemWriteB(unsigned int addr, unsigned char data)
/* write a byte (data) to a memory address (addr) */
static inline void tlcsMemWriteB(unsigned int addr, unsigned char data)
{
addr&= 0x00FFFFFF;
if (addr<0x000008a0)
......@@ -454,8 +430,4 @@ inline void tlcsMemWriteB(unsigned int addr, unsigned char data)
}
#endif // _MEMORYH_
// Flavor modified sound.c and sound.h from NEOPOP
// which was originally based on sn76496.c from MAME
// some ideas also taken from NeoPop-SDL code
//---------------------------------------------------------------------------
// Originally from
// NEOPOP : Emulator as in Dreamland
//
// Copyright (c) 2001-2002 by neopop_uk
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// 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. See also the license.txt file for
// additional informations.
//---------------------------------------------------------------------------
/* Flavor modified sound.c and sound.h from NEOPOP
* which was originally based on sn76496.c from MAME
* some ideas also taken from NeoPop-SDL code
*---------------------------------------------------------------------------
* Originally from
* NEOPOP : Emulator as in Dreamland
*
* Copyright (c) 2001-2002 by neopop_uk
*---------------------------------------------------------------------------
*---------------------------------------------------------------------------
* 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. See also the license.txt file for
* additional informations.
*---------------------------------------------------------------------------
*/
/************************************************************************
......@@ -33,37 +34,36 @@
#include "main.h"
#include "memory.h"
//#include "menu.h"
//=============================================================================
/* ============================================================================= */
SoundChip toneChip;
SoundChip noiseChip;
//==== DAC
/* ==== DAC */
#ifdef TARGET_WIN
#define DAC_BUFFERSIZE (2560 * 1024) //at (256 * 1024) the PC version will crash on MS2 intro
#define DAC_BUFFERSIZE (2560 * 1024) /* at (256 * 1024) the PC version will crash on MS2 intro */
#else
#define DAC_BUFFERSIZE (256 * 1024) //at (256 * 1024) the PC version will crash on MS2 intro
#define DAC_BUFFERSIZE (256 * 1024) /* at (256 * 1024) the PC version will crash on MS2 intro */
#endif
int dacLBufferRead, dacLBufferWrite, dacLBufferCount;
_u16 dacBufferL[DAC_BUFFERSIZE];
int fixsoundmahjong;
//=============================================================================
/* ============================================================================= */
#define SOUNDCHIPCLOCK (3072000) //Unverified / sounds correct
#define SOUNDCHIPCLOCK (3072000) /* Unverified / sounds correct */
#define MAX_OUTPUT 0x7fff
#define STEP 0x10000 //Fixed point adjuster
#define STEP 0x10000 /* Fixed point adjuster */
#define MAX_OUTPUT_STEP 0x7fff0000
#define STEP_SHIFT 16
static _u32 VolTable[16];
static _u32 UpdateStep = 0; //Number of steps during one sample.
static _u32 UpdateStep = 0; /* Number of steps during one sample. */
/* Formulas for noise generator */
/* bit0 = output */
......@@ -80,7 +80,7 @@ static _u32 UpdateStep = 0; //Number of steps during one sample.
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
//=============================================================================
/* ============================================================================= */
static _u16 sample_chip_tone(void)
{
......@@ -150,183 +150,186 @@ static _u16 sample_chip_tone(void)
out = vol[0] * toneChip.Volume[0] + vol[1] * toneChip.Volume[1] +
vol[2] * toneChip.Volume[2];
//if (out > MAX_OUTPUT * STEP) out = MAX_OUTPUT * STEP;
if (out > MAX_OUTPUT_STEP) out = MAX_OUTPUT_STEP;
if (out > MAX_OUTPUT_STEP)
out = MAX_OUTPUT_STEP;
return out>>STEP_SHIFT;//out / STEP;
return out>>STEP_SHIFT;
}
//=============================================================================
/* ============================================================================= */
static _u16 sample_chip_noise(void)
{
int i;
int i;
//int vol[4];
int vol3 = 0;
unsigned int out;
int left;
int vol3 = 0;
unsigned int out;
int left;
/* vol[] keeps track of how long each square wave stays */
/* in the 1 position during the sample period. */
/*
vol[0] = vol[1] = vol[2] = vol[3] = 0;
for (i = 0; i < 3; i++)
{
if (noiseChip.Output[i]) vol[i] += noiseChip.Count[i];
noiseChip.Count[i] -= STEP;
// Period[i] is the half period of the square wave. Here, in each
// loop I add Period[i] twice, so that at the end of the loop the
// square wave is in the same status (0 or 1) it was at the start.
// vol[i] is also incremented by Period[i], since the wave has been 1
// exactly half of the time, regardless of the initial position.
// If we exit the loop in the middle, Output[i] has to be inverted
// and vol[i] incremented only if the exit status of the square
// wave is 1.
while (noiseChip.Count[i] <= 0)
{
noiseChip.Count[i] += noiseChip.Period[i];
if (noiseChip.Count[i] > 0)
{
noiseChip.Output[i] ^= 1;
if (noiseChip.Output[i]) vol[i] += noiseChip.Period[i];
break;
}
noiseChip.Count[i] += noiseChip.Period[i];
vol[i] += noiseChip.Period[i];
}
if (noiseChip.Output[i]) vol[i] -= noiseChip.Count[i];
}
*/
if (noiseChip.Volume[3])
{
left = STEP;
do
{
int nextevent = min(noiseChip.Count[3],left);
//if (noiseChip.Count[3] < left) nextevent = noiseChip.Count[3];
//else nextevent = left;
/* vol[] keeps track of how long each square wave stays */
/* in the 1 position during the sample period. */
/*
vol[0] = vol[1] = vol[2] = vol[3] = 0;
for (i = 0; i < 3; i++)
{
if (noiseChip.Output[i]) vol[i] += noiseChip.Count[i];
noiseChip.Count[i] -= STEP;
// Period[i] is the half period of the square wave. Here, in each
// loop I add Period[i] twice, so that at the end of the loop the
// square wave is in the same status (0 or 1) it was at the start.
// vol[i] is also incremented by Period[i], since the wave has been 1
// exactly half of the time, regardless of the initial position.
// If we exit the loop in the middle, Output[i] has to be inverted
// and vol[i] incremented only if the exit status of the square
// wave is 1.
while (noiseChip.Count[i] <= 0)
{
noiseChip.Count[i] += noiseChip.Period[i];
if (noiseChip.Count[i] > 0)
{
noiseChip.Output[i] ^= 1;
if (noiseChip.Output[i]) vol[i] += noiseChip.Period[i];
break;
}
noiseChip.Count[i] += noiseChip.Period[i];
vol[i] += noiseChip.Period[i];
}
if (noiseChip.Output[i]) vol[i] -= noiseChip.Count[i];
}
*/
if (noiseChip.Volume[3])
{
left = STEP;
do
{
int nextevent = min(noiseChip.Count[3],left);
if (noiseChip.Output[3]) vol3 += noiseChip.Count[3];
noiseChip.Count[3] -= nextevent;
if (noiseChip.Count[3] <= 0)
{
if (noiseChip.RNG & 1) noiseChip.RNG ^= noiseChip.NoiseFB;
noiseChip.RNG >>= 1;
noiseChip.Output[3] = noiseChip.RNG & 1;
noiseChip.Count[3] += noiseChip.Period[3];
if (noiseChip.Output[3]) vol3 += noiseChip.Period[3];
}
if (noiseChip.Output[3]) vol3 -= noiseChip.Count[3];
#if 0
if (noiseChip.Count[3] < left)
nextevent = noiseChip.Count[3];
else
nextevent = left;
#endif
left -= nextevent;
} while (left > 0);
}
out = vol3 * noiseChip.Volume[3];
if (noiseChip.Output[3]) vol3 += noiseChip.Count[3];
noiseChip.Count[3] -= nextevent;
if (noiseChip.Count[3] <= 0)
{
if (noiseChip.RNG & 1) noiseChip.RNG ^= noiseChip.NoiseFB;
noiseChip.RNG >>= 1;
noiseChip.Output[3] = noiseChip.RNG & 1;
noiseChip.Count[3] += noiseChip.Period[3];
if (noiseChip.Output[3]) vol3 += noiseChip.Period[3];
}
if (noiseChip.Output[3]) vol3 -= noiseChip.Count[3];
left -= nextevent;
} while (left > 0);
}
out = vol3 * noiseChip.Volume[3];
//if (out > MAX_OUTPUT * STEP) out = MAX_OUTPUT * STEP;
if (out > MAX_OUTPUT_STEP) out = MAX_OUTPUT_STEP;
if (out > MAX_OUTPUT_STEP)
out = MAX_OUTPUT_STEP;
return out>>STEP_SHIFT;//out / STEP;
return out>>STEP_SHIFT;
}
//=============================================================================
/* ============================================================================= */
void sound_update(_u16* chip_buffer, int length_bytes)
{
length_bytes >>= 1;//turn it into words
while (length_bytes)
{
//Mix a mono track out of: (Tone + Noise) >> 1