// This is the GUI for the BenEater PC
use beneater::parts::backplane::Backplane;
use beneater::parts::ben_eater_pc::BenEaterPC;
use beneater::parts::cpu_display::CpuDisplay;
use macroquad::prelude::*;
use macroquad::telemetry::frame;
use core::mos6502cpu::cpu::Mos6502Cpu;
use core::periph::at28c256::At28C256;
use core::periph::hm62256::Hm62256;
use core::constants::constants_system::*;
use std::fs;

/// BenEater computer represents the 'Ben Eater' 6502 breadboard computer.
/// This was built along watching the video series where Ben builds a
/// 6502 on a breadboard and explains each step.
///
pub struct BenEater {
    cpu: Mos6502Cpu,
    ram: At28C256,
    rom: Hm62256
}

impl BenEater {
    // pub fn new(rom: &[u8; SIZE_32KB]) -> BenEater {
    //
    // }
}

#[macroquad::main("Ben Eaters PC")]
async fn main() {
    println!("Taxation is Theft");

    // let rom_to_run = fs::read("resources/beneater/roms/ror.bin");
    // let mut pc = BenEater::new(&rom_to_run);
    //
    // let mut backplane = Backplane::new();
    // backplane.load_rom("resources/beneater/roms/ror.bin");

    // let mut dm = DisplayMatrix::new(200.0, 50.0);

    // dm.push_letter('T');
    let mut frame_number: u32 = 0x00;

    loop {
        clear_background(BLUE);

        draw_text("Ben Eater", 20.0, 20.0, 30.0, BLACK);
        // dm.render(20.0, 40.0);
        //  CpuDisplay::render(&computer.cpu, 20.0, 120.0);

        frame_number += 1;

        if frame_number.is_multiple_of(60) {
            // dm.push_letter('X');
       //     computer.tick_system();
        }

        if frame_number.is_multiple_of(60 * 6) {
            // dm.clear_display()
        }

        next_frame().await
    }
}
