Giter VIP home page Giter VIP logo

yakc's Introduction

YAKC (Yet Another KC Emulator)

NOTE: this project is abandoned. This is the followup project: https://floooh.github.io/tiny8bit/

Build Status

Despite the name this is a multi-system emulator for 8-bit home computers.

It started as a KC85 emulator because this was the system I spent most of my youth on: https://en.wikipedia.org/wiki/KC_85

Live Demo

http://floooh.github.io/virtualkc/

This is a WebAssembly version. If this doesn't work, switch to the asm.js version through the top-left hamburger icon.

How to Build:

> python --version
Python 2.7.10
> cmake --version
cmake version 3.3.2
> git clone https://github.com/floooh/yakc
> cd yakc
> ./fips build
> ./fips run yakcapp

In debug mode, the emulator tries to load additional ROMs and games from a local HTTP server at port 8000. Just do this:

> cd yakc/files
> python -m SimpleHTTPServer
...

And run the emulator from another terminal window. When building in release mode, the emulator will load the data directly from the webpage at http://floooh.github.io/virtualkc/

Overview

YAKC currently emulates the following 8-bit systems:

  • KC85/2, KC85/3, KC85/4, KC Compact (VEB Mikroelektronik Muehlhausen)
  • Z9001 (aka KC85/1) and KC87 (Robotron Dresden)
  • Z1013 (Robotron Riesa)
  • Sinclair ZX Spectrum 48k and 128k
  • Amstrad CPC464 and CPC6128
  • Acorn Atom

Source code of the system emulators is here: https://github.com/floooh/yakc/tree/master/src/yakc/systems

The system emulators are built on top of dependency-free, header-only chip emulators written in C (https://github.com/floooh/chips).

Rendering and input is done through Oryol: https://github.com/floooh/oryol

Audio is done through SoLoud: https://github.com/jarikomppa/soloud

The extensive debugging UI is implemented with Dear Imgui: https://github.com/ocornut/imgui

Kudos to MAME for providing a reference when there was insufficient documentation available for emulated chips and computer systems: https://github.com/mamedev/mame

The following platforms are fully supported:

  • asm.js / wasm
  • OSX
  • Windows
  • Linux

The emulator should also build and run on Android, iOS and Raspberry Pi but this is less tested and there will be input- or performance-problems on those platforms.

Implementation Details

A few implementation details are worth mentioning:

  • on M6502 machines (currently only the Acorn Atom), the system is ticked per clock cycle and fully implements the M6502 memory access quirks (each cycle is a memory access, including 'junk accesses')
  • on Z80 machines, the system is ticked with machine-cycle granularity (typical 3..5 clock cycles, or more if wait states are injected)
  • all known undocumented Z80 behaviour is implemented, the M6502 implements the 'stable' undocumented instructions, but not most of the 'unstable' instructions
  • communication between chips happens (mostly) with pin bit masks instead of specialized callbacks, this means the system emulation source code mimics how the different chips are connected on the motherboard instead of relying on 'high level recipes' which describe the functions of specific I/O addresses

Emulated System Details

All the East German computer models had 'unlicensed' Z80-chip-family clones called U880 (Z80 CPU), U855 (Z80 PIO) and U857 (Z80 CTC). The East German clones had some hardware bugfixes compared to the original Z80 and thus some undocumented instructions behaved slightly different. YAKC emulates the original Z80, not the 'fixed' U880 clones (doesn't make a difference with all software I tested).

KC85/2, KC85/3 and KC85/4

These were East German home computers with fairly impressive hardware- and software-capabilities, at least given the 'real-world-socialist' economic restrictions of 80's Eastern Germany. Unlike many other Eastern computers, the KC85 line wasn't a direct clone of Western machines, but implemented some unique ideas both in hardware and software. In terms of hardware capabilities, the ZX Spectrum was the closest Western system, the KC85 had a slower CPU, but higher-resolution graphics.

  • manufactured by VEB Mikroelektronikkombinat Muehlhausen from 1985 (KC85/2) to 1989 (KC85/4)
  • Z80 CPU @ 1.75 MHz, Z80 PIO and Z80 CTC
  • 320x256 display resolution with 16 foreground and 8 background colors
  • 8x4 pixels or 8x1 pixels color attribute resolution (same idea as the ZX Spectrum but with smaller color attribute blocks)
  • 16 KByte (KC85/2 and /3) to ~128 KB RAM (KC85/4)
  • 8 KByte to 20 KByte ROM (operating system and BASIC)
  • no hardware sprites, programmable video signal generator or dedicated sound chip

A few KC85 games:

Digger: Digger

A Pengo 'clone': Pengo Intro Screen

Cave: Cave

House: House Ingame

Jungle: Jungle

KC85/3 start screen with operating system HC-CAOS 3.1:

KC85/3

Z9001 and KC87

This was another of the 'big three' East German 8-bit computer models, built by Robotron Dresden. The Z9001 was later renamed to KC85/1 even though it had no similarities with the KC85/2-based computers from Muehlhausen. The KC87 is identical to the Z9001 apart from a builtin BASIC. A color graphics module was optional (YAKC implements monochrome graphics for the Z9001 and color graphics for the KC87).

  • manufactured by Robotron Dresden from 1984 (Z9001) and 1987 (KC87)
  • Z80 CPU @ 2.5 MHz, 2(!) Z80 PIOs and a Z80 CTC
  • 16 KByte RAM
  • 4 KByte ROM, and additionally a 10 KByte ROM BASIC in the KC87
  • 40x24 or 40x20 black-and-white or 8-color character graphics

KC87 running BASIC:

KC87

Z1013

The Z1013 is the last and most simple of the East German computers emulated by YAKC. It was mostly a hobbyist computer sold as kit, and the only computer in Eastern Germany that was sold directly to citizens.

  • manufactured by Robotron Riesa from 1985
  • Z80 CPU @ 2.0 MHz, Z80 PIO
  • 16..64 KByte RAM
  • 2 KByte ROM
  • 32x32 monochrome character graphics

A Z1013 running a clone of the ZX81 game Mazogs:

Z1013 Mazogs

ZX Spectrum 48k and 128k

The ZX Spectrum was a British machine which was also popular as self-built hobbyist machine or official clone in the Eastern hemisphere because of its simple hardware architecture.

  • manufactured by Sinclair from 1982
  • 3.5 MHz Z80 CPU, custom 'ULA' chip, AY-3-8912 sound chip in the 128k
  • 256x192 @ 15 colors in 8x8 color attribute blocks

YAKC currently doesn't emulate the 'contended memory' performance penalty when accessing video memory.

The iconic 128k start screen:

ZX Spectrum 128k

The 48k version of Bomb Jack:

ZX 48k Bomb Jack

Exolon on the 48k:

ZX 48k Exolon

The start screen of Arkanoid RoD on the 128k:

ZX 128k Arkanoid

Amstrad CPC 464, 6128 and KC Compact

The Amstrad CPC had a very interesting architecture which is surprisingly tricky to emulate. Even though the video system lacked hardware sprites, it made up for it by making clever use of the fairly programmable MC6845 video signal generator chip, which allow some graphics effects otherwise only known from the much more powerful Amiga.

The KC Compact is an outlier, it was an East German CPC clone produced from 1989, and cancelled soon after the Wall came down. The KC Compact emulated the custom Amstrad gate array chip with standard TTL logic, YAKC is cheating here a bit and treats all CPC models the same (the only difference of the KC Compact is a slightly different color palette, and different ROMs).

  • manufactured by Amstrad, Schneider, MEK Muehlhausen and others from 1984
  • 4 MHz Z80 CPU (real world perf more like 3.3 Mhz because of wait state injection)
  • 64 or 128 KByte RAM
  • 32 KByte ROM
  • i8255 Programmable Peripheral Interface chip
  • MC6845 CRT Controller chip
  • AY-3-8912 Programmable Sound Generator chip
  • Amstrad 40007/40010 custom gate array chip
  • 27 hardware colors (32 with some redundant colors)
  • 160x200 @ 16 colors, 320x200 @ 4 colors or 640x200 @ 2 colors display modes

The Amstrad 6128 start screen:

CPC6128

The DTC demo by Arkos and Overlanders:

CPC DTC

The CPC version of Bomb Jack:

CPC Bomb Jack

Arkanoid on the CPC:

CPC Arkanoid

Cybernoid:

CPC Cybernoid

Acorn Atom

The Atom is one of the early Acorn 8-bit computers with a very simple but clever architecture (especially for its early release date). Apart from the Netherlands it wasn't very popular in continental Europe. Currently this is the only system in YAKC with a MOS 6502 CPU.

  • manufactured by Acorn from 1980
  • 1 MHz MOS Technology 6502 CPU
  • up to 40 KByte RAM
  • up to 16 KByte ROM
  • MC6847 Video Display Generator chip
  • i8255 Programmable Peripheral Interface chip
  • optional 6522 Versatile Interface Adapter chip
  • mixed text/semigraphics 32x16 display mode
  • various graphics display modes from 64x64 @ 4 colors up to 256x192 @ 2 colors

Acorn Atom mixed text/semigraphics mode:

Atom

The game 'Atomic Chucky Egg':

Atomic Chucky Egg

The Debugger UI

YAKC has an extensive debugging UI implemented with Dear Imgui:

YAKC Debugger UI

yakc's People

Contributors

floooh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yakc's Issues

Implement device daisy-chain

For proper interrupts from the PIO and CTC, some sort of daisy chain management should be implemented which takes care of interrupt priorities etc...

Fix Digger

  • sound is broken
  • diamond color scrolling is broken (how does this even work?)

Implement better memory mapping

Allow several layers of prioritized memory mappings, where lower priority mapping can fill holes in the memory layout.
This is necessary for the 64KB expansion modules, the 64 KB are mapped continuously from a start address and are accessible through the bank windows that are not mapped by higher-priority memory banks.

Linux Mint 17 32bit compile error

First, > ./fips gen works well.
Then > ./fips make yakcapp give errors:
> ./fips make yakcapp === dependency: 'oryol': dir '/home/takis/tmp/oryol' exists === dependency: 'fips-unittestpp': dir '/home/takis/tmp/fips-unittestpp' exists === dependency: 'fips-remotery': dir '/home/takis/tmp/fips-remotery' exists === dependency: 'fips-glm': dir '/home/takis/tmp/fips-glm' exists === dependency: 'fips-glfw': dir '/home/takis/tmp/fips-glfw' exists === dependency: 'gliml': dir '/home/takis/tmp/gliml' exists === dependency: 'fips-zlib': dir '/home/takis/tmp/fips-zlib' exists === dependency: 'fips-vld': dir '/home/takis/tmp/fips-vld' exists === dependency: 'fips-libcurl': dir '/home/takis/tmp/fips-libcurl' exists === dependency: 'fips-soloud': dir '/home/takis/tmp/fips-soloud' exists === dependency: 'oryol-imgui': dir '/home/takis/tmp/oryol-imgui' exists === dependency: 'fips-imgui': dir '/home/takis/tmp/fips-imgui' exists === building: linux-make-debug make -j3 yakcapp Scanning dependencies of target glfw3 Scanning dependencies of target Core Scanning dependencies of target ALL_GENERATE [ 1%] Building CXX object oryol_Core/CMakeFiles/Core.dir/App.cc.o [ 1%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/context.c.o Traceback (most recent call last): File "/home/takis/tmp/yakc-master/.fips-gen.py", line 56, in <module> processFile(attrs) File "/home/takis/tmp/yakc-master/.fips-gen.py", line 47, in processFile module.generate(input, out_src, out_hdr, args) File "/home/takis/tmp/oryol/fips-generators/Shader.py", line 1870, in generate shaderLibrary.validateShadersGLSL() File "/home/takis/tmp/oryol/fips-generators/Shader.py", line 1567, in validateShadersGLSL glslcompiler.validate(srcLines, 'vs', slVersion) File "/home/takis/tmp/oryol/fips-generators/util/glslcompiler.py", line 102, in validate output = callValidator(cmd) File "/home/takis/tmp/oryol/fips-generators/util/glslcompiler.py", line 38, in callValidator child = subprocess.Popen(cmd, stdout=subprocess.PIPE) File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 8] Exec format error make[3]: *** [oryol-imgui_IMUI/CMakeFiles/ALL_GENERATE] Error 1 make[2]: *** [oryol-imgui_IMUI/CMakeFiles/ALL_GENERATE.dir/all] Error 2 make[2]: *** Waiting for unfinished jobs.... [ 2%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/init.c.o [ 2%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/input.c.o [ 3%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/monitor.c.o [ 3%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/vulkan.c.o [ 3%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Args.cc.o [ 4%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/window.c.o [ 4%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/x11_init.c.o [ 5%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/x11_monitor.c.o [ 6%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Core.cc.o [ 6%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/x11_window.c.o [ 6%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/xkb_unicode.c.o [ 6%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Log.cc.o [ 7%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/linux_joystick.c.o [ 7%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Logger.cc.o [ 7%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/posix_time.c.o [ 8%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/posix_tls.c.o [ 9%] [ 9%] Building CXX object oryol_Core/CMakeFiles/Core.dir/StackTrace.cc.o Building CXX object oryol_Core/CMakeFiles/Core.dir/RunLoop.cc.o [ 9%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/glx_context.c.o [ 10%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Memory/Memory.cc.o [ 11%] Building C object fips-glfw_glfw3/CMakeFiles/glfw3.dir/glfw/src/egl_context.c.o [ 11%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/String.cc.o Linking C static library libglfw3.a [ 11%] Built target glfw3 [ 12%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/StringAtom.cc.o [ 12%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/StringBuilder.cc.o [ 13%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/StringConverter.cc.o [ 13%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/WideString.cc.o [ 13%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/stringAtomBuffer.cc.o [ 14%] Building CXX object oryol_Core/CMakeFiles/Core.dir/String/stringAtomTable.cc.o [ 14%] Building C object oryol_Core/CMakeFiles/Core.dir/String/ConvertUTF.c.o [ 15%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Threading/ThreadLocalData.cc.o [ 15%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Time/Clock.cc.o [ 16%] Building CXX object oryol_Core/CMakeFiles/Core.dir/Trace.cc.o Linking CXX static library libCore.a [ 16%] Built target Core make[1]: *** [src/yakcapp/CMakeFiles/yakcapp.dir/rule] Error 2 make: *** [yakcapp] Error 2 [ERROR] Failed to build config 'linux-make-debug' of project 'yakc-master'

Emulator will get stuck if audio isn't triggered

...e.g. on browsers without WebGL the emulator seems to be frozen (even though the UI works) because the audio cycle count isn't advanced, this will cause the CPU to stop because it thinks it is running to far ahead of audio!

Fix keyboard input

There are several issues with keyboard input:

  • the keys =-; don't work for Z9001 in the browser (is this a general 32-bit issue, or just in browser, and are there differences between browsers? -> it looks like the key_mask is deleted too early)
  • the last_ascii and 'AnyKeyPressed' hack in Main.cc, this leads for instance to key-repeat when Shift is keeping pressed, but was necessary to make games work
  • sometimes the key repeat gets stuck without pressing any keyboard keys
  • the yakc class needs a proper key-input method, the current method up in Main.cc is hacky and must be repeated in every other project which uses the emulator

I think a clean rewrite of the keyboard input code would make sense.

Freeze when debugging Z1013 system ROM

Reminder for more investigation: I just managed to freeze the browser version by debugging the z1013 system rom: set breakpoint at F000, reboot, step from there, at some point hit the break checkbox to continue execution, and at that point the browser froze. Most likely some infinite loop triggered.

CPC: Reason for Chase HQ and Cybernoid found

Ok, here's the reason why this was broken, then worked and then was broken again:

It's the cassette read trap here:

z80_set_trap(&board.z80, 1, this->casread_trap);

Problem is: cannot simply set and clear the trap from inside the CPU callback... this will not be noticed by the CPU since the CPU struct is overwritten... need to implement a more robust solution since the same problem can also happen on other systems (one solution would be a separate 'bool z80_check_trap(int trap_id)' callback which would only be called for verification when the 16-bit address matches.

Rewrite the memory map window

The memory map window needs to be fixed for the KC85/4 memory banks, it would also be nice to directly click on a memory bank and see/edit its content in a memory editor window.

"Freeze" in KC85/3 version of Digger

Just got a freeze after changing levels, the main loop would get stuck waiting for the value in 5F9. This is written to by the CTC2 interrupt and seems to be the pause for moving the player, which probably wasn't triggered anymore. 2 recent changes come to mind:

  • each CTC channel now has its on embedded z80int object, making the daisy chain more complex
  • interrupt request changes while interrupts are disabled, the interrupt request will remain pending until the CPU can handle it

Short freeze when switching from KC85/4 to Z1013.01?

Repro: hang around in the KC85/4 emulation for several minutes, than switch to Z1013, this can freeze the emulator for several seconds. Is there something wrong with the min/max-cycle count computation, so that the z1013 runs a lot of cycles in the first frame to 'catch up'? Something not reset on poweron?

Implement blinking foreground color

  • the timing is controlled by a CTC channel
  • there's a 'blinking' bit in PIO B
  • open questions:
    • is the blinking bit controlled by the CTC interrupt, or is this a global override?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.