freetz Posted June 28, 2020 Share Posted June 28, 2020 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. Quote Link to comment Share on other sites More sharing options...
StickJock Posted June 28, 2020 Share Posted June 28, 2020 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. Quote Link to comment Share on other sites More sharing options...
freetz Posted June 28, 2020 Author Share Posted June 28, 2020 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... Quote Link to comment Share on other sites More sharing options...
Preppie Posted June 28, 2020 Share Posted June 28, 2020 (edited) 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 June 28, 2020 by Preppie Quote Link to comment Share on other sites More sharing options...
freetz Posted June 28, 2020 Author Share Posted June 28, 2020 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... Quote Link to comment Share on other sites More sharing options...
StickJock Posted June 28, 2020 Share Posted June 28, 2020 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. Quote Link to comment Share on other sites More sharing options...
freetz Posted June 28, 2020 Author Share Posted June 28, 2020 Currently, I'm doing the check and screen memory location changes inside an immediate VBI, so it should always happen every 1/50th second. I'll try to set the check to every other VBI and see if that helps... Quote Link to comment Share on other sites More sharing options...
Rybags Posted June 29, 2020 Share Posted June 29, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
freetz Posted June 29, 2020 Author Share Posted June 29, 2020 (edited) 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 June 29, 2020 by freetz Used SKSTAT instead of SKCTL for clarity (although it's the same register) Quote Link to comment Share on other sites More sharing options...
Rybags Posted June 29, 2020 Share Posted June 29, 2020 KBCODE is $D209 on Pokey (ref your comment first line) Yeah - my info was out, the value of 0 means key still pressed for that bit. 1 Quote Link to comment Share on other sites More sharing options...
freetz Posted June 29, 2020 Author Share Posted June 29, 2020 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 1 Quote Link to comment Share on other sites More sharing options...
Rybags Posted June 29, 2020 Share Posted June 29, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
phaeron Posted July 1, 2020 Share Posted July 1, 2020 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). 1 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted July 1, 2020 Share Posted July 1, 2020 54 minutes ago, phaeron said: I'd really recommend avoiding Wikipedia 2 Quote Link to comment Share on other sites More sharing options...
freetz Posted July 1, 2020 Author Share Posted July 1, 2020 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). Quote Link to comment Share on other sites More sharing options...
_The Doctor__ Posted July 1, 2020 Share Posted July 1, 2020 (edited) 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 July 1, 2020 by _The Doctor__ Quote Link to comment Share on other sites More sharing options...
phaeron Posted July 1, 2020 Share Posted July 1, 2020 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. 2 Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 1, 2020 Share Posted July 1, 2020 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. Quote Link to comment Share on other sites More sharing options...
Graham Dearsley Posted July 13, 2020 Share Posted July 13, 2020 The Atari 8 bit articles on Wikipedia are very odd indeed, one day you can read them and they will be quite good, but if you come back a week later you can find that someone has edited them with complete rubbish. Go figure but I am beginning to suspect C64 fans ? 2 Quote Link to comment Share on other sites More sharing options...
Graham Dearsley Posted July 13, 2020 Share Posted July 13, 2020 I found the Type A Tune program at the end of the BASIC Reference Manual interesting when I finally looked at it after several years ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.