Trammell Hudson avatar Trammell Hudson committed 245f2b3

Apple ROM dump maybe worked

Comments (0)

Files changed (2)

+#!/usr/bin/perl
+# Merge a low and high roms into a single image file
+use warnings;
+use strict;
+
+my $f1 = shift;
+my $f2 = shift;
+
+undef $/;
+open BIN1, "<$f1" or die;
+my $bin1 = <BIN1>;
+open BIN2, "<$f2" or die;
+my $bin2 = <BIN2>;
+
+my @b1 = split //, $bin1;
+my @b2 = split //, $bin2;
+
+my $b1_len = length $bin1;
+my $b2_len = length $bin2;
+die "File lengths $b1_len != $b2_len\n"
+	unless $b1_len == $b2_len;
+
+for my $i (0..$b1_len-1)
+{
+	print $b2[$i], $b1[$i];
+}
+
+__END__
 };
 
 
+/** 8192x8 UV EEPROM, found in DX synth */
+static const prom_t prom_mbm2764= {
+	.name		= "MBM2764-30",
+	.pins		= 28,
+	.addr_width	= 13,
+	.addr_pins	= {
+		10, 9, 8, 7, 6, 5, 4, 3, 25, 24, 21, 23, 2,
+	},
+
+	.data_width	= 8,
+	.data_pins	= {
+		11, 12, 13, 15, 16, 17, 18, 19,
+	},
+	.hi_pins	= { 28, 27, 1 }, // vdd, pgm, vpp
+	.lo_pins	= { 22, 20, 14, }, // !oe, !cs, gnd
+};
+
+/** Apple Mac SE PROM chips
+ * Similar to a M27C512, but with the 17th address line on 22 instead of Vpp
+ */
+static const prom_t prom_apple = {
+	.name		= "APPLE PROM",
+	.pins		= 28,
+	.addr_width	= 17,
+	.addr_pins	= {
+		10, 9, 8, 7, 6, 5, 4, 3, 25, 24, 21, 23, 2, 26, 27, 1, 22
+	},
+
+	.data_width	= 8,
+	.data_pins	= {
+		11, 12, 13, 15, 16, 17, 18, 19,
+	},
+	.hi_pins	= { 28, },
+	.lo_pins	= { 20, 14, },
+};
+
 /** Select one of the chips */
-static const prom_t * prom = &prom_m27c256;
+static const prom_t * prom = &prom_apple;
 
 
 /** Translate PROM pin numbers into ZIF pin numbers */
 }
 
 
+static uint8_t
+_prom_read(void)
+{
+	uint8_t b = 0;
+	for (uint8_t i = 0 ; i < prom->data_width  ; i++)
+	{
+		uint8_t bit = in(prom_pin(prom->data_pins[i])) ? 0x80 : 0;
+		b = (b >> 1) | bit;
+	}
+
+	return b;
+}
+
+
 /** Read a byte from the PROM at the specified address..
  * \todo Update this to handle wider than 8-bit PROM chips.
  */
 )
 {
 	prom_set_address(addr);
-
 	for(uint8_t i = 0 ; i < 255; i++)
 	{
 		asm("nop");
+		asm("nop");
+		asm("nop");
+		asm("nop");
 	}
 
-	uint8_t b = 0;
-	for (uint8_t i = 0 ; i < prom->data_width  ; i++)
+	uint8_t old_r = _prom_read();
+
+	// Try reading a few times to be sure,
+	// or until the values converge
+	for (uint8_t i = 0 ; i < 8 ; i++)
 	{
-		uint8_t bit = in(prom_pin(prom->data_pins[i])) ? 0x80 : 0;
-		b = (b >> 1) | bit;
+		uint8_t r = _prom_read();
+		if (r == old_r)
+			break;
+		old_r = r;
 	}
 
-	return b;
+	return old_r;
 }
 
 
 xmodem_send(void)
 {
 	uint8_t c;
-	uint16_t addr = 0;
+	uint32_t addr = 0;
 	static xmodem_block_t block;
 
 	block.soh = 0x01;
 			return;
 	}
 
+	// Ending address
+	const uint32_t end_addr = ((uint32_t) 1) << prom->addr_width;
+
 	// Bring the pins up to level
 	prom_setup();
 
 			return;
 
 		// If we have wrapped the address, we are done
-		if (addr == 0)
+		if (addr > end_addr)
 			break;
 	}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.