private void ApplyTrainers() { for (int f = 0; f < TrainerList.Count; f++) { Trainer trainer = TrainerList[f]; bool applyPokes = (pokesListBox.GetItemCheckState(f) == CheckState.Checked); for (int g = 0; g < trainer.pokeList.Count; g++) { Pokes p = trainer.pokeList[g]; if (applyPokes && (p.newVal > 255)) { inputDialog.Title = trainer.name; inputDialog.ShowDialog(); p.newVal = inputDialog.PokeValue; } if (p.bank == 8) //48k { //Remove poke only if old value is a non-zero value if (!applyPokes && (p.oldVal == 0)) { continue; } ziggyWin.zx.PokeByteNoContend(p.address, (applyPokes ? p.newVal : p.oldVal)); } else { //Remove poke only if old value is a non-zero value if (!applyPokes && (p.oldVal == 0)) { continue; } // ziggyWin.zx.PokeBank(p.bank * 2 + (p.address >> 14), p.address % 16384, (applyPokes ? p.newVal : p.oldVal)); ziggyWin.zx.PokeByteNoContend(p.address, (applyPokes ? p.newVal : p.oldVal)); } } } }
public void LoadTrainer(string filename) { pokesListBox.Items.Clear(); TrainerList.Clear(); using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open)) { System.IO.StreamReader sr = new System.IO.StreamReader(fs); string line; char[] delimiters = new char[] { '\r', '\n', ' ' }; do { line = sr.ReadLine(); if (line[0] == 'N') { Trainer trainer = new Trainer(); trainer.name = line.Substring(1, line.Length - 1); string[] fields; do { Pokes poke = new Pokes(); line = sr.ReadLine(); fields = line.Split(delimiters, System.StringSplitOptions.RemoveEmptyEntries); poke.bank = System.Convert.ToByte(fields[1]); poke.address = System.Convert.ToInt32(fields[2]); poke.newVal = System.Convert.ToInt32(fields[3]); poke.oldVal = System.Convert.ToInt32(fields[4]); trainer.pokeList.Add(poke); } while (fields[0] != "Z"); pokesListBox.Items.Add(trainer.name); TrainerList.Add(trainer); } } while (line[0] != 'Y'); } }