aboutsummaryrefslogblamecommitdiff
path: root/src/bin.rs
blob: 8ced9d7fa7a22aa7da643078bde0ae91056d401d (plain) (tree)
1
2
3
4
5
6
7
8
                  


                  
                        
                                

                                   




                        
                                  

                            
 













                                                 
                          

















                                                                                   

































                                                                                   
                      




                                       
                                 


                                 









                                                  

 
                        
                                                  
                       

                                                           
                                                                           



                                                        


                                                      
                                                       


                                                         






                                                                                
                                                                 

                                                  
          

                                            











                                                       

                                    
           
     
 
             
                                
                       

                                              
                         
                                                                                    

                                
                                                            

                                                                           

                                                          

                                                                            
                  




                       

 

                                       
                                       
                                                                

 
                                        






                                                                                     
                                    



                                 
             
                             
         

     




                                                                                                     
                                               
                                     






                                                                                          
                                    
                                                           















                       
           




















                                                                         
                                             















                                                                  
      





                                              
      
                                                                  
      





                                              
      
                                        

                                         
                                                                                       

                                                       
                                            
                                                           




                                                                        
          
                             
                              
         
                   
     
 
extern crate core;

use std::fs::File;
use std::io::Read;
use core::cell::RefCell;
use core::intrinsics::transmute;
use std::time::{Instant, Duration};
use std::thread::sleep;

extern crate sdl2;

use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sdl2::pixels::PixelFormatEnum;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;

mod memory;
#[macro_use] mod mos6502;
mod ppu;
mod cartridge;
mod mapper;
mod controller;
mod disasm;

use mos6502::CPU;
use ppu::PPU;
use memory::{CPUMemory, PPUMemory};
use cartridge::{BankType, MirrorType, Cartridge};
use controller::stdctl;

const PIXEL_SIZE: u32 = 2;
const RGB_COLORS: [u32; 64] = [
    0x666666, 0x002a88, 0x1412a7, 0x3b00a4, 0x5c007e, 0x6e0040, 0x6c0600, 0x561d00,
    0x333500, 0x0b4800, 0x005200, 0x004f08, 0x00404d, 0x000000, 0x000000, 0x000000,
    0xadadad, 0x155fd9, 0x4240ff, 0x7527fe, 0xa01acc, 0xb71e7b, 0xb53120, 0x994e00,
    0x6b6d00, 0x388700, 0x0c9300, 0x008f32, 0x007c8d, 0x000000, 0x000000, 0x000000,
    0xfffeff, 0x64b0ff, 0x9290ff, 0xc676ff, 0xf36aff, 0