/[projet1]/public/oric/routines/main.c
Defence Force logotype

Contents of /public/oric/routines/main.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 322 - (show annotations)
Wed Apr 28 17:07:31 2010 UTC (9 years, 7 months ago) by Chema
File MIME type: text/plain
File size: 1991 byte(s)


1
2 /**********************************************/
3 /* Example program for reading the Oric's */
4 /* keyboard. All keys are scanned and a */
5 /* virtual matrix of 8 bytes is updated at */
6 /* each IRQ. */
7 /* */
8 /* Idea: Dbug */
9 /* Main code: Twiligthe */
10 /* Adaptation & final implementation: Chema */
11 /* */
12 /* 2010 */
13 /**********************************************/
14
15 #include <stdio.h>
16
17 /* Initialization of ISR */
18 extern void InitISR();
19
20 /* Virtual keyboard matrix */
21 /* Organized as follows: */
22 /* byte is row number (selected through AY) */
23 /* bit in byte indicates the row (selected */
24 /* through the VIA port B) numbered 76543210 */
25 /* For mapping actual keys see: */
26 /* http://wiki.defence-force.org/doku.php?id=oric:hardware:oric_keyboard */
27
28 extern char KeyBank[8];
29
30 /* Function to dump the matrix into screen */
31 void dump_matrix();
32
33 void main()
34 {
35 printf("Keyboard scan demo program --\n");
36 printf("A virtual matrix (shown below) is\n");
37 printf("updated by interrupts. Each row\n");
38 printf("(0-7) is one byte in the KeyBank. \n");
39 printf("Each bit represents activity (1 or 0)\n");
40 printf("sensed in a given column (7-0)\nMultiple keypresses are supported.\n");
41
42 InitISR();
43 while (1)
44 {
45 dump_matrix();
46 }
47
48 }
49
50
51 /* Routine to dump the matrix into screen */
52 void dump_matrix()
53 {
54 char * start;
55 char i,j;
56 char mask=1;
57
58 start=(char *)(0xbfe0-350);
59 for (j=0;j<8;j++)
60 {
61 for(i=0;i<8;i++)
62 {
63 *start = (KeyBank[j] & mask ? '1' : '0');
64 start--;
65 mask=mask<<1;
66 }
67
68 mask=1;
69 start+=(48);
70 }
71
72 }

  ViewVC Help
Powered by ViewVC 1.1.26