Fix mouse electronics test
[lsnes.git] / bsnes-patches / v085 / 0008-Fix-uninitialized-variables.patch
blob5c61a977b72fc9f18afabe95a1fa061ade0bfe64
1 From 7018377c93553071fc404db872b2746d40ac3bce Mon Sep 17 00:00:00 2001
2 From: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
3 Date: Sat, 1 Sep 2012 11:23:34 +0300
4 Subject: [PATCH 08/15] Fix uninitialized variables
6 These uninitialized variables cause a lot of desyncs in Shadowrun.
7 ---
8 snes/alt/dsp/dsp.cpp | 2 ++
9 snes/alt/ppu-compatibility/ppu.cpp | 11 +++++++++++
10 snes/cpu/core/core.cpp | 8 ++++++++
11 snes/cpu/core/core.hpp | 2 ++
12 snes/cpu/cpu.cpp | 1 +
13 snes/smp/core/core.cpp | 11 +++++++++++
14 snes/smp/core/core.hpp | 2 ++
15 snes/smp/smp.cpp | 1 +
16 8 files changed, 38 insertions(+)
18 diff --git a/snes/alt/dsp/dsp.cpp b/snes/alt/dsp/dsp.cpp
19 index d0c9e07..c6809f7 100755
20 --- a/snes/alt/dsp/dsp.cpp
21 +++ b/snes/alt/dsp/dsp.cpp
22 @@ -40,6 +40,8 @@ void DSP::write(uint8 addr, uint8 data) {
25 void DSP::power() {
26 + clock = 0;
27 + memset(samplebuffer, 0, sizeof(samplebuffer));
28 spc_dsp.init(smp.apuram);
29 spc_dsp.reset();
30 spc_dsp.set_output(samplebuffer, 8192);
31 diff --git a/snes/alt/ppu-compatibility/ppu.cpp b/snes/alt/ppu-compatibility/ppu.cpp
32 index 1a3835b..a21e5e3 100755
33 --- a/snes/alt/ppu-compatibility/ppu.cpp
34 +++ b/snes/alt/ppu-compatibility/ppu.cpp
35 @@ -345,6 +345,17 @@ void PPU::power() {
36 regs.time_over = false;
37 regs.range_over = false;
39 + //All kinds of shit...
40 + line = 0;
41 + memset(pixel_cache, 0, sizeof(pixel_cache));
42 + memset(window, 0, sizeof(window));
43 + memset(bg_info, 0, sizeof(bg_info));
44 + active_sprite = 0;
45 + memset(oam_itemlist, 0, sizeof(oam_itemlist));
46 + memset(oam_tilelist, 0, sizeof(oam_tilelist));
47 + memset(oam_line_pal, 0, sizeof(oam_line_pal));
48 + memset(oam_line_pri, 0, sizeof(oam_line_pri));
50 reset();
53 diff --git a/snes/cpu/core/core.cpp b/snes/cpu/core/core.cpp
54 index 427176b..a5b809b 100755
55 --- a/snes/cpu/core/core.cpp
56 +++ b/snes/cpu/core/core.cpp
57 @@ -86,4 +86,12 @@ CPUcore::CPUcore() {
58 initialize_opcode_table();
61 +void CPUcore::powercycle()
63 + aa.d = 0;
64 + rd.d = 0;
65 + sp = 0;
66 + dp = 0;
70 diff --git a/snes/cpu/core/core.hpp b/snes/cpu/core/core.hpp
71 index 964bd12..7a685a8 100755
72 --- a/snes/cpu/core/core.hpp
73 +++ b/snes/cpu/core/core.hpp
74 @@ -7,6 +7,8 @@ struct CPUcore {
75 reg24_t aa, rd;
76 uint8_t sp, dp;
78 + void powercycle();
80 virtual void op_io() = 0;
81 virtual uint8_t op_read(uint32_t addr) = 0;
82 virtual void op_write(uint32_t addr, uint8_t data) = 0;
83 diff --git a/snes/cpu/cpu.cpp b/snes/cpu/cpu.cpp
84 index f6ae975..2d7d343 100755
85 --- a/snes/cpu/cpu.cpp
86 +++ b/snes/cpu/cpu.cpp
87 @@ -125,6 +125,7 @@ void CPU::power() {
88 mmio_power();
89 dma_power();
90 timing_power();
91 + CPUcore::powercycle();
94 void CPU::reset() {
95 diff --git a/snes/smp/core/core.cpp b/snes/smp/core/core.cpp
96 index 9c94d00..2fc29be 100755
97 --- a/snes/smp/core/core.cpp
98 +++ b/snes/smp/core/core.cpp
99 @@ -269,4 +269,15 @@ void SMPcore::op_step() {
103 +void SMPcore::powercycle()
105 + opcode = 0;
106 + dp.w = 0;
107 + sp.w = 0;
108 + rd.w = 0;
109 + wr.w = 0;
110 + bit.w = 0;
111 + ya.w = 0;
115 diff --git a/snes/smp/core/core.hpp b/snes/smp/core/core.hpp
116 index 6adf6f6..1489fce 100755
117 --- a/snes/smp/core/core.hpp
118 +++ b/snes/smp/core/core.hpp
119 @@ -11,6 +11,8 @@ struct SMPcore {
120 word_t dp, sp, rd, wr, bit, ya;
121 uint8 opcode;
123 + void powercycle();
125 void core_serialize(serializer&);
126 string disassemble_opcode(uint16 addr);
128 diff --git a/snes/smp/smp.cpp b/snes/smp/smp.cpp
129 index 9080624..d4ccf42 100755
130 --- a/snes/smp/smp.cpp
131 +++ b/snes/smp/smp.cpp
132 @@ -53,6 +53,7 @@ void SMP::power() {
133 timer0.target = 0;
134 timer1.target = 0;
135 timer2.target = 0;
136 + SMPcore::powercycle();
139 void SMP::reset() {
141 1.9.0