Skip to content

Commit

Permalink
fix screen drawing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
breqdev committed Nov 17, 2023
1 parent 9b4cbdf commit 3669596
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/systems/aiie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ impl SystemBuilder<AiieSystem, AiieSystemRoms, AiieSystemConfig> for AiieSystemB
.map(0x1000, Box::new(NullMemory::new()))
.map(
0xC000,
Box::new(LoggingMemory::new(Box::new(io), "I/O", 0xC000)),
Box::new(io),
// Box::new(LoggingMemory::new(Box::new(io), "I/O", 0xC000)),
)
.map(0xC100, Box::new(peripheral_card))
.map(0xD000, Box::new(applesoft_interpreter))
Expand All @@ -260,7 +261,8 @@ pub struct AiieSystem {
impl System for AiieSystem {
fn tick(&mut self) -> Duration {
if self.cpu.registers.pc.address() < 0xF800 {
println!("{:#04x}", self.cpu.registers.pc.address());
// println!("{:#04x}", self.cpu.registers.pc.address());
// println!("{}", self.cpu.memory.read(32768));
}
Duration::from_secs_f64(1.0 / 1_000_000.0) * self.cpu.tick() as u32
}

Check warning on line 268 in src/systems/aiie/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/aiie/mod.rs#L262-L268

Added lines #L262 - L268 were not covered by tests
Expand All @@ -272,11 +274,20 @@ impl System for AiieSystem {
fn render(&mut self, framebuffer: &mut [u8], config: WindowConfig) {
let flash_state = ((self.cpu.get_info().cycle_count / 500_000) & 0b1) == 0;

Check warning on line 275 in src/systems/aiie/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/aiie/mod.rs#L274-L275

Added lines #L274 - L275 were not covered by tests

for y in 0..HEIGHT {
for x in 0..WIDTH {
let block = y / 3; // unused section of 8 bytes after every 3 lines
let index = (y * WIDTH + x + (block * 8)) as u16;
let value = self.cpu.read(0x0400 + index);
// https://retrocomputing.stackexchange.com/a/2541
for index in 0x000..=0x3FF {
let position = match index & 0x7F {
0x00..=0x27 => Some((0, (index & 0x7F) - 0x00)),

Check failure on line 280 in src/systems/aiie/mod.rs

View workflow job for this annotation

GitHub Actions / Desktop Build and Style Check

this operation has no effect
0x28..=0x4F => Some((1, (index & 0x7F) - 0x28)),
0x50..=0x77 => Some((2, (index & 0x7F) - 0x50)),
_ => None,

Check warning on line 283 in src/systems/aiie/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/aiie/mod.rs#L278-L283

Added lines #L278 - L283 were not covered by tests
};

if let Some((third, x)) = position {
let y = (third * 8) + (index >> 7);
// println!("{} -> {}, {}", index, x, y);

let value = self.cpu.read((0x0400 + index) as u16);

let character_index = ((value & 0b0011_1111) as usize) * 8;
let mode = (value & 0b1100_0000) >> 6;

Check warning on line 293 in src/systems/aiie/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/systems/aiie/mod.rs#L286-L293

Added lines #L286 - L293 were not covered by tests
Expand Down

0 comments on commit 3669596

Please sign in to comment.