Unverified Commit 3cd42bc5 authored by GovanifY's avatar GovanifY
Browse files

Welp that seems to fully work

parent 45962a9d
......@@ -5,7 +5,7 @@ It's as dirty as it can get and doesn't even include VU1 assembler
for now but eh, it kinda works.
Oh btw when I mean it kinda works datas are roughly placed, I just made the
tool in a day. It is still missing some unpack
tool in a day. It is still missing memory checks and additional shading
commands and all, just figured I would upload this before I lose it
Good luck for understanding the code btw, should stop working
......
......@@ -13,16 +13,17 @@ int flag(int x, int y, int z) {
return flagx;
}
int main(int argc, char* argv[]){
long ap, vp, hp;
printf("obj2kh2v\nPlease input only unwelded sorted models containing only triangles!\n\n");
if(argc<3){printf("Usage: obj2kh2v model.obj output.dsm"); return -1;}
std::ifstream in(argv[1], std::ios::in);
std::ofstream dsm (argv[2]);
dsm << ".align 0\n;" << argv[1] << "\n;Automatically generated by obj2kh2v\n;DO NOT EDIT IF YOU DON'T KNOW WHAT YOU ARE DOING\n\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack 4, 128, V4_32, 0, *; Model Part Header\n.int 1, 0, 0, 0;type 1 Model\n";
long hp = dsm.tellp();
dsm << ".align 0\n;" << argv[1] << "\n;Automatically generated by obj2kh2v\n;DO NOT EDIT IF YOU DON'T KNOW WHAT YOU ARE DOING\n\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack[r] V4_32, 0, *; Model Part Header\n.int 1, 0, 0, 0;type 1 Model\n";
hp = dsm.tellp();
//Can't insert if not at eof using ofstream so I put 10 spaces to fill up, size of INT_MAX and no \n to avoid linefeed not beeing rewritten
//It's so hacky but I'm fed up with this shit already
dsm << ".int " << " , , , ";
dsm << "\n.EndUnpack\n\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack 4, 128, V2_16, 0, *; UV definition\n";
dsm << "\n.EndUnpack\n\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack[r] V2_16, 4, *; UV definition\n";
int vi =0;
int ti =0;
......@@ -51,9 +52,9 @@ in.seekg(0, std::ios::beg);
}
dsm << ".EndUnpack\n\nstmask 0xf3f3f3f3; Sets mask register(3303, check EEUSER_E)\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack 4, 128, S_8, 0, *; Vertex indices\n";
dsm << ".EndUnpack\n\nstmask 0xf3f3f3f3; Sets mask register(3303, check EEUSER_E)\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack[r] S_8, 4, *; Vertex indices\n";
for(int i =0; i<vi+1;i++){dsm << ".byte " << i << "\n";}
dsm << ".EndUnpack\n\nstmask 0xf3f3f3f3; Sets mask register(3303, check EEUSER_E)\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack 4, 128, S_8, 0, *; Flags\n";
dsm << ".EndUnpack\n\nstmask 0xf3f3f3f3; Sets mask register(3303, check EEUSER_E)\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack[r] S_8, 4, *; Flags\n";
in.clear();
in.seekg(0, std::ios::beg);
int iff =1;
......@@ -83,7 +84,10 @@ line_process:
}
}
dsm << ".EndUnpack\n\nstcol 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000; We set garbage data to 1(float) so even if nothing is referenced game doesn't go crazy\nstmask 0x02020202; Sets mask register(0002, check EEUSER_E)\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack 4, 128, V3_32, 0, *; Vertex definition\n";
dsm << ".EndUnpack\n\nstcol 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000; We set garbage data to 1(float) so even if nothing is referenced game doesn't go crazy\nstmask 0x02020202; Sets mask register(0002, check EEUSER_E)\nstcycl 01, 01; We write code to memory without skips/overwrite\n\nunpack[r] V3_32,";
vp = dsm.tellp();
dsm << " , *; Vertex definition\n";
in.clear();
in.seekg(0, std::ios::beg);
......@@ -100,7 +104,10 @@ in.seekg(0, std::ios::beg);
}
dsm << ".EndUnpack\n\nunpack 4, 128, V4_32, 0, *; Vertex affiliation header\n.int " << vi+1 << ", 0, 0, 0\n.EndUnpack\n";
dsm << ".EndUnpack\n\nunpack[r] V4_32,";
ap = dsm.tellp();
dsm << " , *; Vertex affiliation header\n.int " << vi+1 << ", 0, 0, 0\n.EndUnpack\nvifnop\nvifnop; We wait for data to be kicked in\n";
}
printf("h1: %i, h2: 4, h3: %i, h4: %i\nj1: %i, j2: %i, j3: 0, j4: 1\n",ti, 4+ti+vi, 4+ti+vi+1,vi, 4+ti);
//TODO: Stop hardcode Header size(5type-line exist) and Vert/Array
......@@ -108,7 +115,11 @@ printf("h1: %i, h2: 4, h3: %i, h4: %i\nj1: %i, j2: %i, j3: 0, j4: 1\n",ti, 4+ti+
//checked!
dsm.seekp(hp);
dsm << ".int " << ti << ", 4, " << 4+ti+vi << ", " << 4+ti+vi+1 << "; Number of u+v+flag+index, their offset, offset of vertex affiliation header, offset of mat definition(end)\n";
dsm << ".int 0, 0, 0, 0; Nobody care about vertices merging and colors\n";
dsm << ".int 0, 0, 0, 0; Nobody care about vertices merging and colors\n";
dsm << ".int " << vi << ", " << 4+ti << ", 0, 1; Number of vertex, their offset, reserved and number of array attribution\n";
dsm.seekp(vp);
dsm << 4+ti;
dsm.seekp(ap);
dsm << 4+ti+vi;
return 1;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment