Skip to content

Commit b8b56e3

Browse files
committed
Remove dead code not used by libretro
1 parent 684e7ea commit b8b56e3

21 files changed

+110
-536
lines changed

source/CommandLine.c

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ void CommandLineInit(void)
3030
// Default strings
3131
strcpy(CommandLine.bios_file, "bios.min");
3232
strcpy(CommandLine.eeprom_file, "PokeMini.eep");
33-
strcpy(CommandLine.joyplatform, "default");
3433

3534
// Default booleans / integers
3635
CommandLine.forcefreebios = 0; // Force FreeBIOS

source/CommandLine.h

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#ifndef COMMAND_LINE
2020
#define COMMAND_LINE
2121

22-
#include <stdio.h>
2322
#include <stdint.h>
2423

2524
typedef struct {
@@ -35,7 +34,6 @@ typedef struct {
3534
int low_battery;
3635
int palette;
3736
int rumblelvl;
38-
char joyplatform[32];
3937
int joybutton[10];
4038
int multicart;
4139
int synccycles;

source/Endianess.h

-55
This file was deleted.

source/Hardware.c

-25
Original file line numberDiff line numberDiff line change
@@ -237,34 +237,9 @@ void MinxCPU_OnWrite(int cpu, uint32_t addr, uint8_t data)
237237
PM_RAM[addr-0x1000] = data;
238238
if (PRCColorMap) MinxColorPRC_WriteFramebuffer(addr-0x1000, data);
239239
return;
240-
} else {
241-
// BIOS Write (Ignored)
242-
return;
243240
}
244241
}
245242

246-
void MinxCPU_OnException(int type, uint32_t ir)
247-
{
248-
#ifdef DEBUG
249-
switch (type) {
250-
case EXCEPTION_UNKNOWN_INSTRUCTION:
251-
log_cb(RETRO_LOG_ERROR, "Unknown instruction %08X before V=%02X,PC=%04X\n", (unsigned int)ir, (int)MinxCPU.PC.B.I, (int)MinxCPU.PC.W.L);
252-
return;
253-
case EXCEPTION_CRASH_INSTRUCTION:
254-
log_cb(RETRO_LOG_ERROR, "Crash instruction %08X before V=%02X,PC=%04X\n", (unsigned int)ir, (int)MinxCPU.PC.B.I, (int)MinxCPU.PC.W.L);
255-
return;
256-
case EXCEPTION_UNSTABLE_INSTRUCTION:
257-
log_cb(RETRO_LOG_ERROR, "Unstable instruction %08X before V=%02X,PC=%04X\n", (unsigned int)ir, (int)MinxCPU.PC.B.I, (int)MinxCPU.PC.W.L);
258-
return;
259-
case EXCEPTION_DIVISION_BY_ZERO:
260-
log_cb(RETRO_LOG_ERROR, "Division by zero before V=%02X,PC=%04X\n", (int)MinxCPU.PC.B.I, (int)MinxCPU.PC.W.L);
261-
return;
262-
default:
263-
return;
264-
}
265-
#endif
266-
}
267-
268243
void MinxCPU_OnIRQHandle(uint8_t cpuflag, uint8_t shift_u)
269244
{
270245
// Disable or enable master interrupt and check for interrupts

source/Joystick.c

+15-32
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,27 @@
2121

2222
#include "Joystick.h"
2323

24-
static void KeyEvent(int key, int press)
25-
{
26-
if (press)
27-
PokeMini_KeypadEvent(key, 1);
28-
else
29-
PokeMini_KeypadEvent(key, 0);
30-
}
31-
32-
// Process joystick buttons packed in bits
33-
void JoystickBitsEvent(uint32_t pressbits)
24+
// Process joystick buttons
25+
void JoystickButtonsEvent(int button, int pressed)
3426
{
35-
static uint32_t lastpressbits;
36-
uint32_t togglebits = pressbits ^ lastpressbits;
3727
int index;
3828

39-
for (index=0; index<10; index++) {
40-
int joybutton = CommandLine.joybutton[index];
41-
if (joybutton >= 0) {
42-
uint32_t maskbit = (1 << joybutton);
43-
if (togglebits & maskbit) {
29+
if (pressed)
30+
{
31+
for (index=0; index<10; index++) {
32+
if (CommandLine.joybutton[index] == button) {
4433
if (index)
45-
KeyEvent(index, (pressbits & maskbit) ? 1 : 0);
34+
MinxIO_Keypad(index, 1);
4635
}
4736
}
48-
}
49-
50-
lastpressbits = pressbits;
51-
}
52-
53-
// Process joystick buttons
54-
void JoystickButtonsEvent(int button, int pressed)
55-
{
56-
int index;
57-
58-
for (index=0; index<10; index++) {
59-
if (CommandLine.joybutton[index] == button) {
60-
if (index)
61-
KeyEvent(index, pressed);
37+
}
38+
else
39+
{
40+
for (index=0; index<10; index++) {
41+
if (CommandLine.joybutton[index] == button) {
42+
if (index)
43+
MinxIO_Keypad(index, 0);
44+
}
6245
}
6346
}
6447
}

source/Joystick.h

-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#ifndef POKEMINI_JOYSTICK
2020
#define POKEMINI_JOYSTICK
2121

22-
// Process joystick buttons packed in bits
23-
void JoystickBitsEvent(uint32_t pressbits);
24-
2522
// Process joystick buttons
2623
void JoystickButtonsEvent(int button, int pressed);
2724

source/MinxAudio.c

+22-71
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,38 @@ int MinxAudio_SaveStateStream(memstream_t *stream)
151151
POKESAVESS_END(32);
152152
}
153153

154+
static int16_t MinxAudio_AudioProcessDirectPWM(void)
155+
{
156+
uint32_t Pwm = 0;
157+
uint16_t TmrCnt = (MinxTimers.Tmr3CntA >> 24) | ((MinxTimers.Tmr3CntB >> 24) << 8);
158+
uint16_t TmrPre = (MinxTimers.Tmr3PreA >> 24) | ((MinxTimers.Tmr3PreB >> 24) << 8);
159+
160+
// Affect sound based of PWM
161+
if (TmrPre)
162+
Pwm = MinxTimers.Timer3Piv * MINX_AUDIO_PWM_RAG / TmrPre;
163+
if (Pwm > MINX_AUDIO_PWM_RAG)
164+
Pwm = MINX_AUDIO_PWM_RAG-1; // Avoid clipping
165+
if (TmrPre < 128)
166+
TmrCnt = 0; // Avoid high hizz
167+
168+
// Output
169+
if (TmrCnt <= MinxTimers.Timer3Piv)
170+
return MinxAudio.Volume + Pwm * MinxAudio.PWMMul;
171+
return MINX_AUDIO_SILENCE + Pwm * MinxAudio.PWMMul;
172+
}
173+
174+
154175
void MinxAudio_ChangeEngine(int engine)
155176
{
156177
if (PokeMini_Flags & POKEMINI_GENSOUND)
157178
engine = engine ? 1 : 0;
158179
SoundEngine = engine;
159180
switch (engine) {
160-
case MINX_AUDIO_GENERATED:
161-
RequireSoundSync = 0;
162-
MinxAudio_AudioProcess = NULL;
163-
break;
164-
case MINX_AUDIO_DIRECT:
165-
RequireSoundSync = 1;
166-
MinxAudio_AudioProcess = MinxAudio_AudioProcessDirect;
167-
break;
168-
case MINX_AUDIO_EMULATED:
169-
RequireSoundSync = 1;
170-
MinxAudio_AudioProcess = MinxAudio_AudioProcessEmulated;
171-
break;
172181
case MINX_AUDIO_DIRECTPWM:
173182
RequireSoundSync = 1;
174183
MinxAudio_AudioProcess = MinxAudio_AudioProcessDirectPWM;
175184
break;
185+
case MINX_AUDIO_GENERATED:
176186
default:
177187
RequireSoundSync = 0;
178188
MinxAudio_AudioProcess = NULL;
@@ -304,57 +314,6 @@ static void MinxAudio_GetEmulated(int *Sound_Frequency, int *Pulse_Width)
304314
}
305315
}
306316

307-
int16_t MinxAudio_AudioProcessDirect(void)
308-
{
309-
uint16_t TmrCnt = (MinxTimers.Tmr3CntA >> 24) | ((MinxTimers.Tmr3CntB >> 24) << 8);
310-
311-
if (TmrCnt <= MinxTimers.Timer3Piv)
312-
return MinxAudio.Volume;
313-
return MINX_AUDIO_SILENCE;
314-
}
315-
316-
int16_t MinxAudio_AudioProcessEmulated(void)
317-
{
318-
int Sound_Frequency, Pulse_Width;
319-
MinxAudio_GetEmulated(&Sound_Frequency, &Pulse_Width);
320-
// Silence
321-
if (Sound_Frequency < 50)
322-
return MINX_AUDIO_SILENCE;
323-
else if (Sound_Frequency < 20000)
324-
{
325-
// Normal
326-
MinxAudio.AudioSCnt -= Sound_Frequency * MINX_AUDIOCONV;
327-
if ((MinxAudio.AudioSCnt & 0xFFF00000)
328-
>= (Pulse_Width << 20))
329-
return MinxAudio.Volume;
330-
return MINX_AUDIO_SILENCE;
331-
}
332-
// PWM
333-
if (Pulse_Width > 4095)
334-
Pulse_Width = 4095;
335-
return MINX_AUDIO_SILENCE + (Pulse_Width << 2) * MinxAudio.PWMMul;
336-
}
337-
338-
int16_t MinxAudio_AudioProcessDirectPWM(void)
339-
{
340-
uint32_t Pwm = 0;
341-
uint16_t TmrCnt = (MinxTimers.Tmr3CntA >> 24) | ((MinxTimers.Tmr3CntB >> 24) << 8);
342-
uint16_t TmrPre = (MinxTimers.Tmr3PreA >> 24) | ((MinxTimers.Tmr3PreB >> 24) << 8);
343-
344-
// Affect sound based of PWM
345-
if (TmrPre)
346-
Pwm = MinxTimers.Timer3Piv * MINX_AUDIO_PWM_RAG / TmrPre;
347-
if (Pwm > MINX_AUDIO_PWM_RAG)
348-
Pwm = MINX_AUDIO_PWM_RAG-1; // Avoid clipping
349-
if (TmrPre < 128)
350-
TmrCnt = 0; // Avoid high hizz
351-
352-
// Output
353-
if (TmrCnt <= MinxTimers.Timer3Piv)
354-
return MinxAudio.Volume + Pwm * MinxAudio.PWMMul;
355-
return MINX_AUDIO_SILENCE + Pwm * MinxAudio.PWMMul;
356-
}
357-
358317
int16_t MinxAudio_PiezoFilter(int32_t Sample)
359318
{
360319
int32_t HP_pCoeff = 40960;
@@ -502,11 +461,3 @@ void MinxAudio_GetSamplesS16Ch(int16_t *soundout,
502461
}
503462
}
504463
}
505-
506-
int MinxAudio_SyncWithAudio(void)
507-
{
508-
if (!RequireSoundSync)
509-
return 0;
510-
return MinxAudio_iSamplesInBuffer() >= MinxAudio_FIFOThreshold;
511-
}
512-

source/MinxAudio.h

-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "MinxTimers.h"
2323

24-
#include <stdio.h>
2524
#include <stdint.h>
2625
#include <streams/memory_stream.h>
2726

@@ -52,8 +51,6 @@ extern int RequireSoundSync;
5251
enum {
5352
MINX_AUDIO_DISABLED = 0, // Disabled
5453
MINX_AUDIO_GENERATED, // Generated (Doesn't require sync)
55-
MINX_AUDIO_DIRECT, // Direct from Timer 3
56-
MINX_AUDIO_EMULATED, // Emulated
5754
MINX_AUDIO_DIRECTPWM // Direct from Timer 3 with PWM support
5855
};
5956

@@ -76,7 +73,6 @@ enum {
7673
// Conversion for the generator counter
7774
#define MINX_AUDIOCONV (2147483647/(MINX_AUDIOFREQ)*2)
7875

79-
8076
int MinxAudio_Create(int audioenable, int fifosize);
8177

8278
void MinxAudio_Destroy(void);
@@ -97,16 +93,8 @@ uint8_t MinxAudio_ReadReg(uint8_t reg);
9793

9894
void MinxAudio_WriteReg(uint8_t reg, uint8_t val);
9995

100-
int16_t MinxAudio_AudioProcessDirect(void);
101-
102-
int16_t MinxAudio_AudioProcessEmulated(void);
103-
104-
int16_t MinxAudio_AudioProcessDirectPWM(void);
105-
10696
int16_t MinxAudio_PiezoFilter(int32_t Sample);
10797

10898
void MinxAudio_GetSamplesS16Ch(int16_t *soundout, int numsamples, int channels);
10999

110-
int MinxAudio_SyncWithAudio(void);
111-
112100
#endif

0 commit comments

Comments
 (0)