Commit e03ea87f authored by KurtJD's avatar KurtJD
Browse files

Fix sprite wrap bug and update README

parent 1b119013
Pipeline #129254 passed with stages
in 7 minutes and 25 seconds
......@@ -97,7 +97,8 @@ Otherwise:
`test.exe` (for unit tests)
## Options
`-x` Enable compatibility mode (disables all S-CHIP quirks but keeps HI-RES and new instructions)
`-l` Enable legacy mode (for running original CHIP-8 ROMs)
`-x` Enable XO-CHIP mode
`-d` Enable debug mode
`-m` Load dump file instead of ROM
`-p` Set program start address (in hex)
......@@ -116,12 +117,12 @@ Also includes flags for disabling specific S-CHIP "quirks" (which are all enable
`-1` Disable 8xy6/8xyE bug
`-2` Disable Fx55/Fx65 bug
`-3` Disable Bnnn bug
`-4` Allow big sprites to be drawn in LO-RES mode
`-5` Clear display when 00FE/00FF execute
`-6` Allow sprite wrapping
`-4` Disable ban on big sprites being drawn in LO-RES mode
`-5` Disable display state remaining the same when 00FE/00FF execute (display is cleared with this disabled)
`-6` Disable sprite clipping
`-7` Disable collision enumeration
`-8` Disable collision check with bottom of screen
`-9` Enable VF reset on logical OR, AND, XOR
`-9` Disable undefined VF after logical OR, AND, XOR (VF is set to 0 with this disabled)
## Controls
......@@ -156,8 +157,8 @@ Also includes flags for disabling specific S-CHIP "quirks" (which are all enable
|`ESC`|Reset Emulator|
## Troubleshooting
* This emulator defaults to S-CHIP mode, which has become more popular since the 90s. Unfortunately, S-CHIP changed the behavior of several instructions and introduced some other quirks, making some programs developed for the original COSMAC VIP not backwards-compatible. If a ROM is not working correctly (especially one written before 1990), try enabling compatibility mode with the `-x` flag.
* If running a program developed for Octo, you should also enable compatibility mode with the `-x` flag since Octo ignores all S-CHIP quirks.
* This emulator defaults to S-CHIP mode, which has become more popular since the 90s. Unfortunately, S-CHIP changed the behavior of several instructions and introduced some other quirks, making some programs developed for the original COSMAC VIP not backwards-compatible. If a ROM is not working correctly (especially one written before 1990), try enabling legacy mode with the `-l` flag.
* If running an XO-CHIP ROM, enable XO-CHIP mode with the `-x` flag.
* This emulator defaults to 0x200 as the start address, however some programs assume other defaults (namely, those written for the ETI-660 which default to 0x600). Try to find out what default address the program assumes and set that with the `-p` option.
* If a program is running very slowly, try increasing the CPU speed or even uncapping it (by setting the `-c` option to 0). Some ROMs are developed around an uncapped execution frequency and will run much more smoothly.
* There are many CHIP-8 variants and this emulator does not support all of them. If a ROM still does not work correctly after trying the suggestions above, it may have been written for an unsupported variant and thus will simply not work.
......
......@@ -953,12 +953,12 @@ void chip8_draw(CHIP8 *chip8, uint8_t x, uint8_t y, uint8_t n, CHIP8BP bitplane)
rows = n;
}
// Allow out-of-bound sprite to wrap-around.
/*// Allow out-of-bound sprite to wrap-around.
if (!chip8->quirks[6])
{
y %= DISPLAY_HEIGHT;
x %= DISPLAY_WIDTH;
}
}*/
bool prev_byte_collide = false;
......@@ -984,7 +984,13 @@ void chip8_draw(CHIP8 *chip8, uint8_t x, uint8_t y, uint8_t n, CHIP8BP bitplane)
{
int disp_x = (x * scale) + (x_start * scale) + k;
int disp_y = (y * scale) + (y_start * scale) + h;
if (disp_x >= DISPLAY_WIDTH || disp_y >= DISPLAY_HEIGHT)
if (!chip8->quirks[6])
{
disp_y %= DISPLAY_HEIGHT;
disp_x %= DISPLAY_WIDTH;
}
else if (disp_x >= DISPLAY_WIDTH || disp_y >= DISPLAY_HEIGHT)
{
break;
}
......
......@@ -271,7 +271,7 @@ bool handle_args(int argc, char **argv)
#ifdef ALLOW_GETOPTS
int opt;
while ((opt = getopt(argc, argv, "012345678xdms:p:c:t:r:f:b:n:k:")) != -1)
while ((opt = getopt(argc, argv, "012345678xldms:p:c:t:r:f:b:n:k:")) != -1)
{
switch (opt)
{
......@@ -289,13 +289,27 @@ bool handle_args(int argc, char **argv)
quirks[opt - '0'] = false;
break;
// Toggle compatibility mode
case 'x':
for (size_t i = 0; i < sizeof(quirks); i++)
// Toggle legacy mode
case 'l':
for (size_t i = 0; i < NUM_QUIRKS; i++)
{
quirks[i] = false;
}
// Both CHIP-8 and SCHIP apparently clip sprites (but not XO-CHIP)
quirks[6] = true;
break;
// Toggle XO-CHIP mode
case 'x':
/* XO-CHIP is similar to legacy mode except the last quirk
(VF Reset) should not be enabled and sprite wrapping should
be enabled. */
for (size_t i = 0; i < NUM_QUIRKS - 1; i++)
{
quirks[i] = false;
}
break;
// Toggle debug mode
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment