To use the info, you can simply add the travel values onto
pseudoregisters every VBL. Use ADC when X or Y is 0 and use
SBC when X or Y is 1 (don't forget to use CLC for ADC and SEC
for SBC). Add the horizontal and vertical travels separately.
If you want faster tracking, ASL the travel values.
*** PART 2: The Super Multitap ***
The multitap is an easy way for a game to support more than two players. The
multitap is particularly useful when some other device supported by the game,
say a mouse, uses up one of the precious controller ports. With the multitap,
you can have up to five players when nothing but controllers are plugged in,
or you can have four players when something uses up port one (ie: mouse).
The switch on the multitap will disable the last three controllers, forcing
the system to only have two controllers (1 and 2). This is for some games
that may have a compatibilty problem. I don't know of any that do however.
The multitap contains a system for determining whether the extra controllers
are actually plugged in or not. This is a useful feature since it isn't
available on the SNES when no multitap is connected.
The multitap does not interfere with normal controller reading. Reading
the normal controllers with the multitap on 3-5 player mode using the
usual registers ($4218,19 for 1, $421A,1B for 2) works properly.
The multitap uses the port 4 registers to hold the info for port 3 so games
that only use three players are as simple as reading the Joy 4 port in addition
to the Joy 1 and 2 ports (Joy 4 is $421E,1F).
Note: The order of operation here is very important.
- To start reading the multitap, or any controller, be sure to check $4212
and delay if necessary, to ensure that the hardware has read all the port
information.
- The next step is to read the first controller normally. Then read $4016
and store the first two bits. They store the plug-in state for controllers
2 and 3.
- Check the lower four bits on port 1. If they aren't zero, it means that
something other than a controller (probably a mouse) is in port one. Read
it at this time.
- Read Controller two normally.
- Read controller four ($421E,$1F). Now read $4017 and store the first
two bits. These are the plug-in states for joyport 4 and 5. Controller
four gives you joyport 3.
- Put a 0 onto the parallel port. This tells the multitap to place
controllers four and five into $4017. Bit 0 will give the bits for
joyport 4 and bit 1 will give you joyport 5.
- Set bit 7 of the parallel port to get the multitap off the extended
controller registers (so the mouse can use it next reading)
If you hate descriptions (and my rambling on), here's a direct source code
clip from my primary SNES project. Since I use symbolic assembly, I'll make
a list of magic numbers for the labels:
If you see it in MiXeD case, it's a RAM value, just create a label in your
assembler with something like:
SJoy0 = 0 ;Controller result for Joystick 1 (of 5)/Mousebuttons
..and so on...
Note: all the RAM locations used in this code section store words
If you see a label in UPPER case, it's a SNES register.
Use this table:
HVBJOY = $4212
JOY0L = $4218 (H is +1)
JOY1L = $421A (H is +1)
JOY2L = $421C (H is +1)
JOY3L = $421E (H is +1)
JOYSER0 = $4016
JOYSER1 = $4017
WRIO = $4201
;
; Read Multitap controller and mouse simultaneously
;
; Code by Gau of the Veldt
; (C) 1995 Gau of the Veldt
; Freeware
;
; Just mention me somewhere your greets or credits if you use
; this code (the "special thanks" section is fine).
;
; Email is nice too - you can even ask for help :)
; gau@netbistro.com
;
; Mixed labels: RAM locations
; CAPPED labels: SNES Registers
;
; JOYSER0/1 are $4016,$4017 respectively
;
php
sep #$30
- lda HVBJOY
bit #$01
bne - ;Wait for the controller states to get read
lda JOY0H
sta SJoy0+1
lda JOY0L
sta SJoy0 ;Jport1/Mousebuttons is read directly
and #$0F
sta Spare0 ;Indicates a nonzero value here if something
ldx #$10 ;else (ie: mouse) uses $4016 - at this point
- lda JOYSER0 ;(and only this point) you can read this
rep #$20 ;device
lsr
rol SRodent ;Read one word thorugh $4016 bit 0
sep #$20 ;serially into the rodent pseudoreg
dex ;(I use a BIOS for my coding)
bne -
lda JOY1H ;Joyport two is read directly
sta SJoy1+1 ;(ie: used $4219,1A)
lda JOY1L
sta SJoy1
and #$0F
sta Spare0+1 ;Joyport three is read directly
lda JOY3H ;(Note you use $421E,1F, not $421C,1D)
sta SJoy2+1
lda JOY3L
sta SJoy2
and #$0F
sta SJoy23Prs+1 ;1's here indicate plugged-in controllers:
sta SJoy23Prs ;Bit 0: #2 plugged in, 8: #3 plugged in
lda JOYSER1
lsr
rol SJoy23Prs
lsr
rol SJoy23Prs+1
stz WRIO ;Control of $4016,17 given to multitap
ldy #$10
- lda JOYSER1
rep #$20
lsr
rol SJoy3 ;32 bits from $4017, read serially from
lsr ;bit 0 and 1, will indicate the states of
rol SJoy4 ;the last two controller ports.
sep #$20 ;Bit 0 has the bits for Joyport four
dey ;Bit 1 has the bits for Joyport five
bne -
lda SJoy3
and #$0F
sta SJoy45Prs ;1's here inidicate plugged-in controller
lda SJoy4 ;Bit 0: #4 plugged in, 8: #5 plugged in
and #$0F
sta SJoy45Prs+1
sta SJoy45Prs
lda JOYSER1
lsr
rol SJoy45Prs
lsr
rol SJoy45Prs+1
lda #$80 ;Control of $4016(17) given back to mouse
sta WRIO ;Tricky - the tap spies on bit 7 of the
plp ; parallel port (meaning it can be
; read at the controller too :)
Back to SNES home page
Back to Gau's home page
E-Mail: gau@netbistro.com
WWW: http://www.netbistro.com/~gau