| MODULE Input; (*NW 5.10.86 / 15.11.90 Ceres-2; PDR 21.4.12 / NW 15.5.2013 Ceres-4*) |
| .MODULE Input (KEY 5DE391A8, VERSION 1, SIZE 00000434) |
| .DATA 20H |
| .STRING TABLE SKIPPED |
| .FIXUP T 0H |
| IMPORT SYSTEM; |
| |
| CONST msAdr = -40; kbdAdr = -36; |
| VAR kbdCode: BYTE; (*last keyboard code read*) |
| Recd, Up, Shift, Ctrl, Ext: BOOLEAN; |
| KTabAdr: INTEGER; (*keyboard code translation table*) |
| MW, MH, MX, MY: INTEGER; (*mouse limits and coords*) |
| MK: SET; (*mouse keys*) |
| |
| (*FIFO implemented in hardware, because every read must be handled, |
| including tracking the state of the Shift and Ctrl keys*) |
| |
| PROCEDURE Peek(); |
| BEGINa |
0000 | a(4EE90004): SUB SP, SP, 4H |
0001 | a(AFE00000): STR LNK, SP, 0H |
| IF SYSTEM.BIT(msAdr, 28) THENb |
0002 | b(5000FFD8): MOV R0, R0, FFFFFFD8H |
0003 | b(80000000): LDR R0, R0, 0H |
0004 | b(4003001D): ROR R0, R0, 1DH |
0005 | b(E800003C): BPL 60 [0042H] |
| SYSTEM.GET(kbdAdr, kbdCode);c |
0006 | c(5000FFDC): MOV R0, R0, FFFFFFDCH |
0007 | c(90000000): LDR R0, R0, 0H |
0008 | c .FIXUP D |
0008 | c(8D000008): LDR SB, MT, MOD0 [Input] |
0009 | c(B0D00000): STR R0, SB, 0H [data] |
| IF kbdCode = 0F0H THENd Up := TRUE |
000A | d(90D00000): LDR R0, SB, 0H |
000B | d(400900F0): SUB R0, R0, F0H |
000C | d(E9000004): BNE 4 [0011H] |
| ELSIFe kbdCodef = 0E0H THENg Ext := TRUE |
000D | e(40000001): MOV R0, R0, 1H |
000E | e .FIXUP D |
000E | e(8D000006): LDR SB, MT, MOD0 [Input] |
000F | e(B0D00002): STR R0, SB, 2H [data] |
0010 | f(E7000031): B 49 [0042H] |
0011 | g .FIXUP D |
0011 | g(8D000003): LDR SB, MT, MOD0 [Input] |
0012 | g(90D00000): LDR R0, SB, 0H [data] |
0013 | g(400900E0): SUB R0, R0, E0H |
0014 | g(E9000004): BNE 4 [0019H] |
| ELSEh |
0015 | h(40000001): MOV R0, R0, 1H |
0016 | h .FIXUP D |
0016 | h(8D000005): LDR SB, MT, MOD0 [Input] |
0017 | h(B0D00005): STR R0, SB, 5H [data] |
| IFi (kbdCode = 12H)j OR (kkbdCode = 59H)l THENm (*shift*) Shift := ~Up |
0018 | i(E7000029): B 41 [0042H] |
0019 | j .FIXUP D |
0019 | j(8D000003): LDR SB, MT, MOD0 [Input] |
001A | j(90D00000): LDR R0, SB, 0H [data] |
001B | j(40090012): SUB R0, R0, 12H |
001C | k(E1000004): BEQ 4 [0021H] |
001D | l .FIXUP D |
001D | l(8D000004): LDR SB, MT, MOD0 [Input] |
001E | l(90D00000): LDR R0, SB, 0H [data] |
001F | l(40090059): SUB R0, R0, 59H |
0020 | m(E9000009): BNE 9 [002AH] |
| ELSIFn kbdCodeo = 14H THENp (*ctrl*) Ctrl := ~Up |
0021 | n .FIXUP D |
0021 | n(8D000004): LDR SB, MT, MOD0 [Input] |
0022 | n(90D00002): LDR R0, SB, 2H [data] |
0023 | n(E9000002): BNE 2 [0026H] |
0024 | n(40000001): MOV R0, R0, 1H |
0025 | n(E7000001): B 1 [0027H] |
0026 | n(40000000): MOV R0, R0, 0H |
0027 | n .FIXUP D |
0027 | n(8D000006): LDR SB, MT, MOD0 [Input] |
0028 | n(B0D00003): STR R0, SB, 3H [data] |
0029 | o(E7000013): B 19 [003DH] |
002A | p .FIXUP D |
002A | p(8D000003): LDR SB, MT, MOD0 [Input] |
002B | p(90D00000): LDR R0, SB, 0H [data] |
002C | p(40090014): SUB R0, R0, 14H |
002D | p(E9000009): BNE 9 [0037H] |
| ELSIFq ~rUp THENs Recd := TRUE (*real key going down*) |
002E | q .FIXUP D |
002E | q(8D000004): LDR SB, MT, MOD0 [Input] |
002F | q(90D00002): LDR R0, SB, 2H [data] |
0030 | q(E9000002): BNE 2 [0033H] |
0031 | q(40000001): MOV R0, R0, 1H |
0032 | q(E7000001): B 1 [0034H] |
0033 | q(40000000): MOV R0, R0, 0H |
0034 | q .FIXUP D |
0034 | q(8D000006): LDR SB, MT, MOD0 [Input] |
0035 | q(B0D00004): STR R0, SB, 4H [data] |
0036 | r(E7000006): B 6 [003DH] |
0037 | s .FIXUP D |
0037 | s(8D000003): LDR SB, MT, MOD0 [Input] |
0038 | s(90D00002): LDR R0, SB, 2H [data] |
0039 | s(E9000003): BNE 3 [003DH] |
| ENDt ; |
003A | t(40000001): MOV R0, R0, 1H |
003B | t .FIXUP D |
003B | t(8D000004): LDR SB, MT, MOD0 [Input] |
003C | t(B0D00001): STR R0, SB, 1H [data] |
| Up := FALSE;u Ext := FALSE |
003D | u(40000000): MOV R0, R0, 0H |
003E | u .FIXUP D |
003E | u(8D000003): LDR SB, MT, MOD0 [Input] |
003F | u(B0D00002): STR R0, SB, 2H [data] |
| ENDv |
0040 | v(40000000): MOV R0, R0, 0H |
0041 | v(B0D00005): STR R0, SB, 5H |
| END; |
| ENDw Peek; |
0042 | w(8FE00000): LDR LNK, SP, 0H |
0043 | w(4EE80004): ADD SP, SP, 4H |
0044 | w(C700000F): B LNK |
| |
| PROCEDURE Available*(): INTEGER; |
| BEGINx Peek();y |
0045 | x .PROC 1 |
0045 | x(4EE90004): SUB SP, SP, 4H |
0046 | x(AFE00000): STR LNK, SP, 0H |
0047 | y(F7FFFFB8): BL -72 [0000H] |
| RETURN ORD(Recd) |
| ENDz Available; |
0048 | z .FIXUP D |
0048 | z(8D00000A): LDR SB, MT, MOD0 [Input] |
0049 | z(90D00001): LDR R0, SB, 1H [data] |
004A | z(8FE00000): LDR LNK, SP, 0H |
004B | z(4EE80004): ADD SP, SP, 4H |
004C | z(C700000F): B LNK |
| |
| PROCEDURE Read*(VAR ch: CHAR); |
| BEGINa |
004D | a .PROC 2 |
004D | a(4EE90008): SUB SP, SP, 8H |
004E | a(AFE00000): STR LNK, SP, 0H |
004F | a(A0E00004): STR R0, SP, 4H |
| WHILE ~Recd DOb Peek() ENDc ; |
0050 | b .FIXUP D |
0050 | b(8D000008): LDR SB, MT, MOD0 [Input] |
0051 | b(90D00001): LDR R0, SB, 1H [data] |
0052 | b(E9000002): BNE 2 [0055H] |
0053 | c(F7FFFFAC): BL -84 [0000H] |
0054 | c(E7FFFFFB): B -5 [0050H] |
| IF Shift OR Ctrld THENe INC(kbdCode, 80H) ENDf; (*ctrl implies shift*) |
0055 | d .FIXUP D |
0055 | d(8D000005): LDR SB, MT, MOD0 [Input] |
0056 | d(90D00003): LDR R0, SB, 3H [data] |
0057 | d(E9000003): BNE 3 [005BH] |
0058 | e .FIXUP D |
0058 | e(8D000003): LDR SB, MT, MOD0 [Input] |
0059 | e(90D00004): LDR R0, SB, 4H [data] |
005A | e(E1000005): BEQ 5 [0060H] |
005B | f .FIXUP D |
005B | f(8D000003): LDR SB, MT, MOD0 [Input] |
005C | f(40D80000): ADD R0, SB, 0H [data] |
005D | f(91000000): LDR R1, R0, 0H |
005E | f(41180080): ADD R1, R1, 80H |
005F | f(B1000000): STR R1, R0, 0H |
| (* ch := kbdTab[kbdCode]; *) |
| SYSTEM.GET(KTabAdr + kbdCode,g ch);h |
0060 | g .FIXUP D |
0060 | g(8D000005): LDR SB, MT, MOD0 [Input] |
0061 | g(80D00008): LDR R0, SB, 8H [data] |
0062 | g(91D00000): LDR R1, SB, 0H |
0063 | g(00080001): ADD R0, R0, R1 |
0064 | h(90000000): LDR R0, R0, 0H |
0065 | h(81E00004): LDR R1, SP, 4H |
0066 | h(B0100000): STR R0, R1, 0H |
| IF Ctrl THENi ch := CHR(ORD(ch) MODj 20H)k ENDl; |
0067 | i(90D00004): LDR R0, SB, 4H |
0068 | i(E1000005): BEQ 5 [006EH] |
0069 | j(80E00004): LDR R0, SP, 4H |
006A | j(90000000): LDR R0, R0, 0H |
006B | k(4004001F): AND R0, R0, 1FH |
006C | l(81E00004): LDR R1, SP, 4H |
006D | l(B0100000): STR R0, R1, 0H |
| Recd := FALSE |
| ENDm Read; |
006E | m(40000000): MOV R0, R0, 0H |
006F | m .FIXUP D |
006F | m(8D00000F): LDR SB, MT, MOD0 [Input] |
0070 | m(B0D00001): STR R0, SB, 1H [data] |
0071 | m(8FE00000): LDR LNK, SP, 0H |
0072 | m(4EE80008): ADD SP, SP, 8H |
0073 | m(C700000F): B LNK |
| |
| PROCEDURE Mouse*(VAR keys: SET; VAR x, y: INTEGER); |
| VAR w: INTEGER; |
| BEGINn SYSTEM.GET(msAdr, w);o |
0074 | n .PROC 3 |
0074 | n(4EE90014): SUB SP, SP, 14H |
0075 | n(AFE00000): STR LNK, SP, 0H |
0076 | n(A0E00004): STR R0, SP, 4H |
0077 | n(A1E00008): STR R1, SP, 8H |
0078 | n(A2E0000C): STR R2, SP, CH |
0079 | o(5000FFD8): MOV R0, R0, FFFFFFD8H |
007A | o(80000000): LDR R0, R0, 0H |
007B | o(A0E00010): STR R0, SP, 10H |
| keys := SYSTEM.VAL(SET, w DIV 1000000H MODp 8)q;r |
007C | p(80E00010): LDR R0, SP, 10H |
007D | p(40020018): ASR R0, R0, 18H |
007E | q(40040007): AND R0, R0, 7H |
007F | r(81E00004): LDR R1, SP, 4H |
0080 | r(A0100000): STR R0, R1, 0H |
| x := w MOD 400H;s y := (w DIV 1000H)t MOD 400H;u |
0081 | s(80E00010): LDR R0, SP, 10H |
0082 | s(400403FF): AND R0, R0, 3FFH |
0083 | s(81E00008): LDR R1, SP, 8H |
0084 | s(A0100000): STR R0, R1, 0H |
0085 | t(80E00010): LDR R0, SP, 10H |
0086 | t(4002000C): ASR R0, R0, CH |
0087 | u(400403FF): AND R0, R0, 3FFH |
0088 | u(81E0000C): LDR R1, SP, CH |
0089 | u(A0100000): STR R0, R1, 0H |
| IF y >= MH THENv y := MH-1 ENDw |
008A | v(80E0000C): LDR R0, SP, CH |
008B | v(80000000): LDR R0, R0, 0H |
008C | v .FIXUP D |
008C | v(8D00001D): LDR SB, MT, MOD0 [Input] |
008D | v(81D00010): LDR R1, SB, 10H [data] |
008E | v(00090001): SUB R0, R0, R1 |
008F | v(E5000005): BLT 5 [0095H] |
0090 | w .FIXUP D |
0090 | w(8D000004): LDR SB, MT, MOD0 [Input] |
0091 | w(80D00010): LDR R0, SB, 10H [data] |
0092 | w(40090001): SUB R0, R0, 1H |
0093 | w(81E0000C): LDR R1, SP, CH |
0094 | w(A0100000): STR R0, R1, 0H |
| ENDx Mouse; |
0095 | x(8FE00000): LDR LNK, SP, 0H |
0096 | x(4EE80014): ADD SP, SP, 14H |
0097 | x(C700000F): B LNK |
| |
| PROCEDURE SetMouseLimits*(w, h: INTEGER); |
| BEGINy MW := w;z MH := h |
0098 | y .PROC 4 |
0098 | y(4EE9000C): SUB SP, SP, CH |
0099 | y(AFE00000): STR LNK, SP, 0H |
009A | y(A0E00004): STR R0, SP, 4H |
009B | y(A1E00008): STR R1, SP, 8H |
009C | z(80E00004): LDR R0, SP, 4H |
009D | z .FIXUP D |
009D | z(8D00000D): LDR SB, MT, MOD0 [Input] |
009E | z(A0D0000C): STR R0, SB, CH [data] |
| ENDa SetMouseLimits; |
009F | a(80E00008): LDR R0, SP, 8H |
00A0 | a(A0D00010): STR R0, SB, 10H |
00A1 | a(8FE00000): LDR LNK, SP, 0H |
00A2 | a(4EE8000C): ADD SP, SP, CH |
00A3 | a(C700000F): B LNK |
| |
| PROCEDURE Init*; |
| BEGINb Up := FALSE;c Shift := FALSE;d Ctrl := FALSE;e Recd := FALSE;f |
00A4 | b .PROC 5 |
00A4 | b .COMMAND Init |
00A4 | b(4EE90004): SUB SP, SP, 4H |
00A5 | b(AFE00000): STR LNK, SP, 0H |
00A6 | c(40000000): MOV R0, R0, 0H |
00A7 | c .FIXUP D |
00A7 | c(8D00000A): LDR SB, MT, MOD0 [Input] |
00A8 | c(B0D00002): STR R0, SB, 2H [data] |
00A9 | d(40000000): MOV R0, R0, 0H |
00AA | d(B0D00003): STR R0, SB, 3H |
00AB | e(40000000): MOV R0, R0, 0H |
00AC | e(B0D00004): STR R0, SB, 4H |
00AD | f(40000000): MOV R0, R0, 0H |
00AE | f(B0D00001): STR R0, SB, 1H |
| KTabAdr := SYSTEM.ADR($
00 00 00 00 00 1A 00 00 00 00 00 00 00 09 60 00
00 00 00 00 00 71 31 00 00 00 7A 73 61 77 32 00
00 63 78 64 65 34 33 00 00 20 76 66 74 72 35 00
00 6E 62 68 67 79 36 00 00 00 6D 6A 75 37 38 00
00 2C 6B 69 6F 30 39 00 00 2E 2F 6C 3B 70 2D 00
00 00 27 00 5B 3D 00 00 00 00 0D 5D 00 5C 00 00
00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00
00 7F 00 00 00 00 1B 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 09 7E 00
00 00 00 00 00 51 21 00 00 00 5A 53 41 57 40 00
00 43 58 44 45 24 23 00 00 20 56 46 54 52 25 00
00 4E 42 48 47 59 5E 00 00 00 4D 4A 55 26 2A 00
00 3C 4B 49 4F 29 28 00 00 3E 3F 4C 3A 50 5F 00
00 00 22 00 7B 2B 00 00 00 00 0D 7D 00 7C 00 00
00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00
00 7F 00 00 00 00 1B 00 00 00 00 00 00 00 00 00$) |
| ENDg Init; |
00AF | g(40D80020): ADD R0, SB, 20H |
00B0 | g(A0D00008): STR R0, SB, 8H |
00B1 | g(8FE00000): LDR LNK, SP, 0H |
00B2 | g(4EE80004): ADD SP, SP, 4H |
00B3 | g(C700000F): B LNK |
| |
| BEGINh Init |
00B4 | h .PROC 0 |
00B4 | h .ENTRYPOINT |
00B4 | h(4EE90004): SUB SP, SP, 4H |
00B5 | h(AFE00000): STR LNK, SP, 0H |
| ENDi Input.j |
00B6 | i(F7FFFFED): BL -19 [00A4H] |
00B7 | j(8FE00000): LDR LNK, SP, 0H |
00B8 | j(4EE80004): ADD SP, SP, 4H |
00B9 | j(C700000F): B LNK |