What's new

Chip 8

aprentice

Moderator
hap said:
it's garbled because you're drawing a 16*16 sprite, while you should draw an 8*16 one, because you're in chip8 drawmode and not in s-schip drawmode.

and the half pixel scroll: the only way to implement this is by doubling the chip8 low resolution i guess, making it 128x64 like s-chip.

It still doesnt show right even if 8*16..
 

hap

New member
A bug's in the way then. A quick cut n paste job on your attached image reveals that the correct sprite is in there, like this:

line 1=1st half of line 1
line 2=2nd half of line 1
line 3=1st half of line 2
line 4=2nd half of line 2
line 5=1st half of line 3

etc
 

aprentice

Moderator
zenogais said:
works fine on mine after I changed by 16x16 drawing routine to change if in chip8 mode.

thats nice mr big shot, now what about your gameboy emu huh? :p

I personally found coding the gameboy gfx was easier than the chip8 and straight foward, not to mention more fun :p
 

Doomulation

?????????????????????????
aprentice said:
my emu hates your rom with a passion, why is that? :p

What is this half pixel scroll btw?
Half pixel scroll is that it practically shifts HALF the pixel, not a full one.
I didn't think of writing my down, DOH! >_<
I must test how these work in my emulator. Hehe, hold on. Might just pick up the source and improve it now if it doesn't work right...

EDIT: Meh, your test doesn't work correctly. Well, that means I've got some work to do when I get home! O_O
Btw, you should tell me how to play each of those games. You know, how it's supposed to like and which buttons you press, so I know we get the same results.
 
Last edited:

hap

New member
I'll attach my emu, so you can compare the results with yours. Note though that if the results are different, you won't know whose emu is bugged, unless it's obvious, like when a game hangs.

Oh, and if you happen to look at help->about, and think 'hey that's not you'. It is, but just a different nickname ;p
 

zenogais

New member
aprentice said:
thats nice mr big shot, now what about your gameboy emu huh? :p

I personally found coding the gameboy gfx was easier than the chip8 and straight foward, not to mention more fun :p

Actually, you may be seeing that sooner than you think...
 

Doomulation

?????????????????????????
Right. I fixed the bug that caused the sprite to be garbeled up. Now I'm currently re-writing the screen system to accomondate the half-pixel shifts. Because of this, I basically need double precision... or perhaps even quadraple precision to accomondate for both half-pixel shift right AND down, which can be a pain.

Btw, aprectice... the bug in your code is that you're probably checking the wrong bit and shifting it wrong. Remember that width should be 8, too! I had the problem of shifting away the data and aquiring the wrong bits. Hehe. Easily done.

EDIT: Finished! Half-pixel scroll and chip8 <-> schip8 is emulated! Now it properly draws chip8 pixels so that when you change between chip8 and schip8, the screen won't change. Now that was fun ^_^ Wonder if there's more to do with chip8? :p

Uploaded new binary and source!
 
Last edited:

TJA

New member
hey there hap, just wondering if you could tell me if you ever had any trouble getting the ufo rom to work (problem occurs in some other roms too), I have noticed that in a lot of chip8 emulators including mine the rom will start to add a score even though no button is pressed and then freeze, other roms run fine. Yours is one of one a few i have come across that does not have this problem.
Thanks for any help I have also attached my emu.
 

hap

New member
Doomulation: nice!

TJA: set the collision flag to 0 before drawing a sprite ?
Also, you'd make it a lot easier for yourself if you added macros for at least V[(opcode&0x0F00)>>8] and V[(opcode&0x00F0)>>4], like this:

#define blah1 V[(opcode&0x0F00)>>8]
#define blah2 V[(opcode&0x00F0)>>4]

and in the rest of cpu.c, change every V[(opcode&0x0F00)>>8] to blah1 and every V[(opcode&0x00F0)>>4] to blah2
 

TJA

New member
lol, I cant believe thats all it was you have no idea how many times i have check my opcodes, thanks so much. And yeah I nothiced it says it should always be set back to zero it dave winters document, when checking to set what the collision register was. As for my code I know its a little messy but now I've got that stupid bug out of the way I will clean it up a bit.

Cheers, TJA.
 
Last edited:

TJA

New member
haha, thanks I actually started the emu two years ago, but lack of knowlege on how to program graphics and keyboard input made the project take a bit longer than expected ( i got lazy and just left the emu without graphics until I found SDL) its been at the stage its at now for some time though, but now that that bug is fixed I might finally finish of the last few schip opcodes (not much to do) and add a gui as I havent programmed one before. Thinking of using GTK.

TJA.
 

hap

New member
When looking at other people's cpu source code, it's funny to see how much alike they are to your own core. Bugs in other people's code are easily found this way. Very explainable though, since basically we all are converting the same Dave Winter's doc to C.
 

Doomulation

?????????????????????????
Indeed, there's mostly only one accurate doc out there, and that is dave winter's. I think we've pretty much emulated all about the system... only that butterfly in field is wrong somehow. And I couldn't figure out why...
 

refraction

PCSX2 Coder
Doomulation said:
Indeed, there's mostly only one accurate doc out there, and that is dave winter's. I think we've pretty much emulated all about the system... only that butterfly in field is wrong somehow. And I couldn't figure out why...


only trouble i had in Field was the side scrolling, which i think i fixed, only way i could do it was to double buffer the screen, copy it to the buffer (with the shift), clear the main one and copy it back over, seemed to sort most of it out.
 

Doomulation

?????????????????????????
That's been bothering me for a while now...
In debug mode, this works perfect:

(say screen is a two-dimensional buffer [64][128])
Code:
memcpy(screen[1],screen,63*128);
ZeroMemory(screen,127);

In release, this doesn't work at all. Nothing happens. You need a temporary buffer to do it. Shrug. That happens all the time when scrolling, and I cannot really see WHY.
 

aprentice

Moderator
Doomulation said:
That's been bothering me for a while now...
In debug mode, this works perfect:

(say screen is a two-dimensional buffer [64][128])
Code:
memcpy(screen[1],screen,63*128);
ZeroMemory(screen,127);

In release, this doesn't work at all. Nothing happens. You need a temporary buffer to do it. Shrug. That happens all the time when scrolling, and I cannot really see WHY.

How are you allocating the 64*128 of space and why you are doing screen[1] in the memcpy routine, is it a pointer for a specific location?
 

refraction

PCSX2 Coder
also your just missing off the first pixel really, what you need to do is something like

miss 2 pixels, copy the rest of the line (so like screen[2] to 127)
miss 2 again, copy the rest of the line (again, but screen[2 + 127] to 127 + 127)

i know thats a terrible way of doing it but im just trying to say you have to do each line, missing the first 2 pixels and shifting them over. so you need an if statement if your using the for statemements.

for(x = 0; x < 64; x++){

for(y = 0; y < 128; y++){
if(y > 2)
screenbuff2[y] = screenbuff[y+2];
}
}
memcpy(screenbuff, screenbuff2, sizeof(screenbuff));

that sorta thing

oh and the way you showed, the problem with that altho it does shift it, the problem is it just moves the pixels back, so ones that should have gone out of the screen on the left, appear a line up on the other side.
 

hap

New member
If destination and source are in the same memoryblock, use memmove instead of memcpy.
 

Top