Input

Used Exports

BUILTINS: BOOLEAN BYTE CHAR CHR INC INTEGER ORD SET
SYSTEM: ADR BIT GET VAL

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
0000a(4EE90004): SUB SP, SP, 4H
0001a(AFE00000): STR LNK, SP, 0H
IF SYSTEM.BIT(msAdr, 28) THENb
0002b(5000FFD8): MOV R0, R0, FFFFFFD8H
0003b(80000000): LDR R0, R0, 0H
0004b(4003001D): ROR R0, R0, 1DH
0005b(E800003C): BPL 60 [0042H]
SYSTEM.GET(kbdAdr, kbdCode);c
0006c(5000FFDC): MOV R0, R0, FFFFFFDCH
0007c(90000000): LDR R0, R0, 0H
0008c .FIXUP D
0008c(8D000008): LDR SB, MT, MOD0 [Input]
0009c(B0D00000): STR R0, SB, 0H [data]
IF kbdCode = 0F0H THENd Up := TRUE
000Ad(90D00000): LDR R0, SB, 0H
000Bd(400900F0): SUB R0, R0, F0H
000Cd(E9000004): BNE 4 [0011H]
ELSIFe kbdCodef = 0E0H THENg Ext := TRUE
000De(40000001): MOV R0, R0, 1H
000Ee .FIXUP D
000Ee(8D000006): LDR SB, MT, MOD0 [Input]
000Fe(B0D00002): STR R0, SB, 2H [data]
0010f(E7000031): B 49 [0042H]
0011g .FIXUP D
0011g(8D000003): LDR SB, MT, MOD0 [Input]
0012g(90D00000): LDR R0, SB, 0H [data]
0013g(400900E0): SUB R0, R0, E0H
0014g(E9000004): BNE 4 [0019H]
ELSEh
0015h(40000001): MOV R0, R0, 1H
0016h .FIXUP D
0016h(8D000005): LDR SB, MT, MOD0 [Input]
0017h(B0D00005): STR R0, SB, 5H [data]
IFi (kbdCode = 12H)j OR (kkbdCode = 59H)l THENm (*shift*) Shift := ~Up
0018i(E7000029): B 41 [0042H]
0019j .FIXUP D
0019j(8D000003): LDR SB, MT, MOD0 [Input]
001Aj(90D00000): LDR R0, SB, 0H [data]
001Bj(40090012): SUB R0, R0, 12H
001Ck(E1000004): BEQ 4 [0021H]
001Dl .FIXUP D
001Dl(8D000004): LDR SB, MT, MOD0 [Input]
001El(90D00000): LDR R0, SB, 0H [data]
001Fl(40090059): SUB R0, R0, 59H
0020m(E9000009): BNE 9 [002AH]
ELSIFn kbdCodeo = 14H THENp (*ctrl*) Ctrl := ~Up
0021n .FIXUP D
0021n(8D000004): LDR SB, MT, MOD0 [Input]
0022n(90D00002): LDR R0, SB, 2H [data]
0023n(E9000002): BNE 2 [0026H]
0024n(40000001): MOV R0, R0, 1H
0025n(E7000001): B 1 [0027H]
0026n(40000000): MOV R0, R0, 0H
0027n .FIXUP D
0027n(8D000006): LDR SB, MT, MOD0 [Input]
0028n(B0D00003): STR R0, SB, 3H [data]
0029o(E7000013): B 19 [003DH]
002Ap .FIXUP D
002Ap(8D000003): LDR SB, MT, MOD0 [Input]
002Bp(90D00000): LDR R0, SB, 0H [data]
002Cp(40090014): SUB R0, R0, 14H
002Dp(E9000009): BNE 9 [0037H]
ELSIFq ~rUp THENs Recd := TRUE (*real key going down*)
002Eq .FIXUP D
002Eq(8D000004): LDR SB, MT, MOD0 [Input]
002Fq(90D00002): LDR R0, SB, 2H [data]
0030q(E9000002): BNE 2 [0033H]
0031q(40000001): MOV R0, R0, 1H
0032q(E7000001): B 1 [0034H]
0033q(40000000): MOV R0, R0, 0H
0034q .FIXUP D
0034q(8D000006): LDR SB, MT, MOD0 [Input]
0035q(B0D00004): STR R0, SB, 4H [data]
0036r(E7000006): B 6 [003DH]
0037s .FIXUP D
0037s(8D000003): LDR SB, MT, MOD0 [Input]
0038s(90D00002): LDR R0, SB, 2H [data]
0039s(E9000003): BNE 3 [003DH]
ENDt ;
003At(40000001): MOV R0, R0, 1H
003Bt .FIXUP D
003Bt(8D000004): LDR SB, MT, MOD0 [Input]
003Ct(B0D00001): STR R0, SB, 1H [data]
Up := FALSE;u Ext := FALSE
003Du(40000000): MOV R0, R0, 0H
003Eu .FIXUP D
003Eu(8D000003): LDR SB, MT, MOD0 [Input]
003Fu(B0D00002): STR R0, SB, 2H [data]
ENDv
0040v(40000000): MOV R0, R0, 0H
0041v(B0D00005): STR R0, SB, 5H
END;
ENDw Peek;
0042w(8FE00000): LDR LNK, SP, 0H
0043w(4EE80004): ADD SP, SP, 4H
0044w(C700000F): B LNK
PROCEDURE Available*(): INTEGER;
BEGINx Peek();y
0045x .PROC 1
0045x(4EE90004): SUB SP, SP, 4H
0046x(AFE00000): STR LNK, SP, 0H
0047y(F7FFFFB8): BL -72 [0000H]
RETURN ORD(Recd)
ENDz Available;
0048z .FIXUP D
0048z(8D00000A): LDR SB, MT, MOD0 [Input]
0049z(90D00001): LDR R0, SB, 1H [data]
004Az(8FE00000): LDR LNK, SP, 0H
004Bz(4EE80004): ADD SP, SP, 4H
004Cz(C700000F): B LNK
PROCEDURE Read*(VAR ch: CHAR);
BEGINa
004Da .PROC 2
004Da(4EE90008): SUB SP, SP, 8H
004Ea(AFE00000): STR LNK, SP, 0H
004Fa(A0E00004): STR R0, SP, 4H
WHILE ~Recd DOb Peek() ENDc ;
0050b .FIXUP D
0050b(8D000008): LDR SB, MT, MOD0 [Input]
0051b(90D00001): LDR R0, SB, 1H [data]
0052b(E9000002): BNE 2 [0055H]
0053c(F7FFFFAC): BL -84 [0000H]
0054c(E7FFFFFB): B -5 [0050H]
IF Shift OR Ctrld THENe INC(kbdCode, 80H) ENDf; (*ctrl implies shift*)
0055d .FIXUP D
0055d(8D000005): LDR SB, MT, MOD0 [Input]
0056d(90D00003): LDR R0, SB, 3H [data]
0057d(E9000003): BNE 3 [005BH]
0058e .FIXUP D
0058e(8D000003): LDR SB, MT, MOD0 [Input]
0059e(90D00004): LDR R0, SB, 4H [data]
005Ae(E1000005): BEQ 5 [0060H]
005Bf .FIXUP D
005Bf(8D000003): LDR SB, MT, MOD0 [Input]
005Cf(40D80000): ADD R0, SB, 0H [data]
005Df(91000000): LDR R1, R0, 0H
005Ef(41180080): ADD R1, R1, 80H
005Ff(B1000000): STR R1, R0, 0H
(* ch := kbdTab[kbdCode]; *)
SYSTEM.GET(KTabAdr + kbdCode,g ch);h
0060g .FIXUP D
0060g(8D000005): LDR SB, MT, MOD0 [Input]
0061g(80D00008): LDR R0, SB, 8H [data]
0062g(91D00000): LDR R1, SB, 0H
0063g(00080001): ADD R0, R0, R1
0064h(90000000): LDR R0, R0, 0H
0065h(81E00004): LDR R1, SP, 4H
0066h(B0100000): STR R0, R1, 0H
IF Ctrl THENi ch := CHR(ORD(ch) MODj 20H)k ENDl;
0067i(90D00004): LDR R0, SB, 4H
0068i(E1000005): BEQ 5 [006EH]
0069j(80E00004): LDR R0, SP, 4H
006Aj(90000000): LDR R0, R0, 0H
006Bk(4004001F): AND R0, R0, 1FH
006Cl(81E00004): LDR R1, SP, 4H
006Dl(B0100000): STR R0, R1, 0H
Recd := FALSE
ENDm Read;
006Em(40000000): MOV R0, R0, 0H
006Fm .FIXUP D
006Fm(8D00000F): LDR SB, MT, MOD0 [Input]
0070m(B0D00001): STR R0, SB, 1H [data]
0071m(8FE00000): LDR LNK, SP, 0H
0072m(4EE80008): ADD SP, SP, 8H
0073m(C700000F): B LNK
PROCEDURE Mouse*(VAR keys: SET; VAR x, y: INTEGER);
VAR w: INTEGER;
BEGINn SYSTEM.GET(msAdr, w);o
0074n .PROC 3
0074n(4EE90014): SUB SP, SP, 14H
0075n(AFE00000): STR LNK, SP, 0H
0076n(A0E00004): STR R0, SP, 4H
0077n(A1E00008): STR R1, SP, 8H
0078n(A2E0000C): STR R2, SP, CH
0079o(5000FFD8): MOV R0, R0, FFFFFFD8H
007Ao(80000000): LDR R0, R0, 0H
007Bo(A0E00010): STR R0, SP, 10H
keys := SYSTEM.VAL(SET, w DIV 1000000H MODp 8)q;r
007Cp(80E00010): LDR R0, SP, 10H
007Dp(40020018): ASR R0, R0, 18H
007Eq(40040007): AND R0, R0, 7H
007Fr(81E00004): LDR R1, SP, 4H
0080r(A0100000): STR R0, R1, 0H
x := w MOD 400H;s y := (w DIV 1000H)t MOD 400H;u
0081s(80E00010): LDR R0, SP, 10H
0082s(400403FF): AND R0, R0, 3FFH
0083s(81E00008): LDR R1, SP, 8H
0084s(A0100000): STR R0, R1, 0H
0085t(80E00010): LDR R0, SP, 10H
0086t(4002000C): ASR R0, R0, CH
0087u(400403FF): AND R0, R0, 3FFH
0088u(81E0000C): LDR R1, SP, CH
0089u(A0100000): STR R0, R1, 0H
IF y >= MH THENv y := MH-1 ENDw
008Av(80E0000C): LDR R0, SP, CH
008Bv(80000000): LDR R0, R0, 0H
008Cv .FIXUP D
008Cv(8D00001D): LDR SB, MT, MOD0 [Input]
008Dv(81D00010): LDR R1, SB, 10H [data]
008Ev(00090001): SUB R0, R0, R1
008Fv(E5000005): BLT 5 [0095H]
0090w .FIXUP D
0090w(8D000004): LDR SB, MT, MOD0 [Input]
0091w(80D00010): LDR R0, SB, 10H [data]
0092w(40090001): SUB R0, R0, 1H
0093w(81E0000C): LDR R1, SP, CH
0094w(A0100000): STR R0, R1, 0H
ENDx Mouse;
0095x(8FE00000): LDR LNK, SP, 0H
0096x(4EE80014): ADD SP, SP, 14H
0097x(C700000F): B LNK
PROCEDURE SetMouseLimits*(w, h: INTEGER);
BEGINy MW := w;z MH := h
0098y .PROC 4
0098y(4EE9000C): SUB SP, SP, CH
0099y(AFE00000): STR LNK, SP, 0H
009Ay(A0E00004): STR R0, SP, 4H
009By(A1E00008): STR R1, SP, 8H
009Cz(80E00004): LDR R0, SP, 4H
009Dz .FIXUP D
009Dz(8D00000D): LDR SB, MT, MOD0 [Input]
009Ez(A0D0000C): STR R0, SB, CH [data]
ENDa SetMouseLimits;
009Fa(80E00008): LDR R0, SP, 8H
00A0a(A0D00010): STR R0, SB, 10H
00A1a(8FE00000): LDR LNK, SP, 0H
00A2a(4EE8000C): ADD SP, SP, CH
00A3a(C700000F): B LNK
PROCEDURE Init*;
BEGINb Up := FALSE;c Shift := FALSE;d Ctrl := FALSE;e Recd := FALSE;f
00A4b .PROC 5
00A4b .COMMAND Init
00A4b(4EE90004): SUB SP, SP, 4H
00A5b(AFE00000): STR LNK, SP, 0H
00A6c(40000000): MOV R0, R0, 0H
00A7c .FIXUP D
00A7c(8D00000A): LDR SB, MT, MOD0 [Input]
00A8c(B0D00002): STR R0, SB, 2H [data]
00A9d(40000000): MOV R0, R0, 0H
00AAd(B0D00003): STR R0, SB, 3H
00ABe(40000000): MOV R0, R0, 0H
00ACe(B0D00004): STR R0, SB, 4H
00ADf(40000000): MOV R0, R0, 0H
00AEf(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;
00AFg(40D80020): ADD R0, SB, 20H
00B0g(A0D00008): STR R0, SB, 8H
00B1g(8FE00000): LDR LNK, SP, 0H
00B2g(4EE80004): ADD SP, SP, 4H
00B3g(C700000F): B LNK
BEGINh Init
00B4h .PROC 0
00B4h .ENTRYPOINT
00B4h(4EE90004): SUB SP, SP, 4H
00B5h(AFE00000): STR LNK, SP, 0H
ENDi Input.j
00B6i(F7FFFFED): BL -19 [00A4H]
00B7j(8FE00000): LDR LNK, SP, 0H
00B8j(4EE80004): ADD SP, SP, 4H
00B9j(C700000F): B LNK