What's new

Chip 8

refraction

PCSX2 Coder
Doomulation said:
*Cough*
Ascii output, huh? There just isn't enough space to output using cout or such functions.


actually its very possible, its just quite slow, as you can see from the screenshots from my emu HERE :p

this document is the only one you need, ive added a couple of comments in case of confusion on some of the op codes.

Chip8 Documentation
 

Villela

New member
Doomulation said:
No of course it isn't hard. Nothing is hard once you learn it, but in the beginning it might be. What other ways?
Puting the rom in a long char array


Doomulation said:
Ascii output, huh? There just isn't enough space to output using cout or such functions. Besides that, on more complex emulators (even gameboy) it is a MUST to learn this. Ascii won't do. Sound *IS* necessary, although not that much in chip8.
Its just chip-8, sound can be a beep beep, not emulating the sound will of course make the emulator limited but will not make you unable to emulate chip-8

Doomulation said:
Just putting in random input is cheating and you won't learn anything from it.
You learn the instruction and will implement the imput instruction, just from another way

Doomulation said:
You need to get the emulator working to get an understanding on how the real emulators work, to trace DOWN BUGS, etc etc. No, you need to learn it a little more than just get it working actually...
A simple and incomplete emulator don't need to have bugs, but can make the one who does learn the basics of an emulator



@refraction: nice :)
 

Doomulation

?????????????????????????
Villela said:
Puting the rom in a long char array
Each instruction is two byte. Do you want to put it in a WORD array? If you do, what if the gfx data is no even-addressed? You need bifts, bytes & shifting anyhow you do it.

Its just chip-8, sound can be a beep beep, not emulating the sound will of course make the emulator limited but will not make you unable to emulate chip-8
I agree somewhat with you there. Chip8 only has a beep sound, but still, it would be a good thing to emulate the sound opcodes.

You learn the instruction and will implement the imput instruction, just from another way
I mean, you won't learn how to do real input ;)

A simple and incomplete emulator don't need to have bugs, but can make the one who does learn the basics of an emulator
Well, then you miss out essential parts needed for experience of a more advanced emulator, see?
 

Villela

New member
the long char array: convert it, when reading you do an array like: long char rom[] = "00E0621A...." i don't know how can be do it in C or C++ but i believe it can

the soud: yes it will be nice to emulate all, put a beep beep message in ascii

input: will not learn to make an input but will learn how to emulate the chip8 input


What i'm saying is that someone don't need to do a chip emu to play or to the others play, and if find problems or things that don't know how to do can do an alternative way, if someday the one learns how to make an imput and grafics in other output he can go there and emulate correct, but isn't the way you do the things, what matter is doing the emulator and learn
 

Doomulation

?????????????????????????
How do you suppose to convert it, then?
int smthing = (int)memory; // Will convert only that char
int smthing = (int)(memory + memory[i+1]); // Wonder if it does work?

Besides, there are instructions that wants you to shift bits in strings. Although this can be done with division or multiplication, it's much more expensive in time rather than shift.

About input...you know, knowing how to use & recieve input is all part of the training...it's not something you really want to be without. It can be used for many things, in many applications.

Of course you can do things an alternate way, that's how emulators work. They don't do it exactly like the consoles does, they do it an "alternate" way, which achieves the same result.
Say, if there's a bug that causes some games to go weird, what do you do to fix it?

All these parts are essential to making a more advanced emulator. If you can't find the simplest bugs, then probably no game at all will boot in any emulator you make. And that's no experience since you don't get it right...
 

euphoria

Emutalk Member
Doomulation said:
How do you suppose to convert it, then?
int smthing = (int)memory; // Will convert only that char
int smthing = (int)(memory + memory[i+1]); // Wonder if it does work?


int wSmthing = *(int *)&chMem; // makes integer out of char-array element
long dwSmthing = *(long *)&chMem; // makes long integer out of char-array element

There are other ways ofcourse, this was just an example.
 

Doomulation

?????????????????????????
Right, didn't think of that. I have used that method once, though.
I suppose it can be done without shifting in chip8, but for other things, such as wonderswan (oh, I've seen it), it's pretty damn hard without shifting and logic understanding.
 

ector

Emulator Developer
euphoria's method depends on the endian-ness of your processor though. On x86 (little endian) the low byte comes first, on PowerPC and many others the high byte comes first.

BTW, I don't understand why people are making such a big deal of nextgen emulators. In fact, I went from Chip8 to Gameboy to nextgen. Granted, I do have a lot of other coding experience but if you understand the concepts, the only difference about nextgen emulation compared to emulating older systems are the immense speeds of the newer CPU:s and the complexity of some systems. The Gamecube is actually one of the "simplest" consoles above 8 bits to ever come out. The real challenge with the Gamecube lies in the insane CPU requirements of emulating the 485MHz PowerPC at full speed, and reverse engineering the graphics chip (it's pretty damn complex but nothing I can't handle, in theory at least :) ) . And of course the sound has to be HLE:d since the DSP is completely unknown.
 

euphoria

Emutalk Member
ector said:
euphoria's method depends on the endian-ness of your processor though. On x86 (little endian) the low byte comes first, on PowerPC and many others the high byte comes first.

BTW, I don't understand why people are making such a big deal of nextgen emulators. In fact, I went from Chip8 to Gameboy to nextgen. Granted, I do have a lot of other coding experience but if you understand the concepts, the only difference about nextgen emulation compared to emulating older systems are the immense speeds of the newer CPU:s and the complexity of some systems. The Gamecube is actually one of the "simplest" consoles above 8 bits to ever come out. The real challenge with the Gamecube lies in the insane CPU requirements of emulating the 485MHz PowerPC at full speed, and reverse engineering the graphics chip (it's pretty damn complex but nothing I can't handle, in theory at least :) ) . And of course the sound has to be HLE:d since the DSP is completely unknown.
This must be nothing new to you ector but to others interested (if any?) the endianess situation can be solved like this:

int wSmthing = *(int *)&chMem[i ^ a];
long dwSmthing = *(long *)&chMem[i ^ a];
where a is a number that corresponds to what we want to XOR.

The XOR binary operator turns the wanted lower bits to what we want when accessing byte-swapped (^1) or word-swapped (^3) or byte&word-swapped (^2)

Example: we have address 0x0000 which is byte&word-swapped. We want to access its first byte (which is in address 2) we apply 0x0000 ^ 2 = 0x0002,
second byte 0x0001 ^ 2 = 0x0003,
third byte 0x0002 ^ 2 = 0x0000,
fourth byte 0x0003 ^ 2 = 0x0001.

If you play with it for a while it comes apparent to you how this works.
 

ector

Emulator Developer
Stick to shifting; what euphoria proposes just won't work. The XOR will fix the *starting* address of the large read, so one byte will be right, but the rest will be wrong.
 

euphoria

Emutalk Member
ector said:
Stick to shifting; what euphoria proposes just won't work. The XOR will fix the *starting* address of the large read, so one byte will be right, but the rest will be wrong.
Yes, you're right. I was only thinking of byte-sized reads but at the same time wrote code for 4-byte-sized read :doh:
Like ector said it's best to stick with per-byte reads and shift and AND them together.
 

Doomulation

?????????????????????????
Yeah... so, making an emulator without shifting and logic understanding isn't a good thing.
I didn't get HOW that method worked, anyway.
 

-//zAe\\-

New member
Well, it would be great if you will continue this topic. I am about to code my own chip8 emu ;) and this topic is quite usefull for me.
 
OP
sammyboy

sammyboy

Certified SuperHero
Could you keep us informed on all your latest progress. The emul;ator will prbably (at the most) only take you a couple of days).
 

-//zAe\\-

New member
sammyboy said:
Could you keep us informed on all your latest progress. The emul;ator will prbably (at the most) only take you a couple of days).
Well.. yes! As soon as i will gain a few days of free time to spend :(
And you? Have you already done your Emu?
 
OP
sammyboy

sammyboy

Certified SuperHero
-//zAe\\- said:
Well.. yes! As soon as i will gain a few days of free time to spend :(
And you? Have you already done your Emu?

I cant I realised (looking aty the comments on download.com) that my compiler doesnt have the functions for emulation deving. Anyways I am getting Visual Studio.net on Thurs so YAY.
 

Doomulation

?????????????????????????
Hehe, all you need to do a chip8 emulator, huh?
Damn, only a couple of days to do the emulator, but to get it perfect? :p
I still have bugs in the core which I can't be arsed to iron out.
Meh. Well, if you're wondering something about the chip8 system, don't hestitate to ask.
 

Top