public void loadCatridge(byte[] romFile) { #warning not properly done, doesnt manage catridge banks romData = new byte[romFile.Length]; Array.Copy(romFile, romData, romFile.Length); bool knownMBC = false; mbcByte = romData[0x147]; Console.WriteLine("MBC Type is: " + String.Format("#{0:X}", mbcByte)); switch (mbcByte) { case 0x00: //ROM ONLY knownMBC = true; mbc = MBC.ROMONLY; break; case 0x13: knownMBC = true; //MBC3+RAM+BATTERY mbc = MBC.MBC3; ram = true; battery = true; break; } if (!knownMBC) { throw new Exception("MBC Type is not known:" + String.Format("#{0:X}", mbcByte)); } switch (mbc) { case MBC.MBC1: break; case MBC.MBC2: break; case MBC.MBC3: Array.Copy(romData, 0, memoryRaw, 0, 0x4000); break; case MBC.ROMONLY: Array.Copy(romData, memoryRaw, romData.Length); break; } }
public MBC3(byte[] fileData, MBC romType, int romSize) { this.romType = romType; int bankSize = 0x4000; int romBanks = romSize / bankSize; rom = new byte[romBanks, bankSize]; this.ram = this.ReadSave(); for (int i = 0, k = 0; i < romBanks; i++) { for (int j = 0; j < bankSize; j++, k++) { rom[i, j] = fileData[k]; } } Console.WriteLine("DEBUG: Init OK"); }
public ROM(string path, string save = "") { byte[] data = File.ReadAllBytes(path); byte[] save_data; if (save != string.Empty) { save_data = File.ReadAllBytes(save); } Console.WriteLine("DEBUG: Loading ROM"); // Read ROM name for (int i = 0; i < 16; i++) { this.Title += (char)data[0x134 + i]; } Console.WriteLine(" ROMNAME={0}", this.Title); // Game does support CGB features? this.Cgb = data[0x143] == 0x80 || data[0x143] == 0xC0; // Is the cartridge CGB only? this.CgbOnly = data[0x143] == 0xC0; Console.WriteLine(" CGB_SUPPORT={0}", this.Cgb); Console.WriteLine(" CGB_ONLY={0}", this.Cgb); // Does the game support SGB features? this.SgbSupport = data[0x146] == 0x03; Console.WriteLine(" SGB_SUPPORT={0}", this.SgbSupport); // Cartridge Type this.CartridgeType = (MBC)data[0x147]; Console.WriteLine(" MBC={0}", this.CartridgeType); // ROM size this.RomSize = 32000 << data[0x148]; Console.WriteLine(" ROMSIZE={0}KB", this.RomSize / 1000); // RAM size switch (data[0x149]) { case 0x0: this.RamSize = 0; break; case 0x1: this.RamSize = 2048; break; case 0x2: this.RamSize = 8192; break; case 0x03: this.RamSize = 32768; break; } Console.WriteLine(" RAMSIZE={0}KB", this.RamSize / 1000); this.Japanese = data[0x14A] == 0x00; Console.WriteLine(" JAPANESE={0}", this.Japanese); // Init MBC Console.WriteLine("DEBUG: Initialize MBC"); switch (this.CartridgeType) { case MBC.ROM_MBC3_RAM: case MBC.ROM_MBC3_RAM_BATT: case MBC.ROM_MBC3_TIMER_BATT: case MBC.ROM_MBC3_TIMER_RAM_BATT: this.Memory = new MBC3(data, this.CartridgeType, this.RomSize); break; default: throw new Exception("Unsupported cartridge type " + this.CartridgeType); } }
private void buttonCalcular_Click(object sender, EventArgs e) { //variables pendeinte double MAB, MBC, MCA; double A2 = 0, B2 = 0, C2 = 0; double A = 0, B = 0, C = 0; //variables angulos double Angulo1, Angulo2, Angulo3; double tan1, tan2, tan3; double total; if (XAT.Text == "") { MessageBox.Show("Falta agregar el valor X(A)", "Alerta"); } if (XBT.Text == "") { MessageBox.Show("Falta agregar el valor X(B)", "Alerta"); } if (XCT.Text == "") { MessageBox.Show("Falta agregar el valor X(C)", "Alerta"); } if (YAT.Text == "") { MessageBox.Show("Falta agregar el valor Y(A)", "Alerta"); } if (YBT.Text == "") { MessageBox.Show("Falta agregar el valor Y(B)", "Alerta"); } if (YCT.Text == "") { MessageBox.Show("Falta agregar el valor Y(C)", "Alerta"); } //se comprube q sea numero y no otro caracter //leer puntos(X) try { A = Convert.ToDouble(XAT.Text); } catch (Exception) { MessageBox.Show("Escribe un numero en X(A)"); return; } //try X(B) try { B = Convert.ToDouble(XBT.Text); } catch (Exception) { MessageBox.Show("Escribe un numero en X(B)"); return; } //try X(C) try { C = Convert.ToDouble(XCT.Text); } catch (Exception) { MessageBox.Show("Escribe un numero en X(C)"); return; } //Leer puntos(Y) //TRY Y(A) try { A2 = Convert.ToDouble(YAT.Text); } catch (Exception) { MessageBox.Show("Escribe un numero en Y(A)"); return; } //TRY Y(B) try { B2 = Convert.ToDouble(YBT.Text); } catch (Exception) { MessageBox.Show("Escribe un numero en Y(B)"); return; } //TRY Y(C) try { C2 = Convert.ToDouble(YCT.Text); } catch (Exception) { MessageBox.Show("Escribe un numero en Y(C)"); return; } //pendiente listBox1.Items.Add("Pendiente PMAB"); MAB = (B2 - A2) / (B - A); listBox1.Items.Add(MAB.ToString()); listBox2.Items.Add("Pendiente MBC"); MBC = (C2 - B2) / (C - B); listBox2.Items.Add(MBC.ToString()); listBox3.Items.Add("Pendiente MCA"); MCA = (A2 - C2) / (A - C); listBox3.Items.Add(MCA.ToString()); //Angulos =1/match.tan(val(texbox)) Angulo1 = (MAB - MBC) / (1 + (MBC * MAB)); Angulo2 = (MBC - MCA) / (1 + (MCA * MBC)); Angulo3 = (MCA - MAB) / (1 + (MAB * MCA)); tan1 = Math.Atan(Angulo1) * 180 / Math.PI; tan2 = Math.Atan(Angulo2) * 180 / Math.PI; tan3 = Math.Atan(Angulo3) * 180 / Math.PI; listBox1.Items.Add(tan1.ToString()); listBox2.Items.Add(tan2.ToString()); listBox3.Items.Add(tan3.ToString()); total = tan1 + tan2 + tan3; this.textBox1.Text = total.ToString(); }