English Amiga Board


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

 
 
Thread Tools
Old 02 January 2021, 14:04   #1
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 50
Posts: 6,318
CIA periodic interrupt

I'm trying to fix a game (Dizzy Collection) for whdload and the keyboard doesn't respond.


I've enabled level 2 interrupt, put my handler but it doesn't register when I press a key. Nevertheless, it's called every second (I've put a red flash at the start of the routine). Strange as the game doesn't even use the level 2 interrupt. It fiddles with the CIAs but afterwards it doesn't seem to use it (except for floppy, that code is skipped and to read FIRE1)

So I suppose that some CIA mode was enabled / ICR disabled, but I disabled all CIA writes (that I saw). How to restore a proper keyboard interrupt ? (never had that case in 25 years fixing games! plus I kinda suck at programming those CIAs)
jotd is offline  
Old 02 January 2021, 14:37   #2
ross
Defendit numerus

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 51
Posts: 3,689
Have you enabled SP bit on ICR register?

But maybe a full fledged code is better/simpler to check..

EDIT: just locked inside SPS1348.
There is INTENA/PORTS disabled and not a proper IRQ Vector setup (it's zeroed).
ICR/SP and TB enabled (but in one-shot mode, harmless), so CIA is properly set.
I inserted #$4e73 in $0 and forced $8008 to INTENA, pressed a key and IRQ trigger..

Are you sure you are doing a proper handshake in your routine?


In any case I didn't understand what you mean by "periodic interrupt" and "it's called every second", being an asynchronous event you don't need it to be called/handled at regular times.

Last edited by ross; 02 January 2021 at 15:14.
ross is offline  
Old 02 January 2021, 15:18   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 47
Posts: 25,372
Periodic event sounds like keyboard not getting handshake and trying to resynchronize.
Toni Wilen is online now  
Old 02 January 2021, 15:23   #4
ross
Defendit numerus

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 51
Posts: 3,689
Quote:
Originally Posted by Toni Wilen View Post
Periodic event sounds like keyboard not getting handshake and trying to resynchronize.
Yep, I have often seen a raw $BFEC01 keyboard readers within IRQ3 / VBI (or periodic), but in any case there was somewhere an appropriate (IRQ2) handshake handler
ross is offline  
Old 02 January 2021, 15:41   #5
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,710
Is keyboard handling maybe done in the vertical blank interrupt? In that case you need to use the WHDLF_NoKbd flag.
StingRay is offline  
Old 02 January 2021, 17:16   #6
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 50
Posts: 6,318
I have unplugged the keyboard read from VBL, installed my own routine. And there's a proper handshake.

I really don't know what's wrong. I've zoned the dev stuff (source+slave+data) if someone wants to have a look. I don't know what else to do.
jotd is offline  
Old 02 January 2021, 17:38   #7
ross
Defendit numerus

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 51
Posts: 3,689
opsss :

Code:
kh_common:
		lea	$bfec01,a0
		move.w	($100,a0),d0
ross is offline  
Old 02 January 2021, 17:49   #8
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 50
Posts: 6,318
shit! this is Bored Seal code I should have put my own code. Thanks.
jotd is offline  
Old 02 January 2021, 18:03   #9
ross
Defendit numerus

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 51
Posts: 3,689
Quote:
Originally Posted by jotd View Post
shit! this is Bored Seal code I should have put my own code. Thanks.
I don't know if that's how it's supposed to be but there is also an ALRM enabled and triggered because the ICR mask is set to $8F.
Probably if no timers are involved it is best to use a suitable mask ($88).

And as usual Toni was right, the periodic event was the keyboard trying to resynchronize
ross is offline  
Old 02 January 2021, 18:31   #10
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,710
Quote:
Originally Posted by jotd View Post
shit! this is Bored Seal code I should have put my own code. Thanks.

I have fixed that bug in a lot of his old patches. If you run WHDLoad in SNOOP mode, it should report these problems.
StingRay is offline  
Old 02 January 2021, 20:39   #11
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 50
Posts: 6,318
yeah, I know (WinUAE logs that too), but when you update a whdload slave, you are supposed to fix the original game bugs, not the slave bugs
jotd is offline  
Old 02 January 2021, 21:11   #12
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 50
Posts: 6,318
btw nice keyboard interrupt with handshake handled by cia timer not by VPOS active loop (in Fantasy World Dizzy)

Code:
LAB_04E0:
	MOVE.L	D0,-(A7)		;200c2: 2f00
	MOVE.B	CIAA_ICR,D0		;200c4: 103900bfed01
	BTST	#3,D0			;200ca: 08000003
	BEQ.W	LAB_04E1		;200ce: 67000038
	MOVE.B	CIAA_SDR,D0		;200d2: 103900bfec01
	ROR.B	#1,D0			;200d8: e218
	EORI.B	#$ff,D0			;200da: 0a0000ff
	MOVE.B	D0,LAB_04DE		;200de: 13c000020092
	MOVE.B	#$40,CIAA_CRA		;200e4: 13fc004000bfee01
	MOVE.B	#$09,CIAA_CRB		;200ec: 13fc000900bfef01
	MOVE.B	#$00,CIAA_TBLO		;200f4: 13fc000000bfe601
	MOVE.B	#$01,CIAA_TBHI		;200fc: 13fc000100bfe701
	MOVE.L	(A7)+,D0		;20104: 201f
	RTS				;20106: 4e75
LAB_04E1:
	BTST	#1,D0			;20108: 08000001
	BEQ.W	LAB_04E2		;2010c: 67000012
	MOVE.B	#$00,CIAA_CRA		;20110: handshake on timer interrupt
	MOVE.B	#$08,CIAA_CRB		;20118: 13fc000800bfef01
LAB_04E2:
	MOVE.L	(A7)+,D0		;20120: 201f
	RTS				;20122: 4e75
jotd is offline  
Old 02 January 2021, 21:22   #13
ross
Defendit numerus

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 51
Posts: 3,689
Quote:
Originally Posted by jotd View Post
btw nice keyboard interrupt with handshake handled by cia timer not by VPOS active loop (in Fantasy World Dizzy)
I always use handshake through cia timer in my keyboard routines .
(there are some examples somewhere in the forum, maybe..)

EDIT: found
https://eab.abime.net/showpost.php?p...27&postcount=4

Also found this super-tiny code I used in Smarty:
https://eab.abime.net/showpost.php?p...3&postcount=89

Last edited by ross; 02 January 2021 at 21:43.
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
Blitter interrupt during VERTB interrupt phx Coders. Asm / Hardware 38 01 October 2021 19:54
Periodic "stuttering" and large CPU usage mark_k support.WinUAE 15 14 September 2016 00:10
Interrupt 7 BigT support.WinUAE 2 07 September 2013 22:25
example of a CIA timer interrupt in assembler using cia.resource Apollo Coders. Asm / Hardware 3 05 July 2013 08:40
CIA timer interrupt handler called twice during mod playback absence Coders. General 5 16 March 2009 18:55

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 15:33.


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