📄 umd_genegine.cs
字号:
num1 = (uint) (0x1000 + random1.Next(0xfff));
writer1.Write('#');
writer1.Write((short) 130);
writer1.Write((byte) 1);
writer1.Write((byte) 10);
writer1.Write((byte) 1);
writer1.Write(num1);
writer1.Write('$');
writer1.Write(num1);
writer1.Write((uint) (9 + buffer1.Length));
writer1.Write(buffer1);
}
writer1.Write('#');
writer1.Write((short) 0xf1);
writer1.Write((byte) 0);
writer1.Write((byte) 0x15);
writer1.Write(Encoding.ASCII.GetBytes("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"));
// pbar.Maximum = this.iContent.Length * 5;
// pbar.Value = 0;
// this.GetPageOffsetS60(0x10, this.ACTUAL_WIDTH_S60_HORI, ref pbar, out numArray2);
// this.WritePageOffset(0x10, (byte) (this.ACTUAL_WIDTH_S60_HORI + 4), ref numArray2, ref writer1, 1);
// numArray2.Initialize();
// this.GetPageOffsetS60(0x10, this.ACTUAL_WIDTH_S60_VERT, ref pbar, out numArray2);
// this.WritePageOffset(0x10, (byte) (this.ACTUAL_WIDTH_S60_VERT + 4), ref numArray2, ref writer1, 1);
// numArray2.Initialize();
// this.GetPageOffsetS60(12, this.ACTUAL_WIDTH_S60_HORI, ref pbar, out numArray2);
// this.WritePageOffset(12, (byte) (this.ACTUAL_WIDTH_S60_HORI + 4), ref numArray2, ref writer1, 1);
// numArray2.Initialize();
// this.GetPageOffsetS60(12, this.ACTUAL_WIDTH_S60_VERT, ref pbar, out numArray2);
// this.WritePageOffset(12, (byte) (this.ACTUAL_WIDTH_S60_VERT + 4), ref numArray2, ref writer1, 1);
// numArray2.Initialize();
// this.GetPageOffsetSP(10, this.ACTUAL_WIDTH_SP, ref pbar, out numArray2);
// this.WritePageOffset(10, this.ACTUAL_WIDTH_SP, ref numArray2, ref writer1, 5);
writer1.Write('#');
writer1.Write((short) 12);
writer1.Write((byte) 1);
writer1.Write((byte) 9);
writer1.Write((uint) (((uint) writer1.BaseStream.Position) + 4));
writer1.Close();
stream1.Close();
result = "true";
return true;
}
public bool Make(ref ProgressBar pbar, out string result)
{
uint[] numArray2;
this.Prepare();
Random random1 = new Random();
uint num1 = 0;
if (this.iSaveTo.EndsWith(@"\"))
{
this.iSaveTo.Remove(this.iSaveTo.Length - 1, 1);
}
string text1 = this.iSaveTo + @"\" + this.iTitle + ".umd";
if (File.Exists(text1))
{
if (MessageBox.Show("您要保存的文件已经存在,是否覆盖?", "mBook制作工具 版本:1.0", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
File.Delete(text1);
}
else
{
result = "生成文件操作被用户取消";
return false;
}
}
FileStream stream1 = new FileStream(text1, FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter writer1 = new BinaryWriter(stream1);
byte num9 = Encoding.Unicode.GetBytes((string) this.iChapter[0])[0];
writer1.Write((uint) 0xde9a9b89);
writer1.Write('#');
writer1.Write((short) 1);
writer1.Write((byte) 0);
writer1.Write((byte) 8);
writer1.Write((byte) 1);
writer1.Write(this.iPGKSeed);
writer1.Write('#');
writer1.Write((short) 2);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iTitle.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iTitle));
writer1.Write('#');
writer1.Write((short) 3);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iAuthor.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iAuthor));
if (this.iYear.Length > 0)
{
writer1.Write('#');
writer1.Write((short) 4);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iYear.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iYear));
}
if (this.iMonth.Length > 0)
{
writer1.Write('#');
writer1.Write((short) 5);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iMonth.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iMonth));
}
if (this.iDay.Length > 0)
{
writer1.Write('#');
writer1.Write((short) 6);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iDay.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iDay));
}
if (this.iGender.Length > 0)
{
writer1.Write('#');
writer1.Write((short) 7);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iGender.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iGender));
}
if (this.iPublisher.Length > 0)
{
writer1.Write('#');
writer1.Write((short) 8);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iPublisher.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iPublisher));
}
if (this.iVendor.Length > 0)
{
writer1.Write('#');
writer1.Write((short) 9);
writer1.Write((byte) 0);
writer1.Write((byte) (5 + (this.iVendor.Length * 2)));
writer1.Write(Encoding.Unicode.GetBytes(this.iVendor));
}
writer1.Write('#');
writer1.Write((short) 11);
writer1.Write((byte) 0);
writer1.Write((byte) 9);
writer1.Write(this.ibContent.Length);
num1 = (uint) (0x3000 + random1.Next(0xfff));
writer1.Write('#');
writer1.Write((short) 0x83);
writer1.Write((byte) 1);
writer1.Write((byte) 9);
writer1.Write(num1);
writer1.Write('$');
writer1.Write(num1);
writer1.Write((uint) (9 + (this.iChapOff.Length * 4)));
int[] numArray3 = this.iChapOff;
int num8 = 0;
while (num8 < numArray3.Length)
{
int num2 = numArray3[num8];
writer1.Write(num2);
num8++;
}
num1 = (uint) (0x4000 + random1.Next(0xfff));
writer1.Write('#');
writer1.Write((short) 0x84);
writer1.Write((byte) 1);
writer1.Write((byte) 9);
writer1.Write(num1);
int num3 = 0;
foreach (object obj1 in this.iChapStr)
{
num3 += ((((string) obj1).Length * 2) + 1);
}
writer1.Write('$');
writer1.Write(num1);
writer1.Write((uint) (9 + num3));
foreach (object obj2 in this.iChapStr)
{
writer1.Write((byte) (((string) obj2).Length * 2));
writer1.Write(Encoding.Unicode.GetBytes((string) obj2));
}
int num4 = 0;
int num5 = 0;
uint[] numArray1 = new uint[this.iZippedSeg.Length];
if (this.iZippedSeg.Length > 1)
{
num4 = random1.Next(0, this.iZippedSeg.Length - 1);
num5 = random1.Next(0, this.iZippedSeg.Length - 1);
}
for (int num6 = 0; num6 < this.iZippedSeg.Length; num6++)
{
numArray1[num6] = (uint) (random1.Next(1, 0xfffffff) * -1);
writer1.Write('$');
writer1.Write(numArray1[num6]);
writer1.Write((uint) (9 + this.iZippedSeg[num6].Length));
writer1.Write(this.iZippedSeg[num6]);
if (num6 == num4)
{
writer1.Write('#');
writer1.Write((short) 0xf1);
writer1.Write((byte) 0);
writer1.Write((byte) 0x15);
writer1.Write(Encoding.ASCII.GetBytes("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"));
}
if (num6 == num5)
{
writer1.Write('#');
writer1.Write((short) 10);
writer1.Write((byte) 0);
writer1.Write((byte) 9);
writer1.Write(this.iCID);
}
}
num1 = (uint) (0x2000 + random1.Next(0xfff));
writer1.Write('#');
writer1.Write((short) 0x81);
writer1.Write((byte) 1);
writer1.Write((byte) 9);
writer1.Write(num1);
writer1.Write('$');
writer1.Write(num1);
writer1.Write((uint) (9 + (numArray1.Length * 4)));
uint[] numArray4 = numArray1;
for (num8 = 0; num8 < numArray4.Length; num8++)
{
uint num7 = numArray4[num8];
writer1.Write(num7);
}
if (File.Exists(this.iCoverFile))
{
FileStream stream2 = new FileStream(this.iCoverFile + ".tmp", FileMode.Open);
byte[] buffer1 = new byte[stream2.Length];
stream2.Read(buffer1, 0, (int) stream2.Length);
stream2.Close();
num1 = (uint) (0x1000 + random1.Next(0xfff));
writer1.Write('#');
writer1.Write((short) 130);
writer1.Write((byte) 1);
writer1.Write((byte) 10);
writer1.Write((byte) 1);
writer1.Write(num1);
writer1.Write('$');
writer1.Write(num1);
writer1.Write((uint) (9 + buffer1.Length));
writer1.Write(buffer1);
}
pbar.Maximum = this.iContent.Length * 5;
pbar.Value = 0;
this.GetPageOffsetS60(0x10, this.ACTUAL_WIDTH_S60_HORI, ref pbar, out numArray2);
this.WritePageOffset(0x10, (byte) (this.ACTUAL_WIDTH_S60_HORI + 4), ref numArray2, ref writer1, 1);
numArray2.Initialize();
this.GetPageOffsetS60(0x10, this.ACTUAL_WIDTH_S60_VERT, ref pbar, out numArray2);
this.WritePageOffset(0x10, (byte) (this.ACTUAL_WIDTH_S60_VERT + 4), ref numArray2, ref writer1, 1);
numArray2.Initialize();
this.GetPageOffsetS60(12, this.ACTUAL_WIDTH_S60_HORI, ref pbar, out numArray2);
this.WritePageOffset(12, (byte) (this.ACTUAL_WIDTH_S60_HORI + 4), ref numArray2, ref writer1, 1);
numArray2.Initialize();
this.GetPageOffsetS60(12, this.ACTUAL_WIDTH_S60_VERT, ref pbar, out numArray2);
this.WritePageOffset(12, (byte) (this.ACTUAL_WIDTH_S60_VERT + 4), ref numArray2, ref writer1, 1);
numArray2.Initialize();
this.GetPageOffsetSP(10, this.ACTUAL_WIDTH_SP, ref pbar, out numArray2);
this.WritePageOffset(10, this.ACTUAL_WIDTH_SP, ref numArray2, ref writer1, 5);
writer1.Write('#');
writer1.Write((short) 12);
writer1.Write((byte) 1);
writer1.Write((byte) 9);
writer1.Write((uint) (((uint) writer1.BaseStream.Position) + 4));
writer1.Close();
stream1.Close();
result = "true";
return true;
}
private void ParseOnePage(uint pPageNumber, byte pFontSize, uint pScreenWidth, ref ArrayList pPageoff, byte PID)
{
if (pPageNumber < pPageoff.Count)
{
string text1 = "";
int num1 = 0;
uint num2 = (uint) pPageoff[(int) pPageNumber];
ArrayList list1 = new ArrayList();
byte num3 = 0;
if (PID == 1)
{
num3 = 50;
}
if (PID == 5)
{
num3 = 0x19;
}
for (byte num4 = 0; num4 < num3; num4 = (byte) (num4 + 1))
{
text1 = text1.Remove(0, text1.Length);
string text2 = "";
byte num5 = 0;
Label_0061:
if (num2 < this.iContent.Length)
{
text2 = this.iContent.Substring((int) num2, 1);
}
else
{
text2 = "\0";
}
if ((text2 == "\t") || (text2 == "\0"))
{
text2 = "\u3000";
}
byte num6 = this.CharWidth_S60(text2, pFontSize);
if (text2 == "\u2029")
{
num6 = 0;
}
if ((num6 + num5) <= pScreenWidth)
{
num5 = (byte) (num5 + num6);
num2 += 1;
if (text2 != "\u2029")
{
text1 = text1 + text2;
goto Label_0061;
}
}
if (text2 != "\u2029")
{
list1.Add(text1.Length);
}
else
{
list1.Add(text1.Length + 1);
}
num1 += ((int) list1[num4]);
if (num4 == ((byte) (num3 - 1)))
{
if ((num2 < this.iContent.Length) && (num2 > ((uint) pPageoff[pPageoff.Count - 1])))
{
pPageoff.Add(((uint) pPageoff[pPageoff.Count - 1]) + ((uint) num1));
}
if (num2 >= this.iContent.Length)
{
pPageoff.Add((uint) this.iContent.Length);
}
}
}
}
}
private void Prepare()
{
Random random1 = new Random();
this.iPGKSeed = (short) (random1.Next(0x401, 0x7fff) % 0xffff);
this.iTotalen = 0;
for (int num1 = 0; num1 < this.iChapter.Count; num1++)
{
this.iChapter[num1] = ((string) this.iChapter[num1]).Replace("\r\n", "\u2029");
this.iContent = this.iContent + ((string) this.iChapter[num1]);
this.iChapOff[num1] = this.iTotalen;
this.iTotalen += (((string) this.iChapter[num1]).Length * 2);
}
this.ibContent = new byte[this.iTotalen];
int num2 = 0;
for (int num3 = 0; num3 < this.iChapter.Count; num3++)
{
byte[] buffer1 = new byte[((string) this.iChapter[num3]).Length * 2];
buffer1 = Encoding.Unicode.GetBytes((string) this.iChapter[num3]);
buffer1.CopyTo(this.ibContent, num2);
num2 += buffer1.Length;
}
int num4 = 0;
if ((this.iTotalen % 0x8000) == 0)
{
num4 = this.iTotalen / 0x8000;
}
else
{
num4 = (this.iTotalen / 0x8000) + 1;
}
this.iZippedSeg = new byte[num4][];
byte[] buffer2 = new byte[0x8000];
int num5 = 0;
int num6 = 0;
for (int num7 = 0; num7 < this.ibContent.Length; num7++)
{
buffer2[num5] = this.ibContent[num7];
if ((num5 == 0x7fff) || (num7 == (this.ibContent.Length - 1)))
{
byte[] buffer3 = new byte[0x8000];
num5 = 0;
Deflater deflater1 = new Deflater(Deflater.BEST_COMPRESSION, false);
if (deflater1.IsNeedingInput)
{
deflater1.SetInput(buffer2, 0, buffer2.Length);
}
deflater1.Finish();
deflater1.Deflate(buffer3);
this.iZippedSeg[num6] = new byte[deflater1.TotalOut];
Deflater deflater2 = new Deflater(Deflater.BEST_COMPRESSION, false);
if (deflater2.IsNeedingInput)
{
deflater2.SetInput(buffer2, 0, buffer2.Length);
}
deflater2.Finish();
deflater2.Deflate(this.iZippedSeg[num6]);
num6++;
buffer2 = Encoding.Unicode.GetBytes("");
buffer2 = new byte[0x8000];
}
else
{
num5++;
}
}
}
private void WritePageOffset(byte fontSize, byte screenWidth, ref uint[] data, ref BinaryWriter writer, byte PID)
{
Random random1 = new Random();
uint num1 = (uint) (0x7000 + random1.Next(0xfff));
writer.Write('#');
writer.Write((short) 0x87);
writer.Write(PID);
writer.Write((byte) 11);
writer.Write(fontSize);
writer.Write(screenWidth);
writer.Write(num1);
writer.Write('$');
writer.Write(num1);
writer.Write((uint) (9 + (data.Length * 4)));
uint[] numArray1 = data;
for (int num3 = 0; num3 < numArray1.Length; num3++)
{
uint num2 = numArray1[num3];
writer.Write(num2);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -