From 072686ea8db4f90a344e5cd4d6524c3f2adebffc Mon Sep 17 00:00:00 2001 From: Lea Date: Sun, 22 Jan 2023 21:50:58 +0100 Subject: [PATCH] init commit --- .gitignore | 1 + Cargo.lock | 7 ++++ Cargo.toml | 12 ++++++ rom/invaders | Bin 0 -> 8192 bytes rom/invaders.e | Bin 0 -> 2048 bytes rom/invaders.f | Bin 0 -> 2048 bytes rom/invaders.g | Bin 0 -> 2048 bytes rom/invaders.h | Bin 0 -> 2048 bytes src/decompiler/main.rs | 90 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 110 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 rom/invaders create mode 100644 rom/invaders.e create mode 100644 rom/invaders.f create mode 100644 rom/invaders.g create mode 100644 rom/invaders.h create mode 100644 src/decompiler/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..5f6ea9f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "invadeez" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..d53ac4f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "invadeez" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[[bin]] +name = "decompiler" +path = "src/decompiler/main.rs" diff --git a/rom/invaders b/rom/invaders new file mode 100644 index 0000000000000000000000000000000000000000..5a831663457b511ee32385a939415b0c3825e1c3 GIT binary patch literal 8192 zcmeG>|9=}rcC)M1Y9-l{)|PB(CB?H^TXyVV%o01vVhblF{t_qz%D3ya7Xlm(CBY$Z zu^k-QNeJYiK==fX1X?~^@4yAxDqQ;s`SfV2?A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n??Uu_Zr>?^BfZ=D4OtRTbARrZM)TTwP)@HpNDq`i87@YHe6ukF}ez zdLJftIJI5~)f%z>eW%zEl^bZ}tV-kBy>!9{Y1%3-$Eh!Azozf@+lZ~e*k_#95mh&0 zo6B;WOKVharBe_tV)17#bek1+$V2`rU6#J532K5-r|Qv0y>Aed$v52_DhvX%!722;Y@GfRGK*dIg6>2ySvPp9$J*$e8}4!(iicj+>0Bj8}8!a zabsg$V`GX}H)CThKa@3~sgD}J@lTBfx#AF8riJ8jb1|goiOo3 zy5C8C$7?*z;)F53vxyScNw)=wmErR$i&6(knm&*;f_&pi*9Spna;Otf_ z!&SpMoS4S5x61VFg6W4dj>Km;F@fQ(o8}piquI%aT1b%hQAV|7)k@GDgp0_%ixbmw QVmd*y639&+7eEyBe}c}&sQ>@~ literal 0 HcmV?d00001 diff --git a/rom/invaders.e b/rom/invaders.e new file mode 100644 index 0000000000000000000000000000000000000000..66da886fa0242d32d972fd2bd4744d3b999a1239 GIT binary patch literal 2048 zcmY*ZeP|o!8Gr9X(&;3f?sQVPJDsfeB>AMI!BMm{b~H(m-6XcMHgzD&7#pqoL6fn# zVIee5&~$F;AA!LLERdw7B~XUf(y^@t6Id~}4%3|5qlQ42ef+VGO=E2+E$y~ogm2G# zme=-`?)|;L=Y8&X&-1(=*miapFXGO^S}2t7EG!2pdqXkAlJuG`q}(sK246XYsilm2 zQu))U;vQ1$lH&f3r#>K-yY9n^T~$_tqI)2@;;dHB;78qG@GB0#>5bk#%kZZd{&9x? z9<$&WUA!-U%>5%ZSzW`o)~+knF7C0r-pAd`id05w?p)m@QRQ0`Nd-K8WhUysS@DZ&y|EuLur}98S-yy|#E))!~ z3{CADDduz~C5u8V8VQF2o^~NG2f7u_*{Z~`{E;WlI;%mZojvu_?Abu~sMhWs{0~00 z0(C9yNBQ<l*k{x31qziypd}212420{$ShuHSwc;vp|Y z)avZU#%xvfXZ#KXsqa~|%5d$z1#XwnvE+zWQ!$yZj8}0L*&iQs@bSS#D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mV?d00001 diff --git a/rom/invaders.g b/rom/invaders.g new file mode 100644 index 0000000000000000000000000000000000000000..6b90e831e6cc379227aea043f5dfad44cd77df9c GIT binary patch literal 2048 zcmeHG-)kII6rP!^vv+3dPKMnyGt-TGZ#Qj7wk&m`s~M7^KDGXM5Fe_25XA@Mi&P7; zMbl|%P>Q}-f)IaDiZ6>4-Bv_JeMshF=_DN6utwL(gG9_yNg%8tAZgh3%%=69F!$kd z=G^bh`R;eWQ*~x3+!Wn$sz;{?q$T`-YXU4-GKDP@%)Ovmu+ak-6!$!>%&jYs>V=0D zs1rEU3n$dM$BCSXk#F?YWJs7iM+8AIzO!M2$kR)ru1BvDJ(^DPvq?|nA1A?v~s+WLwHD?~dcs(EW*4W)L7#KA%Z-*^AI73+elV4H6o{ z11krGlY@hU*6OlMYBC?mxC(8ZzBP1_p7|;mRG1)pqBBVg`!CWEjJ?ISA40cPDEO5d zau0SRbH^098%gE;Z|hK09`ZMtc%Z+3EO-v{#*0}P$uvjdJ-bs?61=waA(gxNmdP&n zwWNB!m8j=KtaqDu!>ZGyD?@+N)n$Kjp!`DKe|Mn#Y~Ihme3E~zya`__Z!K=>xEebA zs5CqKLU`Tg?T%vXA6jSIG-OhLNywjR z)jNFebz(OhRd=$X+e2IJ&|OE*OsL0Xf);t~G)yQy+n^<(P%e~2_7V*}2@P12-Fd{l zjofBwxM;`k<0W@~I~H70@vWxRkUdTLlahCY|EhZDa9if51a}sF`@O11ub6st1u>aI zO6ODRT}nZOsesCRxMNpqUA6n*ymbezsqPxBu-?O|L~vU(wz4p#8r43ysp1jznDBK6 z5Imt7AK37R3g=Yg>b{)-5k{E%FJ|8i%PJZVOJYsitP(u0!2)sG49?o9FDe!5WlLzH z&ZNZ?)zolQP^{Ors&jzGf=yzC$JqXYmD;bKu^ki?~QL7VlBJWU@8tk2b_I^5Van#+5$2CD$|@Xa13u7DzgEP)g}I Pe7kE`fn5durwaTF#wig=;w5TMC(vL*_)BZsBqd&}#s?D$Vyj!fhZ6?7`6Xie^*TzPPRUtPbf*!Ca-kN3Ia9WPZBFNYZS^=i$J*&tVWhjWx(J5 z?yqQJSaqJIf`NRMzJQ@l`CIBo60eFdU@~xdCz;|cFl_Gi+dlsZ{Y%?{;(TmmBJQ4~ zqvh&>(tPaci9z?Lw8N8>GsqHiZ->}AN;joo6IW*S zA;Wzv=(v~xs&sO;B^SPZ(VD?(4k_|ba&C37x~Sh!5)1BDMNY=ujKX7J`wyzV@69OY z@Y5Gc&bVS?W`C%d-!b*XN-sKDx%$i{o} zgM@sdrR=@jDQ|Y$Wv?$}y@wjbE)Tb(brF*7iY!Ksny;kOV?=&LSED)3$mMk*2026I zLH@RNR_IW?q7I0+KwfQ;$CK_|Eoi$UvPE(4D5xkt3Yd7i>|O|wbe38v7-?RDgCVO2 zqV<_jwEkMiErevHOVbc)2zfWiok=;8luyQUM682a(f`mZga$+kaB9)-M=K4@)fT&Y~p?B4QIS;*!H89CD|XA z&%_(%Hq*>x@Ru>O5gc<#d|(_So{tD*X<}>_moDPuxyFLk2d4^RE66wE)(eNn2WaN5`bH9Z5lyKYUTtr4 z&#P+#lRMO@+U4z)srj}-hqIm4co8yz4d)qd&aZDUO28)}lSyYXIVPsSeTkJTF1{)S z;&|#Tobl8QqGH@ejbo?rJ1x zpN#V}%~OpeSuEJ#!nhpk;*&kb8E`S?lPOdJ62A#eXDTJoP5AnL{nN+W!}8Mzel7=j zY)gCG`DR3aKZzsP=yKRQuCcdg#e0CSryqT4IU&X!Fz$ogl#uBJdK{;8QrrULCKyW~ w_b22nDsNM{5D^c!cwop6@Pq1e;Ty6-WjMi$JB<6>xNo50p_9pT5e$X=3yLDh>i_@% literal 0 HcmV?d00001 diff --git a/src/decompiler/main.rs b/src/decompiler/main.rs new file mode 100644 index 0000000..7cc8925 --- /dev/null +++ b/src/decompiler/main.rs @@ -0,0 +1,90 @@ +use std::fs; +use core::slice::Iter; + +fn main() { + let file = fs::read("/home/lea/Downloads/invadeez/invadeez/rom/invaders.h").expect("where file"); + let mut data = file.iter(); + + while let Some(byte) = data.next() { + fn next(data: &mut Iter, len: u8) -> String { + let mut res = String::new(); + + for _ in 0..len { + res.insert_str(0, format!("{:x}", data.next().expect("Expected data")).as_str()); + } + + return res; + } + + // http://www.emulator101.com/reference/8080-by-opcode.html + + let instruction: String = match byte { + 0x00 => format!("NOP"), + 0x01 => format!("LXI B,#${}", next(&mut data, 2)), + 0x02 => format!("STAX B"), + 0x03 => format!("INX B"), + 0x04 => format!("INR B"), + 0x05 => format!("DCR B"), + 0x06 => format!("MVI B,#0x{}", next(&mut data, 1)), + 0x07 => format!("RLC"), + 0x09 => format!("DAD B"), + 0x0a => format!("LDAX B"), + 0x0b => format!("DCX B"), + 0x0c => format!("INR C"), + 0x0d => format!("DCR C"), + 0x0e => format!("MVI C,#0x{}", next(&mut data, 1)), + 0x0f => format!("RRC"), + 0x11 => format!("LXI D,#0x{}", next(&mut data, 2)), + 0x12 => format!("STAX D"), + 0x13 => format!("INX D"), + 0x14 => format!("INR D"), + 0x15 => format!("DCR D"), + 0x16 => format!("MVI D,#0x{}", next(&mut data, 1)), + 0x17 => format!("RAL"), + 0x19 => format!("DAD D"), + 0x1a => format!("LDAX D"), + 0x1b => format!("DCX D"), + 0x1c => format!("INR E"), + 0x1d => format!("DCR E"), + 0x1e => format!("MVI E,#0x{}", next(&mut data, 1)), + 0x1f => format!("RAR"), + 0x21 => format!("LXI H,#0x{}", next(&mut data, 2)), + 0x22 => format!("SLHD %0x{}", next(&mut data, 2)), + 0x23 => format!("INX H"), + 0x24 => format!("INR H"), + 0x25 => format!("DCR H"), + 0x26 => format!("MVI H,{}", next(&mut data, 1)), + 0x27 => format!("DAA"), + 0x29 => format!("DAD H"), + 0x2a => format!("LHLD ${}", next(&mut data, 2)), + 0x2b => format!("DCX H"), + 0x2c => format!("INR L"), + 0x2d => format!("DCR L"), + 0x2e => format!("MVI L,#0x{}", next(&mut data, 1)), + 0x2f => format!("CMA"), + 0x31 => format!("LXI SP,#0x{}", next(&mut data, 2)), + 0x32 => format!("STA ${}", next(&mut data, 2)), + 0x33 => format!("INX SP"), + 0x34 => format!("INR M"), + 0x35 => format!("DCR M"), + 0x36 => format!("MVI M,#0x{}", next(&mut data, 1)), + 0x37 => format!("STC"), + 0x39 => format!("DAD SP"), + 0x3a => format!("LDA ${}", next(&mut data, 2)), + 0x3b => format!("DCX SP"), + 0x3c => format!("INR A"), + 0x3d => format!("DCR A"), + 0x3e => format!("MVI A,#0x{}", next(&mut data, 1)), + 0x3f => format!("CMC"), + // -- continue here -- + 0xc3 => format!("JMP ${}", next(&mut data, 2)), + 0xc5 => format!("PUSH B"), + 0xd5 => format!("PUSH D"), + 0xe5 => format!("PUSH H"), + 0xf5 => format!("PUSH PSW"), + _ => panic!("Unimplemented instruction {:#x}", byte), + }; + + println!("{}", instruction); + } +}