* Convert IPC shifts and keyrows to character or special * d1 -i o- 6 lsb are keyrow (5-3 column, 2-0 row), see below for output * d2 -i - 3 lsb SHIFT/CTRL/ALT * a4 -ip - sysvar extension address * a6 -ip - sysvar * d0/d2 destroyed * This code may also destroy d6/a0-a1/a3 if it wants, and even a4, provided it * does not make a direct return. * Relevent input data to this code consists of: * sv_caps(a6) if non-zero, CAPS LOCK is on * sv_ichar(a6) zero: no compose * one: compose has been started * other: not used by this code * sx_kbste(a4) twelve bytes which are required to be remapped as * "special" keys. E.g. CTRL/F5 is done here. * Direct return, CTRL in combination with one of space, TAB or ENTER: * d1.w 0..11: Bit 0 = ALT, bit 1 = SHIFT, bit 2 = TAB, bit 3 = ENTER * Return + 2, normal characters: * d1.w msb 0 and lsb 8 bit char or ... * ... msb 8 bit char and lsb $FF if the ALT prefix ($FF) is required. * Return + 4, ignore this (compose first char stored or compose aborted) * d1.w undefined togqh moveq #$8C-256,d0 togq cmp.b d0,d1 compare high end of range bcc.s rts0 too big - no toggle and.b #$E1,d0 get low end of range cmp.b d0,d1 compare low end of range bcs.s rts0 too small - no toggle eor.b #32,d1 flip upper/lower case bit rts0 rts simple moveq #12-1,d0 counter and offset rdlp cmp.b sx_kbste(a4,d0.w),d1 dbeq d0,rdlp bne.s ret2 end of table, return normal move.w d0,d1 found a match, special return rts compose add.b d2,d2 was SHIFT on? bcc.s posalt bsr.s togqh yes - do capitalisation of high set posalt add.b d2,d2 totally ignore CTRL on compose qlck tst.b sv_caps(a6) is CAPS LOCK set beq.s qalt no - skip this bit moveq #'z'+1,d0 bsr.s togq bsr.s togqh qalt not.b d2 was ALT on? simp1 bmi.s simple no - go finish off lsl.w #8,d1 put char into msb st d1 put $FF into lsb ret2 addq.l #2,(sp) make a normal + 2 return rts curcap bsr.s roll put ALT in lsb bra.s simp1 this will be negative... tb_kbenc moveq #$3F,d0 and.w d0,d1 keep scan number asl.b #5,d2 put SCA bits in bits 7..5 tst.b sv_ichar(a6) are we composing? beq.s noshf no - carry on sf sv_ichar(a6) drop the compose flag move.b comptab-3(pc,d1.w),d1 get compose character bne.s compose real one - go do it addq.l #4,(sp) not valid - get out via ignore return rts noshf bsr.s roll fetch in SHIFT bsr.s roll fetch in CTRL move.b keytab-3*4(pc,d1.w),d1 get translated character cmp.b #$C0,d1 bcs.s qlck cmp.b #$E8,d1 bcc.s qalt asr.b #1,d1 cursor/CAPS or CTRL + space/TAB/ENTER bcc.s curcap sub.b #$DC>>1,d1 dump offset then put in ALT and special return roll add.b d2,d2 roll one bit from d2 ... addx.b d1,d1 ... into d1 rts * Main Translation Table * ---------------------- * The scan value (3..63) is multiplied by four, plus two for SHIFT and one * more for CTRL. * The range $C0 to $E7 are cursor keys and CAPS LOCK, which need the ALT bit * put into their lsb. * We utilise the fact that these all have a zero lsb so we can sort out our * special CTRL{/SHIFT}{/ALT} + space/TAB/ENTER. * These have the ODD values from $C1 to $CB given them. * Thus we distinguish them as we play with the ALT bit. * Some more code could be saved overall, but at the expense of making this * table rather more obscure. * Compose Key Table * ----------------- * The compose table is terribly simple here. There are no dual compose chars, * but we'd like 36 convenient single compose keys, which would need 72 bytes of * table, plus code, as opposed to storing the 63+1 bytes for direct lookup. * All entries are the un-"SHIFT"'ed characters, which we apply later. * Unused entries are set to zero to abort the compose. * Where there is a useful CTRL key, but we don't need the compose, we replicate * the CTRL character.