Skip to content

Commit 745a66a

Browse files
committed
Always assume there's a first controller.
Fixed copying name from ROM header. Adjusted for libogc-rice changes. Synchronized changes from Swiss.
1 parent 487a0d3 commit 745a66a

6 files changed

Lines changed: 352 additions & 312 deletions

File tree

gc_audio/audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ EXPORT void CALL AiLenChanged(void)
104104
}
105105

106106
if (scalePitch || Timers.vis > VILimit)
107-
AESND_SetVoiceFrequency(voice, freq * (Timers.vis / VILimit));
107+
AESND_SetVoiceFrequencyRatio(voice, (Timers.vis * freq) / (VILimit * DSP_DEFAULT_FREQ));
108108

109109
IRQ_Restore(level);
110110
}

gc_input/input.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,21 @@ void auto_assign_controllers(void){
424424

425425
// 'Initialize' the unmapped virtual controllers
426426
for(; i<4; ++i){
427-
unassign_controller(i);
428-
padType[i] = PADTYPE_NONE;
429-
padAssign[i] = i;
427+
if(i == 0){
428+
#ifdef HW_RVL
429+
assign_controller(i, &controller_Wiimote, i);
430+
padType[i] = PADTYPE_WII;
431+
padAssign[i] = i;
432+
#else
433+
assign_controller(i, &controller_GC, i);
434+
padType[i] = PADTYPE_GAMECUBE;
435+
padAssign[i] = i;
436+
#endif
437+
} else {
438+
unassign_controller(i);
439+
padType[i] = PADTYPE_NONE;
440+
padAssign[i] = i;
441+
}
430442
}
431443
}
432444

glN64_GX/gSP.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void gSPProcessVertex( u32 v )
181181
#ifndef __GX__
182182
Normalize( &gSP.vertices[v].nx );
183183
#else //!__GX__
184-
guVecNormalize((guVector*) &gSP.vertices[v].nx );
184+
guVecNormalize((guVector*) &gSP.vertices[v].nx,(guVector*) &gSP.vertices[v].nx );
185185
#endif //__GX__
186186

187187
r = gSP.lights[gSP.numLights].r;
@@ -219,7 +219,7 @@ void gSPProcessVertex( u32 v )
219219
#ifndef __GX__
220220
Normalize( &gSP.vertices[v].nx );
221221
#else //!__GX__
222-
guVecNormalize((guVector*) &gSP.vertices[v].nx );
222+
guVecNormalize((guVector*) &gSP.vertices[v].nx,(guVector*) &gSP.vertices[v].nx );
223223
#endif //__GX__
224224

225225
if (gSP.geometryMode & G_TEXTURE_GEN_LINEAR)
@@ -482,7 +482,7 @@ void gSPLight( u32 l, s32 n )
482482
#ifndef __GX__
483483
Normalize( &gSP.lights[n].x );
484484
#else //!__GX__
485-
guVecNormalize((guVector*) &gSP.lights[n].x );
485+
guVecNormalize((guVector*) &gSP.lights[n].x,(guVector*) &gSP.lights[n].x );
486486
#endif //__GX__
487487
}
488488

main/ata.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#define IDE_EXI_V1 0
1919
#define IDE_EXI_V2 1
20+
#define IDE_EXI_V3 2
2021

2122
u16 buffer[256] ATTRIBUTE_ALIGN (32);
2223
static int __ata_init[3] = {0,0,0};
@@ -153,7 +154,7 @@ static inline void ata_read_buffer(int chn, u32 *dst)
153154
}
154155
else {
155156
// IDE_EXI_V2, no need to select / deselect all the time
156-
EXI_ImmEx(chn,dst,512,EXI_READ);
157+
EXI_DmaEx(chn,dst,512,EXI_READ);
157158
EXI_Deselect(chn);
158159
EXI_Unlock(chn);
159160
}
@@ -172,7 +173,7 @@ static inline void ata_write_buffer(int chn, u32 *src)
172173
EXI_Lock(chn, dev, NULL);
173174
EXI_Select(chn,dev,EXI_SPEED32MHZ);
174175
EXI_ImmEx(chn,&dat,3,EXI_WRITE);
175-
EXI_ImmEx(chn, src,512,EXI_WRITE);
176+
EXI_DmaEx(chn, src,512,EXI_WRITE);
176177
dat = 0;
177178
EXI_ImmEx(chn,&dat,1,EXI_WRITE); // Burn an extra cycle for the IDE-EXI to know to stop serving data
178179
EXI_Deselect(chn);
@@ -187,8 +188,8 @@ int _ideExiVersion(int chn) {
187188
}
188189
u32 cid = 0;
189190
EXI_GetID(chn,dev,&cid);
190-
if(cid==0x49444532) {
191-
return IDE_EXI_V2;
191+
if((cid&~0xff)==0x49444500) {
192+
return (cid&0xff)-'1';
192193
}
193194
else {
194195
return IDE_EXI_V1;
@@ -204,7 +205,7 @@ u32 _ataDriveIdentify(int chn) {
204205

205206
memset(&ataDriveInfo, 0, sizeof(typeDriveInfo));
206207

207-
// Get the ID to see if it's a V2
208+
// Get the ID to see if it's a V2+
208209
_ideexi_version = _ideExiVersion(chn);
209210
if(_ideexi_version == IDE_EXI_V1 && chn == EXI_CHANNEL_2) {
210211
return -1;
@@ -433,9 +434,14 @@ int _ataWriteSector(int chn, u64 lba, u32 *Buffer)
433434
while(!(ataReadStatusReg(chn) & ATA_SR_DRQ));
434435

435436
// Write data to the drive
436-
u16 *ptr = (u16*)Buffer;
437-
for (i=0; i<256; i++) {
438-
ataWriteu16(chn, ptr[i]);
437+
if(_ideexi_version < IDE_EXI_V3) {
438+
u16 *ptr = (u16*)Buffer;
439+
for (i=0; i<256; i++) {
440+
ataWriteu16(chn, ptr[i]);
441+
}
442+
}
443+
else {
444+
ata_write_buffer(chn, Buffer);
439445
}
440446

441447
// Wait for the write to finish

main/rom_gc.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ bool isEEPROM16k()
135135
/* Loads the ROM into the ROM cache */
136136
int rom_read(fileBrowser_file* file){
137137

138-
char buffer[1024];
139138
int i;
140139

141140
ROMCache_init(file);
@@ -147,14 +146,13 @@ int rom_read(fileBrowser_file* file){
147146
ROMCache_read(&ROM_HEADER, 0, sizeof(rom_header));
148147

149148
//Copy header name as Goodname (in the .ini we can use CRC to identify ROMS)
150-
memset((char*)buffer,0,1024);
151-
strncpy(buffer, (char*)ROM_HEADER.Name,32);
152-
//Maximum ROM name is 32 bytes. Lets make sure we cut off trailing spaces
153-
for(i = strlen(buffer); i>0; i--)
149+
memcpy(ROM_SETTINGS.goodname, ROM_HEADER.Name, 20);
150+
ROM_SETTINGS.goodname[20] = '\0';
151+
//Maximum ROM name is 20 bytes. Lets make sure we cut off trailing spaces
152+
for(i = strlen(ROM_SETTINGS.goodname); i>0; i--)
154153
{
155-
if(buffer[i-1] != ' ') {
156-
strncpy(&ROM_SETTINGS.goodname[0],&buffer[0],i);
157-
ROM_SETTINGS.goodname[i] = 0; //terminate it too
154+
if(ROM_SETTINGS.goodname[i-1] != ' ') {
155+
ROM_SETTINGS.goodname[i] = '\0';
158156
break;
159157
}
160158
}

0 commit comments

Comments
 (0)