/*スーパーカセットビジョンROMリーダー*/ /*2006.1.8 Y.Nemoto*/ #include #include //#include //P40-P47 -> D0-7 & A8-15 &vA0-7 //PA0 74HC138 bit0 //PA1 74HC138 bit1 //PA2 74HC138 bit2 //PA3 74HC245 _OE //PA4 74HC245 DIR(1:A(H8)->B(SCV) 0:B->A) //PA0-2: 0 A15-8 LOAD CK // 1 A7-0 LOAD CK // 2 SCV _RD // 3 SCV _WR void WritePrg(int ad,unsigned char v); unsigned char ReadPrg(int ad); void SetAddr(int ad); //BIOSCOPY 21bytes from www2.odn.ne.jp/~haf09260/Scv/EnrScv.htm unsigned char BIOSCOPY[]={0x48,0x48,0x24,0x34,0,0,0x24,0,0x90,0x14,0xfe,0x0f,0x31,0x52,0xfd,0x34, 0,0x36,0x7f,0xb0,0xfa}; #define BCSIZE 21 int main(int argc, char **argv) { int qflag; int n; int i,j,ofset; int fd,filesize,size; unsigned char bv; unsigned char *dram; char path[64]; PADDR=0xFF; //PortAは全て出力 P4DDR=0xFF; //Port4は最初は出力 PADR=0xFF; P4DR=0xFF; if (argc == 1){ printf("SCV romfile : ROMを読み出してromfileに保存(32KB only)\r"); printf("SCV -d : ROM先頭をダンプ\r"); printf("SCV -bs : RAMカートリッジからBIOSを読み出して保存\r"); printf("SCV -w romfile : RAMカートリッジにromfileを書き込み(最大32KB)\r"); exit(); } if (argv[1][0] != '-'){ strcpy(path,"/ram0/"); strcat(path,argv[1]); printf("Save:%s\r",path); fd=open(path,OptWrite); dram=malloc(0x4000); ofset=0x8000; for(j=0;j<2;j++){ for(i=0;i<0x4000;i++){ dram[i]=ReadPrg(i+ofset); } ofset+=0x4000; write(fd,dram,0x4000); } close(fd); free(dram); } if (strcmp(argv[1],"-b")==0){ for(i=0;i>8; PADR=0x00 | 0x00 | 0x10 | 0xe0; PADR=0x07 | 0x00 | 0x10 | 0xe0; P4DR=ad & 0xff; PADR=0x01 | 0x00 | 0x10 | 0xe0; PADR=0x07 | 0x00 | 0x10 | 0xe0; //PADR=0xff; }