temp - retrotruestory/M1DEV GitHub Wiki

Magic-1 Emulator Project Status

Based on the logs, here's the current status of your Magic-1 emulator:

Working Components

  • ✅ Basic build/compilation is now successful
  • ✅ Memory initialization (65536 bytes allocated)
  • ✅ Device initialization (UART0, IDE Controller)
  • ✅ Resource loading (bootloader, microcode from PROM files)
  • ✅ Disk image loading

Critical Issues

  1. Unknown Opcode Handling

    • The CPU encounters unknown opcode 0x84 at PC=0x0
    • Execution fails immediately after first instruction
    • Need to add better opcode decoding or verify bootloader/ROM format
  2. Segmentation Fault During Execution

    • Crash occurs after "DEBUG: MainWindow::onEmulatorStarted called"
    • Likely in the execution thread or CPU emulation logic
    • Needs null pointer checks and bounds checking
  3. Signal/Slot Connection Issues

    • Multiple "invalid nullptr parameter" warnings
    • Qt connections are failing between Emulator and MainWindow

Next Steps (In Priority Order)

  1. Fix the Segmentation Fault

    • Add null checks in the CPU execution loop
    • Improve exception handling in critical methods
    • Check for array bounds issues in memory access
  2. Fix Boot Process

    • The emulator tries to start at PC=0x0 but should likely start at the bootloader entry point
    • Set CPU.setProgramCounter() to the correct boot address (typically 0xC000)
  3. Implement Better Instruction Debugging

    • Add detailed instruction tracing
    • Implement a proper disassembler
    • Add proper handling for unknown opcodes
  4. Fix Signal/Slot Connections

    • Ensure emulator instance is fully initialized before connecting signals
    • Update signal/slot syntax to modern Qt5 style

The emulator is close to working, but the most critical issues are the segmentation fault and the boot process that needs to point to the correct start address.

Magic-1 Emulator Project Status Report

After reviewing the complete codebase, I've identified several critical issues that need to be addressed before the emulator will function properly. The good news is that we've made significant progress on the core components.

Current Status

  1. CPU Implementation:

    • Core methods for instruction execution are implemented
    • Memory access routines have been fixed for big-endian operation
    • Most register operations are working
  2. Memory System:

    • Basic memory read/write operations implemented
    • ROM protection mechanism added
    • 16-bit access methods fixed for big-endian operation
  3. Instruction Set:

    • Missing critical components for bootloader execution
    • SBR instruction has definition issues (override not properly matching base class)

Critical Remaining Issues

  1. Fix Duplicate Method Definitions:

    // Remove these duplicate definitions at line ~1220-1268:
    uint8_t CPU::readNextByte() { ... }
    uint8_t CPU::readMemoryAt(uint16_t address) const { ... }
    void CPU::writeMemory(uint16_t address, uint8_t value) { ... }
    uint8_t CPU::getAccumulator() const { ... }
    void CPU::setAccumulator(uint8_t value) { ... }
    
  2. Fix Instruction Base Class:

    // Modify instruction.h to declare disassemble method that can be overridden
    class Instruction {
    public:
        // ... existing code ...
        virtual std::string disassemble(CPU* cpu, uint16_t address) = 0;
    };
    
  3. Fix sbr_instruction Implementation:

    // Change constructor to match expected parameters
    sbr_instruction() : Instruction(0x84, "SBR", RELATIVE, BRANCH, 2, 2) {}
    

Steps to Completion

  1. Fix the instruction_set.h file to properly define SBR and other critical instructions (estimated: 1 hour)

  2. Implement missing instruction execution methods for bootloader execution (estimated: 2 hours)

  3. Consolidate memory access methods to ensure consistent big-endian operation (estimated: 1 hour)

  4. Fix the romProtection handling in Memory class (estimated: 30 minutes)

  5. Clean up duplicate methods in CPU class (estimated: 1 hour)

  6. Add execution tracing for debugging the bootloader process (estimated: 1 hour)

Once these issues are resolved, we should be able to compile the emulator and begin testing the bootloader execution. The most critical part is getting the instruction decoder working correctly, as this is the foundation for executing any code on the emulated system.

Would you like me to focus on implementing any particular component first?