Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/Assets/Lua/UnitTests/Joypad_WithControllerNumbers.lua
2 views
1
console.writeline("Unit test for joypad.set using the controller parameter")
2
console.writeline("Core Required: NES (or any multi-player core with U,D,L,R,select,start,A,B as buttons)")
3
console.writeline("Correct behavior:")
4
console.writeline("No Directional button shoudl be imparied in any way, should operate as if nothing was ever pressed")
5
console.writeline("A should be off and user can not push buttons to change that")
6
console.writeline("B should be on and the user can not push buttons to change that")
7
console.writeline("Select should be on, but pressing it turns it off")
8
console.writeline("Start should be unaffected")
9
console.writeline("After frame 600, the console will say 'cleared', and now all buttons should be off and unaffected, as if the script was never run");
10
11
buttons = { };
12
13
buttons["Up"] = false;
14
buttons["Down"] = true;
15
buttons["Left"] = "invert";
16
buttons["Right"] = null;
17
joypad.set(buttons, 1);
18
19
pushThings = true;
20
21
while true do
22
if (pushThings) then
23
buttons = { };
24
buttons["A"] = false;
25
buttons["B"] = true;
26
buttons["Select"] = "invert";
27
buttons["Start"] = null;
28
joypad.set(buttons, 1);
29
end
30
31
if (emu.framecount() == 600) then
32
pushThings = false;
33
turnoff = { };
34
turnoff["A"] = null;
35
turnoff["B"] = null;
36
turnoff["Select"] = null;
37
turnoff["Start"] = null;
38
39
joypad.set(turnoff, 1);
40
console.writeline("cleared")
41
end
42
43
emu.frameadvance();
44
end
45