Difference between revisions of "Peripheral 1 Register"

From SpecNext official Wiki
Jump to: navigation, search
(core 3.1.4 changes/refresh)
(updated to 78a6ee50)
 
Line 15: Line 15:
 
| 3 || Joystick 1 mode (MSB)
 
| 3 || Joystick 1 mode (MSB)
 
|-
 
|-
| 2 || 50/60 Hz mode (0 = 50Hz, 1 = 60Hz) (0 after a PoR or Hard-reset)
+
| 2 || 50/60 Hz mode (0 = 50Hz, 1 = 60Hz, pentagon forces 50hz) (0 after a PoR or Hard-reset)
 
|-
 
|-
 
| 1 || Joystick 2 mode (MSB)
 
| 1 || Joystick 2 mode (MSB)
 
|-  
 
|-  
| 0 || Enable Scandoubler (1 = enabled) (1 after a PoR or Hard-reset)
+
| 0 || Enable Scandoubler (1 = enabled for vga, 0 for crt) (1 after a PoR or Hard-reset)
 
|}
 
|}
  
Line 41: Line 41:
 
| %110 || MD 2 (3 or 6 button joystick port {{PortNo|$xx37}})
 
| %110 || MD 2 (3 or 6 button joystick port {{PortNo|$xx37}})
 
|-
 
|-
| %111 || I/O Mode (since core3.1.4 (but needs fixing))
+
| %111 ||   111 = User Defined Keys Joystick
Affects both joysticks if any of them is set into I/O mode.<br>
+
  * Joysticks can be placed in i/o mode via nextreg 0x0B.
<br>
+
  * Programming the user defined keys joystick is done through the ps2 keymap interface on nextreg 0x28, 0x29 and 0x2B:
Configure the I/O mode by writing to {{PortNo|$xx37}} first!
+
    1. Write 128 to nextreg 0x28
 +
    2. Write 0 (left joystick) or 16 (right joystick) to nextreg 0x29
 +
    3. Write twelve bytes to nextreg 0x2B in order. The bytes correspond to the twelve buttons on an md pad (MODE=11 X Z Y START A C B U D L R=0)
 +
    4. Each byte written identifies a key in the 8x7 membrane; bits 5:3 select the row and bits 2:0 select the column with 111 meaning no action
 +
  * In kempston and md modes, excess buttons on a controller not read via ports will generate key input if so programmed
 
|}
 
|}
  

Latest revision as of 10:59, 3 November 2024

Number $05
Readable Yes
Writable Yes
Short Description Sets joystick mode, video frequency and Scandoubler.


Bit Function
7-6 Joystick 1 mode (LSB)
5-4 Joystick 2 mode (LSB)
3 Joystick 1 mode (MSB)
2 50/60 Hz mode (0 = 50Hz, 1 = 60Hz, pentagon forces 50hz) (0 after a PoR or Hard-reset)
1 Joystick 2 mode (MSB)
0 Enable Scandoubler (1 = enabled for vga, 0 for crt) (1 after a PoR or Hard-reset)

Joystick modes are as follows:

Code Effect
%000 Sinclair Joystick 2 (maps to keys 1,2,3,4,5)
%001 Kempston Joystick 1 (uses port Kempston Joystick ($xx1F / 31))
%010 Cursor Joystick (maps to keys 5,6,7,8,0)
%011 Sinclair Joystick 1 (maps to keys 6,7,8,9,0)
%100 Kempston Joystick 2 (uses port Kempston Joystick 2, Joystick I/O ($xx37 / 55))
%101 MD 1 (3 or 6 button joystick port Kempston Joystick ($xx1F / 31))
%110 MD 2 (3 or 6 button joystick port Kempston Joystick 2, Joystick I/O ($xx37 / 55))
%111 111 = User Defined Keys Joystick
  * Joysticks can be placed in i/o mode via nextreg 0x0B.
  * Programming the user defined keys joystick is done through the ps2 keymap interface on nextreg 0x28, 0x29 and 0x2B:
    1. Write 128 to nextreg 0x28
    2. Write 0 (left joystick) or 16 (right joystick) to nextreg 0x29
    3. Write twelve bytes to nextreg 0x2B in order. The bytes correspond to the twelve buttons on an md pad (MODE=11 X Z Y START A C B U D L R=0)
    4. Each byte written identifies a key in the 8x7 membrane; bits 5:3 select the row and bits 2:0 select the column with 111 meaning no action
  * In kempston and md modes, excess buttons on a controller not read via ports will generate key input if so programmed

since core3.1.4: both joysticks are placed in I/O Mode if either is set to I/O Mode. The underlying joystick type is not changed and reads of this register will continue to return the last joystick type. Whether the joystick is in I/O mode or not is invisible but this state can be cleared either through reset or by re-writing the register with joystick type not equal to 111. Recovery time for a normal joystick read after leaving I/O Mode is at most 64 scan lines.

(since core 3.0) both joysticks set to the same type is now confirmed as valid configuration. The result is combined readings from both joysticks to single output.

"MD" above refers to controllers compatible with SEGA Mega Drive system. The 6 (and 3) button variant is mapped onto Kempston port this way (mirroring XYZ buttons on the ABC buttons, so only 4 distinct buttons are supported) (new mapping since core3.1.4):

Bit Joystick action
7 "start" button (pin 9)
6 A button (pin 6)
5 C button (pin 9)
4 B button (pin 6)
3 Up (pin 1)
2 Down (pin 2)
1 Left (pin 3)
0 Right (pin 4)

The pin 6 and 9 reading depends on pin 7 being GND/+5V and it is driven by the FPGA internally (scanning both and building state), the Z80 SW reads final 8bit state from ports 0x1F and/or 0x37 (not driving the pin 7).

(core 3.1.1) the sinclair joystick modes are swapped, "sinclair 2" are keys 1,2,3,4,5 and "sinclair 1" are keys 6,7,8,9,0.