From f7cd3834a744a8aa35e3f3cd575683d44eb38895 Mon Sep 17 00:00:00 2001 From: Sergio Martin Date: Fri, 19 Jan 2024 18:44:28 +0100 Subject: [PATCH] Simplifying/modernizing --- source/quickerNES/Nes_Cart.h | 3 +- source/quickerNES/Nes_Core.h | 14 ++--- source/quickerNES/Nes_Emu.cpp | 6 --- source/quickerNES/Nes_Mapper.h | 2 + source/quickerNES/Nes_Ppu.h | 2 + source/quickerNES/Nes_Ppu_Impl.cpp | 20 ++++---- source/quickerNES/Nes_Ppu_Impl.h | 2 +- source/quickerNES/Nes_Ppu_Rendering.cpp | 33 ++++++------ source/quickerNES/Nes_Ppu_Rendering.h | 2 +- source/quickerNES/Nes_Ppu_Sprites.h | 8 +-- source/quickerNES/audio/Effects_Buffer.cpp | 4 +- source/quickerNES/audio/Multi_Buffer.cpp | 11 ++-- source/quickerNES/audio/Nes_Buffer.cpp | 4 +- source/quickerNES/audio/Nes_Buffer.h | 2 + source/quickerNES/audio/Nes_Oscs.h | 3 ++ source/quickerNES/audio/apu.cpp | 6 +-- source/quickerNES/audio/apu.h | 14 +++-- source/quickerNES/audio/fme7/apu.h | 4 +- source/quickerNES/audio/namco/apu.cpp | 2 +- source/quickerNES/audio/vrc6/apu.cpp | 2 +- source/quickerNES/audio/vrc6/apu.h | 2 +- source/quickerNES/audio/vrc7/apu.h | 2 +- source/quickerNES/blargg_common.h | 60 ---------------------- source/quickerNES/mappers/mapper001.hpp | 5 +- source/quickerNES/mappers/mapper004.hpp | 4 +- source/quickerNES/mappers/mapper005.hpp | 5 +- source/quickerNES/mappers/mapper015.hpp | 2 +- source/quickerNES/mappers/mapper019.hpp | 4 +- source/quickerNES/mappers/mapper021.hpp | 3 +- source/quickerNES/mappers/mapper024.hpp | 4 +- source/quickerNES/mappers/mapper032.hpp | 3 +- source/quickerNES/mappers/mapper033.hpp | 3 +- source/quickerNES/mappers/mapper069.hpp | 2 +- source/quickerNES/mappers/mapper075.hpp | 3 +- source/quickerNES/mappers/mapper085.hpp | 2 +- source/quickerNES/mappers/mapper088.hpp | 3 +- source/quickerNES/mappers/mapper156.hpp | 3 +- source/quickerNES/mappers/mapper206.hpp | 3 +- source/quickerNES/mappers/mapper207.hpp | 3 +- source/quickerNES/mappers/mapper244.hpp | 3 +- 40 files changed, 95 insertions(+), 168 deletions(-) delete mode 100644 source/quickerNES/blargg_common.h diff --git a/source/quickerNES/Nes_Cart.h b/source/quickerNES/Nes_Cart.h index d3fd82b..21a1bc5 100644 --- a/source/quickerNES/Nes_Cart.h +++ b/source/quickerNES/Nes_Cart.h @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include +#include #include "blargg_common.h" @@ -36,7 +37,7 @@ public: uint8_t flags2; // MMMM --XX Mapper high 4 bits uint8_t zero [8]; // if zero [7] is non-zero, treat flags2 as zero }; - BOOST_STATIC_ASSERT( sizeof (ines_header_t) == 16 ); + static_assert( sizeof (ines_header_t) == 16 ); // Load iNES file void load_ines( const uint8_t* buffer ) diff --git a/source/quickerNES/Nes_Core.h b/source/quickerNES/Nes_Core.h index ea8354b..512b4f2 100644 --- a/source/quickerNES/Nes_Core.h +++ b/source/quickerNES/Nes_Core.h @@ -113,7 +113,7 @@ struct joypad_state_t uint8_t w4016; // strobe uint8_t unused [3]; }; -BOOST_STATIC_ASSERT( sizeof (joypad_state_t) == 12 ); +static_assert( sizeof (joypad_state_t) == 12 ); struct cpu_state_t { @@ -125,7 +125,7 @@ struct cpu_state_t uint8_t y; uint8_t unused [1]; }; -BOOST_STATIC_ASSERT( sizeof (cpu_state_t) == 8 ); +static_assert( sizeof (cpu_state_t) == 8 ); class Nes_Core : private Nes_Cpu { typedef Nes_Cpu cpu; @@ -1085,18 +1085,18 @@ inline void Nes_Core::cpu_write( nes_addr_t addr, int data, nes_time_t time ) } #define NES_CPU_READ_PPU( cpu, addr, time ) \ - STATIC_CAST(Nes_Core&,*cpu).cpu_read_ppu( addr, time ) + static_cast(*cpu).cpu_read_ppu( addr, time ) #define NES_CPU_READ( cpu, addr, time ) \ - STATIC_CAST(Nes_Core&,*cpu).cpu_read( addr, time ) + static_cast(*cpu).cpu_read( addr, time ) #define NES_CPU_WRITEX( cpu, addr, data, time ){\ - STATIC_CAST(Nes_Core&,*cpu).cpu_write( addr, data, time );\ + static_cast(*cpu).cpu_write( addr, data, time );\ } #define NES_CPU_WRITE( cpu, addr, data, time ){\ if ( addr < 0x800 ) cpu->low_mem [addr] = data;\ - else if ( addr == 0x2007 ) STATIC_CAST(Nes_Core&,*cpu).cpu_write_2007( data );\ - else STATIC_CAST(Nes_Core&,*cpu).cpu_write( addr, data, time );\ + else if ( addr == 0x2007 ) static_cast(*cpu).cpu_write_2007( data );\ + else static_cast(*cpu).cpu_write( addr, data, time );\ } diff --git a/source/quickerNES/Nes_Emu.cpp b/source/quickerNES/Nes_Emu.cpp index 891e797..88026b1 100644 --- a/source/quickerNES/Nes_Emu.cpp +++ b/source/quickerNES/Nes_Emu.cpp @@ -1,4 +1,3 @@ - // Nes_Emu 0.7.0. http://www.slack.net/~ant/ #include @@ -18,11 +17,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ int const sound_fade_size = 384; -// Constants are manually duplicated in Nes_Emu so their value can be seen -// directly, rather than having to look in Nes_Ppu.h. "0 +" converts to int. -BOOST_STATIC_ASSERT( Nes_Emu::image_width == 0 + Nes_Ppu::image_width ); -BOOST_STATIC_ASSERT( Nes_Emu::image_height == 0 + Nes_Ppu::image_height ); - Nes_Emu::equalizer_t const Nes_Emu::nes_eq = { -1.0, 80 }; Nes_Emu::equalizer_t const Nes_Emu::famicom_eq = { -15.0, 80 }; Nes_Emu::equalizer_t const Nes_Emu::tv_eq = { -12.0, 180 }; diff --git a/source/quickerNES/Nes_Mapper.h b/source/quickerNES/Nes_Mapper.h index b41f7b8..5c39630 100644 --- a/source/quickerNES/Nes_Mapper.h +++ b/source/quickerNES/Nes_Mapper.h @@ -8,6 +8,8 @@ #include "Nes_Cart.h" #include "Nes_Cpu.h" +#include + class Blip_Buffer; class blip_eq_t; class Nes_Core; diff --git a/source/quickerNES/Nes_Ppu.h b/source/quickerNES/Nes_Ppu.h index 499f35d..63007be 100644 --- a/source/quickerNES/Nes_Ppu.h +++ b/source/quickerNES/Nes_Ppu.h @@ -7,6 +7,8 @@ #define NES_PPU_H #include "Nes_Ppu_Rendering.h" +#include + class Nes_Mapper; class Nes_Core; diff --git a/source/quickerNES/Nes_Ppu_Impl.cpp b/source/quickerNES/Nes_Ppu_Impl.cpp index b98eb0b..ced92b7 100644 --- a/source/quickerNES/Nes_Ppu_Impl.cpp +++ b/source/quickerNES/Nes_Ppu_Impl.cpp @@ -325,19 +325,19 @@ struct calc_sprite_max_scanlines uint8_t* p = scanlines + top; if ( (unsigned) (239 - top) < limit ) { - unsigned long p0 = ((unaligned_uint32_t*)p) [0].val + offset; - unsigned long p4 = ((unaligned_uint32_t*)p) [1].val + offset; - ((unaligned_uint32_t*)p) [0].val = p0; + unsigned long p0 = ((uint32_t*)p) [0] + offset; + unsigned long p4 = ((uint32_t*)p) [1] + offset; + ((uint32_t*)p) [0] = p0; any_hits |= p0; - ((unaligned_uint32_t*)p) [1].val = p4; + ((uint32_t*)p) [1] = p4; any_hits |= p4; if ( height > 8 ) { - unsigned long p0 = ((unaligned_uint32_t*)p) [2].val + offset; - unsigned long p4 = ((unaligned_uint32_t*)p) [3].val + offset; - ((unaligned_uint32_t*)p) [2].val = p0; + unsigned long p0 = ((uint32_t*)p) [2] + offset; + unsigned long p4 = ((uint32_t*)p) [3] + offset; + ((uint32_t*)p) [2] = p0; any_hits |= p0; - ((unaligned_uint32_t*)p) [3].val = p4; + ((uint32_t*)p) [3] = p4; any_hits |= p4; } } @@ -376,12 +376,12 @@ long Nes_Ppu_Impl::recalc_sprite_max( int scanline ) // check four at a time uint8_t* pos = &sprite_max_scanlines [scanline]; - unsigned long n = ((unaligned_uint32_t*)pos)->val; + unsigned long n = *((uint32_t*)pos); while ( 1 ) { unsigned long x = n & mask; pos += 4; - n = ((unaligned_uint32_t*)pos)->val; + n = *((uint32_t*)pos); if ( x ) break; } diff --git a/source/quickerNES/Nes_Ppu_Impl.h b/source/quickerNES/Nes_Ppu_Impl.h index 4d5fbb4..f19698b 100644 --- a/source/quickerNES/Nes_Ppu_Impl.h +++ b/source/quickerNES/Nes_Ppu_Impl.h @@ -29,7 +29,7 @@ struct ppu_state_t uint8_t open_bus; uint8_t unused2[3]; }; -BOOST_STATIC_ASSERT( sizeof (ppu_state_t) == 20 + 0x20 ); +static_assert( sizeof (ppu_state_t) == 20 + 0x20 ); class Nes_Ppu_Impl : public ppu_state_t { public: diff --git a/source/quickerNES/Nes_Ppu_Rendering.cpp b/source/quickerNES/Nes_Ppu_Rendering.cpp index 32d1fff..ce4476b 100644 --- a/source/quickerNES/Nes_Ppu_Rendering.cpp +++ b/source/quickerNES/Nes_Ppu_Rendering.cpp @@ -1,4 +1,3 @@ - // Nes_Emu 0.7.0. http://www.slack.net/~ant/ #include "Nes_Ppu_Rendering.h" @@ -30,7 +29,7 @@ inline Nes_Ppu_Impl::cached_tile_t const& int index = sprite_tile_index( sprite ); // use index directly, since cached tile is same size as native tile - BOOST_STATIC_ASSERT( sizeof (cached_tile_t) == bytes_per_tile ); + static_assert( sizeof (cached_tile_t) == bytes_per_tile ); return *(Nes_Ppu_Impl::cached_tile_t*) ((uint8_t*) tiles + map_chr_addr( index * bytes_per_tile )); } @@ -38,7 +37,7 @@ inline Nes_Ppu_Impl::cached_tile_t const& inline Nes_Ppu_Impl::cached_tile_t const& Nes_Ppu_Impl::get_bg_tile( int index ) { // use index directly, since cached tile is same size as native tile - BOOST_STATIC_ASSERT( sizeof (cached_tile_t) == bytes_per_tile ); + static_assert( sizeof (cached_tile_t) == bytes_per_tile ); return *(Nes_Ppu_Impl::cached_tile_t*) ((uint8_t*) tile_cache + map_chr_addr( index * bytes_per_tile )); } @@ -205,11 +204,11 @@ void Nes_Ppu_Rendering::draw_background_( int remain ) for ( int n = 4; n--; ) { unsigned long line = *lines++; - ((unaligned_uint32_t*) p) [0].val = (line >> 4 & mask) + offset; - ((unaligned_uint32_t*) p) [1].val = (line & mask) + offset; + ((uint32_t*) p) [0] = (line >> 4 & mask) + offset; + ((uint32_t*) p) [1] = (line & mask) + offset; p += row_bytes; - ((unaligned_uint32_t*) p) [0].val = (line >> 6 & mask) + offset; - ((unaligned_uint32_t*) p) [1].val = (line >> 2 & mask) + offset; + ((uint32_t*) p) [0] = (line >> 6 & mask) + offset; + ((uint32_t*) p) [1] = (line >> 2 & mask) + offset; p += row_bytes; } } @@ -220,27 +219,27 @@ void Nes_Ppu_Rendering::draw_background_( int remain ) if ( fine_y & 1 ) { unsigned long line = *lines++; - ((unaligned_uint32_t*) p) [0].val = (line >> 6 & mask) + offset; - ((unaligned_uint32_t*) p) [1].val = (line >> 2 & mask) + offset; + ((uint32_t*) p) [0] = (line >> 6 & mask) + offset; + ((uint32_t*) p) [1] = (line >> 2 & mask) + offset; p += row_bytes; } for ( int n = height >> 1; n--; ) { unsigned long line = *lines++; - ((unaligned_uint32_t*) p) [0].val = (line >> 4 & mask) + offset; - ((unaligned_uint32_t*) p) [1].val = (line & mask) + offset; + ((uint32_t*) p) [0] = (line >> 4 & mask) + offset; + ((uint32_t*) p) [1] = (line & mask) + offset; p += row_bytes; - ((unaligned_uint32_t*) p) [0].val = (line >> 6 & mask) + offset; - ((unaligned_uint32_t*) p) [1].val = (line >> 2 & mask) + offset; + ((uint32_t*) p) [0] = (line >> 6 & mask) + offset; + ((uint32_t*) p) [1] = (line >> 2 & mask) + offset; p += row_bytes; } if ( height & 1 ) { unsigned long line = *lines; - ((unaligned_uint32_t*) p) [0].val = (line >> 4 & mask) + offset; - ((unaligned_uint32_t*) p) [1].val = (line & mask) + offset; + ((uint32_t*) p) [0] = (line >> 4 & mask) + offset; + ((uint32_t*) p) [1] = (line & mask) + offset; } } } @@ -367,8 +366,8 @@ void Nes_Ppu_Rendering::check_sprite_hit( int begin, int end ) { // get pixels for line unsigned long line = lines [skip >> 1]; - unsigned long hit0 = ((unaligned_uint32_t*) bg) [0].val; - unsigned long hit1 = ((unaligned_uint32_t*) bg) [1].val; + unsigned long hit0 = ((uint32_t*) bg) [0]; + unsigned long hit1 = ((uint32_t*) bg) [1]; bg += next_row; line >>= skip << 1 & 2; line |= line >> 1; diff --git a/source/quickerNES/Nes_Ppu_Rendering.h b/source/quickerNES/Nes_Ppu_Rendering.h index 38ac8ed..63cf738 100644 --- a/source/quickerNES/Nes_Ppu_Rendering.h +++ b/source/quickerNES/Nes_Ppu_Rendering.h @@ -50,7 +50,7 @@ private: inline Nes_Ppu_Rendering::Nes_Ppu_Rendering() { sprite_limit = 8; - host_pixels = NULL; + host_pixels = nullptr; } inline void Nes_Ppu_Rendering::draw_sprites( int start, int count ) diff --git a/source/quickerNES/Nes_Ppu_Sprites.h b/source/quickerNES/Nes_Ppu_Sprites.h index 8d936f3..d5dd4dc 100644 --- a/source/quickerNES/Nes_Ppu_Sprites.h +++ b/source/quickerNES/Nes_Ppu_Sprites.h @@ -32,11 +32,11 @@ unsigned long const maskgen = 0x80808080 + zero; #define DRAW_PAIR( shift ) { \ int sprite_count = *scanlines; \ - CALC_FOUR( ((unaligned_uint32_t*) out) [0].val, (line >> (shift + 4)), out0 ) \ - CALC_FOUR( ((unaligned_uint32_t*) out) [1].val, (line >> shift), out1 ) \ + CALC_FOUR( ((uint32_t*) out) [0], (line >> (shift + 4)), out0 ) \ + CALC_FOUR( ((uint32_t*) out) [1], (line >> shift), out1 ) \ if ( sprite_count < this->max_sprites ) { \ - ((unaligned_uint32_t*) out) [0].val = out0; \ - ((unaligned_uint32_t*) out) [1].val = out1; \ + ((uint32_t*) out) [0] = out0; \ + ((uint32_t*) out) [1] = out1; \ } \ if ( CLIPPED ) visible--; \ out += next_row; \ diff --git a/source/quickerNES/audio/Effects_Buffer.cpp b/source/quickerNES/audio/Effects_Buffer.cpp index 7548610..0a8ef9a 100644 --- a/source/quickerNES/audio/Effects_Buffer.cpp +++ b/source/quickerNES/audio/Effects_Buffer.cpp @@ -22,11 +22,11 @@ typedef long fixed_t; const unsigned echo_size = 4096; const unsigned echo_mask = echo_size - 1; -BOOST_STATIC_ASSERT( (echo_size & echo_mask) == 0 ); // must be power of 2 +static_assert( (echo_size & echo_mask) == 0 ); // must be power of 2 const unsigned reverb_size = 8192 * 2; const unsigned reverb_mask = reverb_size - 1; -BOOST_STATIC_ASSERT( (reverb_size & reverb_mask) == 0 ); // must be power of 2 +static_assert( (reverb_size & reverb_mask) == 0 ); // must be power of 2 Effects_Buffer::config_t::config_t() { diff --git a/source/quickerNES/audio/Multi_Buffer.cpp b/source/quickerNES/audio/Multi_Buffer.cpp index 5e7e743..9c2746f 100644 --- a/source/quickerNES/audio/Multi_Buffer.cpp +++ b/source/quickerNES/audio/Multi_Buffer.cpp @@ -2,6 +2,7 @@ // Blip_Buffer 0.4.0. http://www.slack.net/~ant/ #include "Multi_Buffer.h" +#include /* Copyright (C) 2003-2006 Shay Green. This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -67,9 +68,9 @@ void Mono_Buffer::RestoreAudioBufferState() Silent_Buffer::Silent_Buffer() : Multi_Buffer( 1 ) // 0 channels would probably confuse { - chan.left = NULL; - chan.center = NULL; - chan.right = NULL; + chan.left = 0; + chan.center = 0; + chan.right = 0; } void Silent_Buffer::SaveAudioBufferState() @@ -192,7 +193,7 @@ void Stereo_Buffer::mix_stereo( blip_sample_t* out, long count ) right.begin( bufs [2] ); int bass = center.begin( bufs [0] ); - if (out != NULL) + if (out != 0) { while ( count-- ) { @@ -235,7 +236,7 @@ void Stereo_Buffer::mix_mono( blip_sample_t* out, long count ) Blip_Reader in; int bass = in.begin( bufs [0] ); - if (out != NULL) + if (out != 0) { while ( count-- ) { diff --git a/source/quickerNES/audio/Nes_Buffer.cpp b/source/quickerNES/audio/Nes_Buffer.cpp index e17ddee..8e8acf0 100644 --- a/source/quickerNES/audio/Nes_Buffer.cpp +++ b/source/quickerNES/audio/Nes_Buffer.cpp @@ -97,7 +97,7 @@ long Nes_Buffer::read_samples( blip_sample_t* out, long count ) int lin_bass = lin.begin( buf ); int nonlin_bass = nonlin.begin( tnd ); - if (out != NULL) + if (out != 0) { for ( int n = count; n--; ) { @@ -150,7 +150,7 @@ void Nes_Buffer::RestoreAudioBufferState() Nes_Nonlinearizer::Nes_Nonlinearizer() { - apu = NULL; + apu = nullptr; enabled = true; float const gain = 0x7fff * 1.3f; diff --git a/source/quickerNES/audio/Nes_Buffer.h b/source/quickerNES/audio/Nes_Buffer.h index 6d70fe4..d8a847b 100644 --- a/source/quickerNES/audio/Nes_Buffer.h +++ b/source/quickerNES/audio/Nes_Buffer.h @@ -7,6 +7,8 @@ #define NES_BUFFER_H #include "Multi_Buffer.h" +#include + class Nes_Apu; class Nes_Nonlinearizer { diff --git a/source/quickerNES/audio/Nes_Oscs.h b/source/quickerNES/audio/Nes_Oscs.h index a57ef71..e0ee853 100644 --- a/source/quickerNES/audio/Nes_Oscs.h +++ b/source/quickerNES/audio/Nes_Oscs.h @@ -11,6 +11,9 @@ class Nes_Apu; +typedef long nes_time_t; // CPU clock cycle count +typedef unsigned nes_addr_t; // 16-bit memory address + struct Nes_Osc { unsigned char regs [4]; diff --git a/source/quickerNES/audio/apu.cpp b/source/quickerNES/audio/apu.cpp index f1ac56f..119c037 100644 --- a/source/quickerNES/audio/apu.cpp +++ b/source/quickerNES/audio/apu.cpp @@ -21,8 +21,8 @@ Nes_Apu::Nes_Apu() : square2( &square_synth ) { dmc.apu = this; - dmc.prg_reader = NULL; - irq_notifier_ = NULL; + dmc.prg_reader = 0; + irq_notifier_ = 0; oscs [0] = &square1; oscs [1] = &square2; @@ -30,7 +30,7 @@ Nes_Apu::Nes_Apu() : oscs [3] = &noise; oscs [4] = &dmc; - output( NULL ); + output( 0 ); volume( 1.0 ); reset( false ); } diff --git a/source/quickerNES/audio/apu.h b/source/quickerNES/audio/apu.h index ad1a424..a488a99 100644 --- a/source/quickerNES/audio/apu.h +++ b/source/quickerNES/audio/apu.h @@ -5,11 +5,9 @@ // Nes_Snd_Emu 0.1.7 #include +#include +#include #include "blargg_endian.h" - -typedef long nes_time_t; // CPU clock cycle count -typedef unsigned nes_addr_t; // 16-bit memory address - #include "Nes_Oscs.h" class Nes_Apu { @@ -91,7 +89,7 @@ public: SWAP_LE( dmc.addr ); } }; - BOOST_STATIC_ASSERT( sizeof (apu_state_t) == 72 ); + static_assert( sizeof (apu_state_t) == 72 ); Nes_Apu(); ~Nes_Apu(); @@ -102,7 +100,7 @@ public: // Set memory reader callback used by DMC oscillator to fetch samples. // When callback is invoked, 'user_data' is passed unchanged as the // first parameter. - void dmc_reader( int (*callback)( void* user_data, nes_addr_t ), void* user_data = NULL ); + void dmc_reader( int (*callback)( void* user_data, nes_addr_t ), void* user_data = nullptr ); // All time values are the number of CPU clock cycles relative to the // beginning of the current time frame. Before resetting the CPU clock @@ -150,7 +148,7 @@ public: // Set IRQ time callback that is invoked when the time of earliest IRQ // may have changed, or NULL to disable. When callback is invoked, // 'user_data' is passed unchanged as the first parameter. - void irq_notifier( void (*callback)( void* user_data ), void* user_data = NULL ); + void irq_notifier( void (*callback)( void* user_data ), void* user_data = nullptr ); // Get time that APU-generated IRQ will occur if no further register reads // or writes occur. If IRQ is already pending, returns irq_waiting. If no @@ -162,7 +160,7 @@ public: // Count number of DMC reads that would occur if 'run_until( t )' were executed. // If last_read is not NULL, set *last_read to the earliest time that // 'count_dmc_reads( time )' would result in the same result. - int count_dmc_reads( nes_time_t t, nes_time_t* last_read = NULL ) const; + int count_dmc_reads( nes_time_t t, nes_time_t* last_read = nullptr ) const; // Time when next DMC memory read will occur nes_time_t next_dmc_read_time() const; diff --git a/source/quickerNES/audio/fme7/apu.h b/source/quickerNES/audio/fme7/apu.h index 28a26bc..2754fee 100644 --- a/source/quickerNES/audio/fme7/apu.h +++ b/source/quickerNES/audio/fme7/apu.h @@ -15,7 +15,7 @@ struct fme7_apu_state_t uint8_t latch; uint16_t delays [3]; // a, b, c }; -BOOST_STATIC_ASSERT( sizeof (fme7_apu_state_t) == 24 ); +static_assert( sizeof (fme7_apu_state_t) == 24 ); class Nes_Fme7_Apu : private fme7_apu_state_t { public: @@ -86,7 +86,7 @@ inline void Nes_Fme7_Apu::output( Blip_Buffer* buf ) inline Nes_Fme7_Apu::Nes_Fme7_Apu() { - output( NULL ); + output( 0 ); volume( 1.0 ); reset(); } diff --git a/source/quickerNES/audio/namco/apu.cpp b/source/quickerNES/audio/namco/apu.cpp index f2a0b04..1de4193 100644 --- a/source/quickerNES/audio/namco/apu.cpp +++ b/source/quickerNES/audio/namco/apu.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Nes_Namco_Apu::Nes_Namco_Apu() { - output( NULL ); + output( 0 ); volume( 1.0 ); reset(); } diff --git a/source/quickerNES/audio/vrc6/apu.cpp b/source/quickerNES/audio/vrc6/apu.cpp index 3d9464a..d7fdbd7 100644 --- a/source/quickerNES/audio/vrc6/apu.cpp +++ b/source/quickerNES/audio/vrc6/apu.cpp @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Nes_Vrc6_Apu::Nes_Vrc6_Apu() { - output( NULL ); + output( 0 ); volume( 1.0 ); reset(); } diff --git a/source/quickerNES/audio/vrc6/apu.h b/source/quickerNES/audio/vrc6/apu.h index e110ad1..4f236e0 100644 --- a/source/quickerNES/audio/vrc6/apu.h +++ b/source/quickerNES/audio/vrc6/apu.h @@ -73,7 +73,7 @@ struct vrc6_apu_state_t uint8_t phases [3]; uint8_t unused; }; -BOOST_STATIC_ASSERT( sizeof (vrc6_apu_state_t) == 20 ); +static_assert( sizeof (vrc6_apu_state_t) == 20 ); inline void Nes_Vrc6_Apu::osc_output( int i, Blip_Buffer* buf ) { diff --git a/source/quickerNES/audio/vrc7/apu.h b/source/quickerNES/audio/vrc7/apu.h index 27b5ed0..956235d 100644 --- a/source/quickerNES/audio/vrc7/apu.h +++ b/source/quickerNES/audio/vrc7/apu.h @@ -60,7 +60,7 @@ struct vrc7_snapshot_t int internal_opl_state_size; OPLL_STATE internal_opl_state; }; -BOOST_STATIC_ASSERT( sizeof (vrc7_snapshot_t) == 28 + 440 + 4 ); +static_assert( sizeof (vrc7_snapshot_t) == 28 + 440 + 4 ); inline void Nes_Vrc7::osc_output( int i, Blip_Buffer* buf ) { diff --git a/source/quickerNES/blargg_common.h b/source/quickerNES/blargg_common.h deleted file mode 100644 index 60dcf3e..0000000 --- a/source/quickerNES/blargg_common.h +++ /dev/null @@ -1,60 +0,0 @@ -// Sets up common environment for Shay Green's libraries. -// To change configuration options, modify blargg_config.h, not this file. - -// File_Extractor 1.0.0 -#ifndef BLARGG_COMMON_H -#define BLARGG_COMMON_H - -#include -#include -#include - -/* Pure virtual functions cause a vtable entry to a "called pure virtual" -error handler, requiring linkage to the C++ runtime library. This macro is -used in place of the "= 0", and simply expands to its argument. During -development, it expands to "= 0", allowing detection of missing overrides. */ -#define BLARGG_PURE( def ) def - -/* My code depends on ASCII anywhere a character or string constant is -compared with data read from a file, and anywhere file data is read and -treated as a string. */ -#if '\n'!=0x0A || ' '!=0x20 || '0'!=0x30 || 'A'!=0x41 || 'a'!=0x61 - #error "ASCII character set required" -#endif - -/* My code depends on int being at least 32 bits. Almost everything these days -uses at least 32-bit ints, so it's hard to even find a system with 16-bit ints -to test with. The issue can't be gotten around by using a suitable blargg_int -everywhere either, because int is often converted to implicitly when doing -arithmetic on smaller types. */ -#if UINT_MAX < 0xFFFFFFFF - #error "int must be at least 32 bits" -#endif - -// In case compiler doesn't support these properly. Used rarely. -#define STATIC_CAST(T,expr) static_cast (expr) - -// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. -#ifndef BOOST_STATIC_ASSERT -#ifdef _MSC_VER -// MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified -#define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / (int)!!(expr) - 1] ) -#else -// Some other compilers fail when declaring same function multiple times in class, -// so differentiate them by line -#define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) -#endif -#endif - -typedef struct -#ifdef NO_UNALIGNED_ACCESS -__attribute ((packed)) -#endif -{ - uint32_t val; -}unaligned_uint32_t; - - -#endif diff --git a/source/quickerNES/mappers/mapper001.hpp b/source/quickerNES/mappers/mapper001.hpp index 61fe1ac..19e94bd 100644 --- a/source/quickerNES/mappers/mapper001.hpp +++ b/source/quickerNES/mappers/mapper001.hpp @@ -3,8 +3,7 @@ // Nes_Emu 0.7.0. http://www.slack.net/~ant/ #include "Nes_Mapper.h" - -#include +#include /* Copyright (C) 2004-2006 Shay Green. This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -25,7 +24,7 @@ struct mmc1_state_t uint8_t bit; // number of bits in buffer (0 to 4) uint8_t buf; // currently buffered bits (new bits added to bottom) }; -BOOST_STATIC_ASSERT( sizeof (mmc1_state_t) == 6 ); +static_assert( sizeof (mmc1_state_t) == 6 ); class Mapper001 : public Nes_Mapper, mmc1_state_t { public: diff --git a/source/quickerNES/mappers/mapper004.hpp b/source/quickerNES/mappers/mapper004.hpp index f822df9..7c75251 100644 --- a/source/quickerNES/mappers/mapper004.hpp +++ b/source/quickerNES/mappers/mapper004.hpp @@ -4,7 +4,7 @@ #include "Nes_Mapper.h" -#include +#include #include "Nes_Core.h" /* Copyright (C) 2004-2006 Shay Green. This module is free software; you @@ -37,7 +37,7 @@ struct mmc3_state_t uint8_t irq_enabled;// last write was to 0) $e000, 1) $e001 uint8_t irq_flag; }; -BOOST_STATIC_ASSERT( sizeof (mmc3_state_t) == 15 ); +static_assert( sizeof (mmc3_state_t) == 15 ); class Mapper004 : public Nes_Mapper, mmc3_state_t { public: diff --git a/source/quickerNES/mappers/mapper005.hpp b/source/quickerNES/mappers/mapper005.hpp index c657e1f..80b360b 100644 --- a/source/quickerNES/mappers/mapper005.hpp +++ b/source/quickerNES/mappers/mapper005.hpp @@ -7,7 +7,7 @@ #include "Nes_Mapper.h" #include "Nes_Core.h" -#include +#include /* Copyright (C) 2004-2006 Shay Green. This module is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -26,8 +26,7 @@ struct mmc5_state_t uint8_t regs [0x30]; uint8_t irq_enabled; }; -// to do: finalize state format -BOOST_STATIC_ASSERT( sizeof (mmc5_state_t) == 0x31 ); +static_assert( sizeof (mmc5_state_t) == 0x31 ); // MMC5 diff --git a/source/quickerNES/mappers/mapper015.hpp b/source/quickerNES/mappers/mapper015.hpp index df994f1..e46e70f 100644 --- a/source/quickerNES/mappers/mapper015.hpp +++ b/source/quickerNES/mappers/mapper015.hpp @@ -25,7 +25,7 @@ struct Mapper015_state_t uint8_t mirroring; }; -BOOST_STATIC_ASSERT( sizeof (Mapper015_state_t) == 5 ); +static_assert( sizeof (Mapper015_state_t) == 5 ); // K-1029, K-1030P diff --git a/source/quickerNES/mappers/mapper019.hpp b/source/quickerNES/mappers/mapper019.hpp index 1db8dd4..8dd33b6 100644 --- a/source/quickerNES/mappers/mapper019.hpp +++ b/source/quickerNES/mappers/mapper019.hpp @@ -5,7 +5,6 @@ // Nes_Emu 0.7.0. http://www.slack.net/~ant/ #include "Nes_Mapper.h" - #include "blargg_endian.h" #include "audio/namco/apu.h" @@ -37,8 +36,7 @@ struct namco106_state_t set_le16( &sound_state.delays [i], sound_state.delays [i] ); } }; - -BOOST_STATIC_ASSERT( sizeof (namco106_state_t) == 20 + sizeof (namco_state_t) ); +static_assert( sizeof (namco106_state_t) == 20 + sizeof (namco_state_t) ); // Namco106 diff --git a/source/quickerNES/mappers/mapper021.hpp b/source/quickerNES/mappers/mapper021.hpp index e6ec509..b21f26d 100644 --- a/source/quickerNES/mappers/mapper021.hpp +++ b/source/quickerNES/mappers/mapper021.hpp @@ -40,8 +40,7 @@ struct vrc2_state_t uint16_t next_time; uint8_t irq_pending; }; - -BOOST_STATIC_ASSERT( sizeof ( vrc2_state_t ) == 18 ); +static_assert( sizeof ( vrc2_state_t ) == 18 ); template class Mapper_VRC2_4 : public Nes_Mapper, vrc2_state_t { diff --git a/source/quickerNES/mappers/mapper024.hpp b/source/quickerNES/mappers/mapper024.hpp index 00f3f1f..cf5451b 100644 --- a/source/quickerNES/mappers/mapper024.hpp +++ b/source/quickerNES/mappers/mapper024.hpp @@ -47,9 +47,7 @@ struct vrc6_state_t set_le16( &sound_state.delays [i], sound_state.delays [i] ); } }; -BOOST_STATIC_ASSERT( sizeof (vrc6_state_t) == 26 + sizeof (vrc6_apu_state_t) ); - - +static_assert( sizeof (vrc6_state_t) == 26 + sizeof (vrc6_apu_state_t) ); template class Mapper_Vrc6 : public Nes_Mapper, vrc6_state_t { diff --git a/source/quickerNES/mappers/mapper032.hpp b/source/quickerNES/mappers/mapper032.hpp index c534fd8..b64ac5d 100644 --- a/source/quickerNES/mappers/mapper032.hpp +++ b/source/quickerNES/mappers/mapper032.hpp @@ -32,8 +32,7 @@ struct mapper32_state_t uint8_t prg_mode; uint8_t mirr; }; - -BOOST_STATIC_ASSERT( sizeof ( mapper32_state_t ) == 12 ); +static_assert( sizeof ( mapper32_state_t ) == 12 ); // Irem_G101 diff --git a/source/quickerNES/mappers/mapper033.hpp b/source/quickerNES/mappers/mapper033.hpp index 1a5cb52..2fa5385 100644 --- a/source/quickerNES/mappers/mapper033.hpp +++ b/source/quickerNES/mappers/mapper033.hpp @@ -31,8 +31,7 @@ struct tc0190_state_t uint8_t creg [ 6 ]; uint8_t mirr; }; - -BOOST_STATIC_ASSERT( sizeof ( tc0190_state_t ) == 9 ); +static_assert( sizeof ( tc0190_state_t ) == 9 ); // TaitoTC0190 diff --git a/source/quickerNES/mappers/mapper069.hpp b/source/quickerNES/mappers/mapper069.hpp index 669c7b0..65d3d24 100644 --- a/source/quickerNES/mappers/mapper069.hpp +++ b/source/quickerNES/mappers/mapper069.hpp @@ -38,7 +38,7 @@ struct fme7_state_t set_le16( &sound_state.delays [i], sound_state.delays [i] ); } }; -BOOST_STATIC_ASSERT( sizeof (fme7_state_t) == 18 + sizeof (fme7_apu_state_t) ); +static_assert( sizeof (fme7_state_t) == 18 + sizeof (fme7_apu_state_t) ); // Fme7 diff --git a/source/quickerNES/mappers/mapper075.hpp b/source/quickerNES/mappers/mapper075.hpp index 05db0a1..e139605 100644 --- a/source/quickerNES/mappers/mapper075.hpp +++ b/source/quickerNES/mappers/mapper075.hpp @@ -26,8 +26,7 @@ struct vrc1_state_t uint8_t chr_banks_hi [ 2 ]; uint8_t mirroring; }; - -BOOST_STATIC_ASSERT( sizeof ( vrc1_state_t ) == 8 ); +static_assert( sizeof ( vrc1_state_t ) == 8 ); // VRC1 diff --git a/source/quickerNES/mappers/mapper085.hpp b/source/quickerNES/mappers/mapper085.hpp index 9fd70ab..24cd609 100644 --- a/source/quickerNES/mappers/mapper085.hpp +++ b/source/quickerNES/mappers/mapper085.hpp @@ -34,7 +34,7 @@ struct vrc7_state_t vrc7_snapshot_t sound_state; }; -BOOST_STATIC_ASSERT( sizeof (vrc7_state_t) == 20 + sizeof (vrc7_snapshot_t) ); +static_assert( sizeof (vrc7_state_t) == 20 + sizeof (vrc7_snapshot_t) ); // Vrc7 diff --git a/source/quickerNES/mappers/mapper088.hpp b/source/quickerNES/mappers/mapper088.hpp index cfdefcb..26e23d5 100644 --- a/source/quickerNES/mappers/mapper088.hpp +++ b/source/quickerNES/mappers/mapper088.hpp @@ -33,8 +33,7 @@ struct namco_34x3_state_t uint8_t mirr; uint8_t mode; }; - -BOOST_STATIC_ASSERT( sizeof (namco_34x3_state_t) == 10 ); +static_assert( sizeof (namco_34x3_state_t) == 10 ); template < bool _is154 > class Mapper_Namco_34x3 : public Nes_Mapper, namco_34x3_state_t { diff --git a/source/quickerNES/mappers/mapper156.hpp b/source/quickerNES/mappers/mapper156.hpp index f9cd005..9998db9 100644 --- a/source/quickerNES/mappers/mapper156.hpp +++ b/source/quickerNES/mappers/mapper156.hpp @@ -1,5 +1,4 @@ #include "Nes_Mapper.h" - #pragma once // DIS23C01 DAOU ROM CONTROLLER @@ -9,7 +8,7 @@ struct m156_state_t uint8_t prg_bank; uint8_t chr_banks [8]; }; -BOOST_STATIC_ASSERT( sizeof (m156_state_t) == 9 ); +static_assert( sizeof (m156_state_t) == 9 ); class Mapper156 : public Nes_Mapper, m156_state_t { public: diff --git a/source/quickerNES/mappers/mapper206.hpp b/source/quickerNES/mappers/mapper206.hpp index 205985e..f85890e 100644 --- a/source/quickerNES/mappers/mapper206.hpp +++ b/source/quickerNES/mappers/mapper206.hpp @@ -33,8 +33,7 @@ struct namco_34xx_state_t uint8_t mirr; uint8_t mode; }; - -BOOST_STATIC_ASSERT( sizeof (namco_34xx_state_t) == 10 ); +static_assert( sizeof (namco_34xx_state_t) == 10 ); // Namco_34xx diff --git a/source/quickerNES/mappers/mapper207.hpp b/source/quickerNES/mappers/mapper207.hpp index 2536938..2164f67 100644 --- a/source/quickerNES/mappers/mapper207.hpp +++ b/source/quickerNES/mappers/mapper207.hpp @@ -31,8 +31,7 @@ struct taito_x1005_state_t uint8_t creg [ 6 ]; uint8_t nametable [ 2 ]; }; - -BOOST_STATIC_ASSERT( sizeof (taito_x1005_state_t) == 11 ); +static_assert( sizeof (taito_x1005_state_t) == 11 ); // TaitoX1005 diff --git a/source/quickerNES/mappers/mapper244.hpp b/source/quickerNES/mappers/mapper244.hpp index 2847208..bbbdd57 100644 --- a/source/quickerNES/mappers/mapper244.hpp +++ b/source/quickerNES/mappers/mapper244.hpp @@ -32,8 +32,7 @@ struct mapper244_state_t uint8_t preg; uint8_t creg; }; - -BOOST_STATIC_ASSERT( sizeof (mapper244_state_t) == 2 ); +static_assert( sizeof (mapper244_state_t) == 2 ); class Mapper244 : public Nes_Mapper, mapper244_state_t { public: