From ff51d2f4b2daa6aa91e25c5b65c42631d00754fc Mon Sep 17 00:00:00 2001 From: Luigi Thirty Date: Thu, 10 Aug 2017 20:06:41 -0400 Subject: [PATCH] hires starting --- FruitMachine.xcodeproj/project.pbxproj | 4 ++ .../AppleII/Video/Modes/HiresMode.swift | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 FruitMachine/AppleII/Video/Modes/HiresMode.swift diff --git a/FruitMachine.xcodeproj/project.pbxproj b/FruitMachine.xcodeproj/project.pbxproj index 4662b08..faccc14 100644 --- a/FruitMachine.xcodeproj/project.pbxproj +++ b/FruitMachine.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 2A044E2C1F37D65A000E8085 /* LanguageCard16K.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A044E2B1F37D65A000E8085 /* LanguageCard16K.swift */; }; 2A044E2E1F382CA9000E8085 /* AppleIIPlus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A044E2D1F382CA9000E8085 /* AppleIIPlus.swift */; }; + 2A07857D1F3D273E008736D2 /* HiresMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A07857C1F3D273E008736D2 /* HiresMode.swift */; }; 2A0D0C691F3C09990000913B /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A0D0C681F3C09990000913B /* Types.swift */; }; 2A16ADBB1F33C341004A0333 /* DiskImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A16ADBA1F33C341004A0333 /* DiskImage.swift */; }; 2A2126841F2A9FA300E43DC1 /* DebuggerWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A2126831F2A9FA300E43DC1 /* DebuggerWindowController.swift */; }; @@ -61,6 +62,7 @@ /* Begin PBXFileReference section */ 2A044E2B1F37D65A000E8085 /* LanguageCard16K.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageCard16K.swift; sourceTree = ""; }; 2A044E2D1F382CA9000E8085 /* AppleIIPlus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleIIPlus.swift; sourceTree = ""; }; + 2A07857C1F3D273E008736D2 /* HiresMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HiresMode.swift; sourceTree = ""; }; 2A0D0C681F3C09990000913B /* Types.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = ""; }; 2A16ADBA1F33C341004A0333 /* DiskImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskImage.swift; sourceTree = ""; }; 2A2126831F2A9FA300E43DC1 /* DebuggerWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebuggerWindowController.swift; sourceTree = ""; }; @@ -148,6 +150,7 @@ 2A86FB981F32694A00AD0C68 /* VideoModes.swift */, 2A63C2321F32C39300D4F4F8 /* TextMode.swift */, 2A63C2341F32C4F700D4F4F8 /* LoresMode.swift */, + 2A07857C1F3D273E008736D2 /* HiresMode.swift */, ); path = Modes; sourceTree = ""; @@ -442,6 +445,7 @@ 2AE42E0A1F28521E00C4900E /* WriteOverride.swift in Sources */, 2A6DC7ED1F30492C0066FE0D /* ScreenDelegate.swift in Sources */, 2A044E2C1F37D65A000E8085 /* LanguageCard16K.swift in Sources */, + 2A07857D1F3D273E008736D2 /* HiresMode.swift in Sources */, 2A5BC5191F29A28D008C03BE /* AppleIScreenView.swift in Sources */, 2A63C2371F32C55100D4F4F8 /* VideoHelpers.swift in Sources */, 2A63C23A1F32CCE900D4F4F8 /* DiskII.swift in Sources */, diff --git a/FruitMachine/AppleII/Video/Modes/HiresMode.swift b/FruitMachine/AppleII/Video/Modes/HiresMode.swift new file mode 100644 index 0000000..b245780 --- /dev/null +++ b/FruitMachine/AppleII/Video/Modes/HiresMode.swift @@ -0,0 +1,55 @@ +// +// HiresMode.swift +// FruitMachine +// +// Created by Christopher Rohl on 8/10/17. +// Copyright © 2017 Christopher Rohl. All rights reserved. +// + +import Cocoa + +class HiresMode: NSObject { + static func putHiresPixel(buffer: UnsafeMutablePointer?, pixel: UInt8, address: UInt16) { + let pageBase: Address + + if(EmulatedSystemInstance!.videoSoftswitches.PAGE_2) { + pageBase = 0x4000 + } else { + pageBase = 0x2000 + } + + //Convert the address into an (X,Y) pixel coordinate. + var offset = address - 0x2000 + if(offset >= 0x2000) { //Page 2 address + offset -= 0x2000 + } + + //Find the row number. + var rowNumber = offset / 0x80 + let lowByte = offset & 0x0FF + + if(0x28 ... 0x4F ~= lowByte || 0xA8 ... 0xCF ~= lowByte) { + //Middle third. + rowNumber += 64 + //cellX = (lowByte & ~(0x80)) - 0x28 + } + else if(0x50 ... 0x77 ~= lowByte || 0xD0 ... 0xF7 ~= lowByte) { + //Bottom third. + rowNumber += 64 + //cellX = (lowByte & ~(0x80)) - 0x50 + } + else if(0x78 ... 0x7F ~= lowByte || 0xF8 ... 0xFF ~= lowByte) { + //Discard. + } + else { + //Top third. + rowNumber += 0 + //cellX = (lowByte & ~(0x80)) + } + + rowNumber += offset / 0x400 + + let columnByte = (offset & 0x0007) + + } +}