home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Palm / Tetris / Source / FreeTris11.txt < prev   
Text File  |  2001-12-04  |  30KB  |  1,651 lines

  1. \ STris  Main 11/17/01 9:33 CJS
  2. \ 65 k  
  3.  
  4. include STris-Variables
  5. include STris-Setup
  6. include STris-Num2Lab
  7. include STris-Height
  8. include STris-Startup
  9. include STris-Color
  10. include STris-Config
  11. include STris-Sound
  12. include STris-Score
  13. include STris-BitMap
  14. include STris-Blocks
  15. include STris-Rows
  16. include STris-Move
  17. include STris-Rotate
  18. include STris-HighS
  19. include STris-Main2 
  20.  
  21. .( Main...) cr
  22.  
  23. : (MenuItem)
  24.     on: QuitID do:  bye
  25.     on: AboutID do: ShowAbout
  26.     on: NGameID do: Startup
  27.     on: SettingsID do: ShowPref 
  28.     on: HowID do: ShowHelp
  29.     on: HSMenuID 
  30.         do: ShowHighScores
  31.     ;
  32. : MenuItem ( -- )
  33.     event >abs itemid
  34.     (MenuItem) drop 
  35.     ;
  36. : dispatch-event  ( ekey -- ekey )
  37.     on: menuEvent do: MenuItem
  38.        on: penDownEvent do: PDown
  39.     ;
  40. : CleanUp ( -- )
  41.     UnlockKeys
  42.     >State
  43.     UnlockHandles
  44.     ;
  45. : LauncherMode ( -- )
  46.     event >abs itemid
  47.     StartButton = if
  48.         Setup
  49.     then
  50.     ;
  51. : NormalPlayMode ( -- )
  52.     TimeOut
  53.     KeyWait @
  54.     KeySpeed @
  55.     >  if
  56.         KeyPress
  57.     else
  58.         KeyWait @ 1+
  59.         KeyWait !
  60.     then
  61.     ;
  62. : GameEndingMode ( -- )
  63.     4 GameState !
  64.     OverID PopupForm
  65.     UpdateStats
  66.     2000 MS
  67.     UnlockKeys
  68.     ;
  69. : GameOverMode ( -- )
  70.     event >abs itemid
  71.     GmOvrOK = if
  72.         score @ bonus @ + high? if
  73.             GetName
  74.         else
  75.             Startup
  76.         then
  77.         drop
  78.     then
  79.     ;
  80. : OptionsMode ( -- )
  81.     event >abs itemid
  82.     OptOK = if
  83.         OptReturn
  84.     then
  85.     ;
  86. : HSMode ( -- )
  87.     event >abs itemid
  88.     HSOK = if 
  89.         HSReturn
  90.     then
  91.     ;
  92. : EnterNameMode ( -- )
  93.     event >abs itemid
  94.     NameOK = if 
  95.         NameReturn
  96.         Startup
  97.         ShowHighScores
  98.     then
  99.     ;
  100. : ModeControl
  101.     on: 2 do: NormalPlayMode
  102.     on: 0 do: LauncherMode
  103.     on: 3 do: GameEndingMode
  104.     on: 4 do: GameOverMode
  105.     on: 5 do: OptionsMode
  106.     on: 6 do: HSMode
  107.     on: 7 do: EnterNameMode
  108.     ;
  109. : (Restore)
  110.     (Setup)
  111.     State> drop
  112.     UpdateScore
  113.     DrawNextBlock
  114.     PauseIt
  115.     ;
  116. : [Restore]
  117.     on: 0 do: Startup
  118.     on: 1 or: 2  do: (Restore)
  119.     on: 3 or: 4 or: 5 or: 6 or: 8  
  120.     do: Startup
  121.     ;
  122. : Restore ( -- )
  123.     State> 0= if 
  124.         Startup
  125.     else 
  126.         GameState @ 
  127.          [Restore] drop
  128.     then
  129.     ;
  130. : go ( -- )
  131.     LockHandles
  132.      3.0-features? if
  133.         GetConfig
  134.         GetHS
  135.         ConfigColor
  136.     then
  137.     6000 ShowForm
  138.     0 Begin 1+ 
  139.         dup 7 >
  140.         ekey
  141.         penDownEvent = 
  142.      or Until drop
  143.     Restore
  144.     begin
  145.         1 0 ['] (ekey) catch
  146.         ByeThrow  = if 
  147.             CleanUp
  148.             (bye)
  149.         then
  150.         dispatch-event drop
  151.         GameState @ 
  152.         ModeControl drop
  153.     again 
  154.     ;
  155.  
  156. \ STris-Main2
  157.  
  158. (ID) MXTs (ID) rsrc use-resources
  159.  
  160. : ScreenComponents ( -- )
  161.     152 102 4 43 0
  162.     rounded-rectangle
  163.      150 100 5 44 0
  164.     erase-rounded-rectangle
  165.     39 0 39 42 line  81 0 81 42 line
  166.     96 0 96 42 line  117 0 117 42 line
  167.     ;
  168. : PauseIt ( -- ) 
  169.     1 GameState !
  170.     ScreenComponents
  171.     7 5 AT-XY 
  172.     ." Paused... "
  173.     5 8 AT-XY 
  174.     ." < Tap to Resume >"
  175.     4 12 AT-XY
  176.     ." Version 1.1"
  177.     ;
  178. : Unpause ( -- )
  179.     2 GameState !
  180.     ReDraw
  181.     DrawBlock
  182.     ;
  183. : PDown ( -- )
  184.     GameState @ dup
  185.     1 = if  Unpause then 
  186.     2 = if PauseIt then
  187.     ;
  188. : (KeyPress) ( Addr --  )
  189.     @
  190.     on: 0 do: BLeft 
  191.     on: 1 do: BRight 
  192.     on:  2 do:  PDown 
  193.     on:  3 do: BDown 
  194.     on: 4 do: RotateLeft
  195.     on: 5 do: RotateRight
  196.     ;
  197. : KeyPress ( -- )
  198.         KeyCurrentState
  199.     2dup 8. Dand  8. D= if 
  200.         KeyA (KeyPress) drop
  201.     then
  202.      2dup 16. Dand 16. D= if  
  203.         KeyB (KeyPress) drop
  204.     then
  205.      2dup 32. Dand
  206.     32. D= if 
  207.         KeyC (KeyPress) drop
  208.     then
  209.      2dup 64. Dand 64. D= if 
  210.         KeyD  (KeyPress) drop
  211.     then
  212.      2dup 4. Dand 4. D= if  
  213.         KeyDn (KeyPress)  drop
  214.     then
  215.     2. Dand 2.   D= if  
  216.         KeyUp (KeyPress) drop
  217.     then
  218.     ;
  219. : Startup ( -- )
  220.     Page ." Starting . "
  221.     UnlockKeys 
  222.     StartFormID PopupForm
  223.     0 Level ! 0 BaseLevel !
  224.     0 GameState !
  225.     ;
  226. : (Setup) ( -- )
  227.     Page
  228.     InitializeVariables
  229.     SetupShapes
  230.     2 GameState !
  231.     FormID PopupForm
  232.     LockKeys
  233.     ScreenComponents
  234.     ShowTime
  235.     ;
  236. : Setup ( -- )
  237.     ClearBoard
  238.     ClearBuffer
  239.     ClearCBuffer
  240.     ClearShapes
  241.     LevelSetup
  242.     HeightSetup
  243.     (Setup)
  244.     RandomNext
  245.     Next>Current
  246.     0 Score!
  247.     5  BlockY ! 3 BlockX !
  248.     ReDraw
  249.     DrawBlock
  250.     DrawNextBlock
  251.     ;
  252. : ShowAbout ( -- )
  253.     UnlockKeys
  254.     AlertID FrmAlert drop
  255.     LockKeys
  256.     ;
  257. : ShowHelp ( -- )
  258.     UnlockKeys
  259.     How$ID FrmHelp
  260.     LockKeys
  261.     ;
  262.  
  263. \ STris-Variables 11/16/01 8:46 CJS
  264. .( ids...sarrary.... ) cr
  265. needs ids
  266. needs sarray  \ ⌐Robert L. Ryan
  267. .( Variables... )
  268. 3000 constant FormID
  269. 3001 constant AlertID
  270. 3002 constant OverID
  271. 3003 constant StartFormID
  272. 3004 constant OptFormID
  273. 3005 constant HSFormID
  274. 3006 constant NameFormID
  275. 3041 constant AboutID
  276. 3042 constant NGameID
  277. 3043 constant QuitID
  278. 3044 constant SettingsID
  279. 3045 constant HowID
  280. 3046 constant HSMenuID
  281. 3101 constant How$ID
  282. 3203 constant ScoreLbID
  283. 3301 constant GmOvrOK
  284. 3302 constant StartButton
  285. 3379 constant HSOK
  286. 3380 constant OptOK
  287. 3381 constant NameOK
  288. 3401 constant NameField
  289. -257 constant ByeThrow
  290.  
  291. here constant state-base
  292.     variable BlockX
  293.     variable BlockY
  294.     variable NextBlock
  295.     variable BlockSpeed
  296.     variable WaitCount
  297.     variable Score
  298.     variable Level
  299.     variable Bonus
  300.     variable BaseLevel
  301.     variable RMode
  302.     variable GameState
  303.     variable vTet
  304.     variable vTri
  305.     variable vDou
  306.     variable vSin
  307.     variable vLin
  308.     28 4 1 cells matrix Shapes{{
  309.     4 4 1 cells matrix BlockBuffer{{
  310.     4 4 1 cells matrix BlockCBuffer{{
  311.     20 10 1 cells matrix Board{{
  312. here state-base - constant state-size
  313. variable StatePtr State-size StatePtr !
  314.  
  315. variable KeySpeed
  316. variable KeyWait
  317. variable Svol 32 Svol !
  318.  
  319. here constant prefs-base
  320.     variable VolumeP
  321.     variable SensitiveP
  322.     variable KeyA
  323.     variable KeyB
  324.     variable KeyC
  325.     variable KeyD
  326.     variable KeyUp
  327.     variable KeyDn
  328.     variable bw
  329.     variable DelayNext
  330.     variable Flat
  331. here prefs-base - constant prefs-size
  332. variable SizePtr prefs-size SizePtr !
  333.  
  334. variable LastMode
  335. variable LabelString
  336. variable PrefLabel
  337.  
  338. create LblTxtBufferV 20 chars allot
  339. create LblTxtBufferS 20 chars allot
  340. create LblTxtBuffer1 20 chars allot
  341. create LblTxtBuffer2 20 chars allot
  342. create LblTxtBuffer3 20 chars allot
  343. create LblTxtBuffer4 20 chars allot
  344. create LblTxtBufferU 20 chars allot
  345. create LblTxtBufferD 20 chars allot
  346.  
  347. create TxtBuffer 10 chars allot
  348. variable StatNum
  349. variable StatLabel
  350.  
  351. 2variable RocketPtr
  352.  
  353. 2variable Block1Ptr
  354. 2variable Block2Ptr
  355. 2variable Block3Ptr
  356. 2variable Block4Ptr
  357. 2variable Block5Ptr
  358. 2variable Block6Ptr
  359. 2variable Block7Ptr
  360. 2variable Block8Ptr
  361.  
  362. ID Tbmp
  363.  
  364. variable BlkOffSet
  365.  variable LoopX
  366.  variable LoopY
  367.  
  368. variable BlocksFound
  369. variable RowsCleared
  370. variable BombsFound
  371.  
  372. variable Can?
  373. variable YMove
  374. variable XMove
  375.  
  376. here constant HS-base
  377.     10 22 chars  array Names{
  378.     10 1 cells array Scores{
  379. here HS-base - constant HS-size
  380. variable HSPtr HS-size HSPtr !
  381. create NameBuffer 21 chars allot
  382.  
  383. variable StartY
  384. 2variable OldKeyMask
  385.  
  386. \ STris-Setup 9/26/01 13:27 CJS
  387. \ Copyright 2001 ⌐
  388. \ Christopher J. Smith
  389. .( Standard Libs... ) cr
  390.  
  391. .( . ) needs facility
  392. .( . ) needs facility-ext
  393. .( . ) needs resources
  394. .( . ) needs Events
  395. .( . ) needs Forms 
  396. .( . )  needs ids
  397. .( . )  needs graphics
  398. .( . )  needs double
  399. .( . )  needs random
  400. .( . )  needs sound
  401. .( . )  needs music
  402. .( . )  needs zstrings
  403. .( . )   needs color
  404. .( . )  needs ver
  405. .( Extended Librarys... ) cr
  406. .( . )  needs color35
  407. .( . )  needs UIColor
  408. .( . )  needs Double-Tools 
  409. .( . )  needs ondo  \ ⌐Kristopher Johnson
  410. .( . )  needs sarray  \ ⌐Robert L. Ryan
  411. cr .( SetUp... )   cr
  412. : ShowTime
  413.     0 13 AT-XY
  414.     TIME&DATE 2drop drop
  415.     .     ." :"  
  416.     dup 10 < if ." 0" then
  417.       .    drop ."    "
  418.     ;
  419. : LockKeys ( -- )
  420.     126 s>d Dinvert 
  421.     KeySetMask
  422.     OldKeyMask  2!
  423.     ;
  424. : UnlockKeys ( -- )
  425.     OldKeyMask 2@  KeySetMask
  426.     2drop
  427.     ;
  428. : >State ( -- )
  429.     false state-size
  430.     state-base >abs 1 1
  431.     [id] MxTs
  432.     PrefSetAppPreferences
  433.     ;
  434. : State> ( -- f )
  435.     false stateptr >abs
  436.     state-base >abs
  437.     1 [id] MxTs
  438.     PrefGetAppPreferences
  439.     1 =
  440.     ;
  441. : InitializeVariables
  442.     5  BlockY ! 3 BlockX !
  443.     180 BlockSpeed ! 0 WaitCount !
  444.     0 KeyWait !
  445.     0 Score ! 0 Bonus !
  446.     2 GameState !
  447.     0 vTet ! 0 vTri ! 0 vDou ! 0 vSin !
  448.     0 vLin !
  449.     ;
  450. : shuffle
  451.  ( x1 x2 x3 x4 -- x4 x3 x1 x2 )
  452.     swap 2swap
  453.     ;
  454. : ClearBoard ( -- )
  455.     20 Begin 1-
  456.         10 Begin 1- 
  457.             2dup
  458.              Board{{ 0 shuffle  }}  !
  459.         dup 0 = until drop
  460.     dup 0 = until drop
  461.     ;
  462. : ClearBuffer ( -- )
  463.     4 Begin 1-
  464.         4 Begin 1- 
  465.             2dup BlockBuffer{{ 
  466.             0 shuffle  }}  !
  467.         dup 0 = until drop
  468.     dup 0 = until drop
  469.     ;
  470. : ClearCBuffer ( -- )
  471.     4 Begin 1-
  472.         4 Begin 1- 
  473.             2dup BlockCBuffer{{ 
  474.             0 shuffle  }}  !
  475.         dup 0 = until drop
  476.     dup 0 = until drop
  477.     ;
  478. : ClearShapes ( -- )
  479.     28 Begin 1-
  480.         4 Begin 1- 
  481.             2dup Shapes{{ 
  482.             0 shuffle  }}  !
  483.         dup 0 = until drop
  484.     dup 0 = until drop
  485.     ;
  486. : SetupShapes ( -- )
  487. \ Tetris
  488.     Flat @ 0= if
  489. 3    dup Shapes{{  0 1 }} !
  490.     dup Shapes{{ 1 1 }} !
  491.     dup Shapes{{ 2 1 }} !
  492.     Shapes{{ 3 1 }} !
  493. else
  494. 3    dup Shapes{{  1 0 }} !
  495.     dup Shapes{{ 1 1 }} !
  496.     dup Shapes{{ 1 2 }} !
  497.     Shapes{{ 1 3 }} !
  498. then
  499. \ 'T' Shape
  500. 1    dup Shapes{{ 4 1 }} !
  501.     dup Shapes{{ 5 0 }} !
  502.     dup Shapes{{ 5 1 }} !
  503.     Shapes{{ 5 2 }} !
  504. \ Square
  505. 4    dup Shapes{{ 9 1 }} !
  506.     dup Shapes{{ 9 2 }} !
  507.     dup Shapes{{ 10 1 }} !
  508.     Shapes{{ 10 2 }} !
  509. \ 'L' Shape
  510. 2    dup Shapes{{ 13 0 }} !
  511.     dup Shapes{{ 13 1 }} !
  512.     dup Shapes{{ 13 2 }} !
  513.     Shapes{{ 14 0 }} !
  514. \ Backwards 'L'
  515. 7    dup Shapes{{ 17 0 }} !
  516.     dup Shapes{{ 17 1 }} !
  517.     dup Shapes{{ 17 2 }} !
  518.     Shapes{{ 18 2 }} !
  519. \ Backwards  'S'
  520. 5     dup Shapes{{ 20 0 }} !
  521.     dup Shapes{{ 20 1 }} !
  522.     dup Shapes{{ 21 1 }} !
  523.     Shapes{{ 21 2 }} !
  524. \ Forwards 'S'
  525. 6    dup Shapes{{ 24 1 }} !
  526.     dup Shapes{{ 24 2 }} !
  527.     dup Shapes{{ 25 0 }} !
  528.     Shapes{{ 25 1 }} !
  529.     ;
  530.  
  531. \ STris-Num2Lab 10/10/01 14:47 CJS
  532. \ Copyright 2001 ⌐
  533. \ Christopher J. Smith
  534.  
  535. .( STris-Num2Lab... )
  536.  
  537. : CreateTxt ( # -- c-addr u )
  538.     TxtBuffer 0
  539.     StatNum @ 0 <# #s #> append
  540.     z" " 1+ append 
  541.     ;
  542.  
  543. : Stat ( ID #  -- )
  544.     StatNum !
  545.     StatLabel !
  546.     StatLabel @ GetObjectIndex
  547.     FrmGetActiveForm
  548.     FrmHideObject
  549.     CreateTxt drop >abs
  550.     StatLabel @
  551.     SetLabel
  552.     StatLabel @  GetObjectIndex
  553.     FrmGetActiveForm
  554.     FrmShowObject
  555.     ;
  556. : UpdateStats ( -- )
  557.     3242 vTet @ Stat
  558.     3243 vTri @ Stat
  559.     3244 vDou @ Stat
  560.     3245 vSin @ Stat
  561.     3246 vLin @ Stat
  562.     3248 Level @ Stat
  563.     3206 Score @ Bonus @ + Stat
  564.     ;
  565.  
  566.  
  567. \ STris-Height 10/11/01 15:02 CJS
  568. \ Copyright 2001 ⌐
  569. \ Christopher J. Smith
  570.  
  571. .( STris-Height... )
  572.  
  573. : Brick? ( -- 0|8 ) rand 2 mod 8 * ;
  574. : FillRow ( Row# -- )
  575.     1-
  576.     Begin 1+
  577.     10 Begin 1- 
  578.         2dup
  579.          Board{{ Brick? shuffle  }}  !
  580.     dup 0 = until drop
  581.     dup 19 = until drop
  582.     ;
  583.         
  584.  
  585. \ STris-Startup 10/10/01 10:13 CJS
  586. \ Copyright 2001 ⌐
  587. \ Christopher J. Smith
  588.  
  589. .( STris-Startup... )
  590.  
  591. : Level? ( Flag Level -- )
  592.     swap if 
  593.         dup
  594.         BaseLevel ! Level !
  595.     else
  596.         drop
  597.     then
  598.     ;
  599. : LevelSetup ( -- )
  600.     -1 Begin 1+
  601.         dup dup 3350 +
  602.         GetControlValue 
  603.         swap Level?
  604.     dup 9 = Until drop
  605.     ;
  606. : Scramble? ( Flag Row -- )
  607.     swap if FillRow
  608.     else drop
  609.     then
  610.     ;
  611. : HeightSetup ( -- )
  612.     -1 Begin 1+
  613.         dup dup 3361 +
  614.         GetControlValue 
  615.         swap 18 swap - Scramble?
  616.     dup 8 = Until drop
  617.     ;
  618.  
  619. \ STris-Color 11/8/01 11:27 CJS
  620. .( STris-Color... )
  621. variable CurrentDepth
  622. variable TempDepth
  623. variable MaxDepth 
  624. 2variable black
  625. 2variable white
  626. 2variable blue
  627.  
  628. : SetColors
  629.     3.5-features? if
  630.         Black >abs WinRGBToIndex 
  631.         WinSetForeColor
  632.         drop
  633.         white >abs WinRGBToIndex 
  634.         WinSetBackColor
  635.         drop
  636.         Black >abs WinRGBToIndex 
  637.         WinSetTextColor
  638.         drop
  639.     else
  640.         Black 2@ foreground
  641.         White 2@  background
  642.     then
  643.     ;
  644. : Check
  645.     0= if
  646.         TempDepth @
  647.         CurrentDepth !
  648.         CurrentDepth @
  649.         MaxDepth @ >  if
  650.             CurrentDepth @
  651.             MaxDepth !
  652.         then
  653.     else
  654.         drop
  655.     then
  656.     ;
  657. : SetTemp
  658.     dup TempDepth ! 
  659.     ;
  660. : Depth ( depth -- )
  661.     SetTemp  ['] color-depth catch
  662.     Check
  663.     ;
  664. : SetUITable ( -- )
  665.     3.5-features? if
  666.         Blue >abs 
  667.         UIObjectFrame
  668.         UIColorSetTableEntry drop
  669.         Black >abs 
  670.         UIObjectForeground
  671.         UIColorSetTableEntry drop
  672.         Blue >abs 
  673.         UIFormFrame
  674.         UIColorSetTableEntry drop
  675.         white >abs  
  676.         UIFormFill
  677.         UIColorSetTableEntry drop
  678.         blue >abs  
  679.         UIDialogFrame
  680.         UIColorSetTableEntry drop
  681.         white >abs  
  682.         UIDialogFill
  683.         UIColorSetTableEntry drop
  684.         blue >abs  
  685.         UIAlertFrame 
  686.         UIColorSetTableEntry drop
  687.         white >abs  
  688.         UIAlertFill 
  689.         UIColorSetTableEntry drop
  690.         black >abs  
  691.         UIMenuFrame
  692.         UIColorSetTableEntry drop
  693.         white >abs  
  694.         UIMenuFill
  695.         UIColorSetTableEntry drop
  696.         black >abs  
  697.         UIMenuForeground
  698.         UIColorSetTableEntry drop
  699.         blue >abs  
  700.         UIMenuSelectedFill
  701.         UIColorSetTableEntry drop
  702.         white >abs  
  703.         UIMenuSelectedForeground
  704.         UIColorSetTableEntry drop
  705.     then
  706.     ;
  707. : ConfigColor ( -- )
  708.     (hex) 0. black 2!
  709.     (hex) FFFFFF. white  2!
  710.     (hex) 0000FF. blue 2!
  711.     1 MaxDepth !
  712.     1 depth
  713.     bw @ 0=  if
  714.         2 depth  4 depth  8 depth
  715.         SetUITable
  716.         SetColors
  717.     then
  718.     ;
  719.  
  720. \ STris-Config 10/15/01 10:33 CJS
  721. \ Copyright 2001 ⌐
  722. \ Christopher J. Smith
  723.  
  724. .( STris-Config... )
  725.  
  726. : >prefs ( -- )
  727.     false Prefs-Size
  728.     Prefs-base >abs 1 0
  729.     [id] MxTs
  730.     PrefSetAppPreferences
  731.     ;
  732. : prefs> ( -- f )
  733.     false SizePtr >abs 
  734.     Prefs-base  >abs
  735.     0 [id] MxTs
  736.     PrefGetAppPreferences
  737.     1 =
  738.     ;
  739. : HideControl ( ID -- )
  740.     GetObjectIndex
  741.     FrmGetActiveForm
  742.     FrmHideObject
  743. ;
  744. : ShowControl ( ID -- )
  745.     GetObjectIndex
  746.     FrmGetActiveForm
  747.     FrmShowObject
  748. ;
  749. : Volume@ ( -- volumeP )
  750.     VolumeP @ 
  751.     ;
  752. : Volume! ( volume -- )
  753.     dup 0 = if 0 Svol ! then
  754.     dup 1 = if 16 Svol ! then
  755.     dup 2 = if 32 Svol ! then
  756.     dup 3 = if 64 Svol ! then
  757.     VolumeP !
  758.     ;
  759. : Sensitive@ ( --  KeySpdP )
  760.     SensitiveP @
  761.     ;
  762. : Sensitive! ( KeySpdP -- )
  763.     dup 0 = if 22 KeySpeed ! then
  764.     dup 1 = if 18 KeySpeed ! then
  765.     dup 2 = if 14 KeySpeed ! then
  766.     dup 3 = if 10 KeySpeed ! then
  767.     dup 4 = if 6 KeySpeed ! then
  768.     SensitiveP !
  769.     ;
  770. : GetConfig ( -- )
  771.     prefs> 0=  if
  772.         1 Volume! 1 Sensitive!
  773.         0 KeyA ! 1 KeyB ! 4 KeyC ! 
  774.         5 KeyD ! 2 KeyUp ! 
  775.         3 KeyDn ! false bw !
  776.         false DelayNext !
  777.         false Flat !
  778.     then
  779.     SensitiveP @ Sensitive!
  780.     VolumeP @ Volume!
  781.     ;
  782. : IdListSet 
  783.     GetObjectPtr LstSetSelection ;
  784. : IdListGetText
  785.     GetObjectPtr
  786.     LstGetSelectionText
  787.     >rel 20 append drop >abs
  788.      ;
  789. : SetUpPrefsForm ( -- )
  790.     Volume@ 3636 IdListSet 
  791.     LblTxtBufferV 0 Volume@
  792.     3636  IdListGetText
  793.     3370 SetLabel
  794.  
  795.     Sensitive@ 3637 IdListSet 
  796.     LblTxtBufferS 0 Sensitive@
  797.     3637  IdListGetText
  798.     3371 SetLabel
  799.  
  800.     KeyA @ 3638 IdListSet 
  801.     LblTxtBuffer1 0 KeyA @
  802.     3638  IdListGetText
  803.     3372 SetLabel
  804.  
  805.     KeyB @ 3639 IdListSet 
  806.     LblTxtBuffer2 0 KeyB @
  807.     3639  IdListGetText
  808.     3373 SetLabel
  809.  
  810.     KeyC @ 3640 IdListSet 
  811.     LblTxtBuffer3 0 KeyC @
  812.     3640  IdListGetText
  813.     3374 SetLabel
  814.  
  815.     KeyD @ 3641 IdListSet 
  816.     LblTxtBuffer4 0 KeyD @
  817.     3641  IdListGetText
  818.     3375 SetLabel
  819.  
  820.     KeyUp @ 3642 IdListSet 
  821.     LblTxtBufferU 0 KeyUp @
  822.     3642  IdListGetText
  823.     3376 SetLabel
  824.  
  825.     KeyDn @ 3643 IdListSet 
  826.     LblTxtBufferD 0 KeyDn @
  827.     3643  IdListGetText
  828.     3377 SetLabel
  829.  
  830.     bw @ 3378 GetObjectPtr
  831.     CtlSetValue
  832.     DelayNext  @
  833.     3382 GetObjectPtr
  834.     CtlSetValue
  835.     Flat @ 3383 GetObjectPtr
  836.     CtlSetValue
  837.     ;
  838. : IdGetList ( ID -- Value )
  839.     GetObjectPtr
  840.     LstGetSelection ;
  841. : IdGetCtl ( ID -- value )
  842.     GetObjectPtr
  843.     CtlGetValue ;
  844. : StorePrefs ( -- )
  845.     3636 IdGetList Volume! 
  846.     3637 IdGetList Sensitive!
  847.     3638 IdGetList KeyA !
  848.     3639 IdGetList KeyB !
  849.     3640 IdGetList KeyC !
  850.     3641 IdGetList KeyD !
  851.     3642 IdGetList KeyUp !
  852.     3643 IdGetList KeyDn !
  853.     3378 IdGetCtl bw !
  854.     3382 IdGetCtl DelayNext !
  855.     3383  IdGetCtl Flat !
  856.     >Prefs
  857.     ;
  858. : ShowPref ( -- )
  859.     UnlockKeys
  860.     GameState @ LastMode !
  861.     5 GameState !
  862.     OptFormID PopupForm
  863.     SetUpPrefsForm
  864.     ;
  865. : OptReturn ( -- )
  866.     LastMode @ dup GameState !
  867.     StorePrefs
  868.     ClearShapes
  869.     SetupShapes
  870.     0 = if
  871.         StartFormID 
  872.         FrmReturnToForm
  873.     else
  874.         LockKeys
  875.         FormID
  876.         FrmReturnToForm
  877.     then
  878.     ;
  879.  
  880. \ STris-Sound 11/8/01 15:16 CJS
  881. .( STris-Sound... )
  882. needs sound
  883.  
  884. : tick ( -- )
  885.     Svol @ 5 262 sound ;
  886. : woop ( -- )
  887.     Svol @
  888.     494 Begin 32 -
  889.         2dup 1 swap sound
  890.     dup 294 < until drop
  891.     drop
  892.     ;
  893. : Tetris! ( -- )
  894.     Svol @ v
  895.     1 o sixteenth 2 o c e d f e g f
  896.     ;
  897. : bell ( -- )
  898.     Svol @
  899.     2801 Begin 200 +
  900.         2dup 1 swap sound
  901.     dup 3600 > Until drop
  902.     drop \ drop the 10...
  903.     ;
  904.  
  905. \ STris-Score 10/5/01 9:20 CJS
  906. \ Copyright 2001 ⌐
  907. \ Christopher J. Smith
  908. .( STris-Score... )
  909. : Level>Speed 
  910.         ( Level -- Level Speed )
  911.     on: 0 do: 180
  912.     on: 1 do: 160
  913.     on: 2 do: 140
  914.     on: 3 do: 120
  915.     on: 4 do: 100
  916.     on: 5 do: 80
  917.     on: 6 do: 60
  918.     on: 7 do: 40
  919.     on: 8 do: 30
  920.     on: 9 do: 25
  921.     on: 10 do: 22
  922.     on: 11 do: 20
  923.     on: 12 do: 18
  924.     on: 13 do: 17
  925.     on: 14 do: 16
  926.     on: 15 do: 15
  927.     on: 16 do: 14
  928.     on: 17 do: 13
  929.     on: 18 do: 12
  930.     on: 19 do: 11
  931.     on: 20 do: 10
  932.     on: 21 do:  9
  933.     on: 22 do: 8
  934.     on: 23 do: 7
  935.     on: 24 do: 6
  936.     on: 25 do: 5
  937.     on: 26 do: 4
  938.     on: 27 do: 3
  939.     on: 28 do: 2
  940.     on: 29 do: 1
  941.     ;
  942. : EraseRocket ( -- )
  943.     143 15 17 145 0
  944.     erase-rounded-rectangle
  945.     ;
  946. : DrawRocket ( -- )
  947.     148  9  Level @  * - 148
  948.     RocketPtr 2@ 
  949.     WinDrawBitmap 
  950.     ;
  951. : UpdateScore ( -- )
  952.     ScoreLbID Score @ 
  953.     Bonus @ + Stat
  954.     ;
  955.  
  956. : Score! ( # -- )
  957.     Score @ + Score ! 
  958.     UpdateScore
  959.     EraseRocket
  960.     Score @ 100 / BaseLevel @ +
  961.     dup 29 > if drop 29 then
  962.     Level !
  963.     DrawRocket
  964.     Level  @ Level>Speed
  965.     swap drop 
  966.     BlockSpeed !
  967.     ;
  968. : Rows>Score ( #rows -- )
  969.     dup 1 = if
  970.         10 score! 
  971.         vSin @ 1+ vSin !
  972.     then
  973.     dup 2 = if
  974.         10 score! 
  975.         vDou @ 1+ vDou !
  976.     then
  977.     dup 3 = if 
  978.         20 score!
  979.         vTri @ 1+ vTri !
  980.     then
  981.     4 = if 
  982.         40 score! 
  983.         vTet @ 1+ vTet !
  984.     then
  985.     ;
  986.  
  987. \ STris-BitMap 9/27/01 11:07 CJS
  988. \ Copyright 2001 ⌐
  989. \ Christopher J. Smith
  990.  
  991. .( STris-BitMap... )
  992.  
  993. : Block0  ( y x Block# -- )
  994.     3drop  ;
  995. : Block1  ( y x Block# -- )
  996.     drop Block1Ptr 2@
  997.     WinDrawBitmap ;
  998. : Block2  ( y x Block# -- )
  999.     drop Block2Ptr 2@ 
  1000.     WinDrawBitmap ;
  1001. : Block3  ( y x Block# -- )
  1002.     drop Block3Ptr 2@ 
  1003.     WinDrawBitmap ;
  1004. : Block4 ( y x Block# -- )
  1005.     drop Block4Ptr 2@
  1006.     WinDrawBitmap ;
  1007. : Block5 ( y x Block# -- )
  1008.     drop Block5Ptr 2@ 
  1009.     WinDrawBitmap ;
  1010. : Block6 ( y x Block# -- )
  1011.     drop Block6Ptr 2@ 
  1012.     WinDrawBitmap ;
  1013. : Block7 ( y x Block# -- )
  1014.     drop Block7Ptr 2@ 
  1015.     WinDrawBitmap ;
  1016. : Block9 ( y x Block# -- )
  1017.     drop 10 10 2swap 
  1018.     erase-rectangle ;
  1019. : Block8 ( y x Block# -- )
  1020.     drop Block8Ptr 2@ 
  1021.     WinDrawBitmap 
  1022.     ;
  1023. : DBlock ( y x Block# -- )
  1024.     on: 0 do: Block0
  1025.     on: 1 do: Block1
  1026.     on: 2 do: Block2
  1027.     on: 3 do: Block3
  1028.     on: 4 do: Block4
  1029.     on: 5 do: Block5
  1030.     on: 6 do: Block6
  1031.     on: 7 do: Block7
  1032.     on: 8 do: Block8
  1033.     on: 9 do: Block9
  1034.     ;
  1035. : IdLock
  1036.     Tbmp DmGetResource
  1037.     MemHandleLock ;
  1038. : LockHandles ( -- )
  1039.     3083 IdLock Block1Ptr 2!
  1040.     3084 IdLock Block2Ptr 2!
  1041.     3085 IdLock Block3Ptr 2!
  1042.     3086 IdLock Block4Ptr 2!
  1043.     3087 IdLock Block5Ptr 2!
  1044.     3088 IdLock Block6Ptr 2!
  1045.     3089 IdLock Block7Ptr 2!
  1046.     3090 IdLock Block8Ptr 2!
  1047.     3091 IdLock RocketPtr 2!
  1048.     ;
  1049. : UnlockHandles ( -- )
  1050.     3082 Begin 1+
  1051.         dup Tbmp
  1052.         DmGetResource
  1053.         MemHandleUnlock drop
  1054.     dup 3091 = Until drop
  1055.     ;
  1056.  
  1057. \ STris-Blocks 9/28/01 11:08 CJS
  1058. \ Copyright 2001 ⌐
  1059. \ Christopher J. Smith
  1060. .( STris-Blocks... )
  1061. : (BStore)  ( y x block# -- )
  1062.     Board{{  2swap  }}  !  
  1063.     ;
  1064. : Block>Board  ( -- )
  1065.     4 Begin 1-
  1066.         4 Begin 1-
  1067.             2dup 2dup 2>r >r >r
  1068.             BlockY @ r> +
  1069.             BlockX @ r> +
  1070.             BlockBuffer{{ 2r> }}
  1071.             @ dup 0 > if
  1072.                 (BStore)
  1073.             else
  1074.                 3drop
  1075.             then
  1076.         dup 0 = until drop
  1077.     dup 0 = until drop
  1078.     ;
  1079. : Block>CBuffer ( Block# -- )
  1080.     1- 4 *  BlkOffSet  !
  1081.     4 Begin 1-
  1082.         4 Begin 1-
  1083.             2dup 2dup 2>r >r >r
  1084.             shapes{{ r>
  1085.             BlkOffSet @ + r> }} @
  1086.             BlockCBuffer{{ 2r> }} !
  1087.         dup 0 = until drop
  1088.     dup 0 = until drop
  1089.     ;
  1090. : DrawNextBlock (  -- )
  1091.     ShowTime
  1092.     NextBlock @ Block>CBuffer
  1093.     4 Begin 1-
  1094.         4 Begin 1-
  1095.             2dup 2dup 2>r >r >r
  1096.             r> 10 * 40 + r> 10 *
  1097.             BlockCBuffer{{ 2r> }}
  1098.             @ dup 0= if 
  1099.                 drop 9 then
  1100.             DBlock
  1101.         dup 0 = until drop
  1102.     dup 0 = until drop
  1103.     ;
  1104. : SetRMode ( Block# -- Block#)
  1105.     2 RMode !
  1106.     dup 1 = if 
  1107.         3 RMode !
  1108.     then
  1109.     dup 3 = if
  1110.         3 RMode !
  1111.     then
  1112.     ;
  1113. : Block>Buffer ( Block# -- )
  1114.     SetRMode
  1115.     1- 4 *  BlkOffSet  !
  1116.     4 Begin 1 -
  1117.         4 Begin 1 -
  1118.             2dup 2dup 2>r >r >r
  1119.             shapes{{ r>
  1120.             BlkOffSet @ + r> }} @
  1121.             BlockBuffer{{ 2r> }} !
  1122.         dup 0 = until drop
  1123.     dup 0 = until drop
  1124.     ;
  1125. : RandomNext ( -- )
  1126.     rand 7 mod 1+ NextBlock ! 
  1127.     ;
  1128. : YStore! ( # -- )
  1129.     dup BlockY ! StartY ! ;
  1130. : Next>Current ( -- )
  1131.     NextBlock @ dup  Block>Buffer
  1132.     dup 1 = if 0 YStore! then
  1133.     dup 2 = if 2 YStore! then
  1134.     dup 3 = if 1 YStore! then
  1135.     dup 4 = if 1 YStore! then
  1136.     dup 5 = if 1 YStore! then
  1137.     dup 6 = if 2 YStore! then
  1138.     7 = if 2 YStore! then
  1139.     3 BlockX !
  1140.     RandomNext 
  1141.     ;
  1142. : DrawBlock (  -- )
  1143.     4 Begin 1-
  1144.         4 Begin 1-
  1145.             2dup 2dup 2>r >r >r
  1146.             5 BlockY @ 10 * +
  1147.             r> 10 * + 40 -
  1148.             44 BlockX @ 10 * +
  1149.             r> 10 * +
  1150.             BlockBuffer{{ 2r> }}
  1151.             @  0 2swap swap 
  1152.             dup 3 > if
  1153.                 swap 2swap 
  1154.                 drop DBlock
  1155.             else
  1156.                 2drop 2drop
  1157.             then
  1158.         dup 0 = until drop
  1159.     dup 0 = until drop
  1160.     ;
  1161. : ClearBlock ( -- )
  1162.     4 Begin 1-
  1163.         4 Begin 1-
  1164.             2dup 2dup 2>r >r >r
  1165.             5 BlockY @ 10 * +
  1166.             r> 10 * + 40 -
  1167.             44 BlockX @ 10 * +
  1168.             r> 10 * +
  1169.             BlockBuffer{{ 2r> }}
  1170.             @  0 2swap swap 
  1171.             dup 3 > if
  1172.                 swap 2swap 
  1173.                 drop dup 0 > if 
  1174.                     drop 9 
  1175.                 then 
  1176.                 DBlock
  1177.             else
  1178.                 2drop 2drop
  1179.             then
  1180.         dup 0 = until drop
  1181.     dup 0 = until drop
  1182.     ;
  1183.  
  1184.  
  1185. \ STris-Rows 10/1/01 8:47 CJS
  1186. \ Copyright 2001 ⌐
  1187. \ Christopher J. Smith
  1188. .( STris-Rows... )
  1189. : ReDraw (  -- )
  1190.     10 Begin 1-
  1191.         19 Begin 1-
  1192.             2dup 2dup
  1193.             LoopY ! LoopX !
  1194.             10 * 35 -
  1195.             swap 10 * 44 +
  1196.             Board{{ LoopY @
  1197.             LoopX @  }} @
  1198.             dup 0 = if
  1199.                 drop 9 then
  1200.             DBlock
  1201.         dup 4 = until drop
  1202.     dup 0 = until drop
  1203.     ;
  1204. : DropRow ( row -- row )
  1205.      dup Begin 1-
  1206.         10 Begin 1-
  1207.             2dup LoopX ! LoopY !
  1208.             Board{{ LoopY @
  1209.             LoopX @  }} @
  1210.             Board{{ 
  1211.             LoopY @ 1+
  1212.             LoopX @  }}  !
  1213.         dup 0 = until drop
  1214.     dup 0 = until drop
  1215.     vLin @ 1+ vLin !
  1216.     ;
  1217. : ClearRows ( -- )
  1218.     0 RowsCleared !
  1219.     20 Begin 1-
  1220.         0 BlocksFound !
  1221.         0 BombsFound !
  1222.         10 Begin 1- 
  1223.             2dup
  1224.              Board{{ 0
  1225.              shuffle  }}  
  1226.             @ swap drop
  1227.             dup 0 > if
  1228.                 BlocksFound @ 1+ 
  1229.                 BlocksFound !
  1230.             then
  1231.             8 = if
  1232.                   BombsFound @ 1+ 
  1233.                   BombsFound !
  1234.             then
  1235.         dup 0 = until drop
  1236.         BlocksFound @ 
  1237.         10 = if
  1238.             BombsFound @ 
  1239.             0= 0= if
  1240.                  BombsFound @ 1+
  1241.                  Begin 1- Bell
  1242.             Bonus @ 10 + Bonus !
  1243.                  UpdateScore
  1244.                  dup 0= Until drop
  1245.             then
  1246.             DropRow
  1247.             RowsCleared @ 1+
  1248.             dup RowsCleared !
  1249.             Rows>Score
  1250.             ReDraw Woop
  1251.             Drop 19
  1252.             RowsCleared @
  1253.             4 = if Tetris! then
  1254.         then
  1255.     dup 2 = until drop
  1256.     ;
  1257.  
  1258.  
  1259. \ STris-HighS 11/10/01 11:56 CJS
  1260. \ Copyright 2001 ⌐
  1261. \ Christopher J. Smith
  1262.  
  1263. .( STris-HighS... )
  1264.  
  1265. needs STris-Setup
  1266. needs syncname
  1267. needs fields
  1268.  
  1269. : >HighScores ( -- )
  1270.     false HS-Size
  1271.     HS-base >abs 1 2
  1272.     [id] MxTs
  1273.     PrefSetAppPreferences
  1274.     ;
  1275. : HighScores> ( -- f )
  1276.     false HSPtr >abs 
  1277.     HS-base  >abs
  1278.     2 [id] MxTs
  1279.     PrefGetAppPreferences
  1280.     1 =
  1281.     ;
  1282. : high? ( score -- pos f ) 
  1283.     10  Begin 1-
  1284.         2dup Scores{ swap } @
  1285.         > if
  1286.             swap drop true exit
  1287.         then
  1288.     dup 0= Until drop
  1289.     drop -1 False
  1290.     ;
  1291. : high>buffer ( pos -- )
  1292.     Names{ swap } NameBuffer
  1293.     22 chars move    
  1294.     ;
  1295. : buffer>high ( pos -- )
  1296.     Names{ swap } NameBuffer
  1297.     swap 22 chars move
  1298.     ;
  1299. : shiftdown ( pos -- )
  1300.     dup 0> if
  1301.         0 Begin 1+
  1302.             dup dup scores{ 
  1303.             swap 1+ } @
  1304.             swap scores{ swap } !
  1305.             dup 1+ high>buffer
  1306.             dup buffer>high
  1307.         2dup = Until drop
  1308.      then
  1309.     drop
  1310.      ;
  1311. : s>high ( c-addr u pos -- )
  1312.     Names{ swap } swap chars move
  1313.     ;
  1314. : DefaultHS ( -- )
  1315.     712 Scores{ 0 } !
  1316.     855 Scores{ 1 } !
  1317.     981 Scores{ 2 } !
  1318.     1062 Scores{ 3 } !
  1319.     1100 Scores{ 4 } !
  1320.     1241 Scores{ 5 } !
  1321.     1372 Scores{ 6 } !
  1322.     1433 Scores{ 7 } !
  1323.     1572 Scores{ 8 } !
  1324.     1635 Scores{ 9 } !
  1325.     10 Begin 1-
  1326.         dup s"                      " rot
  1327.         s>high 
  1328.     dup 0= Until drop
  1329. s" Harry S. Truman" 0 s>high
  1330. s" Dwight D. Eisenhower" 1 s>high
  1331. s" John F. Kennedy" 2 s>high
  1332. s" Lyndon B. Johnson" 3 s>high
  1333. s" Richard M. Nixon" 4 s>high
  1334. s" Gerald R. Ford " 5 s>high
  1335. s" Jimmy Carter" 6 s>high
  1336. s" Ronald W. Reagan" 7 s>high
  1337. s" George Bush" 8 s>high
  1338. s" William J. Clinton" 9 s>high
  1339.     ;
  1340. : GetHS ( -- )
  1341.     HighScores> 0=  if
  1342.         DefaultHS
  1343.     then
  1344.     ;
  1345. : SetUpHSForm ( -- )
  1346.     0 2 AT-XY
  1347.     10 Begin 1-
  1348.         dup  ."     " 1+
  1349.         dup  1 >  if
  1350.             ."   "
  1351.         then
  1352.         11 swap - . ."        "
  1353.         dup dup scores{ swap } 
  1354.         @ dup 1000 < if
  1355.             ."   "
  1356.         then
  1357.         . ."        "
  1358.         names{ swap } 21 type cr
  1359.     dup 0 = Until drop
  1360.     ;
  1361. : ShowHighScores ( -- )
  1362.     UnlockKeys
  1363.     GameState @ LastMode !
  1364.     6 GameState !
  1365.      HSFormID PopupForm
  1366.     SetUpHSForm
  1367.     ;
  1368. : HSReturn ( -- )
  1369.     LastMode @ dup GameState !
  1370.     0 = if
  1371.         StartFormID 
  1372.         FrmReturnToForm
  1373.     else
  1374.         LockKeys
  1375.         FormID
  1376.         FrmReturnToForm
  1377.     then
  1378.     ;
  1379. : GetName ( -- )
  1380.     UnlockKeys
  1381.     GameState @ LastMode !
  1382.     7 GameState !
  1383.     NameFormID PopupForm
  1384.     UserName NameField
  1385.     string>field drop
  1386.     ;
  1387. : NameReturn ( -- )
  1388.     score @ bonus @ + dup 
  1389.     high? drop
  1390.     dup shiftdown
  1391.      s"                      " NameBuffer
  1392.     swap chars move
  1393.     NameBuffer NameField
  1394.     Field>String drop
  1395.     dup  buffer>high
  1396.     scores{ swap } !
  1397.     >HighScores
  1398.     ;
  1399.  
  1400. \ STris-Rotate 9/30/01 11:48 CJS
  1401. \ Copyright 2001 ⌐
  1402. \ Christopher J. Smith
  1403.  
  1404. .( Rotate... ) cr
  1405.  
  1406. : Buffer>CBuffer (  -- )
  1407.     4 Begin 1-
  1408.         4 Begin 1-
  1409.             2dup 2dup 2>r 2>r
  1410.             BlockBuffer{{  
  1411.             2r> }} @
  1412.             BlockCBuffer{{ 
  1413.             2r> }} !
  1414.         dup 0 = until drop
  1415.     dup 0 = until drop
  1416.     ;
  1417. : CBuffer>Buffer 
  1418.     4 Begin 1-
  1419.         4 Begin 1-
  1420.             2dup 2dup 2>r 2>r
  1421.             BlockCBuffer{{ 
  1422.             2r> }} @
  1423.             BlockBuffer{{ 
  1424.             2r>  }} !
  1425.         dup 0 = until drop
  1426.     dup 0 = until drop
  1427.     ;
  1428. : RotateRight 
  1429.     0 KeyWait !
  1430.     Buffer>CBuffer
  1431.     ClearBlock
  1432.     RMode @ 1+  Begin 1-
  1433.         RMode @ 1+  Begin 1-
  1434.             2dup 2dup 2>r 2>r
  1435.             BlockCBuffer{{ 
  1436.             RMode @
  1437.             r>  -  r> }} @
  1438.             BlockBuffer{{ 
  1439.             2r>  }} !
  1440.         dup 0 = until drop
  1441.     dup 0 = until drop
  1442.     0 YMove !
  1443.     0 XMove !
  1444.     Move? if
  1445.         DrawBlock
  1446.     else
  1447.         CBuffer>Buffer
  1448.         DrawBlock
  1449.     then
  1450.     ;
  1451. : RotateLeft 
  1452.     0 KeyWait !
  1453.      Buffer>CBuffer
  1454.     ClearBlock
  1455.     RMode @ 1+  Begin 1-
  1456.         RMode @ 1+  Begin 1-
  1457.             2dup 2dup 2>r 2>r
  1458.             BlockCBuffer{{  
  1459.             r> RMode @ r> - }} @
  1460.             BlockBuffer{{ 
  1461.             2r>  }} !
  1462.         dup 0 = until drop
  1463.     dup 0 = until drop
  1464.     0 YMove !
  1465.     0 XMove !
  1466.     Move? if
  1467.         DrawBlock
  1468.     else
  1469.         CBuffer>Buffer
  1470.         DrawBlock
  1471.     then
  1472.     ;
  1473.  
  1474. \ STris-Move 9/28/01 14:11 CJS
  1475. \ Copyright 2001 ⌐
  1476. \ Christopher J. Smith
  1477.  
  1478. .( Move... ) cr
  1479.  
  1480. : (Move?)  (  y x -- )
  1481.     dup 10 < if dup -1 > if
  1482.     swap dup 19 < if
  1483.         swap
  1484.         0 Board{{ 2swap
  1485.         }} @ swap drop
  1486.         0 > if
  1487.             False Can? !
  1488.         then
  1489.     else
  1490.         2drop False Can? !
  1491.     then
  1492.     else
  1493.         2drop False Can? !
  1494.     then
  1495.     else
  1496.         2drop False Can? !
  1497.     then
  1498.     ;
  1499. : Move? ( -- Flag )
  1500.     True Can? !
  1501.     4 Begin 1-
  1502.         4 Begin 1-
  1503.             2dup 2dup 2>r >r >r
  1504.             BlockY @ r> +
  1505.             YMove @ +
  1506.             BlockX @ r> +
  1507.             XMove @ +
  1508.             BlockBuffer{{ 2r> }}
  1509.             @  0 > if
  1510.                 (Move?)
  1511.             else
  1512.                 2drop
  1513.             then
  1514.         dup 0 = until drop
  1515.     dup 0 = until drop
  1516.     Can? @
  1517.     dup False = if
  1518.         YMove @ 1 = if
  1519.             BlockY @ 2 < if
  1520.                 3 GameState !
  1521.             then
  1522.             tick
  1523.             Block>Board
  1524.             Next>Current
  1525.             DelayNext @ 0= if
  1526.                 DrawNextBlock
  1527.             then
  1528.             ClearRows
  1529.             1 Score!
  1530.             ReDraw
  1531.         then
  1532.     else
  1533.         DelayNext @ if
  1534.             BlockY @ StartY @  
  1535.             = if
  1536.                 DrawNextBlock
  1537.             then
  1538.         then
  1539.      then
  1540.     ;
  1541. : BDown ( -- )
  1542.     KeySpeed @ 4 -  KeyWait !
  1543.     0 WaitCount !
  1544.     1 YMove ! 0 XMove !
  1545.     Move?  if
  1546.         ClearBlock
  1547.         BlockY @ 1+ BlockY !
  1548.         DrawBlock 
  1549.     then
  1550.     ; INLINE
  1551. : BLeft ( -- ) 
  1552.     0 KeyWait !
  1553.     0 YMove !
  1554.     0 1- XMove !
  1555.     Move? if
  1556.         ClearBlock
  1557.         BlockX @ 1- BlockX !
  1558.         DrawBlock 
  1559.     then
  1560.     ; INLINE
  1561. : BRight ( -- ) 
  1562.     0 KeyWait !
  1563.     0 YMove !
  1564.     1 XMove !
  1565.     Move? if
  1566.         ClearBlock
  1567.         BlockX @ 1+ BlockX !
  1568.         DrawBlock 
  1569.     then
  1570.     ; INLINE
  1571. : TimeOut ( -- )
  1572.     WaitCount @ 1+ dup
  1573.     BlockSpeed @    >  if
  1574.         1 YMove ! 0 XMove !
  1575.         Move? if
  1576.             ClearBlock
  1577.             BlockY @ 1+ BlockY !
  1578.             DrawBlock 
  1579.         then
  1580.         drop 0
  1581.     then
  1582.     WaitCount !
  1583.     ; INLINE
  1584.  
  1585.  
  1586. \ STris-Make 11/14/01 7:23 CJS
  1587.  
  1588. needs STris
  1589. cr .( Build PRC... )
  1590.  
  1591. ' go (id) MxTs  MakePRC FreeTris
  1592.  
  1593. cr  .( Copy Resources... )
  1594. 3040 (ID) MBAR CopyRsrc
  1595. 3001 (ID) Talt CopyRsrc
  1596. 3082 (ID) Tbmp CopyRsrc
  1597. 3083 (ID) Tbmp CopyRsrc 
  1598. 3084  (ID) Tbmp CopyRsrc
  1599. 3085  (ID) Tbmp CopyRsrc
  1600. 3086  (ID) Tbmp CopyRsrc
  1601. 3087  (ID) Tbmp CopyRsrc
  1602. 3088  (ID) Tbmp CopyRsrc
  1603. 3089  (ID) Tbmp CopyRsrc
  1604. 3090  (ID) Tbmp CopyRsrc
  1605. 3091  (ID) Tbmp CopyRsrc
  1606. 3092  (ID) Tbmp CopyRsrc
  1607. 3095  (ID) Tbmp CopyRsrc
  1608. 3096  (ID) Tbmp CopyRsrc
  1609. 3097  (ID) Tbmp CopyRsrc
  1610. 3098  (ID) Tbmp CopyRsrc
  1611. 6004  (ID) Tbmp CopyRsrc
  1612. 6005  (ID) Tbmp CopyRsrc
  1613. 6006  (ID) Tbmp CopyRsrc
  1614. 1000 (ID) tAIB CopyRsrc
  1615. 1001 (ID) tAIB CopyRsrc
  1616. 3104 (ID) tAIN CopyRsrc
  1617. 3000 (ID) tFRM CopyRsrc
  1618. 3002 (ID) tFRM CopyRsrc 
  1619. 3003  (ID) tFRM CopyRsrc
  1620. 3004  (ID) tFRM CopyRsrc
  1621. 3005  (ID) tFRM CopyRsrc
  1622. 3006  (ID) tFRM CopyRsrc
  1623. 6000  (ID) tFRM CopyRsrc
  1624. 3101  (ID) tSTR CopyRsrc
  1625. 3102  (ID) tSTR CopyRsrc
  1626. \ 3103  (ID) tSTR CopyRsrc
  1627. 3104  (ID) tSTR CopyRsrc
  1628. 3106  (ID) tSTR CopyRsrc
  1629. 1  (ID) tver CopyRsrc
  1630.  
  1631. .( Delete Unused Resources... )
  1632. 1000 (ID) tFRM DelRsrc
  1633. 1001 (ID) tFRM DelRsrc
  1634. 1002 (ID) tFRM DelRsrc
  1635.  
  1636. .( Complete  ) a bye
  1637.  
  1638. Version Log
  1639.  
  1640. 1.0
  1641. Initial Release
  1642. 1.1
  1643. Added Splash Screen
  1644. Fixed Bug at level 21
  1645. Quicker Button Reading
  1646. Optimized code
  1647. Fixed High Score Numbering Bug
  1648. Improved Graphics
  1649.  
  1650.  
  1651.