Jump to content
IGNORED

How to display a help page only as long as the HELP key is pressed?


Recommended Posts

Hi folks,

 

I'm currently struggling with displaying a help text in a machine language program that should only be displayed as long as the HELP key is pressed. Afterwards, the previous screen should be restored.

Displaying the help screen upon pressing HELP works, so far, I only got it working to the point that you had to press another key to exit the help page.

This seems to have to do with the fact that both querying memory locations HELPFG as well as KBCODE keep the last value stored until it is cleared (HELPFG) or a different key is pressed (KBCODE).

But I don't want people having to press a key which then might execute a program function they don't intend to.

So far I can only think of a workaround like ("press ESC to return to main screen"), but if possible, I'd like to avoid that.

 

Thanks in advance for any pointers,

 

F.

Link to comment
Share on other sites

The Atari keyboard controller isn't designed to generate a key release along with the key press. Try clearing the key scan code, and then when the timer increments read it again. If you read anything other than the help key, such as no key or a different key, then clear your help screen.

Link to comment
Share on other sites

Thanks, I tried this, but this results in screen flickering due to the switching between main and help screen, at least with HELPFG (732) because I clear the register and when reading it again, it is still cleared or has just been set to 17 (HELP key pressed) again.

As for KBCODE, is there a way to clear it? As its hardware register is "dual use", poking a zero there will start some POKEY timer, IIRC...

 

Link to comment
Share on other sites

Simplest solution is press HELP for help then press HELP again to remove help, you don't need to mess around with the esc key.

 

In BASIC:

 

10 if peek(764)<>63 then 10

20 poke 764,255

30 ?"toggle help"

40 goto 10

 

I used code 63 ('a') instead of help as I'm on emulator and don't know where help key is :)

 

You can use location 754 if you don't want auto repeat.

Edited by Preppie
Link to comment
Share on other sites

Yes, that would work, but I would still need to press the key again (whether it's HELP or ESC or whatever) and not just release it. If that's the only way it can be done, then it has to be that way (and no, START, SELECT and OPTION are no alternative as they have other uses already). I just wanted to make sure I haven't overlooked a possibility as I think I have seen a program implementing it that way...

Link to comment
Share on other sites

29 minutes ago, freetz said:

Thanks, I tried this, but this results in screen flickering due to the switching between main and help screen, at least with HELPFG (732) because I clear the register and when reading it again, it is still cleared or has just been set to 17 (HELP key pressed) again.

As for KBCODE, is there a way to clear it? As its hardware register is "dual use", poking a zero there will start some POKEY timer, IIRC...

 

That's why you need to check the timer - to delay before you test the keyboard again.  Use a long enough delay that they keyboard has been scanned again, but short enough that the program feels responsive to the key being released.

Link to comment
Share on other sites

There's no key release code but SKSTAT helps out here.

 

Bit 2 = 1 means the last key is still pressed.  Should be used in conjunction with reading the KBCODE from Pokey to ensure the same key is pressed.

 

The Help key flag works somewhat differently to normal keys.  The Help key code isn't stored in 764 and HELPFG is only altered when the Help key is pressed - you're supposed to clear it yourself, and it also doesn't have autorepeat like most other keys.

  • Like 1
Link to comment
Share on other sites

Wonderful, that was the information I was hoping for :) - but the strange thing is that at least on my Atari Bit 4 in SKCTL ($D20F) is set when there is NO key pressed and it's zero if a key is pressed. This is the code that displays the contents at "HelpText" if HELP is pressed and at "INTRO" when HELP is not pressed / released:

		lda KBCODE		; $D209
		cmp #$11		; Keyboard code for HELP key
		bne exitvbi		; if not, then exit
		lda SKSTAT		; if it is HELP
		and #4			; mask out Bit 2 of SKSTAT ($D20F)
		bne showMenu		; if set, key seems not to be pressed, so show main window
showHelp	lda #<HelpText		; otherwise
		sta ScreenMem		; get contents from "HelpText"
		lda #>HelpText		; and put into
		sta ScreenMem+1		; screen memory location
		bne exitvbi		; and exit VBI
showMenu	lda #<INTRO		; get contents from "INTRO"
		sta ScreenMem		; and put into
		lda #>INTRO		; screen memory location
		sta ScreenMem+1
exitvbi		jmp $e45f		; and exit VBI

 

Edited by freetz
Used SKSTAT instead of SKCTL for clarity (although it's the same register)
Link to comment
Share on other sites

That and IRQST are just about the only hw read registers where a 0 value means true.  NMIST in Antic reads 1 for true, the collision bits in GTIA are 1 for true, IRQ state on PIA uses 1 for true.

TRIG, CONSOL and the PORTA bits for sticks are 0 for true though that's generally the way with controllers as they're pulled up signals that get tied to GND when active.

  • Thanks 1
Link to comment
Share on other sites

On 6/29/2020 at 5:26 AM, freetz said:

Thanks, corrected. And as for the meaning of Bit 2, that seems to be a general misconception as I found the same information on its meaning here as well:

https://atariwiki.org/wiki/Wiki.jsp?page=SKCTL

and here as well:

https://en.wikipedia.org/wiki/POKEY#SKSTAT_$D20F_Read

I'd really recommend avoiding Wikipedia for documentation on Atari hardware registers. The information on there looks like it was badly cribbed from other sources such as Atari's Hardware Manual and my own Hardware Manual, and there are many errors and misleading statements in it. You would be far better off using the Atari Hardware Manual (there are a couple of errors, but mainly in the serial port section).

 

  • Like 1
Link to comment
Share on other sites

I'm not a big fan of running down Wikipedia; yes, the quality of the articles vary, also depending on what language you use, but in many cases there is hardly a better source except for outright expert sources which often are hard to find or freely accessible. Of course you need to apply common sense and double-check important information, but having said that, atariwiki.org has the same error, so even with double-checking it would not have been easily possible to know that the meaning of this Bit is exactly the other way around. If it is now confirmed that Bit 2 is 0 when a key is still pressed, I'll sign up on these two pages and correct the error (which, by the way, anybody can do).

Link to comment
Share on other sites

On 6/28/2020 at 8:05 PM, Rybags said:

There's no key release code but SKSTAT helps out here.

 

Bit 2 = 1 means the last key is still pressed.  Should be used in conjunction with reading the KBCODE from Pokey to ensure the same key is pressed.

 

The Help key flag works somewhat differently to normal keys.  The Help key code isn't stored in 764 and HELPFG is only altered when the Help key is pressed - you're supposed to clear it yourself, and it also doesn't have autorepeat like most other keys.

so wanted to give the prize winning thank you cup on this... maybe you can edit or just click 'report post' on yourself and ask to have the post edit that to zero or ability to edit the post yourself. They'll often make the correction for you or give you rights to edit and you do it yourself.

Edited by _The Doctor__
Link to comment
Share on other sites

37 minutes ago, freetz said:

I'm not a big fan of running down Wikipedia; yes, the quality of the articles vary, also depending on what language you use, but in many cases there is hardly a better source except for outright expert sources which often are hard to find or freely accessible. Of course you need to apply common sense and double-check important information, but having said that, atariwiki.org has the same error, so even with double-checking it would not have been easily possible to know that the meaning of this Bit is exactly the other way around. If it is now confirmed that Bit 2 is 0 when a key is still pressed, I'll sign up on these two pages and correct the error (which, by the way, anybody can do).

Wikipedia is generally a good resource, but for Atari hardware registers specifically, the three main articles -- ANTIC, GTIA, and POKEY -- are low quality in both accuracy and readability. This includes weird nonsense like the list of IRQ names and the description of horizontal fine scrolling (no, ANTIC does not have a 16 color clock buffer). Of the information that is special and hard to find, a fair amount of it was plagiarized from me without attribution and without context. There are many sources you can use that are much better, and in particular the Atari Hardware Manual in particular would have shown you the answer immediately as it has the asserted polarity listed for each bit.

 

 

image.thumb.png.290f8997aef7d38aef04720283a230a2.png

image.thumb.png.4aeb4ee0a1a5d4dc42e3967ba5dda8c4.png

 

image.thumb.png.995c5cb3766465aa2eed2f3c000e8165.png

 

image.thumb.png.bea842a6fe22d416c9a334c6613b55a4.png

  • Like 2
Link to comment
Share on other sites

The Wikipedia articles are trying to be a programming reference rather than a historical and descriptive document like they should be.

 

Really, they should just have an overview with list of features, bugs, exploits and not too much more.

Link to comment
Share on other sites

  • 2 weeks later...

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...