diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-04-27 20:00:53 +0200 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-04-27 20:00:53 +0200 |
commit | 20050fb66886f96b38e0cb14ac147434b638005d (patch) | |
tree | 0d12800e4c2c0b0cbef6ef493d94e4627d1a368c /src | |
parent | 81e98b5e129f7018f1379d04ad42c0dc1ca5420b (diff) |
quick attempt at supercard emulation. really ugly
Diffstat (limited to 'src')
-rw-r--r-- | src/NDSCart.cpp | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index 5cca87c..411d773 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -1098,8 +1098,10 @@ void ROMPrepareData(u32 param) NDS::CheckDMAs(0, 0x05); } +u32 sc_addr = 0; + void WriteROMCnt(u32 val) -{printf("ROMCNT %08X %08X %04X\n", val, ROMCnt, SPICnt); +{ ROMCnt = (val & 0xFF7F7FFF) | (ROMCnt & 0x00800000); if (!(SPICnt & (1<<15))) return; @@ -1153,11 +1155,11 @@ void WriteROMCnt(u32 val) *(u32*)&cmd[4] = *(u32*)&ROMCommand[4]; } - printf("ROM COMMAND %04X %08X %02X%02X%02X%02X%02X%02X%02X%02X SIZE %04X\n", + /*printf("ROM COMMAND %04X %08X %02X%02X%02X%02X%02X%02X%02X%02X SIZE %04X\n", SPICnt, ROMCnt, cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5], cmd[6], cmd[7], - datasize); + datasize);*/ switch (cmd[0]) { @@ -1203,6 +1205,42 @@ void WriteROMCnt(u32 val) } break; + + // SUPERCARD EMULATION TEST + // TODO: INTEGRATE BETTER!!!! + + case 0x70: // init??? returns whether SDHC addressing should be used + for (u32 pos = 0; pos < DataOutLen; pos += 4) + *(u32*)&DataOut[pos] = 0; + break; + + case 0x53: // set address for read + sc_addr = (cmd[1]<<24) | (cmd[2]<<16) | (cmd[3]<<8) | cmd[4]; + printf("SUPERCARD: read %08X\n", sc_addr); + break; + + case 0x80: // read operation busy, I guess + // TODO: make it take some time + for (u32 pos = 0; pos < DataOutLen; pos += 4) + *(u32*)&DataOut[pos] = 0; + break; + + case 0x81: // read data + { + if (DataOutLen != 0x200) + printf("SUPERCARD: BOGUS READ %d\n", DataOutLen); + + // TODO: this is really inefficient. just testing + FILE* f = fopen("scsd.bin", "rb"); + fseek(f, sc_addr, SEEK_SET); + fread(DataOut, 1, 0x200, f); + fclose(f); + } + break; + + // SUPERCARD EMULATION TEST END + + default: switch (cmd[0] & 0xF0) { |