Page 1 of 1

Keyboard and Storage Device?

Posted: Sun Nov 18, 2018 4:15 am
by noyen1973
Has anyone been able to interface a PC keyboard to the game port or some kind of storage device to the Super NES?
The scan codes from the Xband keyboard look identical to a PC keyboard and the pin outs are pretty much the same as PS/2 and USB with vcc, gnd, clk and data. FAT16/32 has been implemented in 6502 using SPI mode with SD cards. Can the same be done for the Super NES using one or both of the game ports for IO?

Re: Keyboard and Storage Device?

Posted: Sun Nov 18, 2018 6:06 am
by tepples
You'd need a microcontroller (MCU) to link the two, as both the Control Deck and the keyboard want to be generating the clock signal. Years ago, tpw_rules was working on a PS/2 to NES/Super NES controller bridge, with a mouse mode and a keyboard mode, but college interfered.

Re: Keyboard and Storage Device?

Posted: Sun Nov 18, 2018 9:00 am
by nocash
To play by the rules, an SD card adaptor should have voltage conversion (for 3.3V supply/signals).
Without extra logic, the SNES could read about 1 byte per 150 cpu cycles via SPI.
That would be maybe 20Kbytes/second at 3.5MHz for opcodes in FastROM (and less MHz for controller access and main ram).

Re: Keyboard and Storage Device?

Posted: Sun Nov 18, 2018 10:06 am
by tepples
That sounds about right. Assuming the SD card uses SPI over controller 2 bit 1, with a passthrough receptacle to connect actual controller 2 to bit 0, I count 92 master clocks per bit, or 32 + (108 * 8) - 6 = 890 clocks to read a byte, less than one 1324-clock scanline. (Correct me if I'm wrong.)

Code: Select all

  ; Assume sep $20 and fast ROM
  lda #$01   ; 12
  sta tmp    ; 20   ; loop counter: once this 1 reaches carry, we're done
loop:
  lda $4017  ; 30   ; 401x access takes 12 clocks or two fast cycles
  lsr a      ; 12
  lsr a      ; 12   ; select adapter (bit 1), not player 1 (bit 0)
  rol tmp    ; 36
  bcc loop   ; 18
             ; -6   ; last untaken
Equivalent NES code runs in 60 + 192 * 8 - 12 = 1584 clocks, just over one 1364-clock scanline.

Code: Select all

  lda #$01   ; 24
  sta tmp    ; 36   ; loop counter: once this 1 reaches carry, we're done
loop:
  lda $4017  ; 48
  and #$08   ; 24
  cmp #$01   ; 24   ; select adapter (bit 3), not player 1 (bit 0)
  rol tmp    ; 60
  bcc loop   ; 36
             ; -12	   ; last untaken
This is why a few SPI-on-NES proposals give the SPI serialization job to cart hardware.

Re: Keyboard and Storage Device?

Posted: Sun Nov 18, 2018 2:37 pm
by noyen1973
Loading 20Kbytes/s is not that bad if you were going to implement some kind of interpreted language like Basic. A banks worth of Basic code can go pretty far even if it's full of data statements. Audio is pretty limited since the SPC700 only has 64k, ~3 seconds to load. Only graphics data takes up a lot of space and the intent is not making a commercially saleable piece of software. As a learning tool it would be quite appealing for a kid to write something on a console that was intended just for video games. Some built-in tools like a tile/sprite editor, music tracker, assembler and disassembler/monitor to complement Basic would not require much room in ROM (a bank each). Everything could be done right on the Super NES without touching a PC.