What's new

Chip 8

smcd

Active member
OK just wanting to clarify that since it wasn't mentioned in your post (that I saw) and on an unrelated note the values i used as a demo happened to have some weird results (completely random out of my head, i swear!) "and 6 = 0666" haha
 

hap

New member
I've also noticed that at some points there are jump instructions to below 0x200, as is now I'm ignoring opcode reading from below 0x200 so it doesn't interpret the fonts as opcodes
The VM contains 4KB of RAM, a program should be allowed to write or read anywhere in that space, so theoratically, a jump below $200 is possible, though I don't think any program actually does that.

I had a quick look at your source code, and one problem I saw was the use of carries I discussed a bit earlier in this thread with Garstyciuks:
carry calculation for every math opcode should be done after register calculation, and not before, because vf may be used in maths, eg:
ld vf,1
shr vf
vf will be 1 again
 

hwave

New member
I've moved all carry calculations to after register calculations now. I remember reading something like that in this thread somewhere now that you reminded me :)

I corrected a small logical error in subroutine jumping, I made it return to the exact location of the subroutine calling so whenever it was supposed to return it got stuck in a loop :p After fixing that I can get ingame and shoot aliens in space invaders :) By the way, is space invaders supposed to seem so slow? The bullet I fire only move at the same time the aliens move, doesn't seem very smooth. It may be that it's coded that way though.

How did you handle the controls? I've changed it slightly since the version I attached to my post last page, I made a variable that gets set to true so I check for the keypress not just the instant it reads the opcode but all the time till the next opcode. But even with that I am forced to hold the button down a while to get the games to recognize what I'm pressing.
 

Garstyciuks

New member
I wanted to remind him too about that register stuff. But anyways, all the games were working fine all along with it made incorrect. I believe that none of them use arithemtic operations on VF, but there could be exceptions :p

I did the input the same as you did - keydown is set when the key is pushed and it gets cleared when the key is released. When my emulator encouters a keyboard check opcode, it checks the status of keydown array. And it seems that input is doing quite fine.
 

hap

New member
About the Space Invaders speed: it's up to you to define the speed of your interpreter, I'd say about 500 opcodes per second is fast enough for standard CHIP-8.

I believe that none of them use arithemtic operations on VF, but there could be exceptions :p
It's handy for 16 bit addition, Sokoban uses it :p
 

hwave

New member
That was a great idea. I had built the emulator using a simple fps limiter. I redesigned it to perform 500/fpslimit ops and that solved the slow feeling of the game :) I didn't think of doing it that way before. Thanks!
 

hap

New member
If you wrongly generate a carry before doing the maths, the first few levels should still work (16 bit addition is used to calculate the level offset), so that shouldn't be the reason it doesn't work at all.

Of all other emulators I've tried it on (many), it only works correctly on HP48 SCHIP, and on DarkChip 8. Could you post your current source/binary I can have a look at?
 

Garstyciuks

New member
I didn't have a lot time to fix the flag generation, so I did it in quite a lame way, which may even be incorrect. But anyway, here's the source code for it. I may completely remake my emulator at some later time.

Edit: omg, forgot to attach the source ^^
 

hap

New member
and the current binary? (executable), with debugger enabled
I can't compile it, I don't have Visual Studio 7
 

hap

New member
The first fix already should make the current version of Sokoban work, I haven't looked at why the previous (a1) version locks up.

Code:
cpu.h, line 136:
i = ((u16)(memory.reg[opcode & 0x0F00]>>8) + (u16)(memory.reg[opcode&0x00F0]>>4))>0x00FF;
you've made a mistake with brackets, a carry will never happen here

cpu.h, line 179:
memory.pos = opcode & 0x0FFF + memory.reg[0];
I don't know, but it might prioritize + over &, so place parentheses

overall:
Try to avoid possible overflows from happening, like over 16
nested subroutines happening, or the index register overflowing,
or a >1 bytes memory read/write from offset $FFF (opcode Fx55/56).
 

Melvo

New member
SpeedChip...

Hello to all of you, I've finished my Chip8 Emulator, I named it SpeedChip :p
Right now it only emulates Chip8 but I'll soon upgrade it to SCHIP :)
I think it fully emulates Chip8, please, test it and tell me if you found any bugs...
If you think you have found one, try playing first with the menu options, like for example: In Maze, if you don't select 'Use AND Operator' it will not work right...
I didn't made a debugger, my bad here, I'll release the executable only for now, when I upgrade to SCHIP I'll post the source along with the executable, so anyone that is trying to make theirs can take a look at my source and see if they are doing it right.


Suggestions and Opinions are welcome :)


BTW, This is my first post here.
 

Garstyciuks

New member
It seems to emulate everything quite nice. But I still found a bug, not related to chip8. When you drag your window outside the screen, or put some other window in front of your chip8 window and then restore chip8, nothing is drawn. (This is only for those games which have menus and don't draw anything more after the menu is drawn)
 

Melvo

New member
@Garstyciuks: yes, i know that, but remember, that's only when the game is waiting for a key, which I don't want to draw anything at that moment.

Reason: Kill Cpu Usage...

BTW, thanks for taking a look :p
 

Reaper666

New member
Right now I'm working on a Chip8 emu specifically for the Logitech G15 keyboard, or I suppose similar devices would work, but it will display on the keyboard's screen and might be useful if you play pc games on the net where you can get eliminated and you have to wait and wait until the game ends. So far I'm about into a day of actually programming it, so far it works on the console but gotta work on making it work on the G15 screen, should be ready for release in a day or two. One thing I want to do is make the "G keys" work as keyboard input instead of using regular keys, since there's 18 of them and they're basically extra keys. If anybody knows if they do/can, or how to make them work as unique keys(unique scan codes) instead of just macro keys please tell me.
 

Melvo

New member
SpeedChip Emulator

Okay, I finally finished my emulator :)

I have to thanks Garstyciuks for his debugger which helped me track bugs.

My Emulator emulates CHIP8/SCHIP now.
I didn't do the half pixel stuff because it was a pain in the ass (didn't found any game that used it anyway) and I thought the way I was doing it could slightly slow the emulator's performance which that will ruin it's name lol.

Everyone used some different way to draw the graphics, so I did :p, I used bitmaps (If you notice, sprites aren't of a single color, they have a little fade :)).

It took me a month to begin with emulation and finish this thing. :)
(Note: I wasn't new to programming, only to emulation)

And 4 days to upgrade it to SCHIP...

If you find any bugs related to anything, please let me know.

Ok, enough talk, here's the source and binary:


Enjoy.
 
Last edited:

Doomulation

?????????????????????????
There are a couple of super chip games that uses pixel shift. Mostly for scrolling. Like car... or that space chip... or ant...
 

Top