diff options
author | twinaphex | 2017-08-16 06:57:36 +0200 |
---|---|---|
committer | twinaphex | 2017-08-16 06:57:36 +0200 |
commit | aa610b2ba997a945c77ce06e9a33638dedb480da (patch) | |
tree | 5f5d5448a458492bfb220eb2dc6d80096692c1b6 | |
parent | 7a8802b9311099e5034054a69a309dcb17661dfa (diff) | |
download | snes9x2005-aa610b2ba997a945c77ce06e9a33638dedb480da.tar.gz snes9x2005-aa610b2ba997a945c77ce06e9a33638dedb480da.tar.bz2 snes9x2005-aa610b2ba997a945c77ce06e9a33638dedb480da.zip |
More C89_BUILD fixes
-rw-r--r-- | source/ppu.c | 29 | ||||
-rw-r--r-- | source/sa1.c | 6 | ||||
-rw-r--r-- | source/sdd1.c | 6 | ||||
-rw-r--r-- | source/seta010.c | 8 | ||||
-rw-r--r-- | source/soundux.c | 62 | ||||
-rw-r--r-- | source/spc700.c | 9 | ||||
-rw-r--r-- | source/spc7110.c | 19 | ||||
-rw-r--r-- | source/spc7110dec.c | 42 | ||||
-rw-r--r-- | source/srtc.c | 4 | ||||
-rw-r--r-- | source/tile.c | 32 | ||||
-rw-r--r-- | source/tile.h | 4 |
11 files changed, 138 insertions, 83 deletions
diff --git a/source/ppu.c b/source/ppu.c index 07d32f4..1f5df0b 100644 --- a/source/ppu.c +++ b/source/ppu.c @@ -87,8 +87,9 @@ void S9xUpdateHTimer() void S9xFixColourBrightness() { - IPPU.XB = mul_brightness [PPU.Brightness]; int32_t i; + + IPPU.XB = mul_brightness [PPU.Brightness]; for (i = 0; i < 256; i++) { IPPU.Red [i] = IPPU.XB [PPU.CGDATA [i] & 0x1f]; @@ -1648,6 +1649,10 @@ uint8_t S9xGetCPU(uint16_t Address) static void CommonPPUReset() { + uint8_t B; + int32_t c; + int32_t Sprite; + PPU.BGMode = 0; PPU.BG3Priority = 0; PPU.Brightness = 0; @@ -1657,7 +1662,6 @@ static void CommonPPUReset() PPU.VMA.FullGraphicCount = 0; PPU.VMA.Shift = 0; - uint8_t B; for (B = 0; B < 4; B++) { PPU.BG[B].SCBase = 0; @@ -1681,7 +1685,6 @@ static void CommonPPUReset() PPU.ClipWindow2Inside[4] = PPU.ClipWindow2Inside[5] = true; PPU.CGFLIP = false; - int32_t c; for (c = 0; c < 256; c++) { IPPU.Red [c] = (c & 7) << 2; @@ -1691,7 +1694,6 @@ static void CommonPPUReset() } PPU.FirstSprite = 0; - int32_t Sprite; for (Sprite = 0; Sprite < 128; Sprite++) { PPU.OBJ[Sprite].HPos = 0; @@ -1790,6 +1792,8 @@ static void CommonPPUReset() void S9xResetPPU() { + int32_t c; + CommonPPUReset(); PPU.Joypad1ButtonReadPos = 0; PPU.Joypad2ButtonReadPos = 0; @@ -1802,7 +1806,6 @@ void S9xResetPPU() IPPU.PrevMouseX[0] = IPPU.PrevMouseX[1] = 256 / 2; IPPU.PrevMouseY[0] = IPPU.PrevMouseY[1] = 224 / 2; - int32_t c; for (c = 0; c < 0x8000; c += 0x100) { if (!Settings.SuperFX) @@ -1822,9 +1825,10 @@ void S9xResetPPU() void S9xSoftResetPPU() { + int32_t c; + CommonPPUReset(); - int32_t c; for (c = 0; c < 0x8000; c += 0x100) memset(&Memory.FillRAM [c], c >> 8, 0x100); @@ -1972,10 +1976,14 @@ void S9xNextController() void S9xUpdateJustifiers() { static bool last_p1; + bool offscreen; + int32_t x, y; + uint32_t buttons; + in_bit = 0; justifiers = 0xFFFF00AA; - bool offscreen = JustifierOffscreen(); + offscreen = JustifierOffscreen(); JustifierButtons(&justifiers); last_p1 = !last_p1; @@ -1983,9 +1991,6 @@ void S9xUpdateJustifiers() if (!last_p1) justifiers |= 0x1000; - int32_t x, y; - uint32_t buttons; - if (Memory.FillRAM[0x4201] & 0x80) { @@ -2122,11 +2127,13 @@ void S9xSuperFXExec() { if ((Memory.FillRAM [0x3000 + GSU_SFR] & FLG_G) && (Memory.FillRAM [0x3000 + GSU_SCMR] & 0x18) == 0x18) { + int32_t GSUStatus; + if (!Settings.WinterGold || Settings.StarfoxHack) FxEmulate(~0); else FxEmulate((Memory.FillRAM [0x3000 + GSU_CLSR] & 1) ? 700 : 350); - int32_t GSUStatus = Memory.FillRAM [0x3000 + GSU_SFR] | (Memory.FillRAM [0x3000 + GSU_SFR + 1] << 8); + GSUStatus = Memory.FillRAM [0x3000 + GSU_SFR] | (Memory.FillRAM [0x3000 + GSU_SFR + 1] << 8); if ((GSUStatus & (FLG_G | FLG_IRQ)) == FLG_IRQ) S9xSetIRQ(GSU_IRQ_SOURCE); /* Trigger a GSU IRQ. */ } diff --git a/source/sa1.c b/source/sa1.c index 1666e17..e190b5c 100644 --- a/source/sa1.c +++ b/source/sa1.c @@ -618,6 +618,8 @@ static void S9xSA1DMA() void S9xSA1ReadVariableLengthData(bool inc, bool no_shift) { + uint8_t s; + uint32_t data; uint32_t addr = Memory.FillRAM[0x2259] | (Memory.FillRAM[0x225a] << 8) | (Memory.FillRAM[0x225b] << 16); uint8_t shift = Memory.FillRAM [0x2258] & 15; @@ -626,14 +628,14 @@ void S9xSA1ReadVariableLengthData(bool inc, bool no_shift) else if (shift == 0) shift = 16; - uint8_t s = shift + SA1.variable_bit_pos; + s = shift + SA1.variable_bit_pos; if (s >= 16) { addr += (s >> 4) << 1; s &= 15; } - uint32_t data = S9xSA1GetWord(addr) | (S9xSA1GetWord(addr + 2) << 16); + data = S9xSA1GetWord(addr) | (S9xSA1GetWord(addr + 2) << 16); data >>= s; Memory.FillRAM [0x230c] = (uint8_t) data; diff --git a/source/sdd1.c b/source/sdd1.c index 3a46ec9..3847b13 100644 --- a/source/sdd1.c +++ b/source/sdd1.c @@ -7,9 +7,10 @@ void S9xSetSDD1MemoryMap(uint32_t bank, uint32_t value) { + int32_t c; + bank = 0xc00 + bank * 0x100; value = value * 1024 * 1024; - int32_t c; for (c = 0; c < 0x100; c += 16) { uint8_t* block = &Memory.ROM [value + (c << 12)]; @@ -22,8 +23,9 @@ void S9xSetSDD1MemoryMap(uint32_t bank, uint32_t value) void S9xResetSDD1() { - memset(&Memory.FillRAM [0x4800], 0, 4); int32_t i; + + memset(&Memory.FillRAM [0x4800], 0, 4); for (i = 0; i < 4; i++) { Memory.FillRAM [0x4804 + i] = i; diff --git a/source/seta010.c b/source/seta010.c index d452cd9..dd2156c 100644 --- a/source/seta010.c +++ b/source/seta010.c @@ -288,8 +288,9 @@ void ST010_SortDrivers(uint16_t Positions, uint16_t Places[32], uint16_t Drivers { do { - Sorted = true; int32_t i; + + Sorted = true; for(i = 0; i < Positions - 1; i++) { if(Places[i] < Places[i + 1]) @@ -517,6 +518,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) (int16_t*) &Memory.SRAM[0x0000], (int16_t*) &Memory.SRAM[0x0002], (int16_t*) &Memory.SRAM[0x0004], (int16_t*) &Memory.SRAM[0x0010]); #else + { int16_t x1, y1, Quadrant, Theta; ST010_OP01(ST010_WORD(0x0000), ST010_WORD(0x0002), &x1, &y1, &Quadrant, &Theta); @@ -529,6 +531,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) Memory.SRAM[0x0005] = (uint8_t)(Quadrant >> 8); Memory.SRAM[0x0010] = (uint8_t)(Theta); Memory.SRAM[0x0011] = (uint8_t)(Theta >> 8); + } #endif break; } @@ -563,6 +566,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) int32_t dx, dy; int16_t a1, b1, c1; uint16_t o1; + uint16_t old_speed; bool wrap = false; @@ -612,7 +616,7 @@ void S9xSetST010(uint32_t Address, uint8_t Byte) wrap = true; } - uint16_t old_speed = speed; + old_speed = speed; if (ABS(o1 - rot) == 0x8000) /* special case */ speed = 0x100; diff --git a/source/soundux.c b/source/soundux.c index 967ac10..0de7f4b 100644 --- a/source/soundux.c +++ b/source/soundux.c @@ -7,6 +7,8 @@ #include <string.h> #include <errno.h> +#include <retro_inline.h> + #define CLIP16(v) \ if ((v) < -32768) \ (v) = -32768; \ @@ -88,7 +90,7 @@ uint32_t KeyOffERate [10]; #define LAST_SAMPLE 0xffffff #define JUST_PLAYED_LAST_SAMPLE(c) ((c)->sample_pointer >= LAST_SAMPLE) -static inline uint8_t* S9xGetSampleAddress(int32_t sample_number) +static INLINE uint8_t* S9xGetSampleAddress(int32_t sample_number) { uint32_t addr = (((APU.DSP[APU_DIR] << 8) + (sample_number << 2)) & 0xffff); return (IAPU.RAM + addr); @@ -182,6 +184,8 @@ void S9xSetEchoVolume(int16_t volume_left, int16_t volume_right) void S9xSetEchoEnable(uint8_t byte) { + int32_t i; + if (!SoundData.echo_write_enabled || Settings.DisableSoundEcho) byte = 0; if (byte && !SoundData.echo_enable) @@ -191,7 +195,6 @@ void S9xSetEchoEnable(uint8_t byte) } SoundData.echo_enable = byte; - int32_t i; for (i = 0; i < NUM_CHANNELS; i++) { if (byte & (1 << i)) @@ -243,6 +246,8 @@ void S9xSetSoundKeyOff(int32_t channel) void S9xFixSoundAfterSnapshotLoad() { + int32_t i; + SoundData.echo_write_enabled = !(APU.DSP [APU_FLG] & 0x20); S9xSetEchoDelay(APU.DSP [APU_EDL] & 0xf); S9xSetEchoFeedback((int8_t) APU.DSP [APU_EFB]); @@ -255,7 +260,6 @@ void S9xFixSoundAfterSnapshotLoad() S9xSetFilterCoefficient(5, (int8_t) APU.DSP [APU_C5]); S9xSetFilterCoefficient(6, (int8_t) APU.DSP [APU_C6]); S9xSetFilterCoefficient(7, (int8_t) APU.DSP [APU_C7]); - int32_t i; for (i = 0; i < 8; i++) { SoundData.channels[i].needs_decode = true; @@ -275,6 +279,7 @@ void S9xSetFilterCoefficient(int32_t tap, int32_t value) void S9xSetSoundADSR(int32_t channel, int32_t attack_ind, int32_t decay_ind, int32_t sustain_ind, int32_t sustain_level, int32_t release_rate) { + Channel *ch; int32_t attack_rate = AttackRate [attack_ind]; int32_t decay_rate = DecayRate [decay_ind]; int32_t sustain_rate = SustainRate [sustain_ind]; @@ -284,7 +289,8 @@ void S9xSetSoundADSR(int32_t channel, int32_t attack_ind, int32_t decay_ind, int if(attack_rate == 1) attack_rate = 0; - Channel* ch = &SoundData.channels[channel]; + + ch = &SoundData.channels[channel]; ch->env_ind_attack = attack_ind; ch->env_ind_decay = decay_ind; ch->env_ind_sustain = sustain_ind; @@ -346,6 +352,10 @@ void DecodeBlock(Channel* ch) uint8_t filter; uint8_t shift; int8_t sample1, sample2; + int8_t *compressed; + int16_t *raw; + uint32_t i; + int32_t prev0, prev1; if (ch->block_pointer > 0x10000 - 9) { @@ -355,19 +365,18 @@ void DecodeBlock(Channel* ch) return; } - int8_t* compressed = (int8_t*) &IAPU.RAM [ch->block_pointer]; + compressed = (int8_t*) &IAPU.RAM [ch->block_pointer]; filter = *compressed; if ((ch->last_block = (bool) (filter & 1))) ch->loop = (bool) (filter & 2); - int16_t* raw = ch->block = ch->decoded; - uint32_t i; + raw = ch->block = ch->decoded; compressed++; - int32_t prev0 = ch->previous [0]; - int32_t prev1 = ch->previous [1]; + prev0 = ch->previous [0]; + prev1 = ch->previous [1]; shift = filter >> 4; switch ((filter >> 2) & 3) @@ -440,7 +449,7 @@ void DecodeBlock(Channel* ch) ch->block_pointer += 9; } -static inline void MixStereo(int32_t sample_count) +static INLINE void MixStereo(int32_t sample_count) { static int32_t wave[SOUND_BUFFER_SIZE]; @@ -449,15 +458,17 @@ static inline void MixStereo(int32_t sample_count) uint32_t J; for (J = 0; J < NUM_CHANNELS; J++) { + uint32_t I; + int32_t VL, VR; + uint32_t freq0; + uint8_t mod; Channel* ch = &SoundData.channels[J]; if (ch->state == SOUND_SILENT) continue; - int32_t VL, VR; - uint32_t freq0 = ch->frequency; - - uint8_t mod = pitch_mod & (1 << J); + freq0 = ch->frequency; + mod = pitch_mod & (1 << J); if (ch->needs_decode) { @@ -479,7 +490,6 @@ static inline void MixStereo(int32_t sample_count) VL = (ch->sample * ch-> left_vol_level) / 128; VR = (ch->sample * ch->right_vol_level) / 128; - uint32_t I; for (I = 0; I < (uint32_t) sample_count; I += 2) { uint32_t freq = freq0; @@ -659,9 +669,11 @@ static inline void MixStereo(int32_t sample_count) } else { + uint8_t *dir; + S9xAPUSetEndX(J); ch->last_block = false; - uint8_t* dir = S9xGetSampleAddress(ch->sample_number); + dir = S9xGetSampleAddress(ch->sample_number); ch->block_pointer = READ_WORD(dir + 2); } } @@ -760,8 +772,9 @@ void S9xMixSamples(int16_t* buffer, int32_t sample_count) /* ... with filter defined. */ for (J = 0; J < sample_count; J++) { + int32_t E; Loop [(Z - 0) & 15] = Echo [SoundData.echo_ptr]; - int32_t E = Loop [(Z - 0) & 15] * FilterTaps [0]; + E = Loop [(Z - 0) & 15] * FilterTaps [0]; if (FilterTapDefinitionBitfield & 0x02) E += Loop [(Z - 2) & 15] * FilterTaps [1]; if (FilterTapDefinitionBitfield & 0x04) E += Loop [(Z - 4) & 15] * FilterTaps [2]; if (FilterTapDefinitionBitfield & 0x08) E += Loop [(Z - 6) & 15] * FilterTaps [3]; @@ -858,20 +871,22 @@ void S9xResetSound(bool full) void S9xSetPlaybackRate(uint32_t playback_rate) { + int32_t i; + so.playback_rate = playback_rate; if (playback_rate) { - /* notaz: calculate a value (let's call it freqbase) to simplify channel freq calculations later. */ - so.freqbase = (FIXED_POINT << 11) / (playback_rate * 33 / 32); - /* now precalculate env rates for S9xSetEnvRate */ static int32_t steps [] = { 0, 64, 619, 619, 128, 1, 64, 55, 64, 619 }; - int32_t i, u; + /* notaz: calculate a value (let's call it freqbase) to simplify channel freq calculations later. */ + so.freqbase = (FIXED_POINT << 11) / (playback_rate * 33 / 32); + /* now precalculate env rates for S9xSetEnvRate */ + for (u = 0 ; u < 10 ; u++) { int64_t fp1000su = ((int64_t) FIXED_POINT * 1000 * steps[u]); @@ -894,7 +909,6 @@ void S9xSetPlaybackRate(uint32_t playback_rate) } S9xSetEchoDelay(APU.DSP [APU_EDL] & 0xf); - int32_t i; for (i = 0; i < 8; i++) S9xSetSoundFrequency(i, SoundData.channels [i].hertz); } @@ -945,6 +959,7 @@ bool S9xSetSoundMode(int32_t channel, int32_t mode) void S9xPlaySample(int32_t channel) { + uint8_t *dir; Channel* ch = &SoundData.channels[channel]; ch->state = SOUND_SILENT; @@ -963,12 +978,13 @@ void S9xPlaySample(int32_t channel) else ch->type = SOUND_SAMPLE; + S9xSetSoundFrequency(channel, ch->hertz); ch->loop = false; ch->needs_decode = true; ch->last_block = false; ch->previous [0] = ch->previous[1] = 0; - uint8_t* dir = S9xGetSampleAddress(ch->sample_number); + dir = S9xGetSampleAddress(ch->sample_number); ch->block_pointer = READ_WORD(dir); ch->sample_pointer = 0; ch->env_error = 0; diff --git a/source/spc700.c b/source/spc700.c index eaf5467..c5ea4ef 100644 --- a/source/spc700.c +++ b/source/spc700.c @@ -1918,15 +1918,18 @@ void Apu8F(void) void Apu9E(void) { + uint32_t i; + uint32_t yva; + uint32_t x; + /* DIV YA,X */ if ((IAPU.Registers.X & 0x0f) <= (IAPU.Registers.YA.B.Y & 0x0f)) APUSetHalfCarry(); else APUClearHalfCarry(); - uint32_t yva = IAPU.Registers.YA.W; - uint32_t x = IAPU.Registers.X << 9; - uint32_t i; + yva = IAPU.Registers.YA.W; + x = IAPU.Registers.X << 9; for (i = 0 ; i < 9 ; ++i) { diff --git a/source/spc7110.c b/source/spc7110.c index ac8e0a8..249bbc9 100644 --- a/source/spc7110.c +++ b/source/spc7110.c @@ -134,6 +134,7 @@ uint8_t S9xGetSPC7110(uint16_t Address) return 0; if ((s7r.written & 0x07) == 0x07) { + uint8_t tmp; uint32_t i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811; i %= s7r.DataRomSize; if (s7r.reg4818 & 0x02) @@ -162,8 +163,8 @@ uint8_t S9xGetSPC7110(uint16_t Address) } } i += s7r.DataRomOffset; - uint8_t tmp = Memory.ROM[i]; - i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811; + tmp = Memory.ROM[i]; + i = (s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811; if (s7r.reg4818 & 0x02) { @@ -283,6 +284,7 @@ uint8_t S9xGetSPC7110(uint16_t Address) case 0x481A: if (s7r.written == 0x1F) { + uint8_t tmp; uint32_t i = ((s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811); if (s7r.reg4818 & 0x08) i += ((int16_t)(s7r.reg4815 << 8)) | s7r.reg4814; @@ -291,7 +293,7 @@ uint8_t S9xGetSPC7110(uint16_t Address) i %= s7r.DataRomSize; i += s7r.DataRomOffset; - uint8_t tmp = Memory.ROM[i]; + tmp = Memory.ROM[i]; if ((s7r.reg4818 & 0x60) == 0x60) { i = ((s7r.reg4813 << 16) | (s7r.reg4812 << 8) | s7r.reg4811); @@ -393,8 +395,10 @@ uint8_t S9xGetSPC7110(uint16_t Address) return Address >> 8; if (rtc_f9.init) { + uint8_t tmp; + S9xUpdateRTC(); - uint8_t tmp = rtc_f9.reg[rtc_f9.index]; + tmp = rtc_f9.reg[rtc_f9.index]; rtc_f9.index++; rtc_f9.index %= 0x10; return tmp; @@ -469,9 +473,12 @@ void S9xSetSPC7110(uint8_t data, uint16_t Address) break; case 0x480B: /* Offset enable */ { + int32_t table; + int32_t j; + s7r.reg480B = data; - int32_t table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801; - int32_t j = 4 * s7r.reg4804 + s7r.DataRomOffset + table; + table = (s7r.reg4803 << 16) | (s7r.reg4802 << 8) | s7r.reg4801; + j = 4 * s7r.reg4804 + s7r.DataRomOffset + table; if (s7r.reg480B == 0) s7r.AlignBy = 0; diff --git a/source/spc7110dec.c b/source/spc7110dec.c index 9adb4d6..7bea0af 100644 --- a/source/spc7110dec.c +++ b/source/spc7110dec.c @@ -66,6 +66,8 @@ SPC7110Decomp decomp; uint8_t spc7110dec_read(void) { + uint8_t data; + decomp.read_counter++; if(decomp.buffer_length == 0) @@ -86,7 +88,7 @@ uint8_t spc7110dec_read(void) } } - uint8_t data = decomp.buffer[decomp.buffer_rdoffset++]; + data = decomp.buffer[decomp.buffer_rdoffset++]; decomp.buffer_rdoffset &= SPC7110_DECOMP_BUFFER_SIZE - 1; decomp.buffer_length--; return data; @@ -109,6 +111,8 @@ uint8_t spc7110dec_dataread(void) void spc7110dec_clear(uint32_t mode, uint32_t offset, uint32_t index) { + uint32_t i; + decomp.original_mode = mode; decomp.original_offset = offset; decomp.original_index = index; @@ -117,7 +121,6 @@ void spc7110dec_clear(uint32_t mode, uint32_t offset, uint32_t index) decomp.buffer_rdoffset = 0; decomp.buffer_wroffset = 0; decomp.buffer_length = 0; - uint32_t i; for(i = 0; i < 32; i++) /* reset decomp.context states */ { @@ -164,6 +167,9 @@ void spc7110dec_mode0(bool init) uint32_t bit; for(bit = 0; bit < 8; bit++) { + uint32_t shift = 0; + uint32_t flag_lps; + uint32_t prob, mps; /* Get decomp.context */ uint8_t mask = (1 << (bit & 3)) - 1; uint8_t con = mask + ((inverts & mask) ^ (lps & mask)); @@ -172,11 +178,10 @@ void spc7110dec_mode0(bool init) con += 15; /* Get prob and mps */ - uint32_t prob = spc7110dec_probability(con); - uint32_t mps = (((out >> 15) & 1) ^ decomp.context[con].invert); + prob = spc7110dec_probability(con); + mps = (((out >> 15) & 1) ^ decomp.context[con].invert); /* Get bit */ - uint32_t flag_lps; if(val <= span - prob) /* mps */ { @@ -193,7 +198,6 @@ void spc7110dec_mode0(bool init) } /* Renormalize */ - uint32_t shift = 0; while(span < 0x7f) { @@ -249,10 +253,12 @@ void spc7110dec_mode1(bool init) while(decomp.buffer_length < (SPC7110_DECOMP_BUFFER_SIZE >> 1)) { + uint32_t data; uint32_t pixel; for(pixel = 0; pixel < 8; pixel++) { + uint32_t bit; /* Get first symbol decomp.context */ uint32_t a = ((out >> (1 * 2)) & 3); uint32_t b = ((out >> (7 * 2)) & 3); @@ -306,10 +312,10 @@ void spc7110dec_mode1(bool init) realorder[0] = a; /* Get 2 symbols */ - uint32_t bit; for(bit = 0; bit < 2; bit++) { + uint32_t shift = 0; /* Get prob */ uint32_t prob = spc7110dec_probability(con); @@ -329,7 +335,6 @@ void spc7110dec_mode1(bool init) } /* Renormalize */ - uint32_t shift = 0; while(span < 0x7f) { @@ -367,7 +372,7 @@ void spc7110dec_mode1(bool init) } /* Turn pixel data into bitplanes */ - uint32_t data = spc7110dec_morton_2x8(out); + data = spc7110dec_morton_2x8(out); spc7110dec_write(data >> 8); spc7110dec_write(data >> 0); @@ -398,10 +403,11 @@ void spc7110dec_mode2(bool init) while(decomp.buffer_length < (SPC7110_DECOMP_BUFFER_SIZE >> 1)) { - uint32_t pixel; + uint32_t pixel, data; for(pixel = 0; pixel < 8; pixel++) { + uint32_t bit; /* Get first symbol context */ uint32_t a = ((out0 >> (0 * 4)) & 15); uint32_t b = ((out0 >> (7 * 4)) & 15); @@ -456,10 +462,11 @@ void spc7110dec_mode2(bool init) realorder[0] = a; /* Get 4 symbols */ - uint32_t bit; for(bit = 0; bit < 4; bit++) { + uint32_t invertbit; + uint32_t shift = 0; /* Get prob */ uint32_t prob = spc7110dec_probability(con); @@ -479,7 +486,6 @@ void spc7110dec_mode2(bool init) } /* Renormalize */ - uint32_t shift = 0; while(span < 0x7f) { @@ -494,10 +500,11 @@ void spc7110dec_mode2(bool init) } } + /* Update processing info */ - lps = (lps << 1) + flag_lps; - uint32_t invertbit = decomp.context[con].invert; - inverts = (inverts << 1) + invertbit; + lps = (lps << 1) + flag_lps; + invertbit = decomp.context[con].invert; + inverts = (inverts << 1) + invertbit; /* Update decomp.context state */ if(flag_lps & spc7110dec_toggle_invert(con)) @@ -519,7 +526,7 @@ void spc7110dec_mode2(bool init) } /* Convert pixel data into bitplanes */ - uint32_t data = spc7110dec_morton_4x8(out0); + data = spc7110dec_morton_4x8(out0); spc7110dec_write(data >> 24); spc7110dec_write(data >> 16); bitplanebuffer[buffer_index++] = data >> 8; @@ -585,11 +592,12 @@ void spc7110dec_reset(void) void spc7110dec_init(void) { + uint32_t i; + decomp.buffer = malloc(SPC7110_DECOMP_BUFFER_SIZE); spc7110dec_reset(); /* Initialize reverse morton lookup tables */ - uint32_t i; for(i = 0; i < 256; i++) { #define map(x, y) (((i >> x) & 1) << y) diff --git a/source/srtc.c b/source/srtc.c index bdb2970..e86b6b2 100644 --- a/source/srtc.c +++ b/source/srtc.c @@ -343,8 +343,10 @@ void S9xSRTCPreSaveState() { if (Settings.SRTC) { + int32_t s; + S9xUpdateSrtcTime(); - int32_t s = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0; + s = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0; if (s > 0x20000) s = 0x20000; diff --git a/source/tile.c b/source/tile.c index e203ee1..3c6b43f 100644 --- a/source/tile.c +++ b/source/tile.c @@ -256,79 +256,83 @@ static void WRITE_4PIXELS16_FLIPPEDx2x2(int32_t Offset, uint8_t* Pixels, uint16_ void DrawTile16(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); RENDER_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4); } void DrawClippedTile16(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); TILE_CLIP_PREAMBLE(); RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4); } void DrawTile16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); RENDER_TILE(WRITE_4PIXELS16_HALFWIDTH, WRITE_4PIXELS16_FLIPPED_HALFWIDTH, 2); } void DrawClippedTile16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); TILE_CLIP_PREAMBLE(); RENDER_CLIPPED_TILE(WRITE_4PIXELS16_HALFWIDTH, WRITE_4PIXELS16_FLIPPED_HALFWIDTH, 2); } void DrawTile16x2(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8); } void DrawClippedTile16x2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); TILE_CLIP_PREAMBLE(); RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8); } void DrawTile16x2x2(uint32_t Tile, int32_t Offset, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8); } void DrawClippedTile16x2x2(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Width, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); uint8_t* bp; + TILE_PREAMBLE(); TILE_CLIP_PREAMBLE(); RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8); } void DrawLargePixel16(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); - uint16_t* sp = (uint16_t*) GFX.S + Offset; - uint8_t* Depth = GFX.DB + Offset; uint16_t pixel; + uint16_t *sp; + uint8_t *Depth; + TILE_PREAMBLE(); + sp = (uint16_t*) GFX.S + Offset; + Depth = GFX.DB + Offset; RENDER_TILE_LARGE(ScreenColors [pixel], PLOT_PIXEL); } void DrawLargePixel16HalfWidth(uint32_t Tile, int32_t Offset, uint32_t StartPixel, uint32_t Pixels, uint32_t StartLine, uint32_t LineCount) { - TILE_PREAMBLE(); - uint16_t* sp = (uint16_t*) GFX.S + Offset; - uint8_t* Depth = GFX.DB + Offset; uint16_t pixel; + uint16_t *sp; + uint8_t *Depth; + TILE_PREAMBLE(); + sp = (uint16_t*) GFX.S + Offset; + Depth = GFX.DB + Offset; RENDER_TILE_LARGE_HALFWIDTH(ScreenColors [pixel], PLOT_PIXEL); } diff --git a/source/tile.h b/source/tile.h index 12b294d..ca9f854 100644 --- a/source/tile.h +++ b/source/tile.h @@ -4,6 +4,8 @@ #define _TILE_H_ #define TILE_PREAMBLE() \ + uint32_t l; \ + uint16_t *ScreenColors; \ uint8_t *pCache; \ uint32_t TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift); \ if ((Tile & 0x1ff) >= 256) \ @@ -15,8 +17,6 @@ BG.Buffered[TileNumber] = ConvertTile (pCache, TileAddr); \ if (BG.Buffered [TileNumber] == BLANK_TILE) \ return; \ - uint32_t l; \ - uint16_t *ScreenColors; \ if (BG.DirectColourMode) \ { \ if (IPPU.DirectColourMapsNeedRebuild) \ |