/[projet1]/public/atari/demos/defenceforce/savetheearth/keyboard.s
Defence Force logotype

Annotation of /public/atari/demos/defenceforce/savetheearth/keyboard.s

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (hide annotations)
Sat Nov 28 13:10:37 2009 UTC (10 years, 6 months ago) by dbug
File size: 2481 byte(s)
Added the source code of "Save The Earth", the Atari STe demo presented at Kindergarden 2009
1 dbug 172
2    
3     KEYTEST_STATE macro
4     key set \1
5     keybit set key&7
6     keybyte set key>>3
7     btst.b #keybit,keyboard_matrix+keyboard_state+keybyte
8     endm
9    
10     KEYTEST_PRESSED macro
11     key set \1
12     keybit set key&7
13     keybyte set key>>3
14     btst.b #keybit,keyboard_matrix+keyboard_pressed+keybyte
15     endm
16    
17     KEYTEST_RELEASED macro
18     key set \1
19     keybit set key&7
20     keybyte set key>>3
21     btst.b #keybit,keyboard_matrix+keyboard_released+keybyte
22     endm
23    
24     KEYTEST_STATE_ANY macro
25     lea keyboard_matrix+keyboard_state,a0 ; 16 bytes
26     move.l (a0)+,d0
27     or.l (a0)+,d0
28     or.l (a0)+,d0
29     or.l (a0)+,d0
30     endm
31    
32    
33     ; Main keyboard
34     KEY_SPACE equ $39
35    
36     ; Arrows
37     KEY_ARROW_LEFT equ $4b
38     KEY_ARROW_RIGHT equ $4d
39    
40     ; Numeric pad
41     KEY_NUMPAD_1 equ $6d
42     KEY_NUMPAD_2 equ $6e
43     KEY_NUMPAD_3 equ $6f
44     KEY_NUMPAD_4 equ $6a
45     KEY_NUMPAD_5 equ $6b
46     KEY_NUMPAD_6 equ $6c
47     KEY_NUMPAD_7 equ $67
48     KEY_NUMPAD_8 equ $68
49     KEY_NUMPAD_9 equ $69
50     KEY_NUMPAD_ENTER equ $72
51    
52    
53     SECTION TEXT
54    
55     even
56    
57     KeyboardManage
58     ; Clear the existing press/release states
59     lea keyboard_matrix,a0
60     movem.l empty_line,d0-d7 ; 32 bytes
61     movem.l d0-d7,keyboard_pressed(a0) ; Erase both keyboard_pressed and keyboard_released tables
62    
63     .loop
64     btst #0,$fffffc00.w
65     beq.s .exit
66    
67     lea keyboard_matrix,a0
68    
69     moveq #0,d0
70     move.b $fffffc02.w,d0
71    
72     move.b d0,d1
73     and.w #%01111111,d1
74     lsr.w #3,d1 ; Which byte
75    
76     tst.b d0
77     bmi.s .released
78     .pressed
79     bset.b d0,keyboard_state(a0,d1) ; Key is pressed
80     bset.b d0,keyboard_pressed(a0,d1) ; Key is pressed
81     bra.s .loop
82    
83     .released
84     bclr.b d0,keyboard_state(a0,d1) ; Key is no more pressed
85     bset.b d0,keyboard_released(a0,d1) ; Key is released
86     bra.s .loop
87    
88     .exit
89     rts
90    
91    
92     KeyboardFlushBuffer
93     btst.b #0,$fffffc00.w ; Have we some keys to wait for ?
94     beq.s .exit
95     tst.b $fffffc02.w
96     bra.s KeyboardFlushBuffer
97     .exit
98     rts
99    
100    
101     KeyboardDefaultManager
102     KEYTEST_RELEASED KEY_SPACE
103     bne.s .end_demo
104    
105     ifne enable_navigation
106     KEYTEST_RELEASED KEY_ARROW_RIGHT
107     bne.s .end_part
108    
109     KEYTEST_RELEASED KEY_ARROW_LEFT
110     bne.s .previous_part
111     endc
112    
113     moveq #0,d0
114     rts
115    
116     .previous_part
117     sub.l #3*4*2,PtrSequencer
118     bra.s .end_part
119    
120     .end_demo
121     st.b flag_end_program
122     .end_part
123     moveq #1,d0
124     rts
125    
126    
127    
128     SECTION BSS
129    
130     even
131    
132     rsreset
133     keyboard_state rs.b 128/8 ; 16 bytes
134     keyboard_pressed rs.b 128/8 ; 16 bytes
135     keyboard_released rs.b 128/8 ; 16 bytes
136     keyboard_size rs.b 0
137    
138     keyboard_matrix ds.b keyboard_size
139    
140     even
141    

  ViewVC Help
Powered by ViewVC 1.1.26