24 July 2021, 18:42 | #21 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
@ross:
I did follow the flowchart. There was a bra .0in your code which was at the end of the part where the keystroke was handled which branched back to before the move.b (a1),d0part, where the clear was. I've changed the code, but the result is the same: one read and after that nothing. Full code: Code:
lea CIAA+CIASDR,a1 clr.b (a1) ReadKbd: move.b (a1),d0 ror.b #1,d0 not.b d0 bmi.b CheckMouse clr.b (a1) TCheckF2: cmp.b #BtnF2,d0 ; Check if F2. bne TCheckF3 ; Nope, skip. eor.b #1,THitPower ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. TCheckF3: cmp.b #BtnF3,d0 ; Check if F3. bne TCheckF4 ; Nope, skip. eor.b #1,THealth ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. TCheckF4: cmp.b #BtnF4,d0 ; Check if F4. bne TCheckF5 ; Nope, skip. eor.b #1,TTime ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. TCheckF5: cmp.b #BtnF5,d0 ; Check if F5. bne CheckMouse ; Nope, skip. eor.b #1,TLaserShots ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. CheckMouse: btst #6,-CIASDR(a1) bne.b ReadKbd @Thomas Richter: After the program, a single-task game will start and will throw out the OS anyway. I just would like to check the state of a few keys and the mouse button. (The latter one works.) |
24 July 2021, 19:07 | #22 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
It depends, with such a simple code in fact it is. [EDIT: not in the last snippet you posted, ReadKbd in this position make it mandatory]
But in the 'flowchart' I made a clrimmediately to avoid the possible loss of a subsequent quick key press. Suppose you have a keypress, your code takes a long time to execute and in the meantime there is a subsequent keypress (or more than a key pressed at once, the Amiga keyboard buffer it). If you clrit at the end of the cycle you have lost the keypress. In any case this would only alleviate a little the problem, it seems to me that the keyboard buffers 10 keys or something like that. But simple cases would still be handled, like shift-keys. Well, it remains a lousy method... It is sometimes used in intros or for really unimportant things. AVOID IT, please. I don't seem to have ever used it. Quote:
I have no idea why it doesn't work for you, do a post with the executable attached. Last edited by ross; 24 July 2021 at 19:33. |
|
24 July 2021, 19:08 | #23 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
No, it's not redundant, it tells you that there is no new keycode.
You could also ditch the stateless approach and always remember the last code you read, and if it's the same then it means nothing was pressed. Something like (high-level): Code:
byte code, last_code = 0; ... while ((code = *0xbfec01) != last_code) { last_code = code; // process code ... } |
24 July 2021, 19:28 | #24 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
What this executable does for you?:
Code:
lea $bfec01,a0 lea -256(sp),sp lea (sp),a1 .0 clr.b (a0) .1 move.b (a0),d1 ror.b #1,d1 not.b d1 bmi.b .2 move.b d1,(a1)+ bra.b .0 .2 btst #6,-$c00(a0) bne.b .1 move.l (sp),d0 lea 256(sp),sp rts |
24 July 2021, 19:30 | #25 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
@ross: This is an unimportant thing, a simple menu. I give the binary via link, the attachment button does not working in my browser. Edit: The attachments popped up in a separate tab...
http://oscomp.hu/depot/8ac345dc Edit: Yes, your binary does that for me too. Edit: The drawing code might be slow, but it appears instantly, what makes it impossible for me to hit a key during drawing. @a/b: But i cannot read new keycodes, so there is nothing to store, after the first. Last edited by TCH; 24 July 2021 at 19:39. |
24 July 2021, 19:43 | #26 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
There is no system handshake, and the keyboard does not send other codes, simple. |
|
24 July 2021, 19:45 | #27 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
That was needed for opening the custom screen. During keyboard reading i should use
Enable()? |
24 July 2021, 19:50 | #28 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
24 July 2021, 19:51 | #29 |
Registered User
Join Date: Jun 2016
Location: europe
Posts: 1,039
|
"Cannot"...
If you are doing the handshaking yourself then you must ensure that nothing is interfering (eg. OS must be shut down), otherwise you could end up not being able to read them (properly). If you are not doing the handshaking and relying on OS to do it for you, then you have to know whether the code you just read is the old code (that you have read already) or not. One way is to clear the HW register and the other way is to compare it to the previous code you've read. Clearing is simpler/stateless, but since you said that doesn't work either (pretty much every code posted before an hour or so ago), then this should really work as it does not interfere with the protocol in any way (doesn't write anything to HW). But if you have managed to get the clr version working, that's ok then. |
24 July 2021, 19:53 | #30 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
@ross:
I have no idea why it is necessary if it is, you've suggested it's usage too. @a/b: It seems the Disable()was preventing both your and ross' code from working. |
24 July 2021, 19:58 | #31 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
The link point to some generic code (which does nothing!) that take control of the system, in anticipation of the free modification of the IRQs and hardware registers. In this case you don't have to take control of the machine, let alone change the IRQs. |
|
24 July 2021, 20:02 | #32 | |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
Quote:
Urge that you read some docs EDIT: Sorry for the back-to-back post, this text was not in the original post. |
|
24 July 2021, 20:02 | #33 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
I've seen a custom screen opening code and used it.
Disable()was supposed to do something with the copperlist, or i don't know. In the other topic, no one questioned it's usage. Edit: But, that was what you and a/b suggested until this point, to disable the interrupts. Now what then? Edit 2: Okay, i've put the Enable()after the DMA and the copper is set, and another Disable()before they are restored and now the code works. Thanks guys. Edit 3: No, i was wrong. It works until the system tries to exit. After LMB everything freezes. Last edited by TCH; 24 July 2021 at 20:09. |
24 July 2021, 20:13 | #34 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
24 July 2021, 20:19 | #35 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Currently it become quite stochastic. The following cases are observed:
- Neither the keyboard, neither LMB works from the start. - The keyboard works, but when LMB is clicked it freezes. - If LMB is clicked without the keys hit, it works. - Both works. All this randomly. Edit: I've removed all Enable()and Disable()and now it works. No, it's not, it's just worked for ten times a row... /o\ Last edited by TCH; 24 July 2021 at 20:34. |
24 July 2021, 21:09 | #36 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Code for initialization:
Code:
lea CUSTOM,a2 move.l $4,a6 ; Old copper backuped in a3. lea graphics_lib(pc),a1 jsr OldOpenLibrary(a6) move.l d0,a1 move.l 38(a1),a3 jsr CloseLibrary(a6) jsr Disable(a6) lea copperlist(pc),a1 move.l a1,COP1LCH(a2) move.w #SETCLR,d3 ; DMA backuped in a4. or.w DMACONR(a2),d3 move.w d3,a4 move.w #$7fff,DMACON(a2) move.w #SETCLR|DMA_ENABLED,DMACON(a2) jsr Enable(a6) Code:
lea CIAA+CIASDR,a1 clr.b (a1) ReadKbd: move.b (a1),d0 ror.b #1,d0 not.b d0 bmi.b CheckMouse clr.b (a1) TCheckF2: cmp.b #BtnF2,d0 ; Check if F2. bne TCheckF3 ; Nope, skip. eor.b #1,THitPower ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. TCheckF3: cmp.b #BtnF3,d0 ; Check if F3. bne TCheckF4 ; Nope, skip. eor.b #1,THealth ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. TCheckF4: cmp.b #BtnF4,d0 ; Check if F4. bne TCheckF5 ; Nope, skip. eor.b #1,TTime ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. TCheckF5: cmp.b #BtnF5,d0 ; Check if F5. bne CheckMouse ; Nope, skip. eor.b #1,TLaserShots ; Yep, toggle. bra PrintStatuses ; Break from keyboard handling. CheckMouse: btst #6,-CIASDR(a1) bne.b ReadKbd Code:
Exit: jsr Disable(a6) move.w #$7fff,DMACON(a2) move.l a3,COP1LCH(a2) ; Restore old Copper settings. move.w a4,DMACON(a2) ; Restore old DMA flags. jsr Enable(a6) moveq #0,d0 ; Exit. rts |
25 July 2021, 10:38 | #37 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Okay, this time i got it, by removing the first
Enable()and the second Disable()and replacing the remaining ones with Forbid()and Permit()the code now finally works. (ross, you were right on this.) Thx again guys. |
26 July 2021, 10:41 | #38 | ||
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Quote:
Quote:
You misunderstood what a/b was saying - you need to disable interrupts permanently (i.e. not periodically while reading the keyboard) for his example to work. Please read what people are suggesting carefully - only using half their advice when you don't understand what's going on will often not get you anywhere |
||
26 July 2021, 17:07 | #39 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Indeed, the code shown is calling for trouble.
Never access the hardware directly when the OS is still alive! And the OS is alive, when the AmigaOS interrupts are handled. Also don't play with DMA channels and copper lists in that state. |
29 July 2021, 08:41 | #40 |
Newbie Amiga programmer
Join Date: Jun 2012
Location: Front of my A500+
Age: 38
Posts: 372
|
Interesting, because now i did not disable the interrupts at all and yet, the keyboard reading works.
I called Forbid()(formerly Disable()) before setting the DMA channel and the copperlist, is that okay that way? |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kipper CD32 riser keyboard reset? | lord of time | support.Hardware | 0 | 31 August 2019 16:21 |
Keyboard keys register as double or more presses | Hoggy | support.WinUAE | 3 | 08 September 2018 07:45 |
A1200 can't reset from Ctrl+A+A, keyboard problem? | MrD | support.Hardware | 7 | 28 October 2016 17:16 |
Keyboard reset warning support broke in 2.4.0 beta 21 | mark_k | support.WinUAE | 2 | 17 April 2012 15:32 |
A500 keyboard, reset problem | orange | support.Hardware | 10 | 04 November 2010 19:51 |
|
|