19 July 2017, 14:32 | #1 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
4 controller support on blitz
I remember some Blitz games do actually support 4 controllers ( Skidmarks comes to mind now, I think those Tennis Champ games were also coded in Blitz)
Yet on its manual all joystick functions only mention port 0 or 1, and trying to access any other "port" will give me an error. Is there any way to do it ? Also, does the CD32 supports this somehow ? I dunno if the CD32 has a serial port. |
19 July 2017, 14:38 | #2 |
Unregistered User
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 43
Posts: 4,190
|
The Amiga only has two joystick ports. 4-player games use a parallel port adapter to interface to the two extra controllers, so you have to access the parallel port. I think Blitz should have methods to do this? If you can read the parallel port pins directly, I think it should be fairly simple to read the extra joysticks.
Here's the pinout: http://www.tmeeco.eu/9X4EVER/GOODIES...iga4Player.htm The CD32 can also be used with a 4-player adapter if you connect an SX-1, SX-32 or other expansion which provides a parallel port. |
19 July 2017, 14:47 | #3 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Yeah, I know its a parallel port cable (not Serial like I said in the OP, urgh)..... just thought there was an easy way to do it.
Blitz manual talks about the CIA chip and which register is responsible for the parallel port, but I have no idea of how to read that. I don't think many people with CD32s have a SX-1 or SX-32, right? |
19 July 2017, 14:53 | #4 |
Unregistered User
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 43
Posts: 4,190
|
No, these kind of expansions were expensive so not particularly common. It basically turns the CD32 into an A1200 with a CD-drive but it is much cheaper to just add a CD-drive to a regular A1200. Then you also get a keyboard.
|
19 July 2017, 15:50 | #5 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Reading the parallel port is pretty simple really, from memory it's just a matter of setting the pins high and then reading them back to read the port status. I used this method to read them in my ControllerTest program, which was written in Blitz. I can dig out the code for you if you'd like? I'm pretty sure (I hope) that I put the routine in a little function that you can easily use without worrying about how it works...
Actually, I have a vague memory of an add-in library for Blitz also offering 4-player joystick support, but it wasn't one of the standard libraries. I'll see if I can find that too... |
19 July 2017, 15:52 | #6 | |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Quote:
|
|
19 July 2017, 15:56 | #7 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
No problem, I'll stick it here tonight, time permitting...
|
19 July 2017, 18:52 | #8 | |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
|
Use the RI Zonejoy library. It should already be in your deflibs.
Quote:
|
|
19 July 2017, 19:52 | #9 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
Here you go - this will give you two routines that will give you direction and button information for any port. Ports 0 and 1 are the standard Amiga ports, and 2 and 3 are on the parallel port adaptor. You could also use the existing Blitz commands and just use these for ports 2 and 3 if you liked.
The joydir{port.b} function returns a byte representing the direction of the selected stick, with the lowest 4 bits representing the 4 directions. Note that it will allow opposite directions to be read (e.g. left and right), even though with most controllers that's mechanically impossible. Bit 0 is up, bit 1 is down, bit 2 is left and bit 3 is right, and the bit is set when the controller is pushed that direction. For example: Code:
joybyte.b = joydir{i} If joybyte & %0100 NPrint "Left!" End If Code:
btns.w = joybuttons{1} If btns & %00000010 NPrint "Fire 2 pressed on port 1" End If Code:
Poke.b $BFD200,Peek.b($BFD200) | %00000111 ; Handshake lines to output Poke.b $BFD000,Peek.b($BFD000) | %00000111 ; Handshake lines high Poke.b $BFD200,Peek.b($BFD200) & %11111000 ; Handshake lines back to input Poke.b $BFE301,%11111111 ; Output mode Poke.b $BFE101,%11111111 ; All pins high So the full code can look like this: Code:
; Initialisation Poke.b $BFD200,Peek.b($BFD200) | %00000111 ; Handshake lines to output Poke.b $BFD000,Peek.b($BFD000) | %00000111 ; Handshake lines high Poke.b $BFD200,Peek.b($BFD200) & %11111000 ; Handshake lines back to input Poke.b $BFE301,%11111111 ; Output mode Poke.b $BFE101,%11111111 ; All pins high Function.b joydir{port.b} result.b=0 If port<2 If port=1 bytes.w=Peek.w($DFF00C) ; JOY1DAT Else bytes.w=Peek.w($DFF00A) ; JOY0DAT End If bit9.w=bytes&%0000001000000000 bit8.w=bytes&%0000000100000000 bit1.w=bytes&%0000000000000010 bit0.w=bytes&%0000000000000001 result = result | (((bit9 LSR 1) EOR bit8) LSR 8) ; Up result = result | (bit1 LSL 2) ; Right result = result | (bit1 EOR (bit0 LSL 1)) ; Down result = result | (bit9 LSR 7) ; Left Else ; Parallel port adaptor byte.b = NOT Peek.b($BFE101) If port=2 result=byte & %00001111 Else result=(byte & %11110000) LSR 4 End If End If Function Return result End Function Function.b joybuttons{port.b} result.w=0 If port<2 buttonbyte.b=Peek.b($BFE001) ; CIA for button 1 If port=1 result=(buttonbyte & %0000000010000000) LSR 7 Else result=(buttonbyte & %0000000001000000) LSR 6 End If bytes.w=(Peek.w($DFF016) LSR (9+(port*4))) ; Potgo for buttons 2 & 3 result=result | (bytes & %0000000000000010) bytes.w=(Peek.w($DFF016) LSR (6+(port*4))) result=result | (bytes & %0000000000000100) Else ; Parallel port adaptor buttonbyte=Peek.b($BFD000) If port=3 result=(buttonbyte & %00000001) result=result | %00000010 ; No second fire button on port 3 (Yet... Wired to Ack) Else result=(buttonbyte & %00000100) LSR 2 result=result | (buttonbyte & %00000010) End If result=result | % 11111100 End If Function Return result End Function |
19 July 2017, 19:53 | #10 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
|
|
20 July 2017, 03:49 | #11 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Hey, thank you guys. This will be very helpful!
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blitz basic] How much amiga-blitz friendly is this? | saimon69 | Coders. Blitz Basic | 105 | 21 April 2022 19:45 |
Blitz Support Suite - REDMapEditor 060 compatibility? | Graham Humphrey | Coders. Blitz Basic | 2 | 07 April 2017 22:21 |
Sony ds4 controller and cd32 support | ARTHUR071169 | support.FS-UAE | 8 | 31 December 2016 01:18 |
XBox 360 controller support (hat switch) | sulaco | support.WinUAE | 6 | 13 April 2012 16:50 |
Alien Breed 3D controller support. | AtlasRapture | support.WinUAE | 1 | 17 July 2010 01:13 |
|
|