Exemple #1
0
        void LoadLevelCombobox()
        {
            //init combobox
            levelComboBox.SelectedItem = null;
            levelComboBox.Items.Clear();

            //convert course id => course no using data in ROM
            rom.SetBank(0);
            List<ComboboxItem> items = new List<ComboboxItem>();
            for(int i = 0 ; i <= 0x2A ; i++)
            {
                int levelpointer = rom.ReadWord(0x0534 + i * 2);
                int courseNo = (levelpointer - 0x0587) / 3;
                ComboboxItem item = new ComboboxItem(string.Format("Course {0:D2}", courseNo), i);
                items.Add(item);
            }

            items = items.OrderBy(x => x.Text).ToList();
            string oldItem = null;
            foreach(var item in items)
            {
                if(oldItem != null && item.Text == oldItem)
                {
                    item.Text += " (revisited)";
                }
                oldItem = item.Text;
            }

            levelComboBox.Items.AddRange(items.ToArray());
        }