Skip to content

Commit

Permalink
Update MSX.ino
Browse files Browse the repository at this point in the history
Added support for the Hudson Soft Bee Pack and Bee Cards.

Requires a Hudson Soft Bee Pack inserted into the MSX Adapter.

Be sure to fully insert the Bee Card into the Bee Pack.

Select Mapper 14 "Hudson Soft Bee Pack" and set the ROM size (16K/32K).
  • Loading branch information
sakman55 authored Nov 5, 2024
1 parent 5aa6678 commit d6dd621
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions Cart_Reader/MSX.ino
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static const byte PROGMEM msxmapsize[] = {
11, 0, 4, 2, 2, // PAC 0K/FM-PAC 64K [sram r/w] 8K
12, 7, 7, 0, 0, // R-Type 384K
13, 5, 5, 0, 0, // Super Lode Runner (Irem) 128K
14, 2, 3, 0, 0, // Hudson Soft Bee Pack
};

// MSX1 = 8,16,32,128,256
Expand All @@ -99,7 +100,7 @@ byte MSXRAM[] = { 0, 2, 8, 16, 32 };
byte msxramlo = 0; // Lowest Entry
byte msxramhi = 4; // Highest Entry

byte msxmapcount = 14; // (sizeof(mapsize)/sizeof(mapsize[0])) / 5;
byte msxmapcount = 15; // (sizeof(mapsize)/sizeof(mapsize[0])) / 5;
boolean msxmapfound = false;
byte msxmapselect;
int msxindex;
Expand Down Expand Up @@ -400,7 +401,7 @@ void readROM_MSX() {
CS2_DISABLE;
break;

case 4: // Game Master 2 (128K)
case 4: // Game Master 2 (128K)
readSegment_MSX(0x4000, 0x6000); // 8K Fixed Bank 0
writeData_MSX(0x6000, 1); // Set Bank 1 for subsequent reads
readSegment_MSX(0x6000, 0x8000); // 8K Init Bank 1
Expand Down Expand Up @@ -450,7 +451,7 @@ void readROM_MSX() {
CS2_DISABLE;
break;

case 8: // Konami MegaROM without SCC
case 8: // Konami MegaROM without SCC
readSegment_MSX(0x4000, 0x6000); // 8K Fixed Bank 0
readSegment_MSX(0x6000, 0x8000); // 8K Init Bank 1
msxbanks = int_pow(2, msxsize - 1);
Expand Down Expand Up @@ -514,6 +515,17 @@ void readROM_MSX() {
CS2_DISABLE;
MERQ_DISABLE;
break;

case 14: // Hudson Soft Bee Pack (16K/32K)
CS1_ENABLE;
readSegment_MSX(0x4000,0x8000); // 16K Bank 0
CS1_DISABLE;
if (msxsize == 3) { // 32K
CS2_ENABLE;
readSegment_MSX(0x8000, 0xC000); // +16K Bank 1
CS2_DISABLE;
}
break;
}
myFile.close();

Expand Down Expand Up @@ -618,15 +630,15 @@ void readRAM_MSX() {
writeData_MSX(0x7000, 0); // SRAM Disable
break;

case 2: // ASCII16 (2K/8K)
case 2: // ASCII16 (2K/8K)
writeData_MSX(0x7000, 0x10); // Bit 4 Enable
readSegment_MSX(0x8000, 0x8800); // 2K - Hydlide 2 & Daisenryaku (2K)
if (msxramsize == 2) // A-Train (8K)
readSegment_MSX(0x8800, 0xA000); // +6K = 8K
writeData_MSX(0x7000, 0); // SRAM Disable
break;

case 4: // Game Master 2 (8K)
case 4: // Game Master 2 (8K)
writeData_MSX(0xA000, 0x10); // Bit 4 Enable, Bit 5 SRAM Segment 0
readSegment_MSX(0xB000, 0xC000); // 4K
writeData_MSX(0xA000, 0x30); // Bit 4 Enable, Bit 5 SRAM Segment 1
Expand Down Expand Up @@ -667,7 +679,7 @@ void readRAM_MSX() {
writeData_MSX(0x7000, 0); // SRAM Disable
break;

case 11: // PAC/FM-PAC (8K)
case 11: // PAC/FM-PAC (8K)
writeData_MSX(0x5FFE, 0x4D); // SRAM Enable Step 1
writeData_MSX(0x5FFF, 0x69); // SRAM Enable Step 2
readSegment_MSX(0x4000, 0x6000); // 8K
Expand Down Expand Up @@ -708,7 +720,7 @@ void writeRAM_MSX() {
if (myFile.open(filePath, O_READ)) {

switch (msxmapper) {
case 1: // ASCII8 (2K/8K)
case 1: // ASCII8 (2K/8K)
for (word address = 0x0; address < (0x800 * msxramsize * msxramsize); address += 512) { // 2K/8K
if (msxramsize == 1)
writeData_MSX(0x7000, 0x10); // Bit 4
Expand All @@ -722,8 +734,8 @@ void writeRAM_MSX() {
writeData_MSX(0x7000, 0); // SRAM Disable
break;

case 2: // ASCII16 (2K/8K)
writeData_MSX(0x7000, 0x10); // Bit 4 Enable
case 2: // ASCII16 (2K/8K)
writeData_MSX(0x7000, 0x10); // Bit 4 Enable
for (word address = 0x0; address < (0x800 * msxramsize * msxramsize); address += 512) { // 2K/8K
myFile.read(sdBuffer, 512);
for (int x = 0; x < 512; x++) {
Expand All @@ -735,7 +747,7 @@ void writeRAM_MSX() {

case 4: // Game Master 2 (8K)
for (int y = 0; y < 2; y++) {
writeData_MSX(0xA000, 0x10 + (y * 0x20)); // Bit 4 Enable, Bit 5 SRAM Segment 0/1
writeData_MSX(0xA000, 0x10 + (y * 0x20)); // Bit 4 Enable, Bit 5 SRAM Segment 0/1
for (word address = 0x0; address < 0x1000; address += 512) { // 4K
myFile.read(sdBuffer, 512);
for (int x = 0; x < 512; x++) {
Expand All @@ -748,7 +760,7 @@ void writeRAM_MSX() {

case 5: // HAL Note (16K)
MERQ_ENABLE;
writeData_MSX(0x4FFF, 0x80); // Bit 7 Enable
writeData_MSX(0x4FFF, 0x80); // Bit 7 Enable
for (word address = 0; address < 0x4000; address += 512) { // 16K
myFile.read(sdBuffer, 512);
for (int x = 0; x < 512; x++) {
Expand All @@ -764,7 +776,7 @@ void writeRAM_MSX() {
if (srambit6)
writeData_MSX(0x7000, 0xC0); // Bit 6 + Bit 7 Enable
else
writeData_MSX(0x7000, 0xA0); // Bit 5 + Bit 7 Enable
writeData_MSX(0x7000, 0xA0); // Bit 5 + Bit 7 Enable
for (word address = 0x0; address < 0x2000; address += 512) { // 8K
myFile.read(sdBuffer, 512);
for (int x = 0; x < 512; x++) {
Expand All @@ -776,7 +788,7 @@ void writeRAM_MSX() {
if (srambit6)
writeData_MSX(0x7000, 0xC0 + y); // Bit 6 + Bit 7 Enable
else
writeData_MSX(0x7000, 0xA0 + y); // Bit 5 + Bit 7 Enable
writeData_MSX(0x7000, 0xA0 + y); // Bit 5 + Bit 7 Enable
for (word address = 0x0; address < 0x2000; address += 512) { // 8K
myFile.read(sdBuffer, 512);
for (int x = 0; x < 512; x++) {
Expand All @@ -788,9 +800,9 @@ void writeRAM_MSX() {
writeData_MSX(0x7000, 0); // SRAM Disable
break;

case 11: // PAC/FM-PAC (8K)
writeData_MSX(0x5FFE, 0x4D); // SRAM Enable Step 1
writeData_MSX(0x5FFF, 0x69); // SRAM Enable Step 2
case 11: // PAC/FM-PAC (8K)
writeData_MSX(0x5FFE, 0x4D); // SRAM Enable Step 1
writeData_MSX(0x5FFF, 0x69); // SRAM Enable Step 2
for (word address = 0x0; address < 0x2000; address += 512) { // 8K
myFile.read(sdBuffer, 512);
for (int x = 0; x < 512; x++) {
Expand Down Expand Up @@ -846,7 +858,7 @@ setmapper:
String newmap;
msxmapfound = false;
printMapper(0);
Serial.print(F("Enter Mapper [0-13]: "));
Serial.print(F("Enter Mapper [0-14]: "));
while (Serial.available() == 0) {}
newmap = Serial.readStringUntil('\n');
Serial.println(newmap);
Expand Down Expand Up @@ -1122,7 +1134,7 @@ void checkStatus_MSX() {
EEPROM_readAnything(7, msxmapper);
EEPROM_readAnything(8, msxsize);
EEPROM_readAnything(10, msxramsize);
if (msxmapper > 13) {
if (msxmapper > 14) {
msxmapper = 0;
EEPROM_writeAnything(7, msxmapper);
}
Expand Down Expand Up @@ -1215,6 +1227,9 @@ void printMapper(byte msxmaplabel) {
case 13:
println_Msg(F("SUPER LODE RUNNER"));
break;
case 14:
println_Msg(F("HUDSON SOFT BEE PACK"));
break;
}
#else
Serial.println(F("0 = NONE"));
Expand All @@ -1231,6 +1246,7 @@ void printMapper(byte msxmaplabel) {
Serial.println(F("11 = PAC/FM-PAC"));
Serial.println(F("12 = R-TYPE"));
Serial.println(F("13 = SUPER LODE RUNNER"));
Serial.println(F("14 = HUDSON SOFT BEE PACK"));
#endif
}

Expand Down

0 comments on commit d6dd621

Please sign in to comment.