Quantcast
Channel: Emulators - World of Spectrum
Viewing all articles
Browse latest Browse all 477

writing an emulator-newbie needs help

$
0
0
Hi, this is my first post here. I decided to write a minimalistic emulator of ZX Spectrum-no emulation of advanced peripherals, no emulation of sound etc. All I hope to achieve is to successfully load a game into my emulator and be able to play it. I work under Windows, I'm going to write my application in C or C++. I have the basic understanding of Z80 microprocessor architecture and Z80 assembly, but it doesn't seem enough for me to start my task. I have some questions. I believe they're really basic to most of you and you most likely read them hundreds of times before, but for me, a beginner, answers to them are crucial. I also realize answers to most of my questions are probably spread around different parts of "World of Spectrum" page, but I'd like to have them in one place. Here's what I need to know:

1. Probably the most important one. Assume I work with a particular file containing the game data (.tzx, .z80, whatever). How should I handle them (i.e. interpret their contents in my program)? I should execute consecutive instructions, but "rom" files have some meaningless ASCII characters in them. No big surprise here, I guess they contain binary data produced from asm files by assembler. Still, I don't know how to treat them. An emulator should operate on assembly or machine code, right? Should I disassemble them? Or should I work directly on "roms", read them byte by byte and interpret each value as an opcode or operand?

2. I don't expect my emulator to work with all or even most of the file formats available. I'll be glad if it works with any of them. Which of them would you say is the easiest to handle? .z80 snapshots?

3. How do I emulate I/O? When it comes to Spectrum emulation, most pages I've seen so far usually give detailed information about emulation of Z80 microprocessor/memory, they give full list of instructions/opcodes etc., but they say nothing about emulating peripherals. Where can I find some useful information about emulation of input (keyboard/joystick) and output (screen)? Which asm instructions and memory regions are responsible for it? Simply, how should I do it?

4. I'm afraid to ask this one, because I think it's something really basic. I looked at a few emulator packages found here and there. All of them contained, among other files, a file with "rom" extension-what does it contain? ZX Spectrum bios, operating system, some sort of emulator core? Is this file necessary for an emulator to work? I used nes and snes emulators in the past and they didn't use anything like that (name "rom" was reserved for files with games).

5. Let's say my emulator is ready and I want to test it with some simple programs written by myself, like "hello world". Since emulator operates on files such as .tzx and .z80, how do I produce them from my asm file?

6. I read about special applications for checking correctness of microprocessor/memory emulation. They perform a series of tests to check if all instructions are emulated properly. They probably would be helpful, can you recommend me any?


Thanks in advance.

Viewing all articles
Browse latest Browse all 477

Trending Articles