コード例 #1
0
void write_MBC2(uint16_t addr, uint8_t val) {
    
    switch (addr & 0xF000) {
        case 0x0000:
        case 0x1000: // Activate/Deactivate RAM banking
                    // If deactivating, save to file,
                    if ((addr & 0x100) == 0x0) {
                        if (battery && ram_banking && ((val & 0xF) != 0xA)) {
                            write_SRAM();
                        }
                        ram_banking = ((val & 0xF) == 0xA);
                    }
                    break;
        case 0x2000:
        case 0x3000:/* Set ROM bank */
                    if ((addr & 0x100) != 0x0) {
                        cur_ROM_bank = (val & 0xF) + ((val & 0xF) == 0);
                    }
                    break;
        
        case 0xA000: // Write to RAM bank if RAM banking enabled
                    if (ram_banking) {
                        RAM_banks[0][addr & 0x1FF] = val & 0xF; 
                    }
                    break;
    }    
}
コード例 #2
0
ファイル: main.c プロジェクト: RossMeikleham/PlutoBoy
int main(int argc, char **argv) {

    int debug = 0;
    int cgb_mode = 1;
    //char file_name[1024] = "sdmc:/rom.gb";
    
    char file_name[1024];
    if (!selectFile(&cgb_mode, file_name)) {
        cleanup();
        return 0;
    };

    ClientOrServer cs = NO_CONNECT;
   
    set_log_level(LOG_INFO);

    if (!init_emu(file_name, debug, !cgb_mode, cs)) {
        log_message(LOG_ERROR, "Failed to initialize emulator\n");
        cleanup();
        return 1;
    }
    
    log_message(LOG_INFO, "Running emu\n");
    run();

    write_SRAM();
    cleanup();
	return 0;
}
コード例 #3
0
/* Update current state of GameBoy keys as well as control
 * other external actions for the emulator */
void update_keys() {
        SDL_Event event;
        if (SDL_PollEvent(&event)) {
            switch (event.type) {
                    // exit if the window is closed
                case SDL_QUIT:
                            write_SRAM();
                            exit(0);
                            break;
#ifndef PSP
                case SDL_KEYDOWN: // Key pressed
                    keys[event.key.keysym.sym] = 1;
                    if (keys[SDLK_ESCAPE]) {
                        write_SRAM();
                        exit(0);
                    }
                        break;

                case SDL_KEYUP: //Key "unpressed"
                    keys[event.key.keysym.sym] = 0;
                    break;
#endif

#ifdef PSP
                  
                case SDL_JOYBUTTONDOWN:
                    keys[event.jbutton.button] = 1; 
                    break;
                case SDL_JOYBUTTONUP:
                    keys[event.jbutton.button] = 0;
                    break;
#endif
                
             }
        } 
}