diff --git a/coco-ui/index.html b/coco-ui/index.html
index 625c6ec..175e9e3 100644
--- a/coco-ui/index.html
+++ b/coco-ui/index.html
@@ -20,6 +20,7 @@
👻-8
+
diff --git a/coco-ui/index.js b/coco-ui/index.js
index 82b0e8a..3cb7830 100644
--- a/coco-ui/index.js
+++ b/coco-ui/index.js
@@ -51,7 +51,7 @@ async function main() {
const _ = await initWasm("./vendor/coco_ui_bg.wasm");
const romSelector = document.querySelector("#coco-rom-selector");
- const defaultRom = "sprite.rom";
+ const defaultRom = "sprite_move.rom";
setupRomSelector(romSelector, defaultRom);
setupControls();
diff --git a/coco-ui/roms/sprite_move.rom b/coco-ui/roms/sprite_move.rom
new file mode 100644
index 0000000..a9bc926
Binary files /dev/null and b/coco-ui/roms/sprite_move.rom differ
diff --git a/coco-vm/src/lib.rs b/coco-vm/src/lib.rs
index 83cce9c..29ad5c6 100644
--- a/coco-vm/src/lib.rs
+++ b/coco-vm/src/lib.rs
@@ -60,8 +60,7 @@ impl Vm {
}
pub fn on_video(&mut self, cpu: &mut Cpu) -> DeviceOutput {
- // TODO: call video vector
- cpu.run(0x200, self);
+ cpu.run(self.video.vector(), self);
self.output()
}
diff --git a/coco-vm/src/video.rs b/coco-vm/src/video.rs
index 6fc4a95..3c7242b 100644
--- a/coco-vm/src/video.rs
+++ b/coco-vm/src/video.rs
@@ -11,7 +11,6 @@ impl Ports for VideoPorts {
}
impl VideoPorts {
- #[allow(dead_code)]
const VECTOR: u8 = 0x00;
const X: u8 = 0x02;
const Y: u8 = 0x03;
@@ -32,6 +31,7 @@ pub struct VideoDevice {
pub layers: [VideoBuffer; 2],
is_dirty: bool,
buffer: VideoBuffer,
+ vector: u16,
}
impl VideoDevice {
@@ -40,9 +40,14 @@ impl VideoDevice {
layers: [[0x00; VIDEO_BUFFER_LEN]; 2],
is_dirty: true,
buffer: [0x00; VIDEO_BUFFER_LEN],
+ vector: 0,
}
}
+ pub fn vector(&self) -> u16 {
+ self.vector
+ }
+
pub fn pixels(&mut self) -> &VideoBuffer {
if std::mem::take(&mut self.is_dirty) {
self.refresh_buffer();
@@ -76,6 +81,15 @@ impl VideoDevice {
u16::from_be_bytes([hi, lo])
}
+ #[inline]
+ fn deo_vector(&mut self, cpu: &mut Cpu) {
+ let ports = cpu.device_page::();
+ let hi = ports[VideoPorts::VECTOR as usize];
+ let lo = ports[VideoPorts::VECTOR as usize + 1];
+
+ self.vector = u16::from_be_bytes([hi, lo]);
+ }
+
fn deo_pixel(&mut self, cpu: &mut Cpu) {
self.is_dirty = true;
@@ -162,6 +176,7 @@ impl VideoDevice {
impl Device for VideoDevice {
fn deo(&mut self, cpu: &mut Cpu, target: u8) {
match target {
+ VideoPorts::VECTOR => self.deo_vector(cpu),
VideoPorts::X => {}
VideoPorts::Y => {}
VideoPorts::PIXEL => self.deo_pixel(cpu),