Some updates for compatibility with Bizhawk

This commit is contained in:
SergioMartin86 2024-02-22 19:32:35 +00:00
parent 16605d68c7
commit 6b9b3bdb23
95 changed files with 138 additions and 95 deletions

View File

@ -88,4 +88,4 @@ void Nes_Effects_Buffer::RestoreAudioBufferState()
{ {
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -38,4 +38,4 @@ class Nes_Effects_Buffer : public Effects_Buffer
friend Multi_Buffer *set_apu(Nes_Effects_Buffer *, Apu *); friend Multi_Buffer *set_apu(Nes_Effects_Buffer *, Apu *);
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -372,4 +372,4 @@ int Apu::read_status(nes_time_t time)
return result; return result;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -360,4 +360,4 @@ inline void Apu::load_state(apu_state_t const &state)
dmc.run(last_time, last_time); dmc.run(last_time, last_time);
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -419,4 +419,4 @@ void Blip_Buffer::RestoreAudioBufferState()
memcpy(buffer_, extra_buffer, sizeof(extra_buffer)); memcpy(buffer_, extra_buffer, sizeof(extra_buffer));
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -377,4 +377,4 @@ inline int Blip_Reader::begin(Blip_Buffer &blip_buf)
int const blip_max_length = 0; int const blip_max_length = 0;
int const blip_default_length = 250; int const blip_default_length = 250;
} // namespace quickNES } // namespace quickerNES

View File

@ -233,4 +233,4 @@ void Nonlinearizer::RestoreAudioBufferState()
prev = extra_prev; prev = extra_prev;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -79,4 +79,4 @@ class Buffer : public Multi_Buffer
virtual void RestoreAudioBufferState(); virtual void RestoreAudioBufferState();
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -515,4 +515,4 @@ void Effects_Buffer::mix_enhanced(blip_sample_t *out, long count)
r2.end(bufs[6]); r2.end(bufs[6]);
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -101,4 +101,4 @@ inline Effects_Buffer::channel_t Effects_Buffer::channel(int i)
return channels[i % chan_count]; return channels[i % chan_count];
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -105,4 +105,4 @@ void Fme7_Apu::run_until(blip_time_t end_time)
last_time = end_time; last_time = end_time;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -152,4 +152,4 @@ inline void Fme7_Apu::load_state(fme7_apu_state_t const &in)
run_until(last_time); run_until(last_time);
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -284,4 +284,4 @@ void Stereo_Buffer::RestoreAudioBufferState()
right()->RestoreAudioBufferState(); right()->RestoreAudioBufferState();
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -199,4 +199,4 @@ inline long Mono_Buffer::read_samples(blip_sample_t *p, long s) { return buf.rea
inline long Mono_Buffer::samples_avail() const { return buf.samples_avail(); } inline long Mono_Buffer::samples_avail() const { return buf.samples_avail(); }
} // namespace quickNES } // namespace quickerNES

View File

@ -180,4 +180,4 @@ void Namco_Apu::load_state(namco_state_t const &in)
run_until(last_time); run_until(last_time);
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -112,4 +112,4 @@ inline void Namco_Apu::write_data(nes_time_t time, int data)
access() = data; access() = data;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -679,4 +679,4 @@ void Noise::run(nes_time_t time, nes_time_t end_time)
delay = time - end_time; delay = time - end_time;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -169,4 +169,4 @@ struct Dmc : Osc
nes_time_t next_read_time() const; nes_time_t next_read_time() const;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -212,4 +212,4 @@ void Vrc6_Apu::run_saw(nes_time_t end_time)
osc.last_amp = last_amp; osc.last_amp = last_amp;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -109,4 +109,4 @@ inline void Vrc6_Apu::treble_eq(blip_eq_t const &eq)
square_synth.treble_eq(eq); square_synth.treble_eq(eq);
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -208,4 +208,4 @@ void Vrc7::update_last_amp()
} }
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -76,4 +76,4 @@ inline void Vrc7::osc_output(int i, Blip_Buffer *buf)
oscs[i].output = buf; oscs[i].output = buf;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -1152,4 +1152,4 @@ void OPLL_writeIO(OPLL *opll, e_uint32 adr, e_uint32 val)
opll->adr = val; opll->adr = val;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -220,4 +220,4 @@ extern "C"
} }
#endif #endif
} // namespace quickNES } // namespace quickerNES

View File

@ -113,4 +113,4 @@ extern "C"
} }
#endif #endif
} // namespace quickNES } // namespace quickerNES

View File

@ -38,4 +38,4 @@ extern "C"
} }
#endif #endif
} // namespace quickNES } // namespace quickerNES

View File

@ -114,4 +114,4 @@ class Cart
unsigned mapper; unsigned mapper;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -1070,4 +1070,4 @@ inline void Core::cpu_write(nes_addr_t addr, int data, nes_time_t time)
static_cast<Core &>(*cpu).cpu_write(addr, data, time); \ static_cast<Core &>(*cpu).cpu_write(addr, data, time); \
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -1169,4 +1169,4 @@ end:
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -138,6 +138,12 @@ class Cpu
{ {
return (uint8_t *)code_map[addr >> page_bits] + addr; return (uint8_t *)code_map[addr >> page_bits] + addr;
} }
inline const uint8_t *get_code(nes_addr_t addr) const
{
return (const uint8_t *)code_map[addr >> page_bits] + addr;
}
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -445,4 +445,4 @@ void Emu::RestoreAudioBufferState()
sound_buf->RestoreAudioBufferState(); sound_buf->RestoreAudioBufferState();
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -219,6 +219,26 @@ class Emu
uint8_t *spr_mem() const { return emu.ppu.getSpriteRAM(); } uint8_t *spr_mem() const { return emu.ppu.getSpriteRAM(); }
uint16_t spr_mem_size() const { return emu.ppu.getSpriteRAMSize(); } uint16_t spr_mem_size() const { return emu.ppu.getSpriteRAMSize(); }
// Palette memory
uint8_t *pal_mem() const { return emu.ppu.getPaletteRAM(); }
uint16_t pal_mem_size() const { return emu.ppu.getPaletteRAMSize(); }
uint8_t peek_prg(nes_addr_t addr) const { return *emu.get_code(addr); }
void poke_prg(nes_addr_t addr, uint8_t value) { *emu.get_code(addr) = value; }
uint8_t peek_ppu(int addr) { return emu.ppu.peekaddr(addr); }
uint8_t get_ppu2000() const { return emu.ppu.w2000; }
void get_regs(unsigned int *dest) const
{
dest[0] = emu.r.a;
dest[1] = emu.r.x;
dest[2] = emu.r.y;
dest[3] = emu.r.sp;
dest[4] = emu.r.pc;
dest[5] = emu.r.status;
}
// End of public interface // End of public interface
public: public:
const char *set_sample_rate(long rate, class Buffer *); const char *set_sample_rate(long rate, class Buffer *);
@ -287,4 +307,4 @@ inline long Emu::chr_size() const
return cart()->chr_size() ? cart()->chr_size() : emu.ppu.chr_addr_size; return cart()->chr_size() ? cart()->chr_size() : emu.ppu.chr_addr_size;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -291,4 +291,4 @@ Mapper *Mapper::getMapperFromCode(const int mapperCode)
return mapper; return mapper;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -209,4 +209,4 @@ inline bool Mapper::write_intercepted(nes_time_t, nes_addr_t, int) { return fals
inline int Mapper::read(nes_time_t, nes_addr_t) { return -1; } // signal to caller inline int Mapper::read(nes_time_t, nes_addr_t) { return -1; } // signal to caller
} // namespace quickNES } // namespace quickerNES

View File

@ -35,4 +35,4 @@ class Mapper000 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -126,4 +126,4 @@ class Mapper001 : public Mapper, mmc1_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -45,4 +45,4 @@ class Mapper002 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -44,4 +44,4 @@ class Mapper003 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -255,4 +255,4 @@ class Mapper004 : public Mapper, mmc3_state_t
int counter_just_clocked; // used only for debugging int counter_just_clocked; // used only for debugging
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -149,4 +149,4 @@ class Mapper005 : public Mapper, mmc5_state_t
nes_time_t irq_time; nes_time_t irq_time;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -52,4 +52,4 @@ class Mapper007 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -78,4 +78,4 @@ class Mapper009 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -76,4 +76,4 @@ class Mapper010 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -52,4 +52,4 @@ class Mapper011 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -94,4 +94,4 @@ class Mapper015 : public Mapper, Mapper015_state_t
unsigned long int i; unsigned long int i;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -199,4 +199,4 @@ class Mapper019 : public Mapper, namco106_state_t
nes_time_t last_time; nes_time_t last_time;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -256,4 +256,4 @@ void Mapper_VRC2_4<type_a, type_b>::write_irq(nes_time_t time,
typedef Mapper_VRC2_4<true, true> Mapper021; typedef Mapper_VRC2_4<true, true> Mapper021;
} // namespace quickNES } // namespace quickerNES

View File

@ -34,4 +34,4 @@ namespace quickerNES
typedef Mapper_VRC2_4<false, true> Mapper022; typedef Mapper_VRC2_4<false, true> Mapper022;
} // namespace quickNES } // namespace quickerNES

View File

@ -33,4 +33,4 @@ namespace quickerNES
typedef Mapper_VRC2_4<false, false> Mapper023; typedef Mapper_VRC2_4<false, false> Mapper023;
} // namespace quickNES } // namespace quickerNES

View File

@ -233,4 +233,4 @@ class Mapper_Vrc6 : public Mapper, vrc6_state_t
typedef Mapper_Vrc6<0> Mapper024; typedef Mapper_Vrc6<0> Mapper024;
} // namespace quickNES } // namespace quickerNES

View File

@ -33,4 +33,4 @@ namespace quickerNES
typedef Mapper_VRC2_4<true, false> Mapper025; typedef Mapper_VRC2_4<true, false> Mapper025;
} // namespace quickNES } // namespace quickerNES

View File

@ -11,4 +11,4 @@ namespace quickerNES
typedef Mapper_Vrc6<3> Mapper026; typedef Mapper_Vrc6<3> Mapper026;
} // namespace quickNES } // namespace quickerNES

View File

@ -53,4 +53,4 @@ class Mapper030 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -126,4 +126,4 @@ class Mapper032 : public Mapper, mapper32_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -103,4 +103,4 @@ class Mapper033 : public Mapper, tc0190_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -44,4 +44,4 @@ class Mapper034 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -53,4 +53,4 @@ class Mapper060 : public Mapper
uint8_t game_sel, last_game; uint8_t game_sel, last_game;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -52,4 +52,4 @@ class Mapper066 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -190,4 +190,4 @@ class Mapper069 : public Mapper, fme7_state_t
Fme7_Apu sound; Fme7_Apu sound;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -84,4 +84,4 @@ class Mapper_74x161x162x32 : public Mapper
typedef Mapper_74x161x162x32<70> Mapper070; typedef Mapper_74x161x162x32<70> Mapper070;
} // namespace quickNES } // namespace quickerNES

View File

@ -54,4 +54,4 @@ class Mapper071 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -134,4 +134,4 @@ class Mapper073 : public Mapper, vrc3_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -110,4 +110,4 @@ class Mapper075 : public Mapper, vrc1_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -77,4 +77,4 @@ class Mapper078 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -95,4 +95,4 @@ void Mapper_AveNina<multicart>::write_regs()
typedef Mapper_AveNina<false> Mapper079; typedef Mapper_AveNina<false> Mapper079;
} // namespace quickNES } // namespace quickerNES

View File

@ -225,4 +225,4 @@ class Mapper085 : public Mapper, vrc7_state_t
}; };
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -26,4 +26,4 @@ namespace quickerNES
typedef Mapper_74x161x162x32<86> Mapper086; typedef Mapper_74x161x162x32<86> Mapper086;
} // namespace quickNES } // namespace quickerNES

View File

@ -50,4 +50,4 @@ class Mapper087 : public Mapper
void write(nes_time_t, nes_addr_t, int) {} void write(nes_time_t, nes_addr_t, int) {}
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -112,4 +112,4 @@ class Mapper_Namco_34x3 : public Mapper, namco_34x3_state_t
typedef Mapper_Namco_34x3<false> Mapper088; typedef Mapper_Namco_34x3<false> Mapper088;
} // namespace quickNES } // namespace quickerNES

View File

@ -59,4 +59,4 @@ class Mapper089 : public Mapper
uint8_t regs; uint8_t regs;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -58,4 +58,4 @@ class Mapper093 : public Mapper
uint8_t regs; uint8_t regs;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -57,4 +57,4 @@ class Mapper094 : public Mapper
uint8_t bank; uint8_t bank;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -66,4 +66,4 @@ class Mapper097 : public Mapper
uint8_t bank; uint8_t bank;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -30,4 +30,4 @@ namespace quickerNES
typedef Mapper_AveNina<true> Mapper113; typedef Mapper_AveNina<true> Mapper113;
} // namespace quickNES } // namespace quickerNES

View File

@ -66,4 +66,4 @@ class Mapper140 : public Mapper
uint8_t regs; uint8_t regs;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -26,4 +26,4 @@ namespace quickerNES
typedef Mapper_74x161x162x32<152> Mapper152; typedef Mapper_74x161x162x32<152> Mapper152;
} // namespace quickNES } // namespace quickerNES

View File

@ -30,4 +30,4 @@ namespace quickerNES
typedef Mapper_Namco_34x3<true> Mapper154; typedef Mapper_Namco_34x3<true> Mapper154;
} // namespace quickNES } // namespace quickerNES

View File

@ -62,4 +62,4 @@ class Mapper156 : public Mapper, m156_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -57,4 +57,4 @@ class Mapper180 : public Mapper
uint8_t bank; uint8_t bank;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -67,4 +67,4 @@ class Mapper184 : public Mapper
uint8_t regs; uint8_t regs;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -57,4 +57,4 @@ class Mapper190 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -78,4 +78,4 @@ class Mapper193 : public Mapper
uint8_t regs[4]; uint8_t regs[4];
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -100,4 +100,4 @@ class Mapper206 : public Mapper, namco_34xx_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -93,4 +93,4 @@ class Mapper207 : public Mapper, taito_x1005_state_t
virtual void write(nes_time_t, nes_addr_t addr, int data) {} virtual void write(nes_time_t, nes_addr_t addr, int data) {}
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -56,4 +56,4 @@ class Mapper232 : public Mapper
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -66,4 +66,4 @@ class Mapper240 : public Mapper
uint8_t regs; uint8_t regs;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -55,4 +55,4 @@ class Mapper241 : public Mapper
uint8_t bank; uint8_t bank;
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -72,4 +72,4 @@ class Mapper244 : public Mapper, mapper244_state_t
} }
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -77,4 +77,4 @@ class Mapper246 : public Mapper
uint8_t regs[8]; uint8_t regs[8];
}; };
} // namespace quickNES } // namespace quickerNES

View File

@ -656,4 +656,4 @@ nes_time_t Ppu::earliest_open_bus_decay()
return (decay_low < decay_high) ? decay_low : decay_high; return (decay_low < decay_high) ? decay_low : decay_high;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -143,4 +143,4 @@ inline void Ppu::update_open_bus(nes_time_t time)
if (time >= decay_high) open_bus &= ~0xE0; if (time >= decay_high) open_bus &= ~0xE0;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -433,4 +433,4 @@ long Ppu_Impl::recalc_sprite_max(int scanline)
return 0; return 0;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -89,10 +89,27 @@ class Ppu_Impl : public ppu_state_t
}; };
impl_t *impl; impl_t *impl;
long map_chr_addr_peek( unsigned a ) const
{
return chr_pages[a / chr_page_size] + a;
}
int peekaddr(int addr)
{
if (addr < 0x2000)
return chr_data[map_chr_addr_peek(addr)];
else
return get_nametable(addr)[addr & 0x3ff];
}
static const uint16_t scanline_len = 341; static const uint16_t scanline_len = 341;
uint8_t *getSpriteRAM() const { return (uint8_t*)spr_ram; } uint8_t *getSpriteRAM() const { return (uint8_t*)spr_ram; }
uint16_t getSpriteRAMSize() const { return spr_ram_size; } uint16_t getSpriteRAMSize() const { return spr_ram_size; }
uint8_t *getPaletteRAM() const { return (uint8_t*)palette; }
uint16_t getPaletteRAMSize() const { return sizeof(palette); }
uint8_t spr_ram[spr_ram_size]; uint8_t spr_ram[spr_ram_size];
void all_tiles_modified(); void all_tiles_modified();
@ -243,4 +260,4 @@ inline void Ppu_Impl::begin_frame()
addr_inc = w2000 & 4 ? 32 : 1; addr_inc = w2000 & 4 ? 32 : 1;
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -503,4 +503,4 @@ void Ppu_Rendering::draw_background(int start, int count)
} }
} }
} // namespace quickNES } // namespace quickerNES

View File

@ -61,4 +61,4 @@ inline void Ppu_Rendering::draw_sprites(int start, int count)
draw_scanlines(start, count, host_pixels + host_row_bytes * start, host_row_bytes, 2); draw_scanlines(start, count, host_pixels + host_row_bytes * start, host_row_bytes, 2);
} }
} // namespace quickNES } // namespace quickerNES