Recover damaged CPU Diagnostic ROM

Discuss the games, programs, utilities... and vaporware!
User avatar
MADrigal
Site Admin
Posts: 1258
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Recover damaged CPU Diagnostic ROM

Post by MADrigal » Mon Aug 12, 2024 10:19 am

I will shortly publish the fixed ROM on the CreatiVEmu website as well as other updates.
Thanks!
User avatar
Scouter3d
Posts: 673
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: Recover damaged CPU Diagnostic ROM

Post by Scouter3d » Fri Aug 16, 2024 10:04 am

Hi,

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

Cheers, TOM:0)
User avatar
MADrigal
Site Admin
Posts: 1258
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Recover damaged CPU Diagnostic ROM

Post by MADrigal » Fri Aug 23, 2024 11:33 pm

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 :)
User avatar
wavemotion
Posts: 8
Joined: Sat Jul 15, 2023 1:12 am

Re: Recover damaged CPU Diagnostic ROM

Post by wavemotion » Thu Aug 29, 2024 11:30 am

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!
Post Reply