#include #include "emuapi.h" #include "psram_t.h" #include "iopins.h" extern "C" { #include "shared.h" #include "defs.h" #include "regs.h" #include "lcd.h" #include "rc.h" #include "cpu.h" #include "mem.h" #include "hw.h" #include "rtc.h" #include "sound.h" #include "loader.h" } static int rom_offset = 0; #ifdef HAS_T41 EXTMEM static unsigned char MemPool[8*1024*1024]; extern "C" uint8 read_rom(int address) { return (MemPool[address+rom_offset]); } extern "C" void write_rom(int address, uint8 val) { MemPool[address]=val; } #else #ifdef HAS_PSRAM #include "psram_t.h" PSRAM_T psram = PSRAM_T(PSRAM_CS, PSRAM_MOSI, PSRAM_SCLK, PSRAM_MISO); extern "C" uint8 read_rom(int address) { return (psram.psread(address+rom_offset)); } extern "C" void write_rom(int address, uint8 val) { psram.pswrite(address,val); } #else DMAMEM static unsigned char MemPool[490*1024]; extern "C" uint8 read_rom(int address) { return (MemPool[address+rom_offset]); } extern "C" void write_rom(int address, uint8 val) { MemPool[address]=val; } #endif #endif void emu_KeyboardOnDown(int keymodifer, int key) { } void emu_KeyboardOnUp(int keymodifer, int key) { } void gbe_Init(void) { emu_printf("Allocating MEM"); #ifdef HAS_PSRAM psram.begin(); #endif mem_init(); emu_printf("Allocating MEM done"); } static int hk = 0; static int k = 0; void gbe_Input(int click) { hk = emu_ReadI2CKeyboard(); k = emu_ReadKeys(); } static char buf[0x1000]; extern "C" int loadfile(char * filename); int loadfile(char * filename) { int romsize = emu_FileSize(filename); int pos = 0; int n; int i; if (emu_FileOpen(filename)) { while ( (n = emu_FileRead(buf,sizeof(buf))) ) { for (int i=0; i 0 && R_LY < YRES) cpu_emulate(cpu.lcdc); rtc_tick(); //emu_printi(emu_FrameSkip()); emu_DrawVsync(); } void SND_Process(void *stream, int len) { #ifdef SOUND_PRESENT #ifdef HAS_SND audio_play_sample(stream, 0, len); #endif #endif }