4 Player Adapter

From IndividualComputers
Jump to: navigation, search
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.


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.



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

; VIC20
;USERPORT_DDR  = $9112
; CBM610
;note: for CBM610 the code below must
;      be extended to switch to the
;      system bank


; 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)
        ora joy4reg
        sta joy4reg             ; joy 4 button


; 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


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

Personal tools