• Keyboard layout/character set question

    From Colin Leroy-Mira@21:1/5 to All on Fri Jan 20 09:03:02 2023
    Hi,

    I have a french Apple 2c, with a french keyboard and a toggle button
    that allows to switch the keyboard layout from french to US. The button
    has two effects. It switches characters codes for standard ASCII
    characters (ie, 'a' becomes 'q' and vice-versa), but for "extended"
    characters, the code is not changed, only the display is.
    For example, if I hit 'é' while in french mode, it's going to display as
    'é'. If I toggle the keyboard to US when an 'é' is displayed on-screen,
    the display of this character changes and becomes an '{'. (this is
    quite funny, but a bit impractical).

    I'd like to programmaticaly know which mode the keyboard is in, but I
    can't find anything related in PEEKs and POKEs or anything. Does anyone
    know if this is possible ?

    Thanks!
    --
    Colin
    https://www.colino.net/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stu M@21:1/5 to Colin Leroy-Mira on Fri Jan 20 20:24:57 2023
    On Friday, January 20, 2023 at 3:03:05 AM UTC-5, Colin Leroy-Mira wrote:
    Hi,

    I have a french Apple 2c, with a french keyboard and a toggle button
    that allows to switch the keyboard layout from french to US. The button
    has two effects. It switches characters codes for standard ASCII
    characters (ie, 'a' becomes 'q' and vice-versa), but for "extended" characters, the code is not changed, only the display is.
    For example, if I hit 'é' while in french mode, it's going to display as 'é'. If I toggle the keyboard to US when an 'é' is displayed on-screen, the display of this character changes and becomes an '{'. (this is
    quite funny, but a bit impractical).

    I'd like to programmaticaly know which mode the keyboard is in, but I
    can't find anything related in PEEKs and POKEs or anything. Does anyone
    know if this is possible ?

    Thanks!
    --
    Colin
    https://www.colino.net/

    I don't know for sure, this is probably more a hardware question than a software question, but I'd guess it's not possible.
    I did a lot of playing around with the keyboard (I had a U.S. apple //e) and the only available information was the key pressed, read from $C000 and the high bit of the $C010 soft switch was the any-key-down flag.

    So if you're going to probe around, I'd look at the bits in $C010 and probably the other bytes from $C001 to $C010 and see if they show any change when the switch is flipped.

    My guess is that this is done in hardware and never makes it to the software side of the machine.

    I only remember this so well, because I played around a lot with the keyboard trying to make the $C010 any-key-down flag line up with the byte read from $C000 to tell me what key was down. But the important bit there is that the auto-repeat feature of
    the keyboard is in hardware and not adjustable or even detectable in software, which is why I'm going to guess that your switch isn't either.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Colin Leroy-Mira@21:1/5 to All on Tue Jan 24 11:36:42 2023
    Hi,

    So if you're going to probe around, I'd look at the bits in $C010 and >probably the other bytes from $C001 to $C010 and see if they show any
    change when the switch is flipped.

    Thanks for your reply Stu.

    I've checked and see no bit move in this region when toggling the
    keyboard layout switch.

    Well, that was worth trying ! Thanks :)
    --
    Colin
    https://www.colino.net/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From fadden@21:1/5 to Colin Leroy-Mira on Tue Jan 24 07:40:27 2023
    On Tuesday, January 24, 2023 at 2:36:47 AM UTC-8, Colin Leroy-Mira wrote:
    I've checked and see no bit move in this region when toggling the
    keyboard layout switch.

    Well, that was worth trying ! Thanks :)

    Another good place to ask: https://retrocomputing.stackexchange.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Antoine Vignau@21:1/5 to All on Tue Jan 24 12:27:09 2023
    Hi All,

    Here are the //c firmware equates:

    SBTL "Apple //c Video Firmware"
    ********************************
    *
    * Apple //c
    * Video Firmware and
    * Monitor ROM Source
    *
    * COPYRIGHT 1977-1983 BY
    * APPLE COMPUTER, INC.
    *
    * ALL RIGHTS RESERVED
    *
    * S. WOZNIAK 1977
    * A. BAUM 1977
    * JOHN A NOV 1978
    * R. AURICCHIO SEP 1981
    * E. BEERNINK 1983
    *
    ********************************
    *
    * ZERO PAGE EQUATES
    *
    LOC0 EQU $00 ;vector for autostart from disk
    LOC1 EQU $01
    WNDLFT EQU $20 ;left edge of text window
    WNDWDTH EQU $21 ;width of text window
    WNDTOP EQU $22 ;top of text window
    WNDBTM EQU $23 ;bottom+1 of text window
    CH EQU $24 ;cursor horizontal position
    CV EQU $25 ;cursor vertical position
    GBASL EQU $26 ;lo-res graphics base addr.
    GBASH EQU $27
    BASL EQU $28 ;text base address
    BASH EQU $29
    BAS2L EQU $2A ;temp base for scrolling
    BAS2H EQU $2B
    H2 EQU $2C ;temp for lo-res graphics
    LMNEM EQU $2C ;temp for mnemonic decoding
    RTNL equ $2C ;Step return address
    V2 EQU $2D ;temp for lo-res graphics
    RMNEM EQU $2D ;temp for mnemonic decoding
    rtnh equ $2D ;Step return address
    MASK EQU $2E ;color mask for lo-res gr.
    FORMAT EQU $2E ;temp for opcode decode
    LENGTH EQU $2F ;temp for opcode decode
    COLOR EQU $30 ;color for lo-res graphics
    MODE EQU $31 ;Monitor mode
    INVFLG EQU $32 ;normal/inverse(/flash)
    PROMPT EQU $33 ;prompt character
    YSAV EQU $34 ;position in Monitor command
    YSAV1 EQU $35 ;temp for Y register
    CSWL EQU $36 ;character output hook
    CSWH EQU $37
    KSWL EQU $38 ;character input hook
    KSWH EQU $39
    PCL EQU $3A ;temp for program counter
    PCH EQU $3B
    XQT EQU $3C ;Step and trace execute area
    A1L EQU $3C ;Monitor temp
    A1H EQU $3D ;Monitor temp
    A2L EQU $3E ;Monitor temp
    A2H EQU $3F ;Monitor temp
    A3L EQU $40 ;Monitor temp
    A3H EQU $41 ;Monitor temp
    A4L EQU $42 ;Monitor temp
    A4H EQU $43 ;Monitor temp
    A5L EQU $44 ;Monitor temp
    A5H EQU $45 ;Monitor temp
    *
    * Note: In Apple II, //e, both interrupts and BRK destroyed
    * location $45. Now only BRK destroys $45 (ACC) and it
    * also destroys $44 (MACSTAT).
    *
    MACSTAT EQU $44 ;Machine state after BRK
    ACC EQU $45 ;Acc after BRK
    *
    XREG EQU $46 ;X reg after break
    YREG EQU $47 ;Y reg after break
    STATUS EQU $48 ;P reg after break
    SPNT EQU $49 ;SP after break
    RNDL EQU $4E ;random counter low
    RNDH EQU $4F ;random counter high
    *
    * Value equates
    *
    GOODF8 EQU $06 ;value of //e, lolly ID byte
    PICK EQU $95 ;CONTROL-U character
    ESC EQU $9B ;what ESC generates
    *
    * Characters read by GETLN are placed in
    * IN, terminated by a carriage return.
    *
    IN EQU $0200 ;input buffer for GETLN
    *
    * Page 3 vectors
    *
    BRKV EQU $03F0 ;vectors here after break
    SOFTEV EQU $03F2 ;vector for warm start
    PWREDUP EQU $03F4 ;THIS MUST = EOR #$A5 OF SOFTEV+1
    AMPERV EQU $03F5 ;APPLESOFT & EXIT VECTOR
    USRADR EQU $03F8 ;APPLESOFT USR function vector
    NMI EQU $03FB ;NMI vector
    IRQLOC EQU $03FE ;Maskable interrupt vector
    LINE1 EQU $0400 ;first line of text screen
    MSLOT EQU $07F8 ;owner of $C8 space
    *
    * HARDWARE EQUATES
    *
    IOADR EQU $C000 ;for IN#, PR# vector
    KBD EQU $C000 ;>127 if keystroke
    CLR80COL EQU $C000 ;disable 80 column store
    SET80COL EQU $C001 ;enable 80 column store
    RDMAINRAM EQU $C002 ;read from main 48K RAM
    RDCARDRAM EQU $C003 ;read from alt. 48K RAM
    WRMAINRAM EQU $C004 ;write to main 48K RAM
    WRCARDRAM EQU $C005 ;write to alt. 48K RAM
    SETSTDZP EQU $C008 ;use main zero page/stack
    SETALTZP EQU $C009 ;use alt. zero page/stack
    CLR80VID EQU $C00C ;disable 80 column hardware
    SET80VID EQU $C00D ;enable 80 column hardware
    CLRALTCHAR EQU $C00E ;normal LC, flashing UC
    SETALTCHAR EQU $C00F ;normal inverse, LC; no flash
    KBDSTRB EQU $C010 ;turn off key pressed flag
    RDLCBNK2 EQU $C011 ;>127 if LC bank 2 is in
    RDLCRAM EQU $C012 ;>127 if LC RAM read enabled
    RDRAMRD EQU $C013 ;>127 if reading main 48K
    RDRAMWRT EQU $C014 ;>127 if writing main 48K
    RDALTZP EQU $C016 ;>127 if Alt ZP and LC switched in
    RD80COL EQU $C018 ;>127 if 80 column store
    RDVBLBAR EQU $C019 ;>127 if not VBL
    RDTEXT EQU $C01A ;>127 if text (not graphics)
    RDMIX EQU $C01B ;>127 if mixed mode on
    RDPAGE2 EQU $C01C ;>127 if TXTPAGE2 switched in
    RDHIRES EQU $C01D ;>127 if HIRES is on
    ALTCHARSET EQU $C01E ;>127 if alternate char set in use
    RD80VID EQU $C01F ;>127 if 80 column hardware in
    ROMBANK EQU $C028 ;Switches rombanks
    SPKR EQU $C030 ;clicks the speaker
    TXTCLR EQU $C050 ;switch in graphics (not text)
    TXTSET EQU $C051 ;switch in text (not graphics)
    MIXCLR EQU $C052 ;clear mixed-mode
    MIXSET EQU $C053 ;set mixed-mode (4 lines text)
    TXTPAGE1 EQU $C054 ;switch in text page 1
    TXTPAGE2 EQU $C055 ;switch in text page 2
    LORES EQU $C056 ;low-resolution graphics
    HIRES EQU $C057 ;high-resolution graphics
    CLRAN0 EQU $C058
    SETAN0 EQU $C059
    CLRAN1 EQU $C05A
    SETAN1 EQU $C05B
    CLRAN2 EQU $C05C
    SETAN2 EQU $C05D
    CLRAN3 EQU $C05E
    SETAN3 EQU $C05F
    RD40SW EQU $C060 ;>127 if 40/80 switch in 40 pos
    BUTN0 EQU $C061 ;open apple key
    BUTN1 EQU $C062 ;closed apple key
    PADDL0 EQU $C064 ;read paddle 0
    PTRIG EQU $C070 ;trigger the paddles
    ROMIN EQU $C081 ;switch in $D000-$FFFF ROM
    LCBANK2 EQU $C083 ;switch in LC bank 2
    LCBANK1 EQU $C08B ;switch in LC bank 1
    CLRROM EQU $CFFF ;switch out $C8 ROMs
    BASIC EQU $E000 ;BASIC entry point
    BASIC2 EQU $E003 ;BASIC warm entry point
    *
    VMODE EQU $4F8+3 ;OPERATING MODE
    *
    * BASIC VMODE BITS
    *
    * 1....... - BASIC active
    * 0....... - Pascal active
    * .0......
    * .1......
    * ..0..... - Print control characters
    * ..1..... - Don't print ctrl chars
    * ...0.... -
    * ...1.... -
    * ....0... - Print control characters
    * ....1... - Don't print ctrl chars.
    * .....0.. -
    * .....1.. -
    * ......0. -
    * ......1. -
    * .......0 - Print mouse characters
    * .......1 - Don't print mouse characters
    *
    M.40 EQU $40
    M.CTL2 EQU $20 ;Don't print controls
    M.CTL EQU $08 ;Don't print controls
    M.MOUSE EQU $01 ;Don't print mouse chars
    *
    * Pascal Mode Bits
    *
    * 1....... - BASIC active
    * 0....... - Pascal active
    * .0......
    * .1......
    * ..0..... -
    * ..1..... -
    * ...0.... - Cursor always on
    * ...1.... - Cursor always off
    * ....0... - GOTOXY n/a
    * ....1... - GOTOXY in progress
    * .....0.. - Normal Video
    * .....1.. - Inverse Video
    * ......0. -
    * ......1. -
    * .......0 - Print mouse chars
    * .......1 - Don't print mouse chars
    *
    M.PASCAL EQU $80 ;Pascal active
    M.CURSOR EQU $10 ;Don't print cursor
    M.GOXY EQU $08 ;GOTOXY IN PROGRESS
    M.VMODE EQU $04
    *
    ROMSTATE EQU $478 ;temp store of ROM state
    TEMP1 EQU $4F8 ;used by CTLCHAR
    TEMPA EQU $578 ;used by scroll
    TEMPY EQU $5F8 ;used by scroll
    *
    OLDCH EQU $478+3 ;last value of CH
    OURCH EQU $578+3 ;80-COL CH
    OURCV EQU $5F8+3 ;CURSOR VERTICAL
    VFACTV EQU $678+3 ;Bit7=video firmware inactive
    XCOORD EQU $6F8+3 ;X-COORD (GOTOXY)
    NXTCUR EQU $778+3 ;next cursor to display
    CURSOR EQU $7F8+3 ;the current cursor char
    *
    * Disk II boot rom equates
    *
    DNIBL EQU $356
    NBUF1 EQU $300
    SLOTZ EQU $2B
    BOOTTMP EQU $3C
    BOOTDEV EQU $4F
    skp 3
    rep 40
    * Entry points for other modules
    rep 40
    pcnv equ $C880
    bootfail equ $C5F5 ;Boot fails message
    pcnvrst equ $C5F8 ;Protocol converter reset
    atalk equ $C580 ;Apple talk

    --
    Antoine

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael J. Mahon@21:1/5 to Stu M on Tue Jan 24 22:50:39 2023
    Stu M <[email protected]> wrote:
    On Friday, January 20, 2023 at 3:03:05 AM UTC-5, Colin Leroy-Mira wrote:
    Hi,

    I have a french Apple 2c, with a french keyboard and a toggle button
    that allows to switch the keyboard layout from french to US. The button
    has two effects. It switches characters codes for standard ASCII
    characters (ie, 'a' becomes 'q' and vice-versa), but for "extended"
    characters, the code is not changed, only the display is.
    For example, if I hit 'é' while in french mode, it's going to display as
    'é'. If I toggle the keyboard to US when an 'é' is displayed on-screen,
    the display of this character changes and becomes an '{'. (this is
    quite funny, but a bit impractical).

    I'd like to programmaticaly know which mode the keyboard is in, but I
    can't find anything related in PEEKs and POKEs or anything. Does anyone
    know if this is possible ?

    Thanks!
    --
    Colin
    https://www.colino.net/

    I don't know for sure, this is probably more a hardware question than a software question, but I'd guess it's not possible.
    I did a lot of playing around with the keyboard (I had a U.S. apple //e)
    and the only available information was the key pressed, read from $C000
    and the high bit of the $C010 soft switch was the any-key-down flag.

    So if you're going to probe around, I'd look at the bits in $C010 and probably the other bytes from $C001 to $C010 and see if they show any
    change when the switch is flipped.

    My guess is that this is done in hardware and never makes it to the
    software side of the machine.

    I only remember this so well, because I played around a lot with the
    keyboard trying to make the $C010 any-key-down flag line up with the byte read from $C000 to tell me what key was down. But the important bit there
    is that the auto-repeat feature of the keyboard is in hardware and not adjustable or even detectable in software, which is why I'm going to
    guess that your switch isn't either.

    Stu, the Any Key Down bit reports that one or more keys are depressed. The $C000 port reports the last key depressed. One or more keys can be held
    down, and the code at $C000 will change as any key is depressed. If I
    remember correctly, the key code is also reported at $C010 a few
    milliseconds before it shows up at $C000 (prior to denouncing).

    Take a look at the code for RTSYNTH on my website for details. This
    behavior is what allowed me to implement _glissando_ keying, in which a
    newly pressed key sounds even as other key(s) are being held down.

    --
    -michael - NadaNet 3.1 and AppleCrate II: http://michaeljmahon.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stu M@21:1/5 to [email protected] on Wed Jan 25 04:28:51 2023
    On Tuesday, January 24, 2023 at 5:50:45 PM UTC-5, [email protected] wrote:
    Stu M <[email protected]> wrote:
    On Friday, January 20, 2023 at 3:03:05 AM UTC-5, Colin Leroy-Mira wrote:
    Hi,

    I have a french Apple 2c, with a french keyboard and a toggle button
    that allows to switch the keyboard layout from french to US. The button >> has two effects. It switches characters codes for standard ASCII
    characters (ie, 'a' becomes 'q' and vice-versa), but for "extended"
    characters, the code is not changed, only the display is.
    For example, if I hit 'é' while in french mode, it's going to display as >> 'é'. If I toggle the keyboard to US when an 'é' is displayed on-screen, >> the display of this character changes and becomes an '{'. (this is
    quite funny, but a bit impractical).

    I'd like to programmaticaly know which mode the keyboard is in, but I
    can't find anything related in PEEKs and POKEs or anything. Does anyone >> know if this is possible ?

    Thanks!
    --
    Colin
    https://www.colino.net/

    I don't know for sure, this is probably more a hardware question than a software question, but I'd guess it's not possible.
    I did a lot of playing around with the keyboard (I had a U.S. apple //e) and the only available information was the key pressed, read from $C000 and the high bit of the $C010 soft switch was the any-key-down flag.

    So if you're going to probe around, I'd look at the bits in $C010 and probably the other bytes from $C001 to $C010 and see if they show any change when the switch is flipped.

    My guess is that this is done in hardware and never makes it to the software side of the machine.

    I only remember this so well, because I played around a lot with the keyboard trying to make the $C010 any-key-down flag line up with the byte read from $C000 to tell me what key was down. But the important bit there is that the auto-repeat feature of the keyboard is in hardware and not adjustable or even detectable in software, which is why I'm going to
    guess that your switch isn't either.

    Stu, the Any Key Down bit reports that one or more keys are depressed. The $C000 port reports the last key depressed. One or more keys can be held down, and the code at $C000 will change as any key is depressed. If I remember correctly, the key code is also reported at $C010 a few milliseconds before it shows up at $C000 (prior to denouncing).

    Take a look at the code for RTSYNTH on my website for details. This
    behavior is what allowed me to implement _glissando_ keying, in which a newly pressed key sounds even as other key(s) are being held down.

    --
    -michael - NadaNet 3.1 and AppleCrate II: http://michaeljmahon.com

    I remember spending a lot of time on this though I may forget some details.
    the big thing I remember is that there was lag on the data coming in on $C000, as in if you waited for the any-key-down bit to go high and then read from $C000 to find out what key was pressed, you'd get the previously pressed key for a few ms and then
    the correct key would show up.
    at the time I was trying to write a key-repeat input program so that you could alter the delay and repeat frequency of the auto-repeat feature of the keyboard, since you couldn't modify the hardware. and that little bit of lag made it unusable because
    when you're trying to type, the key you actually his is important. :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From qkumba@21:1/5 to All on Wed Jan 25 10:59:13 2023
    ...which is exactly the issue in Prince of Persia, which can register "false" keypresses as a result of the polling $C010 and then fetching the wrong key from $C000.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stu M@21:1/5 to qkumba on Wed Jan 25 12:26:50 2023
    On Wednesday, January 25, 2023 at 1:59:15 PM UTC-5, qkumba wrote:
    ...which is exactly the issue in Prince of Persia, which can register "false" keypresses as a result of the polling $C010 and then fetching the wrong key from $C000.

    I saw this in the apple ][ implementation of gauntlet as well. that game is what first clued me into the fact that there was an any-key-down flag in the first place, and then I found a one line comment about it in the apple ][ reference manual

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andrew Roughan@21:1/5 to qkumba on Mon Jan 30 11:29:37 2023
    qkumba <[email protected]> wrote:
    ...which is exactly the issue in Prince of Persia, which can register
    "false" keypresses as a result of the polling $C010 and then fetching the wrong key from $C000.


    There’s more information about this issue https://www.applefritter.com/comment/101047#comment-101047

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stu M@21:1/5 to Andrew Roughan on Mon Jan 30 13:15:46 2023
    On Monday, January 30, 2023 at 6:29:39 AM UTC-5, Andrew Roughan wrote:
    qkumba <[email protected]> wrote:
    ...which is exactly the issue in Prince of Persia, which can register "false" keypresses as a result of the polling $C010 and then fetching the wrong key from $C000.

    There’s more information about this issue https://www.applefritter.com/comment/101047#comment-101047


    so it took some digging, but I was finally able to find it.
    so somebody a long time ago asked a question on stackoverflow: what's the coolest hack you've ever seen or done.
    lots of great juicy stuff there and then some stuffy people went and deleted it.
    but thanks to technology, and the wonderful people at the internet archive, we still have it.

    https://web.archive.org/web/20150925080324/https://stackoverflow.com/questions/192479/whats-the-coolest-hack-youve-seen-or-done/510143

    search for "I've ever created was on my Apple //e" and you'll see my entry. somewhere along the way I was able to find a copy of the little program I came up with that correctly got the key that was pressed once you checked the any-key-down flag.

    What I *didn't* know, which I'm happy to finally find out, is why it works.

    Unfortunately, as noted here on page 7-12 of James Sather's book Understanding the Apple IIe, AKD does not wait for a key to be decoded, so software must "wait until KEYSTROBE is set before interpreting the keyboard ASCII.

    That little nugget of information is something I've been wanting to know for 30 something years now....

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)