        ROM Patch Details
        -----------------


        Repairing a Galaga88 with missing or non-functional
        ic "CUSTOM"  at F10 on the ROM board.

        
        Lock IC contains a code and a 16 bit hardware divider
        CPU writes in the dividend and divisor and the chip
        returns the quotient and remainder.

        It is only used for the shots/hits ratio so to calculate
        this correctly a new simple divide routine is patched
        into the PRG7 ROM.

        First part of fix is to PRG6, removing the lock test
        and fixing the ROM checksum.

        Second part is to PRG7 adding in the divide code
        and the call to use it.
                                   




        G88-PRG6.FIX

        offset    value   comment
        ----------------------------------------
        0020      12      remove lock test
        0021      12
        0022      12


        0070      12      rom checksum fix
        0071      12
        0072      12



        G88-PRG7.FIX

        offset    value    comment
        ----------------------------------------

        EF87      BD       jsr $FA00
        EF88      FA       call to the divide routine
        EF89      00


        FA00      xx       16bit Divide Routine code
        FA3E    



                

        ; --------------------------------------
        ; 
        ; Galaga'88 Divider Code
        ; With a missing of faulty lock/divider
        ; need to do the diving in software(!)
        ; 
        ; --------------------------------------



        ; org $FA00
        

        ; $4102 ; hits
        ; $4100 ; shots

dvs     equ $C2         
dvd     equ $4100
rsd     equ $4104

        

        ldx #32

        ldd #0
        std rsd
        std rsd+2



div1:   andcc #$FE

        rol dvd+3
        rol dvd+2
        rol dvd+1
        rol dvd
        rol rsd+3
        rol rsd+2
        rol rsd+1
        rol rsd

        ldd rsd+2
        subd < dvs        
        bcs  div2  ; zero bit

        std rsd+2
        inc  dvd+3

div2:   leax -1,x        
        bne div1

        ldd dvd+2

        rts







        


