Exemple #1
0
        public static byte[] Assemble(string code)
        {
            var sections = SplitSections(code);

            var ri = SectionMetadata.GetRomInfo(sections["metadata"]);

            Dictionary <string, ushort> constants;

            byte[] dataDeclaresAssembled;
            var    dataDeclares = SectionData.GetSectionData(sections["data"], out constants, out dataDeclaresAssembled);

            var dataReserved = SectionBss.GetSectionBss(sections["bss"]);

            var dataJoined = dataDeclares.Concat(dataReserved).ToDictionary();

            int offset = 0x150 + dataDeclaresAssembled.Length;

            byte[] offsetBytes = BitConverter.GetBytes((ushort)offset);

            // Startcode = nop, jp [offset]
            byte[] startCode = new byte[] { 0, 195, offsetBytes[0], offsetBytes[1] };

            var dataCode = SectionCode.AssembleCode(sections, offset, constants, dataJoined);

            // BUG: No interrupt table
            var rom = RomBuilder.BuildRom(ri,
                                          RomBuilder.BuildJumptable(dataCode["rst00"], dataCode["rst08"], dataCode["rst10"], dataCode["rst18"], dataCode["rst20"], dataCode["rst28"], dataCode["rst30"], dataCode["rst38"]),
                                          RomBuilder.BuildInterruptTable(new byte[0], new byte[0], new byte[0], new byte[0], new byte[0]),
                                          RomBuilder.BuildHeader(ri, startCode),
                                          RomBuilder.BuildCode(dataDeclaresAssembled, dataCode["text"])
                                          );

            return(rom);
        }
 public void BookASeat(SeatNumber seat, RowNumber row, SectionCode section, Person person)
 {
     if (!_sections.ContainsKey(section))
     {
         throw new InvalidOperationException($"There is no Section {section} on a stadium {Id}.");
     }
     _sections[section].BookASeat(row, seat, person);
 }
 public void AddARow(Row row, SectionCode sectionCode)
 {
     _sections.TryGetValue(sectionCode, out var section);
     if (section != null)
     {
         section.AddARow(row);
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
 public void AddASeat(Seat seat, RowNumber rowNumber, SectionCode sectionCode)
 {
     _sections.TryGetValue(sectionCode, out var section);
     if (section != null)
     {
         section.AddASeat(rowNumber, seat);
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Exemple #5
0
 /// <summary>
 /// Indicates whether this instance section code is equal to a specified section code.
 /// </summary>
 /// <param name="sectionCode">A section code.</param>
 /// <returns><c>true</c> if this instance section is the same as the parameter, <c>false</c> otherwise.</returns>
 public bool Is(SectionCode sectionCode) => SectionCode == (int)sectionCode;
Exemple #6
0
 /// <summary>
 /// Initialize a new instance.
 /// </summary>
 /// <param name="length">Section length.</param>
 /// <param name="sectionCode">Section code.</param>
 public SectionInfo(long length, SectionCode sectionCode) : this(length, (int)sectionCode)
 {
 }
 public Section(SectionCode sectionId, Row[] rows)
 {
     SectionId = sectionId;
     _rows     = rows.ToDictionary(r => r.RowId);
 }
Exemple #8
0
 /// <summary>
 /// Creates an unknown section from the given section name and payload.
 /// </summary>
 /// <param name="Name">The unknown section's name.</param>
 /// <param name="Payload">The unknown section's payload.</param>
 public UnknownSection(SectionCode Code, byte[] Payload)
 {
     this.Code    = Code;
     this.Payload = Payload;
 }