Fixing SPM targets. Adding example project
This commit is contained in:
parent
cb12225d5e
commit
83bb16b28b
7
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
BIN
.swiftpm/xcode/package.xcworkspace/xcuserdata/selim.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
BIN
.swiftpm/xcode/package.xcworkspace/xcuserdata/selim.xcuserdatad/UserInterfaceState.xcuserstate
generated
Normal file
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>NesKit.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<key>nes-Package.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>NesKit</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>nes</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@ -9,8 +9,8 @@ add_executable(nes
|
||||
examples/sdl/main.cpp
|
||||
src/Cartridge.cpp
|
||||
src/Cartridge.h
|
||||
src/Nes.cpp
|
||||
src/Nes.h
|
||||
src/System.cpp
|
||||
src/System.h
|
||||
src/Cpu.cpp
|
||||
src/Cpu.h
|
||||
src/Mapper/Mapper.cpp
|
||||
|
||||
18
NesKit/NesSystem.h
Normal file
18
NesKit/NesSystem.h
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// NesSystem.h
|
||||
//
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NesSystem : NSObject
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
28
NesKit/NesSystem.mm
Normal file
28
NesKit/NesSystem.mm
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// NesSystem.m
|
||||
//
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
|
||||
#import "NesSystem.h"
|
||||
#import <NesKitCpp.h>
|
||||
#import <memory>
|
||||
|
||||
|
||||
@interface NesSystem()
|
||||
|
||||
@end
|
||||
|
||||
@implementation NesSystem {
|
||||
std::unique_ptr<nes::System> _system;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if(self = [super init]) {
|
||||
_system = std::make_unique<nes::System>();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
13
NesKit/include/NesKit.h
Normal file
13
NesKit/include/NesKit.h
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// Header.h
|
||||
//
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
|
||||
#ifndef NesKit_h
|
||||
#define NesKit_h
|
||||
|
||||
#import "../NesSystem.h"
|
||||
|
||||
#endif /* Header_h */
|
||||
@ -10,18 +10,17 @@ let package = Package(
|
||||
.iOS(.v16)
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, making them visible to other packages.
|
||||
.library(
|
||||
name: "NesKit",
|
||||
targets: ["NesKit"]),
|
||||
.library(name: "NesKit", targets: ["NesKit"]),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package, defining a module or a test suite.
|
||||
// Targets can depend on other targets in this package and products from dependencies.
|
||||
.target(name: "NesKitCpp",
|
||||
path: "src",
|
||||
exclude: ["Logger.cpp", "Logger.h"]),
|
||||
.target(name: "NesKit",
|
||||
path: "./src",
|
||||
exclude: ["Logger.cpp", "Logger.h"],
|
||||
publicHeadersPath: ".")
|
||||
dependencies: [.target(name: "NesKitCpp")],
|
||||
path: "NesKit")
|
||||
],
|
||||
cxxLanguageStandard: .cxx20
|
||||
)
|
||||
|
||||
390
examples/NesApp/NesApp.xcodeproj/project.pbxproj
Normal file
390
examples/NesApp/NesApp.xcodeproj/project.pbxproj
Normal file
@ -0,0 +1,390 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 60;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
7AF4D40F2AC4A97B00717C81 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF4D40E2AC4A97B00717C81 /* AppDelegate.swift */; };
|
||||
7AF4D4112AC4A97B00717C81 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF4D4102AC4A97B00717C81 /* SceneDelegate.swift */; };
|
||||
7AF4D4132AC4A97B00717C81 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF4D4122AC4A97B00717C81 /* ViewController.swift */; };
|
||||
7AF4D4162AC4A97B00717C81 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7AF4D4142AC4A97B00717C81 /* Main.storyboard */; };
|
||||
7AF4D4182AC4A97D00717C81 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7AF4D4172AC4A97D00717C81 /* Assets.xcassets */; };
|
||||
7AF4D41B2AC4A97D00717C81 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7AF4D4192AC4A97D00717C81 /* LaunchScreen.storyboard */; };
|
||||
7AF4D4242AC4A9D300717C81 /* NesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7AF4D4232AC4A9D300717C81 /* NesKit */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
7AF4D40B2AC4A97B00717C81 /* NesApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NesApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7AF4D40E2AC4A97B00717C81 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AF4D4102AC4A97B00717C81 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
7AF4D4122AC4A97B00717C81 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
|
||||
7AF4D4152AC4A97B00717C81 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
7AF4D4172AC4A97D00717C81 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
7AF4D41A2AC4A97D00717C81 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
7AF4D41C2AC4A97D00717C81 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
7AF4D4082AC4A97B00717C81 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7AF4D4242AC4A9D300717C81 /* NesKit in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
7AF4D4022AC4A97B00717C81 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7AF4D40D2AC4A97B00717C81 /* NesApp */,
|
||||
7AF4D40C2AC4A97B00717C81 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7AF4D40C2AC4A97B00717C81 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7AF4D40B2AC4A97B00717C81 /* NesApp.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7AF4D40D2AC4A97B00717C81 /* NesApp */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7AF4D40E2AC4A97B00717C81 /* AppDelegate.swift */,
|
||||
7AF4D4102AC4A97B00717C81 /* SceneDelegate.swift */,
|
||||
7AF4D4122AC4A97B00717C81 /* ViewController.swift */,
|
||||
7AF4D4142AC4A97B00717C81 /* Main.storyboard */,
|
||||
7AF4D4172AC4A97D00717C81 /* Assets.xcassets */,
|
||||
7AF4D4192AC4A97D00717C81 /* LaunchScreen.storyboard */,
|
||||
7AF4D41C2AC4A97D00717C81 /* Info.plist */,
|
||||
);
|
||||
path = NesApp;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
7AF4D40A2AC4A97B00717C81 /* NesApp */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 7AF4D41F2AC4A97D00717C81 /* Build configuration list for PBXNativeTarget "NesApp" */;
|
||||
buildPhases = (
|
||||
7AF4D4072AC4A97B00717C81 /* Sources */,
|
||||
7AF4D4082AC4A97B00717C81 /* Frameworks */,
|
||||
7AF4D4092AC4A97B00717C81 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = NesApp;
|
||||
packageProductDependencies = (
|
||||
7AF4D4232AC4A9D300717C81 /* NesKit */,
|
||||
);
|
||||
productName = NesApp;
|
||||
productReference = 7AF4D40B2AC4A97B00717C81 /* NesApp.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
7AF4D4032AC4A97B00717C81 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = 1;
|
||||
LastSwiftUpdateCheck = 1500;
|
||||
LastUpgradeCheck = 1500;
|
||||
TargetAttributes = {
|
||||
7AF4D40A2AC4A97B00717C81 = {
|
||||
CreatedOnToolsVersion = 15.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 7AF4D4062AC4A97B00717C81 /* Build configuration list for PBXProject "NesApp" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 7AF4D4022AC4A97B00717C81;
|
||||
packageReferences = (
|
||||
7AF4D4222AC4A9D300717C81 /* XCLocalSwiftPackageReference "../.." */,
|
||||
);
|
||||
productRefGroup = 7AF4D40C2AC4A97B00717C81 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
7AF4D40A2AC4A97B00717C81 /* NesApp */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
7AF4D4092AC4A97B00717C81 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7AF4D41B2AC4A97D00717C81 /* LaunchScreen.storyboard in Resources */,
|
||||
7AF4D4182AC4A97D00717C81 /* Assets.xcassets in Resources */,
|
||||
7AF4D4162AC4A97B00717C81 /* Main.storyboard in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
7AF4D4072AC4A97B00717C81 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7AF4D4132AC4A97B00717C81 /* ViewController.swift in Sources */,
|
||||
7AF4D40F2AC4A97B00717C81 /* AppDelegate.swift in Sources */,
|
||||
7AF4D4112AC4A97B00717C81 /* SceneDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
7AF4D4142AC4A97B00717C81 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
7AF4D4152AC4A97B00717C81 /* Base */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7AF4D4192AC4A97D00717C81 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
7AF4D41A2AC4A97D00717C81 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
7AF4D41D2AC4A97D00717C81 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
7AF4D41E2AC4A97D00717C81 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
7AF4D4202AC4A97D00717C81 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = NesApp/Info.plist;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||
INFOPLIST_KEY_UIMainStoryboardFile = Main;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = pro.aliencat.NesApp;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
7AF4D4212AC4A97D00717C81 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = NesApp/Info.plist;
|
||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
|
||||
INFOPLIST_KEY_UIMainStoryboardFile = Main;
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = pro.aliencat.NesApp;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
7AF4D4062AC4A97B00717C81 /* Build configuration list for PBXProject "NesApp" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
7AF4D41D2AC4A97D00717C81 /* Debug */,
|
||||
7AF4D41E2AC4A97D00717C81 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
7AF4D41F2AC4A97D00717C81 /* Build configuration list for PBXNativeTarget "NesApp" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
7AF4D4202AC4A97D00717C81 /* Debug */,
|
||||
7AF4D4212AC4A97D00717C81 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCLocalSwiftPackageReference section */
|
||||
7AF4D4222AC4A9D300717C81 /* XCLocalSwiftPackageReference "../.." */ = {
|
||||
isa = XCLocalSwiftPackageReference;
|
||||
relativePath = ../..;
|
||||
};
|
||||
/* End XCLocalSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
7AF4D4232AC4A9D300717C81 /* NesKit */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = NesKit;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 7AF4D4032AC4A97B00717C81 /* Project object */;
|
||||
}
|
||||
7
examples/NesApp/NesApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
7
examples/NesApp/NesApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>NesApp.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
36
examples/NesApp/NesApp/AppDelegate.swift
Normal file
36
examples/NesApp/NesApp/AppDelegate.swift
Normal file
@ -0,0 +1,36 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// NesApp
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@main
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
6
examples/NesApp/NesApp/Assets.xcassets/Contents.json
Normal file
6
examples/NesApp/NesApp/Assets.xcassets/Contents.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
25
examples/NesApp/NesApp/Base.lproj/LaunchScreen.storyboard
Normal file
25
examples/NesApp/NesApp/Base.lproj/LaunchScreen.storyboard
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
24
examples/NesApp/NesApp/Base.lproj/Main.storyboard
Normal file
24
examples/NesApp/NesApp/Base.lproj/Main.storyboard
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
25
examples/NesApp/NesApp/Info.plist
Normal file
25
examples/NesApp/NesApp/Info.plist
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
<key>UISceneStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
52
examples/NesApp/NesApp/SceneDelegate.swift
Normal file
52
examples/NesApp/NesApp/SceneDelegate.swift
Normal file
@ -0,0 +1,52 @@
|
||||
//
|
||||
// SceneDelegate.swift
|
||||
// NesApp
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
guard let _ = (scene as? UIWindowScene) else { return }
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
21
examples/NesApp/NesApp/ViewController.swift
Normal file
21
examples/NesApp/NesApp/ViewController.swift
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// ViewController.swift
|
||||
// NesApp
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import NesKit
|
||||
|
||||
class ViewController: UIViewController {
|
||||
|
||||
var system = NesSystem()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "../../src/Nes.h"
|
||||
#include "../../src/System.h"
|
||||
#include "Window.h"
|
||||
#include "SdlKeyboardController.h"
|
||||
|
||||
@ -9,7 +9,7 @@ int main() {
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
nes::Nes device;
|
||||
nes::System device;
|
||||
nes::SdlWindow window(nes::Ppu::SCREEN_WIDTH, nes::Ppu::SCREEN_HEIGHT);
|
||||
window.setSize(nes::Ppu::SCREEN_WIDTH * 4, nes::Ppu::SCREEN_HEIGHT * 4);
|
||||
|
||||
|
||||
110
src/Cpu.cpp
110
src/Cpu.cpp
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "Cpu.h"
|
||||
#include "Nes.h"
|
||||
#include "System.h"
|
||||
#include <iostream>
|
||||
|
||||
#ifdef NES_LOGGING
|
||||
@ -12,27 +12,27 @@
|
||||
|
||||
namespace nes {
|
||||
|
||||
Cpu::Cpu(Nes* system): _ticks{}, A{}, X{}, Y{}, PC{}, SP{}, flags{} {
|
||||
Cpu::Cpu(System* system): _ticks{}, A{}, X{}, Y{}, PC{}, SP{}, flags{} {
|
||||
_system = system;
|
||||
_instructions = std::vector<Instruction>(256);
|
||||
_instructions[0x00] = {"BRK", &Cpu::BRK, &Cpu::IMP, 7, false};
|
||||
_instructions[0x00] = {"BRK", &Cpu::BRK, &Cpu::IMPL, 7, false};
|
||||
_instructions[0x01] = {"ORA", &Cpu::ORA, &Cpu::IZX, 6, false};
|
||||
_instructions[0x05] = {"ORA", &Cpu::ORA, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x06] = {"ASL", &Cpu::ASL, &Cpu::ZP0, 5, false};
|
||||
_instructions[0x09] = {"ORA", &Cpu::ORA, &Cpu::IMM, 2, false};
|
||||
_instructions[0x0A] = {"ASL", &Cpu::ASL_ACC, &Cpu::IMP, 2, false};
|
||||
_instructions[0x0D] = {"ORA", &Cpu::ORA, &Cpu::ABS, 4, false};
|
||||
_instructions[0x0A] = {"ASL", &Cpu::ASL_ACC, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x0D] = {"ORA", &Cpu::ORA, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x11] = {"ORA", &Cpu::ORA, &Cpu::IZY, 5, true};
|
||||
_instructions[0x19] = {"ORA", &Cpu::ORA, &Cpu::ABY, 4, true};
|
||||
_instructions[0x15] = {"ORA", &Cpu::ORA, &Cpu::ZPX, 4, false};
|
||||
_instructions[0x1D] = {"ORA", &Cpu::ORA, &Cpu::ABX, 4, true};
|
||||
_instructions[0x0E] = {"ASL", &Cpu::ASL, &Cpu::ABS, 6, false};
|
||||
_instructions[0x0E] = {"ASL", &Cpu::ASL, &Cpu::ABSL, 6, false};
|
||||
_instructions[0x16] = {"ASL", &Cpu::ASL, &Cpu::ZPX, 6, false};
|
||||
_instructions[0x1E] = {"ASL", &Cpu::ASL, &Cpu::ABX, 7, false};
|
||||
_instructions[0x21] = {"AND", &Cpu::AND, &Cpu::IZX, 6, false};
|
||||
_instructions[0x25] = {"AND", &Cpu::AND, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x29] = {"AND", &Cpu::AND, &Cpu::IMM, 2, false};
|
||||
_instructions[0x2D] = {"AND", &Cpu::AND, &Cpu::ABS, 4, false};
|
||||
_instructions[0x2D] = {"AND", &Cpu::AND, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x31] = {"AND", &Cpu::AND, &Cpu::IZY, 5, true};
|
||||
_instructions[0x35] = {"AND", &Cpu::AND, &Cpu::ZPX, 4, false};
|
||||
_instructions[0x39] = {"AND", &Cpu::AND, &Cpu::ABY, 4, true};
|
||||
@ -40,14 +40,14 @@ namespace nes {
|
||||
_instructions[0x41] = {"EOR", &Cpu::EOR, &Cpu::IZX, 6, false};
|
||||
_instructions[0x45] = {"EOR", &Cpu::EOR, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x49] = {"EOR", &Cpu::EOR, &Cpu::IMM, 2, false};
|
||||
_instructions[0x4D] = {"EOR", &Cpu::EOR, &Cpu::ABS, 4, false};
|
||||
_instructions[0x4D] = {"EOR", &Cpu::EOR, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x51] = {"EOR", &Cpu::EOR, &Cpu::IZY, 5, true};
|
||||
_instructions[0x55] = {"EOR", &Cpu::EOR, &Cpu::ZPX, 4, false};
|
||||
_instructions[0x59] = {"EOR", &Cpu::EOR, &Cpu::ABY, 4, true};
|
||||
_instructions[0x5D] = {"EOR", &Cpu::EOR, &Cpu::ABX, 4, true};
|
||||
_instructions[0x61] = {"ADC", &Cpu::ADC, &Cpu::IZX, 6, false};
|
||||
_instructions[0x65] = {"ADC", &Cpu::ADC, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x6D] = {"ADC", &Cpu::ADC, &Cpu::ABS, 4, false};
|
||||
_instructions[0x6D] = {"ADC", &Cpu::ADC, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x69] = {"ADC", &Cpu::ADC, &Cpu::IMM, 2, false};
|
||||
_instructions[0x71] = {"ADC", &Cpu::ADC, &Cpu::IZY, 5, true};
|
||||
_instructions[0x75] = {"ADC", &Cpu::ADC, &Cpu::ZPX, 4, false};
|
||||
@ -55,114 +55,114 @@ namespace nes {
|
||||
_instructions[0x7D] = {"ADC", &Cpu::ADC, &Cpu::ABX, 4, true};
|
||||
_instructions[0xA2] = {"LDX", &Cpu::LDX, &Cpu::IMM, 2, false};
|
||||
_instructions[0xA6] = {"LDX", &Cpu::LDX, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xAE] = {"LDX", &Cpu::LDX, &Cpu::ABS, 4, false};
|
||||
_instructions[0xAE] = {"LDX", &Cpu::LDX, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xB6] = {"LDX", &Cpu::LDX, &Cpu::ZPY, 4, false};
|
||||
_instructions[0xBE] = {"LDX", &Cpu::LDX, &Cpu::ABY, 4, true};
|
||||
_instructions[0x86] = {"STX", &Cpu::STX, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x8E] = {"STX", &Cpu::STX, &Cpu::ABS, 4, false};
|
||||
_instructions[0x8E] = {"STX", &Cpu::STX, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x96] = {"STX", &Cpu::STX, &Cpu::ZPY, 4, false};
|
||||
_instructions[0xA4] = {"LDY", &Cpu::LDY, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xAC] = {"LDY", &Cpu::LDY, &Cpu::ABS, 4, false};
|
||||
_instructions[0xAC] = {"LDY", &Cpu::LDY, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xA0] = {"LDY", &Cpu::LDY, &Cpu::IMM, 2, false};
|
||||
_instructions[0xB4] = {"LDY", &Cpu::LDY, &Cpu::ZPX, 4, false};
|
||||
_instructions[0xBC] = {"LDY", &Cpu::LDY, &Cpu::ABX, 4, true};
|
||||
_instructions[0xA1] = {"LDA", &Cpu::LDA, &Cpu::IZX, 6, false};
|
||||
_instructions[0xA5] = {"LDA", &Cpu::LDA, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xA9] = {"LDA", &Cpu::LDA, &Cpu::IMM, 2, false};
|
||||
_instructions[0xAD] = {"LDA", &Cpu::LDA, &Cpu::ABS, 4, false};
|
||||
_instructions[0xAD] = {"LDA", &Cpu::LDA, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xB1] = {"LDA", &Cpu::LDA, &Cpu::IZY, 5, true};
|
||||
_instructions[0xB5] = {"LDA", &Cpu::LDA, &Cpu::ZPX, 4, false};
|
||||
_instructions[0xB9] = {"LDA", &Cpu::LDA, &Cpu::ABY, 4, true};
|
||||
_instructions[0xBD] = {"LDA", &Cpu::LDA, &Cpu::ABX, 4, true};
|
||||
_instructions[0x18] = {"CLC", &Cpu::CLC, &Cpu::IMP, 2, false};
|
||||
_instructions[0x88] = {"DEY", &Cpu::DEY, &Cpu::IMP, 2, false};
|
||||
_instructions[0x18] = {"CLC", &Cpu::CLC, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x88] = {"DEY", &Cpu::DEY, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xD0] = {"BNE", &Cpu::BNE, &Cpu::REL, 2, false};
|
||||
_instructions[0x81] = {"STA", &Cpu::STA, &Cpu::IZX, 6, false};
|
||||
_instructions[0x8D] = {"STA", &Cpu::STA, &Cpu::ABS, 4, false};
|
||||
_instructions[0x8D] = {"STA", &Cpu::STA, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x91] = {"STA", &Cpu::STA, &Cpu::IZY, 6, false};
|
||||
_instructions[0x95] = {"STA", &Cpu::STA, &Cpu::ZPX, 4, false};
|
||||
_instructions[0x99] = {"STA", &Cpu::STA, &Cpu::ABY, 5, false};
|
||||
_instructions[0x9D] = {"STA", &Cpu::STA, &Cpu::ABX, 5, false};
|
||||
_instructions[0xEA] = {"NOP", &Cpu::NOP, &Cpu::IMP, 2, false};
|
||||
_instructions[0x78] = {"SEI", &Cpu::SEI, &Cpu::IMP, 2, false};
|
||||
_instructions[0xD8] = {"CLD", &Cpu::CLD, &Cpu::IMP, 2, false};
|
||||
_instructions[0x9A] = {"TXS", &Cpu::TXS, &Cpu::IMP, 2, false};
|
||||
_instructions[0xEA] = {"NOP", &Cpu::NOP, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x78] = {"SEI", &Cpu::SEI, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xD8] = {"CLD", &Cpu::CLD, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x9A] = {"TXS", &Cpu::TXS, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x10] = {"BPL", &Cpu::BPL, &Cpu::REL, 2, false};
|
||||
_instructions[0x4C] = {"JMP", &Cpu::JMP, &Cpu::ABS, 3, false};
|
||||
_instructions[0x4C] = {"JMP", &Cpu::JMP, &Cpu::ABSL, 3, false};
|
||||
_instructions[0x6C] = {"JMP", &Cpu::JMP, &Cpu::IND, 5, false};
|
||||
_instructions[0x20] = {"JSR", &Cpu::JSR, &Cpu::ABS, 6, false};
|
||||
_instructions[0x38] = {"SEC", &Cpu::SEC, &Cpu::IMP, 2, false};
|
||||
_instructions[0x20] = {"JSR", &Cpu::JSR, &Cpu::ABSL, 6, false};
|
||||
_instructions[0x38] = {"SEC", &Cpu::SEC, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xB0] = {"BCS", &Cpu::BCS, &Cpu::REL, 2, false};
|
||||
_instructions[0x90] = {"BCC", &Cpu::BCC, &Cpu::REL, 2, false};
|
||||
_instructions[0xF0] = {"BEQ", &Cpu::BEQ, &Cpu::REL, 2, false};
|
||||
_instructions[0x85] = {"STA", &Cpu::STA, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x24] = {"BIT", &Cpu::BIT, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x2C] = {"BIT", &Cpu::BIT, &Cpu::ABS, 4, false};
|
||||
_instructions[0x2C] = {"BIT", &Cpu::BIT, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x70] = {"BVS", &Cpu::BVS, &Cpu::REL, 2, false};
|
||||
_instructions[0x50] = {"BVC", &Cpu::BVC, &Cpu::REL, 2, false};
|
||||
_instructions[0x60] = {"RTS", &Cpu::RTS, &Cpu::IMP, 6, false};
|
||||
_instructions[0xF8] = {"SED", &Cpu::SED, &Cpu::IMP, 2, false};
|
||||
_instructions[0x08] = {"PHP", &Cpu::PHP, &Cpu::IMP, 3, false};
|
||||
_instructions[0x68] = {"PLA", &Cpu::PLA, &Cpu::IMP, 4, false};
|
||||
_instructions[0x60] = {"RTS", &Cpu::RTS, &Cpu::IMPL, 6, false};
|
||||
_instructions[0xF8] = {"SED", &Cpu::SED, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x08] = {"PHP", &Cpu::PHP, &Cpu::IMPL, 3, false};
|
||||
_instructions[0x68] = {"PLA", &Cpu::PLA, &Cpu::IMPL, 4, false};
|
||||
_instructions[0xC1] = {"CMP", &Cpu::CMP, &Cpu::IZX, 6, false};
|
||||
_instructions[0xC5] = {"CMP", &Cpu::CMP, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xC9] = {"CMP", &Cpu::CMP, &Cpu::IMM, 2, false};
|
||||
_instructions[0xCD] = {"CMP", &Cpu::CMP, &Cpu::ABS, 4, false};
|
||||
_instructions[0xCD] = {"CMP", &Cpu::CMP, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xD1] = {"CMP", &Cpu::CMP, &Cpu::IZY, 5, true};
|
||||
_instructions[0xD5] = {"CMP", &Cpu::CMP, &Cpu::ZPX, 4, false};
|
||||
_instructions[0xD9] = {"CMP", &Cpu::CMP, &Cpu::ABY, 4, true};
|
||||
_instructions[0xDD] = {"CMP", &Cpu::CMP, &Cpu::ABX, 4, true};
|
||||
_instructions[0x30] = {"BMI", &Cpu::BMI, &Cpu::REL, 2, false};
|
||||
_instructions[0x48] = {"PHA", &Cpu::PHA, &Cpu::IMP, 3, false};
|
||||
_instructions[0x28] = {"PLP", &Cpu::PLP, &Cpu::IMP, 4, false};
|
||||
_instructions[0xB8] = {"CLV", &Cpu::CLV, &Cpu::IMP, 2, false};
|
||||
_instructions[0x48] = {"PHA", &Cpu::PHA, &Cpu::IMPL, 3, false};
|
||||
_instructions[0x28] = {"PLP", &Cpu::PLP, &Cpu::IMPL, 4, false};
|
||||
_instructions[0xB8] = {"CLV", &Cpu::CLV, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xC0] = {"CPY", &Cpu::CPY, &Cpu::IMM, 2, false};
|
||||
_instructions[0xC4] = {"CPY", &Cpu::CPY, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xCC] = {"CPY", &Cpu::CPY, &Cpu::ABS, 4, false};
|
||||
_instructions[0xCC] = {"CPY", &Cpu::CPY, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xE0] = {"CPX", &Cpu::CPX, &Cpu::IMM, 2, false};
|
||||
_instructions[0xE4] = {"CPX", &Cpu::CPX, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xEC] = {"CPX", &Cpu::CPX, &Cpu::ABS, 4, false};
|
||||
_instructions[0xEC] = {"CPX", &Cpu::CPX, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xE1] = {"SBC", &Cpu::SBC, &Cpu::IZX, 6, false};
|
||||
_instructions[0xE5] = {"SBC", &Cpu::SBC, &Cpu::ZP0, 3, false};
|
||||
_instructions[0xE9] = {"SBC", &Cpu::SBC, &Cpu::IMM, 2, false};
|
||||
_instructions[0xED] = {"SBC", &Cpu::SBC, &Cpu::ABS, 4, false};
|
||||
_instructions[0xED] = {"SBC", &Cpu::SBC, &Cpu::ABSL, 4, false};
|
||||
_instructions[0xF1] = {"SBC", &Cpu::SBC, &Cpu::IZY, 5, true};
|
||||
_instructions[0xF5] = {"SBC", &Cpu::SBC, &Cpu::ZPX, 4, false};
|
||||
_instructions[0xF9] = {"SBC", &Cpu::SBC, &Cpu::ABY, 4, true};
|
||||
_instructions[0xFD] = {"SBC", &Cpu::SBC, &Cpu::ABX, 4, true};
|
||||
_instructions[0x84] = {"STY", &Cpu::STY, &Cpu::ZP0, 3, false};
|
||||
_instructions[0x8C] = {"STY", &Cpu::STY, &Cpu::ABS, 4, false};
|
||||
_instructions[0x8C] = {"STY", &Cpu::STY, &Cpu::ABSL, 4, false};
|
||||
_instructions[0x94] = {"STY", &Cpu::STY, &Cpu::ZPX, 4, false};
|
||||
_instructions[0xC8] = {"INY", &Cpu::INY, &Cpu::IMP, 2, false};
|
||||
_instructions[0xE8] = {"INX", &Cpu::INX, &Cpu::IMP, 2, false};
|
||||
_instructions[0xCA] = {"DEX", &Cpu::DEX, &Cpu::IMP, 2, false};
|
||||
_instructions[0xA8] = {"TAY", &Cpu::TAY, &Cpu::IMP, 2, false};
|
||||
_instructions[0xAA] = {"TAX", &Cpu::TAX, &Cpu::IMP, 2, false};
|
||||
_instructions[0x98] = {"TYA", &Cpu::TYA, &Cpu::IMP, 2, false};
|
||||
_instructions[0x8A] = {"TXA", &Cpu::TXA, &Cpu::IMP, 2, false};
|
||||
_instructions[0xBA] = {"TSX", &Cpu::TSX, &Cpu::IMP, 2, false};
|
||||
_instructions[0x40] = {"RTI", &Cpu::RTI, &Cpu::IMP, 6, false};
|
||||
_instructions[0xC8] = {"INY", &Cpu::INY, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xE8] = {"INX", &Cpu::INX, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xCA] = {"DEX", &Cpu::DEX, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xA8] = {"TAY", &Cpu::TAY, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xAA] = {"TAX", &Cpu::TAX, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x98] = {"TYA", &Cpu::TYA, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x8A] = {"TXA", &Cpu::TXA, &Cpu::IMPL, 2, false};
|
||||
_instructions[0xBA] = {"TSX", &Cpu::TSX, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x40] = {"RTI", &Cpu::RTI, &Cpu::IMPL, 6, false};
|
||||
_instructions[0x46] = {"LSR", &Cpu::LSR, &Cpu::ZP0, 5, false};
|
||||
_instructions[0x4E] = {"LSR", &Cpu::LSR, &Cpu::ABS, 6, false};
|
||||
_instructions[0x4A] = {"LSR", &Cpu::LSR_ACC, &Cpu::IMP, 2, false};
|
||||
_instructions[0x4E] = {"LSR", &Cpu::LSR, &Cpu::ABSL, 6, false};
|
||||
_instructions[0x4A] = {"LSR", &Cpu::LSR_ACC, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x56] = {"LSR", &Cpu::LSR, &Cpu::ZPX, 6, false};
|
||||
_instructions[0x5E] = {"LSR", &Cpu::LSR, &Cpu::ABX, 7, false};
|
||||
_instructions[0x66] = {"ROR", &Cpu::ROR, &Cpu::ZP0, 5, false};
|
||||
_instructions[0x6A] = {"ROR", &Cpu::ROR_ACC, &Cpu::IMP, 2, false};
|
||||
_instructions[0x6E] = {"ROR", &Cpu::ROR, &Cpu::ABS, 6, false};
|
||||
_instructions[0x6A] = {"ROR", &Cpu::ROR_ACC, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x6E] = {"ROR", &Cpu::ROR, &Cpu::ABSL, 6, false};
|
||||
_instructions[0x76] = {"ROR", &Cpu::ROR, &Cpu::ZPX, 6, false};
|
||||
_instructions[0x7E] = {"ROR", &Cpu::ROR, &Cpu::ABX, 7, false};
|
||||
_instructions[0x26] = {"ROL", &Cpu::ROL, &Cpu::ZP0, 5, false};
|
||||
_instructions[0x2A] = {"ROL", &Cpu::ROL_ACC, &Cpu::IMP, 2, false};
|
||||
_instructions[0x2E] = {"ROL", &Cpu::ROL, &Cpu::ABS, 6, false};
|
||||
_instructions[0x2A] = {"ROL", &Cpu::ROL_ACC, &Cpu::IMPL, 2, false};
|
||||
_instructions[0x2E] = {"ROL", &Cpu::ROL, &Cpu::ABSL, 6, false};
|
||||
_instructions[0x36] = {"ROL", &Cpu::ROL, &Cpu::ZPX, 6, false};
|
||||
_instructions[0x3E] = {"ROL", &Cpu::ROL, &Cpu::ABX, 7, false};
|
||||
_instructions[0xE6] = {"INC", &Cpu::INC, &Cpu::ZP0, 5, false};
|
||||
_instructions[0xEE] = {"INC", &Cpu::INC, &Cpu::ABS, 6, false};
|
||||
_instructions[0xEE] = {"INC", &Cpu::INC, &Cpu::ABSL, 6, false};
|
||||
_instructions[0xF6] = {"INC", &Cpu::INC, &Cpu::ZPX, 6, false};
|
||||
_instructions[0xFE] = {"INC", &Cpu::INC, &Cpu::ABX, 7, false};
|
||||
_instructions[0xC6] = {"DEC", &Cpu::DEC, &Cpu::ZP0, 5, false};
|
||||
_instructions[0xCE] = {"DEC", &Cpu::DEC, &Cpu::ABS, 6, false};
|
||||
_instructions[0xCE] = {"DEC", &Cpu::DEC, &Cpu::ABSL, 6, false};
|
||||
_instructions[0xD6] = {"DEC", &Cpu::DEC, &Cpu::ZPX, 6, false};
|
||||
_instructions[0xDE] = {"DEC", &Cpu::DEC, &Cpu::ABX, 7, false};
|
||||
}
|
||||
@ -279,14 +279,14 @@ namespace nes {
|
||||
return {PC++, 0};
|
||||
}
|
||||
|
||||
Cpu::InstructionArgs Cpu::ABS() {
|
||||
Cpu::InstructionArgs Cpu::ABSL() {
|
||||
uint8_t lo = _system->read(PC++);
|
||||
uint8_t hi = _system->read(PC++);
|
||||
uint16_t address = (hi << 8) | lo;
|
||||
return {address, 0};
|
||||
}
|
||||
|
||||
Cpu::InstructionArgs Cpu::IMP() {
|
||||
Cpu::InstructionArgs Cpu::IMPL() {
|
||||
return {0, 0};
|
||||
}
|
||||
|
||||
|
||||
10
src/Cpu.h
10
src/Cpu.h
@ -11,7 +11,7 @@
|
||||
|
||||
namespace nes {
|
||||
|
||||
class Nes;
|
||||
class System;
|
||||
|
||||
enum CpuFlags: uint8_t {
|
||||
Carry = (1 << 0),
|
||||
@ -42,7 +42,7 @@ namespace nes {
|
||||
static constexpr uint16_t STACK_BASE = 0x0100;
|
||||
|
||||
public:
|
||||
explicit Cpu(Nes* system);
|
||||
explicit Cpu(System* system);
|
||||
void reset();
|
||||
bool tick();
|
||||
void setFlag(CpuFlags flag, bool value);
|
||||
@ -56,7 +56,7 @@ namespace nes {
|
||||
|
||||
private:
|
||||
size_t _ticks;
|
||||
Nes* _system;
|
||||
System* _system;
|
||||
std::vector<Instruction> _instructions;
|
||||
|
||||
private:
|
||||
@ -78,8 +78,8 @@ namespace nes {
|
||||
|
||||
private:
|
||||
InstructionArgs IMM();
|
||||
InstructionArgs ABS();
|
||||
InstructionArgs IMP();
|
||||
InstructionArgs ABSL();
|
||||
InstructionArgs IMPL();
|
||||
InstructionArgs REL();
|
||||
InstructionArgs ZP0();
|
||||
InstructionArgs IZX();
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
|
||||
#include "Dma.h"
|
||||
#include "Ppu.h"
|
||||
#include "Nes.h"
|
||||
#include "System.h"
|
||||
|
||||
namespace nes {
|
||||
|
||||
Dma::Dma(Nes *system, Ppu *ppu): _system{system}, _ppu{ppu} {
|
||||
Dma::Dma(System *system, Ppu *ppu): _system{system}, _ppu{ppu} {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -9,18 +9,18 @@
|
||||
|
||||
namespace nes {
|
||||
|
||||
class Nes;
|
||||
class System;
|
||||
class Ppu;
|
||||
|
||||
class Dma {
|
||||
public:
|
||||
Dma(Nes* system, Ppu* ppu);
|
||||
Dma(System* system, Ppu* ppu);
|
||||
[[nodiscard]] bool active() const;
|
||||
void tick(uint64_t cycles);
|
||||
void start(uint8_t page);
|
||||
|
||||
private:
|
||||
Nes* _system;
|
||||
System* _system;
|
||||
Ppu* _ppu;
|
||||
|
||||
private:
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <filesystem>
|
||||
#include <string_view>
|
||||
|
||||
namespace nes {
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Created by Selim Mustafaev on 11.08.2023.
|
||||
//
|
||||
|
||||
#include "Nes.h"
|
||||
#include "System.h"
|
||||
#include "Cartridge.h"
|
||||
#include "Cpu.h"
|
||||
#include "Ppu.h"
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
namespace nes {
|
||||
|
||||
Nes::Nes():
|
||||
System::System():
|
||||
_cycles{}
|
||||
#ifdef NES_LOGGING
|
||||
,_logger(500*1024*1024)
|
||||
@ -25,17 +25,17 @@ namespace nes {
|
||||
_dma = std::make_unique<Dma>(this, _ppu.get());
|
||||
}
|
||||
|
||||
void Nes::insertCartridge(const fs::path &path, std::optional<uint16_t> address) {
|
||||
void System::insertCartridge(const fs::path &path, std::optional<uint16_t> address) {
|
||||
_cartridge = std::make_unique<Cartridge>(path);
|
||||
_ppu->connect(_cartridge.get());
|
||||
reset(address);
|
||||
}
|
||||
|
||||
void Nes::connect(std::shared_ptr<Controller> controller) {
|
||||
void System::connect(std::shared_ptr<Controller> controller) {
|
||||
_controller1 = std::move(controller);
|
||||
}
|
||||
|
||||
void Nes::reset(std::optional<uint16_t> address) {
|
||||
void System::reset(std::optional<uint16_t> address) {
|
||||
_cpu->reset();
|
||||
_ppu->reset();
|
||||
if(address) {
|
||||
@ -43,11 +43,11 @@ namespace nes {
|
||||
}
|
||||
}
|
||||
|
||||
void Nes::setNewFrameCallback(std::function<void(const Pixel *)> onNewFrame) {
|
||||
void System::setNewFrameCallback(std::function<void(const Pixel *)> onNewFrame) {
|
||||
_ppu->onNewFrame = std::move(onNewFrame);
|
||||
}
|
||||
|
||||
void Nes::tick() {
|
||||
void System::tick() {
|
||||
|
||||
bool needInterrupt = _ppu->tick();
|
||||
#ifdef NES_LOGGING
|
||||
@ -84,7 +84,7 @@ namespace nes {
|
||||
_cycles++;
|
||||
}
|
||||
|
||||
uint8_t Nes::read(uint16_t address) {
|
||||
uint8_t System::read(uint16_t address) {
|
||||
if(address < 0x2000) {
|
||||
return _ram[address & 0x07FF];
|
||||
}
|
||||
@ -105,7 +105,7 @@ namespace nes {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Nes::write(uint16_t address, uint8_t value) {
|
||||
void System::write(uint16_t address, uint8_t value) {
|
||||
if(address < 0x2000) {
|
||||
_ram[address & 0x07FF] = value;
|
||||
}
|
||||
@ -129,7 +129,7 @@ namespace nes {
|
||||
// For debug
|
||||
// Calc "hash" - just sum of the bytes of RAM
|
||||
// Can be useful for detecting changes in memory
|
||||
uint32_t Nes::zpHash() const {
|
||||
uint32_t System::zpHash() const {
|
||||
uint32_t sum = 0;
|
||||
for(size_t i = 0; i < 2048; ++i) {
|
||||
sum += _ram[i];
|
||||
@ -2,8 +2,8 @@
|
||||
// Created by Selim Mustafaev on 11.08.2023.
|
||||
//
|
||||
|
||||
#ifndef NES_NES_H
|
||||
#define NES_NES_H
|
||||
#ifndef NES_SYSTEM_H
|
||||
#define NES_SYSTEM_H
|
||||
|
||||
#include "Logger.h"
|
||||
#include "Cpu.h"
|
||||
@ -21,9 +21,9 @@ namespace nes {
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class Nes {
|
||||
class System {
|
||||
public:
|
||||
Nes();
|
||||
System();
|
||||
void insertCartridge(const fs::path& path, std::optional<uint16_t> address = std::nullopt);
|
||||
void connect(std::shared_ptr<Controller> controller);
|
||||
void reset(std::optional<uint16_t> address = std::nullopt);
|
||||
@ -50,4 +50,4 @@ namespace nes {
|
||||
|
||||
}
|
||||
|
||||
#endif //NES_NES_H
|
||||
#endif //NES_SYSTEM_H
|
||||
15
src/include/NesKitCpp.h
Normal file
15
src/include/NesKitCpp.h
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Header.h
|
||||
//
|
||||
//
|
||||
// Created by Selim Mustafaev on 27.09.2023.
|
||||
//
|
||||
// This is umbrella header for SPM module
|
||||
//
|
||||
|
||||
#ifndef NesKitCpp_h
|
||||
#define NesKitCpp_h
|
||||
|
||||
#include "../System.h"
|
||||
|
||||
#endif /* Header_h */
|
||||
Loading…
Reference in New Issue
Block a user