Interviews



Interview with Miha Peternel

Published in Vandalism News #52
Performed by Georg Fuchs
Translation by Arndt Dettke


Featured originally in the Lotek64 Issue 21, now available for the first time in English through Vandalism News. Miha Peternel was born in 1974 in Kranj, Slovenia. He started programming at the age of 9, wrote his first mainframe program at 15 and has been involved in software projects ever since, including emulators, networking software, 3D game engines (for PC, Playstation and Playstation 2), video compression (for PC and Dreamcast), industrial inspection, industrial computer vision and academic computer vision. He has won national programming contests at elementary school, high school and university (team) level. He has worked in Slovenia, USA and Japan...



V)
You are well known in the C64 and emulation community for having coded the first MS-DOS based, "real" C64 emulator. The project C64S was started in 1991 and it was the best emulator around for a long time. Did you start from scratch or have you worked on similar projects before?

M)
I started coding from scratch. I read about an Amiga based C64 emulator and I was aware about its many limitations. I became acquainted with emulation when running ZX Spectrum emulator on C64. So when I got my first PC I made a decision to code a C64 emulator. I got a few hints from a simplistic C64 emulator that appeared on BBSes, I could look at the code and see what changes were made in the ROM images. But rather quickly I built a serial connection to transfer the original ROM images and my huge software library which then provided compatibility test material.


V)
What does the "S" stand for?

M)
S stands for software.


V)
Writing an emulator is not a trivial task. Where did you get your knowledge and when did you start using a real C64?

M)
I got my C64 when I was 10 years old -- I was in the 4th grade. As ROM BASIC didn't do what I needed or what I had learnt on ZX Spectrum, I started poking around and in the 5th grade I started programming in assembler. Then I bought all the books I could find about the internals, ROM listings and so on. Computer magazines in former Yugoslavia were high quality at that time, and they included programming sections. I guess I learnt about 75% from hobby programming and 25% from the magazines. I wrote my first compiler in the 7th grade, only to be told years later that I invented LR(1) parser. I coded a decent side-scroller in the 8th grade, but then slowly the PC world became more interesting. In high-school I would spend weekends coding C64 intros, so I learnt about the importance of timing in emulation. I read some university level books about computer architecture and later I also had access to HP library in Fort Collins (where PA-RISC was developed), so I had a good idea of how hardware functions. I must emphasize the contribution of Marko Makela who managed to document a lot of the lesser known C64 features. Still, it took hundreds and hundreds of targeted test routines to reverse engineer everything that was not obvious from available documentation (and many times the documentation was flat wrong).


V)
In 1993 C64S became shareware. A German site still offers it for 19 Euros. How many registered users are there? Are people still registering? Will it ever be freeware?

M)
Registered users count in the thousands. DOS is now ancient, but there are still a few new registrations per year. C64S will not become freeware in the near future, I will probably release source code when I get too old to continue coding.


V)
Some standards and file formats (PRG, I'm not sure) in C64S are said to be your invention. What formats have existed before you started and what were your additions?

M)
With C64S I standardized two file formats: T64 for tape images and D64 for disk images. D64 was at first just a flat disk dump of a standard 1541 floppy disk which was also used by an older C64 emulator, but I later extended it to support half-tracks, extra tracks and GCR coded tracks. I introduced T64 for compact storage and efficient access of tape files.


V)
The virtual 1541 was one of the great concepts in C64S. Software that couldn't run on emulators (like the Magnetic Scrolls adventures which made use of the 1541's CPU) before was now working perfectly. Was it hard to make this work in MS-DOS?

M)
Yes, 1541 emulation was a major subproject. I did get commented ROM listings from which I could reverse engineer the low level disk format and memory organization, but 1541 hardware internals were very unclear. I spent weeks writing reverse engineering tests that would flip some VIA registers and check results. Luckily turbo loaders and many protection schemes used undocumented features, so I could find out how they were expected to work. As for the PC coding there was just enough DOS memory to stuff 1541 emulation along C64 emulation, but the code itself is convoluted cooperative multitasking code that would take me months to decipher.


V)
Nowadays there are a lot of emulators for all modern platforms, especially for Windows. Some are commercial, while others are freeware like the popular (and frequently updated) VICE which emulates not just a C64 but many of Commodore's 8 bit computers. Have you ever thought of joining one of the teams or did you move to different things today? Do you use one of these emulators yourself?

M)
I did take a look at VICE, CCS64 and FC64, manly to see how they organize and do things. I use none of them, because I do have an alpha version of C64S for Windows. (I may provide an exclusive screen-shot for Lotek :)) I have very little time for C64 related developments, so I haven't even thought about joining any team efforts. I moved on to other projects -- I worked on 3D engines in the game industry in Slovenia and Japan for a few years. I've been also working on computer vision, industrial inspection and networked applications.



V)
In the middle of the 90ies there was even a free  C64S hotline in Germany where registered users would get support. Did you ever expect your emulator to be so successful?

M)
When I started developing it I knew a lot of people would appreciate using it for nostalgic reasons, still I was positively surprised by response. Everyone that could copy a floppy seemed to know C64S and it was a very popular BBS download. Michael Penzkofer did a great job on marketing it in Germany, unfortunately the income from registrations was not enough to sustain development for living indefinitely.


V)
Is C64S finally abandoned? The latest (German) FAQ I found is from 2001.

M)
C64S is not abandoned, but development continues at snail pace. The last major revision of C64S was coded in 2004, then last year I reverse engineered sprite functionality to the last cycle and bit, but I have not had time since to put it in code. The reason it has not been released is that it lacks features in some important usability areas. DOS version prioritized speed over 100% compatibility, but these days there are enough cycles to emulate everything. However, such a perfectionist approach takes a lot of time.


V)
On your "very old" homepage you state that "music is the only drug". If you still love music a lot, records do you recommend our readers?

M)
I'm one of those people with the broadest range of musical taste from electronic, metal to vocal and classical and everything in-between. I think Lotek readers will enjoy 8-bit Operators which is a CD full of remakes of Kraftwerk music using vintage 8-bit consoles and, of course, C64. When C64 fans talk about music they always come to talk about the great SID chip and the fantastic music which was (and actually is) written for it.


V)
Emulating the SID is said to be one of the hardest jobs in emulation. Can you tell us something about your quest for the perfect SID sound in a non C64 environment?

M)
I believe SID sound was one of the greatest C64 features, I'm still surprised how some minimal house demo tunes with filters
and old C64 tricks sound just like what you hear in some nightclubs today. I did have a collection of hundreds of tune rips on C64, which I wanted to reproduce using C64S. Then I got Scream Tracker on PC which was a revelation. I printed out machine code during a summer job and I can still remember the puzzled looks of folks around me while I was studying that piece of code on a bus station. So I coded beeps, then I reverse engineered envelopes, and then I sampled SID waveforms. PC beeper was screaming, so when I upgraded to Sound Blaster I improved waveforms and mixing. When Gravis UltraSound came out, I got a free developer kit and I thought the rewritten GUS SID emulation was spectacular. A few years ago I coded a SID rewrite that's better still, yet there's still room for improvements. New PCs ship with higher-frequency audio output which improves sound a bit. Theoretically one could also characterize analogue output of SID output filters, but I don't have the equipment to do it.


V)
In case you are one of those SID freaks, what are your favourite composers and tunes?

M)
There's a ton of songs I like, but I don't know all the composers. I can remember Hubbard and Galloway. My favourites are several game tunes from Commando, Rambo, Last Ninja and Cybernoid. There's another spectacular tune which was ripped under the name Spijkerhoek, which I used over and over to improve SID output. From the intro/demo scene I love a tune from Inc and one of the late Ikari&Talent tunes.


V)
You had a Spectrum before you got a C64. What platform did you prefer as a coder? And what do you think about the "issues" between Commodore and Sinclair users that is still going on?

M)
I never owned ZX Spectrum personally, but three of my cousins had them, and we had two at school. I liked Sinclair Basic at the time, it was quite powerful. I bought C64 on recommendation of technical superiority. When I learnt assembler and hardware tricks, I found it clearly superior, though ZX Spectrum's CPU might have been more powerful. These days I mock colleagues from the Sinclair camp by calling them "traitors", though I confess wasting many days using Spectrum emulators.


V)
Are you serious, C64S for Windows? This is important news. Is there anything you want to reveal about the project?

M)
The current version of the core emulator is already the third 32-bit rewrite which started in 2002. I started it as a hobby project simply because throwing away all the emulation knowledge would be a waste, as such I can afford to work on it for less than 10 days a year. The philosophy of the project is to be anally true-to-original while providing user friendly interface. It is half-cycle exact and already very compatible, but it still lacks a rewrite of some VIC code, disk image write functions, and much of envisioned GUI. Fully featured emulation will require 2GHz CPU and DX9 compatible graphics hardware. There are two unique features I will not reveal.


V)
Is there anything else that can be done to improve C64 emulation?

M)
There are two things that are becoming important as new PCs are losing the ancient LPT connector. One would be standardizing on a cheap programmable USB IO controller that would allow C64 emulators to interact with C64 peripherals. The other thing is concerning 1541 disk imaging. I think these days it's perfectly reasonable to scan the tracks right at the disk head similarly to how tape originals are imaged.

http://phs-edv.de

[back]