(include "sci.sh")
(use "Main")
(use "Inset")
(use "View")
(use "Obj")
(script 2000)


(local
    local0
    local1
    local2 = 10

)
(procedure (localproc_0036)
    (var temp0, temp1)
    (if (> 0 (= temp0 (- gPEventX (+ 5 (punchCard:x)))))
        return -1
    )
    (if (> (/ temp0 20) 2)
        return -1
    )
    = temp1 (/ temp0 20)
    (if (> 0 (= temp0 (- gPEventY (+ 5 (punchCard:y)))))
        return -1
    )
    (if (> (/ temp0 15) 2)
        return -1
    )
    return + (* (= temp0 (/ temp0 15)) 3) temp1
)


(procedure (localproc_0097 param1)
    = local1 (% param1 3)
    return + (+ 5 (punchCard:x)) (* (% param1 3) 20)
)


(procedure (localproc_00b4 param1)
    = local0 (/ param1 3)
    return + (+ 5 (punchCard:y)) (* (/ param1 3) 15)
)


(procedure (localproc_00ff)
    (var temp0)
    = temp0 0
    (while (< temp0 9)
        (if (& global129 (<< $0001 temp0))
            DrawCel(616 1 1 localproc_0097(temp0) localproc_01b4(temp0) 15)
        )
        ++temp0
    )
    Graph(12 + 5 (punchCard:y) + 5 (punchCard:x) + (+ 5 (punchCard:y)) 45 + (+ 5 (punchCard:x)) 60 1)
)


(procedure (localproc_0171 param1)
    = global129 (| global129 (<< $0001 param1))
    localproc_00ff()
)


(instance public punchCardInit of Code
    (properties)

    (method (doit)
        (if (not (send gRoom:inset()))
            (send gRoom:setInset(punchCard hl))
        )
    )

)
(instance punchCard of Inset
    (properties
        view 616
        x 110
        y 55
        priority 13
    )

    (method (init param1)
        (send gUser:
            canControl(0)
            canInput(0)
        )
        (super:init(rest param1))
        proc0_10(238 5)
        (hl:init())
        (theExit:init())
    )


    (method (doit param1)
        (if (GameIsRestarting())
            localproc_00ff()
            (if (oldCast)
                (send oldCast:eachElementDo(300))
            )
        )
        (super:doit(rest param1))
    )


    (method (dispose param1)
        (send gUser:
            canControl(1)
            canInput(1)
        )
        (super:dispose(rest param1))
    )


    (method (doVerb param1)
        (var temp0)
        (switch (param1)
            (case 33
                (
                (if (<> (= temp0 localproc_0036()) -1)
                    localproc_0171(temp0)
                )
 )
            )
        )
    )

)
(instance hl of Prop
    (properties
        x 110
        y 55
        view 616
        loop 2
        priority 14
        signal 16400
    )

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


    (method (doit param1)
        (var temp0)
        (if (< local2 1)
            (if (not local2)
                = local2 -1
                localproc_00ff()
                (send gUser:
                    canControl(1)
                    canInput(1)
                )
                (send gSQ5:setCursor((send ((send gSq5IconBar:curIcon)):cursor)))
            )
        )(else
            --local2
        )
        (if (<> (= temp0 localproc_0036()) -1)
            (self:
                x(localproc_0097(temp0))
                y(localproc_00b4(temp0))
            )
            (if (& global129 (<< $0001 temp0))
                (self:cel(1))
            )(else
                (self:cel(0))
            )
        )
        (super:doit(rest param1))
    )


    (method (cue)
        UnLoad(128 616)
        DisposeScript(2000)
    )

)
(instance theExit of View
    (properties
        x 146
        y 108
        view 616
        loop 3
        priority 14
        signal 16401
    )

    (method (doVerb)
        (var temp0)
        (punchCard:dispose())
    )

)
