mos6502/beneater/src/bin/make_rom.rs

47 lines
1.1 KiB
Rust

#![feature(slice_as_array)]
use core::constants::constants_system::SIZE_32KB;
use core::constants::constants_isa_op::*;
use std::fs;
use std::path::Path;
fn le_swap(to_swap: &[u8; SIZE_32KB]) -> [u8; 32768] {
let mut work: [u8; SIZE_32KB] = [0x00; SIZE_32KB];
for i in (0..SIZE_32KB).step_by(2) {
work[i] = to_swap[i+1];
work[i + 1] = to_swap[i];
}
work
}
fn main() {
// make the rom data in memory.
// Fill with 0xea -> NOP
let mut vec: [u8; SIZE_32KB] = [ISA_OP_NOP; SIZE_32KB];
vec[0] = ISA_OP_LDA_I; // LDA #$ab
vec[1] = 0b1010_1011; // 1010 1011
vec[2] = 0x02; // --
vec[3] = 0x03; // --
vec[0x4000] = ISA_OP_LDA_I;
vec[0x4001] = 0b0101_0100;
vec[0x4002] = ISA_OP_JMP_ABS;
vec[0x4003] = 0x00;
vec[0x4004] = 0x40;
vec[0x4005] = ISA_OP_NOP;
vec[0x7ffc] = 0x12; // Reset Vector
vec[0x7ffd] = 0x34;
vec[0x7ffe] = 0x43; // Interrupt Vector
vec[0x7fff] = 0x21;
vec = le_swap(&vec);
// write the rom to disk
fs::write("outputfile.bin", &vec[..]).expect("TODO: panic message");
}