diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2025-01-13 20:39:23 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2025-01-13 20:39:23 +0100 |
| commit | 4366e924e44d4294b9791533486f3ab81317ec71 (patch) | |
| tree | 6daa5fe5ae8a6d348cf343052d0fbfb372e9a761 | |
initial commit
| -rw-r--r-- | .clang-format | 85 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/main.mm | 40 | ||||
| -rw-r--r-- | src/view-controller.hh | 6 | ||||
| -rw-r--r-- | src/view-controller.mm | 15 |
7 files changed, 167 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a8bb62b --- /dev/null +++ b/.clang-format @@ -0,0 +1,85 @@ +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: InlineOnly +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortLambdasOnASingleLine: All +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeElse: true + BeforeWhile: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: true +BreakStringLiterals: true +ColumnLimit: 120 +ContinuationIndentWidth: 4 +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +PenaltyBreakAssignment: 1 +PenaltyBreakBeforeFirstCallParameter: 60 +PenaltyBreakComment: 200 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 1000 +PointerAlignment: Right +ReflowComments: true +Cpp11BracedListStyle: false +SortIncludes: Never +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +QualifierAlignment: Right +TabWidth: 4 +UseTab: ForContinuationAndIndentation diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..305ac1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +cmake-build-debug/ +.idea/
\ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..34552bf --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.30) +project( + nes + LANGUAGES CXX OBJCXX OBJC + VERSION 1.0) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(nes) + +add_subdirectory(src) + +find_library(FRAMEWORK_COCOA Cocoa REQUIRED) +target_link_libraries(nes PRIVATE ${FRAMEWORK_COCOA})
\ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..34c0ed3 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources( + nes + PRIVATE + main.mm + view-controller.mm)
\ No newline at end of file diff --git a/src/main.mm b/src/main.mm new file mode 100644 index 0000000..a526e66 --- /dev/null +++ b/src/main.mm @@ -0,0 +1,40 @@ +#import <Cocoa/Cocoa.h> +#import "view-controller.hh" + +int main(int argc, char** argv) +{ + NSApplication* app = [NSApplication sharedApplication]; + [app setActivationPolicy:NSApplicationActivationPolicyRegular]; + + NSMenuItem *quitItem = [[NSMenuItem alloc] init]; + [quitItem setTitle:@"Quit NES"]; + [quitItem setKeyEquivalent:@"q"]; + [quitItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand]; + [quitItem setTarget:app]; + [quitItem setAction:@selector(terminate:)]; + + NSMenu *menu = [[NSMenu alloc] init]; + [menu addItem:quitItem]; + + NSMenuItem *item = [[NSMenuItem alloc] init]; + [item setSubmenu:menu]; + + NSMenu *mainMenu = [[NSMenu alloc] init]; + [mainMenu addItem:item]; + [app setMainMenu:mainMenu]; + + NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0., 0., 640., 480.) + styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | + NSWindowMiniaturizeButton | NSWindowStyleMaskResizable) + backing:NSBackingStoreBuffered + defer:false]; + [window setTitle:@"NES"]; + [window setContentViewController:[[ViewController alloc] init]]; + [window setContentSize:NSMakeSize(640., 480.)]; + [window makeKeyAndOrderFront:nil]; + + [app activateIgnoringOtherApps:YES]; + [app run]; + + return 0; +}
\ No newline at end of file diff --git a/src/view-controller.hh b/src/view-controller.hh new file mode 100644 index 0000000..a89a0c4 --- /dev/null +++ b/src/view-controller.hh @@ -0,0 +1,6 @@ +#pragma once + +#import <Cocoa/Cocoa.h> + +@interface ViewController : NSViewController +@end
\ No newline at end of file diff --git a/src/view-controller.mm b/src/view-controller.mm new file mode 100644 index 0000000..5f24326 --- /dev/null +++ b/src/view-controller.mm @@ -0,0 +1,15 @@ +#import "view-controller.hh" + +@implementation ViewController + +- (void)loadView +{ + [self setView:[[NSView alloc] init]]; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; +} + +@end
\ No newline at end of file |
