Unnecessary double check?

Post Reply
spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Unnecessary double check?

Post by spacy51 »

gba.cpp, Ln 2645:

case 0xC6:
{

Code: Select all

  bool start= ((DM1CNT_H ^ value) & 0x8000) ? true : false;


  value &= 0xF7E0;

 

Code: Select all

  DM1CNT_H = value;


  UPDATE_REG(0xC6, DM1CNT_H);

 

Code: Select all

  if(start [b]&& (value & 0x8000)[/b]) {


    dma1Source = DM1SAD_L | (DM1SAD_H << 16);


    dma1Dest = DM1DAD_L | (DM1DAD_H << 16);


    CPUCheckDMA(0, 2);


  }


}


break;

 

My personal logic tells me that the bold part is unneeded.

Last edited by spacy51 on Mon Aug 17, 2009 5:48 pm, edited 1 time in total.
jbo_85
Junior Member
Posts: 8
Joined: Sun Mar 23, 2008 8:05 pm

Unnecessary double check?

Post by jbo_85 »

The bold part is needed. It fails if DM1CNT_H or value is >= 0x8000.

spacy51
Senior Member
Posts: 371
Joined: Tue Mar 18, 2008 4:59 pm

Unnecessary double check?

Post by spacy51 »

Look at the beginning.

start is only true if bit 15 of value is set, so it does not make sense to seperately check for that again in the bold part.

Last edited by spacy51 on Mon Aug 17, 2009 8:13 pm, edited 1 time in total.
jbo_85
Junior Member
Posts: 8
Joined: Sun Mar 23, 2008 8:05 pm

Unnecessary double check?

Post by jbo_85 »

Look at the beginning.

start is only true if bit 15 of value is set, so it does not make sense to seperately check for that again in the bold part.

It tests bit 15 of (DM1CNT_H ^ value) and not just bit 15 of value.

Post Reply