Oricutron keyboard handling

Comments, problems, suggestions about Oric emulators (Euphoric, Mess, Amoric, etc...) it's the right place to ask. And don't hesitate to give your tips and tricks that help using these emulations in the best possible way on your favorite operating system.
Post Reply
User avatar
Dbug
Site Admin
Posts: 3462
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Oricutron keyboard handling

Post by Dbug »

EDIT: I fixed the typo 512/521
I was doing some tests for a new OSDK article, and I was trying to check some typos in one of the Oric books, and ran this very simple program on both Oricutron (1.2 from OSDK) and my Atmos:

Code: Select all

10 PRINT PEEK(521)
20 GOTO 10
The expected behavior is to display 56 if no key is pressed, 162 if CONTROL is pressed, 164 for LEFT SHIFT, 165 for FUNCTION and 167 for RIGHT SHIFT.

What I noticed is that on the real Oric if I press LEFT SHIFT I see 164, and if I keep pressing LEFT SHIFT and then press RIGHT SHIFT I see 167, and if I release RIGHT SHIFT it goes back to 164.

In Oricutron, the second key is never detected, on the real machine it seems that keys with higher values override whatever is pressed.

Bonus question: In Oricutron if I press ALT, I see the value 166, which is not in the documented list, and I was not able to find the FUNCTION key (possibly 166 was actually FUNCTION but registered as 166 instead of 165?)

User avatar
iss
Wing Commander
Posts: 1129
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Oricutron keyboard handling

Post by iss »

Dbug wrote:
Sun Aug 23, 2020 2:38 pm
PEEK(512) ? :shock:
This code:

Code: Select all

10 PRINT PEEK(#209)
20 GOTO 10
works as expected in recent version of Oricutron.
Small detail: LEFT ALT is reported as 165 and RIGHT ALT as 166.

EDIT: #209 = 521 :), so it's simply a typo in your code.
EDIT2: I've tested (under Linux with wine) Oricutron 1.2 from OSDK and it works fine for me.

User avatar
Dbug
Site Admin
Posts: 3462
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oricutron keyboard handling

Post by Dbug »

I mis-typed in the forum post, I did use 521 in the actual code.
OricutronKeyboardProblem.png
So, LEFT ALT is FUNCTION?
I guess I can mention that RIGHT ALT can be detected as 166 but will only work on emulator
EDIT2: I've tested (under Linux with wine) Oricutron 1.2 from OSDK and it works fine for me.
That's weird.
I wonder where this behavior difference comes from, in my version whatever key I pressed first stays the one displayed, all the subsequent key presses are ignored.

User avatar
iss
Wing Commander
Posts: 1129
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Oricutron keyboard handling

Post by iss »

Hmmm, very interesting thing happens (Oricutron's version doesn't matter)!
It seems that there is a kind of priority depending on which key is pressed first.
For instance if you press and hold RSHIFT then no other key is registered.
If you press and hold RALT then only RSHIFT is indicated... and so on.

Finally the priority is: RSHIFT, RALT, LALT, LSHIFT, LCTRL, RCTRL
and the rule is: pressed key blocks all other key(s) on its right in the above order. :)

Interesting for further investigation is if this behavior happens only when ROM routine is used?
I.e what happens when we use the custom keyboard routine from OSDK?

I'll test later how this works with real Oric-1/Atmos too.

User avatar
Dbug
Site Admin
Posts: 3462
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oricutron keyboard handling

Post by Dbug »

I'm not sure, I only started the article, and I'm starting high level from the rom routines, I only reached these ways to access the modifier keys and posted my messages, but yes, I'm planning to explain how to read the keyboard manually, and what that implies in comparison to use the ROM code.

User avatar
goyo
Officer Cadet
Posts: 35
Joined: Sat Jan 12, 2019 10:16 am

Re: Oricutron keyboard handling

Post by goyo »

Nice documentation !
When I exit my program how to restore ROM IRQ Handler after use the IRQ ASM Handler routine ? :?:

User avatar
Dbug
Site Admin
Posts: 3462
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Oricutron keyboard handling

Post by Dbug »

goyo wrote:
Wed Sep 09, 2020 3:41 pm
Nice documentation !
When I exit my program how to restore ROM IRQ Handler after use the IRQ ASM Handler routine ? :?:
Generally what I do is to have a "Restore" function that does the same thing as the existing "InstallIRQ" routine, and what the InstallIRQ routine does is to modify the values in the Restore one, something like that:

Code: Select all

InstallIRQ
    ; Patch IRQ vector
    lda IRQ_ADDRLO
    sta restore_low+1
    lda #<irq_routine 
    sta IRQ_ADDRLO

    lda IRQ_ADDRHI
    sta restore_high+1
    lda #>irq_routine 
    sta IRQ_ADDRHI

RestoreIRQ
    ; Patch IRQ vector
restore_low
    lda #00
    sta IRQ_ADDRLO
restore_high
    lda #00
    sta IRQ_ADDRHI

User avatar
goyo
Officer Cadet
Posts: 35
Joined: Sat Jan 12, 2019 10:16 am

Re: Oricutron keyboard handling

Post by goyo »

Dbug wrote:
Wed Sep 09, 2020 5:54 pm
goyo wrote:
Wed Sep 09, 2020 3:41 pm
Nice documentation !
When I exit my program how to restore ROM IRQ Handler after use the IRQ ASM Handler routine ? :?:
Generally what I do is to have a "Restore" function that does the same thing as the existing "InstallIRQ" routine, and what the InstallIRQ routine does is to modify the values in the Restore one, something like that:

Code: Select all

InstallIRQ
    ; Patch IRQ vector
    lda IRQ_ADDRLO
    sta restore_low+1
    lda #<irq_routine 
    sta IRQ_ADDRLO

    lda IRQ_ADDRHI
    sta restore_high+1
    lda #>irq_routine 
    sta IRQ_ADDRHI

RestoreIRQ
    ; Patch IRQ vector
restore_low
    lda #00
    sta IRQ_ADDRLO
restore_high
    lda #00
    sta IRQ_ADDRHI
Nice ! Thank you Dbug :-)

Post Reply