use std::cell::RefCell; use std::rc::Rc; use rustv::isa; use rustv::memory::{Memory, MemoryInterface, Mmu}; use memory_tracker::MemoryTracker; pub const HOME_STATUS: isa::Address = 0xFFF00; /// Update the various global data structures as requested by other /// subsystems. // Intended to be passed around as &'a GlobalsUpdater pub struct GlobalsUpdater<'a> { // TODO: weak reference? memory: Rc>, mmu1: Box, mmu2: Box, } impl<'a> GlobalsUpdater<'a> { pub fn new(memory: Rc>, mmu1: Box, mmu2: Box) -> GlobalsUpdater<'a> { GlobalsUpdater { memory: memory, mmu1: mmu1, mmu2: mmu2, } } pub fn init_memory(&self) { // Initialize taunt array to all -1 for offset in 0..(228 / 4) { let address1 = self.mmu1.translate(HOME_STATUS + 28 + offset); let address2 = self.mmu2.translate(HOME_STATUS + 28 + offset); let _ = self.memory.borrow_mut().write_word( address1, (-1 as i32) as isa::Word); let _ = self.memory.borrow_mut().write_word( address2, (-1 as i32) as isa::Word); } } // TODO: how to distinguish which player? pub fn fetch_tag(&self, tag: isa::Address, index: u32) { // TODO: assert index is 0 or 1 let address = HOME_STATUS; } pub fn finish_tag(&self, tag: isa::Address, index: u32) { } pub fn update_score(&self, player1: i64, player2: i64) { } }