Skip to content

Commit

Permalink
fixed cli
Browse files Browse the repository at this point in the history
strange state propegation behavior forced me to treat Memory objects as States instead of Environment objects... whatever
  • Loading branch information
AdinAck committed Apr 12, 2023
1 parent b917b9d commit b17396c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 25 deletions.
5 changes: 2 additions & 3 deletions LEGv8-Simulator-CLI/LEGv8_Simulator_CLI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ struct LEGv8SimulatorCLI: ParsableCommand {
if interpreter.assembled {

interpreter.start(text)
interpreter.goToEntryPoint()

while interpreter.running {
interpreter.step(mode: .running)
}
interpreter.run()

try "\(interpreter.cpu)".write(to: URL(fileURLWithPath: path_out), atomically: true, encoding: .utf8)
} else {
Expand Down
15 changes: 3 additions & 12 deletions LEGv8-Simulator/Models/CPUModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,14 @@ enum CPUError: Error {
case stackPointerMisaligned(_ address: Int64)
}

class Memory: ObservableObject, Identifiable, Comparable {
struct Memory: Identifiable, Comparable {
let id: Int64
@Published var value: Int64
@Published var displayMode: String = "H"
var value: Int64
var displayMode: String = "H"

static func < (lhs: Memory, rhs: Memory) -> Bool {
return lhs.id < rhs.id
}

static func == (lhs: Memory, rhs: Memory) -> Bool {
return lhs.id == rhs.id
}

init(id: Int64, value: Int64) {
self.id = id
self.value = value
}
}

class CPUModel: ObservableObject, CustomStringConvertible {
Expand Down
14 changes: 7 additions & 7 deletions LEGv8-Simulator/Views/Memory/MemoryValueColumnView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import SwiftUI

struct MemoryValueColumnView: View {
@EnvironmentObject var interpreter: Interpreter
@EnvironmentObject var memory: Memory
let memory: Memory
@State private var isPresented: Bool = false

var body: some View {
HStack {
Picker("", selection: $memory.displayMode) {
Text("H").tag("H")
Text("D").tag("D")
}
.pickerStyle(.segmented)
.frame(width: 50)
// Picker("", selection: $memory.displayMode) {
// Text("H").tag("H")
// Text("D").tag("D")
// }
// .pickerStyle(.segmented)
// .frame(width: 50)

Button {
isPresented.toggle()
Expand Down
3 changes: 1 addition & 2 deletions LEGv8-Simulator/Views/Memory/MemoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ struct MemoryView: View {
}

TableColumn("Value") { memory in
MemoryValueColumnView()
MemoryValueColumnView(memory: memory)
.environmentObject(interpreter)
.environmentObject(memory)
}
}
.contextMenu {
Expand Down
2 changes: 1 addition & 1 deletion LEGv8-Simulator/Views/Settings/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

struct AboutView: View {
let version: String = "1.1 (Release)"
let version: String = "1.2 (Release)"

var body: some View {
HStack {
Expand Down

0 comments on commit b17396c

Please sign in to comment.