Solved const-correctness issues
This commit is contained in:
parent
f3df02b0d0
commit
08ca71f289
|
@ -664,9 +664,9 @@ typedef struct
|
|||
/** Height of image in framebuffer */
|
||||
int h;
|
||||
/** Pointer to CLUT data */
|
||||
void *clut_data;
|
||||
const void *clut_data;
|
||||
/** Pointer to image data */
|
||||
void *data;
|
||||
const void *data;
|
||||
}GsImage;
|
||||
|
||||
/**
|
||||
|
@ -796,7 +796,7 @@ void MoveImage(int src_x, int src_y, int dst_x, int dst_y, int w, int h);
|
|||
* @param h Height of image data
|
||||
*/
|
||||
|
||||
void LoadImage(void *img, int x, int y, int w, int h);
|
||||
void LoadImage(const void *img, int x, int y, int w, int h);
|
||||
|
||||
/**
|
||||
* Draws a rectangle in the framebuffer, without considering drawing
|
||||
|
@ -859,7 +859,7 @@ void gpu_data_ctrl(unsigned int command, unsigned int param);
|
|||
* Puts information about a TIM image passed in a buffer in a GsImage structure.
|
||||
*/
|
||||
|
||||
int GsImageFromTim(GsImage *image, void *timdata);
|
||||
int GsImageFromTim(GsImage *image, const void *timdata);
|
||||
|
||||
/**
|
||||
* Uploads an image described by a GsImage structure to video memory.
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
/** Start address of sound data in Sound RAM */
|
||||
#define SPU_DATA_BASE_ADDR 0x1010
|
||||
/** Maximum volume. */
|
||||
#define SPU_MAXVOL 0x3FFF
|
||||
#define SPU_MAXVOL 0x3FFF
|
||||
|
||||
/** VAG file */
|
||||
|
||||
|
@ -45,7 +45,7 @@ typedef struct
|
|||
/** Name */
|
||||
unsigned char name[16];
|
||||
/** Pointer to sound data */
|
||||
void *data;
|
||||
const void *data;
|
||||
/** Address in Sound RAM where the sound data was uploaded */
|
||||
unsigned int spu_addr;
|
||||
/** [Runtime] Voice this VAG is currently being played on */
|
||||
|
@ -113,7 +113,7 @@ void SsKeyOff(int voice);
|
|||
* Set the voices specified by the bitmask to 'on'. Like SsKeyOn()
|
||||
* @param mask Bitmask
|
||||
*/
|
||||
|
||||
|
||||
void SsKeyOnMask(int mask);
|
||||
|
||||
/**
|
||||
|
@ -142,7 +142,7 @@ void SsInit(void);
|
|||
* @param spu_addr Destination address in Sound RAM (multiplier of 8).
|
||||
*/
|
||||
|
||||
void SsUpload(void *addr, int size, int spu_addr);
|
||||
void SsUpload(const void *addr, int size, int spu_addr);
|
||||
|
||||
/**
|
||||
* Converts a sampling rate in hertz to PlayStation pitch rate used by the SPU.
|
||||
|
@ -158,7 +158,7 @@ unsigned short SsFreqToPitch(int hz);
|
|||
* @param data Pointer to VAG file data
|
||||
*/
|
||||
|
||||
int SsReadVag(SsVag *vag, void *data);
|
||||
int SsReadVag(SsVag *vag, const void *data);
|
||||
|
||||
/**
|
||||
* Uploads the sound data specified by a SsVag structure to the specified address in Sound RAM.
|
||||
|
@ -186,7 +186,7 @@ void SsUploadVag(SsVag *vag);
|
|||
* @param vr Right channel volume
|
||||
*/
|
||||
|
||||
void SsPlayVag(SsVag *vag, unsigned char voice, unsigned short vl,
|
||||
void SsPlayVag(SsVag *vag, unsigned char voice, unsigned short vl,
|
||||
unsigned short vr);
|
||||
|
||||
/**
|
||||
|
@ -205,13 +205,13 @@ void SsResetVagAddr(void);
|
|||
/**
|
||||
* Enable CD Audio.
|
||||
*/
|
||||
|
||||
|
||||
void SsEnableCd(void);
|
||||
|
||||
/**
|
||||
* Enable External audio. (???)
|
||||
*/
|
||||
|
||||
|
||||
void SsEnableExt(void);
|
||||
|
||||
/**
|
||||
|
@ -220,6 +220,6 @@ void SsEnableExt(void);
|
|||
* @param right Right channel volume
|
||||
*/
|
||||
|
||||
void SsCdVol(unsigned short left, unsigned short right);
|
||||
void SsCdVol(unsigned short left, unsigned short right);
|
||||
|
||||
#endif
|
||||
|
|
426
libpsx/src/gpu.c
426
libpsx/src/gpu.c
File diff suppressed because it is too large
Load Diff
|
@ -22,17 +22,17 @@ void SsVoiceVol(int voice, unsigned short left, unsigned short right)
|
|||
void SsVoicePitch(int voice, unsigned short pitch)
|
||||
{
|
||||
unsigned short *a = (unsigned short*)SPU_VOICE_BASE_ADDR(voice);
|
||||
|
||||
|
||||
a[2] = pitch;
|
||||
}
|
||||
|
||||
void SsVoiceStartAddr(int voice, unsigned int addr)
|
||||
{
|
||||
// address given is real address, then it is divided by eight when written to the register
|
||||
// address given is real address, then it is divided by eight when written to the register
|
||||
// example: SSVoiceStartAddr(0, 0x1008) , writes 0x201 on the register which means 0x1008
|
||||
|
||||
|
||||
unsigned short *a = (unsigned short*)SPU_VOICE_BASE_ADDR(voice);
|
||||
|
||||
|
||||
a[3] = (addr >> 3);
|
||||
}
|
||||
|
||||
|
@ -50,17 +50,17 @@ void SsVoiceRepeatAddr(int voice, unsigned int addr)
|
|||
// the explanation for SSVoiceStartAddr() is valid for this function as well
|
||||
|
||||
unsigned short *a = (unsigned short*)SPU_VOICE_BASE_ADDR(voice);
|
||||
|
||||
|
||||
a[7] = (addr >> 3);
|
||||
}
|
||||
|
||||
void SsKeyOn(int voice)
|
||||
{
|
||||
unsigned int i = 1 << voice;
|
||||
|
||||
|
||||
SPU_KEY_ON1 = i & 0xffff;
|
||||
SPU_KEY_ON2 = i >> 16;
|
||||
|
||||
|
||||
/* while(SPU_KEY_ON1 != (i & 0xffff));
|
||||
while(SPU_KEY_ON2 != (i >> 16));
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ void SsKeyOn(int voice)
|
|||
void SsKeyOff(int voice)
|
||||
{
|
||||
unsigned int i = 1 << voice;
|
||||
|
||||
|
||||
SPU_KEY_OFF1 = i & 0xffff;
|
||||
SPU_KEY_OFF2 = i >> 16;
|
||||
}
|
||||
|
@ -98,11 +98,11 @@ void SsInit()
|
|||
int x;
|
||||
|
||||
printf("Initializing SPU (Sound Synthesizer)...\n");
|
||||
|
||||
|
||||
DPCR |= 0xB0000;
|
||||
|
||||
|
||||
SPU_MVOL_L = 0x3fff;
|
||||
SPU_MVOL_R = 0x3fff;
|
||||
SPU_MVOL_R = 0x3fff;
|
||||
|
||||
SPU_CONTROL = 0x0;
|
||||
SsWait();
|
||||
|
@ -110,7 +110,7 @@ void SsInit()
|
|||
SPU_STATUS = 0x4; // Must be done, but not totally understood
|
||||
|
||||
while(SPU_STATUS2 & 0x7ff);
|
||||
|
||||
|
||||
SPU_REVERB_L = 0x0;
|
||||
SPU_REVERB_R = 0x0;
|
||||
|
||||
|
@ -136,10 +136,10 @@ void SsInit()
|
|||
SPU_EXT_VOL_R = 0x0;
|
||||
|
||||
// set volume of all voices to 0 and adsr to 0,0
|
||||
|
||||
|
||||
for(x = 0; x < 24; x++)
|
||||
{
|
||||
SsVoiceVol(x, 0, 0);
|
||||
SsVoiceVol(x, 0, 0);
|
||||
SsVoiceADSRRaw(x, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -149,40 +149,40 @@ void SsInit()
|
|||
SPU_REVERB_WORK_ADDR = 0xFFFE; // Reverb work address in SPU memory, 0x1fff * 8 = 0xFFF8
|
||||
|
||||
ss_vag_addr = SPU_DATA_BASE_ADDR;
|
||||
|
||||
|
||||
printf("SPU/SS Initialized.\n");
|
||||
}
|
||||
|
||||
// This implementation of SsUpload() was contributed by Shendo
|
||||
// This implementation of SsUpload() was contributed by Shendo
|
||||
// It waits either for a period of time or for the status flags to be raised, whichever comes first.
|
||||
// This makes it work also on ePSXe, which never raises the status flags.
|
||||
|
||||
void SsUpload(void *addr, int size, int spu_addr)
|
||||
void SsUpload(const void *addr, int size, int spu_addr)
|
||||
{
|
||||
unsigned short *ptr = addr;
|
||||
const unsigned short *ptr = addr;
|
||||
int i;
|
||||
|
||||
|
||||
while(size > 0)
|
||||
{
|
||||
{
|
||||
SPU_STATUS = 4; // Sound RAM Data Transfer Control
|
||||
SPU_CONTROL = SPU_CONTROL & ~0x30; // SPUCNT.transfer_mode = 0 (STOP)
|
||||
|
||||
|
||||
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
if(((SPU_STATUS2 >> 4) & 3) == 0)break; // wait until SPUSTAT.transfer is 0 (STOP)
|
||||
|
||||
|
||||
SPU_ADDR = spu_addr >> 3;
|
||||
|
||||
for(i = 0; i < 32; i++)
|
||||
SPU_DATA = ptr[i];
|
||||
|
||||
|
||||
SPU_CONTROL = (SPU_CONTROL & ~0x30) | 16; // SPUCNT.transfer_mode = 1 (MANUAL)
|
||||
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
if(((SPU_STATUS2 >> 4) & 3) == 1)break; // wait until SPUSTAT.transfer is 1 (MANUAL)
|
||||
|
||||
|
||||
while(SPU_STATUS2 & 0x400); // wait for transfer busy bit to be cleared
|
||||
|
||||
|
||||
spu_addr += 64;
|
||||
ptr += 32;
|
||||
size-=64;
|
||||
|
@ -194,24 +194,24 @@ unsigned short SsFreqToPitch(int hz)
|
|||
// Converts a normal samples per second frequency value in Hz
|
||||
// in a pitch value
|
||||
|
||||
// i.e. 44100 -> 0x1000, 22050 -> 0x800
|
||||
|
||||
// i.e. 44100 -> 0x1000, 22050 -> 0x800
|
||||
|
||||
return (hz << 12) / 44100;
|
||||
}
|
||||
|
||||
int SsReadVag(SsVag *vag, void *data)
|
||||
int SsReadVag(SsVag *vag, const void *data)
|
||||
{
|
||||
unsigned char *i = data;
|
||||
|
||||
const unsigned char *i = data;
|
||||
|
||||
if(strncmp(data, "VAGp", 4) != 0)
|
||||
return 0;
|
||||
|
||||
|
||||
vag->version = (i[4]<<24)|(i[5]<<16)|(i[6]<<8)|i[7];
|
||||
vag->data_size = (i[12]<<24)|(i[13]<<16)|(i[14]<<8)|i[15];
|
||||
vag->sample_rate = (i[16]<<24)|(i[17]<<16)|(i[18]<<8)|i[19];
|
||||
memcpy(vag->name, &i[32], 16);
|
||||
vag->data = &i[48];
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -229,14 +229,14 @@ void SsUploadVag(SsVag *vag)
|
|||
ss_vag_addr += vag->data_size;
|
||||
}
|
||||
|
||||
void SsPlayVag(SsVag *vag, unsigned char voice, unsigned short vl,
|
||||
void SsPlayVag(SsVag *vag, unsigned char voice, unsigned short vl,
|
||||
unsigned short vr)
|
||||
{
|
||||
SsVoicePitch(voice, SsFreqToPitch(vag->sample_rate));
|
||||
SsVoiceStartAddr(voice, vag->spu_addr);
|
||||
SsVoiceVol(voice, vl, vr);
|
||||
SsKeyOn(voice);
|
||||
|
||||
|
||||
vag->cur_voice = voice;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue