AUX RAM fix, Woz adjustments, disassembler separated, new ROMs

This commit is contained in:
tudnai 2022-03-16 10:17:32 -07:00
parent 7ae9d4bada
commit 7a6b8c1f38
17 changed files with 385 additions and 188 deletions

View File

@ -17,7 +17,7 @@
323D04332489BFD80086A901 /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 323D04312489BFD80086A901 /* PreferencesWindowController.swift */; };
323D04442490B3930086A901 /* dotmatrix_effect.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 323D04432490B3930086A901 /* dotmatrix_effect.png */; };
323E2DCF245531E600156805 /* Apple2e_Enhanced.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */; };
323E2DD1245531E600156805 /* Apple2e.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e.rom */; };
323E2DD1245531E600156805 /* Apple2e_16k.rom in Resources */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e_16k.rom */; };
32440BA32480D5C0000F9DA1 /* LoRes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32440BA22480D5C0000F9DA1 /* LoRes.swift */; };
324D15D324ADAC71008AAFB0 /* floppy.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 324D15D224ADAC71008AAFB0 /* floppy.png */; };
32544195264A6C1600B7E3ED /* DisplayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32544194264A6C1600B7E3ED /* DisplayView.swift */; };
@ -58,6 +58,16 @@
325EB6AC2401118300C6B4A4 /* Xonix.woz in Resources */ = {isa = PBXBuildFile; fileRef = 325EB69B2401118300C6B4A4 /* Xonix.woz */; };
3267641624B6572E000BEA11 /* Merlin Assembler.woz in Copy Disk Images */ = {isa = PBXBuildFile; fileRef = 3267641524B6572E000BEA11 /* Merlin Assembler.woz */; };
3267641824BCC9A5000BEA11 /* COPYING in Resources */ = {isa = PBXBuildFile; fileRef = 3267641724BCC9A5000BEA11 /* COPYING */; };
3268B97A27DE7D6A003FBDCC /* disassembler.c in Sources */ = {isa = PBXBuildFile; fileRef = 3268B97927DE7D6A003FBDCC /* disassembler.c */; };
3268B97B27DE7D6B003FBDCC /* disassembler.c in Sources */ = {isa = PBXBuildFile; fileRef = 3268B97927DE7D6A003FBDCC /* disassembler.c */; };
3268B97C27DE7D6B003FBDCC /* disassembler.c in Sources */ = {isa = PBXBuildFile; fileRef = 3268B97927DE7D6A003FBDCC /* disassembler.c */; };
3268B99127DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Resources */ = {isa = PBXBuildFile; fileRef = 3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */; };
3268B99227DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Resources */ = {isa = PBXBuildFile; fileRef = 3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */; };
3268B99327DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Resources */ = {isa = PBXBuildFile; fileRef = 3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */; };
3268B9A627DEAD44003FBDCC /* Apple2e_32k.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 3268B98F27DEAC73003FBDCC /* Apple2e_32k.rom */; };
3268B9B027DEAD51003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */; };
3268B9C327DEAE37003FBDCC /* Apple2e_32k.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 3268B98F27DEAC73003FBDCC /* Apple2e_32k.rom */; };
3268B9E927DEDD61003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */; };
326B56E524AD8E89009BA0AC /* gobackward.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 326B56E424AD8E89009BA0AC /* gobackward.png */; };
326B56E724AD906D009BA0AC /* doc.text.viewfinder.png in Copy Image Files */ = {isa = PBXBuildFile; fileRef = 326B56E624AD906D009BA0AC /* doc.text.viewfinder.png */; };
3277D779273AE0DA00749544 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 32BFFB6022EACC660003B53F /* Main.storyboard */; };
@ -87,7 +97,7 @@
32799F94264B1A5700255669 /* PRNumber3.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 32089E4724556DBD0036E667 /* PRNumber3.ttf */; };
32799F96264B1A5700255669 /* apple.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 32439F8422ECD8AD0077AAE0 /* apple.rom */; };
32799F97264B1A5700255669 /* Apple2e_Enhanced.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */; };
32799F98264B1A5700255669 /* Apple2e.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e.rom */; };
32799F98264B1A5700255669 /* Apple2e_16k.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e_16k.rom */; };
32799F99264B1A5700255669 /* Apple2Plus.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 325EB67F23FBDF8F00C6B4A4 /* Apple2Plus.rom */; };
32799F9A264B1A5700255669 /* DISK_II_C600.ROM in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 325EB68223FBDFBA00C6B4A4 /* DISK_II_C600.ROM */; };
32799F9C264B1A5700255669 /* blank.woz in Copy Disk Images */ = {isa = PBXBuildFile; fileRef = 32440B9C247F9DC7000F9DA1 /* blank.woz */; };
@ -218,7 +228,7 @@
32F8A87D24A3A84700EE6735 /* PRNumber3.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 32089E4724556DBD0036E667 /* PRNumber3.ttf */; };
32F8A87F24A3A8A000EE6735 /* apple.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 32439F8422ECD8AD0077AAE0 /* apple.rom */; };
32F8A88024A3A8A300EE6735 /* Apple2e_Enhanced.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */; };
32F8A88124A3A8A600EE6735 /* Apple2e.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e.rom */; };
32F8A88124A3A8A600EE6735 /* Apple2e_16k.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 323E2DCD245531E500156805 /* Apple2e_16k.rom */; };
32F8A88224A3A8AA00EE6735 /* Apple2Plus.rom in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 325EB67F23FBDF8F00C6B4A4 /* Apple2Plus.rom */; };
32F8A88324A3A8B200EE6735 /* DISK_II_C600.ROM in Copy ROM Images */ = {isa = PBXBuildFile; fileRef = 325EB68223FBDFBA00C6B4A4 /* DISK_II_C600.ROM */; };
32F8A88524A3A91100EE6735 /* blank.woz in Copy Disk Images */ = {isa = PBXBuildFile; fileRef = 32440B9C247F9DC7000F9DA1 /* blank.woz */; };
@ -310,9 +320,11 @@
dstPath = rom;
dstSubfolderSpec = 7;
files = (
3268B9E927DEDD61003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Copy ROM Images */,
32799F96264B1A5700255669 /* apple.rom in Copy ROM Images */,
32799F97264B1A5700255669 /* Apple2e_Enhanced.rom in Copy ROM Images */,
32799F98264B1A5700255669 /* Apple2e.rom in Copy ROM Images */,
32799F98264B1A5700255669 /* Apple2e_16k.rom in Copy ROM Images */,
3268B9C327DEAE37003FBDCC /* Apple2e_32k.rom in Copy ROM Images */,
32799F99264B1A5700255669 /* Apple2Plus.rom in Copy ROM Images */,
32799F9A264B1A5700255669 /* DISK_II_C600.ROM in Copy ROM Images */,
);
@ -424,9 +436,11 @@
dstPath = rom;
dstSubfolderSpec = 7;
files = (
3268B9B027DEAD51003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Copy ROM Images */,
32F8A87F24A3A8A000EE6735 /* apple.rom in Copy ROM Images */,
32F8A88024A3A8A300EE6735 /* Apple2e_Enhanced.rom in Copy ROM Images */,
32F8A88124A3A8A600EE6735 /* Apple2e.rom in Copy ROM Images */,
32F8A88124A3A8A600EE6735 /* Apple2e_16k.rom in Copy ROM Images */,
3268B9A627DEAD44003FBDCC /* Apple2e_32k.rom in Copy ROM Images */,
32F8A88224A3A8AA00EE6735 /* Apple2Plus.rom in Copy ROM Images */,
32F8A88324A3A8B200EE6735 /* DISK_II_C600.ROM in Copy ROM Images */,
);
@ -541,7 +555,7 @@
323D04432490B3930086A901 /* dotmatrix_effect.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dotmatrix_effect.png; sourceTree = "<group>"; };
323D04452490BA1E0086A901 /* scanlines.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = scanlines.png; 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>"; };
323E2DCD245531E500156805 /* Apple2e_16k.rom */ = {isa = PBXFileReference; lastKnownFileType = file; path = Apple2e_16k.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>"; };
@ -633,6 +647,9 @@
3267641524B6572E000BEA11 /* Merlin Assembler.woz */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Merlin Assembler.woz"; sourceTree = "<group>"; };
3267641724BCC9A5000BEA11 /* COPYING */ = {isa = PBXFileReference; lastKnownFileType = text; path = COPYING; sourceTree = "<group>"; };
3268B96F27DBD219003FBDCC /* convert_spkr_buf_to_wav.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = convert_spkr_buf_to_wav.py; sourceTree = SOURCE_ROOT; };
3268B97927DE7D6A003FBDCC /* disassembler.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = disassembler.c; sourceTree = "<group>"; };
3268B98F27DEAC73003FBDCC /* Apple2e_32k.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = Apple2e_32k.rom; path = Resources/rom/Apple2e_32k.rom; sourceTree = SOURCE_ROOT; };
3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */ = {isa = PBXFileReference; lastKnownFileType = file; path = "077-0019 Apple IIe Diagnostic Card - English.rom"; sourceTree = "<group>"; };
3268E68E2474E24900047474 /* paddle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = paddle.h; sourceTree = "<group>"; };
326B56E424AD8E89009BA0AC /* gobackward.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gobackward.png; sourceTree = "<group>"; };
326B56E624AD906D009BA0AC /* doc.text.viewfinder.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = doc.text.viewfinder.png; sourceTree = "<group>"; };
@ -843,8 +860,10 @@
children = (
326ED2EE232D7A0000A41337 /* 6502_functional_test.bin */,
32439F8422ECD8AD0077AAE0 /* apple.rom */,
3268B99027DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom */,
323E2DCC245531E500156805 /* Apple2e_Enhanced.rom */,
323E2DCD245531E500156805 /* Apple2e.rom */,
323E2DCD245531E500156805 /* Apple2e_16k.rom */,
3268B98F27DEAC73003FBDCC /* Apple2e_32k.rom */,
325EB67F23FBDF8F00C6B4A4 /* Apple2Plus.rom */,
325EB68223FBDFBA00C6B4A4 /* DISK_II_C600.ROM */,
);
@ -922,6 +941,7 @@
32439F8622ECD8AD0077AAE0 /* common.h */,
325EB63823F9E48100C6B4A4 /* common.c */,
32DBF76723373FB400DD50E7 /* disassembler.h */,
3268B97927DE7D6A003FBDCC /* disassembler.c */,
);
path = util;
sourceTree = "<group>";
@ -1419,6 +1439,7 @@
325EB68423FBDFBB00C6B4A4 /* DISK_II_C600.ROM in Resources */,
325EB69E2401118300C6B4A4 /* Lode Runner.woz in Resources */,
325EB68123FBDF8F00C6B4A4 /* Apple2Plus.rom in Resources */,
3268B99327DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Resources */,
325EB6AA2401118300C6B4A4 /* Sneakers.woz in Resources */,
32E3126624A7193700E61891 /* disk_ii_arm.sfx in Resources */,
32089E4924556DBD0036E667 /* PRNumber3.ttf in Resources */,
@ -1428,7 +1449,7 @@
325EB68A23FDDF6200C6B4A4 /* Hard Hat Mack - Disk 1, Side A.woz in Resources */,
325EB6A02401118300C6B4A4 /* Crossfire.woz in Resources */,
325EB64C23FBBAD100C6B4A4 /* Assets.xcassets in Resources */,
323E2DD1245531E600156805 /* Apple2e.rom in Resources */,
323E2DD1245531E600156805 /* Apple2e_16k.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 */,
@ -1461,6 +1482,7 @@
32BCCD1A2650D3B1002151C5 /* Debug-Info.plist in Resources */,
32799F8D264B1A5700255669 /* COPYING in Resources */,
32799F8F264B1A5700255669 /* Assets.xcassets in Resources */,
3268B99227DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Resources */,
3277D783273AE0DC00749544 /* Main.storyboard in Resources */,
32799F90264B1A5700255669 /* Preferences.storyboard in Resources */,
32799F91264B1A5700255669 /* Steve2Icon.icns in Resources */,
@ -1474,6 +1496,7 @@
32BCCD192650D3B1002151C5 /* Debug-Info.plist in Resources */,
3267641824BCC9A5000BEA11 /* COPYING in Resources */,
32BFFB5F22EACC660003B53F /* Assets.xcassets in Resources */,
3268B99127DEAC84003FBDCC /* 077-0019 Apple IIe Diagnostic Card - English.rom in Resources */,
3277D779273AE0DA00749544 /* Main.storyboard in Resources */,
323D042E248980600086A901 /* Preferences.storyboard in Resources */,
320F2A8824CFD74100671B35 /* Steve2Icon.icns in Resources */,
@ -1529,6 +1552,7 @@
32A9F74B2467B60B004902A1 /* speaker.c in Sources */,
32A6AB11266AF5160023257A /* paddle.c in Sources */,
32A6AB26266B196A0023257A /* hires.c in Sources */,
3268B97C27DE7D6B003FBDCC /* disassembler.c in Sources */,
325EB67823FBC45300C6B4A4 /* disk.c in Sources */,
325EB64723FBBACF00C6B4A4 /* ViewController.swift in Sources */,
325EB64323FBBACF00C6B4A4 /* AppDelegate.swift in Sources */,
@ -1568,6 +1592,7 @@
32799F7E264B1A5700255669 /* PreferencesWindowController.swift in Sources */,
32799F80264B1A5700255669 /* dsk2woz.c in Sources */,
32799F81264B1A5700255669 /* disk.c in Sources */,
3268B97B27DE7D6B003FBDCC /* disassembler.c in Sources */,
32C6996727C548C900D0F25D /* Shaders.metal in Sources */,
32799F82264B1A5700255669 /* woz.c in Sources */,
32A6AB10266AF5160023257A /* paddle.c in Sources */,
@ -1597,6 +1622,7 @@
323D04332489BFD80086A901 /* PreferencesWindowController.swift in Sources */,
32E3126924A98B9300E61891 /* dsk2woz.c in Sources */,
325EB63623F8F78300C6B4A4 /* disk.c in Sources */,
3268B97A27DE7D6A003FBDCC /* disassembler.c in Sources */,
32C6995D27C548C800D0F25D /* Shaders.metal in Sources */,
325EB62F23F8856F00C6B4A4 /* woz.c in Sources */,
32A6AB0F266AF5160023257A /* paddle.c in Sources */,
@ -2073,7 +2099,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 0.86;
OTHER_CFLAGS = (
"-D_NO_DISASSEMBLER",
"-DDISASSEMBLER",
"-D_NO_INTERRUPT_CHECK_PER_STEP",
"-D_NO_CLK_ABSOLUTE_PRECISE",
);
@ -2115,7 +2141,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 0.86;
OTHER_CFLAGS = (
"-D_NO_DISASSEMBLER",
"-DDISASSEMBLER",
"-D_NO_INTERRUPT_CHECK_PER_STEP",
"-D_NO_CLK_ABSOLUTE_PRECISE",
);

View File

@ -462,6 +462,11 @@
</ContextState>
<ContextState
contextName = "PUSH:6502_instr_stack.h">
<PersistentStrings>
<PersistentString
value = "m6502.SP">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "ViewController.viewDidLoad():ViewController.swift">

View File

@ -1035,12 +1035,18 @@
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="dhI-7d-ciT"/>
</connections>
</menuItem>
<menuItem title="Apple //e" identifier="Apple2e" id="MeE-Kj-pad">
<menuItem title="Apple //e 16k" identifier="Apple2e_16k" id="MeE-Kj-pad">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="2W2-oY-Osz"/>
</connections>
</menuItem>
<menuItem title="Apple //e 32k" identifier="Apple2e_32k" id="nTN-lC-wHz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="ROM_Selected:" target="Voe-Tx-rLC" id="sZ3-ab-1Ia"/>
</connections>
</menuItem>
<menuItem title="Apple //e Enhanced" state="on" identifier="Apple2e_Enhanced" id="cDl-MC-vGJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>

View File

@ -134,7 +134,9 @@ class ViewController: NSViewController {
static var charConvTbl = charConvTblFlashOn
static var romFileName = "Apple2e_Enhanced.rom";
// static var romFileName = "Apple2e_Enhanced.rom";
static var romFileName = "Apple2e_32k.rom";
// static var romFileName = "077-0019 Apple IIe Diagnostic Card - English.rom";
static let textLineOfs : [Int] = [
0x000, 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x028, 0x0A8, 0x128, 0x1A8,

BIN
Resources/rom/Apple2e_32k.rom Executable file

Binary file not shown.

27
convert_disass.py Executable file
View File

@ -0,0 +1,27 @@
#!/usr/local/bin/python3
import re
import sys
if __name__ == "__main__":
# print(f"Arguments count: {len(sys.argv)}")
# for i, arg in enumerate(sys.argv):
# print(f"Argument {i:>6}: {arg}")
for filename in sys.argv[1:]:
print(f"Converting file: {filename}")
# i = 20
with open(filename, 'r') as inf:
with open(filename + '.dis', 'w+') as outf:
for line in inf:
outf.write(re.sub('^\d*\t\d*\t', '', line))
# print('ORIG:', line)
# print('LINE:', re.sub('^\d*\t\d*\t', '', line))
#
# i += 1
# if i > 200:
# break

View File

@ -117,7 +117,6 @@ m6502_t m6502 = {
};
disassembly_t disassembly;
#include "../util/disassembler.h"
#include "../dev/mem/mmio.h"
@ -641,17 +640,17 @@ void m6502_Run() {
spkr_update_disk_sfx();
}
void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, const uint16_t addr ) {
void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, const uint16_t addr, const uint16_t size ) {
char fullPath[256];
strcpy( fullPath, bundlePath );
strcat( fullPath, "/");
strcat( fullPath, filename );
FILE * f = fopen(fullPath, "rb");
if (f == NULL) {
perror("Failed to read ROM: ");
perror("Failed to read ROM image: ");
return;
}
@ -659,7 +658,12 @@ void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, co
uint16_t flen = ftell(f);
fseek(f, 0L, SEEK_SET);
fread( rom + addr, 1, flen, f);
if ( size && (size > flen) ) {
printf("ROM image is too small (size:0x%04X flen:0x04X)\n", size, flen);
return;
}
fread( rom + addr, 1, size, f);
fclose(f);
}
@ -668,7 +672,7 @@ void read_rom( const char * bundlePath, const char * filename, uint8_t * rom, co
size_t getFileSize ( const char * fullPath ) {
FILE * f = fopen(fullPath, "rb");
if (f == NULL) {
perror("Failed to read ROM: ");
perror("Failed to get filesize for ROM image: ");
return 0;
}
@ -689,20 +693,27 @@ void rom_loadFile( const char * bundlePath, const char * filename ) {
strcat( fullPath, "/");
strcat( fullPath, filename );
printf("Loading ROM: %s\n", filename);
size_t flen = getFileSize(fullPath);
if ( flen == 0 ) {
return; // there was an error
}
else if ( flen == 32 * KB ) {
read_rom( bundlePath, filename, INT_64K_ROM + 0x8000, 0, 32 * KB);
memcpy(Apple2_64K_MEM + 0xC000, INT_64K_ROM + 0xC000, 16 * KB); // activate the upper ROM
}
else if ( flen == 16 * KB ) {
read_rom( bundlePath, filename, Apple2_64K_ROM + 0xC000, 0);
memcpy(Apple2_64K_MEM + 0xC000, Apple2_64K_ROM + 0xC000, 16 * KB);
read_rom( bundlePath, filename, INT_64K_ROM + 0xC000, 0, 16 * KB);
memcpy(Apple2_64K_MEM + 0xC000, INT_64K_ROM + 0xC000, 16 * KB);
}
else if ( flen == 12 * KB ) {
read_rom( bundlePath, filename, Apple2_64K_ROM + 0xD000, 0x1000);
memcpy(Apple2_64K_MEM + 0xD000, Apple2_64K_ROM + 0xD000, 12 * KB);
read_rom( bundlePath, filename, INT_64K_ROM + 0xD000, 0x1000, 12 * KB);
memcpy(Apple2_64K_MEM + 0xD000, INT_64K_ROM + 0xD000, 12 * KB);
}
}
@ -750,7 +761,7 @@ void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
#ifdef FUNCTIONTEST
read_rom( bundlePath, "6502_functional_test.bin", Apple2_64K_RAM, 0);
read_rom( bundlePath, "6502_functional_test.bin", Apple2_64K_RAM, 0, 0);
memcpy(Apple2_64K_MEM, Apple2_64K_RAM, 65536);
m6502.PC = 0x400;
@ -760,8 +771,8 @@ void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
rom_loadFile(bundlePath, romFileName);
// Disk ][ ROM in Slot 6
read_rom( bundlePath, "DISK_II_C600.ROM", Apple2_64K_ROM, 0xC600);
memcpy(Apple2_64K_MEM + 0xC600, Apple2_64K_ROM + 0xC600, 0x100);
read_rom( bundlePath, "DISK_II_C600.ROM", EXP_64K_ROM, 0xC600, 0x100);
memcpy(Apple2_64K_MEM + 0xC600, EXP_64K_ROM + 0xC600, 0x100);
m6502.A = m6502.X = m6502.Y = 0xFF;
// reset vector

View File

@ -124,7 +124,8 @@ typedef struct m6502_s {
uint64_t clktime; // 14:
uint64_t clklast; // 22:
uint32_t clkfrm; // 30:
uint64_t clk_wrenable; // CPU clock when WRITE RAM is triggered
debugLevel_t dbgLevel; // 34: 0: No Debug, 1: Disassembly Only, 2: Run till BRK, 3: StepByStep
@ -137,17 +138,6 @@ typedef struct m6502_s {
//#pragma pack()
typedef struct disassembly_s {
uint64_t clk; // clock time
char addr[5]; // 4 digits + \0
char opcode[4 * 3 + 1]; // max 4 bytes * (2 digits + 1 space) + \0
char * pOpcode; // pointer for opcode string builder
char inst[6 + 1]; // 3 char (unknown instr? -- give it 6 chars) + \0
char oper[14 + 2 + 1 + 1 + 1]; // 4 digits + 2 brackets + 1 comma + 1 index + \0
char comment[256]; // to be able to add some comments
} disassembly_t;
// Memory Config
typedef struct MEMcfg_s {
unsigned RAM_16K : 1;

View File

@ -675,13 +675,7 @@ void spkr_update() {
memset(spkr_samples + size, 0, spkr_buf_size * sizeof(spkr_sample_t));
// if ( spkr_sample_idx >= size ) {
// spkr_sample_idx -= size;
// }
// else {
spkr_sample_idx = 0;
// }
spkr_sample_idx = 0;
spkr_sample_last_idx = 0;
}
@ -801,6 +795,7 @@ void spkr_play_disk_motor() {
}
}
void spkr_stop_disk_motor( int time ) {
if ( ( disk_sfx_enabled ) && ( clk_6502_per_frm <= FRAME(iicplus_MHz_6502) ) ) {
spkr_play_disk_motor_time = time;
@ -832,6 +827,7 @@ void spkr_stopAll() {
}
}
void update_disk_sfx( unsigned * time, ALuint src ) {
if ( *time ) {
if ( --*time == 0 ) {
@ -840,6 +836,7 @@ void update_disk_sfx( unsigned * time, ALuint src ) {
}
}
void spkr_update_disk_sfx() {
// is user speeds up the machine, disk sfx needs to be stopped
if ( ( ! disk_sfx_enabled ) || ( clk_6502_per_frm > FRAME(iicplus_MHz_6502) ) ) {

View File

@ -39,6 +39,7 @@ unsigned trackOffset = 0;
unsigned bitOffset = 0;
uint64_t clkelpased;
int extraForward = 6; // we search for 7 bit high a bit further to speed up disk read...
char woz_filename[MAXFILENAME];
woz_flags_t woz_flags = {0,0,0,0};
@ -330,10 +331,13 @@ uint8_t woz_read() {
uint16_t usedBytes = (*woz_trks)[track].bytes_used < WOZ1_TRACK_BYTE_COUNT ? (*woz_trks)[track].bytes_used : WOZ1_TRACK_BYTE_COUNT;
if ( usedBytes ) {
static const int extraForward = 4; // we search for 7 bit high a bit further to speed up disk read...
// static const int extraForward = 4; // we search for 7 bit high a bit further to speed up disk read...
uint64_t bitForward = (clkelpased >> 2) + extraForward;
if ( bitForward > 100000000 ) {
bitForward = 4;
}
// Simulate idle spinning until s close point to the actual turn position
// Simulate idle spinning until a close point to the actual turn position
while ( bitForward-- ) {
if ( ++bitOffset > 7 ) {
bitOffset = 0;
@ -355,7 +359,7 @@ uint8_t woz_read() {
WOZread.latch = 0;
// but we do not want to miss that latch valid nibble...
// in other words synchronization is needed because of imperfect cycle calculation
if ( bitForward < 8 ) {
if ( bitForward < 18 ) {
return latch;
}
}

View File

@ -195,6 +195,7 @@ extern woz_flags_t woz_flags;
extern size_t woz_file_size;
extern uint8_t * woz_file_buffer;
extern int extraForward;
//extern woz_header_t woz_header;
//extern woz_chunk_header_t woz_chunk_header;

View File

@ -34,11 +34,13 @@
videoMode_t videoMode = { 1 }; // 40 col text, page 1
uint8_t INT_64K_ROM[ 64 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
uint8_t AUX_64K_ROM[ 64 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
uint8_t EXP_64K_ROM[ 64 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
uint8_t Apple2_Dummy_Page[ 1 * PG ]; // Dummy Page to discard data
uint8_t Apple2_Dummy_RAM[ 64 * KB ]; // Dummy RAM to discard data
uint8_t Apple2_64K_ROM[ 64 * KB ] = {0}; // ROM C0, C8, D0, D8, E0, E8, F0, F8
uint8_t Apple2_64K_AUX[ 64 * KB ] = {0}; // 64K Expansion Memory
uint8_t Apple2_64K_RAM[ 64 * KB ] = {0}; // Main Memory
uint8_t Apple2_64K_MEM[ 64 * KB ] = {0}; // Shadow Copy of Memory (or current memory content)
@ -79,13 +81,62 @@ const uint8_t * const shadowLowMEM = Apple2_64K_MEM + 0x200;
const uint8_t * currentLowMEM = Apple2_64K_RAM + 0x200;
/// No writing (Readonly), and mark it as NO need to commit from Shadow RAM
INLINE void set_MEM_readonly() {
printf("NOWR_AUX\n");
MEMcfg.WR_RAM = 0;
WRD0MEM = Apple2_Dummy_RAM; // for Discarding any writes to $D000 - $DFFF - BANK X
WRHIMEM = Apple2_Dummy_RAM; // for Discarding any writes to $E000 - $FFFF
}
/// Make AUX RAM writeable -- This is when AUX is also readable, othwrwise use set_AUX_write...
INLINE void set_MEM_write() {
// two consecutive read or write needs for write enable
// Note: if it is already writeable and was previously a ROM read + RAM write, then we also need to bound AUX to MEM
if ( ( (m6502.clktime + m6502.clkfrm - m6502.clk_wrenable) < 8 ) || (MEMcfg.WR_RAM) ) {
printf("WR_AUX\n");
// will write to Shadow RAM, and mark it as need to commit from Shadow RAM
MEMcfg.WR_RAM = 1;
WRD0MEM = Apple2_64K_MEM; // for Write $D000 - $DFFF (shadow memory) - BANK X
WRHIMEM = Apple2_64K_MEM; // for Write $E000 - $FFFF (shadow memory)
}
m6502.clk_wrenable = m6502.clktime + m6502.clkfrm;
}
/// Make AUX RAM writeable -- This is when ROM is readable, othwrwise use set_MEM_write...
INLINE void set_AUX_write() {
// will write directly to Auxiliary RAM, and mark it as NO need to commit from Shadow RAM
// Note: if it is already writeable and was previously a RAM read + RAM write, then we also need to bound AUX to MEM
if ( ( (m6502.clktime + m6502.clkfrm - m6502.clk_wrenable) < 8 ) || (MEMcfg.WR_RAM) ) {
printf("WR_AUX\n");
MEMcfg.WR_RAM = 1;
if ( MEMcfg.RAM_BANK_2 ) {
WRD0MEM = Apple2_64K_AUX; // for Write $D000 - $DFFF (shadow memory) - BANK 2 at 0xD000
}
else {
WRD0MEM = Apple2_64K_AUX - 0x1000; // for Write $D000 - $DFFF (shadow memory) - BANK 1 at 0xC000
}
WRHIMEM = Apple2_64K_AUX; // for Write $E000 - $FFFF (shadow memory)
}
m6502.clk_wrenable = m6502.clktime + m6502.clkfrm;
}
INLINE void io_RAM_EXP( uint16_t addr ) {
if ( MEMcfg.RAM_16K || MEMcfg.RAM_128K ) {
uint8_t * RAM_BANK = Apple2_64K_AUX + 0xC000;
// TODO: store 0xD000 BANK 1 at 0xC000 -- might be a problem emulating 64k/128k Saturn cards
// uint8_t * RAM_BANK = Apple2_64K_AUX + 0xC000;
// save the content of Shadow Memory in needed
if ( MEMcfg.WR_RAM ) {
if ( MEMcfg.WR_RAM && MEMcfg.RD_INT_RAM ) {
// printf("Saving RAM Bank %d to %p\n", MEMcfg.RAM_BANK_2 + 1, current_RAM_bank);
memcpy(current_RAM_bank, Apple2_64K_MEM + 0xD000, 0x1000);
memcpy(Apple2_64K_AUX + 0xE000, Apple2_64K_MEM + 0xE000, 0x2000);
@ -103,17 +154,17 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
case (uint8_t)io_MEM_RDROM_NOWR_2_:
case (uint8_t)io_MEM_RDRAM_WRAM_2_:
// printf("RAM_BANK_2\n");
printf("RAM_BANK_2\n");
MEMcfg.RAM_BANK_2 = 1;
RAM_BANK = Apple2_64K_AUX + 0xD000;
current_RAM_bank = Apple2_64K_AUX + 0xD000;
break;
default:
// printf("RAM_BANK_1\n");
printf("RAM_BANK_1\n");
MEMcfg.RAM_BANK_2 = 0;
RAM_BANK = Apple2_64K_AUX + 0xC000;
current_RAM_bank = Apple2_64K_AUX + 0xC000;
break;
}
@ -129,24 +180,24 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
case (uint8_t)io_MEM_RDRAM_NOWR_1_:
case (uint8_t)io_MEM_RDRAM_WRAM_1_:
// printf("RD_RAM\n");
printf("RD_RAM\n");
MEMcfg.RD_INT_RAM = 1;
// load the content of Aux Memory
memcpy(Apple2_64K_MEM + 0xD000, RAM_BANK, 0x1000);
memcpy(Apple2_64K_MEM + 0xD000, current_RAM_bank, 0x1000);
memcpy(Apple2_64K_MEM + 0xE000, Apple2_64K_AUX + 0xE000, 0x2000);
// set the RAM extension to read on the upper memory area
break;
default:
// printf("RD_ROM\n");
printf("RD_ROM\n");
MEMcfg.RD_INT_RAM = 0;
// load the content of ROM Memory
memcpy(Apple2_64K_MEM + 0xD000, Apple2_64K_ROM + 0xD000, 0x3000);
memcpy(Apple2_64K_MEM + 0xD000, INT_64K_ROM + 0xD000, 0x3000);
// set the ROM to read on the upper memory area
break;
@ -160,17 +211,10 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
case (uint8_t)io_MEM_RDROM_WRAM_2_:
case (uint8_t)io_MEM_RDROM_WRAM_1_:
// printf("RD_ROM + WR_AUX\n");
printf("RD_ROM + WR_AUX\n");
set_AUX_write();
// will write directly to Auxiliary RAM, and mark it as NO need to commit from Shadow RAM
MEMcfg.WR_RAM = 0;
if ( MEMcfg.RAM_BANK_2 ) {
WRD0MEM = Apple2_64K_AUX; // for Write $D000 - $DFFF (shadow memory) - BANK 2
}
else {
WRD0MEM = Apple2_64K_AUX - 0x1000; // for Write $D000 - $DFFF (shadow memory) - BANK 1
}
WRHIMEM = Apple2_64K_AUX; // for Write $E000 - $FFFF (shadow memory)
break;
case (uint8_t)io_MEM_RDRAM_WRAM_2:
@ -179,25 +223,21 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
case (uint8_t)io_MEM_RDRAM_WRAM_2_:
case (uint8_t)io_MEM_RDRAM_WRAM_1_:
// printf("RD_RAM + WR_RAM\n");
printf("RD_RAM + WR_RAM\n");
// will write to Shadow RAM, and mark it as need to commit from Shadow RAM
MEMcfg.WR_RAM = 1;
WRD0MEM = Apple2_64K_MEM; // for Write $D000 - $DFFF (shadow memory) - BANK X
WRHIMEM = Apple2_64K_MEM; // for Write $E000 - $FFFF (shadow memory)
set_MEM_write();
break;
default:
// printf("RD_ROM + NO_WR\n");
// No writing (Readonly), and mark it as NO need to commit from Shadow RAM
MEMcfg.WR_RAM = 0;
WRD0MEM = Apple2_Dummy_RAM; // for Discarding any writes to $D000 - $DFFF - BANK X
WRHIMEM = Apple2_Dummy_RAM; // for Discarding any writes to $E000 - $FFFF
printf("RD_ROM + NO_WR\n");
set_MEM_readonly();
break;
}
current_RAM_bank = RAM_BANK;
// current_RAM_bank = RAM_BANK;
// printf("Set current_RAM_bank %d to %p\n", MEMcfg.RAM_BANK_2 + 1, current_RAM_bank);
@ -208,7 +248,15 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
INLINE uint8_t ioRead( uint16_t addr ) {
// if (outdev) fprintf(outdev, "ioRead:%04X\n", addr);
// printf("ioRead:%04X (PC:%04X)\n", addr, m6502.PC);
// switch(addr) {
// case io_KBD:
// case io_KBDSTRB:
// case io_SPKR:
// break;
// default:
// printf("ioRead:%04X (PC:%04X)\n", addr, m6502.PC);
// }
unsigned int IOframe = m6502.clkfrm - lastIO;
lastIO = m6502.clkfrm;
@ -229,6 +277,25 @@ INLINE uint8_t ioRead( uint16_t addr ) {
}
switch ( (uint8_t)addr ) {
// case 0x20:
case 0x21:
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
case 0x2C:
case 0x2D:
case 0x2E:
case 0x2F:
printf("RD TAPEIO: %04X\n", addr);
return 0;
case (uint8_t)io_KBD:
return Apple2_64K_RAM[io_KBD];
@ -282,7 +349,7 @@ INLINE uint8_t ioRead( uint16_t addr ) {
case (uint8_t)io_RDALTZP:
return MEMcfg.ALT_ZP << 7;
case (uint8_t)io_RDC3ROM:
return MEMcfg.slot_C3_ROM << 7;
@ -469,7 +536,36 @@ INLINE uint8_t ioRead( uint16_t addr ) {
INLINE void ioWrite( uint16_t addr, uint8_t val ) {
// if (outdev) fprintf(outdev, "ioWrite:%04X (A:%02X)\n", addr, m6502.A);
// switch(addr) {
// case io_KBD:
// case io_KBDSTRB:
// case io_SPKR:
// break;
// default:
// printf("ioWrite:%04X (PC:%04X, val:%02X)\n", addr, m6502.PC, val);
// }
switch ( (uint8_t)addr ) {
// case 0x20:
case 0x21:
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x28:
case 0x29:
case 0x2A:
case 0x2B:
case 0x2C:
case 0x2D:
case 0x2E:
case 0x2F:
printf("WR TAPEIO: %04X\n", addr);
return;
case (uint8_t)io_KBDSTRB:
Apple2_64K_RAM[io_KBD] &= 0x7F;
break;
@ -765,7 +861,7 @@ INLINE uint8_t memread( uint16_t addr ) {
INLINE void memwrite8_low( uint16_t addr, uint8_t data ) {
WRLOMEM[addr] = data;
}
INLINE void memwrite8_bank2( uint16_t addr, uint8_t data ) {
INLINE void memwrite8_bank( uint16_t addr, uint8_t data ) {
WRD0MEM[addr] = data;
}
INLINE void memwrite8_high( uint16_t addr, uint8_t data ) {
@ -782,7 +878,7 @@ INLINE void memwrite( uint16_t addr, uint8_t data ) {
}
else if (addr < 0xE000) {
// Aux RAM Bank 1 or 2
memwrite8_bank2(addr, data);
memwrite8_bank(addr, data);
}
else {
// ROM (dummy memory to screape writings) or Aux RAM
@ -1057,11 +1153,11 @@ void C3MemorySelect( MEMcfg_t newMEMcfg ) {
if ( newMEMcfg.slot_C3_ROM ) {
// load internal ROM to memory
memcpy(Apple2_64K_MEM + 0xC300, Apple2_64K_RAM + 0xC300, 0x100);
memcpy(Apple2_64K_MEM + 0xC300, INT_64K_ROM + 0xC300, 0x100);
}
else {
// load peripheral ROM to memory
memcpy(Apple2_64K_MEM + 0xC300, Apple2_64K_ROM + 0xC300, 0x100);
memcpy(Apple2_64K_MEM + 0xC300, EXP_64K_ROM + 0xC300, 0x100);
}
MEMcfg = newMEMcfg;
@ -1072,11 +1168,11 @@ void CxMemorySelect( MEMcfg_t newMEMcfg ) {
if ( newMEMcfg.int_Cx_ROM ) {
// load internal ROM to memory
memcpy(Apple2_64K_MEM + 0xC100, Apple2_64K_ROM + 0xC100, 0xF00);
memcpy(Apple2_64K_MEM + 0xC100, INT_64K_ROM + 0xC100, 0xF00);
}
else {
// load peripheral ROM to memory
memcpy(Apple2_64K_MEM + 0xC100, Apple2_64K_RAM + 0xC100, 0xF00);
memcpy(Apple2_64K_MEM + 0xC100, EXP_64K_ROM + 0xC100, 0xF00);
// memcpy(Apple2_64K_MEM + 0xC600, Apple2_64K_RAM + 0xC600, 0x100);
}
@ -1098,7 +1194,7 @@ void resetMemory() {
CxMemorySelect(MEMcfg);
// initializing disk controller
memcpy(Apple2_64K_MEM + 0xC600, Apple2_64K_ROM + 0xC600, 0x100);
memcpy(Apple2_64K_MEM + 0xC600, EXP_64K_ROM + 0xC600, 0x100);
MEMcfg = newMEMcfg;

View File

@ -50,7 +50,8 @@ extern videoMode_t videoMode; // 40 col text, page 1
extern uint8_t Apple2_Dummy_Page[ 1 * PG ]; // Dummy Page to discard data
extern uint8_t Apple2_Dummy_RAM[ 64 * KB ]; // Dummy RAM to discard data
extern uint8_t Apple2_64K_ROM[ 64 * KB ]; // ROM C0, C8, D0, D8, E0, E8, F0, F8
extern uint8_t INT_64K_ROM[ 64 * KB ]; // ROM C0, C8, D0, D8, E0, E8, F0, F8
extern uint8_t EXP_64K_ROM[ 64 * KB ]; // ROM C0, C8, D0, D8, E0, E8, F0, F8
extern uint8_t Apple2_64K_AUX[ 64 * KB ]; // 64K Expansion Memory
extern uint8_t Apple2_64K_RAM[ 64 * KB ]; // Main Memory
@ -390,7 +391,7 @@ INLINE uint16_t memread16_low( uint16_t addr );
INLINE uint16_t memread16( uint16_t addr );
INLINE uint8_t memread( uint16_t addr );
INLINE void memwrite8_low( uint16_t addr, uint8_t data );
INLINE void memwrite8_bank2( uint16_t addr, uint8_t data );
INLINE void memwrite8_bank( uint16_t addr, uint8_t data );
INLINE void memwrite8_high( uint16_t addr, uint8_t data );
INLINE void memwrite( uint16_t addr, uint8_t data );
INLINE uint8_t fetch(void);

107
src/util/disassembler.c Normal file
View File

@ -0,0 +1,107 @@
//
// disassembler.c
// A2Mac
//
// Created by Tamas Rudnai on 3/13/22.
// Copyright © 2022 GameAlloy. All rights reserved.
//
#include <stdio.h>
#include "disassembler.h"
disassembly_t disassembly;
unsigned long long discnt = 0;
INLINE flags_t getFlags2() {
flags_t f = {
m6502.C != 0, // Carry Flag
m6502.Z != 0, // Zero Flag
m6502.I != 0, // Interrupt Flag
m6502.D != 0, // Decimal Flag
m6502.B != 0, // B Flag
m6502.res != 0, // reserved -- should be always 1
m6502.V != 0, // Overflow Flag ???
m6502.N != 0, // Negative Flag
};
return f;
}
void printDisassembly( FILE * f ) {
if ( m6502.dbgLevel.trace && f ) {
// fprintf( f, "%s: %-14s%-6s%-14s%-16s A:%02X X:%02X Y:%02X S:%02X P:%02X (%c%c%c%c%c%c%c%c)\n",
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper,
// disassembly.comment,
// m6502.A,
// m6502.X,
// m6502.Y,
// m6502.SP,
// m6502.SR,
// m6502.N ? 'N' : 'n',
// m6502.V ? 'V' : 'v',
// m6502.res ? 'R' : 'r',
// m6502.B ? 'B' : 'b',
// m6502.D ? 'D' : 'd',
// m6502.I ? 'I' : 'i',
// m6502.Z ? 'Z' : 'z',
// m6502.C ? 'C' : 'c'
// );
// fprintf( f, "%llu\t%llu %s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t;\t%s\n", // Virtual ][ style
// ++discnt,
// m6502.clktime + clkfrm,
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper,
// m6502.A,
// m6502.X,
// m6502.Y,
// 0,
// //getFlags2(),
// m6502.SP,
// disassembly.comment
// );
// Virtual ][ Style
fprintf( f, "%llu\t%llu\t%s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\n", // Virtual ][ style
++discnt,
disassembly.clk,
disassembly.addr,
disassembly.opcode,
disassembly.inst,
disassembly.oper,
m6502.A,
m6502.X,
m6502.Y,
getFlags2().SR,
m6502.SP
);
// static char line[256];
// // Steve ][ Style
// snprintf( line, sizeof(line), "%10llu %10llu %s: %-11s%-4s%s", // Steve ][ style
// ++discnt,
// disassembly.clk,
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper
// );
//
// fprintf( f, "%-55s; 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", // Steve ][ style
// line,
// m6502.A,
// m6502.X,
// m6502.Y,
// getFlags2().SR,
// m6502.SP
// );
}
}

View File

@ -24,12 +24,29 @@
#ifndef disassembler_h
#define disassembler_h
#undef DISASSEMBLER
#include "6502.h"
#include "common.h"
typedef struct disassembly_s {
uint64_t clk; // clock time
char addr[5]; // 4 digits + \0
char opcode[4 * 3 + 1]; // max 4 bytes * (2 digits + 1 space) + \0
char * pOpcode; // pointer for opcode string builder
char inst[6 + 1]; // 3 char (unknown instr? -- give it 6 chars) + \0
char oper[14 + 2 + 1 + 1 + 1]; // 4 digits + 2 brackets + 1 comma + 1 index + \0
char comment[256]; // to be able to add some comments
} disassembly_t;
extern disassembly_t disassembly;
//#define DISASSEMBLER
//#undef DISASSEMBLER
#ifdef DISASSEMBLER
//extern unsigned long long int clktime;
unsigned long long discnt = 0;
extern unsigned long long discnt;
#define disHexB( to, b ) \
if ( m6502.dbgLevel.trace ) { \
@ -69,100 +86,7 @@ unsigned long long discnt = 0;
} \
}
INLINE flags_t getFlags2() {
flags_t f = {
m6502.C != 0, // Carry Flag
m6502.Z != 0, // Zero Flag
m6502.I != 0, // Interrupt Flag
m6502.D != 0, // Decimal Flag
m6502.B != 0, // B Flag
m6502.res != 0, // reserved -- should be always 1
m6502.V != 0, // Overflow Flag ???
m6502.N != 0, // Negative Flag
};
return f;
}
INLINE void printDisassembly( FILE * f ) {
if ( m6502.dbgLevel.trace && f ) {
// fprintf( f, "%s: %-14s%-6s%-14s%-16s A:%02X X:%02X Y:%02X S:%02X P:%02X (%c%c%c%c%c%c%c%c)\n",
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper,
// disassembly.comment,
// m6502.A,
// m6502.X,
// m6502.Y,
// m6502.SP,
// m6502.SR,
// m6502.N ? 'N' : 'n',
// m6502.V ? 'V' : 'v',
// m6502.res ? 'R' : 'r',
// m6502.B ? 'B' : 'b',
// m6502.D ? 'D' : 'd',
// m6502.I ? 'I' : 'i',
// m6502.Z ? 'Z' : 'z',
// m6502.C ? 'C' : 'c'
// );
// fprintf( f, "%llu\t%llu %s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t;\t%s\n", // Virtual ][ style
// ++discnt,
// m6502.clktime + clkfrm,
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper,
// m6502.A,
// m6502.X,
// m6502.Y,
// 0,
// //getFlags2(),
// m6502.SP,
// disassembly.comment
// );
// // Virtual ][ Style
// fprintf( f, "%llu\t%llu\t%s: %-11s%-4s%s\t0x%02X\t0x%02X\t0x%02X\t0x%02X\t0x%02X\n", // Virtual ][ style
// ++discnt,
// disassembly.clk,
// disassembly.addr,
// disassembly.opcode,
// disassembly.inst,
// disassembly.oper,
// m6502.A,
// m6502.X,
// m6502.Y,
// getFlags2().SR,
// m6502.SP
// );
//
// }
static char line[256];
// Steve ][ Style
snprintf( line, sizeof(line), "%10llu %10llu %s: %-11s%-4s%s", // Steve ][ style
++discnt,
disassembly.clk,
disassembly.addr,
disassembly.opcode,
disassembly.inst,
disassembly.oper
);
fprintf( f, "%-55s; 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", // Steve ][ style
line,
m6502.A,
m6502.X,
m6502.Y,
getFlags2().SR,
m6502.SP
);
}
}
extern void printDisassembly( FILE * f );
#else // DISASSEMBLER