4 Player Adapter

From IndividualComputers
Jump to: navigation, search
(thumbnail)
4 Player Adapter

4 Player Joystick Interface originally used by the Commodore 64 game "Bombmania".

It provides two additional joystick ports connected to the user port and can be used with all Commodore computers with a similar user port - the C64, C128, VIC20, PET and CBM610.

Contents

use on a PET 2001

There are two user ports on the PET 2001 computer. Pinout is very similar to the C64/VIC20 user ports, but they both lack a power connection. References to the PET in the sample code below is therefore academic: You could make it work by modifying the pinout of the PET 2001 computer, but since we're talking about a historic machine, we urge you not to do so.

incompatible with plus/4 computer

The 4-player adapter will not work on a plus/4 computer. While the power connection is there (and on the right pins), the signals used by the 4-player adapter cannot be switched to input on the plus/4. Do not even try to connect the adapter to a plus/4 computer - you risk damage to the machine and the adapter! This is a hardware limitation and cannot be modified easily.

Games

C64

Sample Code

Reading the two additional joystick ports is extremely easy. The following code shows how to create two virtual "registers" which contain exactly the same bits as the standard joystick ports, which makes it trivial to add to existing code:

;---------------------------------------
; 4 player adapter sample code
;---------------------------------------
joy3reg  = $02  ; example joy-regs
joy4reg  = $03

; C64/C128
USERPORT_DATA = $DD01
USERPORT_DDR  = $DD03

; VIC20
;USERPORT_DATA = $9110
;USERPORT_DDR  = $9112
;
; PET
;USERPORT_DATA = $E841
;USERPORT_DDR  = $E843
;
; CBM610
;USERPORT_DATA = $DC01
;USERPORT_DDR  = $DC03
;
;note: for CBM610 the code below must
;      be extended to switch to the
;      system bank

;---------------------------------------

read4plr:
;---------------------------------------
; reads adapter and composes the
; additional virtual joystick-registers
;---------------------------------------
;this code demonstrates how to read the
;additional 2 joysticks and how to com-
;pose 2 'virtual' joystick-registers
;that can be processed exactly like the
;usual ($dc00/$dc01) ones.
;---------------------------------------

        lda #$80                ; cia 2 port B read/write
        sta USERPORT_DATA       ; (output one at PB7)
        lda USERPORT_DATA       ; cia 2 port B read/write
        and #$1f                ; get bit 4-0 (PB4-PB0)
        sta joy3reg             ; joy 3 complete
        lda #$00                ; cia 2 port B read/write
        sta USERPORT_DATA       ; (output zero at PB7)
        lda USERPORT_DATA       ; cia 2 port B read/write
        and #$0f                ; get bit 3-0 (PB3-PB0)
        sta joy4reg             ; joy 4 directions
        lda USERPORT_DATA       ; cia 2 port B read/write
        and #%00100000          ; get bit 5 (PB5)
        lsr
        ora joy4reg
        sta joy4reg             ; joy 4 button
        rts

;---------------------------------------

setup4plr:
;---------------------------------------
; initialize CIAs
;---------------------------------------
;warning: do not mess around with this
;         unless you really know what
;         you are doing! wrong cia setup
;         may toast your cia's !
;---------------------------------------

        lda #%10000000          ; cia 2 port B Data-Direction
        sta USERPORT_DDR        ; bit 7: out    bit 6-0: in
        lda #0
        sta USERPORT_DATA       ; output zero at PB7
        rts


Resellers

Please shop locally. Our partners are listed in alphabetical order.

Personal tools
Namespaces

Variants
Actions
Navigation
Icomp
Print/export
Administration