Close

20230219a -- File Sending Speed

A project log for ROM Disassembly - AlphaSmart Pro

Wherein I disassemble the ROM from a vintage typewriter-thing

ziggurat29ziggurat29 02/22/2023 at 13:510 Comments

While whizzing through the keyboard stuff, there is some special handling of some keystrokes.  This is by scan code, so it's difficult for me to puzzle out what they are.  One exception, though, is for setting the 'send speed'.  There is menu text showing the current speed and allowing changing the speed.

F034             changeSendSpeed_F034:
F034 BD F6 18        jsr     clearHomeLCD_F618 ; Clear LCD set cursor pos 0
F037 CE FD 76        ldx     #aToChangeSendSp ; "To change Send speed, type 1, 2, 3 or 4"...
F03A BD F6 69        jsr     showText_F669   ; show nts text @ X
F03D BD F7 4E        jsr     setcpLine1_F74E ; set cursor Line 1
F040 CE FD 9F        ldx     #a1VerySlow2Slow ; "    1: VERY Slow        2: Slow"
F043 BD F6 69        jsr     showText_F669   ; show nts text @ X
F046 BD F7 54        jsr     setcpLine2_F754 ; set cursor Line 2
F049 CE FD BF        ldx     #a3FastDefault4F ; "    3: Fast(default)    4: Fastest"
F04C BD F6 69        jsr     showText_F669   ; show nts text @ X
F04F BD F7 5A        jsr     setcpLine3_F75A ; set cursor Line 3
F052 CE FD E2        ldx     #aCurrentSetting ; "Current setting is "
F055 BD F6 69        jsr     showText_F669   ; show nts text @ X
F058 B6 01 5C        ldaa    kbdemuSpeed_15C ; XXX keyboard transfer speed (0, 1, 2, c8???)
F05B 81 00           cmpa    #0              ; 0 is very slow
F05D 26 04           bne     cont_F063
F05F C6 31           ldab    #'1'
F061 20 16           bra     showcurspeed_F079
F063             cont_F063:
F063 81 01           cmpa    #1              ; 1 is slow
F065 26 04           bne     cont_F06B
F067 C6 32           ldab    #'2'
F069 20 0E           bra     showcurspeed_F079
F06B             cont_F06B:
F06B 81 02           cmpa    #2              ; 2 is fast
F06D 26 04           bne     cont_F073
F06F C6 33           ldab    #'3'
F071 20 06           bra     showcurspeed_F079
F073             cont_F073:
F073 81 C8           cmpa    #$C8 ; '+'      ; c8 is fastest
F075 26 19           bne     loc_F090        ; unknown setting, force to 1, slow
F077 C6 34           ldab    #'4'
F079             showcurspeed_F079:
F079 BD F6 74        jsr     sendLCDbyteB_F674 ; send byte in B to LCD (w/ctrl as per 0x5b)
F07C             waitKey_F07C:
F07C BD E5 A0        jsr     scanKbd_E5A0    ; do key scan and enqueue
F07F BD EB EE        jsr     dequeueKbdScanCode_EBEE ; pull scan code A (rowno|colno) from keyboard buffer; V set if empty, clear if valid
F082 29 F8           bvs     waitKey_F07C
F084 81 5E           cmpa    #$5E            ; scan code for '1'
F086 26 04           bne     cont_F08C
F088 86 00           ldaa    #0
F08A 20 18           bra     storeSpeed_F0A4
F08C             cont_F08C:
F08C 81 5D           cmpa    #$5D            ; scan code for '2'
F08E 26 04           bne     cont_F094
F090             loc_F090:
F090 86 01           ldaa    #1
F092 20 10           bra     storeSpeed_F0A4
F094             cont_F094:
F094 81 5C           cmpa    #$5C            ; scan code for '3'
F096 26 04           bne     cont_F09C
F098 86 02           ldaa    #2
F09A 20 08           bra     storeSpeed_F0A4
F09C             cont_F09C:
F09C 81 51           cmpa    #$51            ; scan code for '4'
F09E 26 07           bne     leave_F0A7
F0A0 86 C8           ldaa    #$C8 ; '+'
F0A2 20 00           bra     *+2
F0A4             storeSpeed_F0A4:
F0A4 B7 01 5C        staa    kbdemuSpeed_15C ; XXX keyboard transfer speed (0, 1, 2, c8???)
F0A7             leave_F0A7:
F0A7 39              rts

Most of this is simply emitting text, translating a setting value to a textual equivalent for presentation, and waiting for a keystroke to change the value.  I am pretty sure that loc_15C is the current keyboard emulation speed, since it drives the text for the current setting and is updated when we change it.  So I renamed it to kbdemuSpeed_15C.

Since in this limited case we have well-know keys that are switched on in a understandable way, we can learn at least a few key scan codes for '1' - '4'.

It's a curiosity as to why the setting value is 0, 1, 2, and 0xc8 (???).  Maybe that will make sense later.

This routine is called from the keyboard handler at EE18:

EE08             loc_EE08:
EE08 81 56           cmpa    #$56
EE0A 27 25           beq     loc_EE31
EE0C 81 21           cmpa    #$21
EE0E 27 0E           beq     loc_EE1E
EE10 81 61           cmpa    #$61
EE12 27 17           beq     loc_EE2B
EE14 81 4D           cmpa    #$4D            ; scan code for 'S'
EE16 26 27           bne     loc_EE3F
EE18 BD F0 34        jsr     changeSendSpeed_F034
EE1B 7E EE DA        jmp     loc_EEDA

and since the manual states that option-clover-S is the sequence to get into the speed menu, we can infer that 0x4D is likely the scan code for 'S'.

Discussions