From 261dbc4bf27f839adb56961e9cf124fbf37891de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Engstr=C3=B6m?= Date: Mon, 7 Aug 2023 16:51:40 +0200 Subject: [PATCH] Update to .NET 8 --- .github/workflows/main.yml | 2 +- Platforms/ZXBox.Blazor/Hardware/Keyboard.cs | 2 +- Platforms/ZXBox.Blazor/ZXBox.Blazor.csproj | 2 +- Platforms/ZXBox.Blazor/wwwroot/index.html | 8 - .../FileFormats/TapFileFormatTests.cs | 9 + ZXBox.Core.Tests/ZXBox.Core.Tests.csproj | 2 +- .../Cpus/Z80/Z80NOPrefixInstructions.cs | 262 +++++++++--------- ZXBox.Core/Hardware/Input/TapePlayer.cs | 4 +- ZXBox.Core/ZXBox.Core.csproj | 2 +- 9 files changed, 152 insertions(+), 141 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e8614a..c901169 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/setup-dotnet@v1 with: - dotnet-version: '7.0.x' + dotnet-version: '8.0.x' include-prerelease: true - name: Install tools diff --git a/Platforms/ZXBox.Blazor/Hardware/Keyboard.cs b/Platforms/ZXBox.Blazor/Hardware/Keyboard.cs index 0c5dab6..56f521d 100644 --- a/Platforms/ZXBox.Blazor/Hardware/Keyboard.cs +++ b/Platforms/ZXBox.Blazor/Hardware/Keyboard.cs @@ -110,7 +110,7 @@ public int Input(int Port, int tstates) if (GetKeyStatus("t")) returnvalue &= ~16; break; - case 0x07: //1, 2, 3, 4, 5n + case 0x07: //1, 2, 3, 4, 5 //if (ks.IsKeyDown(Keys.D1) || IsNextKey(Keys.D1) || (JoystickType == JoystickTypeEnum.Sinclair1 && (State.DPad.Left == ButtonState.Pressed || ks.IsKeyDown(Keys.Left)))) if (GetKeyStatus("1")) returnvalue &= ~1; diff --git a/Platforms/ZXBox.Blazor/ZXBox.Blazor.csproj b/Platforms/ZXBox.Blazor/ZXBox.Blazor.csproj index f514456..e7ec0bd 100644 --- a/Platforms/ZXBox.Blazor/ZXBox.Blazor.csproj +++ b/Platforms/ZXBox.Blazor/ZXBox.Blazor.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 true diff --git a/Platforms/ZXBox.Blazor/wwwroot/index.html b/Platforms/ZXBox.Blazor/wwwroot/index.html index 81b5491..390f7ca 100644 --- a/Platforms/ZXBox.Blazor/wwwroot/index.html +++ b/Platforms/ZXBox.Blazor/wwwroot/index.html @@ -34,9 +34,6 @@ let source = audiocontext.createBufferSource(); source.buffer = myArrayBuffer; - //source.connect(gainNode); - - gainNode.connect(audiocontext.destination); source.connect(gainNode); if (nextStartTime == 0) nextStartTime = audiocontext.currentTime + (myArrayBuffer.length / myArrayBuffer.sampleRate); @@ -127,15 +124,12 @@ //console.log(pressedKeys); } window.onkeydown = function (e) { - - var key = GetKey(e.keyCode); const index = pressedKeys.indexOf(key); if (index == -1) { pressedKeys.push(key); } event.preventDefault(); - //console.log(pressedKeys); } window.getKeyStatus = function () { @@ -161,8 +155,6 @@ imageData.data.set(Uint8ClampedArray.from(Module.HEAPU8.subarray(dataPtr, dataPtr + imageData.data.length))); context.putImageData(imageData, 0, 0); context.drawImage(canvas, 0, 0, canvas.width, canvas.height); - //console.log((performance.now() - lastcall).toFixed(2)); - lastcall = performance.now(); return true; } diff --git a/ZXBox.Core.Tests/FileFormats/TapFileFormatTests.cs b/ZXBox.Core.Tests/FileFormats/TapFileFormatTests.cs index b91f326..994e10d 100644 --- a/ZXBox.Core.Tests/FileFormats/TapFileFormatTests.cs +++ b/ZXBox.Core.Tests/FileFormats/TapFileFormatTests.cs @@ -17,7 +17,16 @@ public void LoadTapFileTest() Assert.AreEqual(tf.Blocks.Count, 2); } + [TestMethod] + public void LoadSentinelTapFileTest() + { + var filename = @"C:\Users\Jimmy\Downloads\SentinelThe.tap\SENTINEL.TAP"; + var tf = new TapFormat(); + var bytes = File.ReadAllBytes(filename); + tf.ReadFile(bytes); + Assert.AreEqual(tf.Blocks.Count, 2); + } [TestMethod] public void DecodeTapFileTest() { diff --git a/ZXBox.Core.Tests/ZXBox.Core.Tests.csproj b/ZXBox.Core.Tests/ZXBox.Core.Tests.csproj index 97af445..e0adb82 100644 --- a/ZXBox.Core.Tests/ZXBox.Core.Tests.csproj +++ b/ZXBox.Core.Tests/ZXBox.Core.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 false diff --git a/ZXBox.Core/Cpus/Z80/Z80NOPrefixInstructions.cs b/ZXBox.Core/Cpus/Z80/Z80NOPrefixInstructions.cs index ad1ca93..aa8c401 100644 --- a/ZXBox.Core/Cpus/Z80/Z80NOPrefixInstructions.cs +++ b/ZXBox.Core/Cpus/Z80/Z80NOPrefixInstructions.cs @@ -302,20 +302,30 @@ public void DoNoPrefixInstruction() A = ReadByteFromMemory(GetNextPCWord()); SubtractNumberOfTStatesLeft(13); break; - case 0x7F: //LD A,A - case 0x78: //LD A,B - case 0x79: //LD A,C - case 0x7A: //LD A,D - case 0x7B: //LD A,E - A = RegisterValueFromOP(0); - SubtractNumberOfTStatesLeft(4); - break; - case 0x7C: //LD A,H - A = H; - SubtractNumberOfTStatesLeft(4); - break; - case 0x7D: //LD A,L - A = L; + //case 0x7F: //LD A,A + //case 0x78: //LD A,B + //case 0x79: //LD A,C + //case 0x7A: //LD A,D + //case 0x7B: //LD A,E + // A = RegisterValueFromOP(0); + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x7C: //LD A,H + // A = H; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x7D: //LD A,L + // A = L; + // SubtractNumberOfTStatesLeft(4); + // break; + case >= 0x78 and <= 0x7D or 0x7F: //LD A,r + case >= 0x40 and <= 0x43 or 0x47: //LD B,r + case >= 0x48 and <= 0x4D or 0x4F: //LD C,r + case >= 0x50 and <= 0x55 or 0x57: //LD D,r + case >= 0x58 and <= 0x5D or 0x5F: //LD E,r + case >= 0x60 and <= 0x65 or 0x67: //LD H,r + case >= 0x68 and <= 0x6D or 0x6F: //LD L,r + Registers[BitValueFromOP] = RegisterValueFromOP(0); SubtractNumberOfTStatesLeft(4); break; case 0x3E: //LD A,n @@ -326,14 +336,14 @@ public void DoNoPrefixInstruction() B = ReadByteFromMemory(HL); SubtractNumberOfTStatesLeft(7); break; - case 0x47: //LD B,A - case 0x40: //LD B,B - case 0x41: //LD B,C - case 0x42: //LD B,D - case 0x43: //LD B,E - B = RegisterValueFromOP(0); - SubtractNumberOfTStatesLeft(4); - break; + //case 0x47: //LD B,A + //case 0x40: //LD B,B + //case 0x41: //LD B,C + //case 0x42: //LD B,D + //case 0x43: //LD B,E + // B = RegisterValueFromOP(0); + // SubtractNumberOfTStatesLeft(4); + // break; case 0x44: //LD B,H B = H; SubtractNumberOfTStatesLeft(4); @@ -354,22 +364,22 @@ public void DoNoPrefixInstruction() C = ReadByteFromMemory(HL); SubtractNumberOfTStatesLeft(7); break; - case 0x4F: //LD C,A - case 0x48: //LD C,B - case 0x49: //LD C,C - case 0x4A: //LD C,D - case 0x4B: //LD C,E - C = RegisterValueFromOP(0); - SubtractNumberOfTStatesLeft(4); - break; - case 0x4C: //LD C,H - C = H; - SubtractNumberOfTStatesLeft(4); - break; - case 0x4D://LD C,L - C = L; - SubtractNumberOfTStatesLeft(4); - break; + //case 0x4F: //LD C,A + //case 0x48: //LD C,B + //case 0x49: //LD C,C + //case 0x4A: //LD C,D + //case 0x4B: //LD C,E + // C = RegisterValueFromOP(0); + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x4C: //LD C,H + // C = H; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x4D://LD C,L + // C = L; + // SubtractNumberOfTStatesLeft(4); + // break; case 0x0E: //LD C,n C = GetNextPCByte(); SubtractNumberOfTStatesLeft(7); @@ -378,22 +388,22 @@ public void DoNoPrefixInstruction() D = ReadByteFromMemory(HL); SubtractNumberOfTStatesLeft(7); break; - case 0x57: //LD D,A - case 0x50: //LD D,B - case 0x51: //LD D,C - case 0x52: //LD D,D - case 0x53: //LD D,E - D = RegisterValueFromOP(0); - SubtractNumberOfTStatesLeft(4); - break; - case 0x54: //LD D,H - D = H; - SubtractNumberOfTStatesLeft(4); - break; - case 0x55: //LD D,L - D = L; - SubtractNumberOfTStatesLeft(4); - break; + //case 0x57: //LD D,A + //case 0x50: //LD D,B + //case 0x51: //LD D,C + //case 0x52: //LD D,D + //case 0x53: //LD D,E + // D = RegisterValueFromOP(0); + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x54: //LD D,H + // D = H; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x55: //LD D,L + // D = L; + // SubtractNumberOfTStatesLeft(4); + // break; case 0x16: //LD D,n D = GetNextPCByte(); SubtractNumberOfTStatesLeft(7); @@ -406,22 +416,22 @@ public void DoNoPrefixInstruction() E = ReadByteFromMemory(HL); SubtractNumberOfTStatesLeft(7); break; - case 0x5F: //LD E,A - case 0x58: //LD E,B - case 0x59: //LD E,C - case 0x5A: //LD E,D - case 0x5B: //LD E,E - E = RegisterValueFromOP(0); - SubtractNumberOfTStatesLeft(4); - break; - case 0x5C: //LD E,H - E = H; - SubtractNumberOfTStatesLeft(4); - break; - case 0x5D://LD E,L - E = L; - SubtractNumberOfTStatesLeft(4); - break; + //case 0x5F: //LD E,A + //case 0x58: //LD E,B + //case 0x59: //LD E,C + //case 0x5A: //LD E,D + //case 0x5B: //LD E,E + // E = RegisterValueFromOP(0); + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x5C: //LD E,H + // E = H; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x5D://LD E,L + // E = L; + // SubtractNumberOfTStatesLeft(4); + // break; case 0x1E: //LD E,n E = GetNextPCByte(); SubtractNumberOfTStatesLeft(7); @@ -430,34 +440,34 @@ public void DoNoPrefixInstruction() H = ReadByteFromMemory(HL); SubtractNumberOfTStatesLeft(7); break; - case 0x67: //LD H,A - H = A; - SubtractNumberOfTStatesLeft(4); - break; - case 0x60: //LD H,B - H = B; - SubtractNumberOfTStatesLeft(4); - break; - case 0x61: //LD H,C - H = C; - SubtractNumberOfTStatesLeft(4); - break; - case 0x62: //LD H,D - H = D; - SubtractNumberOfTStatesLeft(4); - break; - case 0x63: //LD H,E - H = E; - SubtractNumberOfTStatesLeft(4); - break; - case 0x64: //LD H,H - H = H; - SubtractNumberOfTStatesLeft(4); - break; - case 0x65://LD H,L - H = L; - SubtractNumberOfTStatesLeft(4); - break; + //case 0x67: //LD H,A + // H = A; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x60: //LD H,B + // H = B; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x61: //LD H,C + // H = C; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x62: //LD H,D + // H = D; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x63: //LD H,E + // H = E; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x64: //LD H,H + // H = H; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x65://LD H,L + // H = L; + // SubtractNumberOfTStatesLeft(4); + // break; case 0x26: //LD H,n H = GetNextPCByte(); SubtractNumberOfTStatesLeft(7); @@ -466,34 +476,34 @@ public void DoNoPrefixInstruction() L = ReadByteFromMemory(HL); SubtractNumberOfTStatesLeft(7); break; - case 0x6F://LD L,A - L = A; - SubtractNumberOfTStatesLeft(4); - break; - case 0x68: //LD L,B - L = B; - SubtractNumberOfTStatesLeft(4); - break; - case 0x69: //LD L,C - L = C; - SubtractNumberOfTStatesLeft(4); - break; - case 0x6A: //LD L,D - L = D; - SubtractNumberOfTStatesLeft(4); - break; - case 0x6B: //LD L,E - L = E; - SubtractNumberOfTStatesLeft(4); - break; - case 0x6C: //LD L,H - L = H; - SubtractNumberOfTStatesLeft(4); - break; - case 0x6D://LD L,L - L = L; - SubtractNumberOfTStatesLeft(4); - break; + //case 0x6F://LD L,A + // L = A; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x68: //LD L,B + // L = B; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x69: //LD L,C + // L = C; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x6A: //LD L,D + // L = D; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x6B: //LD L,E + // L = E; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x6C: //LD L,H + // L = H; + // SubtractNumberOfTStatesLeft(4); + // break; + //case 0x6D://LD L,L + // L = L; + // SubtractNumberOfTStatesLeft(4); + // break; case 0x2E: //LD L ,n L = GetNextPCByte(); SubtractNumberOfTStatesLeft(7); diff --git a/ZXBox.Core/Hardware/Input/TapePlayer.cs b/ZXBox.Core/Hardware/Input/TapePlayer.cs index 725b5ab..109b60c 100644 --- a/ZXBox.Core/Hardware/Input/TapePlayer.cs +++ b/ZXBox.Core/Hardware/Input/TapePlayer.cs @@ -7,7 +7,7 @@ namespace ZXBox.Core.Hardware.Input { /// - ///A leader consisting of 8063 (for header blocks) or 3223 (data blocks) pulses, each of which has a duration of 2168 tstates. + ///A Pilot consisting of 8063 (for header blocks) or 3223 (data blocks) pulses, each of which has a duration of 2168 tstates. ///A first sync pulse of 667 tstates. ///A second sync pulse of 735 tstates. ///The block data: a reset bit is encoded as two pulses of 855 tstates each, a set bit as two pulses of 1710 tstates each.The lowest byte in memory is first on tape, with the most significant bit first within each byte. @@ -66,7 +66,7 @@ public void LoadTape(byte[] data) } } ear = !ear; - tstate += 3500; + tstate += 3500 * 5; //5ms EarValues.Add(new() { Ear = ear, TState = tstate, Pulse = PulseTypeEnum.Pause }); //Pause ear = false; diff --git a/ZXBox.Core/ZXBox.Core.csproj b/ZXBox.Core/ZXBox.Core.csproj index d237d06..cf9c3f2 100644 --- a/ZXBox.Core/ZXBox.Core.csproj +++ b/ZXBox.Core/ZXBox.Core.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0