Skip to content

Commit

Permalink
no_intro
Browse files Browse the repository at this point in the history
  • Loading branch information
LLeny committed Oct 7, 2024
1 parent 37ed662 commit ae52260
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ log = { version = "0.4", features = ["max_level_trace", "release_max_level_warn"
serde = { version = "1.0", features = ["derive"] }
postcard = {version = "1.0", features = ["experimental-derive"] }
bitflags = { version = "2.6", features = ["serde"] }
md5 = "0.7.0"
lazy_static = "1.5.0"
36 changes: 34 additions & 2 deletions src/cartridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ mod lnx_header;

mod cartridge_generic;
mod eeprom;
mod no_intro;
use std::io::Error;
use cartridge_generic::*;
use eeprom::Eeprom;
use lnx_header::LNXHeader;
use log::error;
use mikey::registers::MikeyRegisters;
use no_intro::check_no_intro;
use crate::*;

const LNX_HEADER_LENGTH: usize = 64;
Expand All @@ -17,6 +19,11 @@ const DATA_PINS: [u32; 8] = [CART_PIN_D0, CART_PIN_D1, CART_PIN_D2, CART_PIN_D3,
const RIPPLE_PINS: [u32; 11] = [CART_PIN_A0, CART_PIN_A1, CART_PIN_A2, CART_PIN_A3, CART_PIN_A4, CART_PIN_A5, CART_PIN_A6, CART_PIN_A7, CART_PIN_A8, CART_PIN_A9, CART_PIN_A10];
const SHIFTER_PINS: [u32; 8] = [CART_PIN_A12, CART_PIN_A13, CART_PIN_A14, CART_PIN_A15, CART_PIN_A16, CART_PIN_A17, CART_PIN_A18, CART_PIN_A19 ];

const _128K: usize = usize::pow(2, 17);
const _256K: usize = _128K * 2;
const _512K: usize = _256K * 2;
const _1024K: usize = _512K * 2;

// Courtesy of https://github.com/42Bastian/new_bll/
const BLL_LOADER: [u8; 246] = [0xFF, 0x4A, 0x37, 0xB2, 0xB3, 0x0D, 0xEF, 0x61, 0x56, 0xAB, 0xD3, 0xC3, 0x5D, 0x4B, 0xDE, 0xB8,0x38, 0x17, 0x92, 0x59, 0xFA, 0x40, 0xB1, 0x58, 0xC4, 0x8F, 0xB6, 0x6D, 0xBE, 0xBB, 0x20, 0x8E,0x8A, 0x69, 0x86, 0x6C, 0x18, 0x12, 0x0C, 0x7C, 0x50, 0xCD, 0xAA, 0x63, 0x41, 0x3F, 0xD3, 0x89,0xAD, 0xAB, 0x37, 0x14, 0x01, 0xAD, 0xC5, 0x02, 0x49, 0xFF, 0x85, 0xF1, 0xAD, 0xC6, 0x02, 0x49,0xFF, 0x85, 0xF0, 0xAD, 0xC3, 0x02, 0x85, 0xF3, 0x85, 0xF5, 0xAD, 0xC4, 0x02, 0x85, 0xF2, 0x85,0xF4, 0xA2, 0xC0, 0x9A, 0xA0, 0x29, 0xB9, 0x2D, 0x02, 0x99, 0xC0, 0x01, 0x88, 0xD0, 0xF7, 0xA2,0x03, 0x80, 0x9F, 0xCA, 0xD0, 0x09, 0xE6, 0x00, 0xA5, 0x00, 0x20, 0x00, 0xFE, 0xA2, 0x04, 0xAD,0xB2, 0xFC, 0x92, 0xF2, 0xE6, 0xF2, 0xD0, 0x02, 0xE6, 0xF3, 0xE6, 0xF0, 0xD0, 0x07, 0xE6, 0xF1,0xD0, 0x03, 0x6C, 0xF4, 0x00, 0xC8, 0xD0, 0xE7, 0x80, 0xD9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00];

Expand Down Expand Up @@ -117,9 +124,10 @@ impl Cartridge {

if cart.is_lnx(data) {
cart.lnx(data);
}
else if cart.is_bs93(data) {
} else if cart.is_bs93(data) {
cart.bs93(data);
} else if cart.is_nointro(data) {
cart.nointro(data);
}
else {
return Err(Error::new(std::io::ErrorKind::Other, "Couldn't identify cart file format."));
Expand All @@ -143,6 +151,10 @@ impl Cartridge {
&file_content[0..=3] == b"LYNX"
}

fn is_nointro(&self, file_content: &[u8]) -> bool {
check_no_intro(file_content).is_ok()
}

fn bs93(&mut self, file_content: &[u8]) {
let mut cart = CartridgeGeneric::new(1024, &_256K_PINS);
let mut content: Vec<u8> = vec![];
Expand All @@ -156,6 +168,26 @@ impl Cartridge {
self.healthy = true;
}

fn nointro(&mut self, file_content: &[u8]) {
let l = file_content.len();
let mut cart =
if l <= _128K {
CartridgeGeneric::new(512, &_128K_PINS)
} else if l <= _256K {
CartridgeGeneric::new(1024, &_256K_PINS)
} else if l <=_512K {
CartridgeGeneric::new(2048, &_512K_PINS)
} else if l <=_1024K {
CartridgeGeneric::new(4096, &_1024KAUDIN_PINS)
} else {
panic!("Not a No-Intro")
};

cart.load(file_content);
self.cart = CartType::Generic(cart);
self.healthy = true;
}

fn lnx(&mut self, file_content: &[u8]) {
self.load_lnx_header(file_content);

Expand Down
115 changes: 115 additions & 0 deletions src/cartridge/no_intro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
use lazy_static::lazy_static;
use std::collections::HashMap;
use md5;

pub fn check_no_intro(data: &[u8]) -> Result<&'static str, ()> {
let md5 = format!("{:x}", md5::compute(data));
let md5str = md5.as_str();

if SET.contains_key(&md5str) {
Ok(SET[&md5str])
} else {
Err(())
}
}

lazy_static!{
static ref SET: HashMap<&'static str, &'static str> = {
HashMap::from([
("b425941149874c6371c40e85cc5b6241", "A.P.B. (USA, Europe)"),
("8ce6c739d30d6c5ba197fcdd73d5ead5", "Alien vs Predator (USA) (Proto) (1993-12-17)"),
("49d6eeb3c983246ff4d7034497f7095c", "Awesome Golf (USA, Europe)"),
("8c9a72ddbb5559293862684ec67bfa92", "Baseball Heroes (USA, Europe)"),
("f19b95e4835c5fbc44b180dbd3f024fc", "Basketbrawl (USA, Europe)"),
("6e9bbff3c7b66d3ec0411ffbe0e41dfd", "Batman Returns (USA, Europe)"),
("fddecd756abe5eaf613ca1db31d51df7", "Battle Wheels (USA, Europe)"),
("d405ea54b77390b06222f9dac7cea827", "Battlezone 2000 (USA, Europe)"),
("87dff4f4d5e1e4a7132d19f94d4e9b3a", "Bill & Ted's Excellent Adventure (USA, Europe)"),
("c81abf2919effd525b83c2103b75e6ca", "Block Out (USA, Europe)"),
("7c3cb287de2d9f67ff342b4e42592732", "Blue Lightning (USA, Europe) (Demo)"),
("f7b4775771bc25d9053af5c69a8c8b2a", "Blue Lightning (USA, Europe)"),
("90841f8fed54862f8a8750ddf212eb84", "Bubble Trouble (USA, Europe)"),
("73e02bb77dcf857a6578f0e24b4ecb9e", "California Games (USA, Europe)"),
("13cb869b95c67c532efdd0e924e37299", "Centipede (USA) (Proto)"),
("85b33c5e5985ab041ecc44555a8cfb42", "Checkered Flag (USA, Europe)"),
("24611d1445ebd34ab79fb0ae996ff4e4", "Chip's Challenge (USA, Europe)"),
("b4acbd3c544a0d92cc8ad1380bf8a810", "Crystal Mines II (USA, Europe)"),
("f8b4debd68eb0d7c578242fa74e1c593", "Daemonsgate (USA) (Proto)"),
("f764b88c44afa8b5ebefb8eb2e4d7b97", "Desert Strike - Return to the Gulf (USA, Europe)"),
("9496be61fd0675553f05345c5fc2d15c", "Dinolympics (USA, Europe)"),
("8cd77bec912c9b4dcebd8a82dcf91a0b", "Dirty Larry - Renegade Cop (USA, Europe)"),
("0e91b7ed60bb47d569ba24df671ad3a3", "Double Dragon (USA, Europe)"),
("3ff35996887c2ff95e275085efbbbbed", "Dracula the Undead (USA, Europe)"),
("c49ca94a908db219224c6d5baa206ab6", "Electrocop (USA, Europe)"),
("32e726ab7941eb1e833dcc4cf348a060", "European Soccer Challenge (USA, Europe)"),
("858480bb97d86a52b1ca17dc390a8bdc", "Eye of the Beholder (USA) (Proto)"),
("7b3f49bda3162fac51a387905e6fb6f4", "Eye of the Beholder (USA) (Unl)"),
("69abd21c83390dae54630919c3c150d0", "Fat Bobby (USA, Europe)"),
("19eb0ca77284b5d91a63eb02f6962930", "Fidelity Ultimate Chess Challenge, The (USA, Europe)"),
("d5be9118bcb14243468001b08c4aa21a", "Gates of Zendocon (USA, Europe)"),
("8815ea087af1aa89b4f7b65bd3cb8534", "Gauntlet - The Third Encounter (USA, Europe) (Beta) (1990-06-04)"),
("0b572c0dfb938849eeec39b2c9583547", "Gauntlet - The Third Encounter (USA, Europe)"),
("eb9b5b2b6160e5f3015bc2a669d886b6", "Gordo 106 (USA, Europe)"),
("c265f0de8c5bd77db8f9cf5a1f7ab68f", "Hard Drivin' (USA, Europe)"),
("a08b8070ad613bdb2637162b3bf39574", "Hockey (USA, Europe)"),
("76a48869c14fbcf85588001a1327253d", "Hydra (USA, Europe)"),
("addc6c0ae7b535839815b8e7f7fd0f11", "Ishido - The Way of Stones (USA, Europe)"),
("087e6ed018ad0573bd7ce3a91d34f2c9", "Jimmy Connors' Tennis (USA, Europe)"),
("440462507cf5cffaa8d3d3a66f01ac6a", "Joust (USA, Europe)"),
("57043e8e79588c067118a4d5f307cd76", "Klax (USA, Europe) (Beta)"),
("f96a0ddcc72c971226e8fdfd95607c88", "Klax (USA, Europe)"),
("7e82db12a5749ab983e2f3c8bf4c0f6e", "Krazy Ace - Miniature Golf (USA, Europe)"),
("e5e42190918847b8c6056e78316ee91d", "Kung Food (USA, Europe)"),
("3cae85572df3b43f0220326bf4bb3c8b", "Lemmings (USA, Europe)"),
("7ee41edaef283459c9df93366c5da267", "Lexis (USA)"),
("96fd77f3527bc6f65977b99ab63d7f84", "Lode Runner (USA) (Proto) (Unl)"),
("8399c8fba48ba1a4389a96e75838dc49", "Loopz (USA) (Proto)"),
("05d28ab0e92b19147e7f5ea88c6efb6d", "Lynx Casino (USA, Europe)"),
("5d8fdfb15441cdfb8a1c66c243c486da", "Lynx II Production Test Program (USA)"),
("98c851c7ed924e1c7123c60e5164819e", "Malibu Bikini Volleyball (USA, Europe) (Beta) (1993-05-11)"),
("280344c8b073895ecce286d1b9d87d8b", "Malibu Bikini Volleyball (USA, Europe)"),
("194a3eeb876d2b74cc480f4d337d79b3", "Marlboro Go! (Europe) (Proto)"),
("192b6b764a3a1c7831e0a785fa4b5453", "Ms. Pac-Man (USA, Europe)"),
("276b9be28571189912f05d321fcb04ef", "NFL Football (USA, Europe)"),
("7ec4063eb6c7c74600d6a16fb3a3bdbd", "Ninja Gaiden (USA, Europe)"),
("c9ed2a3bdefd6d5fdf67302d87b5cfb2", "Ninja Gaiden III - The Ancient Ship of Doom (USA, Europe)"),
("0a14754b351b4f11a1359e252b8eb992", "Pac-Land (USA, Europe)"),
("2a59d2ca6d6f07bc2791bf349e2778ee", "Paperboy (USA, Europe)"),
("29a248fbc87f477b49587581e29c1dc7", "Pinball Jam (USA, Europe)"),
("5565889a9a8817f99ec6dda322a70877", "Pit-Fighter (USA, Europe)"),
("b29414b8c81cc9ef28ef2f7a09d6d876", "Power Factor (USA, Europe)"),
("12e1eb0900402ef6de8b72dda5d22f47", "QIX (USA, Europe)"),
("abfd6ae93c31e8f59aa934ad922cb4dd", "Raiden (USA) (Proto)"),
("e0cb426257761c3688a866332ed48340", "Rampage (USA, Europe)"),
("d8045ed542d5e58c779c884e0930e16c", "Rampart (USA, Europe)"),
("702e4d515d9f33698407b118c4cd373f", "Road Riot 4WD (USA) (Proto 1)"),
("8e0680d9d484749297bd7f4cfd5b7354", "Road Riot 4WD (USA) (Proto 2)"),
("9222e42a160924dee0c87a67fdbc48d0", "Road Riot 4WD (USA) (Proto 3)"),
("39617ebb81f3c1df27354c18571bd6c3", "RoadBlasters (USA, Europe)"),
("f9faa45e3c35e505249c3f9df801737b", "Robo-Squash (USA, Europe)"),
("60c1dfbf112bbb2a49cf16eddb191842", "Robotron 2084 (USA, Europe)"),
("ff6fff314446ab70dfecb21e2de4a2f6", "Rygar (USA, Europe)"),
("490f8063bbb299070c4aceab64195088", "S.T.U.N. Runner (USA, Europe)"),
("0cf228912d2f8eeb29aa215abf416f6d", "Scrapyard Dog (USA, Europe)"),
("f92d57198ef2da30dba63bdd7c15ff83", "Shadow of the Beast (USA, Europe)"),
("46634eb87e6380d4d10f7b80d177c1ff", "Shanghai (USA, Europe)"),
("8828c0042a1a397de67c4e49042161ff", "Steel Talons (USA, Europe)"),
("67dd69e6ffaf61bc85243d272d9ee9d9", "Super Asteroids, Missile Command (USA, Europe)"),
("6cd23cb37c4c4c34ef4e197468462f3f", "Super Off-Road (USA, Europe)"),
("a19802bd3a7e390daf7e2cbe5a81ed38", "Super Skweek (USA, Europe)"),
("4971dd8b47d3475dc8d31b5325c14459", "Switchblade II (USA, Europe)"),
("4581ac0418679567dce041c88cc97719", "Todd's Adventures in Slime World (USA, Europe)"),
("ec46311f47276e20cc43228c96d119a1", "Toki (USA, Europe)"),
("391dfaba9ab8b9b60e9d8ca2a73f5711", "Tournament Cyberball (USA, Europe)"),
("8caaaf56f95ee0bb610ca14af2d12a61", "Turbo Sub (USA, Europe)"),
("44d7c4ea6b8d930075f5b05c94b5f973", "Viking Child (USA, Europe)"),
("e7f118ac59f985ceea2ecfc0f17e9cc6", "Warbirds (USA, Europe)"),
("7fcf204013cbedf7eaaf682ff5f216ba", "World Class Soccer (USA, Europe)"),
("69fb597cb4db019c48fd2e0c1cc7b75c", "Xenophobe (USA, Europe)"),
("c145bfe904e5d56f479df44204b255da", "Xybots (USA, Europe)"),
("52997de9af205728a0e17ea3475f7ae2", "Zaku (USA) (Beta) (Unl)"),
("6b9d6872961b22de6b1b0cced65d8e3f", "Zaku (USA) (Unl)"),
("d008f41ec119e2c5c6a0782aebf148a8", "Zarlor Mercenary (USA, Europe)"),
])
};
}

0 comments on commit ae52260

Please sign in to comment.