mirror of
https://github.com/Luigi30/FruitMachine-Swift.git
synced 2024-11-23 02:33:00 +00:00
HGR is so weird
This commit is contained in:
parent
ff51d2f4b2
commit
5fc2be1fdc
@ -108,7 +108,8 @@ class AppleIIBase: NSObject, EmulatedSystem {
|
||||
backplane[6] = DiskII(slot: 6, romPath: "/Users/luigi/apple2/341-0027-a.p5")
|
||||
}
|
||||
|
||||
(backplane[6] as! DiskII).attachDiskImage(imagePath: "/Users/luigi/apple2/Prodos_2_4_1.po")
|
||||
//(backplane[6] as! DiskII).attachDiskImage(imagePath: "/Users/luigi/apple2/Prodos_2_4_1.po")
|
||||
(backplane[6] as! DiskII).attachDiskImage(imagePath: "/Users/luigi/apple2/clean332sysmas.do")
|
||||
}
|
||||
|
||||
func doColdReset() {
|
||||
@ -173,8 +174,16 @@ class AppleIIBase: NSObject, EmulatedSystem {
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x2D0, end: videoMemoryStart + 0x2F8)
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x350, end: videoMemoryStart + 0x378)
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x3D0, end: videoMemoryStart + 0x3F8)
|
||||
} else {
|
||||
print("Unimplemented video mode!")
|
||||
} else if(videoMode == .Hires) {
|
||||
|
||||
} else if(videoMode == .MixedHires) {
|
||||
putHiresPixels(buffer: buf!, start: 0x2000, end: 0x3fff)
|
||||
|
||||
//Draw the bottom 4 text rows.
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x250, end: videoMemoryStart + 0x278)
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x2D0, end: videoMemoryStart + 0x2F8)
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x350, end: videoMemoryStart + 0x378)
|
||||
putGlyphs(buffer: buf!, start: videoMemoryStart + 0x3D0, end: videoMemoryStart + 0x3F8)
|
||||
}
|
||||
|
||||
CVPixelBufferUnlockBaseAddress(emulatorViewDelegate.pixels!, CVPixelBufferLockFlags(rawValue: 0))
|
||||
@ -183,6 +192,16 @@ class AppleIIBase: NSObject, EmulatedSystem {
|
||||
}
|
||||
|
||||
/* Video */
|
||||
func putHiresPixels(buffer: UnsafeMutablePointer<BitmapPixelsLE555.PixelData>, start: UInt16, end: UInt16) {
|
||||
for address in start ..< end {
|
||||
let pixelData = CPU.sharedInstance.memoryInterface.readByte(offset: UInt16(address), bypassOverrides: true)
|
||||
|
||||
HiresMode.putHiresByte(buffer: buffer,
|
||||
pixel: pixelData,
|
||||
address: UInt16(address))
|
||||
}
|
||||
}
|
||||
|
||||
func putLoresPixels(buffer: UnsafeMutablePointer<BitmapPixelsLE555.PixelData>, start: UInt16, end: UInt16) {
|
||||
for address in start ..< end {
|
||||
let pixelData = CPU.sharedInstance.memoryInterface.readByte(offset: UInt16(address), bypassOverrides: true)
|
||||
|
@ -74,8 +74,6 @@ class ProdosImage: DiskImageFormat {
|
||||
var sector1 = 0
|
||||
var sector2 = 0
|
||||
|
||||
//static let SECTOR_ORDER = [0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15]
|
||||
|
||||
switch blockOffset8 {
|
||||
case 0:
|
||||
sector1 = 0
|
||||
@ -176,10 +174,6 @@ class DiskImage: NSObject {
|
||||
var data = Data(buffer: ptr)
|
||||
try! data.write(to: URL(fileURLWithPath: filename + ".blk"))
|
||||
|
||||
ptr = UnsafeBufferPointer(start: nbls, count: nbls.count)
|
||||
data = Data(buffer: ptr)
|
||||
try! data.write(to: URL(fileURLWithPath: filename + ".nbl"))
|
||||
|
||||
} else {
|
||||
/* TODO: Hook up logic to figure out the disk format. */
|
||||
image = Dos33Image()
|
||||
|
@ -8,48 +8,117 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
class HiresMode: NSObject {
|
||||
static func putHiresPixel(buffer: UnsafeMutablePointer<BitmapPixelsLE555.PixelData>?, pixel: UInt8, address: UInt16) {
|
||||
let pageBase: Address
|
||||
extension AppleIIBase {
|
||||
|
||||
class HiresMode: NSObject {
|
||||
static func putHiresByte(buffer: UnsafeMutablePointer<BitmapPixelsLE555.PixelData>?, 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 = 0
|
||||
let lowByte = UInt8(offset & 0xFF)
|
||||
var columnByte: UInt8 = 0x00
|
||||
|
||||
if(0x28 ... 0x4F ~= lowByte || 0xA8 ... 0xCF ~= lowByte) {
|
||||
//Middle third.
|
||||
rowNumber += 64
|
||||
columnByte = (lowByte & 0x7F) - 0x28
|
||||
}
|
||||
else if(0x50 ... 0x77 ~= lowByte || 0xD0 ... 0xF7 ~= lowByte) {
|
||||
//Bottom third.
|
||||
rowNumber += 128
|
||||
columnByte = (lowByte & 0x7F) - 0x50
|
||||
}
|
||||
else if(0x78 ... 0x7F ~= lowByte || 0xF8 ... 0xFF ~= lowByte) {
|
||||
//Discard.
|
||||
}
|
||||
else {
|
||||
//Top third.
|
||||
rowNumber += 0
|
||||
columnByte = lowByte & 0x7F
|
||||
}
|
||||
|
||||
if(EmulatedSystemInstance!.videoSoftswitches.PAGE_2) {
|
||||
pageBase = 0x4000
|
||||
} else {
|
||||
pageBase = 0x2000
|
||||
rowNumber += Int(offset / 0x400) /* One line per 0x400 */
|
||||
|
||||
while offset > 0x400 {
|
||||
offset -= 0x400
|
||||
}
|
||||
rowNumber += Int((offset / 0x80) * 8)
|
||||
|
||||
//if(pixel & 0x80)
|
||||
|
||||
let dot0 = (pixel & 0x01) == 0x01
|
||||
let dot1 = (pixel & 0x02) == 0x02
|
||||
let dot2 = (pixel & 0x04) == 0x04
|
||||
let dot3 = (pixel & 0x08) == 0x08
|
||||
let dot4 = (pixel & 0x10) == 0x10
|
||||
let dot5 = (pixel & 0x20) == 0x20
|
||||
let dot6 = (pixel & 0x40) == 0x40
|
||||
//let dot7 = (pixel & 0x80) == 0x80
|
||||
|
||||
let pixelRowOffset = Int(rowNumber * AppleII.ScreenDelegate.PIXEL_WIDTH)
|
||||
let pixelColumnOffset = Int(UInt16(columnByte) * 7)
|
||||
|
||||
if(pixelRowOffset + pixelColumnOffset == 17920) {
|
||||
let x = 0
|
||||
}
|
||||
|
||||
if(dot0) {
|
||||
buffer![pixelRowOffset + 0 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 0 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
if(dot1) {
|
||||
buffer![pixelRowOffset + 1 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 1 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
if(dot2) {
|
||||
buffer![pixelRowOffset + 2 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 2 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
if(dot3) {
|
||||
buffer![pixelRowOffset + 3 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 3 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
if(dot4) {
|
||||
buffer![pixelRowOffset + 4 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 4 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
if(dot5) {
|
||||
buffer![pixelRowOffset + 5 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 5 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
if(dot6) {
|
||||
buffer![pixelRowOffset + 6 + pixelColumnOffset] = AppleII.LoresColors.White
|
||||
} else {
|
||||
buffer![pixelRowOffset + 6 + pixelColumnOffset] = AppleII.LoresColors.Black
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user