Next Generation Emulation banner

1 - 4 of 4 Posts

·
VBA 2 developer
Joined
·
404 Posts
Discussion Starter · #1 ·
My VC++7.1 warned me about a problem in the CPULoop function. Is it ok just to replace "tm1d" with "tm1d & 0xFFFF" ?

TM1D has a bigger value than 0xFFFF

Code:
GBA.cpp
function: CPULoop
CRT-Check: Loss of data because of data type cast

...
            if(timer1ClockReload == 1) {
              u32 tm1d = TM1D + clockTicks;
              if(tm1d > 0xffff) {
                tm1d += timer1Reload;
                timerOverflow |= 2;           
                soundTimerOverflow(1);
                if(TM1CNT & 0x40) {
                  IF |= 0x10;
                  UPDATE_REG(0x202, IF);
                }
              }

	//TODO: Check if we need a bitmask
	TM1D = tm1d;

			  timer1Ticks = 0x10000 - TM1D;
              UPDATE_REG(0x104, TM1D);                    
            } else {
              timer1Ticks -= clockTicks;          
              if(timer1Ticks <= 0) {
                timer1Ticks += timer1ClockReload;
                TM1D++;
...
 

·
Premium Member
Joined
·
483 Posts
I assume this is the line you are talking about:

TM1D = tm1d;

If so, then the right solution is to make it:
TM1D = (u16)tm1d;

Doing tm1d & 0xfff is still going to cause the warning (at least it should as that is an int result).
 

·
VBA 2 developer
Joined
·
404 Posts
Discussion Starter · #3 ·
There are some other places where I get these warnings, I think I'll al change them this way. I just wasn't sure if this was wrong code or if just Microsoft's compiler is too strict.

Thanks
 
1 - 4 of 4 Posts
Top