CurtisP, on Fri Apr 27, 2007 11:55 AM, said:
One of my ideas was to use the paddle variables for the keyboard. However, since they are shared with missile0, this would require the kernel_option no_blank_lines to be set. I think I like the idea of dimming the variable better.
The nice thing about making the user "dim" a variable is that it lets you pick which variable you want to use-- one of batari Basic's 26 "user variables," or one of batari Basic's "system variables," or even a byte of Superchip RAM!
CurtisP, on Fri Apr 27, 2007 11:55 AM, said:
The way I would have used vblank was to spread the reading of the controller out over multiple vblanks. Set the output register in one and read it in the next. The drawscreen in between would give you plenty of microseconds. This would require two variables, one for a counter and one for the results. The results variable would just stay 0 until the keypad read was done.
That would take a minimum of 4 frames to read a keypad. I would prefer to read a keypad (or both keypads) in 1 frame. And I've already worked out (in my head, but not yet on paper) how to read the keypad(s) during the vblank and still let the users do other things during the vblank if they want to (although most batari Basic programmers do all of their game tasks during the overscan).
CurtisP, on Fri Apr 27, 2007 11:55 AM, said:
Another possible issue is that this code forces both controllers to be a keypad, whereas some people would like to use a keypad plus a joystick.
No, it doesn't-- or rather, it won't when I'm done with it!

I'm definitely interested in using both a keypad and a joystick, and I'd like to be able to use either controller in either controller port. So I'm going to design my "keypads.asm" include file to compile in different ways depending on the options you want to use. But these won't be kernel options-- at least, not yet, although if batari incorporates my "keypads.asm" include file in a future version of batari Basic, he might want to add some kernel options for it. Instead, what I plan to do is let the user "dim" three possible variables-- "keypads" if both keypads will be used, or "left_keypad" if only one keypad will be used in the left controller port, or "right_keypad" for one keypad in the right controller port. The "keypads.asm" file will compile in different ways depending on whether it should read both keypads, or only one keypad, and which one (left or right) it should read. This will also affect how the "get_keypad" function compiles.
The vblank routine will also compile differently depending on whether the users have specified their own "mini-vblank" routines, which will be called something like "vblank_1" through "vblank_4." Of course, each of these "mini-vblank" routines will be limited in how many cycles they can run for, but that will still be better than not letting the users perform anything at all during the vblank.
Once I've coded everything and tested it out, I'll document it thoroughly before I post it, with some examples showing how to use all of the options-- including the ability to specify which value should be returned for each key when the "get_keypad" function is called.
Michael