In this post I show evidence of two routines having been converted. The first is WaitYN(), and the second is WaitKCX(). WaitYN() simply waits for Y or N to be pressed, only allowing those keystrokes (upper or lower). WaitKCX() waits for any key to be pressed. It will optionally process the inverse key to toggle the inverse text function, or just pass back the inverse key press. It also handle CAPS lock without intervention. WaitKCX() also checks for the HELP key on XL’s, F1-F4 on the 1200XL, and checks for the console keys being pressed (Start, Select, Option). I don’t have a 1200XL to test F1 to F4, though I think the code will work based on technical documents.
The code for the test/demo program follows. It won’t compile without the forthcoming library release. The command used to compiles is in the header comment. Also of note, you will see variable types byte and word which are not C. These are implemented as type definitions. byte equates to an unsigned char. word equates to an unsigned int.
// ------------------------------------------------------------
// Program: waitk.c
// Desc...: Wait Key demonstration
// Author.: Ripdubski
// Date...: 202208
// Notes..: cl65 -v -O -t atarixl waitk.c -o waitk.xex
// ------------------------------------------------------------
// Pull in include files
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <peekpoke.h>
#include <atari.h>
// The next two are part of my Action! library conversion.
#include "a8defines.h"
#include "a8libmisc.c"
// ------------------------------------------------------------
// Func...: void main(void)
// Desc...: Main routine
// ------------------------------------------------------------
void main(void)
{
// Declare vars
byte bR;
word cK;
// Setup screen
clrscr();
printf("-[CC65 Wait Key Test]-------------------");
// Show prompt, then call WaitYN to wait for Y or N keypress
printf("Press Y or N: ");
WaitYN(WON);
printf("\nPress any key (ESC to exit).\n");
// Loop until exit is triggered (ESC pressed)
bR = 0;
while (bR == 0)
{
// Call WaitKCX. Passing WON tells it to process the inverse key
// rather than just pass back that it was pressed.
cK = WaitKCX(WON);
// For special keys, print a message when pressed
if (cK == KINV)
{
printf("Inverse\n");
}
else if (cK == KFHLP)
{
printf("Help\n");
}
else if (cK == KCSTA)
{
printf("Start\n");
}
else if (cK == KCSEL)
{
printf("Select\n");
}
else if (cK == KCOPT)
{
printf("Option\n");
}
else if (cK == KCAP)
{
printf("Caps\n");
}
// For ESC, print the message, and set the exit flag
else if (cK == KESC)
{
printf("Escape\n");
bR = 1;
}
else if (cK == KSPACE)
{
printf("Space\n");
}
// For all other keypresses, display the key value
else
{
printf("%i\n", cK);
}
}
// Exit
return;
}
Screenshot showing it working:
