-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoystick.c
55 lines (49 loc) · 912 Bytes
/
joystick.c
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
int main()
{
// Using a Karnaugh Map on the Low Order Word of the Joystick BYTE in memory
// yields the following:
// xxx0 goes North
// xx0x goes South
// x0xx goes West
// 0xxx goes East
// For the High Order Word
// xxx0 is a button press
uint general8bit=0x01;
uint portA=NULL;
uint btnPressA=NULL;
uint north=NULL;
uint south=NULL;
uint east=NULL;
uint west=NULL;
while( general8bit != 0x00 )
{
shortcls();
portA = peek(0xDC00);
btnPressA = portA & 0x10;
north = portA & 0x01;
south = portA & 0x02;
west = portA & 0x04;
east = portA & 0x08;
if( btnPressA == 0x00 )
{
printf( "FIRE " );
}
if( north == 0x00 )
{
printf( "N" );
}
if( south == 0x00 )
{
printf( "S" );
}
if( west == 0x00 )
{
printf( "W" );
}
if( east == 0x00 )
{
printf( "E" );
}
}
return;
}