Welcome

Conclusion

In the end it took quite some hacking, but the result is nice enough: I can play Zork on an AVR!

It's... not really quick, though. The time from bootup to where I took this screenshot is about 30 seconds. Ofcourse, stuff like memory and SD-card-access could be optimized a bit more by e.g. adding a bit of cache, but I'll never get the same speed as the original: the AVR is just too slow to handle the realtime emulation needed, just as expected.

The emulation isn't completely 100% either: some programs tend to crash or act up, most of the Z80-specific instructions aren't emulated yet and the BIOS still bugs now and then. I was actually thinking of solving these problems and including more functionality like an integrated VGA-out and keyboard in, and maybe using disk-images instead of raw SD-cards... but then I stepped back and remembered I was writing a proof-of-concept emulator for a system that's already emulated a hundred times better and faster on a random PC.

Anyway, in case you want to build this curiosity by yourself or just want to see the sources: as usual, it's all licensed under the GPLv3 and downloadable here. I'd, as always, appreciate a message or email if you actually manage to do something useful with them.

« Prev 4 

28 comments

Luke wrote at 30 Jul 2022, 16.21:

Sorry if the question is stupid but what would it take to have CP/M run directly on the AVR? The CP/M source code for M68000 in C can be found on this page [0]. Theoretically, it could be compiled for AVR. Then you would need the BIOS to handle the particular hardware of you setup (RAM, IO, etc). I'd be interested to know what you think of this idea. [0] http://www.cpm.z80.de/source.html

JT wrote at 13 Aug 2021, 2.58:

Ive been toying around with the idea of trying to make a clone of a 80s synth. Its running on a z80. Would using this method to emulate the ROM of that synth work?

daltondickey wrote at 12 Jun 2021, 7.59:

i vote sprite nobel sheeesh prize for literally being mind blowing remembering tricks and tips so us noobs don’t fuck up, can i ask a personal question . you gotta pull that all time sweetest nootch ever? i’m not being sarcastic chicks dig intelligence, and he’s humble i mean looking at comments he don’t get mad when repeating shit

Vasya wrote at 16 Feb 2018, 18.02:

Does not work https://my.mixtape.moe/xwnggc.png

pureoxy wrote at 21 Feb 2017, 12.35:

It's same like Pseudo disk for apple II card. So I think it's become for SS-50 or ISA bus interface more better. Do you think so?

Mark wrote at 19 Feb 2015, 6.34:

Since SD cards have WAY more capacity than any disk available in CPM days, I would just use 128 bytes of each 512 byte SD card sector. Yep, wastes 3/4 the capacity of the card, but who cares. Should also be faster and cause less wear to the SD card... no need to do those read-modify-write cycles.

Jeroen wrote at 16 Jun 2013, 14.10:

You know what would be cool? Putting this on an arduino (UNO) with TVout libary enabled :D

Sprite_tm wrote at 19 Apr 2012, 11.13:

LWATCDR: That\'s not really possible, the AVR isn\'t able to execute from RAM and re-flashing a bit of memory every time the program would drop to avr-mode isn\'t feasible either. The \'peripherials\', however, work in a way that minimuize the amount of BIOS-code needed, so there\'s not too much to gain there anyway.

LWATCDR wrote at 16 Apr 2012, 13.04:

A trick you could use would be to create an opcode to drop into AVR mode. That way you could write the BIOS in AVR asm and gain a little speed. Really a fun little project you did.

James wrote at 8 Feb 2012, 22.44:

Your my hero!

Peter Sieg wrote at 8 Aug 2011, 21.04:

This is the progress so far: http://avr.cwsurf.de/?AVR_CP%2FM http://www.mikrocontroller.net/topic/177481 http://www.mikrocontroller.net/articles/AVR_CP/M Peter

Sprite_tm wrote at 13 Jun 2011, 8.04:

Ivan: Sure, if you change the firmware you could even use core memory as the RAM... just write the drivers. Any other DRAM-chip with about the same specs as the GM71C4256A will work too, though, just raid an old XT or 286 mobo or some 30 pin SIMs.

Ivan wrote at 11 Jun 2011, 21.14:

Too difficult to find DRAM GM71C4256A. Can use SRAM instead? Chaging firmware emulator?

sist wrote at 10 May 2011, 17.50:

As I am a bit older, CP/M-80 was the first OS I got to know. And many times I have been considering to do what you did. Zork brought back the memory of a large piece of paper being te result of many nights playing the game. Wow. And you say it is not quick; a 2MHz 8080 and 8-inch floppies (with head loading klunk!) may well take more time to boot. Thank you for the smile you\'ve given me! Simon.

relef wrote at 13 Oct 2010, 22.07:

Great Work! Sounds interesting! I am keen to try it myself.... Perhaps with another chip .... ARM or something like that.

heater wrote at 29 May 2010, 11.12:

Fantastic piece of work. I also started out with just 8080 emulation on the Propeller chip. All you need for CP/M. After some encouragement from the Parallax forum folks it became a (almost) full Z80. Since then Pullmoll there has done a full Z80 on the Prop. If you want to shake out the last op code bugs the SIMH AltairZ80 project has CP/M disks with an instruction set test program EX8080.COM. Find it here: http://www.schorn.ch/cpm/intro.php Lots of other good CP/M stuff there also.

Ray Moore wrote at 8 May 2010, 12.57:

The atmega8515 might be a good solution for this as it has a built in 8-bit external ram interface. Might help cut the code down some not having to deal with the read/write interface to the ram. Just a thought. Ray Moore #emr (electronics, microcontrollers, & robotics) on irc.magicstar.net

Ben Zijlstra wrote at 4 May 2010, 7.39:

If you connect a atmega32 terminal to it, it would be nice. Check http://www.sbprojects.com/projects/apple1/a-one-terminal.htm Compiled with SB-ASM.

toby seckshund wrote at 29 Apr 2010, 19.40:

Great work ! I have often thoght of a \"Z80\" emu on an AVR. I follow the Propeller emus and keep thinking of using an old DRAM instead of latched statics (the lack of interupts makes refresh tricky, to my \"brain\") I am planning to try an old EDO chip, then perhaps a SDRAM if any of it works. The AVR will suffer overclocking I once push a 20MHz 168 upto 32MHz by mistake (at 5V)instead of 16MHz, It gave four little pictures on the monitor.

carlos - www.msxhardware.com.ar wrote at 28 Apr 2010, 22.33:

Fantastic work my friend! ;)

Sprite_tm wrote at 28 Apr 2010, 20.06:

Crisp: Hmm, I didn\'t know that, thanks :) abraXxl: I don\'t know off the top of my head, but it emulates a 64K machine, so you should have the maximum TPA CPM2 allows.

Crisp wrote at 28 Apr 2010, 20.02:

Just a Info the Atmega 88 PU can be overclocked to 32MHz with a Crystal Oscillator (tested at 5V) the new Atmega 88 PA revision even runs at 40MHz (5V) so maybe that helps in speeding emulation a bit up ;-)

abraXxl wrote at 28 Apr 2010, 18.32:

Hi, cool idea. I like too build that too. How big is the TPA in your emulation?

sak wrote at 28 Apr 2010, 8.58:

Congratulations. Quite an achievement imho.

Sprite_tm wrote at 28 Apr 2010, 7.07:

Michael: Theoretically, yes. I read that not too many cards actually support that command, though, so I decided to optimize for compatability and keep the blocksize 512bytes.

Michael wrote at 28 Apr 2010, 0.09:

Isn\'t it possible to use SET_BLOCKLEN (CMD16) to change the block length read/written to 128? Or is there something I\'ve overlooked? Either way, this is a really neat project!

Ken wrote at 27 Apr 2010, 21.13:

Well done! I am old enough to have owned 2 Z80 machines (Kits) when they where new. I was also thinking of porting the Zork engine to an Arduino with a 20x4 LCD and a small keyboard. Congrats Ken

Front a little wrote at 27 Apr 2010, 17.43:

MC Frontalot - It Is Pitch Dark http://www.youtube.com/watch?v=4nigRT2KmCE

Leave a comment:

Your name:

What does this picture say?
Sorry, this is a captcha

Your comment:


© 2006-2022 Sprite_tm - Contact