[hatari-devel] Re: Captain Blood IKBD clock

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


 Hi!

Am Thu, 20 Sep 2012 14:28:28 +0200
schrieb Nicolas Pomarède <npomarede@xxxxxxxxxxxx>:

> as reported on atari-forum, captain blood doesn't work properly under 
> Hatari.
> 
> At the top of the screen, under the X/Y coordinate of the planet, 
> there's a minutes/seconds counter (click in bottom left corner to
> close the planet view and see it)
> 
> When the game starts under Hatari, the values are 69.28, then the 
> seconds wrap at 69.87 and continue at 70.28 (it should wrap at 59
> seconds)
> 
> I made some investigations, and the game is using minute/second as 
> returned by the IKBD's ReadClock functions, so getting seconds > 60
> is clearly a bug in our implementation.
> 
> The game uses ReadClock, which means that even if you pause the game, 
> time is still counting in real time.
> 
> As with zombi, the game uses SetClock at the beginning with "99 12 31
> 00 00 00", which ensures minute/second are 0 at the start of the game.
> In our case, as we are in the year 2012, I think something is not 
> correct in the way nTimeOffset is computed for year "99".

There were indeed two problems left, first IKBD_FromBCD had a bug,
calculating wrong values for the year 99, and second the mktime
function created a timestamp that was one hour off. After having a
closer look at the man-page, I discovered that I missed to set the
"daylight saving time" field in the tm structure, so I guess that
caused the difference of one hour. After setting the "tm_isdst" field,
Captain Blood seems is working fine for me now.


> Also, independantly of this bug, the ikbd's year is returned as :
> 
> IKBD_ToBCD(SystemTime->tm_year)
> 
> which is wrong for tm_year >= 100. 2012 gives tm_year = 112 and a BCD 
> value of 0xB2. The correct way would be to return :
> 
> IKBD_ToBCD( SystemTime->tm_year % 100 )
> 
> which correctly returns 0x12. But even with this modification, time
> is still wrong in Captain Blood.

That "bug" is on purpose, see the comment of the IKBD_ToBCD() function.

 Thomas



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/