marioballano / emudore

emudore, a Commodore 64 emulator
Apache License 2.0
303 stars 21 forks source link

Question, RAM bug? #13

Closed xlar54 closed 6 years ago

xlar54 commented 6 years ago

Hey Mario,

One question I have for you - dont know if its my implementation or if you can replicate it in your code. If I patch RAM such as:

memram[0xc000] = 0xff;

It will place that value just fine. But if I try to POKE a new value into that memory location, it treats it like a ROM and wont overwrite those values. Seems to happen anywhere I set RAM.

Could you try this and see if you get the same problem?

ram patch

marioballano commented 6 years ago

uhm.. seems to work fine in my implementation, it might have something to do with memory banking?

screen shot 2017-11-26 at 18 09 36
marioballano commented 6 years ago

I have just tested setting the value to 0xff within the Memory class constructor, peek() reads the right value and poke seems to overwrite it just fine

xlar54 commented 6 years ago

ok cool, thank you. Ill see what Im doing wrong. Appreciate the double check!

marioballano commented 6 years ago

no problem :), see if you can add some debug code around Memory::read_byte and Memory::write_byte, maybe memory banking is screwing things up.. IIRC even in the actual C64 you could effectively write values to the underlying RAM but reading would yield the ROM values due to the memory banking config.

xlar54 commented 6 years ago

I figured it out, thanks! I was patching ROM inside a call to your setup_memory_banks() function. Works fine for ROM, but I added a RAM patch in there also, and due to the banking, you were 100% right. I extracted a patch_ram() function and it works perfectly. Thanks again. (In my case, I have an ML monitor that I want available to me while Im working on the OS, and so patching RAM is needed).

marioballano commented 6 years ago

great!, I remember I went across similar issues when I first wrote the memory banking support that's why it sounded familiar :)