So as its almost time to start an entry for CPCRetroDev 2019 I thought it was time I reported a bug I had with wincpctelera.
Just the one bug (I thought I had a few but it turned out my code was the problem even if wincptelera vs cpc did not produce exactly the same result consistently)
I saw you did some changes for CPCtelera 1.5 which I haven't checked out but it probably still applies.
So here is my example of reading a key from the user (based on one of the examples on cpcwiki somewhere).
The problem is that not all the key codes work when using wincpctelera.
The following keys are not detected: z, x, v, del, space
#include <cpctelera.h>
#include <stdio.h>
cpct_keyID getKey();
void interruptHandler();
void main(void)
{
//default to anything
cpct_keyID chosenKey = Key_A;
u8 letterCount = 0;
u8* memory = 0;
u8* memortAlt = 0;
//disable the firmware to prevent it from interfering with setVideoMode
cpct_disableFirmware();
//setup interruptHandler for keyboard scanning
cpct_setInterruptHandler(interruptHandler);
//set video mode to mode 0
cpct_setVideoMode(0);
memory = cpct_getScreenPtr(CPCT_VMEM_START, 8, 12);
memortAlt = cpct_getScreenPtr(CPCT_VMEM_START, 8, 24);
//loop forever
while (1)
{
u8 chosenCharacter = 0;
//get the next character from the user
chosenKey = getKey();
switch (chosenKey)
{
case Key_A:
chosenCharacter = 'a';
break;
case Key_B:
chosenCharacter = 'b';
break;
case Key_C:
chosenCharacter = 'c';
break;
case Key_D:
chosenCharacter = 'd';
break;
case Key_E:
chosenCharacter = 'e';
break;
case Key_F:
chosenCharacter = 'f';
break;
case Key_G:
chosenCharacter = 'g';
break;
case Key_H:
chosenCharacter = 'h';
break;
case Key_I:
chosenCharacter = 'i';
break;
case Key_J:
chosenCharacter = 'j';
break;
case Key_K:
chosenCharacter = 'k';
break;
case Key_L:
chosenCharacter = 'l';
break;
case Key_M:
chosenCharacter = 'm';
break;
case Key_N:
chosenCharacter = 'n';
break;
case Key_O:
chosenCharacter = 'o';
break;
case Key_P:
chosenCharacter = 'p';
break;
case Key_Q:
chosenCharacter = 'q';
break;
case Key_R:
chosenCharacter = 'r';
break;
case Key_S:
chosenCharacter = 's';
break;
case Key_T:
chosenCharacter = 't';
break;
case Key_U:
chosenCharacter = 'u';
break;
case Key_V:
chosenCharacter = 'v';
break;
//doesnt work on wincpctelera
case Key_W:
chosenCharacter = 'w';
break;
//doesnt work on wincpctelera
case Key_X:
chosenCharacter = 'x';
break;
case Key_Y:
chosenCharacter = 'y';
break;
//doesnt work on wincpctelera
case Key_Z:
chosenCharacter = 'z';
break;
//space does not work on wincpctelera
case Key_Space:
chosenCharacter = 0;
cpct_drawStringM0("space", memortAlt, 1, 0);
break;
//del doesn't work with cpctelera but 16386 does
//case 16386:
case Key_Del:
chosenCharacter = 0;
cpct_drawStringM0("del", memortAlt, 1, 0);
break;
default:
chosenCharacter = 0;
cpct_drawStringM0("default", memortAlt, 1, 0);
break;
}
if (chosenCharacter)
{
//draw letter
cpct_drawCharM0(memory, 1, 0, chosenCharacter);
}
}
}
cpct_keyID getKey()
{
// Traverse the keystatus vector from end to start, to help
// the compiler better optimise this code
u8 i = 10;
u8* keys = cpct_keyboardStatusBuffer + 9;
u16 keypressed = 0;
// wait for any previous key presses to clear first
while (cpct_isAnyKeyPressed());
//then wait for the desired key press
while (!cpct_isAnyKeyPressed());
// Analyse which key has been pressed and return its keycode
do
{
// We analyse groups of keys byte by byte (8 by 8, 1 bit per key)
// If no single key is pressed in this group, all bits will be on, and the byte will be 0xFF
// Then, XORing the byte with 0xFF will result in 0 unless some key from this group is pressed
keypressed = *keys ^ 0xFF;
if (keypressed)
{
return (keypressed << + (i - 1); // Convert to cpct_keyID format: 8 first bits = key mask, 8 next bits, keyboard row (0-9)
}
--keys;
} while (--i);
// No key was pressed
return 0;
}
void interruptHandler()
{
//scan for any keyboard changes
cpct_scanKeyboard_if();
}
Have you completed your changes for CPCtelera 1.5?
I haven't decided if I should be using 1.4.2 or grabbing the latest 1.5 from github.