mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-30 00:14:15 +01:00
remove duplicate code for F4,F6 & F8 mapper
This commit is contained in:
parent
53b71f9108
commit
8bd6d7dfdc
@ -181,7 +181,7 @@ void readDataArray_2600(uint16_t addr, uint16_t size) {
|
||||
|
||||
void readSegmentF8_2600(uint16_t startaddr, uint16_t endaddr, uint16_t bankaddr) {
|
||||
for (uint16_t addr = startaddr; addr < endaddr; addr += 512) {
|
||||
for (int w = 0; w < 512; w++) {
|
||||
for (uint16_t w = 0; w < 512; w++) {
|
||||
if (addr > 0x1FF9) // SET BANK ADDRESS FOR 0x1FFA-0x1FFF
|
||||
readData_2600(bankaddr);
|
||||
uint8_t temp = readData_2600(addr + w);
|
||||
@ -191,6 +191,25 @@ void readSegmentF8_2600(uint16_t startaddr, uint16_t endaddr, uint16_t bankaddr)
|
||||
}
|
||||
}
|
||||
|
||||
void readSegmentE7_2600(uint8_t start, uint8_t end) {
|
||||
for (uint8_t x = start; x <= end; x++) {
|
||||
readData_2600(0x1FE0 + x);
|
||||
readSegment_2600(0x1000, 0x1800);
|
||||
}
|
||||
}
|
||||
|
||||
void readSegmentFx_2600(bool hasRAM, uint16_t size) {
|
||||
if(hasRAM) {
|
||||
outputFF_2600(0x100); // Skip 0x1000-0x10FF RAM
|
||||
readDataArray_2600(0x1100, 0x100);
|
||||
} else {
|
||||
readSegment_2600(0x1000, 0x1200);
|
||||
}
|
||||
readSegment_2600(0x1200, 0x1E00);
|
||||
// Split Read of Last 0x200 bytes
|
||||
readDataArray_2600(0x1E00, size);
|
||||
}
|
||||
|
||||
void outputFF_2600(uint16_t size) {
|
||||
memset(sdBuffer, 0xFF, size * sizeof(sdBuffer[0]));
|
||||
myFile.write(sdBuffer, size);
|
||||
@ -261,14 +280,11 @@ void writeData3F_2600(uint16_t addr, uint8_t data) {
|
||||
}
|
||||
|
||||
// E7 Mapper Check - Check Bank for FFs
|
||||
boolean checkE7(int bank) {
|
||||
boolean checkE7(uint16_t bank) {
|
||||
writeData_2600(0x1800, 0xFF);
|
||||
readData_2600(0x1FE0 + bank);
|
||||
uint32_t testdata = (readData_2600(0x1000) << 24) | (readData_2600(0x1001) << 16) | (readData_2600(0x1002) << 8) | (readData_2600(0x1003));
|
||||
if (testdata == 0xFFFFFFFF)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (testdata == 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void readROM_2600() {
|
||||
@ -384,33 +400,18 @@ void readROM_2600() {
|
||||
break;
|
||||
|
||||
case 0xE7: // E7 Mapper 8KB/12KB/16KB
|
||||
writeData_2600(0x1800, 0xFF);
|
||||
// Check Bank 0 - If 0xFFs then Bump 'n' Jump
|
||||
if (checkE7(0)) { // Bump 'n' Jump 8K
|
||||
writeData_2600(0x1800, 0xFF);
|
||||
|
||||
for (int x = 4; x < 7; x++) { // Banks 4-6
|
||||
readData_2600(0x1FE0 + x);
|
||||
readSegment_2600(0x1000, 0x1800);
|
||||
}
|
||||
readSegmentE7_2600(4, 6); // Banks 4-6
|
||||
}
|
||||
// Check Bank 3 - If 0xFFs then BurgerTime
|
||||
else if (checkE7(3)) { // BurgerTime 12K
|
||||
writeData_2600(0x1800, 0xFF);
|
||||
for (int x = 0; x < 2; x++) { // Banks 0+1
|
||||
readData_2600(0x1FE0 + x);
|
||||
readSegment_2600(0x1000, 0x1800);
|
||||
}
|
||||
for (int x = 4; x < 7; x++) { // Banks 4-6
|
||||
readData_2600(0x1FE0 + x);
|
||||
readSegment_2600(0x1000, 0x1800);
|
||||
}
|
||||
readSegmentE7_2600(0, 1); // Banks 0+1
|
||||
readSegmentE7_2600(4, 6); // Banks 4-6
|
||||
}
|
||||
else { // Masters of the Universe (or Unknown Cart) 16K
|
||||
writeData_2600(0x1800, 0xFF);
|
||||
for (int x = 0; x < 7; x++) { // Banks 0-6
|
||||
readData_2600(0x1FE0 + x);
|
||||
readSegment_2600(0x1000, 0x1800);
|
||||
}
|
||||
readSegmentE7_2600(0, 6); // Banks 0-6
|
||||
}
|
||||
readSegment_2600(0x1800, 0x2000); // Bank 7
|
||||
break;
|
||||
@ -426,15 +427,7 @@ void readROM_2600() {
|
||||
case 0xF4: // F4 Mapper 32KB
|
||||
for (int x = 0; x < 8; x++) {
|
||||
readData_2600(0x1FF4 + x);
|
||||
if(a2600mapper == 0xF4) {
|
||||
readSegment_2600(0x1000, 0x1200);
|
||||
} else {
|
||||
outputFF_2600(0x100); // Skip 0x1000-0x10FF RAM
|
||||
readDataArray_2600(0x1100, 0x100);
|
||||
}
|
||||
readSegment_2600(0x1200, 0x1E00);
|
||||
// Split Read of Last 0x200 bytes
|
||||
readDataArray_2600(0x1E00, 0x1F4);
|
||||
readSegmentFx_2600(a2600mapper == 0x04, 0x1F4);
|
||||
for (int z = 0; z < 12; z++) {
|
||||
// Set Bank to ensure 0x1FFC-0x1FFF is correct
|
||||
readData_2600(0x1FF4 + x);
|
||||
@ -448,15 +441,7 @@ void readROM_2600() {
|
||||
case 0xF6: // F6 Mapper 16KB
|
||||
for (int w = 0; w < 4; w++) {
|
||||
readData_2600(0x1FF6 + w);
|
||||
if(a2600mapper == 0xF6) {
|
||||
readSegment_2600(0x1000, 0x1200);
|
||||
} else {
|
||||
outputFF_2600(0x100); // Skip 0x1000-0x10FF RAM
|
||||
readDataArray_2600(0x1100, 0x100);
|
||||
}
|
||||
readSegment_2600(0x1200, 0x1E00);
|
||||
// Split Read of Last 0x200 bytes
|
||||
readDataArray_2600(0x1E00, 0x1F6);
|
||||
readSegmentFx_2600(a2600mapper == 0x06, 0x1F6);
|
||||
// Bank Registers 0x1FF6-0x1FF9
|
||||
for (int y = 0; y < 4; y++){
|
||||
readData_2600(0x1FFF); // Reset Bank
|
||||
@ -477,15 +462,7 @@ void readROM_2600() {
|
||||
case 0xF8: // F8 Mapper 8KB
|
||||
for (int w = 0; w < 2; w++) {
|
||||
readData_2600(0x1FF8 + w);
|
||||
if(a2600mapper == 0xF8) {
|
||||
readSegment_2600(0x1000, 0x1200);
|
||||
} else {
|
||||
outputFF_2600(0x100); // Skip 0x1000-0x10FF RAM
|
||||
readDataArray_2600(0x1100, 0x100);
|
||||
}
|
||||
readSegment_2600(0x1200, 0x1E00);
|
||||
// Split Read of Last 0x200 bytes
|
||||
readDataArray_2600(0x1E00, 0x1F8);
|
||||
readSegmentFx_2600(a2600mapper == 0x08, 0x1F8);
|
||||
// Bank Registers 0x1FF8-0x1FF9
|
||||
for (int y = 0; y < 2; y++){
|
||||
readData_2600(0x1FFF); // Reset Bank
|
||||
|
Loading…
Reference in New Issue
Block a user