famiclom icon indicating copy to clipboard operation
famiclom copied to clipboard

Reset doesn't work on CCL

Open PuercoPop opened this issue 9 years ago • 3 comments

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 avatar May 06 '16 00:05 PuercoPop

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

PuercoPop avatar May 06 '16 02:05 PuercoPop

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!

kingcons avatar May 06 '16 12:05 kingcons

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.

PuercoPop avatar May 06 '16 20:05 PuercoPop