(include "sci.sh")
(use "Main")
(use "ShipChunk")
(use "Blink")
(use "Scaler")
(use "CueObj")
(use "MoveFwd")
(use "n958")
(use "SysWindow")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 850)


(local
    local0
    local1
    local2
    theTheRegister_2
    theTheRegister
    theRegister
    local6
    local7
    theShipNum
    local9
    local10
    theShip
    local12
    local13
    local14
    local15
    local16
    local17
    local18
    local19
    clientX
    clientY
    local22
    local23
    local24
    local25
    local26
    local27[2]
    local31 = 2
    local32
    local33
    local63
    local63[30] = (9 5 3 5 0 0 0 0 0 0 0 0 6 7 8 9 )
    local63[16] = (58602 55248 44622 48816 17632 36480 58432 11808 17472 3584 17472 3584 20032 20032 20032 20032 )
    local79[6] = (120 134 158 150 190 120 )
    local85[300]

)
(procedure (localproc_055b param1)
    (var temp0, temp1, temp2, temp3)
    = temp0 (+ (* (/ gPEventX 9) 9) 2)
    = temp1 (- (* (/ gPEventY 8) 8) 3)
    = temp2 0
    = temp3 0
    (switch (param1)
        (case 1
            (= temp3 -1  )
        )
        (case 5
            (= temp3 1  )
        )
        (case 3
            (= temp2 1  )
        )
        (case 7
            (= temp2 -1  )
        )
        (case 2
            (= temp2 1 = temp3 -1  )
        )
        (case 8
            (= temp2 -1 = temp3 -1  )
        )
        (case 4
            (= temp2 1 = temp3 1  )
        )
        (case 6
            (= temp2 -1 = temp3 1 )
        )
    )
    = temp2 (* temp2 9)
    = temp3 (* temp3 8)
    SetCursor(+ temp0 temp2 + temp1 temp3)
)


(procedure (localproc_0614 param1 param2)
    (var temp0)
    return == local63[param1] local63[(+ temp0 (= local63[(+ temp0 param1)] (+ local63[(+ (= temp0 
                (if (== param2 0)
                    4
                )(else
                    8
                )
) param1)] 1)))]
)


(procedure (localproc_0641)
    (send gSQ5:handsOn())
    (send gSq5IconBar:disable(0 3 4 5 6))
    (send ((send gSq5IconBar:at(2))):cursor(999))
    (send gSq5IconBar:curIcon((send gSq5IconBar:at(2))))
)


(procedure (localproc_067d param1)
    return <= local63[param1] local63[(+ param1 4)]
)


(procedure (localproc_0689 param1 param2 param3)
    (var temp0, temp1)
    = temp0 (- param1 1)
    (while (<= temp0 (+ param1 1))
        = temp1 (- param2 1)
        (while (<= temp1 (+ param2 1))
            (if ((((== temp1 param2) or (== temp0 param1)) and proc999_4(0 0 9 9 temp0 temp1)) and not (& $0008 localproc_07ef(temp0 temp1 param3 0)))
                = local22 temp0
                = local23 temp1
                = local24 param3
                return 1
            )
            ++temp1
        )
        ++temp0
    )
    return 0
)


(procedure (localproc_06fc)
    (var temp0, temp1, temp2, temp3)
    = temp2 0
    (while (< temp2 3)
        = temp0 0
        (while (<= temp0 9)
            = temp1 0
            (while (<= temp1 9)
                (if (((> (& $000f (= temp3 localproc_07ef(temp0 temp1 temp2 0))) 8) and not localproc_067d((- (& $0007 temp3) 1))) and localproc_0689(temp0 temp1 temp2))
                    return 1
                )
                ++temp1
            )
            ++temp0
        )
        ++temp2
    )
    return 0
)


(procedure (localproc_076b)
    (var temp0[3], temp3, temp4)
    (asm
        pushi   0
        call    localproc_07fc, 0
        bnt     code_077d
        lal     local22
        sal     local13
        lal     local23
        sal     local12
        jmp     code_07ba
code_077d:pushi   2
        pushi   0
        pushi   4
        callk   Random, 4
        push    
        ldi     2
        mul     
        sal     local13
        pushi   2
        pushi   0
        pushi   9
        callk   Random, 4
        sal     local12
        push    
        ldi     1
        and     
        bnt     code_079b
        +al     local13
code_079b:pushi   2
        pushi   0
        pushi   2
        callk   Random, 4
        sal     local24
        pushi   8
        pushi   4
        lsl     local13
        lsl     local12
        push    
        pushi   0
        call    localproc_07ef, 8
        sat     temp3
        and     
        not     
        bnt     code_077d
        jmp     code_07ba
        jmp     code_077d
code_07ba:lal     local24
        ret     
    )
)


(procedure (localproc_07bd param1 param2 param3 param4)
    (var temp0, temp1)
    = temp0 32768
    = temp0 (>> temp0 (+ param1 (= param2 (* param2 4))))
    = temp1 local63[(+ (* param3 4) param4)]
    return & local63[(+ (* param3 4) param4)] temp0
)


(procedure (localproc_07ef param1 param2 param3 param4)
    (var temp0, temp1)
    = temp0 (+ (+ (* param3 50) (* param2 5)) (/ param1 2))
    = temp1 
        (if (& param1 $0001)
            255
        )(else
            65280
        )
    = temp0 (& local85[(+ param4 temp0)] temp1)
    return 
        (if (& param1 $0001)
            temp0
        )(else
            >> temp0 $0008
        )
)


(procedure (localproc_0834 param1 param2 param3 param4 param5)
    (var temp0, temp1, temp2)
    = temp0 (+ (+ (* param3 50) (* param2 5)) (/ param1 2))
    = temp1 
        (if (& param1 $0001)
            65280
        )(else
            255
        )
    = local85[(+ param4 temp0)] (& local85[(+ param4 temp0)] temp1)
    = param5 (& param5 $00ff)
    = temp1 
        (if (& param1 $0001)
            param5
        )(else
            (<< param5 $0008)
        )
    = local85[(+ param4 temp0)] (| local85[(+ param4 temp0)] temp1)
)


(procedure (localproc_089b)
    (var temp0)
    = temp0 0
    (while (< temp0 300)
        = local85[temp0] 0
        ++temp0
    )
)


(procedure (localproc_08b3 param1 param2 param3 param4 param5 param6)
    (var temp0, temp1)
    = temp0 0
    (while (< temp0 4)
        = temp1 0
        (while (< temp1 4)
            (if (localproc_07bd(temp1 temp0 param1 param2))
                (if (not proc999_4(0 0 9 9 - (+ temp1 param4) 1 - (+ temp0 param5) 1))
                    return 0
                )(else
                    (if (localproc_07ef(- (+ temp1 param4) 1 - (+ temp0 param5) 1 param3 param6))
                        return 0
                    )
                )
            )
            ++temp1
        )
        ++temp0
    )
    return 1
)


(procedure (localproc_0935 param1 param2 param3 param4 param5 param6 param7)
    (var temp0, temp1)
    = temp0 0
    (while (< temp0 4)
        = temp1 0
        (while (< temp1 4)
            (if (localproc_07bd(temp1 temp0 param1 param2))
                localproc_0834(- (+ temp1 param4) 1 - (+ temp0 param5) 1 param3 param6 param7)
            )
            ++temp1
        )
        ++temp0
    )
)


(procedure (localproc_0987)
    (shipSelector:loop((+ theShipNum 6)))
    (if ((send (= theShip 
        (switch (theShipNum)
            (case 0
                (ship1  )
            )
            (case 1
                (ship2  )
            )
            (case 2
                (ship3  )
            )
            (case 3
                (ship4 )
            )
        )
):inPlace))
        (specialCursor:
            view(999)
            loop(0)
            cel(0)
        )
        = theShip 0
    )(else
        (specialCursor:
            view((send theShip:view))
            loop((send theShip:loop))
            setCel((send theShip:cel))
        )
    )
)


(procedure (localproc_0a0a)
    (var temp0, temp1)
    = temp0 0
    = temp1 1
    (while (< temp0 10)
        DrawCel(537 temp1 0 + 114 (* temp0 9) 89 14)
        ++temp0
        ++temp1
    )
    = temp0 0
    = temp1 1
    (while (< temp0 10)
        DrawCel(539 temp1 0 106 + 97 (* temp0 8) 14)
        ++temp0
        ++temp1
    )
    Graph(12 88 115 95 205 1)
    Graph(12 97 106 176 113 1)
)


(procedure (localproc_0a89 param1 param2)
    (var temp0, temp1, temp2, temp3)
    = temp0 0
    (while (< temp0 10)
        = temp1 0
        (while (< temp1 10)
            (if (& (= temp2 localproc_07ef(temp1 temp0 param1 param2)) $0008)
                (if (& temp2 $0007)
                    = temp3 0
                )(else
                    = temp3 1
                )
                DrawCel(537 12 temp3 + 115 (* temp1 9) + 97 (* temp0 8) 14)
            )(else
                (if (& temp2 $0010)
                    DrawCel(537 12 2 + 115 (* temp1 9) + 97 (* temp0 8) 14)
                )
            )
            ++temp1
        )
        ++temp0
    )
)


(procedure (localproc_0b1d param1 param2 param3 param4)
    (var temp0, temp1, temp2)
    = temp1 (- param2 2)
    (while (< temp1 (+ param2 2))
        = temp0 (- param1 2)
        (while (< temp0 (+ param1 2))
            = temp2 localproc_07ef(temp0 temp1 param3 param4)
            (if (proc999_4(0 0 9 9 temp0 temp1) and (& temp2 $0007))
                localproc_0834(temp0 temp1 param3 param4 = temp2 (| temp2 $0010))
            )
            ++temp0
        )
        ++temp1
    )
)


(procedure (localproc_0b8c)
    (var temp0, temp1, temp2, temp3)
    = temp3 0
    (while (< temp3 3)
        = temp1 0
        (while (< temp1 10)
            = temp0 0
            (while (< temp0 10)
                (if (& (= temp2 localproc_07ef(temp0 temp1 temp3 150)) $0007)
                    localproc_0834(temp0 temp1 temp3 150 | temp2 $0010)
                )
                ++temp0
            )
            ++temp1
        )
        ++temp3
    )
)


(procedure (localproc_0beb)
    (var temp0, temp1, temp2, temp3, temp4)
    (asm
        ldi     0
        sat     temp0
code_0bf1:lst     temp0
        ldi     4
        lt?     
        bnt     code_0c86
code_0bf9:pushi   2
        pushi   0
        pushi   9
        callk   Random, 4
        sat     temp3
        pushi   2
        pushi   0
        pushi   9
        callk   Random, 4
        sat     temp4
        pushi   2
        pushi   0
        pushi   2
        callk   Random, 4
        sat     temp2
        pushi   2
        pushi   0
        pushi   3
        callk   Random, 4
        sat     temp1
        pushi   6
        lst     temp0
        push    
        lst     temp2
        lst     temp3
        lst     temp4
        pushi   150
        call    localproc_08b3, 12
        bnt     code_0bf9
        pushi   7
        lst     temp0
        lst     temp1
        lst     temp2
        lst     temp3
        lst     temp4
        pushi   150
        lst     temp0
        ldi     1
        add     
        push    
        call    localproc_0935, 14
        lst     temp1
        pushi   16
        lat     temp0
        add     
        sali    local33
        lst     temp3
        ldi     13
        add     
        push    
        ldi     9
        mul     
        push    
        ldi     2
        add     
        push    
        pushi   20
        lat     temp0
        add     
        sali    local33
        lst     temp4
        ldi     13
        add     
        push    
        ldi     8
        mul     
        push    
        ldi     3
        sub     
        push    
        pushi   24
        lat     temp0
        add     
        sali    local33
        jmp     code_0c81
        jmp     code_0bf9
code_0c81:+at     temp0
        jmp     code_0bf1
code_0c86:ret     
    )
)


(procedure (localproc_0c87 param1)
    (var temp0, temp1)
    = temp0 0
    (while (< temp0 (send gCast:size))
        (if ((send ((= temp1 (send gCast:at(temp0)))):isKindOf(Ship)) and (send temp1:inPlace))
            (if (== (send temp1:lev) param1)
                (send temp1:
                    show()
                    startUpd()
                )
                (if (>= (send gSQ5:_detailLevel) 3)
                    (send temp1:setScale(ShipScaler))
                )(else
                    (send temp1:
                        scaleX(127)
                        scaleY(127)
                    )
                )
            )(else
                (send temp1:hide())
            )
        )
        ++temp0
    )
)


(class ShipChunk of Actor
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck 26505
        state 0
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 533
        loop 0
        cel 0
        priority 13
        underBits 0
        signal 22544
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal 0
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        illegalBits 32768
        xLast 0
        yLast 0
        xStep 3
        origStep 770
        moveSpeed 1
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
    )

    (method (init param1 param2 param3)
        (self:
            x(param1)
            y(param2)
        )
        (super:init(rest param3))
        (self:
            setCycle(Fwd)
            setMotion(MoveFwd 50 self)
        )
    )


    (method (cue)
        (self:dispose())
    )

)
(class Ship of Prop
    (properties
        x 0
        y 0
        z 50
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck 26505
        state 0
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 538
        loop 0
        cel 0
        priority 13
        underBits 0
        signal 20504
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal 1
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        shipNum -1
        col -1
        row -1
        lev -1
        inPlace 0
    )

    (method (init param1)
        (super:init(rest param1))
        (self:hide())
    )


    (method (doit param1)
        (if ((== local33 3) and (== local63 0))
            (self:hide())
        )(else
            (if ((== theShip self) or not (send gUser:canControl()))
                0
            )(else
                (if ((inPlace and (== theRegister lev)) and not (self:isNotHidden()))
                    (self:show())
                )(else
                    (if ((<> theRegister lev) and (self:isNotHidden()))
                        (self:hide())
                    )
                )
            )
        )
        (super:doit(rest param1))
    )


    (method (doVerb param1)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (if (== local33 0)
                        (if (not theShip)
                            = theShipNum shipNum
                            = inPlace 0
                            (self:hide())
                            = theShip self
                            localproc_0935(shipNum cel lev col row 0 0)
                            localproc_0987()
                        )(else
                            (grid:doVerb(4))
                        )
                    )
                )
                (default 
                    (send gTestMessager:say(noun 0 0 0))
                )
            )
        )(else
            (send gTestMessager:say(noun 0 0 0))
        )
    )


    (method (onMe param1)
        (if (not proc999_4(116 97 206 177 gPEventX gPEventY) or (<> (send gSq5IconBar:curIcon) (send gSq5IconBar:at(2))))
            (super:onMe(rest param1))
        )(else
            (if ((((<= nsLeft (specialCursor:x)) and (<= (specialCursor:x) nsRight)) and (<= nsTop (specialCursor:y))) and (<= (specialCursor:y) nsBottom))
                (self:isNotHidden())
            )
            return 
        )
    )


    (method (place)
        (if (localproc_08b3(shipNum cel lev col row 0))
            (self:
                inPlace(1)
                show()
                normalize()
            )
            localproc_0935(shipNum cel lev col row 0 + shipNum 1)
            = theShip 0
        )
    )


    (method (normalize)
        (self:
            x(+ (* (+ col 13) 9) 2)
            y(+ (- (* (+ row 13) 8) 3) z)
            scaleX(128)
            scaleY(128)
        )
    )

)
(instance public rm850 of Rm
    (properties
        noun 13
        picture 75
    )

    (method (init param1)
        (quirkHead:init())
        (send gSq5Music1:
            number(27)
            vol(127)
            loop(-1)
            play()
        )
        proc958_0(128 537 531 538 539 533)
        proc958_0(132 202 203 27)
        (super:init(rest param1))
        (cheat1f:
            init()
            setOnMeCheck(26505)
        )
        (cheat2f:
            init()
            setOnMeCheck(26505)
        )
        (send gDirectionHandler:addToFront(controlBar))
        (self:
            overlay(175)
            setScript(playGame)
        )
    )


    (method (doit param1)
        (if (GameIsRestarting())
            localproc_0a0a()
            localproc_0a89(theRegister 
                (if (== local63 0)
                    150
                )(else
                    0
                )
)
        )
        (super:doit(rest param1))
    )


    (method (dispose param1)
        (send ((send gSq5IconBar:at(2))):cursor(982))
        (send gDirectionHandler:delete(controlBar))
        (controlBar:dispose())
        DisposeScript(951)
        (super:dispose(rest param1))
    )


    (method (doVerb param1 param2)
        return 
            (if (== param1 1)
                (super:doVerb(param1 rest param2))
            )(else
                return 1
            )
    )

)
(class Bar of EventHandler
    (properties
        elements 0
        size 0
        curButton 0
        selectCount 0
        initialized 0
    )

    (method (init param1)
        (if (not initialized)
            (super:init(rest param1))
            (send gTheDoits:addToFront(self))
            (send gMouseDownHandler:addToFront(self))
            (send gKeyDownHandler:addToFront(self))
            = initialized 1
        )
    )


    (method (doit)
        (var temp0)
        (super:doit())
        (if (((not selectCount and (== (send gSq5IconBar:curIcon) (send gSq5IconBar:at(2)))) and (send gUser:canControl())) and (= temp0 (self:firstTrue(226 gPEventX (- gPEventY 10)))))
            (self:highLight(temp0))
        )
    )


    (method (dispose param1)
        (send gTheDoits:delete(self))
        (send gMouseDownHandler:delete(self))
        (send gKeyDownHandler:delete(self))
        (super:dispose(rest param1))
    )


    (method (handleEvent pEvent)
        (var temp0, temp1)
        = temp1 (send ((send gSq5IconBar:curIcon)):message)
        (if (selectCount and (& (send pEvent:type) $4002))
            (self:highLight(curButton))
            = selectCount 0
            (send pEvent:claimed(1))
        )(else
            (if (((send pEvent:claimed) or not (send gUser:canControl())) or (<> (send gSq5IconBar:curIcon) (send gSq5IconBar:at(2))))
                0
            )(else
                (if (& (send pEvent:type) $0040)
                    localproc_055b((send pEvent:message))
                    (send pEvent:claimed(1))
                    return 1
                )(else
                    (if (((& (send pEvent:type) $4001) and proc999_4(116 97 206 177 pEvent)) and (<> local33 1))
                        return 0
                    )(else
                        (if (((& (send pEvent:type) $0001) and not (send pEvent:modifiers)) and not selectCount)
                            (if (= temp0 (self:firstTrue(226 pEvent)))
                                (self:select((= temp0 (self:firstTrue(226 pEvent)))))
                                (send temp0:doVerb(temp1))
                                (send pEvent:claimed(1))
                            )(else
                                (send pEvent:claimed(0))
                            )
                        )(else
                            (if (& (send pEvent:type) $4004)
                                (switch ((send pEvent:message))
                                    (case 13
                                        (if (= temp0 (self:firstTrue(226 pEvent)))
                                            (self:select((= temp0 (self:firstTrue(226 pEvent)))))
                                            (send temp0:doVerb(temp1))
                                            (self:highLight(curButton))
                                            = selectCount 0
                                            (send pEvent:claimed(1))
                                        )(else
                                            (send pEvent:claimed(0))
                                        )
                                    )
                                    (case 3840
                                        (self:retreat())
                                        (send pEvent:claimed(1))
                                    )
                                    (case 9
                                        (self:advance())
                                        (send pEvent:claimed(1))
                                    )
                                )
                            )(else
                                (send pEvent:claimed(0))
                            )
                        )
                    )
                )
            )
        )
        return (send pEvent:claimed)
    )


    (method (select theCurButton)
        (send curButton:setCel(0))
        (if (paramTotal and theCurButton)
            (send theCurButton:setCel(1))
            = curButton theCurButton
            (send gSq5Music2:
                number(124)
                loop(1)
                play()
            )
            = selectCount 1
        )(else
            = curButton 0
        )
    )


    (method (highLight theCurButton)
        (send curButton:highLight())
        (if (paramTotal and theCurButton)
            (send theCurButton:highLight(1))
            = curButton theCurButton
        )(else
            = curButton 0
        )
    )


    (method (advance)
        (var temp0, temp1)
        = temp0 (self:indexOf(curButton))
        (if (== ++temp0 size)
            = temp0 0
        )
        SetCursor(+ (send ((= temp1 (self:at(temp0)))):x) 3 + (send temp1:y) 3)
        = gPEventX (+ (send temp1:x) 3)
        = gPEventY (+ (send temp1:y) 3)
    )


    (method (retreat)
        (var temp0, temp1)
        = temp0 (self:indexOf(curButton))
        (if (== --temp0 -1)
            = temp0 (- size 1)
        )
        SetCursor(+ (send ((= temp1 (self:at(temp0)))):x) 3 + (send temp1:y) 3)
        = gPEventX (+ (send temp1:x) 3)
        = gPEventY (+ (send temp1:y) 3)
    )


    (method (hide)
        (self:eachElementDo(102))
    )


    (method (show)
        (self:eachElementDo(224))
    )

)
(instance controlBar of Bar
    (properties)

    (method (init)
        (super:init())
        (self:release())
        (switch (local33)
            (case 0
                ((playBut:dispose()) (directionBut:dispose()) (self:
                    add(nextBut rotateBut doneBut sector1But sector2But sector3But quitBut)
                    curButton(sector1But)
                )
  )
            )
            (case 1
                ((self:
                    add(playBut directionBut)
                    curButton(playBut)
                )
  )
            )
            (default 
                (
                (switch (local63)
                    (case 150
                        ((self:add(doneBut)) (weaponBut:dispose()) (probeBut:dispose()) (numProbes:
                            startUpd()
                            dispose()
                            delete()
                        )
 (firePanel:
                            startUpd()
                            dispose()
                            delete()
                        )
  )
                    )
                    (case 0
                        ((doneBut:dispose()) (self:add(weaponBut)) (weaponBut:
                            init()
                            current(1)
                        )
 
                        (if (local31)
                            (probeBut:
                                init()
                                current(0)
                            )
                            (self:add(probeBut))
                            (numProbes:
                                init()
                                stopUpd()
                            )
                        )(else
                            (probeBut:
                                startUpd()
                                dispose()
                                delete()
                            )
                            (numProbes:
                                startUpd()
                                dispose()
                                delete()
                            )
                        )
 (firePanel:
                            init()
                            stopUpd()
                        )
 )
                    )
                )
 (nextBut:dispose()) (rotateBut:dispose()) (shipSelector:dispose()) (self:
                    add(sector1But sector2But sector3But quitBut)
                    curButton(sector1But)
                )
 = theShip 0 )
            )
        )
        (self:eachElementDo(110))
    )

)
(class Button of View
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck 26505
        state 0
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 538
        loop 0
        cel 0
        priority 14
        underBits 0
        signal 16400
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal 0
        scaleX 128
        scaleY 128
        maxScale 128
        current 0
    )

    (method (init param1)
        (self:setCel(
            (if (current)
                3
            )(else
                0
            )
))
        (super:init(rest param1))
    )


    (method (doit param1)
        (if (current and (< cel 3))
            (self:setCel((+ cel 3)))
        )(else
            (if (not current and (> cel 2))
                (self:setCel((- cel 3)))
            )
        )
        (super:doit(rest param1))
    )


    (method (handleEvent pEvent param2)
        (var temp0)
        (if (== (send pEvent:message) 4)
            (controlBar:handleEvent(pEvent))
        )(else
            (super:handleEvent(pEvent rest param2))
        )
    )


    (method (highLight)
        (var theParamTotal, temp1)
        (if (paramTotal)
            = theParamTotal paramTotal
        )(else
            = theParamTotal 0
        )
        (self:setCel((= temp1 (+ 
                (if (theParamTotal)
                    2
                )(else
                    0
                )
 
                (if (current)
                    3
                )(else
                    0
                )
))))
    )

)
(instance doneBut of Button
    (properties
        x 73
        y 174
        noun 3
        loop 3
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (if (== local33 3)
                        (if (== local63 150)
                            (quirksTurn:cue())
                        )(else
                            (rogersTurn:cue())
                        )
                    )(else
                        (if ((((ship1:inPlace) and (ship2:inPlace)) and (ship3:inPlace)) and (ship4:inPlace))
                            (send ((send gRoom:script)):cue())
                        )(else
                            (send gTestMessager:say(noun 4 1 0))
                        )
                    )
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance sector1But of Button
    (properties
        x 206
        y 104
        noun 15
    )

    (method (doit param1)
        = current (== theRegister 0)
        (super:doit(rest param1))
    )


    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (grid:setScript(changeGrid 0 0))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance sector2But of Button
    (properties
        x 206
        y 116
        noun 16
        loop 1
    )

    (method (doit param1)
        = current (== theRegister 1)
        (super:doit(rest param1))
    )


    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (grid:setScript(changeGrid 0 1))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance sector3But of Button
    (properties
        x 206
        y 128
        noun 17
        loop 2
    )

    (method (doit param1)
        = current (== theRegister 2)
        (super:doit(rest param1))
    )


    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (grid:setScript(changeGrid 0 2))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance nextBut of Button
    (properties
        x 73
        y 115
        noun 7
        loop 11
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    = theShipNum (% --theShipNum 4)
                    localproc_0987()
                    (grid:setScript(showShip))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance quitBut of Button
    (properties
        x 73
        y 104
        noun 11
        loop 12
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (grid:setScript(iQuit))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance playBut of Button
    (properties
        x 140
        y 120
        view 539
        loop 11
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    = local33 0
                    (send ((send gRoom:script)):cue())
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance directionBut of Button
    (properties
        x 140
        y 135
        view 539
        loop 12
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    = local33 2
                    (send ((send gRoom:script)):cue())
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance rotateBut of Button
    (properties
        x 73
        y 126
        noun 14
        loop 10
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (if (theShip and not (send theShip:inPlace))
                        (send theShip:setCel((% (- (send theShip:cel) 1) 4)))
                        (specialCursor:
                            view((send theShip:view))
                            loop((send theShip:loop))
                            cel((send theShip:cel))
                        )
                    )
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance weaponBut of Button
    (properties
        x 212
        y 149
        noun 18
        loop 14
        current 1
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    = current 1
                    (probeBut:current(0))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance probeBut of Button
    (properties
        x 212
        y 162
        noun 9
        loop 15
    )

    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    = current 1
                    (weaponBut:current(0))
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )

)
(instance numProbes of View
    (properties
        x 217
        y 173
        noun 8
        view 538
        loop 13
        priority 14
        signal 22544
    )

    (method (init param1)
        (self:setCel(local31))
        (super:init(rest param1))
    )


    (method (doVerb param1 param2)
        return 
            (if (== param1 1)
                (super:doVerb(param1 rest param2))
            )(else
                return 1
            )
    )

)
(instance firePanel of View
    (properties
        x 209
        y 142
        noun 4
        view 538
        loop 12
        cel 3
        priority 13
        signal 16400
    )

    (method (doVerb param1 param2)
        return 
            (if (== param1 1)
                (super:doVerb(param1 rest param2))
            )(else
                return 1
            )
    )

)
(instance lines of View
    (properties
        x 115
        y 97
        noun 5
        view 538
        loop 4
        cel 3
        priority 13
        signal 18448
    )

    (method (doit)
        (if (<> loop (grid:loop))
            (self:setLoop((grid:loop)))
        )
        (if (>= (grid:scaleX) 127)
            (self:
                x((grid:x))
                y((grid:y))
            )
            (if (not (self:isNotHidden()) and (grid:isNotHidden()))
                (self:show())
            )
        )(else
            (if ((self:isNotHidden()))
                (self:hide())
            )
        )
    )


    (method (doVerb param1)
        (grid:doVerb(rest param1))
    )

)
(instance grid of Actor
    (properties
        x 115
        y 97
        noun 5
        yStep 6
        view 538
        loop 4
        priority 12
        signal 18448
        scaleSignal 5
        scaleX 127
        scaleY 127
        cycleSpeed 20
        xStep 8
        moveSpeed 0
    )

    (method (init param1)
        (if (== local33 0)
            (self:
                setLoop(4)
                posn(120 134)
                scaleX(10)
                scaleY(10)
            )
        )(else
            (if (== local63 0)
                (self:setLoop(5))
            )(else
                (self:setLoop(4))
            )
            (self:setCel(theRegister))
            (if (< (send gSQ5:_detailLevel) 3)
                (grid:
                    setScale(0)
                    scaleX(128)
                    scaleY(128)
                    posn(115 97)
                )
            )(else
                (self:
                    x(local79[* theRegister 2])
                    y(local79[+ (* theRegister 2) 1])
                    scaleX(10)
                    scaleY(10)
                )
            )
        )
        (super:init(rest param1))
    )


    (method (doVerb param1 param2)
        (if ((send gUser:canControl()))
            (switch (param1)
                (case 4
                    (if (== local33 0)
                        (if (theShip and proc999_4(116 97 206 177 gPEventX (- gPEventY 10)))
                            (send theShip:place())
                        )
                    )(else
                        (if ((not script and (== local63 0)) and proc999_4(116 97 206 177 gPEventX (- gPEventY 10)))
                            8
                            (if (ERROR_UNIMPLEMENTED_OPCODE)
                                (send gTestMessager:say(noun 4 2 0))
                            )(else
                                (if ((weaponBut:current))
                                    (self:setScript(fire))
                                )(else
                                    (if (local31)
                                        (self:setScript(launchProbe))
                                    )
                                )
                            )
                        )
                    )
                )
                (default 
                    (super:doVerb(param1 rest param2))
                )
            )
        )
    )


    (method (hide param1)
        (lines:hide())
        (super:hide(rest param1))
    )

)
(instance ship1 of Ship
    (properties
        noun 19
        loop 6
        shipNum 0
    )
)
(instance ship2 of Ship
    (properties
        noun 20
        loop 7
        shipNum 1
    )
)
(instance ship3 of Ship
    (properties
        noun 21
        loop 8
        shipNum 2
    )
)
(instance ship4 of Ship
    (properties
        noun 22
        loop 9
        shipNum 3
    )
)
(instance logo of View
    (properties
        x 118
        y 118
        view 537
        priority 14
        signal 16400
        scaleSignal 1
    )

    (method (doit param1)
        (self:x((- 160 (/ (- nsRight nsLeft) 2))))
        (super:doit(rest param1))
    )

)
(instance shipSelector of View
    (properties
        x 87
        y 149
        noun 1
        view 538
        loop 6
        priority 13
        signal 20496
    )

    (method (doit param1)
        (if (theShip and (<> cel (send theShip:cel)))
            (self:setCel((send theShip:cel)))
        )
        (super:doit(rest param1))
    )


    (method (doVerb param1 param2)
        return 
            (if (== param1 1)
                (super:doVerb(param1 rest param2))
            )(else
                return 1
            )
    )

)
(instance extra1 of Actor
    (properties
        x 277
        y 162
        view 538
        loop 7
        cel 3
        priority 8
        signal 22544
    )
)
(instance extra2 of Actor
    (properties
        view 537
        loop 12
        cel 1
        priority 14
        signal 22544
    )
)
(instance chunk1 of ShipChunk
    (properties
        loop 1
    )
)
(instance chunk2 of ShipChunk
    (properties
        heading 60
        loop 2
    )
)
(instance chunk3 of ShipChunk
    (properties
        heading 120
        loop 3
    )
)
(instance chunk4 of ShipChunk
    (properties
        heading 180
        loop 4
    )
)
(instance chunk5 of ShipChunk
    (properties
        heading 240
        loop 5
    )
)
(instance chunk6 of ShipChunk
    (properties
        heading 320
        loop 6
    )
)
(instance hitMiss of Prop
    (properties
        y 93
        view 537
        loop 13
        priority 14
        signal 22544
        cycleSpeed 12
    )

    (method (init param1 param2)
        (if (paramTotal and param1)
            (self:
                setLoop(14)
                cel(1)
                posn(83 93)
            )
        )(else
            (self:
                setLoop(13)
                cel(1)
                posn(211 93)
            )
        )
        (super:init(rest param2))
    )


    (method (doVerb param1 param2)
        return 
            (if (== param1 1)
                (super:doVerb(param1 rest param2))
            )(else
                return 1
            )
    )

)
(instance quirkHead of Prop
    (properties
        x 139
        y 65534
        view 531
        priority 1
        signal 22544
    )

    (method (doVerb param1 param2)
        return 
            (if (== param1 1)
                (super:doVerb(param1 rest param2))
            )(else
                return 1
            )
    )


    (method (show param1 param2)
        (switch (local32)
            (case 0
                ((self:
                    setLoop(0)
                    x(139)
                    y(65534)
                )
  )
            )
            (case 2
                ((self:
                    setLoop(1)
                    x(143)
                    y(65531)
                )
  )
            )
            (case 1
                ((self:
                    setLoop(2)
                    x(134)
                    y(65531)
                )
 )
            )
        )
        (super:show(rest param2))
    )

)
(instance specialCursor of View
    (properties
        view 999
        priority 15
        signal 20496
    )

    (method (doit param1)
        (var temp0, temp1, temp2, temp3)
        (asm
            pushi   #canControl
            pushi   0
            lag     gUser
            send    4
            not     
            bnt     code_1a4f
            pushi   #isNotHidden
            pushi   0
            self    4
            bnt     code_1a4f
            pushi   #hide
            pushi   0
            self    4
            jmp     code_1c1b
code_1a4f:  pushi   #curIcon
            pushi   0
            lag     gSq5IconBar
            send    4
            push    
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            eq?     
            bnt     code_1bdb
            lag     gPEventX
            sat     temp2
            lsg     gPEventY
            ldi     10
            sub     
            sat     temp3
            pushi   6
            pushi   116
            pushi   97
            pushi   206
            pushi   177
            lst     temp2
            push    
            calle   proc999_4, 12
            bnt     code_1b98
            pushi   #cursor
            pushi   0
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            send    4
            push    
            ldi     996
            ne?     
            bnt     code_1ac8
            pushi   #cursor
            pushi   1
            pushi   996
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            send    6
            pushi   #curIcon
            pushi   1
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            push    
            lag     gSq5IconBar
            send    6
            pushi   #setCursor
            pushi   1
            pushi   996
            lag     gSQ5
            send    6
code_1ac8:  lst     temp2
            ldi     1
            add     
            push    
            ldi     9
            div     
            sat     temp0
            push    
            ldi     13
            lt?     
            bnt     code_1ade
            ldi     13
            sat     temp0
code_1ade:  lst     temp0
            ldi     22
            gt?     
            bnt     code_1aea
            ldi     22
            sat     temp0
code_1aea:  lst     temp3
            ldi     7
            add     
            push    
            ldi     8
            div     
            sat     temp1
            push    
            ldi     13
            lt?     
            bnt     code_1b00
            ldi     13
            sat     temp1
code_1b00:  lst     temp1
            ldi     22
            gt?     
            bnt     code_1b0c
            ldi     22
            sat     temp1
code_1b0c:  lst     temp0
            ldi     13
            sub     
            sal     local13
            lst     temp1
            ldi     13
            sub     
            sal     local12
            lal     local11
            bnt     code_1b72
            pushi   6
            lsl     local8
            pTos    cel
            lsl     local5
            lst     temp0
            ldi     13
            sub     
            push    
            lst     temp1
            ldi     13
            sub     
            push    
            pushi   0
            call    localproc_08b3, 12
            bnt     code_1c1b
            pushi   224
            pushi   0
            pushi   1
            pushi   1
            lst     temp0
            ldi     9
            mul     
            push    
            ldi     2
            add     
            push    
            pushi   0
            pushi   1
            lst     temp1
            ldi     8
            mul     
            push    
            ldi     3
            sub     
            push    
            self    16
            pushi   #col
            pushi   1
            lsl     local13
            pushi   722
            pushi   1
            lsl     local12
            pushi   723
            pushi   1
            lsl     local5
            lal     local11
            send    18
            jmp     code_1c1b
code_1b72:  pushi   2
            pushi   1
            pushi   999
            pushi   224
            pushi   #y
            pushi   1
            pushi   1
            lst     temp0
            ldi     9
            mul     
            push    
            ldi     2
            add     
            push    
            pushi   0
            pushi   1
            lst     temp1
            ldi     8
            mul     
            push    
            ldi     3
            sub     
            push    
            self    22
            jmp     code_1c1b
code_1b98:  pushi   #cursor
            pushi   0
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            send    4
            push    
            ldi     999
            ne?     
            bnt     code_1bd3
            pushi   #cursor
            pushi   1
            pushi   999
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            send    6
            pushi   #setCursor
            pushi   1
            pushi   #cursor
            pushi   0
            pushi   #curIcon
            pushi   0
            lag     gSq5IconBar
            send    4
            send    4
            push    
            lag     gSQ5
            send    6
code_1bd3:  pushi   #hide
            pushi   0
            self    4
            jmp     code_1c1b
code_1bdb:  pushi   #cursor
            pushi   0
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            send    4
            push    
            ldi     999
            ne?     
            bnt     code_1c16
            pushi   #cursor
            pushi   1
            pushi   999
            pushi   #at
            pushi   1
            pushi   2
            lag     gSq5IconBar
            send    6
            send    6
            pushi   #setCursor
            pushi   1
            pushi   #cursor
            pushi   0
            pushi   #curIcon
            pushi   0
            lag     gSq5IconBar
            send    4
            send    4
            push    
            lag     gSQ5
            send    6
code_1c16:  pushi   #hide
            pushi   0
            self    4
code_1c1b:  pushi   #doit
            pushi   0
            &rest   param1
            super   View, 4
            ret     
        )
    )


    (method (doVerb)
        (grid:doVerb(4))
    )

)
(instance changeGrid of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (
                (if (== client grid)
                    (send gSQ5:handsOff())
                )
 (grid:startUpd()) (lines:startUpd()) 
                (if ((== local63 150) or (== local33 0))
                    (ship1:startUpd())
                    (ship2:startUpd())
                    (ship3:startUpd())
                    (ship4:startUpd())
                )
 
                (if (== theRegister register)
                    = state (+ state 1)
                )(else
                    (if (> register 3)
                        = register (- register 10)
                    )
                )
 = cycles 2  )
            )
            (case 1
                (
                (if (local9)
                    Graph(8 local9)
                    Graph(13 97 115 178 206)
                    Graph(11 97 115 178 206 2 -1 0 -1)
                )
 = cycles 4  )
            )
            (case 2
                (
                (if ((== local63 150) or (== local33 0))
                    localproc_0c87(theRegister)
                )
 
                (if (< (send gSQ5:_detailLevel) 3)
                    (grid:
                        setScale(0)
                        scaleX(127)
                        scaleY(127)
                        posn(115 97)
                    )
                    = state (+ state 2)
                    = cycles 1
                )(else
                    (grid:
                        setMotion(MoveTo local79[* theRegister 2] local79[+ (* theRegister 2) 1] self)
                        setScale(gridScaler 100 10 97 local79[+ (* theRegister 2) 1])
                    )
                )
 )
            )
            (case 3
                (
                (if (<> theRegister register)
                    (grid:hide())
                )
 = cycles 2  )
            )
            (case 4
                (
                (if (<> theRegister register)
                    = local9 Graph(7 97 115 178 206 1)
                )
 = cycles 2  )
            )
            (case 5
                (
                (if (<> theRegister register)
                    (grid:
                        show()
                        setCel(= theRegister register)
                    )
                    = state (+ state 1)
                )
 
                (if (< (send gSQ5:_detailLevel) 3)
                    (grid:
                        posn(115 97)
                        scaleX(127)
                        scaleY(127)
                    )
                    = cycles 3
                )(else
                    (grid:
                        posn(local79[* theRegister 2] local79[+ (* theRegister 2) 1])
                        setMotion(MoveTo 115 97 self)
                        setScale(gridScaler 100 10 97 local79[+ (* theRegister 2) 1])
                    )
                )
 
                (if ((== local63 150) or (== local33 0))
                    localproc_0c87(theRegister)
                )
 )
            )
            (case 6
                ((lines:show()) = cycles 2  )
            )
            (case 7
                (
                (if ((== local63 150) or (== local33 0))
                    (ship1:
                        setScale(0)
                        normalize()
                        stopUpd()
                    )
                    (ship2:
                        setScale(0)
                        normalize()
                        stopUpd()
                    )
                    (ship3:
                        setScale(0)
                        normalize()
                        stopUpd()
                    )
                    (ship4:
                        setScale(0)
                        normalize()
                        stopUpd()
                    )
                )
 (grid:
                    x(115)
                    y(97)
                    scaleX(127)
                    scaleY(127)
                )
 (lines:stopUpd()) (grid:stopUpd()) = cycles 1  )
            )
            (case 8
                (
                (if (== local33 3)
                    localproc_0a89(theRegister 
                        (if (== local63 0)
                            150
                        )(else
                            0
                        )
)
                )
 
                (if (== client grid)
                    localproc_0641()
                )
 (self:dispose()) )
            )
        )
    )

)
(instance showShip of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (
                (if (== client grid)
                    (send gSQ5:handsOff())
                )
 
                (if ((send (= temp0 
                    (switch (theShipNum)
                        (case 0
                            (ship1  )
                        )
                        (case 1
                            (ship2  )
                        )
                        (case 2
                            (ship3  )
                        )
                        (case 3
                            (ship4 )
                        )
                    )
):inPlace))
                    (self:setScript(changeGrid self (send temp0:lev)))
                )(else
                    (if (== client grid)
                        localproc_0641()
                    )
                    (self:dispose())
                )
 )
            )
            (case 1
                (
                (if (== client grid)
                    localproc_0641()
                )
 (self:dispose()) )
            )
        )
    )

)
(instance shakeShip of Script
    (properties)

    (method (dispose param1)
        (send client:
            x(clientX)
            y(clientY)
        )
        (super:dispose(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send client:startUpd()) = cycles 3  )
            )
            (case 1
                (= clientX (send client:x) = clientY (send client:y) = cycles 1  )
            )
            (case 2
                ((send client:
                    x(+ clientX (* (- Random(0 2) 1) 1))
                    y(+ clientY (* (- Random(0 2) 1) 1))
                )
 --state = cycles 1 )
            )
        )
    )

)
(instance blowUpShip of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc958_0(128 538 533) proc958_0(132 203) 
                (if (theShip)
                    (extra1:
                        view((send theShip:view))
                        loop((send theShip:loop))
                        cel((send theShip:cel))
                        x((send theShip:x))
                        y(- (send theShip:y) (send theShip:z))
                        signal(16400)
                        init()
                    )
                )(else
                    (extra1:
                        view(538)
                        cel(local63[+ 15 (& local19 $0007)])
                        signal(16400)
                        loop(+ 5 (& local19 $0007))
                        x(local63[+ 19 (& local19 $0007)])
                        y(local63[+ 23 (& local19 $0007)])
                        init()
                    )
                )
 (extra1:
                    setPri(15)
                    setScript(shakeShip)
                )
 = seconds 4  )
            )
            (case 1
                ((send gSq5Music2:
                    number(203)
                    loop(1)
                    play()
                )
 (extra1:
                    view(533)
                    loop(0)
                    cel(0)
                    cycleSpeed(5)
                    setScript(0)
                    setCycle(End self)
                )
 (chunk1:init((extra1:x) (extra1:y))) (chunk2:init((extra1:x) (extra1:y))) (chunk3:init((extra1:x) (extra1:y))) (chunk4:init((extra1:x) (extra1:y))) (chunk5:init((extra1:x) (extra1:y))) (chunk6:init((extra1:x) (extra1:y))) = seconds 4  )
            )
            (case 2
                ((extra1:dispose())  )
            )
            (case 3
                ((chunk1:dispose()) (chunk2:dispose()) (chunk3:dispose()) (chunk4:dispose()) (chunk5:dispose()) (chunk6:dispose()) (send gTestMessager:say(local2 0 local1 0 self))  )
            )
            (case 4
                (= register 
                    (if (== local63 150)
                        28
                    )(else
                        29
                    )
 
                (if (== local63 0)
                    ++local31
                )
 
                (if (== (= local63[register] (+ local63[register] 1)) 4)
                    = local6 
                        (if (== local63 0)
                            150
                        )(else
                            0
                        )
                )
 (self:dispose()) )
            )
        )
    )

)
(instance launchProbe of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (
                (if (== local63 0)
                    (numProbes:setCel(--local31))
                )
 = theShip 0 
                (if (== client grid)
                    (send gSQ5:handsOff())
                )
 = local16 local12 (extra1:
                    init()
                    view(537)
                    setLoop(12)
                    cel(1)
                    x(+ 115 (* (= local17 local13) 9))
                    y(97)
                    setPri(15)
                )
 (extra2:
                    view(537)
                    setLoop(12)
                    cel(1)
                    x(115)
                    y(+ 97 (* local16 8))
                    init()
                )
 (send gSq5Music2:
                    number(224)
                    loop(-1)
                    play()
                )
 DrawCel(537 + local17 1 1 + 114 (* local17 9) 89 14) DrawCel(539 + local16 1 1 106 + 97 (* local16 8) 14) Graph(12 88 115 95 205 1) Graph(12 97 106 176 113 1) = local14 0 = local15 0 = cycles 2  )
            )
            (case 1
                (
                (if (<> local15 local17)
                    (extra2:
                        x(+ (extra2:x) 9)
                        y(+ 97 (* local16 8))
                    )
                    ++local15
                    = state 0
                )
 
                (if (<> local14 local16)
                    (extra1:
                        x(+ 115 (* local17 9))
                        y(+ (extra1:y) 8)
                    )
                    ++local14
                    = state 0
                )
 = ticks 10  )
            )
            (case 2
                ((extra2:dispose()) (extra1:
                    view(537)
                    setLoop(15)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 3
                (DrawCel(537 + local17 1 0 + 114 (* local17 9) 89 14) DrawCel(539 + local16 1 0 106 + 97 (* local16 8) 14) Graph(12 88 115 95 205 1) Graph(12 97 106 176 113 1) = cycles 2  )
            )
            (case 4
                ((send gSq5Music2:stop()) localproc_0b1d(local13 local12 theRegister 
                    (if (== local63 0)
                        150
                    )(else
                        0
                    )
) localproc_0a89(theRegister 
                    (if (== local63 0)
                        150
                    )(else
                        0
                    )
) (extra1:dispose()) = seconds 4  )
            )
            (case 5
                (
                (if (== local63 0)
                    (rogersTurn:cue())
                )(else
                    localproc_0641()
                )
 (self:dispose()) )
            )
        )
    )

)
(instance fire of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (= theShip 0 
                (if (== client grid)
                    (send gSQ5:handsOff())
                )
 = local16 local12 = local17 local13 (send gSq5Music2:
                    number(657)
                    loop(1)
                    play()
                )
 (extra1:
                    init()
                    view(537)
                    setLoop(12)
                    cel(1)
                    x(+ 115 (* local17 9))
                    y(97)
                    setPri(15)
                )
 (extra2:
                    view(537)
                    setLoop(12)
                    setCel(1)
                    init()
                    setCycle(0)
                    x(115)
                    y(+ 97 (* local16 8))
                    setPri(15)
                )
 DrawCel(537 + local17 1 1 + 114 (* local17 9) 89 14) DrawCel(539 + local16 1 1 106 + 97 (* local16 8) 14) Graph(12 88 115 95 205 1) Graph(12 97 106 176 113 1) = local14 0 = local15 0 = cycles 4  )
            )
            (case 1
                (
                (if (<> local15 local17)
                    (extra2:
                        x(+ (extra2:x) 9)
                        y(+ 97 (* local16 8))
                    )
                    ++local15
                    = state 0
                )
 
                (if (<> local14 local16)
                    (extra1:
                        x(+ 115 (* local17 9))
                        y(+ (extra1:y) 8)
                    )
                    ++local14
                    = state 0
                )
 = ticks 5  )
            )
            (case 2
                (
                (if (& (= local19 localproc_07ef(local17 local16 theRegister 
                        (if (== local63 0)
                            150
                        )(else
                            0
                        )
)) $0007)
                    (if (== local63 150)
                        = theShip 
                            (switch ((- (& local19 $0007) 1))
                                (case 0
                                    ship1
                                )
                                (case 1
                                    ship2
                                )
                                (case 2
                                    ship3
                                )
                                (case 3
                                    ship4
                                )
                            )
                        (send theShip:setScript(shakeShip))
                    )
                    (send gSq5Music2:
                        number(202)
                        loop(1)
                        play()
                    )
                    (hitMiss:init(1))
                )(else
                    (hitMiss:init(0))
                )
 (extra2:dispose()) (extra1:
                    setLoop(11)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(End self)
                )
  )
            )
            (case 3
                ((extra1:setCycle(Beg self))  )
            )
            (case 4
                (
                (if (theShip and (== local63 150))
                    (send theShip:setScript(0))
                )
 (hitMiss:dispose()) (extra1:dispose()) 
                (if (== local63 150)
                    = local2 12
                )(else
                    = local2 10
                )
 
                (if (& local19 $0007)
                    (if (localproc_0614(- (& local19 $0007) 1 
                        (if (== local63 0)
                            150
                        )(else
                            0
                        )
))
                        = local1 local63[(+ 11 (& local19 $0007))]
                    )(else
                        = local1 4
                    )
                )(else
                    = local1 5
                )
 = cycles 4  )
            )
            (case 5
                (DrawCel(537 + local17 1 0 + 114 (* local17 9) 89 14) DrawCel(539 + local16 1 0 106 + 97 (* local16 8) 14) Graph(12 88 115 95 205 1) Graph(12 97 106 176 113 1) = cycles 2  )
            )
            (case 6
                (localproc_0834(local17 local16 theRegister 
                    (if (== local63 0)
                        150
                    )(else
                        0
                    )
 | local19 $0008) localproc_0a89(theRegister 
                    (if (== local63 0)
                        150
                    )(else
                        0
                    )
) = cycles 4  )
            )
            (case 7
                (
                (if (proc999_5(local1 4 5))
                    = cycles 1
                )(else
                    (self:setScript(blowUpShip self))
                )
 )
            )
            (case 8
                (= theShip 0 (quirkHead:show(0)) 
                (if (== local6 -1)
                    (if (== local63 0)
                        (rogersTurn:cue())
                    )(else
                        localproc_0641()
                    )
                )(else
                    (send gRoom:setScript(endGame))
                )
 (self:dispose()) )
            )
        )
    )

)
(instance quirksTurn of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1[30])
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) = local63 150 (lines:startUpd()) (grid:
                    startUpd()
                    hide()
                )
 (firePanel:
                    startUpd()
                    hide()
                )
 (numProbes:
                    startUpd()
                    hide()
                )
 = cycles 2  )
            )
            (case 1
                (
                (if (local9)
                    Graph(8 local9)
                    Graph(13 97 115 178 206)
                    Graph(11 97 115 178 206 2 -1 0 -1)
                )
 = cycles 4  )
            )
            (case 2
                ((controlBar:
                    init()
                    show()
                )
 DrawPic(175 100 0) = cycles 2  )
            )
            (case 3
                (= local9 Graph(7 97 115 178 206 1) = cycles 2  )
            )
            (case 4
                (= theRegister theTheRegister (grid:
                    init()
                    show()
                )
 = temp0 localproc_076b() (self:setScript(changeGrid self temp0))  )
            )
            (case 5
                ((ship1:stopUpd()) (ship2:stopUpd()) (ship3:stopUpd()) (ship4:stopUpd()) (self:setScript(fire self))  )
            )
            (case 6
                (localproc_0641()  )
            )
            (case 7
                (= theTheRegister theRegister (self:dispose()) )
            )
        )
    )

)
(instance rogersTurn of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (ship1:hide()) (ship2:hide()) (ship3:hide()) (ship4:hide()) (lines:startUpd()) (grid:
                    startUpd()
                    hide()
                )
 (firePanel:
                    startUpd()
                    show()
                )
 (numProbes:
                    startUpd()
                    show()
                )
 = cycles 2  )
            )
            (case 1
                (
                (if (local9)
                    Graph(8 local9)
                    Graph(13 97 115 178 206)
                    Graph(11 97 115 178 206 2 -1 0 -1)
                )
 = cycles 4  )
            )
            (case 2
                (= local63 0 (controlBar:
                    init()
                    show()
                )
 = theRegister theTheRegister_2 (grid:
                    init()
                    show()
                )
 DrawPic(176 100 0) = cycles 2  )
            )
            (case 3
                (= local9 Graph(7 97 115 178 206 1) = cycles 2  )
            )
            (case 4
                ((self:setScript(changeGrid self 
                    (if (< (send gSQ5:_detailLevel) 3)
                        theTheRegister_2
                    )(else
                        (+ theTheRegister_2 10)
                    )
))  )
            )
            (case 5
                (localproc_0641()  )
            )
            (case 6
                (= theTheRegister_2 theRegister (self:dispose()) )
            )
        )
    )

)
(instance endGame of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (ship1:hide()) (ship2:hide()) (ship3:hide()) (ship4:hide()) (grid:
                    startUpd()
                    hide()
                )
 (firePanel:
                    startUpd()
                    show()
                )
 (numProbes:
                    startUpd()
                    show()
                )
 = cycles 2  )
            )
            (case 1
                (
                (if (local9)
                    Graph(8 local9)
                    Graph(13 97 115 178 206)
                    Graph(11 97 115 178 206 2 -1 0 -1)
                )
 = cycles 4  )
            )
            (case 2
                (
                (if (local6)
                    proc0_10(215 * (- 4 local63[28]) 25)
                    (send gTestMessager:say(12 2 11 0 self))
                )(else
                    (send gTestMessager:say(10 2 11 0 self))
                )
 )
            )
            (case 3
                ((send gRoom:newRoom(500)) )
            )
        )
    )

)
(instance iQuit of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gTestMessager:say(10 2 10 0 self))  )
            )
            (case 1
                ((send gRoom:newRoom(500)) )
            )
        )
    )

)
(instance doDirections of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (playBut:dispose()) (directionBut:dispose()) (send gRoom:drawPic(75 9)) = cycles 3  )
            )
            (case 1
                ((send gTestMessager:say(2 0 0 0 self))  )
            )
            (case 2
                (= local33 0 = gSq5Win gSq5Win_2 (send gRoom:overlay(175)) (self:dispose()) )
            )
        )
    )

)
(instance playGame of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (logo:
                    init()
                    scaleX(0)
                    scaleY(0)
                )
 = seconds 2  )
            )
            (case 1
                (
                (if (< (logo:scaleX) 128)
                    (logo:
                        scaleX(+ (logo:scaleX) 3)
                        scaleY(+ (logo:scaleY) 3)
                    )
                    --state
                )
 = cycles 1  )
            )
            (case 2
                (= seconds 2  )
            )
            (case 3
                ((extra1:
                    init()
                    setCycle(0)
                    setStep(4 4)
                    moveSpeed(0)
                    setMotion(MoveTo 47 162 self)
                )
  )
            )
            (case 4
                ((extra1:dispose()) = cycles 1  )
            )
            (case 5
                (
                (if (> (logo:scaleX) 0)
                    (logo:
                        scaleX(- (logo:scaleX) 3)
                        scaleY(- (logo:scaleY) 3)
                    )
                    --state
                )
 = cycles 1  )
            )
            (case 6
                ((send gSq5Music1:fade(5 10 0 0)) localproc_0641() (logo:dispose()) = local33 1 localproc_0641() (controlBar:init())  )
            )
            (case 7
                ((send gSQ5:handsOff()) 
                (if (== local33 0)
                    = cycles 1
                )(else
                    (self:setScript(doDirections self))
                )
 )
            )
            (case 8
                (localproc_0641() (controlBar:init()) (lines:init()) localproc_089b() = theRegister 0 (grid:init()) (changeGrid:start(1)) (self:setScript(changeGrid self 0)) (changeGrid:start(0)) (ship1:init()) (ship2:init()) (ship3:init()) (ship4:init()) = theShipNum 0 = theShip ship1 (ship1:hide()) (shipSelector:init()) (specialCursor:init()) localproc_0a0a() (nextBut:doVerb(4)) = local33 0  )
            )
            (case 9
                ( )
            )
            (case 10
                ((send gSQ5:handsOff()) localproc_0beb() = local33 3 (shipSelector:dispose()) = cycles 2  )
            )
            (case 11
                ((controlBar:init()) (self:setScript(rogersTurn self))  )
            )
            (case 12
                ((controlBar:init()) (self:setScript(quirksTurn self))  )
            )
            (case 13
                (= cycles 2 = state (- state 3) )
            )
        )
    )

)
(instance gridScaler of Scaler
    (properties)

    (method (doit)
        (var clientY, theBackSize)
        (send client:
            scaleX(= theBackSize (/ (* theBackSize 128) 100))
            scaleY(
                (if (>= (= clientY (send client:y)) backY)
                    = theBackSize backSize
                )(else
                    (if (<= clientY frontY)
                        = theBackSize frontSize
                    )(else
                        = theBackSize (+ (/ (* slopeNum clientY) slopeDen) const)
                    )
                )
)
        )
    )

)
(class ShipScaler of Scaler
    (properties
        client 0
        frontY 190
        backY 0
        frontSize 100
        backSize 0
        slopeNum 0
        slopeDen 0
        const 0
    )

    (method (init theClient)
        = client theClient
    )


    (method (doit)
        (var temp0, temp1, temp2)
        = temp0 (/ (* (grid:scaleX) (+ (* (send client:col) 9) 1)) 128)
        = temp1 (/ (* (grid:scaleX) (+ (* (send client:row) 8) 3)) 128)
        (send client:
            x(+ (+ (grid:x) temp0) 2)
            y(+ (+ (+ (grid:y) temp1) (send client:z)) 1)
            scaleX((grid:scaleX))
            scaleY((grid:scaleX))
        )
    )

)
(instance public rogerTalker of Narrator
    (properties
        talkWidth 100
    )

    (method (init param1)
        = gSq5Win gNewSpeakWindow
        = font gFont
        (send gSq5Win:
            tailX(240)
            xOffset(0)
            tailY(150)
            isBottom(1)
        )
        (super:init(rest param1))
    )


    (method (dispose param1)
        = gSq5Win gSq5Win_2
        (super:dispose(rest param1))
    )

)
(instance public quirkTalker of Talker
    (properties
        x 139
        y 65534
        view 531
        talkWidth 120
    )

    (method (init param1)
        = font gFont
        (quirkHead:
            startUpd()
            hide()
        )
        (switch (global122)
            (case 25
                ((self:
                    loop(0)
                    x(137)
                    y(65534)
                )
 (quirkMouth:
                    loop(3)
                    cel(0)
                    nsLeft(22)
                    nsTop(24)
                )
 = local32 0  )
            )
            (case 3
                ((self:
                    loop(1)
                    x(143)
                    y(65531)
                )
 (quirkMouth:
                    loop(4)
                    cel(0)
                    nsLeft(12)
                    nsTop(30)
                )
 = local32 0  )
            )
            (case 1
                ((self:
                    loop(2)
                    x(134)
                    y(65531)
                )
 (quirkMouth:
                    loop(5)
                    cel(0)
                    nsLeft(18)
                    nsTop(27)
                )
 = local32 0 )
            )
        )
        (send (= gSq5Win gNewSpeakWindow):
            tailX(120)
            xOffset(65511)
            tailY(40)
            isBottom(0)
        )
        (super:init(0 0 quirkMouth rest param1))
    )


    (method (dispose param1)
        = gSq5Win gSq5Win_2
        (quirkHead:show())
        (super:dispose(rest param1))
    )

)
(instance quirkMouth of Prop
    (properties
        view 531
        loop 3
    )
)
(instance public dTalker of Narrator
    (properties
        y 90
        talkWidth 160
        color 15
        back 0
    )

    (method (init param1)
        = gSq5Win (SysWindow:new())
        (self:font(gFont))
        (super:init(rest param1))
    )


    (method (dispose param1)
        (if (gSq5Win)
            (send gSq5Win:dispose())
        )
        = gSq5Win gSq5Win_2
        (super:dispose(rest param1))
    )

)
(instance cheat1f of Feature
    (properties
        nsTop 105
        nsLeft 31
        nsBottom 110
        nsRight 53
    )

    (method (doVerb param1)
        (asm
            lsp     param1
            ldi     1
            eq?     
            bnt     code_32dd
            lsl     local31
            ldi     3
            eq?     
            bnt     code_32dd
            lsl     local32
            ldi     0
            eq?     
            bnt     code_32dd
            +al     local25
            push    
            ldi     3
            mod     
            sal     local25
            pushi   4
            push    
            lal     local26
            add     
            eq?     
            bnt     code_32dd
            pushi   0
            call    localproc_0b8c, 0
code_32dd:  ret     
        )
    )

)
(instance cheat2f of Feature
    (properties
        nsTop 105
        nsLeft 266
        nsBottom 110
        nsRight 289
    )

    (method (doVerb param1)
        (asm
            lsp     param1
            ldi     1
            eq?     
            bnt     code_330c
            lsl     local31
            ldi     3
            eq?     
            bnt     code_330c
            lsl     local32
            ldi     0
            eq?     
            bnt     code_330c
            +al     local26
            push    
            ldi     3
            mod     
            sal     local26
            pushi   4
            lsl     local25
            add     
            eq?     
            bnt     code_330c
            pushi   0
            call    localproc_0b8c, 0
code_330c:  ret     
        )
    )

)
