jamesmcm / chip8go

A simple CHIP-8 interpreter/emulator in Go
GNU General Public License v3.0
27 stars 1 forks source link

Screen wrapping #1

Open tobiasvl opened 4 years ago

tobiasvl commented 4 years ago

Hey! Found your emulator on reddit. You've done some great research here to be accurate!

But you implement screen wrapping, and say this:

X-wrapping should be enabled, that is part of a sprite that exceeds the screen width should wrap around, and a draw instruction to draw off-screen should normally also wrap around the screen horizontally.

However, I don't think that's the case. I'm not aware of any original CHIP-8 interpreters that wrapped sprites that exceeded the screen width.

As you say, sprites should wrap when the starting coordinate is outside the screen – in other words, the starting X and Y coordinates for DXYN should be the values in VX and VY modulo (or just AND) 64 and 32, respectively, like the 1979 Breakout depends on.

On the other hand, if the sprite hits the edge of the screen while it's being drawn, however, it should be clipped, and should not wrap around (ie. the exact same way you implement Y wrapping now). As far as I know that is how it has always worked. You can see it in the disassembly of the COSMAC VIP interpreter here: http://laurencescotford.co.uk/?p=304

jamesmcm commented 4 years ago

Sorry I didn't see this earlier, thanks this is good to know! Perhaps I'll patch it at some point and at least update the README, as it's a confusing topic for sure.