-------------------------------------------------------------------------------
    Using the DXS&HIT 4-Player Adapter with Bomb-Mania by Classical Games
-------------------------------------------------------------------------------

I wrote this while i was patching this game for personal testing purposes ...
i really still wonder how easy it was =) Use this file to understand how both
ours and the Classical-Games adapter works and how to smartly support them
both =)

I didnt really bother yet releasing a patched version, but with this info and
the 3 patch files it should be easy enough for you to create your personal
patched version, even from the original (i think) if you don't like cracks :P.

Groepaz/Hitmen                                                  groepaz@gmx.net

1. in the titlescreen of the game, freeze
2. load "bm-patch1"  => driver for our 4player adapter (here at $0900-$0980)

;---------------------------------------
;4 player adapter sample code by gpz/hit
;---------------------------------------

joy3reg  = $b5
joy4reg  = $b6

         *=$0900

         jmp setup
;---------------------------------------
read
;---------------------------------------
; 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.
;---------------------------------------
         ;
         ; save cia 2 registers
         ;

         lda $dd00
         sta ciasave1+1
         lda $dd02
         sta ciasave2+1

         ;
         ; read directions joy 3+joy 4
         ;

         lda $dd01 ;read cia 2 port b
         sta temp+1

         and #$0f
         sta joy3reg

temp     lda #$00
         lsr a
         lsr a
         lsr a
         lsr a
         sta joy4reg

         ;
         ; read button joy 3
         ;

         lda $dd02      ;cia 2 port a
         and #%11111011 ;data direction
         sta $dd02      ;=> bit 2 input

         lda $dd00      ;read cia 2 p.A
         and #%00000100 ;check bit 2
         asl a
         asl a
         ora joy3reg
         sta joy3reg

         ;
         ; read button joy 4
         ;

         lda #$ff ;serial data register
         sta $dc0c;=> writing $ff causes
                  ;cia to output some
                  ;count signals at cnt1

         lda $dd0c ;read cia 2 serial in
         beq fire  ;button press if zero

         lda joy4reg
         ora #%00010000
         sta joy4reg

fire

         ;
         ; restore cia 2 registers
         ;

ciasave1 lda #$00
         sta $dd00
ciasave2 lda #$00
         sta $dd02

         rts

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

         ;
         ; cia 2 setup
         ;

         lda #$00  ; port b direction
         sta $dd03 ; => input

         lda #$01
         sta $dd04 ; timer a lowbyte
         lda #$00
         sta $dd05 ; timer a highbyte

         lda #%00010001
         sta $dd0e ; control register a
                   ; timer: start
                   ;        continous
                   ;        forced load
                   ; serial port: input

         ;
         ; cia 1 setup
         ;

         lda #$01
         sta $dc04 ; timer a lowbyte
         lda #$00
         sta $dc05 ; timer a highbyte

         lda #%01010001
         sta $dc0e ; control register a
                   ; timer: start
                   ;        continous
                   ;        forced load
                   ; serial port: output

         lda #$ff ;serial data register
         sta $dc0c;=> writing $ff causes
                  ;cia to output some
                  ;count signals at cnt1
         rts

3. load "bm-patch2"  => inserts the adapter init code in the game-init:

original code:

1039    lda #%10000000  ; cia 2 port B Data-Direction
103b    sta $dd03       ; bit 7: out    bit 6-0: in
103e    nop
103f    nop
1040    nop
1041    lda $dd01       ; cia 2 port B read/write
1044    sta $dd01       ; (output zero at PB7 ?)
1047    rts

patch:

1039    jmp $0900   ;adapter init
103c    nop
103d    nop
103e    nop
103f    nop
1040    nop
1041    nop
1042    nop
1043    nop
1044    nop
1045    nop
1046    nop
1047    rts

4. load "bm-patch3"  => this inserts the adapter read code into the game:

original code:

119b    lda $dd01       ; cia 2 port B read/write
119e    and #$1f        ; get bit 4-0 (PB4-PB0)
11a0    sta joy3reg     ; joy 3 complete
11a2    lda #$00        ; cia 2 port B read/write
11a4    sta $dd01       ; (output zero at PB7)
11a7    nop
11a8    nop
11a9    nop
11aa    lda $dd01       ; cia 2 port B read/write
11ad    and #$0f        ; get bit 3-0 (PB3-PB0)
11af    sta joy4reg     ; joy 4 directions
11b1    lda $dd01       ; cia 2 port B read/write
11b4    and #%00100000  ; get bit 5 (PB5)
11b6    lsr
11b7    ora joy4reg
11b9    sta joy4reg     ; joy 4 button
11bb    rts

patch:

119b    jmp $0903   ;adapter read
119e    nop
119f    nop
11a0    nop
11a1    nop
11a2    nop
11a3    nop
11a4    nop
11a5    nop
11a6    nop
11a7    nop
11a8    nop
11a9    nop
11aa    nop
11ab    nop
11ac    nop
11ad    nop
11ae    nop
11af    nop
11b0    nop
11b1    nop
11b2    nop
11b3    nop
11b4    nop
11b5    nop
11b6    nop
11b7    nop
11b8    nop
11b9    nop
11ba    nop
11bb    rts

5. restart the game at $2eda

6. you may freeze again and save

note: i do ofcoz know about removing a rts and filling unneeded space with
      $00's ... just did it like this here for safety reasons. (you can never
      be sure if the coder wouldn't jump just into the middle of his routine)
