Added TAP file injection. Still incomplete.
This commit is contained in:
39
Core/Io/TapManager.cs
Normal file
39
Core/Io/TapManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Core.Io
|
||||
{
|
||||
public class TapManager
|
||||
{
|
||||
private Queue<byte[]> _blocks = new Queue<byte[]>();
|
||||
|
||||
|
||||
public void LoadTapData(byte[] fileData)
|
||||
{
|
||||
_blocks.Clear();
|
||||
int position = 0;
|
||||
|
||||
while (position < fileData.Length)
|
||||
{
|
||||
// 1. Read the 16-bit block length (Little Endian)
|
||||
int blockLength = fileData[position] | (fileData[position + 1] << 8);
|
||||
position += 2;
|
||||
|
||||
// 2. Extract the block payload
|
||||
byte[] blockData = new byte[blockLength];
|
||||
Array.Copy(fileData, position, blockData, 0, blockLength);
|
||||
position += blockLength;
|
||||
|
||||
// 3. Queue it up
|
||||
_blocks.Enqueue(blockData);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] GetNextBlock()
|
||||
{
|
||||
return _blocks.Count > 0 ? _blocks.Dequeue() : null;
|
||||
}
|
||||
|
||||
public bool HasBlocks => _blocks.Count > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user