-
Notifications
You must be signed in to change notification settings - Fork 9
/
PinNoise.xml
70 lines (63 loc) · 1.65 KB
/
PinNoise.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugin[<!ELEMENT plugin (instance, reference*, code)>
<!ATTLIST plugin version CDATA "1.0">
<!ELEMENT instance EMPTY>
<!ATTLIST instance class CDATA #REQUIRED>
<!ELEMENT reference EMPTY>
<!ATTLIST reference name CDATA #REQUIRED>
<!ELEMENT code (#PCDATA)>
<!ATTLIST code codeFileName CDATA #IMPLIED>]>
<plugin version="1.0">
<instance class="PinNoise" />
<code><![CDATA[//Assemblies needed for GEAR plugin system.
using Gear.EmulationCore;
using Gear.PluginSupport;
//Class declaration of plugin.
class PinNoise : PluginBase
{
private int Drive;
private bool Clock;
private double last;
//Constructor for plugin initialization.
public PinNoise(PropellerCPU chip) : base(chip)
{
Drive = 0;
Clock = false;
last = 0.0;
}
//Title to be shown in tab.
public override string Title
{
get { return "Pin Noise"; }
}
//Register the events to be notified to this plugin.
public override void PresentChip()
{
NotifyOnPins();
NotifyOnClock();
}
//Called every time a pin changes, only if it was registered on
//method PresentChip() above.
public override void OnPinChange(double time, PinState[] pinStates)
{
Drive++;
if (Drive % 3 == 0)
{
// DrivePin(int pin_number, bool isFloating, bool isHigh)
DrivePin(3, false, (Drive & 1) == 1);
}
}
//Called every clock tick, only if it was registered on method
//PresentChip() above.
public override void OnClock(double time, uint sysCounter)
{
if (time - last >= 0.00001)
{
last += 0.00001;
Clock = !Clock;
DrivePin(2, false, Clock);
}
}
}
]]></code>
</plugin>