Skip to content

Commit 6b19b76

Browse files
authored
Merge branch 'grumpycoders:main' into main
2 parents 90d7e7a + 1ab8625 commit 6b19b76

39 files changed

+242
-1029
lines changed

src/core/cdriso.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV
363363
stream_index = ret;
364364
st = fmt_ctx->streams[stream_index];
365365

366-
AVCodec *dec = avcodec_find_decoder(st->codecpar->codec_id);
366+
const AVCodec *dec = avcodec_find_decoder(st->codecpar->codec_id);
367367
if (!dec) {
368368
PCSX::g_system->printf(_("Failed to find %s codec\n"), av_get_media_type_string(type));
369369
return AVERROR(EINVAL);
@@ -391,7 +391,7 @@ static int open_codec_context(int *stream_idx, AVFormatContext *fmt_ctx, enum AV
391391
static int decode_compressed_cdda_track(char *buf, char *src_filename, int *size) {
392392
AVFormatContext *fmt_ctx = NULL;
393393
AVCodecContext *audio_dec_ctx = NULL;
394-
AVCodec *audio_codec = NULL;
394+
const AVCodec *audio_codec = NULL;
395395
AVStream *audio_stream = NULL;
396396
int audio_stream_idx = -1;
397397
AVFrame *frame = NULL;

src/core/gpu.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ class GPU {
6161
virtual void save(SaveStates::GPU &gpu) = 0;
6262
virtual void load(const SaveStates::GPU &gpu) = 0;
6363

64-
virtual void keypressed(int key) {}
6564
virtual void displayText(char *pText) { PCSX::g_system->printf("%s\n", pText); }
6665
virtual void makeSnapshot(void) {}
6766
virtual void toggleDebug(void) {}
6867
virtual int32_t getScreenPic(unsigned char *pMem) { return -1; }
6968
virtual int32_t showScreenPic(unsigned char *pMem) { return -1; }
7069
virtual void clearDynarec(void (*callback)(void)) {}
71-
virtual void hSync(int val) {}
72-
virtual void vBlank(int val) {}
70+
virtual void vBlank() {}
7371
virtual void visualVibration(uint32_t iSmall, uint32_t iBig) {}
7472
virtual void cursor(int player, int x, int y) {}
7573
virtual void addVertex(short sx, short sy, int64_t fx, int64_t fy, int64_t fz) {}

src/core/kernellog.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static const char *const A0names[] = {
143143
"memset", "memmove", "memcmp", "memchr", "rand",
144144
// 30
145145
"srand", "qsort", "strtod", "user_malloc", "user_free", "lsearch", "bsearch", "user_calloc", "user_realloc",
146-
"user_initheap", nullptr, "getchar", "putchar", "gets", "puts", "printf",
146+
"user_initheap", "abort", "getchar", "putchar", "gets", "puts", "printf",
147147
// 40
148148
"SystemErrorUnresolvedException", "loadExeHeader", "loadExe", "exec", "flushCache", "installKernelHandlers",
149149
"GPU_dw", "GPU_mem2vram", "GPU_send", "GPU_cw", "GPU_cwb", "GPU_sendPackets", "GPU_abort", "GPU_getStatus",
@@ -445,6 +445,10 @@ void PCSX::R3000Acpu::logA0KernelCall(uint32_t call) {
445445
g_system->log(LogClass::KERNEL, "0x%08x, %i)", n.a0, n.a1);
446446
break;
447447
}
448+
case 0x3a: {
449+
g_system->log(LogClass::KERNEL, "%i)", n.a0);
450+
break;
451+
}
448452
case 0x3b: {
449453
g_system->log(LogClass::KERNEL, ")");
450454
break;

src/core/pad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Pads {
5252

5353
private:
5454
EventBus::Listener m_listener;
55-
int m_gamepadsMap[16];
55+
int m_gamepadsMap[16] = {0};
5656

5757
static const int GLFW_GAMEPAD_BUTTON_LEFT_TRIGGER = GLFW_GAMEPAD_BUTTON_LAST + 1;
5858
static const int GLFW_GAMEPAD_BUTTON_RIGHT_TRIGGER = GLFW_GAMEPAD_BUTTON_LAST + 2;

src/core/psxcounters.cc

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,8 @@ void PCSX::Counters::psxRcntUpdate() {
187187
if (cycle - m_rcnts[3].cycleStart >= m_rcnts[3].cycle) {
188188
psxRcntReset(3);
189189

190-
PCSX::g_emulator->m_gpu->hSync(m_hSyncCount);
191-
192-
m_spuSyncCount++;
193190
m_hSyncCount++;
194-
191+
m_spuSyncCount++;
195192
// Update spu.
196193
if (m_spuSyncCount >= SpuUpdInterval[PCSX::g_emulator->settings.get<PCSX::Emulator::SettingVideo>()]) {
197194
m_spuSyncCount = 0;
@@ -206,24 +203,19 @@ void PCSX::Counters::psxRcntUpdate() {
206203
}
207204
#endif
208205

209-
// VSync irq.
206+
// Trigger VBlank IRQ when VBlank starts
210207
if (m_hSyncCount == VBlankStart[PCSX::g_emulator->settings.get<PCSX::Emulator::SettingVideo>()]) {
211-
PCSX::g_emulator->m_gpu->vBlank(1);
212-
213-
// For the best times. :D
214-
// setIrq( 0x01 );
215-
}
216-
217-
// Update lace. (calculated at psxHsyncCalculate() on init/defreeze)
218-
if (m_hSyncCount >= m_HSyncTotal[PCSX::g_emulator->settings.get<PCSX::Emulator::SettingVideo>()]) {
219-
m_hSyncCount = 0;
220-
221-
PCSX::g_emulator->m_gpu->vBlank(0);
208+
PCSX::g_emulator->m_gpu->vBlank();
222209
setIrq(0x01);
223-
210+
211+
// Update lace. (calculated at psxHsyncCalculate() on init/defreeze)
224212
PCSX::g_emulator->m_gpu->updateLace();
225213
PCSX::g_emulator->vsync();
226214
}
215+
216+
if (m_hSyncCount >= m_HSyncTotal[PCSX::g_emulator->settings.get<PCSX::Emulator::SettingVideo>()]) {
217+
m_hSyncCount = 0;
218+
}
227219
}
228220
}
229221

src/core/psxemulator.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ void PCSX::Emulator::vsync() {
122122
g_system->update(true);
123123
m_cheats->ApplyCheats();
124124

125-
if (m_vblank_count_hideafter) {
126-
if (!(--m_vblank_count_hideafter)) {
127-
PCSX::g_emulator->m_gpu->showScreenPic(NULL);
128-
}
129-
}
130-
131125
if (m_config.RewindInterval > 0 && !(++m_rewind_counter % m_config.RewindInterval)) {
132126
// CreateRewindState();
133127
}

src/core/psxemulator.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@
4646

4747
#ifndef MAXPATHLEN
4848
#ifdef _WIN32
49-
#ifndef WIN32_LEAN_AND_MEAN
50-
#define WIN32_LEAN_AND_MEAN
51-
#endif
52-
#ifndef NOMINMAX
53-
#define NOMINMAX
54-
#endif
55-
#include <windows.h>
49+
#include "support/windowswrapper.h"
5650
#endif
5751
#ifdef MAX_PATH
5852
#define MAXPATHLEN MAX_PATH
@@ -221,7 +215,6 @@ class Emulator {
221215

222216
// It is safe if these overflow
223217
uint32_t m_rewind_counter = 0;
224-
uint8_t m_vblank_count_hideafter = 0;
225218

226219
// Used for overclocking
227220
// Make the timing events trigger faster as we are currently assuming everything

src/core/psxinterpreter.cc

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,8 @@ inline void InterpretedCPU::doBranch(uint32_t target, bool fromLink) {
343343
* Format: OP rt, rs, immediate *
344344
*********************************************************/
345345
void InterpretedCPU::psxADDI(uint32_t code) {
346-
if (!_Rt_) return;
347-
348-
auto rs = _rRs_;
349-
auto imm = _Imm_;
346+
const auto rs = _rRs_;
347+
const auto imm = _Imm_;
350348
uint32_t res = rs + imm;
351349

352350
if (_Rt_ == 29) {
@@ -369,9 +367,12 @@ void InterpretedCPU::psxADDI(uint32_t code) {
369367
}
370368
}
371369

372-
maybeCancelDelayedLoad(_Rt_);
373-
_rRt_ = res;
374-
} // Rt = Rs + Im (Exception on Integer Overflow)
370+
if (_Rt_ != 0) {
371+
maybeCancelDelayedLoad(_Rt_);
372+
_rRt_ = res;
373+
}
374+
}
375+
375376
void InterpretedCPU::psxADDIU(uint32_t code) {
376377
if (!_Rt_) return;
377378
maybeCancelDelayedLoad(_Rt_);
@@ -437,10 +438,8 @@ void InterpretedCPU::psxSLTIU(uint32_t code) {
437438
* Format: OP rd, rs, rt *
438439
*********************************************************/
439440
void InterpretedCPU::psxADD(uint32_t code) {
440-
if (!_Rd_) return;
441-
442-
auto rs = _rRs_;
443-
auto rt = _rRt_;
441+
const auto rs = _rRs_;
442+
const auto rt = _rRt_;
444443
uint32_t res = rs + rt;
445444
if (_Rd_ == 29) {
446445
if ((_Rs_ == 29) || (_Rt_ == 29)) {
@@ -462,13 +461,16 @@ void InterpretedCPU::psxADD(uint32_t code) {
462461
}
463462
}
464463

465-
maybeCancelDelayedLoad(_Rd_);
466-
_rRd_ = res;
467-
} // Rd = Rs + Rt (Exception on Integer Overflow)
464+
if (_Rd_ != 0) {
465+
maybeCancelDelayedLoad(_Rd_);
466+
_rRd_ = res;
467+
}
468+
}
469+
468470
void InterpretedCPU::psxADDU(uint32_t code) {
469471
if (!_Rd_) return;
470472
maybeCancelDelayedLoad(_Rd_);
471-
uint32_t res = _u32(_rRs_) + _u32(_rRt_);
473+
uint32_t res = _rRs_ + _rRt_;
472474
if (_Rd_ == 29) {
473475
if ((_Rs_ == 29) || (_Rt_ == 29)) {
474476
PCSX::g_emulator->m_callStacks->offsetSP(_rRd_, res - _rRd_);
@@ -479,10 +481,8 @@ void InterpretedCPU::psxADDU(uint32_t code) {
479481
_rRd_ = res;
480482
} // Rd = Rs + Rt
481483
void InterpretedCPU::psxSUB(uint32_t code) {
482-
if (!_Rd_) return;
483-
484-
auto rs = _rRs_;
485-
auto rt = _rRt_;
484+
const auto rs = _rRs_;
485+
const auto rt = _rRt_;
486486
uint32_t res = rs - rt;
487487
if (_Rd_ == 29) {
488488
if (_Rs_ == 29) {
@@ -503,13 +503,16 @@ void InterpretedCPU::psxSUB(uint32_t code) {
503503
return;
504504
}
505505
}
506-
maybeCancelDelayedLoad(_Rd_);
507-
_rRd_ = res;
506+
507+
if (_Rd_ != 0) {
508+
maybeCancelDelayedLoad(_Rd_);
509+
_rRd_ = res;
510+
}
508511
} // Rd = Rs - Rt (Exception on Integer Overflow)
509512
void InterpretedCPU::psxSUBU(uint32_t code) {
510513
if (!_Rd_) return;
511514
maybeCancelDelayedLoad(_Rd_);
512-
uint32_t res = _u32(_rRs_) - _u32(_rRt_);
515+
uint32_t res = _rRs_ - _rRt_;
513516
if (_Rd_ == 29) {
514517
if (_Rs_ == 29) {
515518
PCSX::g_emulator->m_callStacks->offsetSP(_rRd_, res - _rRd_);

src/core/r3000a.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
int PCSX::R3000Acpu::psxInit() {
3737
g_system->printf(_("PCSX-Redux booting\n"));
38-
g_system->printf(_("Copyright (C) 2019-2021 PCSX-Redux authors\n"));
38+
g_system->printf(_("Copyright (C) 2019-2022 PCSX-Redux authors\n"));
3939
const auto& args = g_system->getArgs();
4040

4141
if (args.get<bool>("interpreter"))

src/core/system.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ DstTP ClockCast(const SrcTP tp) {
5353
}
5454

5555
namespace Events {
56-
struct SettingsLoaded {};
56+
struct SettingsLoaded {
57+
bool safe = false;
58+
};
5759
struct Quitting {};
5860
struct LogMessage {
5961
LogClass logClass;

0 commit comments

Comments
 (0)