-
Notifications
You must be signed in to change notification settings - Fork 19
/
transport.go
65 lines (53 loc) · 1.96 KB
/
transport.go
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
// This file is part of Gopher2600.
//
// Gopher2600 is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Gopher2600 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Gopher2600. If not, see <https://www.gnu.org/licenses/>.
package moviecart
// transport is the process of communication between the kernel and the
// microcontroller. for convenience these types have been added to facilitate
// testing and comparison between transportDirection value and transportButtons
// values.
type transportDirection uint8
func (b transportDirection) isUp() bool {
return b&transportUp == transportUp
}
func (b transportDirection) isDown() bool {
return b&transportDown == transportDown
}
func (b transportDirection) isLeft() bool {
return b&transportLeft == transportLeft
}
func (b transportDirection) isRight() bool {
return b&transportRight == transportRight
}
type transportButtons uint8
func (b transportButtons) isBW() bool {
return b&transportBW == transportBW
}
func (b transportButtons) isReset() bool {
return b&transportReset == transportReset
}
func (b transportButtons) isButton() bool {
return b&transportButton == transportButton
}
// masks for transport input.
const (
transportRight transportDirection = 0x10
transportLeft transportDirection = 0x08
transportDown transportDirection = 0x04
transportUp transportDirection = 0x02
transportBW transportButtons = 0x10
transportSelect transportButtons = 0x04 // nolint
transportReset transportButtons = 0x02
transportButton transportButtons = 0x01
)