chip8go icon indicating copy to clipboard operation
chip8go copied to clipboard

Screen wrapping

Open tobiasvl opened this issue 4 years ago • 1 comments

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

tobiasvl avatar Apr 27 '20 21:04 tobiasvl

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.

jamesmcm avatar May 25 '20 14:05 jamesmcm