From 7f979be9dc50cea7a814b3c93abb8e124579a4dd Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Wed, 24 Mar 2021 10:30:54 -0700 Subject: [PATCH 01/31] add RISC5 interrupt implementation --- src/risc.c | 37 +++++++++++++++++++++++++++++++++++-- src/risc.h | 1 + src/sdl-main.c | 18 ++++++++++-------- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/risc.c b/src/risc.c index 0e66513..c44aabb 100644 --- a/src/risc.c +++ b/src/risc.c @@ -30,7 +30,11 @@ struct RISC { uint32_t PC; uint32_t R[16]; uint32_t H; - bool Z, N, C, V; + uint32_t SPC; // SPC: Saved PC + bool SZ, SN, SC, SV; // : Saved Condition Codes + bool Z, N, C, V, I, E, P; // I: Interrupt mode + // E: Interrupts enabled + // P: Interrupt pending uint32_t mem_size; uint32_t display_start; @@ -161,6 +165,10 @@ void risc_reset(struct RISC *risc) { risc->PC = ROMStart/4; } +void risc_trigger_interrupt(struct RISC *risc) { + risc->P = true; +} + void risc_run(struct RISC *risc, int cycles) { risc->progress = 20; // The progress value is used to detect that the RISC cpu is busy @@ -174,6 +182,15 @@ void risc_run(struct RISC *risc, int cycles) { static void risc_single_step(struct RISC *risc) { uint32_t ir; + if (risc->P && risc->E && ! risc->I ) { + risc->SPC = risc->PC; + risc->SZ = risc->Z; + risc->SN = risc->N; + risc->SC = risc->C; + risc->SV = risc->V; + risc->I = true; + risc->PC = 1; + } if (risc->PC < risc->mem_size / 4) { ir = risc->RAM[risc->PC]; } else if (risc->PC >= ROMStart/4 && risc->PC < ROMStart/4 + ROMWords) { @@ -359,7 +376,23 @@ static void risc_single_step(struct RISC *risc) { case 4: t ^= risc->C | risc->Z; break; case 5: t ^= risc->N ^ risc->V; break; case 6: t ^= (risc->N ^ risc->V) | risc->Z; break; - case 7: t ^= true; break; + case 7: t ^= true; + if (((ir & ubit) == 0) && ((ir & 0x00000010) == 0x10) && risc->I) { // IRET + risc->PC = risc->SPC; + risc->Z = risc->SZ; + risc->N = risc->SN; + risc->C = risc->SC; + risc->V = risc->SV; + risc->I = false; + risc->P = false; + return; + }else{ + if (((ir & ubit) == 0) && ((ir & 0x00000020) == 0x20)) { // STI and CLI + risc->E = (ir & 1) == 1 ? true: false; + return; + } + } + break; default: abort(); // unreachable } if (t) { diff --git a/src/risc.h b/src/risc.h index cf4eeb7..90b63e0 100644 --- a/src/risc.h +++ b/src/risc.h @@ -24,6 +24,7 @@ void risc_set_clipboard(struct RISC *risc, const struct RISC_Clipboard *clipboar void risc_set_switches(struct RISC *risc, int switches); void risc_reset(struct RISC *risc); +void risc_trigger_interrupt(struct RISC *risc); void risc_run(struct RISC *risc, int cycles); void risc_set_time(struct RISC *risc, uint32_t tick); void risc_mouse_moved(struct RISC *risc, int mouse_x, int mouse_y); diff --git a/src/sdl-main.c b/src/sdl-main.c index b82b291..02defe2 100644 --- a/src/sdl-main.c +++ b/src/sdl-main.c @@ -17,6 +17,7 @@ #define CPU_HZ 25000000 #define FPS 60 +#define MSPF 1000/FPS static uint32_t BLACK = 0x657b83, WHITE = 0xfdf6e3; //static uint32_t BLACK = 0x000000, WHITE = 0xFFFFFF; @@ -336,18 +337,19 @@ int main (int argc, char *argv[]) { } risc_set_time(risc, frame_start); - risc_run(risc, CPU_HZ / FPS); - + for (int i=0; i 0) { + SDL_Delay(delay); + } + risc_trigger_interrupt(risc); + } update_texture(risc, texture, &risc_rect); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture, &risc_rect, &display_rect); SDL_RenderPresent(renderer); - - uint32_t frame_end = SDL_GetTicks(); - int delay = frame_start + 1000/FPS - frame_end; - if (delay > 0) { - SDL_Delay(delay); - } } return 0; } From 5234e8bea096a2de5d5fe82e723625f8312010c5 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 11:57:02 -0700 Subject: [PATCH 02/31] announce that this is a fork --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ae01e5..330b6d2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Oberon RISC Emulator +# Oberon RISC Emulator Integrated Oberon Fork + +Forked from [Peter De Wachter's RISC emulator in C](https://github.com/pdewacht/oberon-risc-emu) with miscelaneous features added This is an emulator for the Oberon RISC machine. For more information, [see Niklaus Wirth's site](https://www.inf.ethz.ch/personal/wirth/). For From 2a9d0f394ecaeda936f4f693c4d326d8a34a2b1f Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 12:12:48 -0700 Subject: [PATCH 03/31] introduce github build action --- .github/workflows/build4ubuntu.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/build4ubuntu.yml diff --git a/.github/workflows/build4ubuntu.yml b/.github/workflows/build4ubuntu.yml new file mode 100644 index 0000000..9a9ad1d --- /dev/null +++ b/.github/workflows/build4ubuntu.yml @@ -0,0 +1,14 @@ +name: build4ubuntu +on: [push] +jobs: + ubuntu-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build + run: | + pwd + ls + which make From 37021880a1cd6886160e236cfa42454c7f0f8698 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 12:21:03 -0700 Subject: [PATCH 04/31] install dependencies, build, test --- .github/workflows/build4ubuntu.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build4ubuntu.yml b/.github/workflows/build4ubuntu.yml index 9a9ad1d..44559b3 100644 --- a/.github/workflows/build4ubuntu.yml +++ b/.github/workflows/build4ubuntu.yml @@ -7,8 +7,18 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Build + - name: Install Dependencies run: | - pwd - ls - which make + sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" + sudo apt-get update -y -qq + sudo apt-get install libsdl2-dev + + - name: Build + run: | + make + + - name: Test + run: | + ./risc --help + + From 1335fd656d7bd217e01b016695d31ec637919ea7 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 12:22:54 -0700 Subject: [PATCH 05/31] fix indent --- .github/workflows/build4ubuntu.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build4ubuntu.yml b/.github/workflows/build4ubuntu.yml index 44559b3..1ca566a 100644 --- a/.github/workflows/build4ubuntu.yml +++ b/.github/workflows/build4ubuntu.yml @@ -7,17 +7,17 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Install Dependencies + - name: Install Dependencies run: | sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" sudo apt-get update -y -qq sudo apt-get install libsdl2-dev - - name: Build + - name: Build run: | make - - name: Test + - name: Test run: | ./risc --help From d6bb850c3de327fec880c0a099a6cb18c95abe72 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 13:08:42 -0700 Subject: [PATCH 06/31] add MacOS build --- .github/workflows/build4ubuntu.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build4ubuntu.yml b/.github/workflows/build4ubuntu.yml index 1ca566a..5959bb3 100644 --- a/.github/workflows/build4ubuntu.yml +++ b/.github/workflows/build4ubuntu.yml @@ -1,7 +1,7 @@ name: build4ubuntu on: [push] jobs: - ubuntu-build: + Ubuntu-build: runs-on: ubuntu-latest steps: - name: Checkout @@ -19,6 +19,23 @@ jobs: - name: Test run: | - ./risc --help + ls -alh ./risc + MacOS-build: + runs-on: macOS-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Dependencies + run: | + brew install SDL2 + + - name: Build + run: | + make + + - name: Test + run: | + ls -alh ./risc From e6154136063972cb9a574a9c608779faa3b11467 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 15:36:13 -0700 Subject: [PATCH 07/31] add Windows build step --- .../{build4ubuntu.yml => build-and-test.yml} | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) rename .github/workflows/{build4ubuntu.yml => build-and-test.yml} (77%) diff --git a/.github/workflows/build4ubuntu.yml b/.github/workflows/build-and-test.yml similarity index 77% rename from .github/workflows/build4ubuntu.yml rename to .github/workflows/build-and-test.yml index 5959bb3..584192a 100644 --- a/.github/workflows/build4ubuntu.yml +++ b/.github/workflows/build-and-test.yml @@ -1,4 +1,4 @@ -name: build4ubuntu +name: Build and Test on: [push] jobs: Ubuntu-build: @@ -39,3 +39,17 @@ jobs: run: | ls -alh ./risc + Windows-build: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Build + run: | + make + + - name: Test + run: | + dir + From 529c95124413e151723750fb73323853f609e1ca Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 18:03:22 -0700 Subject: [PATCH 08/31] install dependencies for Windows --- .github/workflows/build-and-test.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 584192a..99ddb8b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -45,9 +45,11 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Build + - name: Install Dependencies run: | - make + vcpkg install SDL2 + vcpkg install getopt + - name: Test run: | From 849f8a393710a131d41488c84ec72adeb60764db Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 18:12:39 -0700 Subject: [PATCH 09/31] add Makefile for Visual Studio --- Makefile.vc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Makefile.vc diff --git a/Makefile.vc b/Makefile.vc new file mode 100644 index 0000000..3f9a2ac --- /dev/null +++ b/Makefile.vc @@ -0,0 +1,34 @@ +CC = cl +CFLAGS = -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD \ + -DSTATIC_BUFSIZ= -DS_IRUSR=0 -DS_IWUSR=0 \ + -wd4146 -wd4100 -wd4996 -nologo + + +VCPKG_BASE = h:\github\vcpkg\installed\x64-windows + +RISC_CFLAGS = $(CFLAGS) -I $(VCPKG_BASE)\include\SDL2 -I $(VCPKG_BASE)\include + +RISC_SOURCE = \ + src/sdl-main.c \ + src/sdl-ps2.c src/sdl-ps2.h \ + src/risc.c src/risc.h src/risc-boot.inc \ + src/risc-fp.c src/risc-fp.h \ + src/disk.c src/disk.h \ + src/pclink.c src/pclink.h \ + src/raw-serial.c src/raw-serial.h \ + src/sdl-clipboard.c src/sdl-clipboard.h + +all: risc.exe + +OBJS:= $(patsubst %.c,%.obj,$(filter %.c, $(RISC_SOURCE)) ) + +src/%.obj:src/%.c + $(CC) -c $(RISC_CFLAGS) $< -Fo$@ + +risc.exe:$(OBJS) + link -debug:full $(OBJS) sdl2main.lib sdl2.lib getopt.lib -libpath:$(VCPKG_BASE)\lib -libpath:$(VCPKG_BASE)\lib\manual-link -SUBSYSTEM:WINDOWS -out:$@ + +clean: + -del /s *.obj + -del *.exe + -del *.pdb From 091312597414c32fcd4eb58fb5448c0f6f95d656 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 18:17:12 -0700 Subject: [PATCH 10/31] try cmake for visual studio --- .github/workflows/build-and-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 99ddb8b..a226385 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -50,6 +50,9 @@ jobs: vcpkg install SDL2 vcpkg install getopt + - name: Build + run: | + cmake Makefile.vc - name: Test run: | From 10831d8a69070d502347b2215556c419832f3442 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 14 Aug 2021 18:21:54 -0700 Subject: [PATCH 11/31] try regular make for visual studio --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index a226385..f2bf74a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -52,7 +52,9 @@ jobs: - name: Build run: | - cmake Makefile.vc + mv Makefile Makefile.bak + mv Makefile.vc Makefile + make - name: Test run: | From 1e117b0575413a8861e76d726b49b59ff4872baa Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 08:40:26 -0700 Subject: [PATCH 12/31] remove incorrect include paths for Windows --- Makefile.vc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.vc b/Makefile.vc index 3f9a2ac..f702e27 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -4,9 +4,9 @@ CFLAGS = -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD \ -wd4146 -wd4100 -wd4996 -nologo -VCPKG_BASE = h:\github\vcpkg\installed\x64-windows -RISC_CFLAGS = $(CFLAGS) -I $(VCPKG_BASE)\include\SDL2 -I $(VCPKG_BASE)\include + +RISC_CFLAGS = $(CFLAGS) RISC_SOURCE = \ src/sdl-main.c \ @@ -26,7 +26,7 @@ src/%.obj:src/%.c $(CC) -c $(RISC_CFLAGS) $< -Fo$@ risc.exe:$(OBJS) - link -debug:full $(OBJS) sdl2main.lib sdl2.lib getopt.lib -libpath:$(VCPKG_BASE)\lib -libpath:$(VCPKG_BASE)\lib\manual-link -SUBSYSTEM:WINDOWS -out:$@ + link -debug:full $(OBJS) sdl2main.lib sdl2.lib getopt.lib -SUBSYSTEM:WINDOWS -out:$@ clean: -del /s *.obj From fab4a02185fce18b23458971a5ad26b792406811 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 08:58:40 -0700 Subject: [PATCH 13/31] adjust makefile --- Makefile.vc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile.vc b/Makefile.vc index f702e27..4429b0a 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -20,12 +20,17 @@ RISC_SOURCE = \ all: risc.exe +XOBJS:= $(patsubst %.c,%.obj,$(filter %.c, $(RISC_SOURCE)) ) + OBJS:= $(patsubst %.c,%.obj,$(filter %.c, $(RISC_SOURCE)) ) src/%.obj:src/%.c $(CC) -c $(RISC_CFLAGS) $< -Fo$@ -risc.exe:$(OBJS) +risc.exe:$(RISC_SOURCE) + $(CC) -c $(RISC_CFLAGS) src/sdl-main.c + dir + dir src link -debug:full $(OBJS) sdl2main.lib sdl2.lib getopt.lib -SUBSYSTEM:WINDOWS -out:$@ clean: From 5efdb27d65768bfaf29bfa0f97f66dd30d6efa65 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 09:06:19 -0700 Subject: [PATCH 14/31] move visual studio makefile into src directory --- .github/workflows/build-and-test.yml | 3 ++- Makefile.vc => src/Makefile.vc | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename Makefile.vc => src/Makefile.vc (100%) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f2bf74a..fb4334a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -52,11 +52,12 @@ jobs: - name: Build run: | - mv Makefile Makefile.bak + cd src mv Makefile.vc Makefile make - name: Test run: | dir + dir src diff --git a/Makefile.vc b/src/Makefile.vc similarity index 100% rename from Makefile.vc rename to src/Makefile.vc From b2df0c879d028f56f4fcfb79fb355d206488ac58 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 09:12:03 -0700 Subject: [PATCH 15/31] simplify makefile for vs --- src/Makefile.vc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Makefile.vc b/src/Makefile.vc index 4429b0a..a97d13b 100644 --- a/src/Makefile.vc +++ b/src/Makefile.vc @@ -9,14 +9,14 @@ CFLAGS = -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD \ RISC_CFLAGS = $(CFLAGS) RISC_SOURCE = \ - src/sdl-main.c \ - src/sdl-ps2.c src/sdl-ps2.h \ - src/risc.c src/risc.h src/risc-boot.inc \ - src/risc-fp.c src/risc-fp.h \ - src/disk.c src/disk.h \ - src/pclink.c src/pclink.h \ - src/raw-serial.c src/raw-serial.h \ - src/sdl-clipboard.c src/sdl-clipboard.h + sdl-main.c \ + sdl-ps2.c sdl-ps2.h \ + risc.c risc.h risc-boot.inc \ + risc-fp.c risc-fp.h \ + disk.c disk.h \ + pclink.c pclink.h \ + raw-serial.c raw-serial.h \ + sdl-clipboard.c sdl-clipboard.h all: risc.exe @@ -24,13 +24,15 @@ XOBJS:= $(patsubst %.c,%.obj,$(filter %.c, $(RISC_SOURCE)) ) OBJS:= $(patsubst %.c,%.obj,$(filter %.c, $(RISC_SOURCE)) ) -src/%.obj:src/%.c +%.obj:%.c $(CC) -c $(RISC_CFLAGS) $< -Fo$@ risc.exe:$(RISC_SOURCE) - $(CC) -c $(RISC_CFLAGS) src/sdl-main.c + $(CC) -c $(RISC_CFLAGS) sdl-main.c dir dir src + +foo: link -debug:full $(OBJS) sdl2main.lib sdl2.lib getopt.lib -SUBSYSTEM:WINDOWS -out:$@ clean: From 1093741ba39d359af0b9e40b19fb3f5d37e6b615 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 09:17:47 -0700 Subject: [PATCH 16/31] try bare compile for windows --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fb4334a..59af569 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -54,7 +54,7 @@ jobs: run: | cd src mv Makefile.vc Makefile - make + cl -c -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD -DSTATIC_BUFSIZ= -DS_IRUSR=0 -DS_IWUSR=0 -wd4146 -wd4100 -wd4996 -nologo sdl-main.c - name: Test run: | From 074a8b195a9c7308ad5f87adb4d814240707d71e Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 09:28:02 -0700 Subject: [PATCH 17/31] find visual studio and enter the development shell --- .github/workflows/build-and-test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 59af569..c886a00 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -51,7 +51,19 @@ jobs: vcpkg install getopt - name: Build + shell: pwsh run: | + ${VCPKG_INSTALLED} = "${env:VCPKG_ROOT}/installed/${{matrix.config.arch}}-${{matrix.config.sys}}" + ${HUNSPELL_SRC} = "${VCPKG_INSTALLED}/include" + ${HUNSPELL_LIB} = "${VCPKG_INSTALLED}/lib" + Write-Output "VCPKG_INSTALLED_DIR=${VCPKG_INSTALLED}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + ${VS_INST_PATH} = & "${env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -property installationPath + Write-Output " <-> VS Install Path: ${VS_INST_PATH}" + Import-Module ${VS_INST_PATH}/Common7/Tools/Microsoft.VisualStudio.DevShell.dll + Enter-VsDevShell -VsInstallPath ${VS_INST_PATH} -SkipAutomaticLocation -DevCmdArguments '-arch=${{matrix.config.arch}} -no_logo' + ${MAKE_CMD} = "${env:JOM_DIR}/jom" + cd src mv Makefile.vc Makefile cl -c -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD -DSTATIC_BUFSIZ= -DS_IRUSR=0 -DS_IWUSR=0 -wd4146 -wd4100 -wd4996 -nologo sdl-main.c From 9e359b7ea82efa77a14502f464a71b3ed027d1eb Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sun, 15 Aug 2021 09:36:24 -0700 Subject: [PATCH 18/31] compile with local .h files --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c886a00..6667932 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -66,7 +66,7 @@ jobs: cd src mv Makefile.vc Makefile - cl -c -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD -DSTATIC_BUFSIZ= -DS_IRUSR=0 -DS_IWUSR=0 -wd4146 -wd4100 -wd4996 -nologo sdl-main.c + cl -c -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD -DSTATIC_BUFSIZ= -DS_IRUSR=0 -DS_IWUSR=0 -wd4146 -wd4100 -wd4996 -nologo sdl-main.c disk.c pclink.c raw-serial.c risc.c risc-fp.c sdl-clipboard.c sdl-ps2.c /I . - name: Test run: | From c0b4e7074ab0868a7938c338b8ee1e8f393964b5 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Thu, 19 Aug 2021 20:34:03 -0700 Subject: [PATCH 19/31] attempt a release action --- .github/workflows/release.yml | 104 ++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..866dd01 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,104 @@ +name: Release + +on: + # Trigger the workflow on the new 'v*' tag created + push: + tags: + - "v*" + +jobs: + create_release: + name: Create Github Release + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Create Release + id: create_release + uses: actions/create-release@v1.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + + - name: Output Release URL File + run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt + - name: Save Release URL File for publish + uses: actions/upload-artifact@v1 + with: + name: release_url + path: release_url.txt + + build_artifact: + needs: [create_release] + name: ${{ matrix.os }}-build-${{ github.ref }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set tag name + uses: olegtarasov/get-tag@v2 + id: tag + with: + tagRegex: "v(.*)" + tagRegexGroup: 1 + + - name: Build binary + run: | + mkdir dist + + - if: matrix.os == 'ubuntu-latest' + name: Install ubuntu dependencies and build + run: | + sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" + sudo apt-get update -y -qq + sudo apt-get install libsdl2-dev + make + cp ./risc dist/ubuntu-risc + + - if: matrix.os == 'macOS-latest' + name: Install macOS dependencies and build + run: | + brew install SDL2 + make + cp ./risc dist/osx-risc + + - if: matrix.os == 'windows-latest' + name: Install windows dependencies and build + run: | + type "placeholder" + + - name: Load Release URL File from release job + uses: actions/download-artifact@v1 + with: + name: release_url + + - name: Set binary path name + run: echo "::set-env name=BINARY_PATH::./dist/stan${{ env.EXT }}" + + - name: Get Release File Name & Upload URL + id: get_release_info + run: | + echo "::set-output name=upload_url::$(cat release_url/release_url.txt)" + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_release_info.outputs.upload_url }} + asset_path: ${{ env.BINARY_PATH }} + asset_name: stan-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }} + asset_content_type: application/octet-stream + + From f489be725db979684cbd23ab2e9240e8ee7ac34f Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Fri, 20 Aug 2021 09:58:08 -0700 Subject: [PATCH 20/31] remove Windows from ci for now --- .github/workflows/build-and-test.yml | 34 ---------------------------- .github/workflows/release.yml | 7 +----- 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6667932..3f94739 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -39,37 +39,3 @@ jobs: run: | ls -alh ./risc - Windows-build: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Dependencies - run: | - vcpkg install SDL2 - vcpkg install getopt - - - name: Build - shell: pwsh - run: | - ${VCPKG_INSTALLED} = "${env:VCPKG_ROOT}/installed/${{matrix.config.arch}}-${{matrix.config.sys}}" - ${HUNSPELL_SRC} = "${VCPKG_INSTALLED}/include" - ${HUNSPELL_LIB} = "${VCPKG_INSTALLED}/lib" - Write-Output "VCPKG_INSTALLED_DIR=${VCPKG_INSTALLED}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - ${VS_INST_PATH} = & "${env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -property installationPath - Write-Output " <-> VS Install Path: ${VS_INST_PATH}" - Import-Module ${VS_INST_PATH}/Common7/Tools/Microsoft.VisualStudio.DevShell.dll - Enter-VsDevShell -VsInstallPath ${VS_INST_PATH} -SkipAutomaticLocation -DevCmdArguments '-arch=${{matrix.config.arch}} -no_logo' - ${MAKE_CMD} = "${env:JOM_DIR}/jom" - - cd src - mv Makefile.vc Makefile - cl -c -D_WIN32 -Zi -W4 -WX -D_CRT_SECURE_NO_WARNINGS -MD -DSTATIC_BUFSIZ= -DS_IRUSR=0 -DS_IWUSR=0 -wd4146 -wd4100 -wd4996 -nologo sdl-main.c disk.c pclink.c raw-serial.c risc.c risc-fp.c sdl-clipboard.c sdl-ps2.c /I . - - - name: Test - run: | - dir - dir src - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 866dd01..fabff14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [ubuntu-latest, macOS-latest] steps: - name: Checkout @@ -72,11 +72,6 @@ jobs: make cp ./risc dist/osx-risc - - if: matrix.os == 'windows-latest' - name: Install windows dependencies and build - run: | - type "placeholder" - - name: Load Release URL File from release job uses: actions/download-artifact@v1 with: From 652433696b28046d18a951e847514366f982af40 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Fri, 20 Aug 2021 10:10:28 -0700 Subject: [PATCH 21/31] adjust action method of setting environment variable --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fabff14..7920e43 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,7 +78,7 @@ jobs: name: release_url - name: Set binary path name - run: echo "::set-env name=BINARY_PATH::./dist/stan${{ env.EXT }}" + run: echo "BINARY_PATH=./dist/${{ env.EXT }}" >> $GITHUB_ENV - name: Get Release File Name & Upload URL id: get_release_info From f7ba4719ecfae093194adda5ee776b835e8ecaab Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Fri, 20 Aug 2021 10:14:35 -0700 Subject: [PATCH 22/31] update get-tag --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7920e43..e25f4b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,7 +46,7 @@ jobs: uses: actions/checkout@v2 - name: Set tag name - uses: olegtarasov/get-tag@v2 + uses: olegtarasov/get-tag@v2.1 id: tag with: tagRegex: "v(.*)" From ecf38548a2a6920cc7c2daf7445babb2291c0950 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Fri, 20 Aug 2021 10:22:15 -0700 Subject: [PATCH 23/31] update binary path for release --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e25f4b5..1fb5528 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,14 +63,14 @@ jobs: sudo apt-get update -y -qq sudo apt-get install libsdl2-dev make - cp ./risc dist/ubuntu-risc + cp ./risc dist/risc-ubuntu-latest - if: matrix.os == 'macOS-latest' name: Install macOS dependencies and build run: | brew install SDL2 make - cp ./risc dist/osx-risc + cp ./risc dist/risc-macOS-latest - name: Load Release URL File from release job uses: actions/download-artifact@v1 @@ -78,7 +78,7 @@ jobs: name: release_url - name: Set binary path name - run: echo "BINARY_PATH=./dist/${{ env.EXT }}" >> $GITHUB_ENV + run: echo "BINARY_PATH=./dist/risc-${{ matrix.os }}" >> $GITHUB_ENV - name: Get Release File Name & Upload URL id: get_release_info @@ -93,7 +93,7 @@ jobs: with: upload_url: ${{ steps.get_release_info.outputs.upload_url }} asset_path: ${{ env.BINARY_PATH }} - asset_name: stan-${{ steps.tag.outputs.tag }}-${{ runner.os }}-ghc-${{ matrix.ghc }}${{ env.EXT }} + asset_name: stan-${{ steps.tag.outputs.tag }}-risc-${{ runner.os }} asset_content_type: application/octet-stream From 3206b5c7083cc89cc54e3e80c693447a7f643f55 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Fri, 20 Aug 2021 12:19:14 -0700 Subject: [PATCH 24/31] change resultant binary name to risc-on- --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1fb5528..d9aa341 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: with: upload_url: ${{ steps.get_release_info.outputs.upload_url }} asset_path: ${{ env.BINARY_PATH }} - asset_name: stan-${{ steps.tag.outputs.tag }}-risc-${{ runner.os }} + asset_name: risc-on-${{ runner.os }} asset_content_type: application/octet-stream From b6b68848d09cb2f6c999895839ab4aa2d5ca98c7 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Fri, 20 Aug 2021 12:31:24 -0700 Subject: [PATCH 25/31] add link to artifacts in README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 330b6d2..b01c5c1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ Forked from [Peter De Wachter's RISC emulator in C](https://github.com/pdewacht/oberon-risc-emu) with miscelaneous features added +* CAUTION: More features are not always better features! + +Latest risc binary for Ubuntu: [risc-on-Linux](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.20d/risc-on-Linux) (Requires SDL2 installed via apt) + +Latest risc binary for macOS: [risc-on-macOS](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.20d/risc-on-macOS) (Requires SDL2 installed via homebrew) + This is an emulator for the Oberon RISC machine. For more information, [see Niklaus Wirth's site](https://www.inf.ethz.ch/personal/wirth/). For newcomers to the Oberon family of operating systems, the document From 9f0025f7e6f0e1339c3147d6f6ccc89bffd67bc2 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Tue, 31 Aug 2021 11:02:59 -0700 Subject: [PATCH 26/31] add version argument --- src/sdl-main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sdl-main.c b/src/sdl-main.c index 02defe2..7c75e70 100644 --- a/src/sdl-main.c +++ b/src/sdl-main.c @@ -63,6 +63,7 @@ struct KeyMapping key_map[] = { }; static struct option long_options[] = { + { "version", no_argument, NULL, 'V' }, { "zoom", required_argument, NULL, 'z' }, { "fullscreen", no_argument, NULL, 'f' }, { "leds", no_argument, NULL, 'L' }, @@ -87,6 +88,7 @@ static void usage() { puts("Usage: risc [OPTIONS...] DISK-IMAGE\n" "\n" "Options:\n" + " --version Print the version of the emulator\n" " --fullscreen Start the emulator in full screen mode\n" " --zoom REAL Scale the display in windowed mode\n" " --leds Log LED state on stdout\n" @@ -121,7 +123,7 @@ int main (int argc, char *argv[]) { bool boot_from_serial = false; int opt; - while ((opt = getopt_long(argc, argv, "z:fLm:s:I:O:S", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "z:fLmV:s:I:O:S", long_options, NULL)) != -1) { switch (opt) { case 'z': { double x = strtod(optarg, 0); @@ -130,6 +132,12 @@ int main (int argc, char *argv[]) { } break; } + case 'V': { + fullscreen = true; + printf("1.1.1\n"); + exit(0); + break; + } case 'f': { fullscreen = true; break; From 9a351de0ed3860927f5caba310b04c66d49793c9 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Tue, 31 Aug 2021 11:05:51 -0700 Subject: [PATCH 27/31] align version with today release --- src/sdl-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl-main.c b/src/sdl-main.c index 7c75e70..5a0d1ec 100644 --- a/src/sdl-main.c +++ b/src/sdl-main.c @@ -134,7 +134,7 @@ int main (int argc, char *argv[]) { } case 'V': { fullscreen = true; - printf("1.1.1\n"); + printf("2021.8.31\n"); exit(0); break; } From ace63f7cb5387b6784b08834275371e1763bda22 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Tue, 31 Aug 2021 11:38:17 -0700 Subject: [PATCH 28/31] update README --- README.md | 4 ++-- tag-and-push-to-github.txt | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 tag-and-push-to-github.txt diff --git a/README.md b/README.md index b01c5c1..ce2d9b5 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Forked from [Peter De Wachter's RISC emulator in C](https://github.com/pdewacht/ * CAUTION: More features are not always better features! -Latest risc binary for Ubuntu: [risc-on-Linux](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.20d/risc-on-Linux) (Requires SDL2 installed via apt) +Latest risc binary for Ubuntu: [risc-on-Linux](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.31/risc-on-Linux) (Requires SDL2 installed via apt) -Latest risc binary for macOS: [risc-on-macOS](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.20d/risc-on-macOS) (Requires SDL2 installed via homebrew) +Latest risc binary for macOS: [risc-on-macOS](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.31/risc-on-macOS) (Requires SDL2 installed via homebrew) This is an emulator for the Oberon RISC machine. For more information, [see Niklaus Wirth's site](https://www.inf.ethz.ch/personal/wirth/). For diff --git a/tag-and-push-to-github.txt b/tag-and-push-to-github.txt new file mode 100644 index 0000000..f9b5902 --- /dev/null +++ b/tag-and-push-to-github.txt @@ -0,0 +1,3 @@ +git tag -a v202x.x.xx -m "tag message" +git push origin v202x.x.xx + From f4697d218e2b5079d6af5bb795456455f6a64757 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 4 Sep 2021 14:36:54 -0700 Subject: [PATCH 29/31] add io register write for exiting emulator --- src/risc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/risc.c b/src/risc.c index c44aabb..9509b57 100644 --- a/src/risc.c +++ b/src/risc.c @@ -584,6 +584,11 @@ static void risc_store_io(struct RISC *risc, uint32_t address, uint32_t value) { risc->spi_selected = value & 3; break; } + case 32: { + // halt with value + exit(value); + break; + } case 40: { // Clipboard control if (risc->clipboard) { From 3ac5a8ab4edb37c65ef8f25ec49ebac7b66976cd Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 4 Sep 2021 15:03:07 -0700 Subject: [PATCH 30/31] instrument risc_run to exit via sdl_main to avoid segmentation fault --- src/risc.c | 11 ++++++++--- src/risc.h | 2 +- src/sdl-main.c | 8 ++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/risc.c b/src/risc.c index 9509b57..3c12fda 100644 --- a/src/risc.c +++ b/src/risc.c @@ -39,6 +39,7 @@ struct RISC { uint32_t mem_size; uint32_t display_start; + uint32_t shutdown; uint32_t progress; uint32_t current_tick; uint32_t mouse; @@ -162,6 +163,7 @@ void risc_set_switches(struct RISC *risc, int switches) { } void risc_reset(struct RISC *risc) { + risc->shutdown = 0; risc->PC = ROMStart/4; } @@ -169,15 +171,16 @@ void risc_trigger_interrupt(struct RISC *risc) { risc->P = true; } -void risc_run(struct RISC *risc, int cycles) { +int risc_run(struct RISC *risc, int cycles) { risc->progress = 20; // The progress value is used to detect that the RISC cpu is busy // waiting on the millisecond counter or on the keyboard ready // bit. In that case it's better to just pause emulation until the // next frame. - for (int i = 0; i < cycles && risc->progress; i++) { + for (int i = 0; i < cycles && risc->progress && (risc->shutdown == 0); i++) { risc_single_step(risc); } + return risc->shutdown; } static void risc_single_step(struct RISC *risc) { @@ -586,7 +589,9 @@ static void risc_store_io(struct RISC *risc, uint32_t address, uint32_t value) { } case 32: { // halt with value - exit(value); + // SDL_Quit(); + //exit(value); + risc->shutdown = 1; break; } case 40: { diff --git a/src/risc.h b/src/risc.h index 90b63e0..0287d5b 100644 --- a/src/risc.h +++ b/src/risc.h @@ -25,7 +25,7 @@ void risc_set_switches(struct RISC *risc, int switches); void risc_reset(struct RISC *risc); void risc_trigger_interrupt(struct RISC *risc); -void risc_run(struct RISC *risc, int cycles); +int risc_run(struct RISC *risc, int cycles); void risc_set_time(struct RISC *risc, uint32_t tick); void risc_mouse_moved(struct RISC *risc, int mouse_x, int mouse_y); void risc_mouse_button(struct RISC *risc, int button, bool down); diff --git a/src/sdl-main.c b/src/sdl-main.c index 5a0d1ec..579caf2 100644 --- a/src/sdl-main.c +++ b/src/sdl-main.c @@ -343,10 +343,14 @@ int main (int argc, char *argv[]) { } } } - + int sd = 0; risc_set_time(risc, frame_start); for (int i=0; i 0) { From 0649fc161eb5a4e2260c4babaed3447c8eabdbb8 Mon Sep 17 00:00:00 2001 From: Charles Perkins Date: Sat, 4 Sep 2021 15:29:37 -0700 Subject: [PATCH 31/31] point to latest release --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce2d9b5..946f73e 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Forked from [Peter De Wachter's RISC emulator in C](https://github.com/pdewacht/ * CAUTION: More features are not always better features! -Latest risc binary for Ubuntu: [risc-on-Linux](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.31/risc-on-Linux) (Requires SDL2 installed via apt) +Latest risc binary for Ubuntu: [risc-on-Linux](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.9.4/risc-on-Linux) (Requires SDL2 installed via apt) -Latest risc binary for macOS: [risc-on-macOS](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.8.31/risc-on-macOS) (Requires SDL2 installed via homebrew) +Latest risc binary for macOS: [risc-on-macOS](https://github.com/io-core/oberon-risc-emu/releases/download/v2021.9.4/risc-on-macOS) (Requires SDL2 installed via homebrew) This is an emulator for the Oberon RISC machine. For more information, [see Niklaus Wirth's site](https://www.inf.ethz.ch/personal/wirth/). For