int main(int argc, char *argv[]) { cart_load("tests/cpu_instrs.gb"); mem_alloc(); cpu_bios_init(); for(uint32_t i = 0; i < 28000000; ++i) { step(); } printf("\n\nEND OF LINE\n"); mem_free(); cart_free(); return 0; }
void cart_open(char *fname,int memmap) { int flip,i; char *p; cart_free(); if(*fname=='*') { cart.isdocalls=1; fname++; } if(*fname=='!') { memmap=1; fname++; } memset(&cart,0,sizeof(cart)); strcpy(cart.cartname,fname); strcpy(cart.symname,fname); p=strchr(cart.symname,'.'); if(p) strcpy(p,".sym"); else strcat(cart.symname,".sym"); flip=cart_check(fname); if(flip<0) { if(flip==-1) exception("File '%s' could not be opened.",fname); else exception("File '%s' format unrecognized.",fname); cart_dummy(); return; } if(flip==0x0123 && memmap) { if(cart_map(fname)) { exception("Error %i mapping file.",GetLastError()); cart_dummy(); return; } } else { if(cart_load(fname)) { exception("Error %i loading file.",GetLastError()); cart_dummy(); return; } cart_flip(flip); } // get title (reverseswap) for(i=0;i<20;i++) cart.title[i]=cart.data[0x20+(i^3)]; if(cart.mapped) print("ROM image '%s' mapped (%iMB): "YELLOW"%s\n",fname,cart.size/1024/1024,cart.title); else print("ROM image '%s' loaded (%iMB): "YELLOW"%s\n",fname,cart.size/1024/1024,cart.title); }