mamedev / mame

MAME
https://www.mamedev.org/
Other
8.26k stars 2.02k forks source link

request: add CHIP-8 emulator to MAME #9246

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi

I would like to request to add CHIP-8 emulator to MAME. It's not hardware being emulated then but an interpreted language. It's part of gaming history so it should be preserved too in MAME. A software list chip8.xml could be added and a new driver chip8.cpp.

Below the history, tech docs, ROMs (including a test ROM for all opcodes!) and more goodies!

CHIP-8 was created by RCA engineer Joe Weisbecker in 1977 for the COSMAC VIP microcomputer. It was intended as a simpler way to make small programs and games for the computer. Instead of using machine language for the VIP’s CDP1802 processor, you could type in simple hexadecimal instructions (with the VIP’s hex keypad) that resembled machine code, but which was actually interpreted on the fly by a small program.

CHIP-8 soon spread to other computers, like the Finnish Telmac 1800, the Australian DREAM 6800, ETI-660 and MicroBee, and the Canadian ACE VDU. By 1984 the support for CHIP-8 petered out. However, in 1990 it had a renaissance on the HP48 graphing calculators with CHIP-48 and the now-famous SUPER-CHIP extension with higher resolution.

http://devernay.free.fr/hacks/chip8/C8TECH10.HTM

https://chip-8.github.io/links/

https://tobiasvl.github.io/blog/write-a-chip-8-emulator/

Robbbert commented 2 years ago

There's already several chip8 computers in MAME: Various RCA models, Dream 6800, ETI660 and more. A software list already exists.

You would need to write the code and submit a PR if you want this to progress.

cuavas commented 2 years ago

CHIP8 was an early example of a hardware-independent virtual machine, in the same vein as AS/400’s TIMI, the Java runtime, or the .NET CLR. It isn’t MAME’s purpose to emulate these kinds of virtual machines directly. As @Robbbert already noted, MAME already emulates several computers with CHIP-8 runtimes. You could build a CHIP-8 emulator using MAME’s framework, but it doesn’t really belong in MAME itself.

ajrhacker commented 2 years ago

I think MAME could potentially emulate one of the many FPGA-based implementations of CHIP-8 if the hardware is documented well enough. After all, there are some other CPU architectures which are FPGA-exclusive and commercially relevant enough that MAME may need to start emulating them in the near future.

ghost commented 2 years ago

CHIP8 was an early example of a hardware-independent virtual machine, in the same vein as AS/400’s TIMI, the Java runtime, or the .NET CLR. It isn’t MAME’s purpose to emulate these kinds of virtual machines directly. As @Robbbert already noted, MAME already emulates several computers with CHIP-8 runtimes. You could build a CHIP-8 emulator using MAME’s framework, but it doesn’t really belong in MAME itself.

What exactly do you mean? You only need to emulate the Chip-8 virtual machine to run a chip-8 ROM. I don't know why you emulate the hardware itself, since the GOAL of a virtual machine is to be hardware independent. So it's useless to emulate all the hardware it runs on, because the ROMs only run on top of the interpreted chip-8 language...

cuavas commented 2 years ago

You’re misunderstanding the purpose of MAME. With very limited exceptions, MAME does not emulate virtual machines, it documents and emulates real machines and the software that ran on them.

In reality, the behaviour of a CHIP-8 system depends on the real machine it ran on:

There are also behavioural differences between implementations of CHIP-8. The CHIP-48 interpreter that resulted in CHIP-8 regaining attention differed from the original COSMAC VIP in significant ways, and a lot of modern CHIP-8 software assumes CHIP-48 behaviour.

MAME emulates systems that included or supported CHIP-8 environments, ranging from the COSMAC VIP where it all began, to the HP-48 that revived it with CHIP-48, to PC systems, allowing you to experience CHIP-8 software in context.

ghost commented 2 years ago

1) it's useless to emulate the hardware that runs a virtual machine. Google for chip-8 emulator in ANY language, you won't find any hardware emulation. Only the virtual machine is emulated

2) chip-8 and super chip-8 require 2 diferent emulators. Hardware INDEPENDENT. It has nothing to do with the hardware. The second is an update of the first and therefore not compatible

3) please give me a rom example to proof your first 3 points. Until you give this to me and indicate a so called 'native code' inside this rom, unaccessible of course because of the virtual machine, those things belong in fairy tale land... THE CHIP-8 opcodes only do things on the virtual machine registers, stack, ... You can find the opcodes online.

4) the last point is correct. Again a virtual machine has nothing to do with the hardware it runs on. A chip-8 ROM doesn't care and also don't 'know' on what hardware it runs. Every software is dependent on the host hardware, also mame. You can't do anything about this. It has nothing to do with emulating the opcodes in a chip-8 rom.

You are not capable of leading a project as mame because of the nonsense you say.

And finally mame preserves game history. Chip-8 is a BIG part of it. It belongs certainly in mame. Game history must not be split in real hardware or virtual machines to decide what's in or not. Mame in fact is a virtual machine on itself...

ghost commented 2 years ago

Chip-8 is actually SO important because of the enormous time span it took and pickup up later again by much more modern hardware. Even today enthusiasts use it So it would be a crime not to include chip-8 and super chip-8 into MAME. I guess you like to commit crimes against the preservation of gaming history...

Closed. I won't even read your answer because you can't proof the first 3 points you say.

ajrhacker commented 2 years ago

MAME already does emulate hardware purposely designed to run specific virtual machines. For instance, the mk1forth driver emulates a simple homebrew TTL CPU (http://www.aholme.co.uk/Mk1/Architecture.htm) that runs a FORTH interpreter which is itself written in bytecode.

cuavas commented 2 years ago

CHIP-8 was written by Joseph Weisbecker to provide a simplified environment for users to write their own games on the COSMAC VIP. Many implementation details and characteristics of the original host system are exposed:

Implementation details leaked in other interpreters, too:

MAME preserves technology history, which CHIP-8 was an important part of, being an accessible way to develop games for cheap, limited home computers from the mid ’70s to early ’80s. The simplicity meant it was easy to develop an interpreter, it didn’t need a lot of expensive memory, and it didn’t even need a full-size keyboard. These were significant advantages over BASIC on low-cost systems. The names of the newsletters that published the CHIP-8 programs reflect the names of the systems that the CHIP-8 programs were designed to run on (e.g. VIPER for the COSMAC VIP and DREAMER for the Electronics Australia DREAM 6800).

CHIP-8 largely fell out of use after that until CHIP-48 was released for HP-48 graphing calculators in 1990, followed by SCHIP. At this point, it was more or a curiosity than anything else, providing a easier way to write simple games than using SysRPL. Interest in CHIP-8 as a simple introduction to writing a virtual machine or bytecode interpreter is largely a response to documentation published by David Winter, who also wrote CHIP-8/SCHIP interpreters for HP-48 and PCs.

CHIP-8 isn’t really part of gaming history, it’s part of hobbyist computer history. You can only really understand and appreciate it in the context that lead to its development. MAME emulates all the major low-cost computer platforms where CHIP-8 emerged, as well as the HP-48 calculators where it experienced a renaissance.

cuavas commented 2 years ago

Oh, and by the way, most of this is very well-known, and can be gleaned from the relevant Wikipedia page: https://en.wikipedia.org/wiki/CHIP-8

You can still read David Winter’s highly influential document: http://vanbeveren.byethost13.com/stuff/CHIP8.pdf