mirror of
https://github.com/libretro/Mu.git
synced 2026-07-08 17:57:01 +00:00
Use rng in tests to verify that results arnt just a coincidence
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "../m68k/m68k.h"
|
||||
#include "../emulator.h"
|
||||
@@ -63,6 +64,24 @@ static void logApiCalls(){
|
||||
}
|
||||
}
|
||||
|
||||
static int64_t randomRange(int64_t start, int64_t end){
|
||||
static bool seedRng = true;
|
||||
int64_t result;
|
||||
|
||||
if(seedRng){
|
||||
srand(time(NULL));
|
||||
seedRng = false;
|
||||
}
|
||||
|
||||
result = rand();
|
||||
result <<= 32;
|
||||
result |= rand();
|
||||
result %= llabs(end - start) + 1;
|
||||
result += start;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
static uint32_t scanForPrivateFunctionAddress(const char* name){
|
||||
//this is not 100% accurate, it scans memory for a function
|
||||
@@ -361,14 +380,21 @@ void sandboxTest(uint32_t test){
|
||||
//since the sandbox can interrupt any running function(including ADC ones) this safeguard is needed
|
||||
if(ads7846BitsToNextControl == 0){
|
||||
uint32_t point;
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t osX;
|
||||
int16_t osY;
|
||||
input_t oldInput = palmInput;
|
||||
|
||||
palmInput.touchscreenTouched = true;
|
||||
palmInput.touchscreenX = randomRange(0, 159);
|
||||
palmInput.touchscreenY = randomRange(0, 219);
|
||||
|
||||
//PrvBBGetXY on self dumped ROM
|
||||
callFunction(false, 0x100827CE, NULL, "v(L)", &point);
|
||||
x = point >> 16;
|
||||
y = point & 0xFFFF;
|
||||
debugLog("Sandbox: Touch position is x:%d, y:%d\n", x, y);
|
||||
osX = point >> 16;
|
||||
osY = point & 0xFFFF;
|
||||
debugLog("Sandbox: Real touch position is x:%d, y:%d\n", palmInput.touchscreenX, palmInput.touchscreenY);
|
||||
debugLog("Sandbox: OS reported touch position is x:%d, y:%d\n", osX, osY);
|
||||
palmInput = oldInput;
|
||||
}
|
||||
else{
|
||||
debugLog("Sandbox: Unsafe to read touch position.\n");
|
||||
|
||||
19
tests/rngTouchTest.txt
Normal file
19
tests/rngTouchTest.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Sandbox: Test 1 started(printed 1 times)
|
||||
SPI2 transfer, ENABLE:true, XCH:true, IRQ:false, IRQEN:false, BITCOUNT:5(printed 1 times)
|
||||
SPI2 transfer, before:0x001B, after:0x0360, PC:0x1008119E(printed 1 times)
|
||||
Accessed ADS7846 Ch:5, 8 bits, Diff Mode, Power Save:1, PC:0x10081208.(printed 1 times)
|
||||
SPI2 transfer, ENABLE:true, XCH:true, IRQ:false, IRQEN:false, BITCOUNT:12(printed 1 times)
|
||||
SPI2 transfer, before:0x0213, after:0x3059, PC:0x10081208(printed 1 times)
|
||||
Accessed ADS7846 Ch:1, 8 bits, Diff Mode, Power Save:1, PC:0x10081208.(printed 1 times)
|
||||
SPI2 transfer, ENABLE:true, XCH:true, IRQ:false, IRQEN:false, BITCOUNT:12(printed 1 times)
|
||||
SPI2 transfer, before:0x021B, after:0xB017, PC:0x10081208(printed 1 times)
|
||||
SPI2 transfer, ENABLE:true, XCH:true, IRQ:false, IRQEN:false, BITCOUNT:3(printed 1 times)
|
||||
SPI2 transfer, before:0x0004, after:0x0020, PC:0x1008124C(printed 1 times)
|
||||
Sandbox: Real touch position is x:108, y:211(printed 1 times)
|
||||
Sandbox: OS reported touch position is x:89, y:23(printed 1 times)
|
||||
Sandbox: Test 1 finished(printed 1 times)
|
||||
|
||||
Results:
|
||||
X Inaccuracy -19
|
||||
Y Inaccuracy +15(y seems to be inverted)(219 - 211 = 8)(23 - 8 = 15)
|
||||
This is before the touch calibration screen.
|
||||
Reference in New Issue
Block a user