VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

When I compile it for Windows etc., I end up with (1000000000/1190000)(=PIT frequency), ending up with a variable (which is calculated when compiling) containing about 800(the amount of nanoseconds for a PIT tick). But instead, the application ends up with a number about 1.728413e-306, which causes an insane amount of PIT ticks to be handled, instead of just a few, on the very first instruction executed. This causes the application to crash after it's very first CPU instruction is executed, and the PIT starts ticking it's supposed ticks for that instruction.

Is this fixable? I've used the SDL2.0 build with the Android NDK(Createn using the tutorial at http://lazyfoo.net/tutorials/SDL/52_hello_mob … ndows/index.php ).

Anyone?

https://bitbucket.org/superfury/unipcemu.git

Edit: Can it be fixed by moving the relevant formula inside executable functions (e.g. leave the global variable global, but move it's assignment of it's value to a normal function that's always called when the module is used)?

So, like:

double abc=(1000000000/(1.0/2.0)); //Example

Becoming:

double abc=0.0; //Example

void initModule()
{
//Initialize our timings!
abc = (1000000000/(1.0/2.0)); //Example
}

Will this work for the Android NDK(on windows, using SDL2 based on the tutorial on lazyfoo: http://lazyfoo.net/tutorials/SDL/52_hello_mob … ndows/index.php ) and all used android devices(I've changed the compilation architecture to the 'all' option, compiling for all possible Android targets)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 4, by ZanQuance

User metadata
Rank Member
Rank
Member

What about just declaring it as a constant?

const double abc=50000000.0

[edit]
I think I misunderstood the question, is this a math precision issue? or are you attempting to calculate the PIT frequencies interrupt time?

Reply 2 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

The original code already declared it as a constant:

const double abc=(1000000000/(1.0/2.0))

Actually, the number that was dividing was a 1.19MHz double floating point division:

//Exact 14Mhz clock used on a PC!
#define MHZ14 ((15.75/1.1)*1000000.0)
//The clock speed of the PIT (14.31818MHz divided by 12)!
#define TIME_RATE (MHZ14/12.0)
double time_tick = (1000000000.0 / (double)TIME_RATE); //Time of a tick in the PIT!

The value of time_tick(which is never adjusted in the code) contains a ridiculously small value (200+ positions after the comma(1e-200)) instead of it's supposed ~800 value(which is it's compiled value on Windows).
The time_tick is the value in nanoseconds of one tick of the PIT. Since that value is reversed (by another value containing the same value but 1/x executed on it to perform multiplication instead of division), it causes the Android to execute about 1e200 PIT cycles instead of ~830 pit cycles.

Last edited by superfury on 2016-08-22, 11:46. Edited 1 time in total.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 4, by ZanQuance

User metadata
Rank Member
Rank
Member

Ah okay, I see.
So you've solved your issue then?

Reply 4 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've changed the code to simply execute the time_tick variable assignment during the initialization procedure instead of at compilation, but don't know yet if it works on an Android device(still waiting for a response of anyone having tested it on Android).

https://bitbucket.org/superfury/unipcemu.git

Anyone can try to compile it, test it on a Android device and report back if it works? A log file should be generated in the current log directory of UniPCemu(It's at /storage/sdcard0(or external_SD, depending on the location of the SETTINGS.DAT file)/UniPCemu/logs/emu.txt). Anyone can upload the log?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io