Jump to content
IGNORED

generate key click programmatically


Recommended Posts

I know you can turn on or off the key click (POKE 731,0 or POKE 731,255), but I'm wondering if it's possible to generate the key click sound on command? Is there a bit of code to call from basic, or possibly a way in basic to generate the same or very similar noise? I don't remember my sound coding from back in the day or I'd probably be able to figure it out myself. I don't mind cheating by calling the existing key click routine :)

Link to comment
Share on other sites

I know you can turn on or off the key click (POKE 731,0 or POKE 731,255), but I'm wondering if it's possible to generate the key click sound on command? Is there a bit of code to call from basic, or possibly a way in basic to generate the same or very similar noise? I don't remember my sound coding from back in the day or I'd probably be able to figure it out myself. I don't mind cheating by calling the existing key click routine :)

 

The keyboard speaker is controlled by writing either a 0 or an 8 to the GTIA register at address 53279 (D01F). This simple pushes the speaker cone out or pull it back in, so you have to continually change the value to make a sound. You can do this through BASIC, but you really need machine language to control it effectively.

Link to comment
Share on other sites

 

The keyboard speaker is controlled by writing either a 0 or an 8 to the GTIA register at address 53279 (D01F). This simple pushes the speaker cone out or pull it back in, so you have to continually change the value to make a sound. You can do this through BASIC, but you really need machine language to control it effectively.

Agreed. Any idea if I can call the OS's keyclick code directly from basic? I'm using Turbo Basic XL if that matters.

Link to comment
Share on other sites

Looking to execute the appropriate part of the keyboard handler that makes the click.

Reading the following resources I've gotten more understanding of the keyboard handler.

 

http://www.atariarchives.org/mapping/appendix18.phpand

http://www.atarimania.com/documents/Complete_and_Essential_Map_For_the_XL_XE_Part_I.pdfand

http://atariage.com/forums/topic/241272-how-do-i-use-the-keyboard-handler-the-proper-way/

They are tantalizing but don't tell me much (but the statement "SHIFT + CONTROL + key (which generate keyclick but don't return anything)" indicates that there is a way to do this, but it eludes me). I wonder if it's possible to pass a "null" key and still generate the click, or alternately simply call the routine that generates the click sound.

Link to comment
Share on other sites

There's no standard OS entry to generate a keyclick, and very bad practice to just find where it is and call it since it's different among OS revisions.

 

The keyclick is only generated when the E: or K: handler is asked to perform input, which in the case of a running user program is usually not the case.

In theory you could open a K: device file then POKE 764,12 and use the GET statement. The "danger" in doing so is like you said those null keypresses if anadvertantly triggered by the user can cause the program to get stuck.

 

What you'd want to do is disable the normal keyboard temporarily so that your "forced keystroke" doesn't get messed up.

 

Like this - press Start to generate the keyclick.

 

 

5 POKE 53279,8:IF PEEK(53279)<>6 THEN 5
10 OPEN #1,4,0,"K:" : IRQEN = PEEK(16)
20 POKE 16,0 : POKE 53774,0 : POKE 764,12
30 GET #1,C : POKE 16,IRQEN : POKE 53774,IRQEN

 

Probably a way better method would be an assembler program to just do it yourself... I'll see what I can do.

Link to comment
Share on other sites

OK - better alternative.

Quick and dirty assembly routine to generate a keyclick, and sample program wrapped around it. The assembly routine gets put into a string, since it's relocatable.

10 GOSUB 900 : GRAPHICS 0
20 POKE 764,255
30 IF PEEK(764)<>255 THEN Z=USR(ADR(K$)):GOTO 20
40 GOTO 30
899 STOP 
900 DIM K$(30):A=1:TRAP 920
910 READ D:K$(A,A)=CHR$(D):A=A+1:GOTO 910
920 RETURN 
1000 DATA 104,162,126,142,31,208,173,11,212,205,11,212,240,251,202,202,16,241,96,-1
  • Like 4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...