Skip to content

Commit

Permalink
Remove nightly features
Browse files Browse the repository at this point in the history
  • Loading branch information
joajfreitas committed Aug 22, 2024
1 parent d7ca493 commit 2bc750c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ resolver = "2"

members = [
"fpt",
"fpt-egui",
#"fpt-egui",
"fpt-cli",
]
2 changes: 1 addition & 1 deletion fpt-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
default-run = "main"

[dependencies]
clap = { version = "4.4.6", features = ["derive"] }
clap = { version = "4.0", features = ["derive"] }
fpt = { path = "../fpt" }
rustyline = "13.0.0"

Expand Down
4 changes: 2 additions & 2 deletions fpt-cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#![feature(array_chunks)]
#![feature(iter_intersperse)]
//#![feature(array_chunks)]
//#![feature(iter_intersperse)]
4 changes: 2 additions & 2 deletions fpt-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![feature(array_chunks)]
#![feature(iter_intersperse)]
//#![feature(array_chunks)]
//#![feature(iter_intersperse)]

use std::fs;

Expand Down
6 changes: 3 additions & 3 deletions fpt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(bigint_helper_methods)]
#![feature(array_chunks)]
#![feature(iter_intersperse)]
//#![feature(bigint_helper_methods)]
//#![feature(array_chunks)]
//#![feature(iter_intersperse)]

use std::collections::VecDeque;

Expand Down
21 changes: 17 additions & 4 deletions fpt/src/lr35902.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ use crate::{bw, memory};

pub mod instructions;

fn carrying_add(x:u8, y:u8, carry: bool) -> (u8, bool) {
let carry: u8 = carry as u8;
let half_adder = x ^ y ;
let sum = half_adder ^ carry;
let carry = (carry & half_adder) | (x & y);
(sum, carry == 1)
}

// yolo
fn borrowing_sub(x:u8, y:u8, borrow:bool) -> (u8, bool) {
carrying_add(x, !y, !borrow)
}

#[derive(Clone, PartialEq)]
pub struct LR35902 {
af: u16,
Expand Down Expand Up @@ -403,9 +416,9 @@ impl LR35902 {
self.set_c_flag(overflow);
result
}

fn addc8(&mut self, x: u8, y: u8) -> u8 {
let (result, overflow) = x.carrying_add(y, self.c_flag());
let (result, overflow) = carrying_add(x, y, self.c_flag());
self.set_z_flag(result == 0);
self.set_n_flag(false);
self.set_h_flag(self.half_carryc8(x, y, self.c_flag() as u8));
Expand All @@ -424,10 +437,10 @@ impl LR35902 {
}

fn subc8(&mut self, x: u8, y: u8) -> u8 {
let (result, overflow) = x.borrowing_sub(y, self.c_flag());
let (result, overflow) = borrowing_sub(x, y, self.c_flag());
self.set_z_flag(result == 0);
self.set_n_flag(true);
self.set_h_flag((x & 0x0f).borrowing_sub(y & 0x0f, self.c_flag()).1);
self.set_h_flag(borrowing_sub(x & 0x0f, y & 0x0f, self.c_flag()).1);
self.set_c_flag(overflow);
result
}
Expand Down
5 changes: 2 additions & 3 deletions fpt/src/ppu/tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ pub fn write_pgm_screenshot(frame: &Frame, filename: &str) {
write!(file, "P2\n# Game Boy screenshot: {filename}\n160 144\n3\n").unwrap();

// Our Game Boy's framebuffer seems to have a direct correspondence to this!
for line in frame.array_chunks::<160>() {
for line in frame.chunks(160) {
let pgm_line = line
.iter()
.map(|p| (b'3' - *p) as char) // ASCII from '0' to '3'
.intersperse(' ')
.map(|p| String::from((b'3' - *p) as char) + " ") // ASCII from '0' to '3'
.collect::<String>()
+ "\n";

Expand Down
3 changes: 2 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[toolchain]
channel = "nightly-2024-06-11"
#channel = "nightly-2024-01-01"
channel = "stable"
components = [ "rustfmt", "rustc-dev" , "clippy"]
profile = "minimal"

0 comments on commit 2bc750c

Please sign in to comment.