endlos99 / finalgrom99

A cartridge for the TI 99/4A that runs ROM and GROM images from an SD card
GNU General Public License v3.0
79 stars 19 forks source link

Keypresses don't work on TI-99/4 #4

Open hexbus opened 1 year ago

hexbus commented 1 year ago

Used v1.3 on a TI-99/4 - Boots fine, but I can't press any key. My guess is the keyscan on the 99/4 is either broken or doesn't take into account the 99/4 keyscan.

endlos99 commented 1 year ago

That'll be hard to examine for me, since I don't own a /4. But I'll keep it in mind, maybe such an opportunity will arise some day.

ecchien commented 5 months ago

I can confirm and repro this same issue. Any hints to determine the keyscan for /4?

hexbus commented 4 months ago

This is what I was told on AtariAge about the Browser.a99 code:

I don’t have access to commented code for the console 99/4 ROM, so I can’t walk the code that matters. What I can 
say is that the likely culprit is in the following code:

input:
       mov  r7, @more_items
       li   r0, >9e7e
       mov  r0, @>8372        ; restore stack pointers for SCAN
       li   r0, >05ff
       mov  r0, @keymode
wait_key:

Storing >05FF at >8374 tells KSCAN to use keyboard #5. The >FF gets stored in >8375 to initialize it to “no key pressed”. 
On the 99/4A, KSCAN stores keyboard#–3 at >83C6 (2 in this case) and then zeroes >8374. 
Since the 99/4 does not know what a keyboard number is, it does not zero >8374 unless a joystick was activated 
and it does not change >83C6. By changing >8374 to 5, the above code has effectively disabled KSCAN on the 99/4. 
This is easy to verify in Classic99 (99/4 mode) by opening the debugger and setting >8374 to 5. 
From that point on, >8374 never changes and keypresses are ignored.

I would change the value stored at >8374 to >00FF.

If there is some concern that the keyboard number has changed, then it could be rewritten to test for the 
99/4A before putting 5 at >8374.

...lee
hexbus commented 4 months ago

Lee actually updated his explanation - I'll just link to it:
https://forums.atariage.com/topic/368319-vcf-se-atlanta-ga-july-19-21st/?do=findComment&comment=5491028

input: mov r7, @more_items li r0, >9e7e mov r0, @>8372 ; restore stack pointers for SCAN li r0, >05ff mov r0, @keymode wait_key:

Storing >05FF at >8374 tells KSCAN to use keyboard (KBD) #5. The >FF gets stored in >8375 to initialize it to “no key pressed”. On the 99/4A, KSCAN stores keyboard#–3 (if KBD# is 3[99/4 mode], 4[Pascal mode], or 5[Basic mode]) at >83C6 (2 in this case) and then zeroes >8374 (which tells KSCAN to check >83C6 for the default KBD#). Since the 99/4 does not know KBD#s other than 0[whole KBD], 1(left-side KBD), and 2(right-side KBD), there is no reason to zero >8374. And, it does not, to my knowledge, do anything with >83C6. By changing >8374 to 5, the above code has effectively disabled KSCAN on the 99/4. This is easy to verify in Classic99 (99/4 mode) by opening the debugger and setting >8374 to 5. From that point on, >8374 never changes and keypresses are ignored until the next software change of KBD# to 0, 1, or 2. FYI, you can also disable KSCAN (until KBD# is properly set to 0, 1, 2, 3, 4, or 5) on the 99/4A by setting the KBD# higher than 5.

I would change the value stored at >8374 to >00FF.

If there is some concern that the keyboard number for a 99/4A has changed, then it could be rewritten to test for the 99/4A before putting 5 at >8374.

hexbus commented 4 months ago

Any updates on this or guidance on how to rebuild it with the suggested changes? I’m using a 99/4 in two weekends (Jul 19-21) and would love to try a new firmware version on my /4, but I have no idea how to recompile and reprogram this. If given instructions, I might be able to. Thanks!

hexbus commented 4 months ago

Fixed it. See here; https://forums.atariage.com/topic/369039-finalgrom-4-patch-here-it-is/