English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 22 September 2018, 18:16   #21
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Photon View Post
I'm not 100% sure this routine is compatible with A2000 keyboards made by Cherry (difference in behavior). All hardware routines should be checked on this combo(!)
What's the difference? Timing for the handshake?
(on my routine I wait 85us)
ross is offline  
Old 22 September 2018, 21:49   #22
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@Photon
As I see in ChkKey.S you are waiting at least one scanline. In worst case it will be one scanline and it will take 63.5us. No offence, but I think is it not enough for handshake.
Asman is offline  
Old 22 September 2018, 22:05   #23
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Up to 200 µs needed for some Cherry keyboards apparently.

Reading vhposr and waiting for 4 line changes should work best, you'll get a delay no less than 192 µs (probably closer to 200 with code overhead), and no more than 256 µs.

If you want an even simpler routine you can just ignore the delay and handshake next VBL or whenever you call your keyboard routine. You'll get low throughput and can't use it for proper typing, but it's enough if you just want to register a few keypresses.
Leffmann is offline  
Old 22 September 2018, 22:35   #24
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Leffmann View Post
Up to 200 µs needed for some Cherry keyboards apparently.
Heck! 200 µs..

Well, i use CIA timer so is a simple value change, but this keyboard is totally out of specs!
ross is offline  
Old 23 September 2018, 01:44   #25
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Yes, this is the oldest routine then, modify as you like. It was mostly because I couldn't quickly see a runnable routine with Rawkey LUT linked.

I did a search through my later source backups but apparently I haven't commented the code with the fix... so I can't provide it quickly now. If I find it I will post it. But it was mostly about these special keyboards. Like there are some floppy drives that ignore HRM also and require a blind 500ms wait somewhere.
Photon is offline  
Old 23 September 2018, 09:08   #26
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by Photon View Post
If I find it I will post it. But it was mostly about these special keyboards.
Thanks Photon.

Anyway, one more reason not to use the wait by scanlines wait.
Too many time lost..

Quote:
Like there are some floppy drives that ignore HRM also and require a blind 500ms wait somewhere.
The very same reason 'cause on my loader I blindly wait

Cheers
ross is offline  
Old 23 September 2018, 12:11   #27
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by phx View Post
You may also look into input.asm from the Solid Gold source (should be the same in Trap Runner). It implements a Level 2 keyboard interupt handler and a FIFO queue for fast typing. Nevertheless it's quite compact.
Just Looked at input.asm: good and compact routine, very similar to mine (i've to look at SG source more often!).

You have opted for 'interior' CIA wait, I've an 'exterior' wait (I start a timer and differ the handshake so I dont waste cycles on fast machine).
Moreover my L2 IRQ manager is more general because i've a dispacher for the variuos sources (also other timers and TOD),
but I change it according to the needs, it can also become with only the handshake and without buffer since I use it for the various games/demos patches.
And the request for a Disable() when you've to read a key is a bit to much, I prefer a semaphore

But I like also Photon approach for the qualifier keys.
The best would be for a "bit level" approach like used by system in InputEvent.ie_Qualifier (well, actually if I need a qualifier I opt for the input.device method )
One day i'll rewrite a routine that sum-up all this goodies..

Cheers!
ross is offline  
Old 24 September 2018, 13:05   #28
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
Wow, thanks for these many answers, my friends... Will have a look into this over the next days..

This is really a great place...
Tigerskunk is offline  
Old 24 September 2018, 16:07   #29
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by ross View Post
You have opted for 'interior' CIA wait, I've an 'exterior' wait (I start a timer and differ the handshake so I dont waste cycles on fast machine).
True. I'm optimizing my games always for the slowest supported architecture, so I didn't think it was worth it. Especially when key presses are rather rare within the game (usually just ESC to quit it).

Interestingly, the "interior handshake" seems to be the prefered method by OS drivers. AmigaOS keyboard.device and NetBSD /dev/kbd do it the same.

Quote:
And the request for a Disable() when you've to read a key is a bit to much, I prefer a semaphore
This was rather a note to myself than a request. My games usually runs in a VERTB-routine, so I am always safe to call getkey.

Quote:
One day i'll rewrite a routine that sum-up all this goodies..
LOL
Please do!
phx is offline  
Old 25 September 2018, 14:51   #30
NorthWay
Registered User
 
Join Date: May 2013
Location: Grimstad / Norway
Posts: 839
I have one of those A2000 Cherry keyboards (currently connected to my A1000).
It is mindblowing how many games it doesn't work with - you get one single keypress and then it is total incommunicado.

For my own simpleton key reading I just did a bunch of e-clock accesses to waste time.
You should ofc use a timer interrupt for anything better than a 7MHz 68000....
NorthWay is offline  
Old 01 October 2018, 15:36   #31
Tigerskunk
Inviyya Dude!
 
Tigerskunk's Avatar
 
Join Date: Sep 2016
Location: Amiga Island
Posts: 2,770
@phx: unfortunately, I get a lot of errors regarding autovecbase, which I don't use in my code.
Just copying the variable from OS.asm didn't do the trick it seems..
Tigerskunk is offline  
Old 02 October 2018, 20:40   #32
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
AutoVecBase must be initialized with the VBR.

When you still have assembler errors, although the symbol exists, then I guess you are confused by the Small Data model I am using (all variables are addressed base-relative via A4). Remove the "(A4)" from all instructions.
phx is offline  
Old 08 October 2018, 21:38   #33
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Northway just helped me verify that >=200 microseconds handshake is the only modification required to fix skipped or frozen key values on the Cherry A2000 keyboards
Photon is offline  
Old 02 August 2023, 09:50   #34
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 256
Quote:
Originally Posted by ross View Post
What's the difference? Timing for the handshake?
(on my routine I wait 85us)
How does your routine look like?

Mine is based on an article of the German Amiga Magazin from 1992. See enclosed page as pdf.

My code looks like this:

Code:
keyboard_handler
  btst    #CIAICRB_SP,CIAICR(a4) ;CIA-A SP-Interrupt ?
  beq     kh_no_keyboard_handler ;No -> skip
  btst    #CIACRAB_SPMODE,CIACRA(a4) ;Output ?
  bne     kh_no_keyboard_handler ;Yes ->skip
  move.b  CIASDR(a4),d0      ;Keycode
  ror.b   #1,d0
  not.b   d0  
  bmi.s   kh_reset_serial_port ;Key released -> skip
  tst.b   kh_key_flag(a3)    ;Keycode already saved?
  bne.s   kh_reset_serial_port ;Yes -> skip
  move.b  d0,kh_key_code(a3) 
  not.b   kh_key_flag(a3)    ;Set key flag
kh_reset_serial_port
  moveq   #FALSE,d0
  move.b  d0,CIASDR(a4)      ;Pulse: Set SP line = low
  moveq   #CIACRAF_SPMODE,d0
  or.b    d0,CIACRA(a4)      ;Serial port output, start handshake
  moveq   #CIACRBF_START,d0
  or.b    d0,CIACRB(a4)      ;Start timer for delay 85 microseconds
kh_delay_loop
  btst    #CIACRBB_START,CIACRB(a4)
  bne.s   kh_delay_loop
  moveq   #TRUE,d0
  move.b  d0,CIASDR(a4)      ;Pulse: Set SP line = high
  moveq   #~CIACRAF_SPMODE,d0
  and.b   d0,CIACRA(a4)      ;Serial port input, stop handshake
kh_check_key
  clr.b   kh_key_flag(a3)    ;Clear key flag
  move.b  kh_key_code(a3),d0
  cmp.b   #kh_key1,d0        ;F1 ?
  ...
I don't see in all the code examples pulsing the SP line for the handshake low then high.
Attached Files
File Type: pdf Amiga Magazin 1992-09-Keyboard-Handler.pdf (459.9 KB, 52 views)

Last edited by dissident; 02 August 2023 at 11:05. Reason: typo
dissident is offline  
Old 17 August 2023, 12:36   #35
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by dissident View Post
I don't see in all the code examples pulsing the SP line for the handshake low then high.
Loading the SDR with 0, as in your example, is not required. To my knowledge handshaking only needs you to set the SP to output for some time (I use 65 ticks).
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
[REQ:ASM] Sprite collisions basics jman Coders. Tutorials 5 03 September 2011 00:07
[REQ:ASM] Loading a static image and its palette jman Coders. Tutorials 3 04 June 2011 14:08
[REQ:ASM] Assembling and running jman Coders. Tutorials 9 07 May 2011 18:39
REQ:ASM getting elapsed time on A1200 jman Coders. Tutorials 18 11 January 2011 22:24
REQ:ASM How to use buffers jman Coders. Tutorials 7 01 December 2010 01:41

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:33.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.27162 seconds with 15 queries