diff --git a/ActiveGS_iOS/activegs.plist b/ActiveGS_iOS/activegs.plist
index 14dc2d1..d3f6440 100644
--- a/ActiveGS_iOS/activegs.plist
+++ b/ActiveGS_iOS/activegs.plist
@@ -91,6 +91,7 @@
UIAppFonts
ShastonHi640.ttf
+ PrintChar21.ttf
UIFileSharingEnabled
diff --git a/ActiveGS_iOS/activegs.xcodeproj/project.pbxproj b/ActiveGS_iOS/activegs.xcodeproj/project.pbxproj
index 25462a2..da6316c 100644
--- a/ActiveGS_iOS/activegs.xcodeproj/project.pbxproj
+++ b/ActiveGS_iOS/activegs.xcodeproj/project.pbxproj
@@ -247,6 +247,9 @@
928410581CA8443A00DC5D93 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 928410571CA8443A00DC5D93 /* Images.xcassets */; };
92B9EADF24D3369700E6CFB2 /* EmulatorKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B9EADE24D3369700E6CFB2 /* EmulatorKeyboard.swift */; };
92E2063225AADFB000AE3F28 /* PreviewUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92E2063125AADF6E00AE3F28 /* PreviewUI.swift */; };
+ 92FA0F2425B52EA200663577 /* EmuWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 92FA0F2325B52EA200663577 /* EmuWrapper.mm */; };
+ 92FA0F2A25B5353D00663577 /* DebugMemoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92FA0F2925B5353D00663577 /* DebugMemoryViewController.swift */; };
+ 92FA0F2D25B59EF100663577 /* PrintChar21.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 92FA0F2C25B59EF100663577 /* PrintChar21.ttf */; };
/* End PBXBuildFile section */
/* Begin PBXBuildRule section */
@@ -600,6 +603,10 @@
92B9EADD24D3369600E6CFB2 /* ActiveGS-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ActiveGS-Bridging-Header.h"; sourceTree = ""; };
92B9EADE24D3369700E6CFB2 /* EmulatorKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmulatorKeyboard.swift; sourceTree = ""; };
92E2063125AADF6E00AE3F28 /* PreviewUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewUI.swift; sourceTree = ""; };
+ 92FA0F2325B52EA200663577 /* EmuWrapper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = EmuWrapper.mm; sourceTree = ""; };
+ 92FA0F2625B52EC000663577 /* EmuWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EmuWrapper.h; sourceTree = ""; };
+ 92FA0F2925B5353D00663577 /* DebugMemoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugMemoryViewController.swift; sourceTree = ""; };
+ 92FA0F2C25B59EF100663577 /* PrintChar21.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = PrintChar21.ttf; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -1016,6 +1023,9 @@
92B9EADE24D3369700E6CFB2 /* EmulatorKeyboard.swift */,
92E2063125AADF6E00AE3F28 /* PreviewUI.swift */,
92B9EADD24D3369600E6CFB2 /* ActiveGS-Bridging-Header.h */,
+ 92FA0F2325B52EA200663577 /* EmuWrapper.mm */,
+ 92FA0F2625B52EC000663577 /* EmuWrapper.h */,
+ 92FA0F2925B5353D00663577 /* DebugMemoryViewController.swift */,
);
name = Common.iphone;
path = ../Common.iphone;
@@ -1115,6 +1125,7 @@
7E5148141CA6B5CE005DA0A6 /* floppy_eject.wav */,
7E5148151CA6B5CE005DA0A6 /* logo_apple2.png */,
7E5148161CA6B5CE005DA0A6 /* logo_apple2gs.png */,
+ 92FA0F2C25B59EF100663577 /* PrintChar21.ttf */,
7E5148171CA6B5CE005DA0A6 /* Search Skip Search 1.wav */,
7E5148181CA6B5CE005DA0A6 /* Search Skip Search 2.wav */,
7E5148191CA6B5CE005DA0A6 /* Search Skip Search 3.wav */,
@@ -1306,6 +1317,7 @@
09AF980F1283F12200083D60 /* starwizard_4.png in Resources */,
09AF98101283F12200083D60 /* starwizard_5.png in Resources */,
09AF98111283F12200083D60 /* starwizard.png in Resources */,
+ 92FA0F2D25B59EF100663577 /* PrintChar21.ttf in Resources */,
7E51482C1CA6B5CE005DA0A6 /* Search Skip Search 3.wav in Resources */,
09D8BCF91285EFE900B6D785 /* miniprix_1.png in Resources */,
09D8BCFC1285EFFA00B6D785 /* miniprix_2.png in Resources */,
@@ -1341,6 +1353,7 @@
9222DD461CBECF2300B321B9 /* main.mm in Sources */,
09BB434511D92F65005ADA46 /* ActiveDownloadMac.cpp in Sources */,
09BB434711D92F65005ADA46 /* CEmulatorCtrlMac.cpp in Sources */,
+ 92FA0F2A25B5353D00663577 /* DebugMemoryViewController.swift in Sources */,
09BB43B011D92F70005ADA46 /* activeconfig.cpp in Sources */,
09BB43B111D92F70005ADA46 /* ActiveDownload.cpp in Sources */,
92B9EADF24D3369700E6CFB2 /* EmulatorKeyboard.swift in Sources */,
@@ -1429,6 +1442,7 @@
0941E6AF16720886003E0411 /* simplexml.cpp in Sources */,
09520D8316AEF8130065E84A /* driver.cpp in Sources */,
09520D8916AEF8250065E84A /* activegs_driver.cpp in Sources */,
+ 92FA0F2425B52EA200663577 /* EmuWrapper.mm in Sources */,
09520D8E16AEF8650065E84A /* apple2e.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/Common.iphone/ActiveGS-Bridging-Header.h b/Common.iphone/ActiveGS-Bridging-Header.h
index 1b598a7..e37a32d 100644
--- a/Common.iphone/ActiveGS-Bridging-Header.h
+++ b/Common.iphone/ActiveGS-Bridging-Header.h
@@ -3,3 +3,5 @@
//
#import "KeyMapper.h"
+
+#import "EmuWrapper.h"
diff --git a/Common.iphone/DebugMemoryViewController.swift b/Common.iphone/DebugMemoryViewController.swift
new file mode 100644
index 0000000..f91face
--- /dev/null
+++ b/Common.iphone/DebugMemoryViewController.swift
@@ -0,0 +1,215 @@
+//
+// DebugMemoryViewController.swift
+// ActiveGS
+//
+// Created by Yoshi Sugawara on 1/17/21.
+//
+
+import Foundation
+import UIKit
+
+class EmuMemoryModel {
+ // make this static for now
+ let numToDisplayPerCell = 8
+ let maxMemorySize = 128 * 1024
+
+ let slowMemory = EmuWrapper.slowMemory()
+
+ func offset(for indexPath: IndexPath) -> Int {
+ return indexPath.row * numToDisplayPerCell
+ }
+
+ func hexStrings(for indexPath: IndexPath) -> [String] {
+ let startIndex = offset(for: indexPath)
+ let endIndex = min(maxMemorySize, startIndex + numToDisplayPerCell)
+ var row = [String]()
+ guard let slowMemory = slowMemory else {
+ return row
+ }
+ for i in startIndex.. String {
+ guard address > 0 && address < maxMemorySize else {
+ print("Cannot get memory: address out of range \(address) > \(maxMemorySize)")
+ return ""
+ }
+ guard let slowMemory = slowMemory else {
+ return ""
+ }
+ let value = slowMemory[address]
+ return String(format: "%02X", value)
+ }
+
+ func getMemoryHeaderString(for address: Int) -> String {
+ return String(format: "%02X", address)
+ }
+
+ func setMemory(at address:Int, value: UInt8) {
+ guard address > 0 && address < maxMemorySize else {
+ print("Cannot set memory: address out of range \(address) > \(maxMemorySize)")
+ return
+ }
+ guard let slowMemory = slowMemory else {
+ return
+ }
+ slowMemory[address] = value
+ }
+
+}
+
+class DebugMemoryCell: UITableViewCell {
+ static let identifier = "DebugMemoryCell"
+
+ var offset: Int?
+
+ lazy var stackView: UIStackView = {
+ let view = UIStackView(frame: .zero)
+ view.translatesAutoresizingMaskIntoConstraints = false
+ view.axis = .horizontal
+ view.spacing = 8.0
+ view.alignment = .center
+ return view
+ }()
+
+ let addressLabel: UILabel = {
+ let label = UILabel(frame: .zero)
+ label.translatesAutoresizingMaskIntoConstraints = false
+ label.font = UIFont(name: "Print Char 21", size: 16)
+ label.textColor = .yellow
+ label.setContentHuggingPriority(.defaultHigh, for: .horizontal)
+ return label
+ }()
+
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+ super.init(style: style, reuseIdentifier: reuseIdentifier)
+ contentView.addSubview(stackView)
+ stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 8.0).isActive = true
+ stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: 8.0).isActive = true
+ stackView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8.0).isActive = true
+ stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: 8.0).isActive = true
+ backgroundColor = .clear
+ selectionStyle = .none
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ func updateWith(offset: Int, hexMemoryValues: [String]) {
+ self.offset = offset
+ stackView.arrangedSubviews.forEach{ $0.removeFromSuperview() }
+ addressLabel.text = String(format: "%04X:", offset)
+ stackView.addArrangedSubview(addressLabel)
+ stackView.setCustomSpacing(3, after: addressLabel)
+ for (index, hexValue) in hexMemoryValues.enumerated() {
+ let button = UIButton(type: .custom)
+ button.setTitle(hexValue, for: .normal)
+ button.titleLabel?.font = UIFont(name: "Print Char 21", size: 16)
+ button.setTitleColor(.green, for: .normal)
+ button.tag = index
+ button.addTarget(self, action: #selector(didTapOnButton(_:)), for: .touchUpInside)
+ stackView.addArrangedSubview(button)
+ }
+ let spacer = UIView()
+ spacer.setContentHuggingPriority(.defaultLow, for: .horizontal)
+ stackView.addArrangedSubview(spacer)
+ }
+
+ @objc func didTapOnButton(_ button: UIButton) {
+ let memoryAddr = String(format:"%04X",(offset ?? 0) + button.tag)
+ print("tapped on button index \(button.tag), address: \(memoryAddr) ")
+ }
+}
+
+@objc class DebugMemoryViewController: UIViewController {
+ let memoryModel = EmuMemoryModel()
+
+ let titleLabel: UILabel = {
+ let label = UILabel(frame: .zero)
+ label.translatesAutoresizingMaskIntoConstraints = false
+ label.font = UIFont(name: "Print Char 21", size: 14)
+ label.textColor = .white
+ label.text = "Memory Debugger"
+ return label
+ }()
+
+ let dismissButton: UIButton = {
+ let button = UIButton(type: .custom)
+ button.translatesAutoresizingMaskIntoConstraints = false
+ button.setTitle("[X]", for: .normal)
+ button.addTarget(self, action: #selector(closeTapped(_:)), for: .touchUpInside)
+ button.titleLabel?.font = UIFont(name: "Print Char 21", size: 12)
+ button.setTitleColor(.red, for: .normal)
+ return button
+ }()
+
+ let tableView: UITableView = {
+ let view = UITableView(frame: .zero)
+ view.translatesAutoresizingMaskIntoConstraints = false
+ view.backgroundColor = .clear
+ return view
+ }()
+
+ init() {
+ super.init(nibName: nil, bundle: nil)
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ func setupView() {
+ view.addSubview(titleLabel)
+ view.addSubview(tableView)
+ view.addSubview(dismissButton)
+ titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
+ titleLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 16).isActive = true
+ tableView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 8).isActive = true
+ tableView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -8).isActive = true
+ tableView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 16).isActive = true
+ tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
+ dismissButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -8).isActive = true
+ dismissButton.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 8.0).isActive = true
+ view.backgroundColor = .black
+ }
+
+ func setupTableView() {
+ tableView.dataSource = self
+ tableView.register(DebugMemoryCell.self, forCellReuseIdentifier: DebugMemoryCell.identifier)
+ }
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ setupView()
+ setupTableView()
+ }
+
+ @objc func closeTapped(_ sender: UIButton) {
+ dismiss(animated: true) {
+ EmuWrapper.resume()
+ }
+ }
+}
+
+extension DebugMemoryViewController: UITableViewDataSource {
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ var numRows = memoryModel.maxMemorySize / memoryModel.numToDisplayPerCell
+ if memoryModel.maxMemorySize % memoryModel.numToDisplayPerCell > 0 {
+ numRows += 1
+ }
+ return numRows
+ }
+
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+ let cell = tableView.dequeueReusableCell(withIdentifier: DebugMemoryCell.identifier, for: indexPath) as! DebugMemoryCell
+ let memoryVals = memoryModel.hexStrings(for: indexPath)
+ cell.updateWith(offset: memoryModel.offset(for: indexPath), hexMemoryValues: memoryVals)
+ return cell
+ }
+
+
+}
diff --git a/Common.iphone/EmuWrapper.h b/Common.iphone/EmuWrapper.h
new file mode 100644
index 0000000..94ad6fc
--- /dev/null
+++ b/Common.iphone/EmuWrapper.h
@@ -0,0 +1,22 @@
+//
+// EmuWrapper.h
+// activegs
+//
+// Created by Yoshi Sugawara on 1/17/21.
+//
+
+#ifndef EmuWrapper_h
+#define EmuWrapper_h
+
+
+#endif /* EmuWrapper_h */
+
+#import
+
+
+@interface EmuWrapper: NSObject
++(unsigned char*) slowMemory;
++(void)pause;
++(void)resume;
+
+@end
diff --git a/Common.iphone/EmuWrapper.mm b/Common.iphone/EmuWrapper.mm
new file mode 100644
index 0000000..932d69b
--- /dev/null
+++ b/Common.iphone/EmuWrapper.mm
@@ -0,0 +1,29 @@
+//
+// EmuWrapper.m
+// ActiveGS
+//
+// Created by Yoshi Sugawara on 1/17/21.
+//
+
+#import
+#import "EmuWrapper.h"
+
+#include "../Common.osx/cemulatorctrlmac.h"
+#include "../kegs/Src/defc.h"
+#include "../kegs/Src/sim65816.h"
+
+@implementation EmuWrapper
+
++(unsigned char*) slowMemory {
+ return g_slow_memory_ptr;
+}
+
++(void)pause {
+ r_sim65816.pause();
+}
+
++(void)resume {
+ r_sim65816.resume();
+}
+
+@end
diff --git a/Common.iphone/KBDController.mm b/Common.iphone/KBDController.mm
index 42d71df..bfbc614 100644
--- a/Common.iphone/KBDController.mm
+++ b/Common.iphone/KBDController.mm
@@ -23,6 +23,7 @@
#include "../Common/ActiveDownload.h"
#import "MfiGameControllerHandler.h"
#import "GameControllerKeyRemapController.h"
+#import "ActiveGS-Swift.h"
#ifdef ACTIVEGS_CUSTOMKEYS
#include "UICustomKey.h"
@@ -1115,6 +1116,12 @@ extern int x_frame_rate ;
[self presentViewController:remapController animated:YES completion:nil];
}
+-(void) memoryDebuggerButtonPressed:(id)sender {
+ r_sim65816.pause();
+ DebugMemoryViewController *controller = [[DebugMemoryViewController alloc] init];
+ [self presentViewController:controller animated:YES completion:nil];
+}
+
//
-(void)addRuntimeControls
{
@@ -1236,6 +1243,19 @@ extern int x_frame_rate ;
[remapControlsButton addTarget:self action:@selector(remapControlsButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.runtimeControlsOptions addSubview:remapControlsButton];
+ l += LINEHEIGHT;
+
+ l += 2.0;
+ UIButton *memoryDebuggerButton = [UIButton buttonWithType:UIButtonTypeCustom];
+ memoryDebuggerButton.frame = CGRectMake(OPTIONMARGIN,l,OPTIONWIDTH,LINEHEIGHT);
+ [memoryDebuggerButton setTitle:@"Memory Debugger" forState:UIControlStateNormal];
+ memoryDebuggerButton.titleLabel.font = [UIFont systemFontOfSize:12*res];
+ memoryDebuggerButton.backgroundColor = [UIColor clearColor];
+ memoryDebuggerButton.layer.borderWidth = 1.0f;
+ memoryDebuggerButton.layer.borderColor = [self.view.tintColor CGColor];
+ [memoryDebuggerButton addTarget:self action:@selector(memoryDebuggerButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
+ [self.runtimeControlsOptions addSubview:memoryDebuggerButton];
+
l += LINEHEIGHT;
nbs++;
diff --git a/Common.iphone/activegsAppDelegate.mm b/Common.iphone/activegsAppDelegate.mm
index 5bba73f..6b8d1a4 100644
--- a/Common.iphone/activegsAppDelegate.mm
+++ b/Common.iphone/activegsAppDelegate.mm
@@ -370,6 +370,16 @@ void x_init_persistent_path(MyString& hp)
[[pManager getBrowserView] updateView ];
+ // fonts!
+ for (NSString *family in [UIFont familyNames]) {
+ NSArray *fontNames = [UIFont fontNamesForFamilyName:family];
+ NSLog(@"Family: %@", family);
+ for (NSString *name in fontNames) {
+ NSLog(@"Font name: %@",name);
+ }
+ NSLog(@"");
+ }
+
[self.window makeKeyAndVisible];
#ifdef HANDLE_URL
diff --git a/Common.res/PrintChar21.ttf b/Common.res/PrintChar21.ttf
new file mode 100644
index 0000000..7204e97
Binary files /dev/null and b/Common.res/PrintChar21.ttf differ