Thread: CHIP8 thread
View Single Post
Old January 8th, 2009   #46 (permalink)
runawayprisoner
Mobile Fanatic
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Santa Cruz, CA
Posts: 6,210
Quote:
Originally Posted by serge2k View Post
well I'm trying to run the PONG program. It runs, displays the paddles and the score but the "ball" jumps around. Scores aren't registering quite right either.

just tried breakout and it isn't working quite right either.

I did just realize what was causing it to be so slow. Redrawing the screen on every single opcode instead of just when it changes. it's faster now.

I think the problem is with my drawing code.l
The ball jumping around could be your arithmetic opcodes not setting the flag the right way. I never got that, though, so I have no idea. Check your collision flag, too.

The scores are calculated using the BCD opcode. Now note that... this one has to be correctly implemented for Pong scores to work right. BCD should work like this:
- Take value in decimal of register VX (0 to 255)
- Split values into hundreds, tens, and units... (123 would become 1 for hundreds, 2 for tens, and 3 for units)
- Store hundreds to memory at address I, store tens to memory at address I+1, store units to memory at address I+2.
- I is NOT and should NOT be affected before, after, or during this.

For collision flag, when a draw opcode is called, VF is set to 0, right away, regardless of its previous value. Then if the calling bit is 1, and if the bit at the position that bit is going to be written to is also 1, VF is set to 1, and will stay at 1 all the time.

And you should have a region set aside for video memory, then... just write the video memory to the screen output 50 or 60 times a second regardless of its state, then you won't have to worry about it going slow anymore.
__________________
cChip interpreter WIP - current status: Release Candidate
LRx Filter RC - current performance rating: 9/10
runawayprisoner is offline   Reply With Quote