-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from jsm174/branch-fixes
BGT opcode fix and CI cleanup
- Loading branch information
Showing
172 changed files
with
1,987 additions
and
1,000 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build | ||
on: [push, pull_request] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
name: Build ${{ matrix.rid }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: windows-latest | ||
rid: win-x64 | ||
- os: windows-latest | ||
rid: win-x86 | ||
- os: macos-latest | ||
rid: osx-x64 | ||
- os: ubuntu-latest | ||
rid: linux-x64 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '3.1.x' | ||
- name: Build | ||
run: | | ||
cd src/WPCEmu | ||
dotnet build WPCEmu.csproj -c Release -r ${{ matrix.rid }} | ||
- name: Test | ||
run: | | ||
cd src/WPCEmu.Test | ||
dotnet test WPCEmu.Test.csproj --runtime ${{ matrix.rid }} -v n | ||
dispatch: | ||
runs-on: ubuntu-latest | ||
needs: [ build ] | ||
if: github.repository == 'jsm174/wpc-emu-cs' && github.ref == 'refs/heads/master' && github.event_name == 'push' | ||
steps: | ||
- uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.GH_PAT }} | ||
event-type: build-complete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish | ||
on: | ||
repository_dispatch: | ||
types: [ release-complete ] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.client_payload.commitish }} | ||
- uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '3.1.x' | ||
- run: | | ||
cd src/WPCEmu | ||
dotnet pack -c Release -o nupkg | ||
nuget push nupkg/WPCEmu.*.nupkg -ApiKey ${{ secrets.NUGET_KEY }} -src https://api.nuget.org/v3/index.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Release | ||
on: | ||
repository_dispatch: | ||
types: [ build-complete ] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
nextVersion: ${{ steps.nextVersion.outputs.nextVersion }} | ||
nextTag: ${{ steps.nextVersion.outputs.nextTag }} | ||
commitish: ${{ steps.commit.outputs.commitish }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- id: nextVersion | ||
run: | | ||
sudo apt-get install xmlstarlet | ||
cd src/WPCEmu | ||
VERSION=$(npx semver -i prerelease $(xmlstarlet sel -t -v "//Project/PropertyGroup/PackageVersion" WPCEmu.csproj)) | ||
xmlstarlet ed -L -u "//Project/PropertyGroup/PackageVersion" -v $VERSION WPCEmu.csproj | ||
echo ::set-output name=nextVersion::${VERSION} | ||
echo ::set-output name=nextTag::"v${VERSION}" | ||
- name: Commit | ||
id: commit | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add src/WPCEmu/WPCEmu.csproj | ||
git commit -m "release: ${{ steps.nextVersion.outputs.nextTag }}." | ||
git push | ||
commitish=$(git rev-parse HEAD) | ||
echo ::set-output name=commitish::${commitish} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ steps.nextVersion.outputs.nextTag }} | ||
release_name: ${{ steps.nextVersion.outputs.nextTag }} | ||
prerelease: true | ||
commitish: ${{ steps.commit.outputs.commitish }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
dispatch: | ||
runs-on: ubuntu-latest | ||
needs: [ release ] | ||
steps: | ||
- uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.GH_PAT }} | ||
event-type: release-complete | ||
client-payload: '{ "run_id": "${{ github.run_id }}", | ||
"nextVersion": "${{ needs.release.outputs.nextVersion }}", | ||
"nextTag": "${{ needs.release.outputs.nextTag }}", | ||
"commitish": "${{ needs.release.outputs.commitish }}" }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# WPC-Emu CS | ||
|
||
[![CI status (x64 Linux, macOS and Windows)](https://github.com/jsm174/wpc-emu-cs/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/jsm174/wpc-emu-cs/actions) | ||
[![NuGet](https://img.shields.io/nuget/vpre/WPCEmuCS.svg)](https://www.nuget.org/packages/WPCEmuCS) | ||
|
||
*Add WPC-Emu support to any .NET application* | ||
|
||
This Nuget package is C# port of neophob's amazing WPC Emulator [wpc-emu](https://github.com/neophob/wpc-emu). | ||
|
||
## Supported Platforms | ||
|
||
- .NET Core (.NETStandard 2.0 and higher on Windows, Linux and macOS) | ||
- Mono | ||
|
||
## Setup | ||
|
||
To install this package, run: | ||
|
||
``` | ||
Install-Package WPCEmuCS | ||
``` | ||
|
||
## Usage | ||
|
||
See the [example project](https://github.com/jsm174/wpc-emu-cs/blob/master/src/WPCEmu.Example/Example.cs) for more information. | ||
|
||
## License | ||
|
||
[Apache License Version 2.0](LICENSE.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.IO; | ||
using WPCEmu.Boards.Elements; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
namespace WPCEmu.Example | ||
{ | ||
class Example | ||
{ | ||
const int TICKS_PER_SECOND = 2000000; | ||
const int TICKS_PER_STEP = 16; | ||
const int INITIAL_FRAMERATE = 50; | ||
|
||
static string[] DOTS = new string[] | ||
{ | ||
" ", | ||
"░", | ||
"▒", | ||
"▓", | ||
"▓" | ||
}; | ||
|
||
static void Start(Emulator wpcSystem) | ||
{ | ||
int ticksPerCall = TICKS_PER_SECOND / INITIAL_FRAMERATE; | ||
int intervalTimingMs = 1000 / INITIAL_FRAMERATE; | ||
|
||
Task.Run(() => | ||
{ | ||
new Timer(_ => wpcSystem.setCabinetInput(16), null, 1500, Timeout.Infinite); | ||
while (true) | ||
{ | ||
wpcSystem.executeCycle(ticksPerCall, TICKS_PER_STEP); | ||
DumpDMD(wpcSystem); | ||
Thread.Sleep(intervalTimingMs); | ||
} | ||
}); | ||
|
||
while (true) | ||
{ | ||
Thread.Sleep(intervalTimingMs); | ||
} | ||
} | ||
|
||
static void DumpDMD(Emulator wpcSystem) | ||
{ | ||
var state = wpcSystem.getState(); | ||
|
||
var display = (OutputDmdDisplay.State)state.asic?.display; | ||
|
||
var dmd = ""; | ||
|
||
for (var y = 0; y < 32; y++) | ||
{ | ||
for (var x = 0; x < 128; x++) | ||
{ | ||
var pixel = y * 128 + x; | ||
var value = display.dmdShadedBuffer[pixel]; | ||
|
||
dmd += DOTS[value]; | ||
} | ||
|
||
dmd += "\n"; | ||
} | ||
|
||
Console.SetCursorPosition(0, 0); | ||
Console.WriteLine(dmd); | ||
Console.WriteLine(state.cpuState.tickCount); | ||
} | ||
|
||
static void Main(string[] args) | ||
{ | ||
try | ||
{ | ||
if (args.Length < 1) | ||
{ | ||
throw new ArgumentException("USAGE: Example <rom file>"); | ||
} | ||
|
||
var u06 = File.ReadAllBytes(args[0]); | ||
|
||
var romObject = new RomBinary | ||
{ | ||
u06 = u06 | ||
}; | ||
|
||
var metaData = new RomMetaData | ||
{ | ||
skipWpcRomCheck = false, | ||
features = new string[] | ||
{ | ||
"securityPic", | ||
"wpc95" | ||
}, | ||
}; | ||
|
||
var wpcSystem = Emulator.initVMwithRom(romObject, metaData); | ||
|
||
wpcSystem.reset(); | ||
wpcSystem.start(); | ||
|
||
Start(wpcSystem); | ||
} | ||
|
||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\WPCEmu\WPCEmu.csproj" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.