Skip to content

Commit

Permalink
Maintenance: remove debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
uxmal committed Aug 3, 2023
1 parent a8c2707 commit 2ef2e88
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions src/Environments/C64/PrgLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,54 +49,6 @@ public override Program LoadProgram(Address? addrLoad)
ushort preferredAddress = ByteMemoryArea.ReadLeUInt16(RawImage, 0);
ushort alignedAddress = (ushort) (preferredAddress & ~0xF);
int pad = preferredAddress - alignedAddress;
#if NOT_OLD
while (pad-- > 0)
stm.WriteByte(0);
stm.Write(RawImage, 2, RawImage.Length - 2);
var loadedBytes = stm.ToArray();
var image = new ByteMemoryArea(
Address.Ptr16(alignedAddress),
loadedBytes);
var rdr = new C64BasicReader(image, 0x0801);
var lines = rdr.ToSortedList(line => line.LineNumber, line => line);
var cfgSvc = Services.RequireService<IConfigurationService>();
var arch = new C64Basic(Services, lines);
var platform = cfgSvc.GetEnvironment("c64").Load(Services, arch);
var arch6502 = cfgSvc.GetArchitecture("m6502")!;
SegmentMap segMap = CreateSegmentMap(platform, image, lines);
var program = new Program(segMap, arch, platform);
program.Architectures.Add(arch6502.Name, arch6502);
var addrBasic = lines.Values[0].Address;
var sym = ImageSymbol.Procedure(arch, addrBasic, state: arch.CreateProcessorState());
program.EntryPoints.Add(sym.Address, sym);
AddLineNumberSymbols(lines, program);
return program;
}

private void AddLineNumberSymbols(SortedList<ushort, C64BasicInstruction> lines, Program program)
{
foreach (var line in lines.Values)
{
var sym = ImageSymbol.Location(program.Architecture, line.Address);
sym.Name = $"L{line.LineNumber}";
program.ImageSymbols.Add(line.Address, sym);
}
}

private SegmentMap CreateSegmentMap(IPlatform platform, ByteMemoryArea bmem, IDictionary<ushort, C64BasicInstruction> lines)
{
var segMap = platform.CreateAbsoluteMemoryMap()!;
Address addrStart = bmem.BaseAddress;
if (lines.Count > 0)
{
segMap.AddSegment(new ImageSegment("basic", bmem.BaseAddress, bmem, AccessMode.ReadExecute));
var lastLine = lines.Values.OrderByDescending(l => l.Address).First();
addrStart = lastLine.Address + lastLine.Line.Length;
}
segMap.AddSegment(new ImageSegment("code", addrStart, bmem, AccessMode.ReadWriteExecute));
return segMap;
}
#else
var c64Ram = new ByteMemoryArea(
Address.Ptr16(0),
new byte[0x10000]);
Expand Down Expand Up @@ -143,6 +95,5 @@ private SegmentMap CreateSegmentMap(
segMap.AddSegment(new ImageSegment("code", addrStart, c64Ram, AccessMode.ReadWriteExecute));
return segMap;
}
#endif
}
}

0 comments on commit 2ef2e88

Please sign in to comment.