massung / CHIP-8

Assembler and Emulator in Go
http://massung.github.io/CHIP-8
zlib License
254 stars 18 forks source link

Load & Save Instruction, terminates the emulator #3

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi, I saw your Chip-8 Assembler and Emulator, they're great btw :3 but... Unfortunately, there's a bug that might you solve, Your emulator terminates when running this Chip-8 program: Cycle counter 2 (actually, i did fix it so it could running on your chip-8 emulator now ._.) Cycle counter 2 (Fixed) I have more Chip-8 program that written by mine, currently... Implementation of Single Precision Floating Number Arithmetic in progress, The plan is to render mandelbrot, (even if it slow as hell) It's written using Octo's assembler

What is an Issue?

The program suddenly terminates, simply running this CHIP-8 Instruction: AFFF then FF55 or FF65,

My suggestion, Loading register from memory at 0xFFF loads v0, but v1-vF settled to the zero, Saving register to memory at 0xFFF only save v0, v1-vF values won't saved to memory

But what's method are used by my own Chip-8 emulator? Loading register from memory at 0xFFF loads all register from memory 0xFFF & 0xFFF Saving register to memory at 0xFFF save all register to memory 0xFFF & 0xFFF So, memory values between 0x000 - 0x00E may changed due this instruction.

Sincerely, Thanks~ A-KouZ1

massung commented 7 years ago

Hmm... I'm actually not sure what happens. It's a good bug, though. :-)

The 1802 used 16-bit registers, so it's highly unlikely that reading past 0xFFF would result in wrapping as opposed to just continuing to read whatever was in memory beyond that location. If it did wrap, it would likely wrap to 0xF00. But again, I doubt it. Do you know for certain what it would actually do?

I should certainly fix it to not crash, but my gut says that reading/writing beyond 0xFFF should either not do anything or should read/write 0's.

ghost commented 7 years ago

Do you know for certain what it would actually do?

Duh, I don't know... I am just only know how the CHIP-8 emulator works, less know about it's real hardware ;_;)

It is better to read zeroes and clip writing 'w')

Anyway, I have another Issue

That is, Unknown OpCode, such as 0000 terminates the program. (that wip guess number game, terminates the program) Eh, for unknown OpCode, in real hardware will ignores it or halt?

Collision detection for Y position over 0x1f, vf should be zero, (especially for my maze game, the player can pass top most position)

Nah, for your Chip-8 emulator screen, for X sprite wrapping, for example drawing sprite at X position 0x40, It's should wrap to next Y position or... wrap to same Y position? That's why it's glitches an UFO game... ._.)

Err... Super-Chip-8's Vertical Scrolling Instruction should able to run in CHIP-8 mode? (It can't scroll screen in lowres mode... In case for testing, falling stars scroll included)

asdf.zip

Check out my Chip-8/SuperChip-8 emulator that written in scratch ;-) KChip-8 (Chip-8 Emu) on Scratch

Sincerely, Thanks~ A-KouZ1

massung commented 7 years ago

Fixed with recent commit. Reading past 0xFFF will read 0's and writing will be ignored.