Page 2 of 2

Re: Recover damaged CPU Diagnostic ROM

Posted: Mon Aug 12, 2024 10:19 am
by MADrigal
I will shortly publish the fixed ROM on the CreatiVEmu website as well as other updates.
Thanks!

Re: Recover damaged CPU Diagnostic ROM

Posted: Fri Aug 16, 2024 10:04 am
by Scouter3d
Hi,

i just gave the diag ROM a go on the real hardware and it works as expected...

Cheers, TOM:0)

Re: Recover damaged CPU Diagnostic ROM

Posted: Fri Aug 23, 2024 11:33 pm
by MADrigal
Thanks Tom, thats great result! :)
I feel now confident to burn the fixed ROM into a brand new EPROM chip and solder it back to where it belongs :)

Re: Recover damaged CPU Diagnostic ROM

Posted: Thu Aug 29, 2024 11:30 am
by wavemotion
Incredible work, Óscar!

Looks like the CreatiVision emulator (and my ColecoDS) use the same 6502 emulation core and it also fails. At first it looked like I was getting illegal opcodes (0x34 and 0x37) but after talking with Óscar, he is fairly sure there are no undocumented opcodes being used... so it's debug time!


With Óscar's help, I found the culprit for ColecoDS. I'm sure any emulator that is using the same M6502 core will have the same bug - it's in the ADC (Add with Carry) and Decimal Mode. The missing line is pointed to below:

Code: Select all

#define M_ADC(Rg) \
  if(R->P&D_FLAG) \
  { \
    K.B.l=(R->A&0x0F)+(Rg&0x0F)+(R->P&C_FLAG); \
    if(K.B.l>9) K.B.l+=6; \
    K.B.h=(R->A>>4)+(Rg>>4)+(K.B.l>15? 1:0); \
    if(K.B.h>9) K.B.h+=6; \     // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< !!!
    R->A=(K.B.l&0x0F)|(K.B.h<<4); \
    R->P=(R->P&~C_FLAG)|(K.B.h>15? C_FLAG:0); \
  } \
  else \
  { \
    K.W=R->A+Rg+(R->P&C_FLAG); \
    R->P&=~(N_FLAG|V_FLAG|Z_FLAG|C_FLAG); \
    R->P|=(~(R->A^Rg)&(R->A^K.B.l)&0x80? V_FLAG:0)| \
          (K.B.h? C_FLAG:0)|ZNTable[K.B.l]; \
    R->A=K.B.l; \
  }
This is also the reason why some games (like Sonic Invaders) under emulation would show HEX digits (A-F) in the score... that's this bug!