kingcons / famiclom

An NES Emulator
BSD 2-Clause "Simplified" License
54 stars 7 forks source link

Reset doesn't work on CCL #4

Open PuercoPop opened 8 years ago

PuercoPop commented 8 years ago

After (reset *nes*) the CPU, PPU and APU have the value of its initform instead of the result of evaluating it.

? (reset *nes*)
#S(NES :CPU (MAKE-CPU) :RAM (BYTEVECTOR 2048) :PPU (MAKE-PPU) :APU (MAKE-APU) :MAPPER NIL)

I have yet to determine if it is invalid to call initialize-instance on objects already initialized or if it is an issue with CCL

PuercoPop commented 8 years ago

It appears I've reported it in the wrong project, the offending code is in cl-6502

kingcons commented 8 years ago

Yikes. There is a reinitialize-instance method but it doesn't initialize based on the values of the initforms which runs counter to my needs here: http://clhs.lisp.se/Body/f_reinit.htm

That's why I used plain old initialize-instance (http://clhs.lisp.se/Body/f_init_i.htm). I didn't see any language explicitly prohibiting it's use on non-new instances but I should investigate more thoroughly. Thanks for the bug report!

PuercoPop commented 8 years ago

I asked on #lisp, although there was no passage of the MOP that explicitly says so, it appears there is no guarantee for initialize-instance to work as desired.

I've hand written a reset method for cl-6502:cpu and for famiclom:nes for the time being, let me know if you consider that an acceptable solution. If so I'll submit the PR.