Stealing Hatari code

A place to discuss current and future developments for STeem

Moderators: Mug UK, Steem Authors, Moderator Team

User avatar
Steven Seagal
Atari God
Atari God
Posts: 1951
Joined: Sun Dec 04, 2005 9:12 am
Location: Undisclosed
Contact:

Re: Stealing Hatari code

Postby Steven Seagal » Sun Oct 05, 2014 9:40 am

npomarede wrote:Maybe there's a similar problem in NBCD and SBCD too ?


I fixed SBCD the same way but there aren't many cases to test it.
This is also copied from Hatari, with an assert to check with Steem's old way.

Code: Select all

#if defined(SSE_CPU_SBCD)
/*  It's more complicated than ABCD if anything.
    eg 22-14 = 8
    2-4 = $FE
    $E-6=8
    one borrow 2-1-1=0
    result: 08

    eg 10-14
    0-4 = $FC
    $C-6=6
    one borrow 1-1-1=$FF
    $F-6=9
    result: 96 with carry ?

    this must be tested
*/
 // BRK(SBCD); //Hades Nebula, LoSTE screens STF, Super Off-Road Racer


#ifdef SSE_DEBUG
    int n=100+
       ( ((m68k_DEST_B&0xf0)>>4)*10+(m68k_DEST_B&0xf) )
      -( ((m68k_src_b&0xf0)>>4)*10+(m68k_src_b&0xf) );
    if(sr&SR_X)n--;
    n%=100;
    n=(BYTE)( (((n/10)%10)<<4)+(n%10) );
#endif

  BYTE src = m68k_src_b;
  BYTE dst = (m68k_DEST_B&0xff);
  BYTE lo_nibble=(dst & 0xF) - (src & 0xF) - ((sr&SR_X)?1:0);
  SR_CLEAR(SR_X+SR_C+SR_N);
  if(lo_nibble&0xF0)
  {
    lo_nibble-=6;
    SR_SET(SR_C);//internal
  }

  WORD hi_nibble=(dst & 0xF0) - (src & 0xF0) - ((sr&SR_C)?0x10:0);
  SR_CLEAR(SR_C);//clear internal bit
  if(hi_nibble&0xF00)
  {
    hi_nibble-=0x60;
    SR_SET(SR_X+SR_C+SR_N);
  }
  m68k_DEST_B=(hi_nibble&0xF0)+(lo_nibble&0xF);
  ASSERT( m68k_DEST_B==n );
  if(!m68k_DEST_B)
    SR_SET(SR_Z)


#else
    int n=100+
       ( ((m68k_DEST_B&0xf0)>>4)*10+(m68k_DEST_B&0xf) )
      -( ((m68k_src_b&0xf0)>>4)*10+(m68k_src_b&0xf) );
    if(sr&SR_X)n--;
    SR_CLEAR(SR_X+SR_C+SR_N);
    if(n<100)SR_SET(SR_X+SR_C); //if a carry occurs
    n%=100;
    if(n)SR_CLEAR(SR_Z);

/*
#if defined(STEVEN_SEAGAL) && defined(SSE_CPU_LINE_8_TIMINGS)
    FETCH_TIMING;
#endif
    PREFETCH_IRC;
*/
    m68k_DEST_B=(BYTE)( (((n/10)%10)<<4)+(n%10) );
#endif



Apparently there's no problem with NBCD.


Social Media

     

Return to “Development”

Who is online

Users browsing this forum: No registered users and 1 guest