mirror of https://github.com/trudnai/Steve2.git
Added ROM changing Menu
Added ROMs Added fonts for 80 col PR#3 Fixed Memory Init issues when Cold Reset Fixed Dummy Memory issues
This commit is contained in:
parent
da27a21a88
commit
15911de276
|
@ -7,7 +7,13 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
32089E4824556DBD0036E667 /* PRNumber3.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 32089E4724556DBD0036E667 /* PRNumber3.ttf */; };
|
||||
32089E4924556DBD0036E667 /* PRNumber3.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 32089E4724556DBD0036E667 /* PRNumber3.ttf */; };
|
||||
3213936624079C30007F5C4A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; };
|
||||
323E2DCE245531E600156805 /* Apple2e_Enhanced.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */; };
|
||||
323E2DCF245531E600156805 /* Apple2e_Enhanced.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */; };
|
||||
323E2DD0245531E600156805 /* Apple2e.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e.rom */; };
|
||||
323E2DD1245531E600156805 /* Apple2e.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e.rom */; };
|
||||
32439F8722ECD8AD0077AAE0 /* 6502.c in Sources */ = {isa = PBXBuildFile; fileRef = 32439F7422ECD8AD0077AAE0 /* 6502.c */; };
|
||||
32439F8822ECD8AD0077AAE0 /* apple.rom in Resources */ = {isa = PBXBuildFile; fileRef = 32439F8422ECD8AD0077AAE0 /* apple.rom */; };
|
||||
325EB62F23F8856F00C6B4A4 /* woz.c in Sources */ = {isa = PBXBuildFile; fileRef = 325EB62E23F8856F00C6B4A4 /* woz.c */; };
|
||||
|
@ -118,6 +124,9 @@
|
|||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
32089E4724556DBD0036E667 /* PRNumber3.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = PRNumber3.ttf; sourceTree = "<group>"; };
|
||||
323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */ = {isa = PBXFileReference; lastKnownFileType = file; path = Apple2e_Enhanced.rom; sourceTree = "<group>"; };
|
||||
323E2DCD245531E500156805 /* Apple2e.rom */ = {isa = PBXFileReference; lastKnownFileType = file; path = Apple2e.rom; sourceTree = "<group>"; };
|
||||
32439F7222ECD8AC0077AAE0 /* A2Mac-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "A2Mac-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
32439F7322ECD8AD0077AAE0 /* mmio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmio.h; sourceTree = "<group>"; };
|
||||
32439F7422ECD8AD0077AAE0 /* 6502.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = 6502.c; sourceTree = "<group>"; };
|
||||
|
@ -385,7 +394,10 @@
|
|||
3262F37423E169F8008BDB95 /* spk_dn.wav */,
|
||||
3262F37523E169F8008BDB95 /* spk_up.wav */,
|
||||
325EB67B23FBD43800C6B4A4 /* PrintChar21.ttf */,
|
||||
32089E4724556DBD0036E667 /* PRNumber3.ttf */,
|
||||
32439F8422ECD8AD0077AAE0 /* apple.rom */,
|
||||
323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */,
|
||||
323E2DCD245531E500156805 /* Apple2e.rom */,
|
||||
325EB67F23FBDF8F00C6B4A4 /* Apple2Plus.rom */,
|
||||
325EB68223FBDFBA00C6B4A4 /* DISK_II_C600.ROM */,
|
||||
325EB68523FC707A00C6B4A4 /* Apple DOS 3.3 January 1983.woz */,
|
||||
|
@ -691,15 +703,18 @@
|
|||
325EB69E2401118300C6B4A4 /* Lode Runner.woz in Resources */,
|
||||
325EB68123FBDF8F00C6B4A4 /* Apple2Plus.rom in Resources */,
|
||||
325EB6AA2401118300C6B4A4 /* Sneakers.woz in Resources */,
|
||||
32089E4924556DBD0036E667 /* PRNumber3.ttf in Resources */,
|
||||
325EB6A82401118300C6B4A4 /* ProDOS_402_System.woz in Resources */,
|
||||
325EB69123FE028800C6B4A4 /* Donkey Kong.woz in Resources */,
|
||||
325EB68A23FDDF6200C6B4A4 /* Hard Hat Mack - Disk 1, Side A.woz in Resources */,
|
||||
325EB6A02401118300C6B4A4 /* Crossfire.woz in Resources */,
|
||||
325EB67923FBC48400C6B4A4 /* spk_dn.wav in Resources */,
|
||||
325EB64C23FBBAD100C6B4A4 /* Assets.xcassets in Resources */,
|
||||
323E2DD1245531E600156805 /* Apple2e.rom in Resources */,
|
||||
325EB68D23FDDFD200C6B4A4 /* Merlin-8 v2.48 (DOS 3.3).woz in Resources */,
|
||||
325EB6A62401118300C6B4A4 /* ProDOS_312.woz in Resources */,
|
||||
325EB6AC2401118300C6B4A4 /* Xonix.woz in Resources */,
|
||||
323E2DCF245531E600156805 /* Apple2e_Enhanced.rom in Resources */,
|
||||
325EB67D23FBD43800C6B4A4 /* PrintChar21.ttf in Resources */,
|
||||
325EB6A42401118300C6B4A4 /* Qbit.woz in Resources */,
|
||||
325EB68723FC707A00C6B4A4 /* Apple DOS 3.3 January 1983.woz in Resources */,
|
||||
|
@ -733,15 +748,18 @@
|
|||
325EB67C23FBD43800C6B4A4 /* PrintChar21.ttf in Resources */,
|
||||
325EB69D2401118300C6B4A4 /* Lode Runner.woz in Resources */,
|
||||
3262F37723E169F8008BDB95 /* spk_up.wav in Resources */,
|
||||
32089E4824556DBD0036E667 /* PRNumber3.ttf in Resources */,
|
||||
325EB6A92401118300C6B4A4 /* Sneakers.woz in Resources */,
|
||||
325EB6A72401118300C6B4A4 /* ProDOS_402_System.woz in Resources */,
|
||||
325EB69023FE028800C6B4A4 /* Donkey Kong.woz in Resources */,
|
||||
325EB68923FDDF6200C6B4A4 /* Hard Hat Mack - Disk 1, Side A.woz in Resources */,
|
||||
325EB69F2401118300C6B4A4 /* Crossfire.woz in Resources */,
|
||||
32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */,
|
||||
323E2DD0245531E600156805 /* Apple2e.rom in Resources */,
|
||||
325EB68C23FDDFD200C6B4A4 /* Merlin-8 v2.48 (DOS 3.3).woz in Resources */,
|
||||
325EB6A52401118300C6B4A4 /* ProDOS_312.woz in Resources */,
|
||||
325EB6AB2401118300C6B4A4 /* Xonix.woz in Resources */,
|
||||
323E2DCE245531E600156805 /* Apple2e_Enhanced.rom in Resources */,
|
||||
325EB68623FC707A00C6B4A4 /* Apple DOS 3.3 January 1983.woz in Resources */,
|
||||
325EB6A32401118300C6B4A4 /* Qbit.woz in Resources */,
|
||||
32439F8822ECD8AD0077AAE0 /* apple.rom in Resources */,
|
||||
|
|
|
@ -12,6 +12,14 @@ import Cocoa
|
|||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
|
||||
@IBAction func ROM_Selected(_ sender: NSMenuItem) {
|
||||
if let menuIdentifier = sender.identifier {
|
||||
// rom_loadFile( Bundle.main.resourcePath, menuIdentifier.rawValue + ".rom" )
|
||||
ViewController.romFileName = menuIdentifier.rawValue + ".rom"
|
||||
m6502_ColdReset( Bundle.main.resourcePath, ViewController.romFileName )
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func Disk1_Selected(_ sender: NSMenuItem) {
|
||||
if let menuIdentifier = sender.identifier {
|
||||
woz_loadFile( Bundle.main.resourcePath, menuIdentifier.rawValue + ".woz" )
|
||||
|
|
|
@ -604,6 +604,37 @@
|
|||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Config" id="Xqf-B7-gCo">
|
||||
<items>
|
||||
<menuItem title="ROM" id="Y3v-20-h2Q">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Disk 1" id="7dA-Bf-QS9">
|
||||
<items>
|
||||
<menuItem title="Apple ][" identifier="apple" id="vNT-Vf-GnM">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="kGO-kr-gGf"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Apple ][ Plus" identifier="Apple2Plus" id="wL6-44-pA1">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="7Z4-x3-Io3"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Apple //e" identifier="Apple2e" id="fj0-JM-dwU">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="xDa-lu-WEG"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Apple //e Enhanced" identifier="Apple2e_Enhanced" id="xHh-GT-uQa">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="A4H-Kk-DWT"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Disk 1" id="0NC-AF-e3z">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Disk 1" id="lnc-y1-bUG">
|
||||
|
@ -650,9 +681,6 @@
|
|||
<menuItem title="Disk 2" id="yVX-3l-dbM">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Item 3" id="Y3v-20-h2Q">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
|
|
|
@ -92,6 +92,8 @@ class ViewController: NSViewController {
|
|||
|
||||
static var charConvTbl = charConvTblFlashOn
|
||||
|
||||
static var romFileName = "Apple2e_Enhanced.rom";
|
||||
|
||||
let textLineOfs : [Int] = [
|
||||
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x028, 0x0A8, 0x128, 0x1A8,
|
||||
0x228, 0x2A8, 0x328, 0x3A8, 0x050, 0x0D0, 0x150, 0x1D0, 0x250, 0x2D0, 0x350, 0x3D0
|
||||
|
@ -117,7 +119,7 @@ class ViewController: NSViewController {
|
|||
DispatchQueue.global().async(execute: workItem!);
|
||||
}
|
||||
#else
|
||||
m6502_ColdReset( Bundle.main.resourcePath )
|
||||
m6502_ColdReset( Bundle.main.resourcePath, ViewController.romFileName )
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,8 @@ class ViewController: UIViewController {
|
|||
|
||||
static var charConvTbl = charConvTblFlashOn
|
||||
|
||||
static var romFileName = "Apple2e_Enhanced.rom";
|
||||
|
||||
let textLineOfs : [Int] = [
|
||||
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x028, 0x0A8, 0x128, 0x1A8,
|
||||
0x228, 0x2A8, 0x328, 0x3A8, 0x050, 0x0D0, 0x150, 0x1D0, 0x250, 0x2D0, 0x350, 0x3D0
|
||||
|
@ -113,7 +115,7 @@ class ViewController: UIViewController {
|
|||
DispatchQueue.global().async(execute: workItem!);
|
||||
}
|
||||
#else
|
||||
m6502_ColdReset( Bundle.main.bundlePath )
|
||||
m6502_ColdReset( Bundle.main.bundlePath, romFileName )
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
102
src/cpu/6502.c
102
src/cpu/6502.c
|
@ -828,8 +828,8 @@ void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, co
|
|||
char fullPath[256];
|
||||
|
||||
strcpy( fullPath, bundlePath );
|
||||
strcat(fullPath, "/");
|
||||
strcat(fullPath, filename);
|
||||
strcat( fullPath, "/");
|
||||
strcat( fullPath, filename );
|
||||
|
||||
FILE * f = fopen(fullPath, "rb");
|
||||
if (f == NULL) {
|
||||
|
@ -847,7 +847,62 @@ void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, co
|
|||
}
|
||||
|
||||
|
||||
void m6502_ColdReset( const char * bundlePath ) {
|
||||
size_t getFileSize ( const char * fullPath ) {
|
||||
FILE * f = fopen(fullPath, "rb");
|
||||
if (f == NULL) {
|
||||
perror("Failed to read ROM: ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(f, 0L, SEEK_END);
|
||||
size_t flen = ftell(f);
|
||||
fseek(f, 0L, SEEK_SET);
|
||||
|
||||
fclose(f);
|
||||
|
||||
return flen;
|
||||
}
|
||||
|
||||
|
||||
void rom_loadFile( const char * bundlePath, const char * filename ) {
|
||||
char fullPath[256];
|
||||
|
||||
strcpy( fullPath, bundlePath );
|
||||
strcat( fullPath, "/");
|
||||
strcat( fullPath, filename );
|
||||
|
||||
size_t flen = getFileSize(fullPath);
|
||||
|
||||
if ( flen == 0 ) {
|
||||
return; // there was an error
|
||||
}
|
||||
|
||||
else if ( flen == 16 * KB ) {
|
||||
read_rom( bundlePath, filename, Apple2_16K_ROM, 0);
|
||||
memcpy(Apple2_12K_ROM + 0x0000, Apple2_16K_ROM + 0x1000, sizeof(Apple2_12K_ROM));
|
||||
memcpy(Apple2_64K_RAM + 0xC000, Apple2_16K_ROM, 0x1000);
|
||||
}
|
||||
|
||||
else if ( flen == 12 * KB ) {
|
||||
read_rom( bundlePath, filename, Apple2_12K_ROM, 0);
|
||||
memcpy(Apple2_64K_RAM + 0xD000, Apple2_12K_ROM, sizeof(Apple2_12K_ROM));
|
||||
}
|
||||
|
||||
// read_rom( bundlePath, "Apple2Plus.rom", Apple2_12K_ROM, 0);
|
||||
// read_rom( bundlePath, "Apple2e.rom", Apple2_16K_ROM, 0);
|
||||
// read_rom( bundlePath, "Apple2e_Enhanced.rom", Apple2_16K_ROM, 0);
|
||||
|
||||
// read_rom( "/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/", "Apple2Plus.rom", Apple2_12K_ROM, 0);
|
||||
// read_rom("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/Apple2Plus.rom", Apple2_12K_ROM, 0);
|
||||
|
||||
// memcpy(Apple2_64K_RAM + 0xD000, Apple2_12K_ROM, sizeof(Apple2_12K_ROM));
|
||||
// memcpy(Apple2_12K_ROM + 0x0000, Apple2_16K_ROM + 0x1000, sizeof(Apple2_12K_ROM));
|
||||
// memcpy(Apple2_64K_RAM + 0xC000, Apple2_16K_ROM, sizeof(Apple2_16K_ROM));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
|
||||
inst_cnt = 0;
|
||||
mhz = (double)MHz_6502 / M;
|
||||
|
||||
|
@ -859,8 +914,7 @@ void m6502_ColdReset( const char * bundlePath ) {
|
|||
// tick_per_sec = e - epoch;
|
||||
// tick_6502_per_sec = tick_per_sec / MHz_6502;
|
||||
|
||||
memset( RAM, 0, sizeof(Apple2_64K_RAM) );
|
||||
memset( RAM + 0xC000, 0, 0x1000 ); // I/O area should be 0
|
||||
resetMemory();
|
||||
|
||||
outdev = fopen("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/disassembly_new.log", "w+");
|
||||
if (outdev == NULL) {
|
||||
|
@ -883,43 +937,13 @@ void m6502_ColdReset( const char * bundlePath ) {
|
|||
|
||||
#else
|
||||
// Apple ][+ ROM
|
||||
read_rom( bundlePath, "Apple2Plus.rom", Apple2_12K_ROM, 0);
|
||||
// read_rom( "/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/", "Apple2Plus.rom", Apple2_12K_ROM, 0);
|
||||
// read_rom("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/Apple2Plus.rom", Apple2_12K_ROM, 0);
|
||||
memcpy(Apple2_64K_RAM + 0xD000, Apple2_12K_ROM, sizeof(Apple2_12K_ROM));
|
||||
|
||||
rom_loadFile(bundlePath, romFileName);
|
||||
|
||||
// Disk ][ ROM in Slot 6
|
||||
read_rom( bundlePath, "DISK_II_C600.ROM", Apple2_64K_RAM, 0xC600);
|
||||
// read_rom( "/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/", "DISK_II_C600.ROM", Apple2_64K_RAM, 0xC600);
|
||||
|
||||
// WOZ DISK
|
||||
// woz_loadFile("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/DOS 3.3 System Master.woz");
|
||||
// woz_loadFile("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/Hard Hat Mack - Disk 1, Side A.woz");
|
||||
|
||||
// woz_loadFile("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/Merlin-8 v2.48 (DOS 3.3).woz");
|
||||
// woz_loadFile("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/DOS3.3.Launcher.2.2.woz");
|
||||
// woz_loadFile("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/", "Apple DOS 3.3 January 1983.woz");
|
||||
|
||||
|
||||
// GAMES
|
||||
// woz_loadFile( bundlePath, "qbit.woz"); // Lode Runner, Hard Hat Mack, QBit, Crossfire, Heat Seaker, Flight Simulator
|
||||
// woz_loadFile( bundlePath, "Donkey Kong.woz");
|
||||
|
||||
/**/// woz_loadFile( bundlePath, "Crossfire.woz");
|
||||
// woz_loadFile( bundlePath, "Lode Runner.woz");
|
||||
/**/// woz_loadFile( bundlePath, "Sneakers.woz");
|
||||
/**/// woz_loadFile( bundlePath, "Wavy Navy.woz");
|
||||
/**/// woz_loadFile( bundlePath, "Xonix.woz");
|
||||
/**/// woz_loadFile( bundlePath, "Hard Hat Mack - Disk 1, Side A.woz");
|
||||
|
||||
|
||||
// SYSTEM
|
||||
/* Requires 64K */// woz_loadFile( bundlePath, "ProDOS_312.woz");
|
||||
/* Requires Enhanced //e or later */// woz_loadFile( bundlePath, "ProDOS_402_System.woz");
|
||||
|
||||
// woz_loadFile( bundlePath, "Merlin-8 v2.48 (DOS 3.3).woz");
|
||||
// woz_loadFile( bundlePath, "Apple DOS 3.3 January 1983.woz");
|
||||
|
||||
|
||||
m6502.A = m6502.X = m6502.Y = 0xFF;
|
||||
// reset vector
|
||||
m6502.SP = 0xFF; //-3;
|
||||
|
@ -1046,7 +1070,7 @@ void tst6502() {
|
|||
// insert code here...
|
||||
printf("6502\n");
|
||||
|
||||
m6502_ColdReset( "" );
|
||||
m6502_ColdReset( "", "" );
|
||||
|
||||
// clock_t start = clock();
|
||||
// epoch = rdtsc();
|
||||
|
|
|
@ -118,9 +118,10 @@ extern double mhz;
|
|||
|
||||
#define fps 30
|
||||
|
||||
extern void rom_loadFile( const char * bundlePath, const char * filename );
|
||||
extern void woz_loadFile( const char * bundlePath, const char * filename );
|
||||
extern void tst6502(void);
|
||||
extern void m6502_ColdReset( const char * bundlePath );
|
||||
extern void m6502_ColdReset( const char * bundlePath, const char * romFilePath );
|
||||
extern void m6502_Run(void);
|
||||
extern void kbdInput ( uint8_t code );
|
||||
extern void setIO ( uint16_t ioaddr, uint8_t val );
|
||||
|
|
|
@ -28,8 +28,10 @@ videoMode_t videoMode = { 1 }; // 40 col text, page 1
|
|||
|
||||
|
||||
uint8_t Apple2_Dummy_Page[ 1 * PG ]; // Dummy Page for discarding data
|
||||
uint8_t Apple2_Dummy_RAM[ 4 * KB ]; // Dummy RAM for discarding data
|
||||
uint8_t Apple2_512_AUX[ 2 * PG ] = {0}; // Auxiliary bank for page 0 and 1
|
||||
uint8_t Apple2_12K_ROM[ 12 * KB ] = {0}; // ROM D0, D8, E0, E8, F0, F8
|
||||
uint8_t Apple2_16K_ROM[ 16 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
|
||||
uint8_t Apple2_16K_RAM[ 16 * KB ] = {0}; // 16K Memory Expansion Card
|
||||
uint8_t Apple2_64K_RAM[ 64 * KB ] = {0}; // Main Memory
|
||||
uint8_t * RAM = Apple2_64K_RAM; // Pointer to the main memory so we can use this from Swift
|
||||
|
@ -170,14 +172,16 @@ enum slot {
|
|||
|
||||
|
||||
// Memory Config
|
||||
struct MEMcfg_s {
|
||||
typedef struct MEMcfg_s {
|
||||
uint8_t RAM_16K : 1;
|
||||
uint8_t RAM_128K : 1;
|
||||
uint8_t RD_RAM : 1;
|
||||
uint8_t WR_RAM : 1;
|
||||
uint8_t RAM_BANK_2 : 1;
|
||||
uint8_t AUX_BANK : 1;
|
||||
} MEMcfg = { 1, 0, 0, 0, 0 };
|
||||
} MEMcfg_t;
|
||||
|
||||
MEMcfg_t MEMcfg = { 1, 0, 0, 0, 0, 0 };
|
||||
|
||||
enum mmio {
|
||||
// Keyboard
|
||||
|
@ -242,6 +246,65 @@ enum mmio {
|
|||
#define PAGES 16
|
||||
|
||||
|
||||
void resetMemory() {
|
||||
// 48K main memory
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x00, Apple2_64K_RAM, 0x00)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x10, Apple2_64K_RAM, 0x10)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x20, Apple2_64K_RAM, 0x20)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x30, Apple2_64K_RAM, 0x30)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x40, Apple2_64K_RAM, 0x40)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x50, Apple2_64K_RAM, 0x50)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x60, Apple2_64K_RAM, 0x60)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x70, Apple2_64K_RAM, 0x70)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x80, Apple2_64K_RAM, 0x80)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x90, Apple2_64K_RAM, 0x90)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xA0, Apple2_64K_RAM, 0xA0)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xB0, Apple2_64K_RAM, 0xB0)
|
||||
// I/O Addresses
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xC0, Apple2_64K_RAM, 0xC0)
|
||||
// Reading from the ROM
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xD0, Apple2_12K_ROM, 0x00) // D0
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xE0, Apple2_12K_ROM, 0x10) // E0
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xF0, Apple2_12K_ROM, 0x20) // F0
|
||||
|
||||
// 48K main memory
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x00, Apple2_64K_RAM, 0x00)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x10, Apple2_64K_RAM, 0x10)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x20, Apple2_64K_RAM, 0x20)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x30, Apple2_64K_RAM, 0x30)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x40, Apple2_64K_RAM, 0x40)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x50, Apple2_64K_RAM, 0x50)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x60, Apple2_64K_RAM, 0x60)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x70, Apple2_64K_RAM, 0x70)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x80, Apple2_64K_RAM, 0x80)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0x90, Apple2_64K_RAM, 0x90)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xA0, Apple2_64K_RAM, 0xA0)
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xB0, Apple2_64K_RAM, 0xB0)
|
||||
// I/O Addresses
|
||||
SWITCH_RAM_PAGE16( RAM_PG_RD_TBL, 0xC0, Apple2_64K_RAM, 0xC0)
|
||||
// NO Writing to the ROM
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xD0, Apple2_Dummy_RAM, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xE0, Apple2_Dummy_RAM, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xF0, Apple2_Dummy_RAM, 0 );
|
||||
|
||||
MEMcfg.RAM_16K = 1;
|
||||
MEMcfg.RAM_16K = 0;
|
||||
MEMcfg.RAM_128K = 0;
|
||||
MEMcfg.RD_RAM = 0;
|
||||
MEMcfg.WR_RAM = 0;
|
||||
MEMcfg.RAM_BANK_2 = 0;
|
||||
MEMcfg.AUX_BANK = 0;
|
||||
|
||||
// 64K Main Memory Area
|
||||
memset( RAM, 0, sizeof(Apple2_64K_RAM) );
|
||||
// 16K Memory Expansion
|
||||
memset( RAM, 0, sizeof(Apple2_16K_RAM) );
|
||||
// I/O area should be 0 -- just in case we decide to init RAM with a different pattern...
|
||||
memset( RAM + 0xC000, 0, 0x1000 );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
INLINE uint8_t ioRead( uint16_t addr ) {
|
||||
dbgPrintf("mmio read:%04X\n", addr);
|
||||
|
@ -389,9 +452,9 @@ INLINE uint8_t ioRead( uint16_t addr ) {
|
|||
default:
|
||||
MEMcfg.WR_RAM = 0;
|
||||
// set the ROM to read on the upper memory area
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xD0, Apple2_Dummy_Page, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xE0, Apple2_Dummy_Page, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xF0, Apple2_Dummy_Page, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xD0, Apple2_Dummy_RAM, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xE0, Apple2_Dummy_RAM, 0 );
|
||||
SWITCH_RAM_PAGE16( RAM_PG_WR_TBL, 0xF0, Apple2_Dummy_RAM, 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -487,11 +550,11 @@ void kbdInput ( uint8_t code ) {
|
|||
|
||||
code |= 0x80;
|
||||
|
||||
for( int i = 10000000; i && ( RAM[io_KBD] > 0x7F ); --i ) {
|
||||
usleep(1);
|
||||
for( int i = 10000; i && ( RAM[io_KBD] > 0x7F ); --i ) {
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
RAM[io_KBD] = code;
|
||||
RAM[io_KBD] = RAM[io_KBDSTRB] = code;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue