MiSTer-devel / NES_MiSTer

GNU General Public License v3.0
169 stars 73 forks source link

[Feature Request] Family BASIC Keyboard support #204

Open famiclone6502 opened 4 years ago

famiclone6502 commented 4 years ago

Hello,

Famicom is short for Family Computer, and it originally offered a keyboard attachment and cassette recorder for loading/saving data like many home computers at the time.

Please support the Family BASIC Keyboard for both typing and loading/saving via the data recorder. I can make a separate request for the data recorder port on the keyboard if needed, but some games like Lode Runner need to detect the presence of the keyboard itself before allowing loading/saving.

Typing is primarily used in multiple revisions of Family BASIC, but it is also used for cheats in Zanac.

Games that uses the data recorder for loading and saving data are Family BASIC programs, Excitebike, Mach Rider, and Wrecking Crew, Castle Excellent, Arkanoid - Revenge of Doh, Lode Runner, and Nuts & Milk.

For the data recorder implementation, please support loading and saving via files and ADC in.

Technical information on the keyboard can be found here on NESdev with some details quoted below:

The Family Basic Keyboard (HVC-007) was a peripheral released with the Family Basic package in 1984. With the data recorder that could be attached to it, it allowed the Famicom to have the abilities of the average home computer of around that time. It is a generic 72 button keyboard using common matrix logic, and can be connected to the Famicom at the expansion port.

Hardware The Family BASIC Keyboard is implemented using a CD4017 decade counter (to scan the rows of the keyboard matrix), a CD4019 quad AND-OR gate, and one sixth of a CD4069 hex inverter. The latter two are combined to make a quad 1-of-2 selector, equivalent to a CD4519 or a 74'157. (Another three inverters are used to interface to the Family BASIC Data Recorder)

Miscellaneous Unlike the PC keyboard, but similar to the Commodore 64 keyboard, the sixteen keys corresponding to ASCII $2C-$3B all specify the ASCII code point should be XORed with $10 when the SHIFT key is pressed. This can be used to simplify the keyboard decoding logic in your program.

There is no backslash key, however, historical reasons have given to using the yen key and symbol for the same meaning. The kana are arranged in (grid) alphabetical order, not in the way that modern Japanese computers are.

Detection The game Lode Runner allows saving level data to tape by pressing SELECT during Edit Mode, but will only provide that option if it detects the Family BASIC Keyboard. The detection procedure (CPU $E9B8) selects the tenth row and expects $4017 AND $1E to return $1E, then writes $00 to $4016 to disable the keyboard and expects $4017 AND $1E to return $00.

Technical details on the data recorder functionality can also be found here on NESdev.

Thank you

famiclone6502 commented 4 years ago

There is a new homebrew application for testing the keyboard that can be found here.

bootsector commented 3 years ago

+1 for this feature! I would really love to experiment with Family BASIC on the MiSTer!

famiclone6502 commented 1 year ago

It looks like there is some activity on this in PR336

From testing it currently conflicts with the save state restore buttons F1-F4.

famiclone6502 commented 1 year ago

It looks like this was merged, but it's still conflicting with save state buttons. I also get a message on Famicom BASIC that the "backup off switch" needs to be flipped.

I've created the following issues: https://github.com/MiSTer-devel/NES_MiSTer/issues/346 https://github.com/MiSTer-devel/NES_MiSTer/issues/347

Cassette recorder functionality is still not implemented, so I am not closing this issue yet. I am leaving closing this to your discretion.