What's new

Chip 8

Doomulation

?????????????????????????
|\/|-a-\/ said:
i use my emu as an debugger. the instruction points to hex char sprite 0x20 (in V1 i think). but you said, there are only 16 chars fopr showing the score. this shows me i still don't know how this works
Probably means you have implemted a bad instruction somewhere. This is a common case for errors such as these.
 

Doomulation

?????????????????????????
Fonts are basically just data stored in the memory. When the instructions says to point to a font, I is set to the address. When the draw function is called, it will draw out fonts from the data. Check out a source of an emulator to see how the fonts are done. It's quite easy.
 

|\/|-a-\/

Uli Hecht
ah, i think i understand now. you think the V1=20 is an error, because only 0 to 0xF are possible values. i don't know how you do, but i'm searching for that bug for days. and how is it possible to find that bug in a greater project like a nintendo64 emu for example???
 

refraction

PCSX2 Coder
|\/|-a-\/ said:
ah, i think i understand now. you think the V1=20 is an error, because only 0 to 0xF are possible values. i don't know how you do, but i'm searching for that bug for days. and how is it possible to find that bug in a greater project like a nintendo64 emu for example???


by use of logical thinking and a good debugger, also trying a few different things is always a good idea.

as for your bug, my mind is telling me to look at your BCD code, its possible that isnt storing the figures correctly, altho i could be wrong.
 

Doomulation

?????????????????????????
I catched most bugs in the emu by stepping thru a debugger. I could catch when the invalid value was written to a register. If you're too lazy to write an own debugger, there are sources posted here that has debuggers, which you may use.
 

ChaosBlade

My Heart Chose.. Revenge.
What does a debugger do really ?

It looks like a simply fetching opcodes and writing what they should do somewhere. like, "Oh, I saw opcode 8XXX At 0xTHIS address, should copy 01 to Register V[1]."
 

refraction

PCSX2 Coder
ChaosBlade said:
What does a debugger do really ?

It looks like a simply fetching opcodes and writing what they should do somewhere. like, "Oh, I saw opcode 8XXX At 0xTHIS address, should copy 01 to Register V[1]."


that basically sums it up yes ;p

for example you could say

"i saw opcode 0x8xxx which is an add command, took x from vx and y from vy, result given was z in vz"

then you can see if the result was correct to the original values or whatever.

its very handy tho for keeping an eye on program jumps and subroutines to make sure they are being executed correctly as well.
 

Doomulation

?????????????????????????
Look at it this way... you KNOW that the value ending up in the register is 0x20. But it SHOULD NOT be that way. So, using a debugger, you step thru the code and notice that HERE it moves 0x20 to the register. So, HERE something is wrong.

That's a basic example of what a debugger does. Of course, it can do so much more. A debugger is a tool to HELPS you find the info you need. For example, it can break whenever a specific value is written to a register. It's pretty much what you code it to be.
 

hap

New member
I've made a BMP viewer for chip8/s-chip. It'll only work with monochrome bmp's of course, and you'll have to chop the header off. change 00ff to 1202 at offset 0 for chip-8 resolution bmps. See attachments.

as for my emulator, fish n chips, it has had some new versions since i posted it on here (several pages back). main additions are sound, able to change colours, and a rewind feature. you can get it at my homepage: http://hap.samor.nl/

*edit* url changed (and again)
 
Last edited:

Sdw

New member
MobiChip8

I'm currently writing a CHIP8 emulator for cellphones in J2ME (Java for mobile devices). The emulator (which I have ever so cleverly dubbed MobiChip8) is working OK, I've yet to add sound and SCHIP8 capability, but I have some problems to sort out first.

The emulation speed seems fine, that is games play at what feels like a correct speed (my implementation of delay should be OK) but input repetition seems way too fast for some games. Say you try playing "Tetris". When you press "4" (or whatever button it was) to rotate the block, it rotates many times in the splt second before you release the button. Same with "Hidden" (as seen in one of the screenshots), the cursor always moves to the extremes.

I think I've implemented the input handling correct by setting 1/0 in the key registers upon press/release, what more is there that could be wrong? Is it just that the author of the game forgot to set up correct delays?

Anyways, some screenshots from MobiChip v0.5 running in the Sun WTK emulator (but it works perfectly on my Nokia 6630 aswell):

chip8-blinky.png


chip8-hidden.png
 

zenogais

New member
Chip8 emulation will always run rather fast, I'd say you should try putting a delay of some sort on your key input, or setting the value manually to zero after checking it and requiring they repress the key to perform another flip. Not sure if the last one will work, but its worth a try :)
 

Sdw

New member
The problem with maunally setting zero or delaying is that you would probably end up with less responsive controls in games like "Invaders", "Brix" and other realtime arcade style game. Maybe I'll add some kind of "input speed" option for the user or something like that.
 

hap

New member
It's due to the emulated CPU speed.

Hidden runs nice at 0.1KHz
Tetris runs nice at 0.3KHz
Brix runs nice at 0.5KHz
and S-chip games usually 'need' over 1KHz.
 

Sdw

New member
hap said:
It's due to the emulated CPU speed.

Hidden runs nice at 0.1KHz
Tetris runs nice at 0.3KHz
Brix runs nice at 0.5KHz
and S-chip games usually 'need' over 1KHz.

Yeah, it seems the problem is that the CHIP8 only has a virtual CPU not running at a fixed frequency, and the gmaes programmers have targeted different speeds. Maybe I'll hardcode some speed/delays associated with each ROM you can load, as I already have to add different mappings for the controls for each ROM, I might aswell add some more...
 

zenogais

New member
If you're going to go that route you might as well create an XML file format for individual ROM control and speed configurations based on message digests of the files and using Java's XML parsing facilities to deal with it. It would be a nice, extensible way to do it and you wouldn't have to recompile the file to add configurations.
 

yosh64

New member
hey

my first post here... anyhows i found some great info in this thread, and lead me to make my first emulator :) my chip8 emulator took only a day to make. I'm not releasing it yet, but plan to... atm it runs too fast, and i found a lil bug i have not begun to try and isolated and figure out yet. but for now im moving onto a gameboy emulator :D <- me think GAMEBOYS ROCK!

I want to thank you all for what i have learnt here, I always thought making an emulator was out of my league, even though I already knew x86 ASM (enjoy doing alot of reverse engineering / cracking)... and been programming for quite some time. but everything made sense and seemed quite simple after browsing over these forums.

now to any new comers, here are the resources i found most useful for making my chip8 emulator. THESE DOCS rocked! CHIP8.htm AND chip8def.htm AND also managed to track down a copy of the GoldRoad Chip8 article chip8.shtml <- which was great! AND finally I found ChoasBlade's source code SOOO EASY to understand, it ROCKED! <- i had to actually force myself not to look at it so I could figure things out for myself :) get it here ChaoC8 v0.5.zip <- i also kinda ported your (ChoasBlade) emu to use OpenGL, as i was trying to get my emu going and wondering if my OpenGL drawing code was working right. :)

anyhows I shell be gone now, and try and stay motivated to get my Gameboy EMULATOR DONE!!!

cyas
 

Top