diff --git a/source/core/Nes_Apu.h b/source/core/Nes_Apu.h index 6a7ea67..60c1983 100644 --- a/source/core/Nes_Apu.h +++ b/source/core/Nes_Apu.h @@ -32,12 +32,12 @@ public: // count, call end_frame( last_cpu_time ). // Write to register (0x4000-0x4017, except 0x4014 and 0x4016) - enum { start_addr = 0x4000 }; - enum { end_addr = 0x4017 }; + static const uint16_t start_addr = 0x4000; + static const uint16_t end_addr = 0x4017; void write_register( nes_time_t, nes_addr_t, int data ); // Read from status register at 0x4015 - enum { status_addr = 0x4015 }; + static const uint16_t status_addr = 0x4015; int read_status( nes_time_t ); // Run all oscillators up to specified time, end current time frame, then @@ -67,7 +67,7 @@ public: // the specified oscillator is muted and emulation accuracy is reduced. // The oscillators are indexed as follows: 0) Square 1, 1) Square 2, // 2) Triangle, 3) Noise, 4) DMC. - enum { osc_count = 5 }; + static const uint16_t osc_count = 5; void osc_output( int index, Blip_Buffer* buffer ); // Set IRQ time callback that is invoked when the time of earliest IRQ @@ -78,8 +78,8 @@ public: // 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 // IRQ will occur, returns no_irq. - enum { no_irq = LONG_MAX / 2 + 1 }; - enum { irq_waiting = 0 }; + static const uint64_t no_irq = LONG_MAX / 2 + 1; + static const uint16_t irq_waiting = 0; nes_time_t earliest_irq( nes_time_t ) const; // Count number of DMC reads that would occur if 'run_until( t )' were executed. diff --git a/source/core/Nes_Emu.h b/source/core/Nes_Emu.h index 5e7888e..f4fb5d1 100644 --- a/source/core/Nes_Emu.h +++ b/source/core/Nes_Emu.h @@ -28,17 +28,17 @@ public: // Size and depth of graphics buffer required for rendering. Note that this // is larger than the actual image, with a temporary area around the edge // that gets filled with junk. - enum { buffer_width = Nes_Ppu::buffer_width }; - int buffer_height() const { return buffer_height_; } - enum { bits_per_pixel = 8 }; + static const uint16_t buffer_width = Nes_Ppu::buffer_width; + uint16_t buffer_height() const { return buffer_height_; } + static const uint8_t bits_per_pixel = 8; // Set graphics buffer to render pixels to. Pixels points to top-left pixel and // row_bytes is the number of bytes to get to the next line (positive or negative). void set_pixels( void* pixels, long row_bytes ); // Size of image generated in graphics buffer - enum { image_width = 256 }; - enum { image_height = 240 }; + static const uint16_t image_width = 256; + static const uint16_t image_height = 240; const uint8_t* getHostPixels () const { return emu.ppu.host_pixels; } @@ -56,11 +56,13 @@ public: virtual const char * emulate_skip_frame( int joypad1, int joypad2 = 0 ); // Maximum size of palette that can be generated - enum { max_palette_size = 256 }; + static const uint16_t max_palette_size = 256; // Result of current frame struct frame_t { + static const uint8_t left = 8; + int joypad_read_count; // number of times joypads were strobed (read) int burst_phase; // NTSC burst phase for frame (0, 1, or 2) @@ -68,7 +70,6 @@ public: int chan_count; // 1: mono, 2: stereo int top; // top-left position of image in graphics buffer - enum { left = 8 }; unsigned char* pixels; // pointer to top-left pixel of image long pitch; // number of bytes to get to next row of image diff --git a/source/core/Nes_Ppu_Impl.h b/source/core/Nes_Ppu_Impl.h index 1a27218..c336316 100644 --- a/source/core/Nes_Ppu_Impl.h +++ b/source/core/Nes_Ppu_Impl.h @@ -23,33 +23,34 @@ public: void save_state( Nes_State_* out ) const; void load_state( Nes_State_ const& ); - enum { image_width = 256 }; - enum { image_height = 240 }; - enum { image_left = 8 }; - enum { buffer_width = image_width + 16 }; - enum { buffer_height = image_height }; + static const uint16_t image_width = 256; + static const uint16_t image_height = 240; + static const uint16_t image_left = 8; + static const uint16_t buffer_width = image_width + 16; + static const uint16_t buffer_height = image_height; int write_2007( int ); // Host palette - enum { palette_increment = 64 }; + static const uint8_t palette_increment = 64; short* host_palette; int palette_begin; int max_palette_size; int palette_size; // set after frame is rendered // Mapping - enum { vaddr_clock_mask = 0x1000 }; + static const uint16_t vaddr_clock_mask = 0x1000; void set_nt_banks( int bank0, int bank1, int bank2, int bank3 ); void set_chr_bank( int addr, int size, long data ); void set_chr_bank_ex( int addr, int size, long data ); // Nametable and CHR RAM - enum { nt_ram_size = 0x1000 }; - enum { chr_addr_size = 0x2000 }; - enum { bytes_per_tile = 16 }; - enum { chr_tile_count = chr_addr_size / bytes_per_tile }; - enum { mini_offscreen_height = 16 }; // double-height sprite + static const uint16_t nt_ram_size = 0x1000; + static const uint16_t chr_addr_size = 0x2000; + static const uint8_t bytes_per_tile = 16; + static const uint16_t chr_tile_count = chr_addr_size / bytes_per_tile; + static const uint8_t mini_offscreen_height = 16; // double-height sprite + struct impl_t { uint8_t nt_ram [nt_ram_size]; @@ -60,7 +61,8 @@ public: }; }; impl_t* impl; - enum { scanline_len = 341 }; + + static const uint16_t scanline_len = 341; protected: uint8_t spr_ram [0x100]; @@ -73,7 +75,7 @@ protected: //friend class Nes_Ppu; private: int addr_inc; // pre-calculated $2007 increment (based on w2001 & 0x04) int read_2007( int addr ); - enum { last_sprite_max_scanline = 240 }; + static const uint16_t last_sprite_max_scanline = 240; long recalc_sprite_max( int scanline ); int first_opaque_sprite_line(); @@ -99,7 +101,7 @@ private: int sprite_tile_index( uint8_t const* sprite ) const; // Mapping - enum { chr_page_size = 0x400 }; + static const uint16_t chr_page_size = 0x400; long chr_pages [chr_addr_size / chr_page_size]; long chr_pages_ex [chr_addr_size / chr_page_size]; long map_chr_addr( unsigned a ) /*const*/ diff --git a/source/core/abstract_file.h b/source/core/abstract_file.h index 663d829..99af53a 100644 --- a/source/core/abstract_file.h +++ b/source/core/abstract_file.h @@ -26,8 +26,8 @@ private: // Write data to memory class Mem_Writer : public Data_Writer { char* data_; - long size_; - long allocated; + size_t size_; + size_t allocated; enum { expanding, fixed, ignore_excess } mode; public: // Keep all written data in expanding block of memory @@ -43,7 +43,7 @@ public: char* data() { return data_; } // Number of bytes written - long size() const { return size_; } + size_t size() const { return size_; } ~Mem_Writer(); }; diff --git a/source/player.cpp b/source/player.cpp index 7cdad23..20493bd 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -73,8 +73,6 @@ int main(int argc, char *argv[]) // Creating emulator instance auto e = EmuInstance(romFilePath, stateFilePath); - auto stateHash = e.getStateHash(); - // Creating playback instance auto p = PlaybackInstance(&e, sequence);