Can somewhat load from audio
This commit is contained in:
@@ -1352,6 +1352,10 @@ namespace Core.Cpu
|
||||
case 0x4D: // RETI Does not affect IFF1 or IFF2
|
||||
PC = Pop();
|
||||
return 14;
|
||||
case 0x51: // OUT (C), D
|
||||
// BC.Word goes to the address bus, D (DE.High) goes to the data bus
|
||||
_simpleIoBus.WritePort(BC.Word, DE.High);
|
||||
return 12; // 2 M-cycles, 12 T-States
|
||||
case 0x53: // LD (nn), DE
|
||||
ushort dest53 = FetchWord();
|
||||
WriteMemory(dest53, DE.Low);
|
||||
@@ -1372,6 +1376,10 @@ namespace Core.Cpu
|
||||
|
||||
AF.Low = flags58;
|
||||
return 12;
|
||||
case 0x59: // OUT (C), E
|
||||
// BC.Word goes to the address bus, E (DE.Low) goes to the data bus
|
||||
_simpleIoBus.WritePort(BC.Word, DE.Low);
|
||||
return 12; // 2 M-cycles, 12 T-States
|
||||
case 0x5B: // LD DE, (nn)
|
||||
ushort src5B = FetchWord();
|
||||
DE.Low = ReadMemory(src5B);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Core.Io
|
||||
public byte ReadPort(ushort portAddress)
|
||||
{
|
||||
// The Spectrum ULA responds to any even port address (where the lowest bit is 0)
|
||||
if ((portAddress & 0x01) == 0)
|
||||
if ((portAddress & 0x01) == 0) //Port 0xFE)
|
||||
{
|
||||
byte highByte = (byte)(portAddress >> 8); // The B register!
|
||||
byte result = 0xFF; // Start assuming no keys are pressed
|
||||
@@ -40,11 +40,17 @@ namespace Core.Io
|
||||
|
||||
//return result;
|
||||
// The top 3 bits (5, 6, 7) are unused by the keyboard and usually return 1 on a real Spectrum
|
||||
return (byte)(result | 0xE0);
|
||||
return (byte)(result | 0xA0);
|
||||
}
|
||||
|
||||
// Kempston Joystick Port
|
||||
if ((portAddress & 0xFF) == 0x1F)
|
||||
{
|
||||
return 0x00; // 0x00 means no joystick connected/no buttons pressed
|
||||
}
|
||||
|
||||
// Return 0xFF for unhandled ports
|
||||
return 0xFF;
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
public void WritePort(ushort portAddress, byte portValue)
|
||||
|
||||
@@ -46,6 +46,11 @@ namespace Core.Io
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_state = TapeState.Idle;
|
||||
}
|
||||
|
||||
private void LoadNextBlock()
|
||||
{
|
||||
if (_blocks.Count == 0)
|
||||
@@ -142,7 +147,8 @@ namespace Core.Io
|
||||
break;
|
||||
|
||||
case TapeState.Pause:
|
||||
LoadNextBlock();
|
||||
_state = TapeState.Idle;
|
||||
//LoadNextBlock();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -157,54 +163,28 @@ namespace Core.Io
|
||||
}
|
||||
|
||||
// --- FAST LOAD METHODS (For ROM Hijack) ---
|
||||
//public byte[] GetNextBlock()
|
||||
//{
|
||||
// return _blocks.Count > 0 ? _blocks.Dequeue() : null;
|
||||
//}
|
||||
|
||||
//public bool HasBlocks => _blocks.Count > 0;
|
||||
// Change this line:
|
||||
public bool HasBlocks => _blocks.Count > 0 || _currentBlock != null;
|
||||
|
||||
public byte[] GetNextBlock()
|
||||
{
|
||||
// If a block is loaded into the tape deck, yank it immediately
|
||||
if (_currentBlock != null)
|
||||
{
|
||||
byte[] blockToReturn = _currentBlock;
|
||||
_state = TapeState.Idle; // Ensure the tape deck is stopped
|
||||
_currentBlock = null;
|
||||
return blockToReturn;
|
||||
}
|
||||
|
||||
// Otherwise, pull directly from the queue
|
||||
return _blocks.Count > 0 ? _blocks.Dequeue() : null;
|
||||
}
|
||||
|
||||
public bool HasBlocks => _blocks.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//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