#![no_std]
#![allow(non_upper_case_globals)]
#[allow(unused_imports)]
use arduboy_rust::prelude::*;
const arduboy: Arduboy2 = Arduboy2::new();
static e: EEPROM = EEPROM::new(10);
struct Scorebord {
player1: u16,
text: &'static str,
}
static mut s: Scorebord = Scorebord {
player1: 0,
text: "lol\0",
};
#[no_mangle]
pub unsafe extern "C" fn setup() {
arduboy.begin();
arduboy.set_frame_rate(1);
arduboy.clear();
e.init(&mut s);
}
#[no_mangle]
#[export_name = "loop"]
pub unsafe extern "C" fn loop_() {
if !arduboy.next_frame() {
return;
}
arduboy.poll_buttons();
if arduboy.just_pressed(B) {
s.player1 += 1;
e.put(&s);
}
if arduboy.just_pressed(DOWN) {
s.player1 -= 1;
e.put(&s);
}
if arduboy.just_pressed(A) {
s.player1 += 1;
e.get(&mut s);
}
arduboy.clear();
if s.player1 == 5 {
arduboy.print(f!(b"lolxd\0"));
s.text = "it works!!!\0";
e.put(&s)
} else {
arduboy.print(f!(b"nope\0"));
s.text = "lol\0";
e.put(&s)
}
arduboy.print("\n\0");
arduboy.print("eeprom save: \0");
let ss: Scorebord = e.get_direct();
arduboy.print(ss.player1);
arduboy.print("\nscore save: \0");
arduboy.print(s.player1);
arduboy.print("\n \0");
arduboy.print(s.text);
arduboy.display();
}