]> Shamusworld >> Repos - virtualjaguar/blob - src/anajoy.cpp
Initial revision
[virtualjaguar] / src / anajoy.cpp
1 #include "jaguar.h"
2
3 static uint8 anajoy_ram[2];
4 static uint8 analog_x, analog_y;
5
6 //////////////////////////////////////////////////////////////////////////////
7 //
8 //////////////////////////////////////////////////////////////////////////////
9 //
10 //
11 //
12 //////////////////////////////////////////////////////////////////////////////
13 void anajoy_init(void)
14 {
15         anajoy_reset();
16 }
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 //////////////////////////////////////////////////////////////////////////////
20 //
21 //
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 void anajoy_reset(void)
25 {
26         memset(anajoy_ram,0x00,2);
27         analog_x=128;
28         analog_y=128;
29 }
30 //////////////////////////////////////////////////////////////////////////////
31 //
32 //////////////////////////////////////////////////////////////////////////////
33 //
34 //
35 //
36 //////////////////////////////////////////////////////////////////////////////
37 void anajoy_done(void)
38 {
39 }
40 //////////////////////////////////////////////////////////////////////////////
41 //
42 //////////////////////////////////////////////////////////////////////////////
43 //
44 //
45 //
46 //////////////////////////////////////////////////////////////////////////////
47 void anajoy_byte_write(uint32 offset, uint8 data)
48 {
49         anajoy_ram[offset&0x01]=data;
50 }
51 //////////////////////////////////////////////////////////////////////////////
52 //
53 //////////////////////////////////////////////////////////////////////////////
54 //
55 //
56 //
57 //////////////////////////////////////////////////////////////////////////////
58 void anajoy_word_write(uint32 offset, uint16 data)
59 {
60         offset&=0x01;
61         anajoy_ram[offset+0]=(data>>8)&0xff;
62         anajoy_ram[offset+1]=data&0xff;
63 }
64 //////////////////////////////////////////////////////////////////////////////
65 //
66 //////////////////////////////////////////////////////////////////////////////
67 //
68 //
69 //
70 //////////////////////////////////////////////////////////////////////////////
71 uint8 anajoy_byte_read(uint32 offset)
72 {
73         if (anajoy_ram[1]&0x01)
74                 return(analog_y);
75         else
76                 return(analog_x);
77 }
78 //////////////////////////////////////////////////////////////////////////////
79 //
80 //////////////////////////////////////////////////////////////////////////////
81 //
82 //
83 //
84 //////////////////////////////////////////////////////////////////////////////
85 uint16 anajoy_word_read(uint32 offset)
86 {
87         uint16 data=anajoy_byte_read((offset+0)&0x01);
88         data<<=8;
89         data|=anajoy_byte_read((offset+1)&0x01);
90         return(data);
91 }