Keyboard emulation
Posted: Tue Apr 26, 2016 9:27 am
Hi, this is my first post on this forum, and I'm also new about the VIC-20 (I'm more familiar with other Commodore machines), so sorry for my possible stupid questions
Recently I've found Pixel's (hopefully I succeeded to find his nick out on this forum ...) shadowVIC emulator, and since I'm great fan (even if I am not an expert in this topic ...) of trying to write emulators, I started to think about getting familiar with VIC-20 too (inspiration by shadowVIC ...), and trying to write my own emulator as well, utilizing the cross-platform SDL2 library. I've already managed to get the READY. prompt with the original ROM images with my own 65C02 (I know, VIC-20 didn't use the 65C02, the reason of this choice, that I already have an emulation coded for this CPU ... even if it's incorrect choice, and no illegal opcodes will work this way of the original NMOS line) and VIA emulations, originally written for my Commodore LCD emulator (both in Javascript for a web browser based emulator and C version for a native application emulator for Windows - cross compiled with gcc/mingw on Linux - and UNIX-like machines including Linux and Raspberry Pi).
Now, my headache is about emulating the keyboard. As far as I thought, it's a really simple 8x8 matrix, controlled by two ports of VIA2. Interestingly, if I try to do this, odd things happen: even with a fixed keyboard matrix value (ie emulating that a single key is pressed constantly) it seems kernal detects sometimes a different key, sometimes as shift would be pressed as well, etc. I also had the suspect, that maybe my CPU emulation is incorrect for some opcodes, and that causes the problems. But I am really unsure. With logging what kind of VIA port writes are initiated (by the CPU) it seems only a single line is tried to be scanned at all.
Is there any special with the VIC-20 keyboard, I don't know? Can someone suggest something, including some schematic which shows the connection of VIA-2 and the keyboard matrix? To be honest, even with Commodore LCD I had no problem with keyboard, it uses VIA's shift register and shifts 16 bits (with additional byte of other information, like battery status, special keys etc), so in nutshell: it's quite strange stuff for me. However now VIC-20 seems to be even more cryptic for me, which it shouldn't be so complex, or at least I can't see where I am wrong in this topic
Any help is welcome, and thanks for the possible answers
Recently I've found Pixel's (hopefully I succeeded to find his nick out on this forum ...) shadowVIC emulator, and since I'm great fan (even if I am not an expert in this topic ...) of trying to write emulators, I started to think about getting familiar with VIC-20 too (inspiration by shadowVIC ...), and trying to write my own emulator as well, utilizing the cross-platform SDL2 library. I've already managed to get the READY. prompt with the original ROM images with my own 65C02 (I know, VIC-20 didn't use the 65C02, the reason of this choice, that I already have an emulation coded for this CPU ... even if it's incorrect choice, and no illegal opcodes will work this way of the original NMOS line) and VIA emulations, originally written for my Commodore LCD emulator (both in Javascript for a web browser based emulator and C version for a native application emulator for Windows - cross compiled with gcc/mingw on Linux - and UNIX-like machines including Linux and Raspberry Pi).
Now, my headache is about emulating the keyboard. As far as I thought, it's a really simple 8x8 matrix, controlled by two ports of VIA2. Interestingly, if I try to do this, odd things happen: even with a fixed keyboard matrix value (ie emulating that a single key is pressed constantly) it seems kernal detects sometimes a different key, sometimes as shift would be pressed as well, etc. I also had the suspect, that maybe my CPU emulation is incorrect for some opcodes, and that causes the problems. But I am really unsure. With logging what kind of VIA port writes are initiated (by the CPU) it seems only a single line is tried to be scanned at all.
Is there any special with the VIC-20 keyboard, I don't know? Can someone suggest something, including some schematic which shows the connection of VIA-2 and the keyboard matrix? To be honest, even with Commodore LCD I had no problem with keyboard, it uses VIA's shift register and shifts 16 bits (with additional byte of other information, like battery status, special keys etc), so in nutshell: it's quite strange stuff for me. However now VIC-20 seems to be even more cryptic for me, which it shouldn't be so complex, or at least I can't see where I am wrong in this topic
Any help is welcome, and thanks for the possible answers