English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 10 October 2013, 14:47   #1
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
Keyboard Issue, multi-keys pressed

Hey Guys

Got a bit of a keyboard issue in the PT-1210 player. We're using keys 1,2,3 & 4 for channel muting. It seems that in WinUAE and on an A600, you can hit all the keys simultaneously and they react. However, on the A1200, its not working. Is there any difference between the two machines keyboard hardware wise?

The keyboard interrupt code was kindly stolen from an example from WHDLoad (i think?) which is below. Is this a known hardware issue or something with the interrupt?



Code:

*****************************************
** keyboard system
*****************************************

	include cia.i
	include intbits.i

kbinit	movem.l	d0-a6,-(a7)
	move.l	VBRptr,a0
	move.l	$68(a0),oldint
	move.b	#CIAICRF_SETCLR|CIAICRF_SP,(ciaicr+$bfe001)
	;clear all ciaa-interrupts
	tst.b	(ciaicr+$bfe001)
	;set input mode
	and.b	#~(CIACRAF_SPMODE),(ciacra+$bfe001)
	;clear ports interrupt
	move.w	#INTF_PORTS,(intreq+$dff000)
	;allow ports interrupt
	move.l	#kbint,$68(a0)
	move.w	#INTF_SETCLR|INTF_INTEN|INTF_PORTS,(intena+$dff000)
	movem.l	(a7)+,d0-a6
	rts

kbrem	movem.l	d0-a6,-(a7)
	move.l	VBRptr,a0
	move.w	#INTF_SETCLR|INTF_PORTS,(intena+$dff000)
	move.l	oldint,$68(a0)
	movem.l	(a7)+,d0-a6
	rts	

kbint	movem.l	d0-d1/a0-a2,-(a7)
	
	lea	$dff000,a0
	move.w	intreqr(a0),d0
	btst	#INTB_PORTS,d0
	beq	.end
		
	lea	$bfe001,a1
	btst	#CIAICRB_SP,ciaicr(a1)
	beq	.end

	;read key and store him
	move.b	ciasdr(a1),d0
	or.b	#CIACRAF_SPMODE,ciacra(a1)
	not.b	d0
	ror.b	#1,d0
	spl	d1
	and.w	#$7f,d0
	lea	keys(pc),a2
	move.b	d1,(a2,d0.w)

	;clr.w	$100	

	;handshake
	moveq	#3-1,d1
.wait1	move.b	vhposr(a0),d0
.wait2	cmp.b	vhposr(a0),d0
	beq	.wait2
	dbf	d1,.wait1

	;set input mode
	and.b	#~(CIACRAF_SPMODE),ciacra(a1)

.end	move.w	#INTF_PORTS,intreq(a0)
	tst.w	intreqr(a0)
	movem.l	(a7)+,d0-d1/a0-a2
	rte

keys: 		dcb.b $80,0
keys2: 		dcb.b $80,0
keysfr: 	dcb.b $80,0


oldint	dc.l	0
h0ffman is offline  
Old 10 October 2013, 16:34   #2
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 810
that code seems to busy-wait inside an interrupt server for 3 scanlines, which is really unpleasant..

why it doesn't work on A1200, I'm not entirely sure.. handshake delay too short maybe?
hooverphonique is offline  
Old 10 October 2013, 16:43   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,023
Keyboard limit? Many keyboards can't support more than 2 simultaneous key presses if they are located in same line in keyboard matrix.
Toni Wilen is online now  
Old 10 October 2013, 16:53   #4
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 810
Quote:
Originally Posted by Toni Wilen View Post
Keyboard limit? Many keyboards can't support more than 2 simultaneous key presses if they are located in same line in keyboard matrix.
and this is a limitation of the keyboard controller, is it not!? and the behavior of that could easily be different between a600 and a1200..
hooverphonique is offline  
Old 10 October 2013, 18:28   #5
Akira
Registered User

Akira's Avatar
 
Join Date: May 2001
Location: New York
Posts: 19,265
I would have assumed the A1200 and A600 would have a similar type of keyboard. But let's be honest, 2 keypresses at once seems rather feasible to press at once. This routine is not even accepting 2 keypresses at once.

The A1200 I am testing it on has a 030, if that changes anything :P
Also: it used to work. h0f, did you compare the code of the version prior you putting the visual hints? Or perhaps I am confused, I should test an older version to check this.
Akira is offline  
Old 10 October 2013, 18:37   #6
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
I only ever noticed it when I started actually using the software on real hardware this year. The keyboard interrupt hasn't changed. The only thing that had possibly changed is the keyboard routines which look at the key data off the back of the interrupt but that shouldn't be an issue as the shift key function works to increase the nudge size.
h0ffman is offline  
Old 10 October 2013, 20:55   #7
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
Ok guys, I've just hacked together a keyboard tester. When a key is pressed you'll see a small line appear at the top of the screen (basically loading the key data section into the plane register!).

If someone could run some tests on real hardware I'd really appreciate it It's only really keys 1 through to 4 we're worries about for now.

Oh yeah, its in the zone.

Last edited by h0ffman; 10 October 2013 at 20:56. Reason: forgot detail!
h0ffman is offline  
Old 10 October 2013, 22:38   #8
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
Right then, I've had it tested on real hardware and can confirm that the A1200 does not allow the keys 1-4 to be pressed at the same time. The A600 must be wired differently hence why it works on that! This is a proper sh*t as I'm going to have to find four keys next to each other where this works!
h0ffman is offline  
Old 10 October 2013, 23:02   #9
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
Quote:
Originally Posted by hooverphonique View Post
that code seems to busy-wait inside an interrupt server for 3 scanlines, which is really unpleasant..
That busy wait is required!

Quote:
Originally Posted by hooverphonique View Post
handshake delay too short maybe?
Guess what the busy-wait is for!
StingRay is offline  
Old 11 October 2013, 01:37   #10
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
Quote:
Originally Posted by StingRay View Post
That busy wait is required!



Guess what the busy-wait is for!
Thankfully the keyboard interrupt is lower down the list than the CIA interrupt. If it wasn't those 3 raster lines might cause me some serious issues!

Unless of course that may be pertaining to my issue stinger???
h0ffman is offline  
Old 11 October 2013, 02:01   #11
Akira
Registered User

Akira's Avatar
 
Join Date: May 2001
Location: New York
Posts: 19,265
Can anybody try this code on an A500 or other computers? It would be great that this works on every computer possible, really.

As for suggestions to move this, how about ZXCV ? Doesn''t PT mute/unmute by a modifier plus one of these?

I mean, this is not absolutely a deal breaker, but it feels just RIGHT to mute/unmute multiple parts at the same time. Right now I am faking it cycling them as fast as I can.
Akira is offline  
Old 11 October 2013, 09:28   #12
h0ffman
Registered User
 
Join Date: Aug 2008
Location: Salisbury
Posts: 469
The multi press for mute has to work, mainly because its caughte out while playing before!!
h0ffman is offline  
Old 11 October 2013, 09:55   #13
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,023
Small correction to my previous post, problem can happen when multiple keys (usually 3+) are pressed and they are located in different keyboard matrix lines or rows. (not in same line)

Does anyone have keyboard schematics? (that includes full matrix layout).

Perhaps A1200 keyboard mcu has artificial limit of 3 simultaneous keys to prevent key "ghosting"? (press 3 keys, matrix "shorts" causing extra ghost key to be registered. Note that qualifier keys are always in separate matrix, they never cause ghosting) It would be easy to test if keyboard matrix layout was available.

EDIT: search for "n-key rollover" or "nkro" for technical details.
Toni Wilen is online now  
Old 11 October 2013, 10:15   #14
ajk
Registered User
ajk's Avatar
 
Join Date: May 2010
Location: Helsinki, Finland
Posts: 1,171
I remember that this was always an issue on the A1200, for example when playing certain multiplayer games that used the keyboard for a couple of the players. You needed to select some pretty odd combinations to be able to play. It seemed to be the worst on the A1200 in particular.
ajk is offline  
Old 11 October 2013, 10:18   #15
musojon74
Registered User

musojon74's Avatar
 
Join Date: Dec 2007
Location: Dereham, United Kingdom
Age: 44
Posts: 470
The a1200 as you've discovered has some limitations on certain simultaneous key presses. I was very disappointed on octamed chord mode on my 1200 years ago, yet my mates 600 was perfect.
musojon74 is offline  
Old 11 October 2013, 14:09   #16
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 810
Quote:
Originally Posted by StingRay View Post
That busy wait is required!

Guess what the busy-wait is for!
Give me some credit here.. I know the delay is required!

Busy-waiting in interrupt servers is most definitely not, and should in general be avoided at all cost; there will be cases where it's ok, but that depends entirely on what else is going on in the system..
hooverphonique is offline  
Old 11 October 2013, 14:15   #17
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 22,023
Quote:
Originally Posted by hooverphonique View Post
Give me some credit here.. I know the delay is required!

Busy-waiting in interrupt servers is most definitely not, and should in general be avoided at all cost; there will be cases where it's ok, but that depends on what else is going on in the system..
OS keyboard handler also busy waits!

You can't start timers in interrupts (unless you have taken over the system) and having separate Task (that Wait()s for Signal() from interrupt) only for keyboard handshaking is not that good idea either. Keyboard must work even in Forbid() state and it must never lose keyboard state.
Toni Wilen is online now  
Old 11 October 2013, 15:09   #18
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,146
Quote:
Originally Posted by hooverphonique View Post
Busy-waiting in interrupt servers is most definitely not
That busy wait is required as I already said! If no CIA timers are used a CIA delay will be the better solution but it doesn't change the fact that this delay is required. Leave it out and you'll be left with a "dead" keyboard after a while.
StingRay is offline  
Old 11 October 2013, 17:18   #19
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,201
Perhaps h0ffman thought about starting a CIA timer during keyboard interrupt and do the handshaking in another routine, when the timer interrupt occurs. But I guess there would be too much overhead, for setting up and processing the interrupt, so that it isn't worth it.

The usual method is to start a CIA timer at the beginning of the keyboard interrupt and do all the required processing (key-mapping, etc.) while the timer is running. Then busy-wait until the timer expires and do the handshake.
phx is offline  
Old 11 October 2013, 17:29   #20
Akira
Registered User

Akira's Avatar
 
Join Date: May 2001
Location: New York
Posts: 19,265
What do you know, I never thought the A1200 had such a shit keyboard. I surely hope we can find a solution to this!

Toni: as I explained above, this routine doesn't even let me press two at the same time. So it feels like the limit is 1 :P
Akira 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
Some of the keyboard keys not responding (A1200) Kenan support.Hardware 39 27 May 2013 17:41
A1000 keyboard-keys compatible with Cherry keyboard-keys? Centerguy support.Hardware 5 09 August 2010 01:56
When you play games, sometimes left-right keys stay "pressed" hexaae support.WinUAE 4 18 April 2009 14:22
Keys on keyboard need fixing Blackadder support.Hardware 10 28 January 2009 05:42
Keys on keyboard sticking Graham Humphrey support.Hardware 6 31 December 2007 16:57

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 16:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.09019 seconds with 12 queries