English Amiga Board


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

 
 
Thread Tools
Old 20 March 2016, 11:15   #1
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,212
Reading the keyboard...

Has anyone got a small, compact, fast & working (non system friendly) keyboard reading routine in ASM?

I can't seem to locate my old one on any of my (few) backups.

I seem to remember also a a sequence of NOP's in my original code (that I borrowed off Del)
DanScott is offline  
Old 20 March 2016, 12:42   #2
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
yeah, you need some delay for the handshake, so NOPs won't work with different cpu's..
hooverphonique is offline  
Old 20 March 2016, 12:57   #3
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
You can use this one.
Code:
IntLvlTwoPorts:
		movem.l	d0-d1/a0-a2,-(a7)

		lea	_custom,a0
		moveq	#INTF_PORTS,d0

	;check if is it level 2 interrupt
		move.w	intreqr(a0),d1
		and.w	d0,d1
		beq.b	.end

	;check if SP cause interrupt, hopefully CIAICRF_SP = 8
		lea	_ciaa,a1 
		move.b	ciaicr(a1),d1
		and.b	d0,d1
		beq.b	.end

		move.b	ciasdr(a1),d1			;get keycode
		or.b	#CIACRAF_SPMODE,ciacra(a1)	;start SP handshaking

		lea	dt+keys(pc),a2
		not.b	d1
		lsr.b	#1,d1
		scc	(a2,d1.w)

	;handshake
		moveq	#3-1,d1
.wait1		move.b	vhposr(a0),d0
.wait2		cmp.b	vhposr(a0),d0
		beq.b	.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
Of course you need to set up PORTS ints. Instead of beam loop you can use cia, then wait will be more accurate. Example you can find in SolidGold source, which you can grab from aminet.
Or I can post above version with cia usage. Just give me a sign.
Asman is offline  
Old 02 August 2023, 11:29   #4
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by Asman View Post
You can use this one.
Code:
IntLvlTwoPorts:
		movem.l	d0-d1/a0-a2,-(a7)

		lea	_custom,a0
		moveq	#INTF_PORTS,d0

	;check if is it level 2 interrupt
		move.w	intreqr(a0),d1
		and.w	d0,d1
		beq.b	.end

	;check if SP cause interrupt, hopefully CIAICRF_SP = 8
		lea	_ciaa,a1 
		move.b	ciaicr(a1),d1
		and.b	d0,d1
		beq.b	.end

		move.b	ciasdr(a1),d1			;get keycode
		or.b	#CIACRAF_SPMODE,ciacra(a1)	;start SP handshaking

		lea	dt+keys(pc),a2
		not.b	d1
		lsr.b	#1,d1
		scc	(a2,d1.w)

	;handshake
		moveq	#3-1,d1
.wait1		move.b	vhposr(a0),d0
.wait2		cmp.b	vhposr(a0),d0
		beq.b	.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
You don't set the SP line for the pulse LOW then HIGH. Is this not necessary for the handshake as explaned in the HRM?
dissident is offline  
Old 02 August 2023, 11:41   #5
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,475
Quote:
Originally Posted by dissident View Post
You don't set the SP line for the pulse LOW then HIGH. Is this not necessary for the handshake as explaned in the HRM?
This is basically unnecessary.
The bit is idle low and you are the only one setting and executing the pulse (and in any case completing the operation).
ross is offline  
Old 02 August 2023, 14:12   #6
dissident
Registered User
 
Join Date: Sep 2015
Location: Germany
Posts: 260
Quote:
Originally Posted by ross View Post
This is basically unnecessary.
Thx for your quick answer. The bit is idle low and you are the only one setting and executing the pulse (and in any case completing the operation).
Thx for your fast answer .That confirms my assumption that it seems not to be really necessary. Okay. so the only important thing seems to be the delay time for the handshake between setting input, then output. If I understood it correctly, 85 microseconds are not enough for some keyboards. 200 microseconds should be used instead for some keyboards.
dissident is offline  
Old 02 August 2023, 14:34   #7
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,475
Quote:
Originally Posted by dissident View Post
..200 microseconds should be used instead for some keyboards.
Right
I usually use that value even if in fact is the keyboard that use delays outside the official specifications (probably too slow micros).
ross 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
Keyboard Problem with AOS 4.1 FE Classic in WinUAE.. Keyboard doesn't work! QBit support.WinUAE 1 07 January 2015 13:43
Reading / writing files and the keyboard jimmy2x2x Coders. Asm / Hardware 3 07 December 2014 19:58
Wanted: Amiga 600 keyboard membrane (Blue) or full keyboard assembly RetromanIE MarketPlace 8 19 August 2012 14:48
Reading Amiga CD on a PC AndersHP support.WinUAE 5 22 August 2010 18:21

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 02:35.

Top

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