Author Topic: Problem with _PRINTSTRING  (Read 6695 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Problem with _PRINTSTRING
« on: October 16, 2018, 12:38:36 pm »
Getting some unexpected results from _PRINTSTRING when trying to print to a different layer.

there is no small way to show this so here is ALL the code. the problem is in EndScreenB starting on line 2038, I recommend using F2 and going to it that way. there is a screen cap below showing what I'm seeing, My question is why is the second _STRINGPRINT showing up on the display when it should be going to layer TEMP&? and why is it ignoring the set font and COLOR scheme?
If you try to run it you will need the updated GFX file.

Code: QB64: [Select]
  1. 'Tetris 64 Ver 0.9 [start date 10/3/18-13.27]
  2. 'v0.9: (last build on 10/13/2018-13:25)
  3. 'add 'no sound' option
  4. 'add level selection in Menu A to game value
  5. 'add B-Type menu
  6. 'small rocket ending done
  7. 'med rocket ending done
  8. 'Large rocket ending done
  9. 'Shuttle ending done
  10. 'High Score screen Atype done
  11. 'high score screen Btype done
  12. 'Fix rotational collisions
  13. 'divorced Narika from code
  14. 'B-Type game functional
  15. '** found new bug with rotational collisions (10/11/2018) **
  16. '
  17. TYPE GameData
  18.  Mode AS _BYTE 'game type A or B
  19.  BGM AS _BYTE 'Back Gound music 1,2,3
  20.  BGMVol AS _BYTE 'Back Gound Music Volume
  21.  SFXVol AS _BYTE 'Sound effects Volume
  22.  Level AS _BYTE 'game level
  23.  Height AS _BYTE 'line height B-type game
  24.  HScore1 AS LONG 'Highest Score
  25.  HScore2 AS LONG 'Higher Score
  26.  HScore3 AS LONG 'High Score
  27.  HName1 AS STRING * 6 'High score name
  28.  HName2 AS STRING * 6 ' "    "     "
  29.  HName3 AS STRING * 6 ' "    "     "
  30.  Hlevel1 AS _BYTE
  31.  Hlevel2 AS _BYTE
  32.  Hlevel3 AS _BYTE
  33.  HScore1B AS LONG 'Highest Score B-type
  34.  HScore2B AS LONG 'Higher Score B-type
  35.  HScore3B AS LONG 'High Score B-type
  36.  HName1B AS STRING * 6 'High score name B-Type
  37.  HName2B AS STRING * 6 ' "    "     "
  38.  HName3B AS STRING * 6 ' "    "     "
  39.  Hlevel1B AS _BYTE
  40.  Hlevel2B AS _BYTE
  41.  Hlevel3B AS _BYTE
  42.  GameOverFlag AS _BYTE 'game over
  43.  Sound AS _BYTE 'sound on or off
  44.  Loaded AS _BYTE
  45.  
  46. TYPE CurrentData
  47.  Icount AS INTEGER ' Number of I blocks used in current game
  48.  Ocount AS INTEGER ' Number of O blocks used in current game
  49.  Zcount AS INTEGER ' number of Z blocks used in current game
  50.  Scount AS INTEGER ' number of S blocks used in current game
  51.  Jcount AS INTEGER ' number of J blocks used in current game
  52.  Lcount AS INTEGER ' number of L blocks used in current game
  53.  Tcount AS INTEGER ' number of T blocks used in current game
  54.  Score AS LONG '     Current game score
  55.  Piece AS _BYTE '    The currently dropping piece
  56.  NextP AS _BYTE '    The next piece in the queue
  57.  Lines AS INTEGER '  The lines complete in A-Type, Lines remaining in B-type
  58.  Orent AS _BYTE '    rotational orentation of current piece
  59.  PieceX AS _BYTE '   current Piece's X location on board 1-10
  60.  PieceY AS _BYTE '   current Piece's Y location on board 1-20
  61.  bonus AS _BYTE '    Quick drop bonus +1 for each line while down is pressed
  62.  
  63. DIM SHARED G AS GameData, P AS CurrentData, Board(11, 21) AS _BYTE
  64. DIM SHARED BGM(5) AS LONG, SFX(64) AS LONG, FFX(1) AS LONG
  65. DIM SHARED MenuA AS LONG, MenuB AS LONG, FieldA AS LONG, CharacterA AS LONG
  66. DIM SHARED Nomes AS LONG, Bzone AS LONG, ButtonHeld%%, LandedNew%%
  67. DIM SHARED TI(10) AS LONG, MenuC AS LONG, EndScrnA AS LONG, EndSprtA AS LONG
  68. DIM SHARED HighS AS LONG, FieldB AS LONG, QuitGameFlag%%, MenuID%%
  69. DIM SHARED Splash&, EndScrnB AS LONG, EndScrnB2 AS LONG, Temp&
  70.  
  71. CONST TRUE = -1, FALSE = NOT TRUE
  72. CONST TypeA = 1, TypeB = 2
  73. CONST NoBGM = 0, Song1 = 1, Song2 = 2, Song3 = 3, LoadIt = -1, NoSound = -2
  74. CONST T = 1, O = 2, Z = 3, S = 4, J = 5, L = 6, I = 7
  75. CONST AdjX% = -8, BACK = -2, QUIT = -3
  76.  
  77. FOR w% = 0 TO 10
  78.  TI(w%) = _FREETIMER
  79. NEXT w%
  80. ON TIMER(TI(0), .85) DropPiece
  81. ON TIMER(TI(1), .72) DropPiece
  82. ON TIMER(TI(2), .63) DropPiece
  83. ON TIMER(TI(3), .55) DropPiece
  84. ON TIMER(TI(4), .47) DropPiece
  85. ON TIMER(TI(5), .38) DropPiece
  86. ON TIMER(TI(6), .3) DropPiece
  87. ON TIMER(TI(7), .22) DropPiece
  88. ON TIMER(TI(8), .13) DropPiece
  89. ON TIMER(TI(9), .1) DropPiece
  90. ON TIMER(TI(10), .05) DropPiece
  91. StartData
  92.  
  93. st! = TIMER
  94.  
  95. PRINT "loading.";
  96. LoadGameStuff NoSound 'LoadIt
  97. _CLEARCOLOR _RGB32(0, 0, 0), MenuB
  98. _CLEARCOLOR _RGB32(0, 0, 0), MenuC
  99. _CLEARCOLOR _RGB32(0, 89, 251), EndSprtA
  100. BoardSetup
  101. MenuID%% = 0
  102. G.Height = 3
  103. P.Score = 1340
  104. EndScreenB
  105.  StartData
  106.  IF MenuID%% = -1 THEN TitleScreen
  107.  IF NOT QuitGameFlag%% THEN
  108.   IF MenuID%% = 0 THEN MenuOne
  109.   IF NOT QuitGameFlag%% THEN
  110.    IF MenuID%% = 1 AND G.Mode = TypeA THEN MenuTwoA
  111.    IF MenuID%% = 1 AND G.Mode = TypeB THEN MenuTwoB
  112.   END IF
  113.   IF MenuID%% = 2 AND (NOT QuitGameFlag%%) AND G.Mode = TypeA THEN GameModeA
  114.   IF MenuID%% = 2 AND (NOT QuitGameFlag%%) AND G.Mode = TypeB THEN GameModeB
  115. LOOP UNTIL QuitGameFlag%%
  116.  
  117. 'dumpboard 'debuging line
  118. '------------------------------------------------------------------
  119. SUB TitleScreen
  120.  _TITLE "Tetris64 V.9  2018\Cobalt"
  121.  _PUTIMAGE (-10, 0), Splash&, _DISPLAY
  122.  _PRINTSTRING (168, 395), "Remake By Cobalt 2018", _DISPLAY
  123.  IF NOT G.Loaded THEN _PRINTSTRING (155, 290), "Please Wait", _DISPLAY
  124.  IF G.Loaded THEN _PRINTSTRING (155, 290), "Ready to Play", _DISPLAY
  125.  
  126.  IF MenuID%% = -1 THEN
  127.   DisplayClickOptions
  128.   COLOR _RGB32(0, 0, 0)
  129.   _PRINTSTRING (570, 200), "Click here"
  130.   _PRINTSTRING (570, 220), "to go Back"
  131.   COLOR _RGB32(255, 255, 255)
  132.   DO
  133.    nul%% = _MOUSEINPUT
  134.     x% = _MOUSEX: y% = _MOUSEY
  135.     exitflag%% = ClickInteraction(x%, y%)
  136.    END IF
  137.    IF exitflag%% = TRUE THEN MenuID%% = 0 'goto next menu
  138.    IF exitflag%% = BACK THEN exitflag%% = FALSE 'no where to go backwards to
  139.    IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  140.   LOOP UNTIL exitflag%%
  141.   CLS
  142.  
  143. SUB LoadGameStuff (opt%%)
  144.  DIM Size(64) AS LONG, FOffset&(64)
  145.  
  146.  SCREEN _NEWIMAGE(800, 480, 32)
  147.  
  148.  OPEN "Tetris.GFX" FOR BINARY AS #1
  149.  FOR w% = 1 TO 15
  150.   GET #1, , FOffset&(w%)
  151.   GET #1, , Size(w%)
  152.   FOffset&(w%) = FOffset&(w%) + 1
  153.  IF INSTR(_OS$, "WIN") THEN f%% = 1 ELSE f%% = 2
  154.  'function LoadGFX(Foff&,Size&,id%%)
  155.  OPEN "temp.dat" FOR BINARY AS #3
  156.  dat$ = SPACE$(Size(f%%))
  157.  GET #1, FOffset&(f%%), dat$
  158.  PUT #3, , dat$
  159.  CLOSE #3
  160.  FFX(1) = _LOADFONT("temp.dat", 20, "monospace")
  161.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  162.  IF FFX(1) THEN _FONT FFX(1)
  163.  _DELAY .125
  164.  
  165.  Splash& = LoadGFX(FOffset&(3), Size(3))
  166.  'Splash& = _LOADIMAGE("Tetris_Splash.bmp", 32)
  167.  ' FFX(1) = _LOADFONT("NESFont.otf", 20, "monospace")
  168.  ' IF FFX(1) THEN _FONT FFX(1)
  169.  ' _DELAY .125
  170.  TitleScreen
  171.  MenuA = LoadGFX(FOffset&(4), Size(4))
  172.  MenuB = LoadGFX(FOffset&(5), Size(5))
  173.  MenuC = LoadGFX(FOffset&(6), Size(6))
  174.  EndScrnA = LoadGFX(FOffset&(7), Size(7))
  175.  EndSprtA = LoadGFX(FOffset&(8), Size(8))
  176.  FieldA = LoadGFX(FOffset&(9), Size(9))
  177.  FieldB = LoadGFX(FOffset&(10), Size(10))
  178.  HighS = LoadGFX(FOffset&(11), Size(11))
  179.  Nomes = LoadGFX(FOffset&(12), Size(12))
  180.  EndScrnB = LoadGFX(FOffset&(13), Size(13))
  181.  EndScrnB2 = LoadGFX(FOffset&(14), Size(14))
  182.  Temp& = _NEWIMAGE(512, 480, 32)
  183.  Bzone = _NEWIMAGE(160, 320, 32)
  184.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  185.  CLOSE #1
  186.  
  187.  IF opt%% = LoadIt THEN 'load sounds option
  188.   OPEN "Tetris_Original.SFX" FOR BINARY AS #1
  189.   FOR w% = 1 TO 16
  190.    GET #1, , foffset&
  191.    GET #1, , Size(w%)
  192.   NEXT
  193.  
  194.   FOR w% = 1 TO 5
  195.    OPEN "temp.dat" FOR BINARY AS #3
  196.    dat$ = SPACE$(Size(w%))
  197.    GET #1, , dat$
  198.    PUT #3, , dat$
  199.    CLOSE #3
  200.    BGM(w%) = _SNDOPEN("temp.dat")
  201.    IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  202.   NEXT w%
  203.   FOR w% = 6 TO 16
  204.    OPEN "temp.dat" FOR BINARY AS #3
  205.    dat$ = SPACE$(Size(w%))
  206.    GET #1, , dat$
  207.    PUT #3, , dat$
  208.    CLOSE #3
  209.    SFX(w% - 6) = _SNDOPEN("temp.dat")
  210.    IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  211.   NEXT w%
  212.   G.Sound = TRUE
  213.  G.Loaded = TRUE
  214.  _PRINTSTRING (155, 290), "Ready to Play", _DISPLAY
  215.  
  216.  
  217. SUB MenuOne
  218.  STATIC FirstRun%%
  219.  IF FirstRun%% = FALSE THEN
  220.   _PRINTSTRING (570, 130), "Click here"
  221.   _PRINTSTRING (570, 150), "to Continue"
  222.  
  223.   DO
  224.    nul%% = _MOUSEINPUT
  225.     x% = _MOUSEX: y% = _MOUSEY
  226.     exitflag%% = ClickInteraction(x%, y%)
  227.    END IF
  228.   LOOP UNTIL exitflag%%
  229.   CLS
  230.   exitflag%% = FALSE
  231.   FirstRun%% = TRUE
  232.  
  233.  _PUTIMAGE (5, 5), MenuA, _DISPLAY, (64, 16)-(574, 462)
  234.  _PUTIMAGE (30 + G.BGMVol * 1.28, 374), MenuA, _DISPLAY, (32, 0)-(45, 13)
  235.  _PUTIMAGE (30 + G.SFXVol * 1.28, 278), MenuA, _DISPLAY, (32, 0)-(45, 13)
  236.  IF G.Mode = TypeA THEN
  237.   _PUTIMAGE (130, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  238.   _PUTIMAGE (250, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  239.  _PUTIMAGE (212, 277), MenuA, _DISPLAY, (0, 0)-(13, 13)
  240.  _PUTIMAGE (360, 277), MenuA, _DISPLAY, (16, 0)-(29, 13)
  241.  IF G.Mode = TypeB THEN
  242.   _PUTIMAGE (322, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  243.   _PUTIMAGE (442, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  244.  DisplayClickOptions
  245.  
  246.   FOR w% = 1 TO 5
  247.    _SNDVOL BGM(G.BGM), G.BGMVol / 100
  248.   NEXT w%
  249.   FOR w% = 0 TO 12
  250.    _SNDVOL SFX(w%), G.SFXVol / 100
  251.   NEXT w%
  252.   _SNDLOOP BGM(G.BGM)
  253.  old%% = G.BGM
  254.  
  255.  DO
  256.   nul%% = _MOUSEINPUT
  257.   IF nul%% THEN
  258.     x% = _MOUSEX: y% = _MOUSEY
  259.     IF x% > 120 AND y% > 102 AND x% < 275 AND y% < 146 THEN 'game type A
  260.      G.Mode = TypeA
  261.      LINE (322, 117)-(338, 131), _RGB32(0, 0, 0), BF
  262.      LINE (442, 117)-(458, 131), _RGB32(0, 0, 0), BF
  263.      _PUTIMAGE (130, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  264.      _PUTIMAGE (250, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  265.     END IF
  266.     IF x% > 312 AND y% > 102 AND x% < 466 AND y% < 146 THEN 'game type B
  267.      G.Mode = TypeB
  268.      LINE (130, 117)-(146, 131), _RGB32(0, 0, 0), BF
  269.      LINE (250, 117)-(266, 131), _RGB32(0, 0, 0), BF
  270.      _PUTIMAGE (322, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  271.      _PUTIMAGE (442, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  272.     END IF
  273.     IF x% > 210 AND y% > 270 AND x% < 378 AND y% < 296 THEN 'BGM 1
  274.      G.BGM = Song1
  275.      LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  276.      LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  277.      _PUTIMAGE (212, 277), MenuA, _DISPLAY, (0, 0)-(13, 13)
  278.      _PUTIMAGE (360, 277), MenuA, _DISPLAY, (16, 0)-(29, 13)
  279.      songchange%% = TRUE
  280.     END IF
  281.     IF x% > 210 AND y% > 302 AND x% < 378 AND y% < 328 THEN 'BGM 2
  282.      G.BGM = Song2
  283.      LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  284.      LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  285.      _PUTIMAGE (212, 310), MenuA, _DISPLAY, (0, 0)-(13, 13)
  286.      _PUTIMAGE (360, 310), MenuA, _DISPLAY, (16, 0)-(29, 13)
  287.      songchange%% = TRUE
  288.     END IF
  289.     IF x% > 210 AND y% > 334 AND x% < 378 AND y% < 362 THEN 'BGM 3
  290.      G.BGM = Song3
  291.      LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  292.      LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  293.      _PUTIMAGE (212, 340), MenuA, _DISPLAY, (0, 0)-(13, 13)
  294.      _PUTIMAGE (360, 340), MenuA, _DISPLAY, (16, 0)-(29, 13)
  295.      songchange%% = TRUE
  296.     END IF
  297.     IF x% > 210 AND y% > 368 AND x% < 378 AND y% < 394 THEN 'BGM Off
  298.      G.BGM = NoBGM
  299.      LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  300.      LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  301.      _PUTIMAGE (212, 374), MenuA, _DISPLAY, (0, 0)-(13, 13)
  302.      _PUTIMAGE (360, 374), MenuA, _DISPLAY, (16, 0)-(29, 13)
  303.      songchange%% = TRUE
  304.     END IF
  305.     IF x% > 36 AND y% > 372 AND x% < 166 AND y% < 392 THEN 'BGM Volume
  306.      G.BGMVol = ((x% - 37) / 128) * 100
  307.      LINE (30, 372)-(172, 388), _RGB32(0, 0, 0), BF
  308.      _PUTIMAGE (30 + G.BGMVol * 1.28, 374), MenuA, _DISPLAY, (32, 0)-(45, 13)
  309.      volchange%% = TRUE
  310.     END IF
  311.     IF x% > 36 AND y% > 276 AND x% < 166 AND y% < 292 THEN 'SFX Volume
  312.      G.SFXVol = ((x% - 37) / 128) * 100
  313.      LINE (30, 276)-(172, 292), _RGB32(0, 0, 0), BF
  314.      _PUTIMAGE (30 + G.SFXVol * 1.28, 278), MenuA, _DISPLAY, (32, 0)-(45, 13)
  315.      FXvolchange%% = TRUE
  316.     END IF
  317.  
  318.     exitflag%% = ClickInteraction(x%, y%)
  319.    END IF
  320.   END IF
  321.  
  322.    IF songchange%% AND G.BGM <> old%% THEN
  323.     _SNDSTOP BGM(old%%)
  324.     _SNDLOOP BGM(G.BGM)
  325.     old%% = G.BGM
  326.     songchange%% = FALSE
  327.     volchange%% = TRUE
  328.    ELSE
  329.     songchange%% = FALSE
  330.    END IF
  331.  
  332.    IF volchange%% THEN
  333.     _SNDVOL BGM(G.BGM), (G.BGMVol / 100)
  334.     volchange%% = FALSE
  335.    END IF
  336.  
  337.    IF FXvolchange%% AND (NOT _MOUSEBUTTON(1)) THEN
  338.     _SNDVOL SFX(0), (G.SFXVol / 100)
  339.     _SNDPLAY SFX(0) 'plays a test sound effect
  340.     FXvolchange%% = FALSE
  341.    END IF
  342.   END IF
  343.   _DELAY .01
  344.  LOOP UNTIL exitflag%%
  345.  
  346.  IF exitflag%% <> BACK AND exitflag%% <> QUIT THEN
  347.    FOR w% = 0 TO 12
  348.     _SNDVOL SFX(w%), G.SFXVol / 100
  349.    NEXT w%
  350.    FOR w% = 1 TO 5
  351.     _SNDVOL BGM(G.BGM), G.BGMVol / 100
  352.    NEXT w%
  353.  
  354.   END IF
  355.  IF exitflag%% = TRUE THEN
  356.   MenuID%% = 1 'go to next menu
  357.   IF G.Sound THEN _SNDPLAY SFX(0)
  358.  IF exitflag%% = BACK THEN
  359.   MenuID%% = -1 'go back to title screen
  360.   IF G.Sound THEN _SNDPLAY SFX(1)
  361.  IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  362.  
  363. SUB MenuTwoA
  364.  LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  365.  _PUTIMAGE (109, 157), MenuB, _DISPLAY, (0, 0)-(31, 31)
  366.  _PUTIMAGE (5, 5), MenuB, _DISPLAY, (64, 16)-(574, 462)
  367.  DisplayClickOptions
  368.  ShowHighScoreA
  369.  DO
  370.   nul%% = _MOUSEINPUT
  371.   IF nul%% THEN
  372.     x% = _MOUSEX: y% = _MOUSEY
  373.     IF x% > 108 AND y% > 155 AND x% < 271 AND y% < 221 THEN 'Start Level
  374.      IF G.Sound THEN _SNDPLAY SFX(6)
  375.  
  376.      IF y% > 155 AND y% < 188 THEN ll% = 0: yy% = 155: lvl%% = 0
  377.      IF y% > 188 AND y% < 221 THEN ll% = 5: yy% = 189: lvl%% = 5
  378.      SELECT CASE x%
  379.       CASE 108 TO 139
  380.        ll% = ll% + 0: xx% = 109: lvl%% = lvl%% + 0
  381.       CASE 139 TO 172
  382.        ll% = ll% + 1: xx% = 141: lvl%% = lvl%% + 1
  383.       CASE 172 TO 204
  384.        ll% = ll% + 2: xx% = 173: lvl%% = lvl%% + 2
  385.       CASE 204 TO 236
  386.        ll% = ll% + 3: xx% = 204: lvl%% = lvl%% + 3
  387.       CASE 236 TO 271
  388.        ll% = ll% + 4: xx% = 237: lvl%% = lvl%% + 4
  389.      END SELECT
  390.      _PUTIMAGE (109, 153), MenuB, _DISPLAY, (0, 32)-(63, 101)
  391.      _PUTIMAGE (173, 153), MenuB, _DISPLAY, (0, 102)-(63, 171)
  392.      _PUTIMAGE (237, 153), MenuB, _DISPLAY, (0, 172)-(63, 241)
  393.      _PUTIMAGE (xx%, yy%), MenuB, _DISPLAY, (0, 0)-(31, 31)
  394.      _PUTIMAGE (107, 153), MenuB, _DISPLAY, (166, 164)-(331, 243)
  395.  
  396.     END IF
  397.     exitflag%% = ClickInteraction(x%, y%)
  398.    END IF
  399.   END IF
  400.   _DELAY .01
  401.  LOOP UNTIL exitflag%%
  402.  G.Level = lvl%%
  403.  IF exitflag%% = TRUE THEN
  404.   MenuID%% = 2 'go to next menu
  405.   IF G.Sound THEN _SNDPLAY SFX(0)
  406.  IF exitflag%% = BACK THEN
  407.   MenuID%% = 0 'go back to title screen
  408.   IF G.Sound THEN _SNDPLAY SFX(1)
  409.  IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  410.  
  411. SUB MenuTwoB
  412.  LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  413.  _PUTIMAGE (109, 157), MenuC, _DISPLAY, (0, 0)-(31, 31)
  414.  _PUTIMAGE (317, 157), MenuC, _DISPLAY, (0, 0)-(31, 31)
  415.  _PUTIMAGE (5, 5), MenuC, _DISPLAY, (64, 16)-(574, 462)
  416.  DisplayClickOptions
  417.  ShowHighScoreB
  418.  DO
  419.   nul%% = _MOUSEINPUT
  420.   IF nul%% THEN
  421.     x% = _MOUSEX: y% = _MOUSEY
  422.     IF x% > 108 AND y% > 155 AND x% < 271 AND y% < 221 THEN 'Start Level
  423.      IF G.Sound THEN _SNDPLAY SFX(6)
  424.      IF y% > 155 AND y% < 188 THEN yy% = 155: lvl%% = 0
  425.      IF y% > 188 AND y% < 221 THEN yy% = 189: lvl%% = 5
  426.      SELECT CASE x%
  427.       CASE 108 TO 139
  428.        xx% = 109: lvl%% = lvl%% + 0
  429.       CASE 139 TO 172
  430.        xx% = 141: lvl%% = lvl%% + 1
  431.       CASE 172 TO 204
  432.        xx% = 173: lvl%% = lvl%% + 2
  433.       CASE 204 TO 236
  434.        xx% = 204: lvl%% = lvl%% + 3
  435.       CASE 236 TO 271
  436.        xx% = 237: lvl%% = lvl%% + 4
  437.      END SELECT
  438.      LINE (107, 153)-(272, 243), _RGB32(0, 0, 0), BF
  439.      _PUTIMAGE (xx%, yy%), MenuC, _DISPLAY, (0, 0)-(31, 31)
  440.      _PUTIMAGE (107, 153), MenuC, _DISPLAY, (166, 164)-(331, 243)
  441.     END IF
  442.     IF x% > 317 AND y% > 155 AND x% < 413 AND y% < 221 THEN 'Start height
  443.      IF G.Sound THEN _SNDPLAY SFX(6)
  444.      IF y% > 155 AND y% < 188 THEN hyy% = 155: hlvl%% = 0
  445.      IF y% > 188 AND y% < 221 THEN hyy% = 189: hlvl%% = 3
  446.      SELECT CASE x%
  447.       CASE 318 TO 348
  448.        hxx% = 317: hlvl%% = hlvl%% + 0
  449.       CASE 349 TO 380
  450.        hxx% = 349: hlvl%% = hlvl%% + 1
  451.       CASE 381 TO 412
  452.        hxx% = 381: hlvl%% = hlvl%% + 2
  453.      END SELECT
  454.      LINE (315, 153)-(415, 243), _RGB32(0, 0, 0), BF
  455.      _PUTIMAGE (hxx%, hyy%), MenuC, _DISPLAY, (0, 0)-(31, 31)
  456.      _PUTIMAGE (315, 153), MenuC, _DISPLAY, (374, 164)-(474, 243)
  457.     END IF
  458.     exitflag%% = ClickInteraction(x%, y%)
  459.    END IF
  460.   END IF
  461.   _DELAY .01
  462.  LOOP UNTIL exitflag%%
  463.  G.Level = lvl%%
  464.  G.Height = hlvl%%
  465.  P.Lines = 25
  466.  IF exitflag%% = TRUE THEN
  467.   MenuID%% = 2 'go to next menu
  468.   IF G.Sound THEN _SNDPLAY SFX(0)
  469.  IF exitflag%% = BACK THEN
  470.   MenuID%% = 0 'go back to title screen
  471.   IF G.Sound THEN _SNDPLAY SFX(1)
  472.  IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  473.  
  474. SUB DisplayNextPiece
  475.  'display the next peice in queue
  476.  'display peice centered in NEXT window(420)
  477.  'first clear next window
  478.  LINE (388, 212)-(450, 275), _RGB32(0, 0, 0), BF
  479.  IF G.Level < 10 THEN Yshift~%% = 16 * G.Level ELSE Yshift~%% = 16 * 9
  480.  SELECT CASE P.NextP
  481.   CASE T
  482.    _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  483.    _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  484.    _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  485.    _PUTIMAGE (420 - 8, 212 + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  486.   CASE J
  487.    _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  488.    _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  489.    _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  490.    _PUTIMAGE (420 + 8, 212 + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  491.   CASE L
  492.    _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  493.    _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  494.    _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  495.    _PUTIMAGE (420 - 24, 212 + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  496.   CASE Z
  497.    _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  498.    _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  499.    _PUTIMAGE (420 - 8, 212 + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  500.    _PUTIMAGE (420 + 8, 212 + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  501.   CASE O
  502.    _PUTIMAGE (420 - 16, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  503.    _PUTIMAGE (420 + 0, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  504.    _PUTIMAGE (420 - 16, 212 + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  505.    _PUTIMAGE (420 + 0, 212 + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  506.   CASE S
  507.    _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  508.    _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  509.    _PUTIMAGE (420 - 8, 212 + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  510.    _PUTIMAGE (420 - 24, 212 + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  511.   CASE I
  512.    _PUTIMAGE (420 - 32, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  513.    _PUTIMAGE (420 - 16, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  514.    _PUTIMAGE (420 + 0, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  515.    _PUTIMAGE (420 + 16, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  516.  
  517.  
  518. SUB PlaceTetraNome
  519.  px% = P.PieceX * 16 + 197 + AdjX%
  520.  py% = P.PieceY * 16 + 85 - 16
  521.  IF G.Level < 10 THEN Yshift~%% = 16 * G.Level ELSE Yshift~%% = 16 * 9
  522.  SELECT CASE P.Piece
  523.   CASE T
  524.    SELECT CASE P.Orent
  525.     CASE 1 'normal
  526.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  527.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  528.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  529.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  530.     CASE 2 '90 rt
  531.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  532.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  533.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  534.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  535.     CASE 3 '180rt
  536.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  537.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  538.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  539.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  540.     CASE 4 '270rt
  541.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  542.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  543.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  544.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  545.    END SELECT
  546.   CASE J
  547.    SELECT CASE P.Orent
  548.     CASE 1 'normal
  549.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  550.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  551.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  552.      _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  553.     CASE 2 '90 rt
  554.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  555.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  556.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  557.      _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  558.     CASE 3 '180 rt
  559.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  560.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  561.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  562.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 24, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  563.     CASE 4 '270 rt
  564.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  565.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  566.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  567.      IF P.PieceY > 0 THEN _PUTIMAGE (px% + 8, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  568.    END SELECT
  569.   CASE L
  570.    SELECT CASE P.Orent
  571.     CASE 1 'normal
  572.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  573.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  574.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  575.      _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  576.     CASE 2 '90 rt
  577.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  578.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  579.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  580.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 24, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  581.     CASE 3 '180 rt
  582.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  583.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  584.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  585.      IF P.PieceY > 0 THEN _PUTIMAGE (px% + 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  586.     CASE 4 '270 rt
  587.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  588.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  589.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  590.      _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  591.    END SELECT
  592.   CASE Z
  593.    SELECT CASE P.Orent
  594.     CASE 1, 3 'normal+180
  595.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  596.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  597.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  598.      _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  599.     CASE 2, 4 '90 rt+270rt
  600.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  601.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  602.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  603.      _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  604.    END SELECT
  605.   CASE O
  606.    SELECT CASE P.Orent
  607.     CASE 1 TO 4 'normal-no rotation change
  608.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  609.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  610.      _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  611.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  612.    END SELECT
  613.   CASE S
  614.    SELECT CASE P.Orent
  615.     CASE 1, 3 'normal+180rt
  616.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  617.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  618.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  619.      _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  620.     CASE 2, 4 '90rt+270rt
  621.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  622.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  623.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  624.      _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  625.    END SELECT
  626.   CASE I
  627.    SELECT CASE P.Orent
  628.     CASE 1, 3 'normal+180
  629.      _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  630.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  631.      _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  632.      _PUTIMAGE (px% + 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  633.     CASE 2, 4 '90rt,270rt
  634.      IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  635.      _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  636.      _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  637.      _PUTIMAGE (px% - 8, py% + 48), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  638.    END SELECT
  639.  
  640. SUB DropPiece
  641.  P.PieceY = P.PieceY + 1 'move Tetranome down
  642.  IF ButtonHeld%% THEN P.bonus = P.bonus + 1 'if player is pressing down button then add to bonus
  643.  IF CollisionDown THEN LandPiece 'check to see if the peice is landed
  644.  
  645. FUNCTION CollisionDown
  646.  result%% = FALSE
  647.  SELECT CASE P.Piece
  648.   CASE T
  649.    SELECT CASE P.Orent
  650.     CASE 1
  651.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  652.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  653.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  654.     CASE 2
  655.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  656.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  657.     CASE 3
  658.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  659.      IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  660.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  661.     CASE 4
  662.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  663.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  664.    END SELECT
  665.    IF P.PieceY + 1 = 21 THEN result%% = TRUE
  666.   CASE J
  667.    SELECT CASE P.Orent
  668.     CASE 1
  669.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  670.      IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  671.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  672.     CASE 2
  673.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  674.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  675.     CASE 3
  676.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  677.      IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  678.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  679.     CASE 4
  680.      IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  681.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  682.    END SELECT
  683.    IF P.PieceY + 1 = 21 THEN result%% = TRUE
  684.   CASE L
  685.    SELECT CASE P.Orent
  686.     CASE 1
  687.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  688.      IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  689.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  690.     CASE 2
  691.      IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  692.      IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  693.     CASE 3
  694.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  695.      IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  696.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  697.     CASE 4
  698.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  699.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  700.    END SELECT
  701.    IF P.PieceY + 1 = 21 THEN result%% = TRUE
  702.   CASE Z
  703.    SELECT CASE P.Orent
  704.     CASE 1, 3
  705.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  706.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  707.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  708.     CASE 2, 4
  709.      IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  710.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  711.    END SELECT
  712.    IF P.PieceY + 1 = 21 THEN result%% = TRUE
  713.   CASE S
  714.    SELECT CASE P.Orent
  715.     CASE 1, 3
  716.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  717.      IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  718.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  719.     CASE 2, 4
  720.      IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  721.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  722.    END SELECT
  723.    IF P.PieceY + 1 = 21 THEN result%% = TRUE
  724.   CASE I
  725.    SELECT CASE P.Orent
  726.     CASE 1, 3
  727.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  728.      IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  729.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  730.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  731.      IF P.PieceY + 1 = 21 THEN result%% = TRUE
  732.     CASE 2, 4
  733.      IF Board(P.PieceX + 0, P.PieceY + 3) > TRUE THEN result%% = TRUE
  734.      IF P.PieceY + 1 = 20 THEN result%% = TRUE
  735.    END SELECT
  736.   CASE O
  737.    SELECT CASE P.Orent
  738.     CASE 1 TO 4
  739.      IF Board(P.PieceX + 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  740.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  741.      IF P.PieceY + 1 = 21 THEN result%% = TRUE
  742.    END SELECT
  743.  CollisionDown = result%%
  744.  
  745. SUB LandPiece
  746.  IF G.Sound THEN _SNDPLAY SFX(5)
  747.  SELECT CASE P.Piece
  748.   CASE T
  749.    Board(P.PieceX + 0, P.PieceY) = 0
  750.    SELECT CASE P.Orent
  751.     CASE 1
  752.      Board(P.PieceX - 1, P.PieceY) = 0
  753.      Board(P.PieceX + 1, P.PieceY) = 0
  754.      Board(P.PieceX + 0, P.PieceY + 1) = 0
  755.     CASE 2
  756.      Board(P.PieceX + 0, P.PieceY - 1) = 0
  757.      Board(P.PieceX - 1, P.PieceY) = 0
  758.      Board(P.PieceX + 0, P.PieceY + 1) = 0
  759.     CASE 3
  760.      Board(P.PieceX - 1, P.PieceY) = 0
  761.      Board(P.PieceX + 1, P.PieceY) = 0
  762.      Board(P.PieceX + 0, P.PieceY - 1) = 0
  763.     CASE 4
  764.      Board(P.PieceX + 0, P.PieceY - 1) = 0
  765.      Board(P.PieceX + 1, P.PieceY) = 0
  766.      Board(P.PieceX + 0, P.PieceY + 1) = 0
  767.    END SELECT
  768.   CASE J
  769.    Board(P.PieceX + 0, P.PieceY) = 2
  770.    SELECT CASE P.Orent
  771.     CASE 1
  772.      Board(P.PieceX - 1, P.PieceY) = 2
  773.      Board(P.PieceX + 1, P.PieceY) = 2
  774.      Board(P.PieceX + 1, P.PieceY + 1) = 2
  775.     CASE 2
  776.      Board(P.PieceX - 0, P.PieceY - 1) = 2
  777.      Board(P.PieceX + 0, P.PieceY + 1) = 2
  778.      Board(P.PieceX - 1, P.PieceY + 1) = 2
  779.     CASE 3
  780.      Board(P.PieceX - 1, P.PieceY) = 2
  781.      Board(P.PieceX + 1, P.PieceY) = 2
  782.      Board(P.PieceX - 1, P.PieceY - 1) = 2
  783.     CASE 4
  784.      Board(P.PieceX - 0, P.PieceY - 1) = 2
  785.      Board(P.PieceX + 0, P.PieceY + 1) = 2
  786.      Board(P.PieceX + 1, P.PieceY - 1) = 2
  787.    END SELECT
  788.   CASE L
  789.    Board(P.PieceX + 0, P.PieceY) = 1
  790.    SELECT CASE P.Orent
  791.     CASE 1
  792.      Board(P.PieceX - 1, P.PieceY) = 1
  793.      Board(P.PieceX + 1, P.PieceY) = 1
  794.      Board(P.PieceX - 1, P.PieceY + 1) = 1
  795.     CASE 2
  796.      Board(P.PieceX - 0, P.PieceY - 1) = 1
  797.      Board(P.PieceX + 0, P.PieceY + 1) = 1
  798.      Board(P.PieceX - 1, P.PieceY - 1) = 1
  799.     CASE 3
  800.      Board(P.PieceX - 1, P.PieceY) = 1
  801.      Board(P.PieceX + 1, P.PieceY) = 1
  802.      Board(P.PieceX + 1, P.PieceY - 1) = 1
  803.     CASE 4
  804.      Board(P.PieceX - 0, P.PieceY - 1) = 1
  805.      Board(P.PieceX + 0, P.PieceY + 1) = 1
  806.      Board(P.PieceX + 1, P.PieceY + 1) = 1
  807.    END SELECT
  808.   CASE Z
  809.    Board(P.PieceX + 0, P.PieceY) = 1
  810.    SELECT CASE P.Orent
  811.     CASE 1, 3
  812.      Board(P.PieceX - 1, P.PieceY) = 1
  813.      Board(P.PieceX + 0, P.PieceY + 1) = 1
  814.      Board(P.PieceX + 1, P.PieceY + 1) = 1
  815.     CASE 2, 4
  816.      Board(P.PieceX - 0, P.PieceY - 1) = 1
  817.      Board(P.PieceX - 1, P.PieceY + 0) = 1
  818.      Board(P.PieceX - 1, P.PieceY + 1) = 1
  819.    END SELECT
  820.   CASE S
  821.    Board(P.PieceX + 0, P.PieceY) = 2
  822.    SELECT CASE P.Orent
  823.     CASE 1, 3
  824.      Board(P.PieceX + 1, P.PieceY) = 2
  825.      Board(P.PieceX + 0, P.PieceY + 1) = 2
  826.      Board(P.PieceX - 1, P.PieceY + 1) = 2
  827.     CASE 2, 4
  828.      Board(P.PieceX - 0, P.PieceY - 1) = 2
  829.      Board(P.PieceX + 1, P.PieceY + 0) = 2
  830.      Board(P.PieceX + 1, P.PieceY + 1) = 2
  831.    END SELECT
  832.   CASE I
  833.    Board(P.PieceX + 0, P.PieceY) = 0
  834.    SELECT CASE P.Orent
  835.     CASE 1, 3
  836.      Board(P.PieceX - 1, P.PieceY) = 0
  837.      Board(P.PieceX + 1, P.PieceY + 0) = 0
  838.      Board(P.PieceX + 2, P.PieceY + 0) = 0
  839.     CASE 2, 4
  840.      Board(P.PieceX - 0, P.PieceY - 1) = 0
  841.      Board(P.PieceX + 0, P.PieceY + 1) = 0
  842.      Board(P.PieceX + 0, P.PieceY + 2) = 0
  843.    END SELECT
  844.   CASE O
  845.    Board(P.PieceX + 0, P.PieceY) = 0
  846.    SELECT CASE P.Orent
  847.     CASE 1 TO 4
  848.      Board(P.PieceX - 1, P.PieceY) = 0
  849.      Board(P.PieceX - 0, P.PieceY + 1) = 0
  850.      Board(P.PieceX - 1, P.PieceY + 1) = 0
  851.    END SELECT
  852.  CheckLines
  853.  IF ButtonHeld%% THEN P.Score = P.Score + (P.bonus * (G.Level + 1)): LandedNew%% = TRUE
  854.  P.bonus = 0
  855.  IF NOT G.GameOverFlag THEN NewPiece
  856.  
  857. SUB DrawBoard
  858.  IF G.Level < 10 THEN Yshift~%% = 16 * G.Level ELSE Yshift~%% = 16 * 9
  859.  FOR y% = 0 TO 19
  860.   FOR x% = 0 TO 9
  861.    IF Board(x% + 1, y% + 1) <> -1 THEN
  862.     _PUTIMAGE (197 + x% * 16, 85 + y% * 16), Nomes, _DISPLAY, (0 + 16 * Board(x% + 1, y% + 1), Yshift~%%)-(15 + 16 * Board(x% + 1, y% + 1), 15 + Yshift~%%)
  863.    ELSE
  864.     LINE (197 + x% * 16, 85 + y% * 16)-(197 + 15 + x% * 16, 85 + 15 + y% * 16), _RGB32(0, 0, 0), BF
  865.    END IF
  866.   NEXT x%
  867.  NEXT y%
  868.  
  869. SUB BoardSetup
  870.  FOR y% = 0 TO 20
  871.   FOR x% = 1 TO 10
  872.    Board(x%, y%) = TRUE
  873.   NEXT x%
  874.  NEXT y%
  875.  
  876. SUB dumpboard
  877.  OPEN "debugboard.txt" FOR OUTPUT AS #2
  878.  LandPiece
  879.  FOR y% = 0 TO 21
  880.   FOR x% = 0 TO 11
  881.    PRINT #2, Board(x%, y%);
  882.   NEXT x%
  883.   PRINT #2,
  884.  NEXT y%
  885.  
  886. SUB CheckLines
  887.  DIM Lines%(4) 'can fill up to 4 lines at once for a TETRIS
  888.  ip%% = 1
  889.  'find solid lines
  890.  FOR y%% = 1 TO 20
  891.   solid%% = TRUE 'assume line is solid at start
  892.   FOR x%% = 1 TO 10
  893.    IF Board(x%%, y%%) = TRUE THEN solid%% = FALSE 'change to false if hole found
  894.   NEXT
  895.   IF solid%% THEN Lines%(ip%%) = y%%: ip%% = ip%% + 1
  896.  ip%% = ip%% - 1
  897.  IF ip%% > 0 THEN
  898.   IF G.Mode = TypeA THEN P.Lines = P.Lines + ip%%
  899.   IF G.Mode = TypeB THEN P.Lines = P.Lines - ip%%
  900.   IF P.Lines < 0 THEN P.Lines = 0
  901.   'give player points for lines completed
  902.   SELECT CASE ip%%
  903.    CASE 1
  904.     P.Score = P.Score + (40 * (G.Level + 1))
  905.     IF G.Sound THEN _SNDPLAY SFX(10)
  906.    CASE 2
  907.     P.Score = P.Score + (100 * (G.Level + 1))
  908.     IF G.Sound THEN _SNDPLAY SFX(10)
  909.    CASE 3
  910.     P.Score = P.Score + (300 * (G.Level + 1))
  911.     IF G.Sound THEN _SNDPLAY SFX(10)
  912.    CASE 4
  913.     P.Score = P.Score + (1200 * (G.Level + 1))
  914.     IF G.Sound THEN _SNDPLAY SFX(9)
  915.   'remove solid lines
  916.   IF Lines%(1) <> 0 THEN
  917.    FOR x% = 1 TO 5
  918.     FOR y% = 1 TO ip%%
  919.      Board(6 - x%, Lines%(y%)) = -1
  920.      Board(5 + x%, Lines%(y%)) = -1
  921.     NEXT y%
  922.     DrawBoard
  923.     _DELAY .075
  924.    NEXT x%
  925.   END IF
  926.   'TETRIS bonus
  927.   IF ip%% = 4 THEN P.Score = P.Score + (100 * (ip%% * (G.Level + 1)))
  928.   'drop any lines down to fill in gaps
  929.   FOR w%% = 1 TO ip%%
  930.    FOR y%% = Lines%(w%%) TO 1 STEP -1
  931.     FOR x%% = 1 TO 10
  932.      Board(x%%, y%%) = Board(x%%, y%% - 1)
  933.     NEXT x%%
  934.    NEXT y%%
  935.    FOR x%% = 1 TO 10 'reset top line
  936.     Board(x%%, y%% + 1) = TRUE
  937.    NEXT x%%
  938.   NEXT w%%
  939.   DrawBoard
  940.  
  941.   IF (P.Lines > 0) AND ((P.Lines MOD 10) = 0) AND G.Mode = TypeA THEN
  942.    TIMER(TI(G.Level)) OFF
  943.    IF G.Level < 10 THEN G.Level = G.Level + 1
  944.    TIMER(TI(G.Level)) ON
  945.   END IF
  946.  
  947.  IF G.Mode = TypeB AND P.Lines = 0 THEN GameOver
  948.  
  949. FUNCTION CollisionLeft
  950.  result%% = FALSE
  951.  SELECT CASE P.Piece
  952.   CASE T
  953.    SELECT CASE P.Orent
  954.     CASE 1
  955.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  956.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  957.     CASE 2
  958.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  959.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  960.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  961.     CASE 3
  962.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  963.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  964.     CASE 4
  965.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  966.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  967.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  968.    END SELECT
  969.   CASE J
  970.    SELECT CASE P.Orent
  971.     CASE 1
  972.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  973.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  974.     CASE 2
  975.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  976.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  977.      IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  978.     CASE 3
  979.      IF Board(P.PieceX - 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  980.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  981.     CASE 4
  982.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  983.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  984.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  985.    END SELECT
  986.   CASE L
  987.    SELECT CASE P.Orent
  988.     CASE 1
  989.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  990.      IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  991.     CASE 2
  992.      IF Board(P.PieceX - 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  993.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  994.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  995.     CASE 3
  996.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  997.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  998.     CASE 4
  999.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1000.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1001.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1002.    END SELECT
  1003.   CASE Z
  1004.    SELECT CASE P.Orent
  1005.     CASE 1, 3
  1006.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1007.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1008.     CASE 2, 4
  1009.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1010.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1011.      IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1012.    END SELECT
  1013.   CASE S
  1014.    SELECT CASE P.Orent
  1015.     CASE 1, 3
  1016.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1017.      IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1018.     CASE 2, 4
  1019.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1020.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1021.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1022.    END SELECT
  1023.   CASE I
  1024.    SELECT CASE P.Orent
  1025.     CASE 1, 3
  1026.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1027.     CASE 2, 4
  1028.      IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1029.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1030.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1031.      IF Board(P.PieceX - 1, P.PieceY + 3) > TRUE THEN result%% = TRUE
  1032.    END SELECT
  1033.   CASE O
  1034.    SELECT CASE P.Orent
  1035.     CASE 1 TO 4
  1036.      IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1037.      IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1038.    END SELECT
  1039.  CollisionLeft = result%%
  1040.  
  1041. FUNCTION CollisionRight
  1042.  result%% = FALSE
  1043.  SELECT CASE P.Piece
  1044.   CASE T
  1045.    SELECT CASE P.Orent
  1046.     CASE 1
  1047.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1048.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1049.     CASE 2
  1050.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1051.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1052.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1053.     CASE 3
  1054.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1055.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1056.     CASE 4
  1057.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1058.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1059.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1060.    END SELECT
  1061.   CASE J
  1062.    SELECT CASE P.Orent
  1063.     CASE 1
  1064.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1065.      IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1066.     CASE 2
  1067.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1068.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1069.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1070.     CASE 3
  1071.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1072.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1073.     CASE 4
  1074.      IF Board(P.PieceX + 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1075.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1076.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1077.    END SELECT
  1078.   CASE L
  1079.    SELECT CASE P.Orent
  1080.     CASE 1
  1081.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1082.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1083.     CASE 2
  1084.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1085.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1086.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1087.     CASE 3
  1088.      IF Board(P.PieceX + 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1089.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1090.     CASE 4
  1091.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1092.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1093.      IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1094.    END SELECT
  1095.   CASE Z
  1096.    SELECT CASE P.Orent
  1097.     CASE 1, 3
  1098.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1099.      IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1100.     CASE 2, 4
  1101.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1102.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1103.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1104.    END SELECT
  1105.   CASE S
  1106.    SELECT CASE P.Orent
  1107.     CASE 1, 3
  1108.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1109.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1110.     CASE 2, 4
  1111.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1112.      IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1113.      IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1114.    END SELECT
  1115.   CASE I
  1116.    SELECT CASE P.Orent
  1117.     CASE 1, 3
  1118.      IF Board(P.PieceX + 3, P.PieceY) > TRUE THEN result%% = TRUE
  1119.     CASE 2, 4
  1120.      IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1121.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1122.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1123.      IF Board(P.PieceX + 1, P.PieceY + 3) > TRUE THEN result%% = TRUE
  1124.    END SELECT
  1125.   CASE O
  1126.    SELECT CASE P.Orent
  1127.     CASE 1 TO 4
  1128.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1129.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1130.    END SELECT
  1131.  CollisionRight = result%%
  1132.  
  1133. SUB StatusUpdate
  1134.  DIM v$(11) 'value strings
  1135.  v$(0) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Lines)))) + LTRIM$(STR$(P.Lines))
  1136.  IF G.Mode = TypeA THEN v$(1) = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1)))) + LTRIM$(STR$(G.HScore1))
  1137.  IF G.Mode = TypeB THEN v$(1) = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1B)))) + LTRIM$(STR$(G.HScore1B))
  1138.  v$(2) = LEFT$("000000", 6 - LEN(LTRIM$(STR$(P.Score)))) + LTRIM$(STR$(P.Score))
  1139.  v$(3) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Tcount)))) + LTRIM$(STR$(P.Tcount))
  1140.  v$(4) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Jcount)))) + LTRIM$(STR$(P.Jcount))
  1141.  v$(5) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Zcount)))) + LTRIM$(STR$(P.Zcount))
  1142.  v$(6) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Ocount)))) + LTRIM$(STR$(P.Ocount))
  1143.  v$(7) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Scount)))) + LTRIM$(STR$(P.Scount))
  1144.  v$(8) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Lcount)))) + LTRIM$(STR$(P.Lcount))
  1145.  v$(9) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Icount)))) + LTRIM$(STR$(P.Icount))
  1146.  v$(10) = LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Level)))) + LTRIM$(STR$(G.Level))
  1147.  v$(11) = LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Height)))) + LTRIM$(STR$(G.Height))
  1148.  FOR u% = 0 TO 6
  1149.   COLOR _RGB32(240, 58, 0)
  1150.   _PRINTSTRING (102, 175 + u% * 32), v$(3 + u%), _DISPLAY
  1151.   COLOR _RGB32(255, 255, 255)
  1152.  NEXT u%
  1153.  _PRINTSTRING (308, 34), v$(0), _DISPLAY
  1154.  _PRINTSTRING (388, 70), v$(1), _DISPLAY
  1155.  _PRINTSTRING (388, 120), v$(2), _DISPLAY
  1156.  _PRINTSTRING (428 - (LEN(v$(10)) * _FONTWIDTH(FFX(1))) / 2, 324), v$(10), _DISPLAY
  1157.  IF G.Mode = TypeB THEN _PRINTSTRING (440 - (LEN(v$(11)) * _FONTWIDTH(FFX(1))) / 2, 390), v$(11), _DISPLAY
  1158.  
  1159. SUB NewPiece
  1160.  IF Board(5, 1) <> TRUE THEN GameOver
  1161.  IF NOT G.GameOverFlag THEN
  1162.   P.PieceY = 0
  1163.   P.PieceX = 5
  1164.   P.Orent = 1
  1165.   P.Piece = P.NextP
  1166.   P.NextP = INT(RND * 7) + 1
  1167.   SELECT CASE P.Piece
  1168.    CASE T
  1169.     P.Tcount = P.Tcount + 1
  1170.    CASE J
  1171.     P.Jcount = P.Jcount + 1
  1172.    CASE L
  1173.     P.Lcount = P.Lcount + 1
  1174.    CASE Z
  1175.     P.Zcount = P.Zcount + 1
  1176.    CASE S
  1177.     P.Scount = P.Scount + 1
  1178.    CASE O
  1179.     P.Ocount = P.Ocount + 1
  1180.    CASE I
  1181.     P.Icount = P.Icount + 1
  1182.   StatusUpdate
  1183.   DisplayNextPiece
  1184.  
  1185. FUNCTION CollisionRotate
  1186.  result%% = FALSE
  1187.  SELECT CASE P.Piece
  1188.   CASE T
  1189.    SELECT CASE P.Orent
  1190.     CASE 1
  1191.      IF Board(P.PieceX + 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1192.     CASE 2
  1193.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1194.     CASE 3
  1195.      IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1196.     CASE 4
  1197.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1198.    END SELECT
  1199.   CASE J
  1200.    SELECT CASE P.Orent
  1201.     CASE 1
  1202.      IF Board(P.PieceX + 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1203.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1204.      IF Board(P.PieceX - 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1205.     CASE 2
  1206.      IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1207.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1208.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1209.     CASE 3
  1210.      IF Board(P.PieceX - 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1211.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1212.      IF Board(P.PieceX - 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1213.     CASE 4
  1214.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1215.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1216.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1217.    END SELECT
  1218.   CASE L
  1219.    SELECT CASE P.Orent
  1220.     CASE 1
  1221.      IF Board(P.PieceX + 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1222.      IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1223.      IF Board(P.PieceX - 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1224.     CASE 2
  1225.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1226.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1227.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1228.     CASE 3
  1229.      IF Board(P.PieceX - 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1230.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1231.      IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1232.     CASE 4
  1233.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1234.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1235.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1236.    END SELECT
  1237.   CASE Z
  1238.    SELECT CASE P.Orent
  1239.     CASE 1, 3
  1240.      IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1241.      IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1242.     CASE 2, 4
  1243.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1244.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1245.    END SELECT
  1246.   CASE S
  1247.    SELECT CASE P.Orent
  1248.     CASE 1, 3
  1249.      IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1250.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1251.     CASE 2, 4
  1252.      IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1253.      IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1254.    END SELECT
  1255.   CASE O
  1256.   CASE I
  1257.    SELECT CASE P.Orent
  1258.     CASE 1, 3
  1259.      IF Board(P.PieceX - 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1260.      IF Board(P.PieceX + 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1261.      IF Board(P.PieceX + 0, P.PieceY + 3) > TRUE THEN result%% = TRUE
  1262.     CASE 2, 4
  1263.      IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1264.      IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1265.      IF P.PieceX + 2 < 12 THEN IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1266.    END SELECT
  1267.  
  1268.  CollisionRotate = result%%
  1269.  
  1270. SUB GameOver
  1271.  MenuID%% = -1 'return to title screen
  1272.  G.GameOverFlag = TRUE
  1273.  IF ButtonHeld%% THEN TIMER(TI(10)) OFF ELSE TIMER(TI(G.Level)) OFF
  1274.  _SNDSTOP BGM(G.BGM)
  1275.  _SNDPLAY SFX(3)
  1276.  _DELAY .25
  1277.  IF G.Mode = TypeA THEN
  1278.   IF G.Sound THEN _SNDPLAY SFX(7)
  1279.   FOR y% = 1 TO 20
  1280.    FOR x% = 1 TO 10
  1281.     Board(x%, y%) = 3
  1282.    NEXT x%
  1283.    DrawBoard
  1284.    _DELAY .2
  1285.   NEXT y%
  1286.   IF P.Score > 30000 THEN EndScreen
  1287.   IF P.Score > G.HScore3 THEN HighScoreScreen
  1288.  
  1289.  IF G.Mode = TypeB AND P.Lines = 0 THEN
  1290.   IF G.Sound THEN _SNDPLAY SFX(8)
  1291.   FOR w%% = 1 TO 4
  1292.    _PUTIMAGE (276 - 16 * w%%, 206), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1293.    _PUTIMAGE (276 - 16 * w%%, 252)-(291 - 16 * w%%, 237), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1294.    _PUTIMAGE (260 + 16 * w%%, 206), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1295.    _PUTIMAGE (260 + 16 * w%%, 252)-(276 + 16 * w%%, 237), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1296.    _DELAY .0375
  1297.   NEXT w%%
  1298.   _PUTIMAGE (196, 206), FieldB, _DISPLAY, (0, 0)-(15, 15)
  1299.   _PUTIMAGE (196, 222), FieldB, _DISPLAY, (0, 16)-(15, 31)
  1300.   _PUTIMAGE (196, 252)-(211, 237), FieldB, _DISPLAY, (0, 0)-(15, 15)
  1301.   _PUTIMAGE (341, 206), FieldB, _DISPLAY, (32, 0)-(47, 15)
  1302.   _PUTIMAGE (356, 222)-(341, 237), FieldB, _DISPLAY, (0, 16)-(15, 31)
  1303.   _PUTIMAGE (341, 252)-(356, 237), FieldB, _DISPLAY, (32, 0)-(47, 15)
  1304.   _PRINTSTRING (214, 220), "SUCCESS!", _DISPLAY
  1305.   _DELAY 1.75
  1306.   EndScreenB
  1307.   IF P.Score > G.HScore3B THEN HighScoreScreen
  1308.   IF G.Sound THEN _SNDPLAY SFX(7)
  1309.   FOR y% = 1 TO 20
  1310.    FOR x% = 1 TO 10
  1311.     Board(x%, y%) = 3
  1312.    NEXT x%
  1313.    DrawBoard
  1314.    _DELAY .2
  1315.   NEXT y%
  1316.   ' iF P.Score > G.HScore3B THEN HighScoreScreen
  1317.  _DELAY 2.5
  1318.  
  1319. FUNCTION ClickInteraction (x%, y%)
  1320.  IF x% > 570 AND y% > 130 AND x% < 710 AND y% < 175 THEN 'next
  1321.   result%% = TRUE
  1322.  IF x% > 570 AND y% > 200 AND x% < 710 AND y% < 245 THEN 'go back
  1323.   result%% = BACK
  1324.  IF x% > 570 AND y% > 400 AND x% < 710 AND y% < 445 THEN 'quit
  1325.   result%% = QUIT
  1326.  
  1327.  ClickInteraction = result%%
  1328.  
  1329. SUB EndScreen
  1330.  _SNDLOOP BGM(4)
  1331.  COLOR _RGB32(250, 250, 250), _RGB32(0, 89, 251)
  1332.  LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  1333.  _PUTIMAGE (5, 5), EndScrnA, _DISPLAY, (64, 16)-(574, 462)
  1334.  v$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(P.Score)))) + LTRIM$(STR$(P.Score))
  1335.  _PRINTSTRING (225, 50), v$, _DISPLAY
  1336.  SELECT CASE P.Score
  1337.   CASE 30000 TO 49999
  1338.    _PUTIMAGE (168, 373), EndSprtA, _DISPLAY, (98, 0)-(113, 15)
  1339.    _DELAY 2.75
  1340.    FOR w% = 0 TO 72
  1341.     y% = y% + (16 * (w% / 100))
  1342.     _PUTIMAGE (168, 373 - y%), EndSprtA, _DISPLAY, (98, 0)-(113, 15)
  1343.     SELECT CASE INT(RND * 3) + 1
  1344.      CASE 1
  1345.       _PUTIMAGE (167, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1346.      CASE 2
  1347.       _PUTIMAGE (167, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1348.      CASE 3
  1349.       _PUTIMAGE (167, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1350.     END SELECT
  1351.     _DELAY .05
  1352.     _PUTIMAGE (168, 388 - y%), EndScrnA, _DISPLAY, (168 + 59, 373 + 10 - y%)-(184 + 59, 388 + 10 - y%)
  1353.     _PUTIMAGE (168, 388 - y%), EndScrnA, _DISPLAY, (168 + 59, 389 + 10 - y%)-(184 + 59, 405 + 10 - y%)
  1354.    NEXT w%
  1355.   CASE 50000 TO 74999
  1356.    _PUTIMAGE (168, 357), EndSprtA, _DISPLAY, (82, 0)-(97, 31)
  1357.    _DELAY 2.75
  1358.    FOR w% = 0 TO 72
  1359.     y% = y% + (16 * (w% / 100))
  1360.     _PUTIMAGE (168, 357 - y%), EndSprtA, _DISPLAY, (82, 0)-(97, 31)
  1361.     SELECT CASE INT(RND * 3) + 1
  1362.      CASE 1
  1363.       _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1364.      CASE 2
  1365.       _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1366.      CASE 3
  1367.       _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1368.     END SELECT
  1369.     _DELAY .05
  1370.     _PUTIMAGE (168, 356 - y%), EndScrnA, _DISPLAY, (168 + 59, 357 + 10 - y%)-(184 + 59, 389 + 10 - y%)
  1371.     _PUTIMAGE (168, 388 - y%), EndScrnA, _DISPLAY, (168 + 59, 389 + 10 - y%)-(184 + 59, 405 + 10 - y%)
  1372.    NEXT w%
  1373.   CASE 75000 TO 99999
  1374.    _PUTIMAGE (160, 325), EndSprtA, _DISPLAY, (50, 0)-(79, 63)
  1375.    _DELAY 2.75
  1376.    FOR w% = 0 TO 72
  1377.     y% = y% + (16 * (w% / 100))
  1378.     _PUTIMAGE (160, 325 - y%), EndSprtA, _DISPLAY, (50, 0)-(79, 63)
  1379.     SELECT CASE INT(RND * 3) + 1
  1380.      CASE 1
  1381.       _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1382.       _PUTIMAGE (172, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1383.      CASE 2
  1384.       _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1385.       _PUTIMAGE (172, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1386.      CASE 3
  1387.       _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1388.       _PUTIMAGE (172, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1389.     END SELECT
  1390.     _DELAY .05
  1391.     _PUTIMAGE (160, 325 - y%), EndScrnA, _DISPLAY, (160 + 59, 325 + 10 - y%)-(192 + 59, 389 + 10 - y%)
  1392.     _PUTIMAGE (160, 388 - y%), EndScrnA, _DISPLAY, (160 + 59, 389 + 10 - y%)-(192 + 59, 405 + 10 - y%)
  1393.    NEXT w%
  1394.   CASE 100000 TO 149999
  1395.    _PUTIMAGE (160, 278), EndSprtA, _DISPLAY, (0, 0)-(49, 112)
  1396.    _DELAY 2.75
  1397.    FOR w% = 0 TO 72
  1398.     y% = y% + (16 * (w% / 100))
  1399.     _PUTIMAGE (160, 278 - y%), EndSprtA, _DISPLAY, (0, 0)-(49, 112)
  1400.     SELECT CASE INT(RND * 3) + 1
  1401.      CASE 1
  1402.       _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1403.       _PUTIMAGE (177, 389 - y%), EndSprtA, _DISPLAY, (0, 114)-(15, 129)
  1404.       _PUTIMAGE (192, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1405.      CASE 2
  1406.       _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1407.       _PUTIMAGE (176, 389 - y%), EndSprtA, _DISPLAY, (16, 114)-(33, 129)
  1408.       _PUTIMAGE (192, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1409.      CASE 3
  1410.       _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1411.       _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (0, 130)-(31, 161)
  1412.       _PUTIMAGE (192, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1413.     END SELECT
  1414.     _DELAY .05
  1415.     _PUTIMAGE (160, 278 - y%), EndScrnA, _DISPLAY, (160 + 59, 279 + 10 - y%)-(212 + 59, 389 + 10 - y%)
  1416.     _PUTIMAGE (160, 388 - y%), EndScrnA, _DISPLAY, (160 + 59, 389 + 10 - y%)-(212 + 59, 421 + 10 - y%)
  1417.    NEXT w%
  1418.   CASE IS > 150000
  1419.  COLOR _RGB(255, 255, 255), _RGB32(0, 0, 0)
  1420.  
  1421. SUB HighScoreScreen
  1422.  DIM names(6) AS STRING * 1
  1423.  _PUTIMAGE (5, 5), HighS, _DISPLAY, (64, 16)-(574, 462)
  1424.  IF G.Mode = TypeA THEN
  1425.   ShowHighScoreA
  1426.   IF P.Score > G.HScore1 THEN
  1427.    G.HScore1 = P.Score: G.Hlevel1 = G.Level
  1428.    _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1)))) + LTRIM$(STR$(G.HScore1))
  1429.    _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1)))) + LTRIM$(STR$(G.Hlevel1))
  1430.    lv%% = 1: ltr%% = 65: G.HName1 = "      "
  1431.    names(1) = "A"
  1432.    FOR w%% = 2 TO 6
  1433.     names(w%%) = " "
  1434.    NEXT w%%
  1435.    DO
  1436.     kbd& = _KEYHIT
  1437.     SELECT CASE kbd&
  1438.      CASE 19200 'left
  1439.       IF lv%% > 1 THEN lv%% = lv%% - 1
  1440.       ltr%% = ASC(names(lv%%))
  1441.      CASE 19712 'right
  1442.       IF lv%% < 6 THEN lv%% = lv%% + 1
  1443.       ltr%% = ASC(names(lv%%))
  1444.      CASE 18432 'up
  1445.       ltr%% = ltr%% + 1
  1446.       IF ltr%% = 91 THEN ltr%% = 64
  1447.      CASE 20480 'down
  1448.       ltr%% = ltr%% - 1
  1449.       IF ltr%% = 63 THEN ltr%% = 90
  1450.      CASE 13, 27
  1451.       exitflag%% = TRUE
  1452.     END SELECT
  1453.     IF ltr%% = 64 THEN ltr%% = 32
  1454.     names(lv%%) = CHR$(ltr%%)
  1455.     IF ltr%% = 32 THEN ltr%% = 64
  1456.     G.HName1 = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1457.     _PRINTSTRING (150, 306), G.HName1
  1458.     LINE (150 + ((lv%% - 1) * 16), 326)-(166 + ((lv%% - 1) * 16), 328), _RGB32(212, 64, 48), BF
  1459.     _DELAY .02
  1460.     LINE (150, 326)-(256, 328), _RGB32(0, 0, 0), BF
  1461.    LOOP UNTIL exitflag%%
  1462.   ELSEIF P.Score > G.HScore2 THEN
  1463.    G.HScore2 = P.Score: G.Hlevel2 = G.Level
  1464.    _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2)))) + LTRIM$(STR$(G.HScore2))
  1465.    _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2)))) + LTRIM$(STR$(G.Hlevel2))
  1466.    lv%% = 1: ltr%% = 65: G.HName2 = "      "
  1467.    FOR w%% = 1 TO 6
  1468.     names(w%%) = " "
  1469.    NEXT w%%
  1470.    DO
  1471.     kbd& = _KEYHIT
  1472.     SELECT CASE kbd&
  1473.      CASE 19200 'left
  1474.       IF lv%% > 1 THEN lv%% = lv%% - 1
  1475.       ltr%% = ASC(names(lv%%))
  1476.      CASE 19712 'right
  1477.       IF lv%% < 6 THEN lv%% = lv%% + 1
  1478.       ltr%% = ASC(names(lv%%))
  1479.      CASE 18432 'up
  1480.       ltr%% = ltr%% + 1
  1481.       IF ltr%% = 91 THEN ltr%% = 64
  1482.      CASE 20480 'down
  1483.       ltr%% = ltr%% - 1
  1484.       IF ltr%% = 63 THEN ltr%% = 90
  1485.      CASE 13, 27
  1486.       exitflag%% = TRUE
  1487.     END SELECT
  1488.     IF ltr%% = 64 THEN ltr%% = 32
  1489.     names(lv%%) = CHR$(ltr%%)
  1490.     IF ltr%% = 32 THEN ltr%% = 64
  1491.     G.HName2 = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1492.     _PRINTSTRING (150, 338), G.HName2
  1493.     LINE (150 + ((lv%% - 1) * 16), 358)-(166 + ((lv%% - 1) * 16), 360), _RGB32(212, 64, 48), BF
  1494.     _DELAY .02
  1495.     LINE (150, 358)-(256, 360), _RGB32(0, 0, 0), BF
  1496.    LOOP UNTIL exitflag%%
  1497.   ELSEIF P.Score > G.HScore3 THEN
  1498.    G.HScore3 = P.Score: G.Hlevel3 = G.Level
  1499.    _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3)))) + LTRIM$(STR$(G.HScore3))
  1500.    _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3)))) + LTRIM$(STR$(G.Hlevel3))
  1501.    lv%% = 1: ltr%% = 65: G.HName3 = "      "
  1502.    FOR w%% = 1 TO 6
  1503.     names(w%%) = " "
  1504.    NEXT w%%
  1505.    DO
  1506.     kbd& = _KEYHIT
  1507.     SELECT CASE kbd&
  1508.      CASE 19200 'left
  1509.       IF lv%% > 1 THEN lv%% = lv%% - 1
  1510.       ltr%% = ASC(names(lv%%))
  1511.      CASE 19712 'right
  1512.       IF lv%% < 6 THEN lv%% = lv%% + 1
  1513.       ltr%% = ASC(names(lv%%))
  1514.      CASE 18432 'up
  1515.       ltr%% = ltr%% + 1
  1516.       IF ltr%% = 91 THEN ltr%% = 64
  1517.      CASE 20480 'down
  1518.       ltr%% = ltr%% - 1
  1519.       IF ltr%% = 63 THEN ltr%% = 90
  1520.      CASE 13, 27
  1521.       exitflag%% = TRUE
  1522.     END SELECT
  1523.     IF ltr%% = 64 THEN ltr%% = 32
  1524.     names(lv%%) = CHR$(ltr%%)
  1525.     IF ltr%% = 32 THEN ltr%% = 64
  1526.     G.HName3 = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1527.     _PRINTSTRING (150, 370), G.HName3
  1528.     LINE (150 + ((lv%% - 1) * 16), 390)-(166 + ((lv%% - 1) * 16), 392), _RGB32(212, 64, 48), BF
  1529.     _DELAY .02
  1530.     LINE (150, 390)-(256, 392), _RGB32(0, 0, 0), BF
  1531.    LOOP UNTIL exitflag%%
  1532.   END IF
  1533.  
  1534.   ShowHighScoreB
  1535.   IF P.Score > G.HScore1B THEN
  1536.    G.HScore1B = P.Score: G.Hlevel1B = G.Level
  1537.    _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1B)))) + LTRIM$(STR$(G.HScore1B))
  1538.    _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1B)))) + LTRIM$(STR$(G.Hlevel1B))
  1539.    lv%% = 1: ltr%% = 65: G.HName1B = "      "
  1540.    FOR w%% = 1 TO 6
  1541.     names(w%%) = " "
  1542.    NEXT w%%
  1543.    DO
  1544.     kbd& = _KEYHIT
  1545.     SELECT CASE kbd&
  1546.      CASE 19200 'left
  1547.       IF lv%% > 1 THEN lv%% = lv%% - 1
  1548.       ltr%% = ASC(names(lv%%))
  1549.      CASE 19712 'right
  1550.       IF lv%% < 6 THEN lv%% = lv%% + 1
  1551.       ltr%% = ASC(names(lv%%))
  1552.      CASE 18432 'up
  1553.       ltr%% = ltr%% + 1
  1554.       IF ltr%% = 91 THEN ltr%% = 64
  1555.      CASE 20480 'down
  1556.       ltr%% = ltr%% - 1
  1557.       IF ltr%% = 63 THEN ltr%% = 90
  1558.      CASE 13, 27
  1559.       exitflag%% = TRUE
  1560.     END SELECT
  1561.     IF ltr%% = 64 THEN ltr%% = 32
  1562.     names(lv%%) = CHR$(ltr%%)
  1563.     IF ltr%% = 32 THEN ltr%% = 64
  1564.     G.HName1B = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1565.     _PRINTSTRING (150, 306), G.HName1B
  1566.     LINE (150 + ((lv%% - 1) * 16), 326)-(166 + ((lv%% - 1) * 16), 328), _RGB32(212, 64, 48), BF
  1567.     _DELAY .02
  1568.     LINE (150, 326)-(256, 328), _RGB32(0, 0, 0), BF
  1569.    LOOP UNTIL exitflag%%
  1570.   ELSEIF P.Score > G.HScore2B THEN
  1571.    G.HScore2B = P.Score: G.Hlevel2B = G.Level
  1572.    _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2B)))) + LTRIM$(STR$(G.HScore2B))
  1573.    _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2B)))) + LTRIM$(STR$(G.Hlevel2B))
  1574.    lv%% = 1: ltr%% = 65: G.HName2B = "      "
  1575.    FOR w%% = 1 TO 6
  1576.     names(w%%) = " "
  1577.    NEXT w%%
  1578.    DO
  1579.     kbd& = _KEYHIT
  1580.     SELECT CASE kbd&
  1581.      CASE 19200 'left
  1582.       IF lv%% > 1 THEN lv%% = lv%% - 1
  1583.       ltr%% = ASC(names(lv%%))
  1584.      CASE 19712 'right
  1585.       IF lv%% < 6 THEN lv%% = lv%% + 1
  1586.       ltr%% = ASC(names(lv%%))
  1587.      CASE 18432 'up
  1588.       ltr%% = ltr%% + 1
  1589.       IF ltr%% = 91 THEN ltr%% = 64
  1590.      CASE 20480 'down
  1591.       ltr%% = ltr%% - 1
  1592.       IF ltr%% = 63 THEN ltr%% = 90
  1593.      CASE 13, 27
  1594.       exitflag%% = TRUE
  1595.     END SELECT
  1596.     IF ltr%% = 64 THEN ltr%% = 32
  1597.     names(lv%%) = CHR$(ltr%%)
  1598.     IF ltr%% = 32 THEN ltr%% = 64
  1599.     G.HName2B = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1600.     _PRINTSTRING (150, 338), G.HName2B
  1601.     LINE (150 + ((lv%% - 1) * 16), 358)-(166 + ((lv%% - 1) * 16), 360), _RGB32(212, 64, 48), BF
  1602.     _DELAY .02
  1603.     LINE (150, 358)-(256, 360), _RGB32(0, 0, 0), BF
  1604.    LOOP UNTIL exitflag%%
  1605.   ELSEIF P.Score > G.HScore3B THEN
  1606.    G.HScore3B = P.Score: G.Hlevel3B = G.Level
  1607.    _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3B)))) + LTRIM$(STR$(G.HScore3B))
  1608.    _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3B)))) + LTRIM$(STR$(G.Hlevel3B))
  1609.    lv%% = 1: ltr%% = 65: G.HName3B = "      "
  1610.    FOR w%% = 1 TO 6
  1611.     names(w%%) = " "
  1612.    NEXT w%%
  1613.    DO
  1614.     kbd& = _KEYHIT
  1615.     SELECT CASE kbd&
  1616.      CASE 19200 'left
  1617.       IF lv%% > 1 THEN lv%% = lv%% - 1
  1618.       ltr%% = ASC(names(lv%%))
  1619.      CASE 19712 'right
  1620.       IF lv%% < 6 THEN lv%% = lv%% + 1
  1621.       ltr%% = ASC(names(lv%%))
  1622.      CASE 18432 'up
  1623.       ltr%% = ltr%% + 1
  1624.       IF ltr%% = 91 THEN ltr%% = 64
  1625.      CASE 20480 'down
  1626.       ltr%% = ltr%% - 1
  1627.       IF ltr%% = 63 THEN ltr%% = 90
  1628.      CASE 13, 27
  1629.       exitflag%% = TRUE
  1630.     END SELECT
  1631.     IF ltr%% = 64 THEN ltr%% = 32
  1632.     names(lv%%) = CHR$(ltr%%)
  1633.     IF ltr%% = 32 THEN ltr%% = 64
  1634.     G.HName3B = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1635.     _PRINTSTRING (150, 370), G.HName3B
  1636.     LINE (150 + ((lv%% - 1) * 16), 390)-(166 + ((lv%% - 1) * 16), 392), _RGB32(212, 64, 48), BF
  1637.     _DELAY .02
  1638.     LINE (150, 390)-(256, 392), _RGB32(0, 0, 0), BF
  1639.    LOOP UNTIL exitflag%%
  1640.   END IF
  1641.  
  1642. SUB ShowHighScoreA
  1643.  _PRINTSTRING (150, 306), G.HName1
  1644.  _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1)))) + LTRIM$(STR$(G.HScore1))
  1645.  _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1)))) + LTRIM$(STR$(G.Hlevel1))
  1646.  _PRINTSTRING (150, 338), G.HName2
  1647.  _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2)))) + LTRIM$(STR$(G.HScore2))
  1648.  _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2)))) + LTRIM$(STR$(G.Hlevel2))
  1649.  _PRINTSTRING (150, 370), G.HName3
  1650.  _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3)))) + LTRIM$(STR$(G.HScore3))
  1651.  _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3)))) + LTRIM$(STR$(G.Hlevel3))
  1652.  
  1653. SUB ShowHighScoreB
  1654.  _PRINTSTRING (150, 306), G.HName1B
  1655.  _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1B)))) + LTRIM$(STR$(G.HScore1B))
  1656.  _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1B)))) + LTRIM$(STR$(G.Hlevel1B))
  1657.  _PRINTSTRING (150, 338), G.HName2B
  1658.  _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2B)))) + LTRIM$(STR$(G.HScore2B))
  1659.  _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2B)))) + LTRIM$(STR$(G.Hlevel2B))
  1660.  _PRINTSTRING (150, 370), G.HName3B
  1661.  _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3B)))) + LTRIM$(STR$(G.HScore3B))
  1662.  _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3B)))) + LTRIM$(STR$(G.Hlevel3B))
  1663.  
  1664. SUB MoveLeft
  1665.  SELECT CASE P.Piece
  1666.   CASE T, J, L
  1667.    SELECT CASE P.Orent
  1668.     CASE 1, 2, 3
  1669.      IF P.PieceX = 1 THEN P.PieceX = 2
  1670.     CASE 4
  1671.      IF P.PieceX = 0 THEN P.PieceX = 1
  1672.    END SELECT
  1673.   CASE Z
  1674.    SELECT CASE P.Orent
  1675.     CASE 1 TO 4
  1676.      IF P.PieceX = 1 THEN P.PieceX = 2
  1677.    END SELECT
  1678.   CASE S
  1679.    SELECT CASE P.Orent
  1680.     CASE 1, 3
  1681.      IF P.PieceX = 1 THEN P.PieceX = 2
  1682.     CASE 2, 4
  1683.      IF P.PieceX = 0 THEN P.PieceX = 1
  1684.    END SELECT
  1685.   CASE O
  1686.    SELECT CASE P.Orent
  1687.     CASE 1 TO 4
  1688.      IF P.PieceX = 1 THEN P.PieceX = 2
  1689.    END SELECT
  1690.   CASE I
  1691.    SELECT CASE P.Orent
  1692.     CASE 2, 4
  1693.      IF P.PieceX = 0 THEN P.PieceX = 1
  1694.     CASE 1, 3
  1695.      IF P.PieceX = 1 THEN P.PieceX = 2
  1696.    END SELECT
  1697.  
  1698. SUB MoveRight
  1699.  SELECT CASE P.Piece
  1700.   CASE T, J, L
  1701.    SELECT CASE P.Orent
  1702.     CASE 1, 3, 4
  1703.      IF P.PieceX = 10 THEN P.PieceX = 9
  1704.     CASE 2
  1705.      IF P.PieceX = 11 THEN P.PieceX = 10
  1706.    END SELECT
  1707.   CASE Z
  1708.    SELECT CASE P.Orent
  1709.     CASE 1, 3
  1710.      IF P.PieceX = 10 THEN P.PieceX = 9
  1711.     CASE 2, 4
  1712.      IF P.PieceX = 11 THEN P.PieceX = 10
  1713.    END SELECT
  1714.   CASE S
  1715.    SELECT CASE P.Orent
  1716.     CASE 1, 3
  1717.      IF P.PieceX = 10 THEN P.PieceX = 9
  1718.     CASE 2, 4
  1719.      IF P.PieceX = 10 THEN P.PieceX = 9
  1720.    END SELECT
  1721.   CASE O
  1722.    SELECT CASE P.Orent
  1723.     CASE 1 TO 4
  1724.      IF P.PieceX = 11 THEN P.PieceX = 10
  1725.    END SELECT
  1726.   CASE I
  1727.    SELECT CASE P.Orent
  1728.     CASE 2, 4
  1729.      IF P.PieceX = 11 THEN P.PieceX = 10
  1730.     CASE 1, 3
  1731.      IF P.PieceX = 9 THEN P.PieceX = 8
  1732.    END SELECT
  1733.  
  1734. SUB StartData
  1735.  IF G.HScore1 = 0 THEN
  1736.   G.BGMVol = 50
  1737.   G.SFXVol = 50
  1738.   G.Mode = TypeA
  1739.   G.BGM = Song1
  1740.   G.HScore1 = 15000
  1741.   G.HScore2 = 10000
  1742.   G.HScore3 = 5000
  1743.   G.Hlevel1 = 10
  1744.   G.Hlevel2 = 5
  1745.   G.Hlevel3 = 1
  1746.   G.HName1 = "Narika"
  1747.   G.HName2 = "Cobalt"
  1748.   G.HName3 = "Ninten"
  1749.   G.HScore1B = 5000
  1750.   G.HScore2B = 3000
  1751.   G.HScore3B = 1000
  1752.   G.Hlevel1B = 10
  1753.   G.Hlevel2B = 5
  1754.   G.Hlevel3B = 1
  1755.   G.HName1B = "Nobody"
  1756.   G.HName2B = "anybdy"
  1757.   G.HName3B = "losers"
  1758.  
  1759.   G.Level = 0
  1760.   P.Score = 0
  1761.   G.GameOverFlag = FALSE
  1762.   G.Level = 0
  1763.   P.Score = 0
  1764.   P.Lines = 0
  1765.   BoardSetup
  1766.  
  1767. SUB BTypeHeight
  1768.  'Btype height * 3 lines
  1769.  IF G.Height > 0 THEN
  1770.   FOR y%% = 20 TO (20 - (G.Height * 3)) + 1 STEP -1
  1771.    FOR x%% = 1 TO 10
  1772.     garbage%% = INT(RND * 100) + 1
  1773.     IF garbage%% > 45 THEN Board(x%%, y%%) = INT(RND * 3)
  1774.    NEXT x%%
  1775.   NEXT y%%
  1776.  
  1777. SUB GameModeA
  1778.  LINE (0, 0)-(799, 480), _RGB32(0, 0, 0), BF
  1779.  _PUTIMAGE (5, 5), FieldA, _DISPLAY, (64, 16)-(574, 462)
  1780.  P.NextP = INT(RND * 7) + 1
  1781.  NewPiece
  1782.  PlaceTetraNome
  1783.  TIMER(TI(G.Level)) ON
  1784.  DO
  1785.   KBD& = _KEYHIT
  1786.   SELECT CASE KBD&
  1787.    CASE 19200 'left
  1788.     IF NOT CollisionLeft THEN
  1789.      IF G.Sound THEN _SNDPLAY SFX(4)
  1790.      P.PieceX = P.PieceX - 1
  1791.      MoveLeft
  1792.     END IF
  1793.    CASE 19712 'right
  1794.     IF NOT CollisionRight THEN
  1795.      IF G.Sound THEN _SNDPLAY SFX(4)
  1796.      P.PieceX = P.PieceX + 1
  1797.      MoveRight
  1798.     END IF
  1799.    CASE 20480 'Down
  1800.     IF ButtonHeld%% = FALSE THEN 'if player holds the down arrow switch to faster timer
  1801.      TIMER(TI(G.Level)) OFF
  1802.      TIMER(TI(10)) ON
  1803.      ButtonHeld%% = TRUE
  1804.     END IF
  1805.    CASE 32 'space
  1806.     'rotational point is second block, top row if app.
  1807.     IF NOT CollisionRotate THEN
  1808.      P.Orent = P.Orent + 1
  1809.      IF P.Orent = 5 THEN P.Orent = 1
  1810.      IF G.Sound THEN _SNDPLAY SFX(3)
  1811.      SELECT CASE P.Piece
  1812.       CASE T, J, L
  1813.        'if piece is to close to edge to rotate then bump it out 1
  1814.        IF P.PieceX = 1 AND P.Orent <> 4 THEN P.PieceX = 2
  1815.        IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1816.       CASE Z
  1817.        IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1818.       CASE O
  1819.       CASE S
  1820.        IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1821.       CASE I
  1822.        IF P.PieceX = 1 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 2
  1823.        IF P.PieceX = 10 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 8
  1824.      END SELECT
  1825.     END IF
  1826.     _KEYCLEAR
  1827.    CASE 27 'Esc
  1828.     exitflag%% = TRUE
  1829.     QuitGameFlag%% = TRUE
  1830.  
  1831.   IF NOT _KEYDOWN(20480) AND ButtonHeld%% THEN 'if player releases the down arrow restore timer
  1832.    ButtonHeld%% = FALSE
  1833.    TIMER(TI(10)) OFF
  1834.    TIMER(TI(G.Level)) ON
  1835.    P.bonus = 0
  1836.   END IF
  1837.  
  1838.   LINE (197, 85)-(197 + 159, 85 + 319), _RGB32(0, 0, 0), BF
  1839.   DrawBoard
  1840.   PlaceTetraNome
  1841.   _DELAY .01
  1842.   IF G.GameOverFlag THEN exitflag%% = TRUE
  1843.  LOOP UNTIL exitflag%%
  1844.  TIMER(TI(G.Level)) OFF
  1845.  
  1846. SUB GameModeB
  1847.  LINE (0, 0)-(799, 480), _RGB32(0, 0, 0), BF
  1848.  _PUTIMAGE (5, 5), FieldB, _DISPLAY, (64, 16)-(574, 462)
  1849.  P.NextP = INT(RND * 7) + 1
  1850.  BTypeHeight
  1851.  NewPiece
  1852.  PlaceTetraNome
  1853.  TIMER(TI(G.Level)) ON
  1854.  DO
  1855.   KBD& = _KEYHIT
  1856.   SELECT CASE KBD&
  1857.    CASE 19200 'left
  1858.     IF NOT CollisionLeft THEN
  1859.      IF G.Sound THEN _SNDPLAY SFX(4)
  1860.      P.PieceX = P.PieceX - 1
  1861.      MoveLeft
  1862.     END IF
  1863.    CASE 19712 'right
  1864.     IF NOT CollisionRight THEN
  1865.      IF G.Sound THEN _SNDPLAY SFX(4)
  1866.      P.PieceX = P.PieceX + 1
  1867.      MoveRight
  1868.     END IF
  1869.    CASE 20480 'Down
  1870.     IF ButtonHeld%% = FALSE THEN 'if player holds the down arrow switch to faster timer
  1871.      TIMER(TI(G.Level)) OFF
  1872.      TIMER(TI(10)) ON
  1873.      ButtonHeld%% = TRUE
  1874.     END IF
  1875.    CASE 32 'space
  1876.     'rotational point is second block, top row if app.
  1877.     IF NOT CollisionRotate THEN
  1878.      IF G.Sound THEN _SNDPLAY SFX(3)
  1879.      P.Orent = P.Orent + 1
  1880.      IF P.Orent = 5 THEN P.Orent = 1
  1881.      SELECT CASE P.Piece
  1882.       CASE T, J, L
  1883.        'if piece is to close to edge to rotate then bump it out 1
  1884.        IF P.PieceX = 1 AND P.Orent <> 4 THEN P.PieceX = 2
  1885.        IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1886.       CASE Z
  1887.        IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1888.       CASE O
  1889.       CASE S
  1890.        IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1891.       CASE I
  1892.        IF P.PieceX = 1 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 2
  1893.        IF P.PieceX = 10 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 8
  1894.      END SELECT
  1895.     END IF
  1896.     _KEYCLEAR
  1897.    CASE 27 'Esc
  1898.     exitflag%% = TRUE
  1899.     QuitGameFlag%% = TRUE
  1900.  
  1901.   IF NOT _KEYDOWN(20480) AND ButtonHeld%% THEN 'if player releases the down arrow restore timer
  1902.    ButtonHeld%% = FALSE
  1903.    TIMER(TI(10)) OFF
  1904.    TIMER(TI(G.Level)) ON
  1905.    P.bonus = 0
  1906.   END IF
  1907.  
  1908.   LINE (197, 85)-(197 + 159, 85 + 319), _RGB32(0, 0, 0), BF
  1909.   DrawBoard
  1910.   PlaceTetraNome
  1911.   _DELAY .01
  1912.   IF G.GameOverFlag THEN exitflag%% = TRUE
  1913.  LOOP UNTIL exitflag%%
  1914.  TIMER(TI(G.Level)) OFF
  1915.  
  1916. SUB DisplayClickOptions
  1917.  _PRINTSTRING (570, 130), "Click here"
  1918.  _PRINTSTRING (570, 150), "to Continue"
  1919.  
  1920.  _PRINTSTRING (570, 200), "Click here"
  1921.  _PRINTSTRING (570, 220), "to go Back"
  1922.  
  1923.  _PRINTSTRING (570, 400), "Click here"
  1924.  _PRINTSTRING (570, 420), "Exit Game"
  1925.  
  1926. FUNCTION LoadGFX& (Foff&, Size&)
  1927.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1928.  OPEN "temp.dat" FOR BINARY AS #3
  1929.  dat$ = SPACE$(Size&)
  1930.  GET #1, Foff&, dat$
  1931.  PUT #3, , dat$
  1932.  CLOSE #3
  1933.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  1934.  
  1935. SUB EndScreenB
  1936.  ST1& = _FREETIMER
  1937.  ON TIMER(ST1&, .025) TypeBAnimation
  1938.  CLS
  1939.  COLOR _RGB32(250, 250, 250), _RGB32(0, 89, 251)
  1940.  LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  1941.  _PUTIMAGE (5, 5), EndScrnB, _DISPLAY, (64, 16)-(574, 462)
  1942.  _PUTIMAGE (112, 68), EndScrnB, _DISPLAY, (100, 180)-(210, 220)
  1943.  _PUTIMAGE (116, 71), EndScrnB, _DISPLAY, (176, 80)-(254, 93)
  1944.  _PUTIMAGE (116, 89), EndScrnB, _DISPLAY, (176, 96)-(272, 110)
  1945.  v$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(P.Score)))) + LTRIM$(STR$(P.Score))
  1946.  v1$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.Level * 1000)))) + LTRIM$(STR$(G.Level * 1000))
  1947.  v2$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.Height * 1000)))) + LTRIM$(STR$(G.Height * 1000))
  1948.  v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  1949.  _PRINTSTRING (225, 50), v$, _DISPLAY
  1950.  _PRINTSTRING (225, 68), v1$, _DISPLAY
  1951.  _PRINTSTRING (225, 86), v2$, _DISPLAY
  1952.  _PRINTSTRING (225, 130), v3$, _DISPLAY
  1953.  
  1954.  _PUTIMAGE (0, 0), _DISPLAY, Temp&, (0, 0)-(511, 479) 'make backup of screen
  1955.  TIMER(ST1&) ON
  1956.  _DELAY 1
  1957.  total& = P.Score
  1958.  _PRINTSTRING (225, 50), v3$, _DISPLAY
  1959.  _PRINTSTRING (225, 50), v3$, Temp&
  1960.  v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  1961.  _PRINTSTRING (225, 130), v3$, _DISPLAY
  1962.  _PRINTSTRING (225, 130), v3$, Temp&
  1963.  _DELAY .25
  1964.  b1% = G.Level * 1000
  1965.  FOR w% = b1% TO 0 STEP -100
  1966.   total& = total& + 100
  1967.   v1$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(w%)))) + LTRIM$(STR$(w%))
  1968.   _PRINTSTRING (225, 68), v1$, _DISPLAY
  1969.   _PRINTSTRING (225, 68), v1$, Temp&
  1970.   v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  1971.   _PRINTSTRING (225, 130), v3$, _DISPLAY
  1972.   _PRINTSTRING (225, 130), v3$, Temp&
  1973.   _DELAY .05
  1974.  NEXT w%
  1975.  b1% = G.Height * 1000
  1976.  FOR w% = b1% TO 0 STEP -100
  1977.   total& = total& + 100
  1978.   v2$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(w%)))) + LTRIM$(STR$(w%))
  1979.   _PRINTSTRING (225, 86), v2$, _DISPLAY
  1980.   _PRINTSTRING (225, 86), v2$, Temp&
  1981.   v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  1982.   _PRINTSTRING (225, 130), v3$, _DISPLAY
  1983.   _PRINTSTRING (225, 130), v3$, Temp&
  1984.   _DELAY .05
  1985.  NEXT w%
  1986.  COLOR _RGB32(254, 254, 254), _RGB32(0, 0, 0)
  1987.  DO: _DELAY .02: LOOP UNTIL INKEY$ = CHR$(13)
  1988.  TIMER(ST1&) OFF
  1989.  TIMER(ST1&) FREE
  1990.  
  1991. SUB TypeBAnimation
  1992.  STATIC Frame%%, Xloc%(5), Yloc%(5)
  1993.  _FONT 16
  1994.  SELECT CASE G.Level
  1995.   CASE 0
  1996.    FOR w%% = 1 TO G.Height + 1
  1997.     LOCATE w%%, 65: PRINT Xloc%(w%%); Frame%%
  1998.     IF Yloc%(w%%) = 0 THEN Yloc%(w%%) = INT(RND * 300) + 100
  1999.     '    IF Yloc%(w%%) > 120 AND Yloc%(w%%) < 146 THEN Yloc%(w%%) = Yloc%(w%%) + INT(RND * 64) + 16
  2000.     IF Xloc%(w%%) = 0 THEN Xloc%(w%%) = INT(RND * 100) - 50
  2001.     IF Xloc%(w%%) > 32 THEN LINE (Xloc%(w%%), Yloc%(w%%))-(Xloc%(w%%) + 16, Yloc%(w%%) + 16), _RGB32(0, 89, 251), B
  2002.     '    _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), EndScrnB, _DISPLAY, (59 + Xloc%(w%%), 11 + Yloc%(w%%))-(59 + Xloc%(w%%) + 16, 11 + Yloc%(w%%) + 16)
  2003.     _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), Temp&, _DISPLAY, (Xloc%(w%%), Yloc%(w%%))-(Xloc%(w%%) + 16, Yloc%(w%%) + 16)
  2004.  
  2005.     Xloc%(w%%) = Xloc%(w%%) + 1: IF Xloc%(w%%) > 460 THEN Xloc%(w%%) = INT(RND * 100) - 50: Yloc%(w%%) = INT(RND * 300) + 100
  2006.     SELECT CASE Frame%%
  2007.      CASE 1 TO 12
  2008.       IF Xloc%(w%%) > 32 THEN _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), EndSprtA, _DISPLAY, (50, 77)-(65, 92)
  2009.      CASE 13 TO 24
  2010.       IF Xloc%(w%%) > 32 THEN _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), EndSprtA, _DISPLAY, (66, 77)-(81, 92)
  2011.     END SELECT
  2012.     Frame%% = Frame%% + 1: IF Frame%% = 25 THEN Frame%% = 1
  2013.    NEXT w%%
  2014.   CASE 1
  2015.   CASE 2
  2016.   CASE 3
  2017.   CASE 4
  2018.  
  2019.  _FONT FFX(1)
  2020.  

A section from EndScreenB:
....
....
FOR w% = b1% TO 0 STEP -100
  total& = total& + 100
  v2$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(w%)))) + LTRIM$(STR$(w%))
  _PRINTSTRING (225, 86), v2$, _DISPLAY
  _PRINTSTRING (225, 86), v2$, Temp& '<---Not displaying correctly, not going to correct layer
  v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  _PRINTSTRING (225, 130), v3$, _DISPLAY
  _PRINTSTRING (225, 130), v3$, Temp& '<---Not displaying correctly, not going to correct layer
  _DELAY .05
 NEXT w%
....
....
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Problem with _PRINTSTRING
« Reply #1 on: October 16, 2018, 12:43:44 pm »
Try setting _DEST before using _PRINTSTRING instead of passing it as a parameter. Does it work as expected that way?

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem with _PRINTSTRING
« Reply #2 on: October 16, 2018, 01:02:45 pm »
It moves it to the right layer but still ignores the FONT and COLOR.
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problem with _PRINTSTRING
« Reply #3 on: October 16, 2018, 01:14:01 pm »
Hi. Try add next parameter to FONT statement" IF FFX(1) THEN _FONT FFX(1), Temp& on line 173, if it help

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Problem with _PRINTSTRING
« Reply #4 on: October 16, 2018, 01:21:31 pm »
This line:

    COLOR _RGB32(254, 254, 254), _RGB32(0, 0, 0) in sub EndScreenB is for which screen?

I repair it (bud not nice) so:

Code: QB64: [Select]
  1. 'Tetris 64 Ver 0.9 [start date 10/3/18-13.27]
  2. 'v0.9: (last build on 10/13/2018-13:25)
  3. 'add 'no sound' option
  4. 'add level selection in Menu A to game value
  5. 'add B-Type menu
  6. 'small rocket ending done
  7. 'med rocket ending done
  8. 'Large rocket ending done
  9. 'Shuttle ending done
  10. 'High Score screen Atype done
  11. 'high score screen Btype done
  12. 'Fix rotational collisions
  13. 'divorced Narika from code
  14. 'B-Type game functional
  15. '** found new bug with rotational collisions (10/11/2018) **
  16. '
  17. TYPE GameData
  18.     Mode AS _BYTE 'game type A or B
  19.     BGM AS _BYTE 'Back Gound music 1,2,3
  20.     BGMVol AS _BYTE 'Back Gound Music Volume
  21.     SFXVol AS _BYTE 'Sound effects Volume
  22.     Level AS _BYTE 'game level
  23.     Height AS _BYTE 'line height B-type game
  24.     HScore1 AS LONG 'Highest Score
  25.     HScore2 AS LONG 'Higher Score
  26.     HScore3 AS LONG 'High Score
  27.     HName1 AS STRING * 6 'High score name
  28.     HName2 AS STRING * 6 ' "    "     "
  29.     HName3 AS STRING * 6 ' "    "     "
  30.     Hlevel1 AS _BYTE
  31.     Hlevel2 AS _BYTE
  32.     Hlevel3 AS _BYTE
  33.     HScore1B AS LONG 'Highest Score B-type
  34.     HScore2B AS LONG 'Higher Score B-type
  35.     HScore3B AS LONG 'High Score B-type
  36.     HName1B AS STRING * 6 'High score name B-Type
  37.     HName2B AS STRING * 6 ' "    "     "
  38.     HName3B AS STRING * 6 ' "    "     "
  39.     Hlevel1B AS _BYTE
  40.     Hlevel2B AS _BYTE
  41.     Hlevel3B AS _BYTE
  42.     GameOverFlag AS _BYTE 'game over
  43.     Sound AS _BYTE 'sound on or off
  44.     Loaded AS _BYTE
  45.  
  46. TYPE CurrentData
  47.     Icount AS INTEGER ' Number of I blocks used in current game
  48.     Ocount AS INTEGER ' Number of O blocks used in current game
  49.     Zcount AS INTEGER ' number of Z blocks used in current game
  50.     Scount AS INTEGER ' number of S blocks used in current game
  51.     Jcount AS INTEGER ' number of J blocks used in current game
  52.     Lcount AS INTEGER ' number of L blocks used in current game
  53.     Tcount AS INTEGER ' number of T blocks used in current game
  54.     Score AS LONG '     Current game score
  55.     Piece AS _BYTE '    The currently dropping piece
  56.     NextP AS _BYTE '    The next piece in the queue
  57.     Lines AS INTEGER '  The lines complete in A-Type, Lines remaining in B-type
  58.     Orent AS _BYTE '    rotational orentation of current piece
  59.     PieceX AS _BYTE '   current Piece's X location on board 1-10
  60.     PieceY AS _BYTE '   current Piece's Y location on board 1-20
  61.     bonus AS _BYTE '    Quick drop bonus +1 for each line while down is pressed
  62.  
  63. DIM SHARED G AS GameData, P AS CurrentData, Board(11, 21) AS _BYTE
  64. DIM SHARED BGM(5) AS LONG, SFX(64) AS LONG, FFX(1) AS LONG
  65. DIM SHARED MenuA AS LONG, MenuB AS LONG, FieldA AS LONG, CharacterA AS LONG
  66. DIM SHARED Nomes AS LONG, Bzone AS LONG, ButtonHeld%%, LandedNew%%
  67. DIM SHARED TI(10) AS LONG, MenuC AS LONG, EndScrnA AS LONG, EndSprtA AS LONG
  68. DIM SHARED HighS AS LONG, FieldB AS LONG, QuitGameFlag%%, MenuID%%
  69. DIM SHARED Splash&, EndScrnB AS LONG, EndScrnB2 AS LONG, Temp&
  70.  
  71. CONST TRUE = -1, FALSE = NOT TRUE
  72. CONST TypeA = 1, TypeB = 2
  73. CONST NoBGM = 0, Song1 = 1, Song2 = 2, Song3 = 3, LoadIt = -1, NoSound = -2
  74. CONST T = 1, O = 2, Z = 3, S = 4, J = 5, L = 6, I = 7
  75. CONST AdjX% = -8, BACK = -2, QUIT = -3
  76.  
  77. FOR w% = 0 TO 10
  78.     TI(w%) = _FREETIMER
  79. NEXT w%
  80. ON TIMER(TI(0), .85) DropPiece
  81. ON TIMER(TI(1), .72) DropPiece
  82. ON TIMER(TI(2), .63) DropPiece
  83. ON TIMER(TI(3), .55) DropPiece
  84. ON TIMER(TI(4), .47) DropPiece
  85. ON TIMER(TI(5), .38) DropPiece
  86. ON TIMER(TI(6), .3) DropPiece
  87. ON TIMER(TI(7), .22) DropPiece
  88. ON TIMER(TI(8), .13) DropPiece
  89. ON TIMER(TI(9), .1) DropPiece
  90. ON TIMER(TI(10), .05) DropPiece
  91. StartData
  92.  
  93. st! = TIMER
  94.  
  95. PRINT "loading.";
  96. LoadGameStuff NoSound 'LoadIt
  97. _CLEARCOLOR _RGB32(0, 0, 0), MenuB
  98. _CLEARCOLOR _RGB32(0, 0, 0), MenuC
  99. _CLEARCOLOR _RGB32(0, 89, 251), EndSprtA
  100. BoardSetup
  101. MenuID%% = 0
  102. G.Height = 3
  103. P.Score = 1340
  104. EndScreenB
  105.     StartData
  106.     IF MenuID%% = -1 THEN TitleScreen
  107.     IF NOT QuitGameFlag%% THEN
  108.         IF MenuID%% = 0 THEN MenuOne
  109.         IF NOT QuitGameFlag%% THEN
  110.             IF MenuID%% = 1 AND G.Mode = TypeA THEN MenuTwoA
  111.             IF MenuID%% = 1 AND G.Mode = TypeB THEN MenuTwoB
  112.         END IF
  113.         IF MenuID%% = 2 AND (NOT QuitGameFlag%%) AND G.Mode = TypeA THEN GameModeA
  114.         IF MenuID%% = 2 AND (NOT QuitGameFlag%%) AND G.Mode = TypeB THEN GameModeB
  115.     END IF
  116. LOOP UNTIL QuitGameFlag%%
  117.  
  118. 'dumpboard 'debuging line
  119. '------------------------------------------------------------------
  120. SUB TitleScreen
  121.     _TITLE "Tetris64 V.9  2018\Cobalt"
  122.     _PUTIMAGE (-10, 0), Splash&, _DISPLAY
  123.     _PRINTSTRING (168, 395), "Remake By Cobalt 2018", _DISPLAY
  124.     IF NOT G.Loaded THEN _PRINTSTRING (155, 290), "Please Wait", _DISPLAY
  125.     IF G.Loaded THEN _PRINTSTRING (155, 290), "Ready to Play", _DISPLAY
  126.  
  127.     IF MenuID%% = -1 THEN
  128.         DisplayClickOptions
  129.         COLOR _RGB32(0, 0, 0)
  130.         _PRINTSTRING (570, 200), "Click here"
  131.         _PRINTSTRING (570, 220), "to go Back"
  132.         COLOR _RGB32(255, 255, 255)
  133.         DO
  134.             nul%% = _MOUSEINPUT
  135.             IF _MOUSEBUTTON(1) THEN
  136.                 x% = _MOUSEX: y% = _MOUSEY
  137.                 exitflag%% = ClickInteraction(x%, y%)
  138.                 DO: LOOP WHILE _MOUSEINPUT
  139.             END IF
  140.             IF exitflag%% = TRUE THEN MenuID%% = 0 'goto next menu
  141.             IF exitflag%% = BACK THEN exitflag%% = FALSE 'no where to go backwards to
  142.             IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  143.         LOOP UNTIL exitflag%%
  144.         CLS
  145.     END IF
  146.  
  147. SUB LoadGameStuff (opt%%)
  148.     DIM Size(64) AS LONG, FOffset&(64)
  149.  
  150.     SCREEN _NEWIMAGE(800, 480, 32)
  151.  
  152.     OPEN "Tetris.GFX" FOR BINARY AS #1
  153.     FOR w% = 1 TO 15
  154.         GET #1, , FOffset&(w%)
  155.         GET #1, , Size(w%)
  156.         FOffset&(w%) = FOffset&(w%) + 1
  157.     NEXT
  158.     IF INSTR(_OS$, "WIN") THEN f%% = 1 ELSE f%% = 2
  159.     'function LoadGFX(Foff&,Size&,id%%)
  160.     OPEN "temp.dat" FOR BINARY AS #3
  161.     dat$ = SPACE$(Size(f%%))
  162.     GET #1, FOffset&(f%%), dat$
  163.     PUT #3, , dat$
  164.     CLOSE #3
  165.     FFX(1) = _LOADFONT("temp.dat", 20, "monospace")
  166.     IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  167.     IF FFX(1) THEN _FONT FFX(1), Temp&
  168.     _DELAY .125
  169.  
  170.     Splash& = LoadGFX(FOffset&(3), Size(3))
  171.     'Splash& = _LOADIMAGE("Tetris_Splash.bmp", 32)
  172.     ' FFX(1) = _LOADFONT("NESFont.otf", 20, "monospace")
  173.     ' IF FFX(1) THEN _FONT FFX(1)
  174.     ' _DELAY .125
  175.     TitleScreen
  176.     MenuA = LoadGFX(FOffset&(4), Size(4))
  177.     MenuB = LoadGFX(FOffset&(5), Size(5))
  178.     MenuC = LoadGFX(FOffset&(6), Size(6))
  179.     EndScrnA = LoadGFX(FOffset&(7), Size(7))
  180.     EndSprtA = LoadGFX(FOffset&(8), Size(8))
  181.     FieldA = LoadGFX(FOffset&(9), Size(9))
  182.     FieldB = LoadGFX(FOffset&(10), Size(10))
  183.     HighS = LoadGFX(FOffset&(11), Size(11))
  184.     Nomes = LoadGFX(FOffset&(12), Size(12))
  185.     EndScrnB = LoadGFX(FOffset&(13), Size(13))
  186.     EndScrnB2 = LoadGFX(FOffset&(14), Size(14))
  187.     Temp& = _NEWIMAGE(512, 480, 32)
  188.     Bzone = _NEWIMAGE(160, 320, 32)
  189.     IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  190.     CLOSE #1
  191.  
  192.     IF opt%% = LoadIt THEN 'load sounds option
  193.         OPEN "Tetris_Original.SFX" FOR BINARY AS #1
  194.         FOR w% = 1 TO 16
  195.             GET #1, , foffset&
  196.             GET #1, , Size(w%)
  197.         NEXT
  198.  
  199.         FOR w% = 1 TO 5
  200.             OPEN "temp.dat" FOR BINARY AS #3
  201.             dat$ = SPACE$(Size(w%))
  202.             GET #1, , dat$
  203.             PUT #3, , dat$
  204.             CLOSE #3
  205.             BGM(w%) = _SNDOPEN("temp.dat")
  206.             IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  207.         NEXT w%
  208.         FOR w% = 6 TO 16
  209.             OPEN "temp.dat" FOR BINARY AS #3
  210.             dat$ = SPACE$(Size(w%))
  211.             GET #1, , dat$
  212.             PUT #3, , dat$
  213.             CLOSE #3
  214.             SFX(w% - 6) = _SNDOPEN("temp.dat")
  215.             IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  216.         NEXT w%
  217.         CLOSE
  218.         G.Sound = TRUE
  219.     END IF
  220.     G.Loaded = TRUE
  221.     _PRINTSTRING (155, 290), "Ready to Play", _DISPLAY
  222.  
  223.  
  224. SUB MenuOne
  225.     STATIC FirstRun%%
  226.     IF FirstRun%% = FALSE THEN
  227.         _PRINTSTRING (570, 130), "Click here"
  228.         _PRINTSTRING (570, 150), "to Continue"
  229.  
  230.         DO
  231.             nul%% = _MOUSEINPUT
  232.             IF _MOUSEBUTTON(1) THEN
  233.                 x% = _MOUSEX: y% = _MOUSEY
  234.                 exitflag%% = ClickInteraction(x%, y%)
  235.                 DO: LOOP WHILE _MOUSEINPUT
  236.             END IF
  237.         LOOP UNTIL exitflag%%
  238.         CLS
  239.         exitflag%% = FALSE
  240.         DO: LOOP WHILE _MOUSEINPUT
  241.         FirstRun%% = TRUE
  242.     END IF
  243.  
  244.     _PUTIMAGE (5, 5), MenuA, _DISPLAY, (64, 16)-(574, 462)
  245.     _PUTIMAGE (30 + G.BGMVol * 1.28, 374), MenuA, _DISPLAY, (32, 0)-(45, 13)
  246.     _PUTIMAGE (30 + G.SFXVol * 1.28, 278), MenuA, _DISPLAY, (32, 0)-(45, 13)
  247.     IF G.Mode = TypeA THEN
  248.         _PUTIMAGE (130, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  249.         _PUTIMAGE (250, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  250.     END IF
  251.     _PUTIMAGE (212, 277), MenuA, _DISPLAY, (0, 0)-(13, 13)
  252.     _PUTIMAGE (360, 277), MenuA, _DISPLAY, (16, 0)-(29, 13)
  253.     IF G.Mode = TypeB THEN
  254.         _PUTIMAGE (322, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  255.         _PUTIMAGE (442, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  256.     END IF
  257.     DisplayClickOptions
  258.  
  259.     IF G.Sound THEN
  260.         FOR w% = 1 TO 5
  261.             _SNDVOL BGM(G.BGM), G.BGMVol / 100
  262.         NEXT w%
  263.         FOR w% = 0 TO 12
  264.             _SNDVOL SFX(w%), G.SFXVol / 100
  265.         NEXT w%
  266.         _SNDLOOP BGM(G.BGM)
  267.     END IF
  268.     old%% = G.BGM
  269.  
  270.     DO
  271.         nul%% = _MOUSEINPUT
  272.         IF nul%% THEN
  273.             IF _MOUSEBUTTON(1) THEN
  274.                 x% = _MOUSEX: y% = _MOUSEY
  275.                 IF x% > 120 AND y% > 102 AND x% < 275 AND y% < 146 THEN 'game type A
  276.                     G.Mode = TypeA
  277.                     LINE (322, 117)-(338, 131), _RGB32(0, 0, 0), BF
  278.                     LINE (442, 117)-(458, 131), _RGB32(0, 0, 0), BF
  279.                     _PUTIMAGE (130, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  280.                     _PUTIMAGE (250, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  281.                 END IF
  282.                 IF x% > 312 AND y% > 102 AND x% < 466 AND y% < 146 THEN 'game type B
  283.                     G.Mode = TypeB
  284.                     LINE (130, 117)-(146, 131), _RGB32(0, 0, 0), BF
  285.                     LINE (250, 117)-(266, 131), _RGB32(0, 0, 0), BF
  286.                     _PUTIMAGE (322, 117), MenuA, _DISPLAY, (0, 0)-(13, 13)
  287.                     _PUTIMAGE (442, 117), MenuA, _DISPLAY, (16, 0)-(29, 13)
  288.                 END IF
  289.                 IF x% > 210 AND y% > 270 AND x% < 378 AND y% < 296 THEN 'BGM 1
  290.                     G.BGM = Song1
  291.                     LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  292.                     LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  293.                     _PUTIMAGE (212, 277), MenuA, _DISPLAY, (0, 0)-(13, 13)
  294.                     _PUTIMAGE (360, 277), MenuA, _DISPLAY, (16, 0)-(29, 13)
  295.                     songchange%% = TRUE
  296.                 END IF
  297.                 IF x% > 210 AND y% > 302 AND x% < 378 AND y% < 328 THEN 'BGM 2
  298.                     G.BGM = Song2
  299.                     LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  300.                     LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  301.                     _PUTIMAGE (212, 310), MenuA, _DISPLAY, (0, 0)-(13, 13)
  302.                     _PUTIMAGE (360, 310), MenuA, _DISPLAY, (16, 0)-(29, 13)
  303.                     songchange%% = TRUE
  304.                 END IF
  305.                 IF x% > 210 AND y% > 334 AND x% < 378 AND y% < 362 THEN 'BGM 3
  306.                     G.BGM = Song3
  307.                     LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  308.                     LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  309.                     _PUTIMAGE (212, 340), MenuA, _DISPLAY, (0, 0)-(13, 13)
  310.                     _PUTIMAGE (360, 340), MenuA, _DISPLAY, (16, 0)-(29, 13)
  311.                     songchange%% = TRUE
  312.                 END IF
  313.                 IF x% > 210 AND y% > 368 AND x% < 378 AND y% < 394 THEN 'BGM Off
  314.                     G.BGM = NoBGM
  315.                     LINE (210, 270)-(226, 400), _RGB32(0, 0, 0), BF
  316.                     LINE (360, 270)-(376, 400), _RGB32(0, 0, 0), BF
  317.                     _PUTIMAGE (212, 374), MenuA, _DISPLAY, (0, 0)-(13, 13)
  318.                     _PUTIMAGE (360, 374), MenuA, _DISPLAY, (16, 0)-(29, 13)
  319.                     songchange%% = TRUE
  320.                 END IF
  321.                 IF x% > 36 AND y% > 372 AND x% < 166 AND y% < 392 THEN 'BGM Volume
  322.                     G.BGMVol = ((x% - 37) / 128) * 100
  323.                     LINE (30, 372)-(172, 388), _RGB32(0, 0, 0), BF
  324.                     _PUTIMAGE (30 + G.BGMVol * 1.28, 374), MenuA, _DISPLAY, (32, 0)-(45, 13)
  325.                     volchange%% = TRUE
  326.                 END IF
  327.                 IF x% > 36 AND y% > 276 AND x% < 166 AND y% < 292 THEN 'SFX Volume
  328.                     G.SFXVol = ((x% - 37) / 128) * 100
  329.                     LINE (30, 276)-(172, 292), _RGB32(0, 0, 0), BF
  330.                     _PUTIMAGE (30 + G.SFXVol * 1.28, 278), MenuA, _DISPLAY, (32, 0)-(45, 13)
  331.                     FXvolchange%% = TRUE
  332.                 END IF
  333.  
  334.                 exitflag%% = ClickInteraction(x%, y%)
  335.             END IF
  336.             DO: _DELAY .001: LOOP WHILE _MOUSEINPUT
  337.         END IF
  338.  
  339.         IF G.Sound THEN
  340.             IF songchange%% AND G.BGM <> old%% THEN
  341.                 _SNDSTOP BGM(old%%)
  342.                 _SNDLOOP BGM(G.BGM)
  343.                 old%% = G.BGM
  344.                 songchange%% = FALSE
  345.                 volchange%% = TRUE
  346.             ELSE
  347.                 songchange%% = FALSE
  348.             END IF
  349.  
  350.             IF volchange%% THEN
  351.                 _SNDVOL BGM(G.BGM), (G.BGMVol / 100)
  352.                 volchange%% = FALSE
  353.             END IF
  354.  
  355.             IF FXvolchange%% AND (NOT _MOUSEBUTTON(1)) THEN
  356.                 _SNDVOL SFX(0), (G.SFXVol / 100)
  357.                 _SNDPLAY SFX(0) 'plays a test sound effect
  358.                 FXvolchange%% = FALSE
  359.             END IF
  360.         END IF
  361.         _DELAY .01
  362.     LOOP UNTIL exitflag%%
  363.  
  364.     IF exitflag%% <> BACK AND exitflag%% <> QUIT THEN
  365.         IF G.Sound THEN
  366.             FOR w% = 0 TO 12
  367.                 _SNDVOL SFX(w%), G.SFXVol / 100
  368.             NEXT w%
  369.             FOR w% = 1 TO 5
  370.                 _SNDVOL BGM(G.BGM), G.BGMVol / 100
  371.             NEXT w%
  372.  
  373.         END IF
  374.         DO: LOOP WHILE _MOUSEINPUT
  375.     END IF
  376.     IF exitflag%% = TRUE THEN
  377.         MenuID%% = 1 'go to next menu
  378.         IF G.Sound THEN _SNDPLAY SFX(0)
  379.     END IF
  380.     IF exitflag%% = BACK THEN
  381.         MenuID%% = -1 'go back to title screen
  382.         IF G.Sound THEN _SNDPLAY SFX(1)
  383.     END IF
  384.     IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  385.  
  386. SUB MenuTwoA
  387.     LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  388.     _PUTIMAGE (109, 157), MenuB, _DISPLAY, (0, 0)-(31, 31)
  389.     _PUTIMAGE (5, 5), MenuB, _DISPLAY, (64, 16)-(574, 462)
  390.     DisplayClickOptions
  391.     ShowHighScoreA
  392.     DO
  393.         nul%% = _MOUSEINPUT
  394.         IF nul%% THEN
  395.             IF _MOUSEBUTTON(1) THEN
  396.                 x% = _MOUSEX: y% = _MOUSEY
  397.                 IF x% > 108 AND y% > 155 AND x% < 271 AND y% < 221 THEN 'Start Level
  398.                     IF G.Sound THEN _SNDPLAY SFX(6)
  399.  
  400.                     IF y% > 155 AND y% < 188 THEN ll% = 0: yy% = 155: lvl%% = 0
  401.                     IF y% > 188 AND y% < 221 THEN ll% = 5: yy% = 189: lvl%% = 5
  402.                     SELECT CASE x%
  403.                         CASE 108 TO 139
  404.                             ll% = ll% + 0: xx% = 109: lvl%% = lvl%% + 0
  405.                         CASE 139 TO 172
  406.                             ll% = ll% + 1: xx% = 141: lvl%% = lvl%% + 1
  407.                         CASE 172 TO 204
  408.                             ll% = ll% + 2: xx% = 173: lvl%% = lvl%% + 2
  409.                         CASE 204 TO 236
  410.                             ll% = ll% + 3: xx% = 204: lvl%% = lvl%% + 3
  411.                         CASE 236 TO 271
  412.                             ll% = ll% + 4: xx% = 237: lvl%% = lvl%% + 4
  413.                     END SELECT
  414.                     _PUTIMAGE (109, 153), MenuB, _DISPLAY, (0, 32)-(63, 101)
  415.                     _PUTIMAGE (173, 153), MenuB, _DISPLAY, (0, 102)-(63, 171)
  416.                     _PUTIMAGE (237, 153), MenuB, _DISPLAY, (0, 172)-(63, 241)
  417.                     _PUTIMAGE (xx%, yy%), MenuB, _DISPLAY, (0, 0)-(31, 31)
  418.                     _PUTIMAGE (107, 153), MenuB, _DISPLAY, (166, 164)-(331, 243)
  419.  
  420.                 END IF
  421.                 exitflag%% = ClickInteraction(x%, y%)
  422.             END IF
  423.             DO: LOOP WHILE _MOUSEINPUT
  424.         END IF
  425.         _DELAY .01
  426.     LOOP UNTIL exitflag%%
  427.     G.Level = lvl%%
  428.     IF exitflag%% = TRUE THEN
  429.         MenuID%% = 2 'go to next menu
  430.         IF G.Sound THEN _SNDPLAY SFX(0)
  431.     END IF
  432.     IF exitflag%% = BACK THEN
  433.         MenuID%% = 0 'go back to title screen
  434.         IF G.Sound THEN _SNDPLAY SFX(1)
  435.     END IF
  436.     IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  437.  
  438. SUB MenuTwoB
  439.     LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  440.     _PUTIMAGE (109, 157), MenuC, _DISPLAY, (0, 0)-(31, 31)
  441.     _PUTIMAGE (317, 157), MenuC, _DISPLAY, (0, 0)-(31, 31)
  442.     _PUTIMAGE (5, 5), MenuC, _DISPLAY, (64, 16)-(574, 462)
  443.     DisplayClickOptions
  444.     ShowHighScoreB
  445.     DO
  446.         nul%% = _MOUSEINPUT
  447.         IF nul%% THEN
  448.             IF _MOUSEBUTTON(1) THEN
  449.                 x% = _MOUSEX: y% = _MOUSEY
  450.                 IF x% > 108 AND y% > 155 AND x% < 271 AND y% < 221 THEN 'Start Level
  451.                     IF G.Sound THEN _SNDPLAY SFX(6)
  452.                     IF y% > 155 AND y% < 188 THEN yy% = 155: lvl%% = 0
  453.                     IF y% > 188 AND y% < 221 THEN yy% = 189: lvl%% = 5
  454.                     SELECT CASE x%
  455.                         CASE 108 TO 139
  456.                             xx% = 109: lvl%% = lvl%% + 0
  457.                         CASE 139 TO 172
  458.                             xx% = 141: lvl%% = lvl%% + 1
  459.                         CASE 172 TO 204
  460.                             xx% = 173: lvl%% = lvl%% + 2
  461.                         CASE 204 TO 236
  462.                             xx% = 204: lvl%% = lvl%% + 3
  463.                         CASE 236 TO 271
  464.                             xx% = 237: lvl%% = lvl%% + 4
  465.                     END SELECT
  466.                     LINE (107, 153)-(272, 243), _RGB32(0, 0, 0), BF
  467.                     _PUTIMAGE (xx%, yy%), MenuC, _DISPLAY, (0, 0)-(31, 31)
  468.                     _PUTIMAGE (107, 153), MenuC, _DISPLAY, (166, 164)-(331, 243)
  469.                 END IF
  470.                 IF x% > 317 AND y% > 155 AND x% < 413 AND y% < 221 THEN 'Start height
  471.                     IF G.Sound THEN _SNDPLAY SFX(6)
  472.                     IF y% > 155 AND y% < 188 THEN hyy% = 155: hlvl%% = 0
  473.                     IF y% > 188 AND y% < 221 THEN hyy% = 189: hlvl%% = 3
  474.                     SELECT CASE x%
  475.                         CASE 318 TO 348
  476.                             hxx% = 317: hlvl%% = hlvl%% + 0
  477.                         CASE 349 TO 380
  478.                             hxx% = 349: hlvl%% = hlvl%% + 1
  479.                         CASE 381 TO 412
  480.                             hxx% = 381: hlvl%% = hlvl%% + 2
  481.                     END SELECT
  482.                     LINE (315, 153)-(415, 243), _RGB32(0, 0, 0), BF
  483.                     _PUTIMAGE (hxx%, hyy%), MenuC, _DISPLAY, (0, 0)-(31, 31)
  484.                     _PUTIMAGE (315, 153), MenuC, _DISPLAY, (374, 164)-(474, 243)
  485.                 END IF
  486.                 exitflag%% = ClickInteraction(x%, y%)
  487.             END IF
  488.             DO: LOOP WHILE _MOUSEINPUT
  489.         END IF
  490.         _DELAY .01
  491.     LOOP UNTIL exitflag%%
  492.     G.Level = lvl%%
  493.     G.Height = hlvl%%
  494.     P.Lines = 25
  495.     IF exitflag%% = TRUE THEN
  496.         MenuID%% = 2 'go to next menu
  497.         IF G.Sound THEN _SNDPLAY SFX(0)
  498.     END IF
  499.     IF exitflag%% = BACK THEN
  500.         MenuID%% = 0 'go back to title screen
  501.         IF G.Sound THEN _SNDPLAY SFX(1)
  502.     END IF
  503.     IF exitflag%% = QUIT THEN QuitGameFlag%% = TRUE 'quit game
  504.  
  505. SUB DisplayNextPiece
  506.     'display the next peice in queue
  507.     'display peice centered in NEXT window(420)
  508.     'first clear next window
  509.     LINE (388, 212)-(450, 275), _RGB32(0, 0, 0), BF
  510.     IF G.Level < 10 THEN Yshift~%% = 16 * G.Level ELSE Yshift~%% = 16 * 9
  511.     SELECT CASE P.NextP
  512.         CASE T
  513.             _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  514.             _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  515.             _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  516.             _PUTIMAGE (420 - 8, 212 + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  517.         CASE J
  518.             _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  519.             _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  520.             _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  521.             _PUTIMAGE (420 + 8, 212 + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  522.         CASE L
  523.             _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  524.             _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  525.             _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  526.             _PUTIMAGE (420 - 24, 212 + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  527.         CASE Z
  528.             _PUTIMAGE (420 - 24, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  529.             _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  530.             _PUTIMAGE (420 - 8, 212 + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  531.             _PUTIMAGE (420 + 8, 212 + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  532.         CASE O
  533.             _PUTIMAGE (420 - 16, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  534.             _PUTIMAGE (420 + 0, 212 + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  535.             _PUTIMAGE (420 - 16, 212 + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  536.             _PUTIMAGE (420 + 0, 212 + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  537.         CASE S
  538.             _PUTIMAGE (420 - 8, 212 + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  539.             _PUTIMAGE (420 + 8, 212 + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  540.             _PUTIMAGE (420 - 8, 212 + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  541.             _PUTIMAGE (420 - 24, 212 + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  542.         CASE I
  543.             _PUTIMAGE (420 - 32, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  544.             _PUTIMAGE (420 - 16, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  545.             _PUTIMAGE (420 + 0, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  546.             _PUTIMAGE (420 + 16, 212 + 24), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  547.  
  548.     END SELECT
  549.  
  550. SUB PlaceTetraNome
  551.     px% = P.PieceX * 16 + 197 + AdjX%
  552.     py% = P.PieceY * 16 + 85 - 16
  553.     IF G.Level < 10 THEN Yshift~%% = 16 * G.Level ELSE Yshift~%% = 16 * 9
  554.     SELECT CASE P.Piece
  555.         CASE T
  556.             SELECT CASE P.Orent
  557.                 CASE 1 'normal
  558.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  559.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  560.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  561.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  562.                 CASE 2 '90 rt
  563.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  564.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  565.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  566.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  567.                 CASE 3 '180rt
  568.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  569.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  570.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  571.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  572.                 CASE 4 '270rt
  573.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  574.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  575.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  576.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  577.             END SELECT
  578.         CASE J
  579.             SELECT CASE P.Orent
  580.                 CASE 1 'normal
  581.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  582.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  583.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  584.                     _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  585.                 CASE 2 '90 rt
  586.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  587.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  588.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  589.                     _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  590.                 CASE 3 '180 rt
  591.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  592.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  593.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  594.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 24, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  595.                 CASE 4 '270 rt
  596.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  597.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  598.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  599.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% + 8, py% + 0), Nomes, _DISPLAY, (32, Yshift~%%)-(45, Yshift~%% + 13)
  600.             END SELECT
  601.         CASE L
  602.             SELECT CASE P.Orent
  603.                 CASE 1 'normal
  604.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  605.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  606.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  607.                     _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  608.                 CASE 2 '90 rt
  609.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  610.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  611.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  612.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 24, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  613.                 CASE 3 '180 rt
  614.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  615.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  616.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  617.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% + 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  618.                 CASE 4 '270 rt
  619.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  620.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  621.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  622.                     _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  623.             END SELECT
  624.         CASE Z
  625.             SELECT CASE P.Orent
  626.                 CASE 1, 3 'normal+180
  627.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  628.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  629.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  630.                     _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  631.                 CASE 2, 4 '90 rt+270rt
  632.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  633.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  634.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  635.                     _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (16, Yshift~%%)-(29, Yshift~%% + 13)
  636.             END SELECT
  637.         CASE O
  638.             SELECT CASE P.Orent
  639.                 CASE 1 TO 4 'normal-no rotation change
  640.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  641.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  642.                     _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  643.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  644.             END SELECT
  645.         CASE S
  646.             SELECT CASE P.Orent
  647.                 CASE 1, 3 'normal+180rt
  648.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  649.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  650.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  651.                     _PUTIMAGE (px% - 24, py% + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  652.                 CASE 2, 4 '90rt+270rt
  653.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  654.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  655.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  656.                     _PUTIMAGE (px% + 8, py% + 32), Nomes, _DISPLAY, (31, Yshift~%%)-(45, Yshift~%% + 13)
  657.             END SELECT
  658.         CASE I
  659.             SELECT CASE P.Orent
  660.                 CASE 1, 3 'normal+180
  661.                     _PUTIMAGE (px% - 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  662.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  663.                     _PUTIMAGE (px% + 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  664.                     _PUTIMAGE (px% + 24, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  665.                 CASE 2, 4 '90rt,270rt
  666.                     IF P.PieceY > 0 THEN _PUTIMAGE (px% - 8, py% + 0), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  667.                     _PUTIMAGE (px% - 8, py% + 16), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  668.                     _PUTIMAGE (px% - 8, py% + 32), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  669.                     _PUTIMAGE (px% - 8, py% + 48), Nomes, _DISPLAY, (0, Yshift~%%)-(13, Yshift~%% + 13)
  670.             END SELECT
  671.     END SELECT
  672.  
  673. SUB DropPiece
  674.     P.PieceY = P.PieceY + 1 'move Tetranome down
  675.     IF ButtonHeld%% THEN P.bonus = P.bonus + 1 'if player is pressing down button then add to bonus
  676.     IF CollisionDown THEN LandPiece 'check to see if the peice is landed
  677.  
  678. FUNCTION CollisionDown
  679.     result%% = FALSE
  680.     SELECT CASE P.Piece
  681.         CASE T
  682.             SELECT CASE P.Orent
  683.                 CASE 1
  684.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  685.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  686.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  687.                 CASE 2
  688.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  689.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  690.                 CASE 3
  691.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  692.                     IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  693.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  694.                 CASE 4
  695.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  696.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  697.             END SELECT
  698.             IF P.PieceY + 1 = 21 THEN result%% = TRUE
  699.         CASE J
  700.             SELECT CASE P.Orent
  701.                 CASE 1
  702.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  703.                     IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  704.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  705.                 CASE 2
  706.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  707.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  708.                 CASE 3
  709.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  710.                     IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  711.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  712.                 CASE 4
  713.                     IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  714.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  715.             END SELECT
  716.             IF P.PieceY + 1 = 21 THEN result%% = TRUE
  717.         CASE L
  718.             SELECT CASE P.Orent
  719.                 CASE 1
  720.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  721.                     IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  722.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  723.                 CASE 2
  724.                     IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  725.                     IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  726.                 CASE 3
  727.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  728.                     IF Board(P.PieceX, P.PieceY + 1) > TRUE THEN result%% = TRUE
  729.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  730.                 CASE 4
  731.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  732.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  733.             END SELECT
  734.             IF P.PieceY + 1 = 21 THEN result%% = TRUE
  735.         CASE Z
  736.             SELECT CASE P.Orent
  737.                 CASE 1, 3
  738.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  739.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  740.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  741.                 CASE 2, 4
  742.                     IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  743.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  744.             END SELECT
  745.             IF P.PieceY + 1 = 21 THEN result%% = TRUE
  746.         CASE S
  747.             SELECT CASE P.Orent
  748.                 CASE 1, 3
  749.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  750.                     IF Board(P.PieceX, P.PieceY + 2) > TRUE THEN result%% = TRUE
  751.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  752.                 CASE 2, 4
  753.                     IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  754.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  755.             END SELECT
  756.             IF P.PieceY + 1 = 21 THEN result%% = TRUE
  757.         CASE I
  758.             SELECT CASE P.Orent
  759.                 CASE 1, 3
  760.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  761.                     IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  762.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  763.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  764.                     IF P.PieceY + 1 = 21 THEN result%% = TRUE
  765.                 CASE 2, 4
  766.                     IF Board(P.PieceX + 0, P.PieceY + 3) > TRUE THEN result%% = TRUE
  767.                     IF P.PieceY + 1 = 20 THEN result%% = TRUE
  768.             END SELECT
  769.         CASE O
  770.             SELECT CASE P.Orent
  771.                 CASE 1 TO 4
  772.                     IF Board(P.PieceX + 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  773.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  774.                     IF P.PieceY + 1 = 21 THEN result%% = TRUE
  775.             END SELECT
  776.     END SELECT
  777.     CollisionDown = result%%
  778.  
  779. SUB LandPiece
  780.     IF G.Sound THEN _SNDPLAY SFX(5)
  781.     SELECT CASE P.Piece
  782.         CASE T
  783.             Board(P.PieceX + 0, P.PieceY) = 0
  784.             SELECT CASE P.Orent
  785.                 CASE 1
  786.                     Board(P.PieceX - 1, P.PieceY) = 0
  787.                     Board(P.PieceX + 1, P.PieceY) = 0
  788.                     Board(P.PieceX + 0, P.PieceY + 1) = 0
  789.                 CASE 2
  790.                     Board(P.PieceX + 0, P.PieceY - 1) = 0
  791.                     Board(P.PieceX - 1, P.PieceY) = 0
  792.                     Board(P.PieceX + 0, P.PieceY + 1) = 0
  793.                 CASE 3
  794.                     Board(P.PieceX - 1, P.PieceY) = 0
  795.                     Board(P.PieceX + 1, P.PieceY) = 0
  796.                     Board(P.PieceX + 0, P.PieceY - 1) = 0
  797.                 CASE 4
  798.                     Board(P.PieceX + 0, P.PieceY - 1) = 0
  799.                     Board(P.PieceX + 1, P.PieceY) = 0
  800.                     Board(P.PieceX + 0, P.PieceY + 1) = 0
  801.             END SELECT
  802.         CASE J
  803.             Board(P.PieceX + 0, P.PieceY) = 2
  804.             SELECT CASE P.Orent
  805.                 CASE 1
  806.                     Board(P.PieceX - 1, P.PieceY) = 2
  807.                     Board(P.PieceX + 1, P.PieceY) = 2
  808.                     Board(P.PieceX + 1, P.PieceY + 1) = 2
  809.                 CASE 2
  810.                     Board(P.PieceX - 0, P.PieceY - 1) = 2
  811.                     Board(P.PieceX + 0, P.PieceY + 1) = 2
  812.                     Board(P.PieceX - 1, P.PieceY + 1) = 2
  813.                 CASE 3
  814.                     Board(P.PieceX - 1, P.PieceY) = 2
  815.                     Board(P.PieceX + 1, P.PieceY) = 2
  816.                     Board(P.PieceX - 1, P.PieceY - 1) = 2
  817.                 CASE 4
  818.                     Board(P.PieceX - 0, P.PieceY - 1) = 2
  819.                     Board(P.PieceX + 0, P.PieceY + 1) = 2
  820.                     Board(P.PieceX + 1, P.PieceY - 1) = 2
  821.             END SELECT
  822.         CASE L
  823.             Board(P.PieceX + 0, P.PieceY) = 1
  824.             SELECT CASE P.Orent
  825.                 CASE 1
  826.                     Board(P.PieceX - 1, P.PieceY) = 1
  827.                     Board(P.PieceX + 1, P.PieceY) = 1
  828.                     Board(P.PieceX - 1, P.PieceY + 1) = 1
  829.                 CASE 2
  830.                     Board(P.PieceX - 0, P.PieceY - 1) = 1
  831.                     Board(P.PieceX + 0, P.PieceY + 1) = 1
  832.                     Board(P.PieceX - 1, P.PieceY - 1) = 1
  833.                 CASE 3
  834.                     Board(P.PieceX - 1, P.PieceY) = 1
  835.                     Board(P.PieceX + 1, P.PieceY) = 1
  836.                     Board(P.PieceX + 1, P.PieceY - 1) = 1
  837.                 CASE 4
  838.                     Board(P.PieceX - 0, P.PieceY - 1) = 1
  839.                     Board(P.PieceX + 0, P.PieceY + 1) = 1
  840.                     Board(P.PieceX + 1, P.PieceY + 1) = 1
  841.             END SELECT
  842.         CASE Z
  843.             Board(P.PieceX + 0, P.PieceY) = 1
  844.             SELECT CASE P.Orent
  845.                 CASE 1, 3
  846.                     Board(P.PieceX - 1, P.PieceY) = 1
  847.                     Board(P.PieceX + 0, P.PieceY + 1) = 1
  848.                     Board(P.PieceX + 1, P.PieceY + 1) = 1
  849.                 CASE 2, 4
  850.                     Board(P.PieceX - 0, P.PieceY - 1) = 1
  851.                     Board(P.PieceX - 1, P.PieceY + 0) = 1
  852.                     Board(P.PieceX - 1, P.PieceY + 1) = 1
  853.             END SELECT
  854.         CASE S
  855.             Board(P.PieceX + 0, P.PieceY) = 2
  856.             SELECT CASE P.Orent
  857.                 CASE 1, 3
  858.                     Board(P.PieceX + 1, P.PieceY) = 2
  859.                     Board(P.PieceX + 0, P.PieceY + 1) = 2
  860.                     Board(P.PieceX - 1, P.PieceY + 1) = 2
  861.                 CASE 2, 4
  862.                     Board(P.PieceX - 0, P.PieceY - 1) = 2
  863.                     Board(P.PieceX + 1, P.PieceY + 0) = 2
  864.                     Board(P.PieceX + 1, P.PieceY + 1) = 2
  865.             END SELECT
  866.         CASE I
  867.             Board(P.PieceX + 0, P.PieceY) = 0
  868.             SELECT CASE P.Orent
  869.                 CASE 1, 3
  870.                     Board(P.PieceX - 1, P.PieceY) = 0
  871.                     Board(P.PieceX + 1, P.PieceY + 0) = 0
  872.                     Board(P.PieceX + 2, P.PieceY + 0) = 0
  873.                 CASE 2, 4
  874.                     Board(P.PieceX - 0, P.PieceY - 1) = 0
  875.                     Board(P.PieceX + 0, P.PieceY + 1) = 0
  876.                     Board(P.PieceX + 0, P.PieceY + 2) = 0
  877.             END SELECT
  878.         CASE O
  879.             Board(P.PieceX + 0, P.PieceY) = 0
  880.             SELECT CASE P.Orent
  881.                 CASE 1 TO 4
  882.                     Board(P.PieceX - 1, P.PieceY) = 0
  883.                     Board(P.PieceX - 0, P.PieceY + 1) = 0
  884.                     Board(P.PieceX - 1, P.PieceY + 1) = 0
  885.             END SELECT
  886.     END SELECT
  887.     CheckLines
  888.     IF ButtonHeld%% THEN P.Score = P.Score + (P.bonus * (G.Level + 1)): LandedNew%% = TRUE
  889.     P.bonus = 0
  890.     IF NOT G.GameOverFlag THEN NewPiece
  891.  
  892. SUB DrawBoard
  893.     IF G.Level < 10 THEN Yshift~%% = 16 * G.Level ELSE Yshift~%% = 16 * 9
  894.     FOR y% = 0 TO 19
  895.         FOR x% = 0 TO 9
  896.             IF Board(x% + 1, y% + 1) <> -1 THEN
  897.                 _PUTIMAGE (197 + x% * 16, 85 + y% * 16), Nomes, _DISPLAY, (0 + 16 * Board(x% + 1, y% + 1), Yshift~%%)-(15 + 16 * Board(x% + 1, y% + 1), 15 + Yshift~%%)
  898.             ELSE
  899.                 LINE (197 + x% * 16, 85 + y% * 16)-(197 + 15 + x% * 16, 85 + 15 + y% * 16), _RGB32(0, 0, 0), BF
  900.             END IF
  901.         NEXT x%
  902.     NEXT y%
  903.  
  904. SUB BoardSetup
  905.     FOR y% = 0 TO 20
  906.         FOR x% = 1 TO 10
  907.             Board(x%, y%) = TRUE
  908.         NEXT x%
  909.     NEXT y%
  910.  
  911. SUB dumpboard
  912.     OPEN "debugboard.txt" FOR OUTPUT AS #2
  913.     LandPiece
  914.     FOR y% = 0 TO 21
  915.         FOR x% = 0 TO 11
  916.             PRINT #2, Board(x%, y%);
  917.         NEXT x%
  918.         PRINT #2,
  919.     NEXT y%
  920.  
  921. SUB CheckLines
  922.     DIM Lines%(4) 'can fill up to 4 lines at once for a TETRIS
  923.     ip%% = 1
  924.     'find solid lines
  925.     FOR y%% = 1 TO 20
  926.         solid%% = TRUE 'assume line is solid at start
  927.         FOR x%% = 1 TO 10
  928.             IF Board(x%%, y%%) = TRUE THEN solid%% = FALSE 'change to false if hole found
  929.         NEXT
  930.         IF solid%% THEN Lines%(ip%%) = y%%: ip%% = ip%% + 1
  931.     NEXT
  932.     ip%% = ip%% - 1
  933.     IF ip%% > 0 THEN
  934.         IF G.Mode = TypeA THEN P.Lines = P.Lines + ip%%
  935.         IF G.Mode = TypeB THEN P.Lines = P.Lines - ip%%
  936.         IF P.Lines < 0 THEN P.Lines = 0
  937.         'give player points for lines completed
  938.         SELECT CASE ip%%
  939.             CASE 1
  940.                 P.Score = P.Score + (40 * (G.Level + 1))
  941.                 IF G.Sound THEN _SNDPLAY SFX(10)
  942.             CASE 2
  943.                 P.Score = P.Score + (100 * (G.Level + 1))
  944.                 IF G.Sound THEN _SNDPLAY SFX(10)
  945.             CASE 3
  946.                 P.Score = P.Score + (300 * (G.Level + 1))
  947.                 IF G.Sound THEN _SNDPLAY SFX(10)
  948.             CASE 4
  949.                 P.Score = P.Score + (1200 * (G.Level + 1))
  950.                 IF G.Sound THEN _SNDPLAY SFX(9)
  951.         END SELECT
  952.         'remove solid lines
  953.         IF Lines%(1) <> 0 THEN
  954.             FOR x% = 1 TO 5
  955.                 FOR y% = 1 TO ip%%
  956.                     Board(6 - x%, Lines%(y%)) = -1
  957.                     Board(5 + x%, Lines%(y%)) = -1
  958.                 NEXT y%
  959.                 DrawBoard
  960.                 _DELAY .075
  961.             NEXT x%
  962.         END IF
  963.         'TETRIS bonus
  964.         IF ip%% = 4 THEN P.Score = P.Score + (100 * (ip%% * (G.Level + 1)))
  965.         'drop any lines down to fill in gaps
  966.         FOR w%% = 1 TO ip%%
  967.             FOR y%% = Lines%(w%%) TO 1 STEP -1
  968.                 FOR x%% = 1 TO 10
  969.                     Board(x%%, y%%) = Board(x%%, y%% - 1)
  970.                 NEXT x%%
  971.             NEXT y%%
  972.             FOR x%% = 1 TO 10 'reset top line
  973.                 Board(x%%, y%% + 1) = TRUE
  974.             NEXT x%%
  975.         NEXT w%%
  976.         DrawBoard
  977.  
  978.         IF (P.Lines > 0) AND ((P.Lines MOD 10) = 0) AND G.Mode = TypeA THEN
  979.             TIMER(TI(G.Level)) OFF
  980.             IF G.Level < 10 THEN G.Level = G.Level + 1
  981.             TIMER(TI(G.Level)) ON
  982.         END IF
  983.  
  984.     END IF
  985.     IF G.Mode = TypeB AND P.Lines = 0 THEN GameOver
  986.  
  987. FUNCTION CollisionLeft
  988.     result%% = FALSE
  989.     SELECT CASE P.Piece
  990.         CASE T
  991.             SELECT CASE P.Orent
  992.                 CASE 1
  993.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  994.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  995.                 CASE 2
  996.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  997.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  998.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  999.                 CASE 3
  1000.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1001.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1002.                 CASE 4
  1003.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1004.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1005.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1006.             END SELECT
  1007.         CASE J
  1008.             SELECT CASE P.Orent
  1009.                 CASE 1
  1010.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1011.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1012.                 CASE 2
  1013.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1014.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1015.                     IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1016.                 CASE 3
  1017.                     IF Board(P.PieceX - 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1018.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1019.                 CASE 4
  1020.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1021.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1022.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1023.             END SELECT
  1024.         CASE L
  1025.             SELECT CASE P.Orent
  1026.                 CASE 1
  1027.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1028.                     IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1029.                 CASE 2
  1030.                     IF Board(P.PieceX - 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1031.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1032.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1033.                 CASE 3
  1034.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1035.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1036.                 CASE 4
  1037.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1038.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1039.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1040.             END SELECT
  1041.         CASE Z
  1042.             SELECT CASE P.Orent
  1043.                 CASE 1, 3
  1044.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1045.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1046.                 CASE 2, 4
  1047.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1048.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1049.                     IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1050.             END SELECT
  1051.         CASE S
  1052.             SELECT CASE P.Orent
  1053.                 CASE 1, 3
  1054.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1055.                     IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1056.                 CASE 2, 4
  1057.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1058.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1059.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1060.             END SELECT
  1061.         CASE I
  1062.             SELECT CASE P.Orent
  1063.                 CASE 1, 3
  1064.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1065.                 CASE 2, 4
  1066.                     IF Board(P.PieceX - 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1067.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1068.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1069.                     IF Board(P.PieceX - 1, P.PieceY + 3) > TRUE THEN result%% = TRUE
  1070.             END SELECT
  1071.         CASE O
  1072.             SELECT CASE P.Orent
  1073.                 CASE 1 TO 4
  1074.                     IF Board(P.PieceX - 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1075.                     IF Board(P.PieceX - 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1076.             END SELECT
  1077.     END SELECT
  1078.     CollisionLeft = result%%
  1079.  
  1080. FUNCTION CollisionRight
  1081.     result%% = FALSE
  1082.     SELECT CASE P.Piece
  1083.         CASE T
  1084.             SELECT CASE P.Orent
  1085.                 CASE 1
  1086.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1087.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1088.                 CASE 2
  1089.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1090.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1091.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1092.                 CASE 3
  1093.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1094.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1095.                 CASE 4
  1096.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1097.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1098.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1099.             END SELECT
  1100.         CASE J
  1101.             SELECT CASE P.Orent
  1102.                 CASE 1
  1103.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1104.                     IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1105.                 CASE 2
  1106.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1107.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1108.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1109.                 CASE 3
  1110.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1111.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1112.                 CASE 4
  1113.                     IF Board(P.PieceX + 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1114.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1115.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1116.             END SELECT
  1117.         CASE L
  1118.             SELECT CASE P.Orent
  1119.                 CASE 1
  1120.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1121.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1122.                 CASE 2
  1123.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1124.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1125.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1126.                 CASE 3
  1127.                     IF Board(P.PieceX + 2, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1128.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1129.                 CASE 4
  1130.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1131.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1132.                     IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1133.             END SELECT
  1134.         CASE Z
  1135.             SELECT CASE P.Orent
  1136.                 CASE 1, 3
  1137.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1138.                     IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1139.                 CASE 2, 4
  1140.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1141.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1142.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1143.             END SELECT
  1144.         CASE S
  1145.             SELECT CASE P.Orent
  1146.                 CASE 1, 3
  1147.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1148.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1149.                 CASE 2, 4
  1150.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1151.                     IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1152.                     IF Board(P.PieceX + 2, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1153.             END SELECT
  1154.         CASE I
  1155.             SELECT CASE P.Orent
  1156.                 CASE 1, 3
  1157.                     IF Board(P.PieceX + 3, P.PieceY) > TRUE THEN result%% = TRUE
  1158.                 CASE 2, 4
  1159.                     IF Board(P.PieceX + 1, P.PieceY - 0) > TRUE THEN result%% = TRUE
  1160.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1161.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1162.                     IF Board(P.PieceX + 1, P.PieceY + 3) > TRUE THEN result%% = TRUE
  1163.             END SELECT
  1164.         CASE O
  1165.             SELECT CASE P.Orent
  1166.                 CASE 1 TO 4
  1167.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1168.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1169.             END SELECT
  1170.     END SELECT
  1171.     CollisionRight = result%%
  1172.  
  1173. SUB StatusUpdate
  1174.     DIM v$(11) 'value strings
  1175.     v$(0) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Lines)))) + LTRIM$(STR$(P.Lines))
  1176.     IF G.Mode = TypeA THEN v$(1) = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1)))) + LTRIM$(STR$(G.HScore1))
  1177.     IF G.Mode = TypeB THEN v$(1) = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1B)))) + LTRIM$(STR$(G.HScore1B))
  1178.     v$(2) = LEFT$("000000", 6 - LEN(LTRIM$(STR$(P.Score)))) + LTRIM$(STR$(P.Score))
  1179.     v$(3) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Tcount)))) + LTRIM$(STR$(P.Tcount))
  1180.     v$(4) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Jcount)))) + LTRIM$(STR$(P.Jcount))
  1181.     v$(5) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Zcount)))) + LTRIM$(STR$(P.Zcount))
  1182.     v$(6) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Ocount)))) + LTRIM$(STR$(P.Ocount))
  1183.     v$(7) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Scount)))) + LTRIM$(STR$(P.Scount))
  1184.     v$(8) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Lcount)))) + LTRIM$(STR$(P.Lcount))
  1185.     v$(9) = LEFT$("000", 3 - LEN(LTRIM$(STR$(P.Icount)))) + LTRIM$(STR$(P.Icount))
  1186.     v$(10) = LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Level)))) + LTRIM$(STR$(G.Level))
  1187.     v$(11) = LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Height)))) + LTRIM$(STR$(G.Height))
  1188.     FOR u% = 0 TO 6
  1189.         COLOR _RGB32(240, 58, 0)
  1190.         _PRINTSTRING (102, 175 + u% * 32), v$(3 + u%), _DISPLAY
  1191.         COLOR _RGB32(255, 255, 255)
  1192.     NEXT u%
  1193.     _PRINTSTRING (308, 34), v$(0), _DISPLAY
  1194.     _PRINTSTRING (388, 70), v$(1), _DISPLAY
  1195.     _PRINTSTRING (388, 120), v$(2), _DISPLAY
  1196.     _PRINTSTRING (428 - (LEN(v$(10)) * _FONTWIDTH(FFX(1))) / 2, 324), v$(10), _DISPLAY
  1197.     IF G.Mode = TypeB THEN _PRINTSTRING (440 - (LEN(v$(11)) * _FONTWIDTH(FFX(1))) / 2, 390), v$(11), _DISPLAY
  1198.  
  1199. SUB NewPiece
  1200.     IF Board(5, 1) <> TRUE THEN GameOver
  1201.     IF NOT G.GameOverFlag THEN
  1202.         P.PieceY = 0
  1203.         P.PieceX = 5
  1204.         P.Orent = 1
  1205.         P.Piece = P.NextP
  1206.         P.NextP = INT(RND * 7) + 1
  1207.         SELECT CASE P.Piece
  1208.             CASE T
  1209.                 P.Tcount = P.Tcount + 1
  1210.             CASE J
  1211.                 P.Jcount = P.Jcount + 1
  1212.             CASE L
  1213.                 P.Lcount = P.Lcount + 1
  1214.             CASE Z
  1215.                 P.Zcount = P.Zcount + 1
  1216.             CASE S
  1217.                 P.Scount = P.Scount + 1
  1218.             CASE O
  1219.                 P.Ocount = P.Ocount + 1
  1220.             CASE I
  1221.                 P.Icount = P.Icount + 1
  1222.         END SELECT
  1223.         StatusUpdate
  1224.         DisplayNextPiece
  1225.     END IF
  1226.  
  1227. FUNCTION CollisionRotate
  1228.     result%% = FALSE
  1229.     SELECT CASE P.Piece
  1230.         CASE T
  1231.             SELECT CASE P.Orent
  1232.                 CASE 1
  1233.                     IF Board(P.PieceX + 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1234.                 CASE 2
  1235.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1236.                 CASE 3
  1237.                     IF Board(P.PieceX + 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1238.                 CASE 4
  1239.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1240.             END SELECT
  1241.         CASE J
  1242.             SELECT CASE P.Orent
  1243.                 CASE 1
  1244.                     IF Board(P.PieceX + 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1245.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1246.                     IF Board(P.PieceX - 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1247.                 CASE 2
  1248.                     IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1249.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1250.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1251.                 CASE 3
  1252.                     IF Board(P.PieceX - 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1253.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1254.                     IF Board(P.PieceX - 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1255.                 CASE 4
  1256.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1257.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1258.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1259.             END SELECT
  1260.         CASE L
  1261.             SELECT CASE P.Orent
  1262.                 CASE 1
  1263.                     IF Board(P.PieceX + 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1264.                     IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1265.                     IF Board(P.PieceX - 0, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1266.                 CASE 2
  1267.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1268.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1269.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1270.                 CASE 3
  1271.                     IF Board(P.PieceX - 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1272.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1273.                     IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1274.                 CASE 4
  1275.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1276.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1277.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1278.             END SELECT
  1279.         CASE Z
  1280.             SELECT CASE P.Orent
  1281.                 CASE 1, 3
  1282.                     IF Board(P.PieceX - 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1283.                     IF Board(P.PieceX + 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1284.                 CASE 2, 4
  1285.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1286.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1287.             END SELECT
  1288.         CASE S
  1289.             SELECT CASE P.Orent
  1290.                 CASE 1, 3
  1291.                     IF Board(P.PieceX - 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1292.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1293.                 CASE 2, 4
  1294.                     IF Board(P.PieceX + 1, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1295.                     IF Board(P.PieceX - 1, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1296.             END SELECT
  1297.         CASE O
  1298.         CASE I
  1299.             SELECT CASE P.Orent
  1300.                 CASE 1, 3
  1301.                     IF Board(P.PieceX - 0, P.PieceY + 0) > TRUE THEN result%% = TRUE
  1302.                     IF Board(P.PieceX + 0, P.PieceY + 2) > TRUE THEN result%% = TRUE
  1303.                     IF Board(P.PieceX + 0, P.PieceY + 3) > TRUE THEN result%% = TRUE
  1304.                 CASE 2, 4
  1305.                     IF Board(P.PieceX - 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1306.                     IF Board(P.PieceX + 1, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1307.                     IF P.PieceX + 2 < 12 THEN IF Board(P.PieceX + 2, P.PieceY + 1) > TRUE THEN result%% = TRUE
  1308.             END SELECT
  1309.  
  1310.     END SELECT
  1311.     CollisionRotate = result%%
  1312.  
  1313. SUB GameOver
  1314.     MenuID%% = -1 'return to title screen
  1315.     G.GameOverFlag = TRUE
  1316.     IF ButtonHeld%% THEN TIMER(TI(10)) OFF ELSE TIMER(TI(G.Level)) OFF
  1317.     _SNDSTOP BGM(G.BGM)
  1318.     _SNDPLAY SFX(3)
  1319.     _DELAY .25
  1320.     IF G.Mode = TypeA THEN
  1321.         IF G.Sound THEN _SNDPLAY SFX(7)
  1322.         FOR y% = 1 TO 20
  1323.             FOR x% = 1 TO 10
  1324.                 Board(x%, y%) = 3
  1325.             NEXT x%
  1326.             DrawBoard
  1327.             _DELAY .2
  1328.         NEXT y%
  1329.         IF P.Score > 30000 THEN EndScreen
  1330.         IF P.Score > G.HScore3 THEN HighScoreScreen
  1331.     END IF
  1332.  
  1333.     IF G.Mode = TypeB AND P.Lines = 0 THEN
  1334.         IF G.Sound THEN _SNDPLAY SFX(8)
  1335.         FOR w%% = 1 TO 4
  1336.             _PUTIMAGE (276 - 16 * w%%, 206), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1337.             _PUTIMAGE (276 - 16 * w%%, 252)-(291 - 16 * w%%, 237), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1338.             _PUTIMAGE (260 + 16 * w%%, 206), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1339.             _PUTIMAGE (260 + 16 * w%%, 252)-(276 + 16 * w%%, 237), FieldB, _DISPLAY, (15, 0)-(31, 15)
  1340.             _DELAY .0375
  1341.         NEXT w%%
  1342.         _PUTIMAGE (196, 206), FieldB, _DISPLAY, (0, 0)-(15, 15)
  1343.         _PUTIMAGE (196, 222), FieldB, _DISPLAY, (0, 16)-(15, 31)
  1344.         _PUTIMAGE (196, 252)-(211, 237), FieldB, _DISPLAY, (0, 0)-(15, 15)
  1345.         _PUTIMAGE (341, 206), FieldB, _DISPLAY, (32, 0)-(47, 15)
  1346.         _PUTIMAGE (356, 222)-(341, 237), FieldB, _DISPLAY, (0, 16)-(15, 31)
  1347.         _PUTIMAGE (341, 252)-(356, 237), FieldB, _DISPLAY, (32, 0)-(47, 15)
  1348.         _PRINTSTRING (214, 220), "SUCCESS!", _DISPLAY
  1349.         _DELAY 1.75
  1350.         EndScreenB
  1351.         IF P.Score > G.HScore3B THEN HighScoreScreen
  1352.     ELSE
  1353.         IF G.Sound THEN _SNDPLAY SFX(7)
  1354.         FOR y% = 1 TO 20
  1355.             FOR x% = 1 TO 10
  1356.                 Board(x%, y%) = 3
  1357.             NEXT x%
  1358.             DrawBoard
  1359.             _DELAY .2
  1360.         NEXT y%
  1361.         ' iF P.Score > G.HScore3B THEN HighScoreScreen
  1362.     END IF
  1363.     _DELAY 2.5
  1364.  
  1365. FUNCTION ClickInteraction (x%, y%)
  1366.     IF x% > 570 AND y% > 130 AND x% < 710 AND y% < 175 THEN 'next
  1367.         result%% = TRUE
  1368.     END IF
  1369.     IF x% > 570 AND y% > 200 AND x% < 710 AND y% < 245 THEN 'go back
  1370.         result%% = BACK
  1371.     END IF
  1372.     IF x% > 570 AND y% > 400 AND x% < 710 AND y% < 445 THEN 'quit
  1373.         result%% = QUIT
  1374.     END IF
  1375.  
  1376.     ClickInteraction = result%%
  1377.  
  1378. SUB EndScreen
  1379.     _SNDLOOP BGM(4)
  1380.     COLOR _RGB32(250, 250, 250), _RGB32(0, 89, 251)
  1381.     LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  1382.     _PUTIMAGE (5, 5), EndScrnA, _DISPLAY, (64, 16)-(574, 462)
  1383.     v$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(P.Score)))) + LTRIM$(STR$(P.Score))
  1384.     _PRINTSTRING (225, 50), v$, _DISPLAY
  1385.     SELECT CASE P.Score
  1386.         CASE 30000 TO 49999
  1387.             _PUTIMAGE (168, 373), EndSprtA, _DISPLAY, (98, 0)-(113, 15)
  1388.             _DELAY 2.75
  1389.             FOR w% = 0 TO 72
  1390.                 y% = y% + (16 * (w% / 100))
  1391.                 _PUTIMAGE (168, 373 - y%), EndSprtA, _DISPLAY, (98, 0)-(113, 15)
  1392.                 SELECT CASE INT(RND * 3) + 1
  1393.                     CASE 1
  1394.                         _PUTIMAGE (167, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1395.                     CASE 2
  1396.                         _PUTIMAGE (167, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1397.                     CASE 3
  1398.                         _PUTIMAGE (167, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1399.                 END SELECT
  1400.                 _DELAY .05
  1401.                 _PUTIMAGE (168, 388 - y%), EndScrnA, _DISPLAY, (168 + 59, 373 + 10 - y%)-(184 + 59, 388 + 10 - y%)
  1402.                 _PUTIMAGE (168, 388 - y%), EndScrnA, _DISPLAY, (168 + 59, 389 + 10 - y%)-(184 + 59, 405 + 10 - y%)
  1403.             NEXT w%
  1404.         CASE 50000 TO 74999
  1405.             _PUTIMAGE (168, 357), EndSprtA, _DISPLAY, (82, 0)-(97, 31)
  1406.             _DELAY 2.75
  1407.             FOR w% = 0 TO 72
  1408.                 y% = y% + (16 * (w% / 100))
  1409.                 _PUTIMAGE (168, 357 - y%), EndSprtA, _DISPLAY, (82, 0)-(97, 31)
  1410.                 SELECT CASE INT(RND * 3) + 1
  1411.                     CASE 1
  1412.                         _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1413.                     CASE 2
  1414.                         _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1415.                     CASE 3
  1416.                         _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1417.                 END SELECT
  1418.                 _DELAY .05
  1419.                 _PUTIMAGE (168, 356 - y%), EndScrnA, _DISPLAY, (168 + 59, 357 + 10 - y%)-(184 + 59, 389 + 10 - y%)
  1420.                 _PUTIMAGE (168, 388 - y%), EndScrnA, _DISPLAY, (168 + 59, 389 + 10 - y%)-(184 + 59, 405 + 10 - y%)
  1421.             NEXT w%
  1422.         CASE 75000 TO 99999
  1423.             _PUTIMAGE (160, 325), EndSprtA, _DISPLAY, (50, 0)-(79, 63)
  1424.             _DELAY 2.75
  1425.             FOR w% = 0 TO 72
  1426.                 y% = y% + (16 * (w% / 100))
  1427.                 _PUTIMAGE (160, 325 - y%), EndSprtA, _DISPLAY, (50, 0)-(79, 63)
  1428.                 SELECT CASE INT(RND * 3) + 1
  1429.                     CASE 1
  1430.                         _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1431.                         _PUTIMAGE (172, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1432.                     CASE 2
  1433.                         _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1434.                         _PUTIMAGE (172, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1435.                     CASE 3
  1436.                         _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1437.                         _PUTIMAGE (172, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1438.                 END SELECT
  1439.                 _DELAY .05
  1440.                 _PUTIMAGE (160, 325 - y%), EndScrnA, _DISPLAY, (160 + 59, 325 + 10 - y%)-(192 + 59, 389 + 10 - y%)
  1441.                 _PUTIMAGE (160, 388 - y%), EndScrnA, _DISPLAY, (160 + 59, 389 + 10 - y%)-(192 + 59, 405 + 10 - y%)
  1442.             NEXT w%
  1443.         CASE 100000 TO 149999
  1444.             _PUTIMAGE (160, 278), EndSprtA, _DISPLAY, (0, 0)-(49, 112)
  1445.             _DELAY 2.75
  1446.             FOR w% = 0 TO 72
  1447.                 y% = y% + (16 * (w% / 100))
  1448.                 _PUTIMAGE (160, 278 - y%), EndSprtA, _DISPLAY, (0, 0)-(49, 112)
  1449.                 SELECT CASE INT(RND * 3) + 1
  1450.                     CASE 1
  1451.                         _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1452.                         _PUTIMAGE (177, 389 - y%), EndSprtA, _DISPLAY, (0, 114)-(15, 129)
  1453.                         _PUTIMAGE (192, 389 - y%), EndSprtA, _DISPLAY, (98, 16)-(113, 31)
  1454.                     CASE 2
  1455.                         _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1456.                         _PUTIMAGE (176, 389 - y%), EndSprtA, _DISPLAY, (16, 114)-(33, 129)
  1457.                         _PUTIMAGE (192, 389 - y%), EndSprtA, _DISPLAY, (98, 32)-(113, 47)
  1458.                     CASE 3
  1459.                         _PUTIMAGE (162, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1460.                         _PUTIMAGE (168, 389 - y%), EndSprtA, _DISPLAY, (0, 130)-(31, 161)
  1461.                         _PUTIMAGE (192, 389 - y%), EndSprtA, _DISPLAY, (98, 48)-(113, 63)
  1462.                 END SELECT
  1463.                 _DELAY .05
  1464.                 _PUTIMAGE (160, 278 - y%), EndScrnA, _DISPLAY, (160 + 59, 279 + 10 - y%)-(212 + 59, 389 + 10 - y%)
  1465.                 _PUTIMAGE (160, 388 - y%), EndScrnA, _DISPLAY, (160 + 59, 389 + 10 - y%)-(212 + 59, 421 + 10 - y%)
  1466.             NEXT w%
  1467.         CASE IS > 150000
  1468.     END SELECT
  1469.     COLOR _RGB(255, 255, 255), _RGB32(0, 0, 0)
  1470.     DO: LOOP UNTIL INKEY$ = CHR$(13)
  1471.  
  1472. SUB HighScoreScreen
  1473.     _KEYCLEAR
  1474.     DIM names(6) AS STRING * 1
  1475.     _PUTIMAGE (5, 5), HighS, _DISPLAY, (64, 16)-(574, 462)
  1476.     IF G.Mode = TypeA THEN
  1477.         ShowHighScoreA
  1478.         IF P.Score > G.HScore1 THEN
  1479.             G.HScore1 = P.Score: G.Hlevel1 = G.Level
  1480.             _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1)))) + LTRIM$(STR$(G.HScore1))
  1481.             _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1)))) + LTRIM$(STR$(G.Hlevel1))
  1482.             lv%% = 1: ltr%% = 65: G.HName1 = "      "
  1483.             names(1) = "A"
  1484.             FOR w%% = 2 TO 6
  1485.                 names(w%%) = " "
  1486.             NEXT w%%
  1487.             DO
  1488.                 kbd& = _KEYHIT
  1489.                 SELECT CASE kbd&
  1490.                     CASE 19200 'left
  1491.                         IF lv%% > 1 THEN lv%% = lv%% - 1
  1492.                         ltr%% = ASC(names(lv%%))
  1493.                     CASE 19712 'right
  1494.                         IF lv%% < 6 THEN lv%% = lv%% + 1
  1495.                         ltr%% = ASC(names(lv%%))
  1496.                     CASE 18432 'up
  1497.                         ltr%% = ltr%% + 1
  1498.                         IF ltr%% = 91 THEN ltr%% = 64
  1499.                     CASE 20480 'down
  1500.                         ltr%% = ltr%% - 1
  1501.                         IF ltr%% = 63 THEN ltr%% = 90
  1502.                     CASE 13, 27
  1503.                         exitflag%% = TRUE
  1504.                 END SELECT
  1505.                 IF ltr%% = 64 THEN ltr%% = 32
  1506.                 names(lv%%) = CHR$(ltr%%)
  1507.                 IF ltr%% = 32 THEN ltr%% = 64
  1508.                 G.HName1 = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1509.                 _PRINTSTRING (150, 306), G.HName1
  1510.                 LINE (150 + ((lv%% - 1) * 16), 326)-(166 + ((lv%% - 1) * 16), 328), _RGB32(212, 64, 48), BF
  1511.                 _DELAY .02
  1512.                 LINE (150, 326)-(256, 328), _RGB32(0, 0, 0), BF
  1513.             LOOP UNTIL exitflag%%
  1514.         ELSEIF P.Score > G.HScore2 THEN
  1515.             G.HScore2 = P.Score: G.Hlevel2 = G.Level
  1516.             _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2)))) + LTRIM$(STR$(G.HScore2))
  1517.             _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2)))) + LTRIM$(STR$(G.Hlevel2))
  1518.             lv%% = 1: ltr%% = 65: G.HName2 = "      "
  1519.             FOR w%% = 1 TO 6
  1520.                 names(w%%) = " "
  1521.             NEXT w%%
  1522.             DO
  1523.                 kbd& = _KEYHIT
  1524.                 SELECT CASE kbd&
  1525.                     CASE 19200 'left
  1526.                         IF lv%% > 1 THEN lv%% = lv%% - 1
  1527.                         ltr%% = ASC(names(lv%%))
  1528.                     CASE 19712 'right
  1529.                         IF lv%% < 6 THEN lv%% = lv%% + 1
  1530.                         ltr%% = ASC(names(lv%%))
  1531.                     CASE 18432 'up
  1532.                         ltr%% = ltr%% + 1
  1533.                         IF ltr%% = 91 THEN ltr%% = 64
  1534.                     CASE 20480 'down
  1535.                         ltr%% = ltr%% - 1
  1536.                         IF ltr%% = 63 THEN ltr%% = 90
  1537.                     CASE 13, 27
  1538.                         exitflag%% = TRUE
  1539.                 END SELECT
  1540.                 IF ltr%% = 64 THEN ltr%% = 32
  1541.                 names(lv%%) = CHR$(ltr%%)
  1542.                 IF ltr%% = 32 THEN ltr%% = 64
  1543.                 G.HName2 = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1544.                 _PRINTSTRING (150, 338), G.HName2
  1545.                 LINE (150 + ((lv%% - 1) * 16), 358)-(166 + ((lv%% - 1) * 16), 360), _RGB32(212, 64, 48), BF
  1546.                 _DELAY .02
  1547.                 LINE (150, 358)-(256, 360), _RGB32(0, 0, 0), BF
  1548.             LOOP UNTIL exitflag%%
  1549.         ELSEIF P.Score > G.HScore3 THEN
  1550.             G.HScore3 = P.Score: G.Hlevel3 = G.Level
  1551.             _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3)))) + LTRIM$(STR$(G.HScore3))
  1552.             _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3)))) + LTRIM$(STR$(G.Hlevel3))
  1553.             lv%% = 1: ltr%% = 65: G.HName3 = "      "
  1554.             FOR w%% = 1 TO 6
  1555.                 names(w%%) = " "
  1556.             NEXT w%%
  1557.             DO
  1558.                 kbd& = _KEYHIT
  1559.                 SELECT CASE kbd&
  1560.                     CASE 19200 'left
  1561.                         IF lv%% > 1 THEN lv%% = lv%% - 1
  1562.                         ltr%% = ASC(names(lv%%))
  1563.                     CASE 19712 'right
  1564.                         IF lv%% < 6 THEN lv%% = lv%% + 1
  1565.                         ltr%% = ASC(names(lv%%))
  1566.                     CASE 18432 'up
  1567.                         ltr%% = ltr%% + 1
  1568.                         IF ltr%% = 91 THEN ltr%% = 64
  1569.                     CASE 20480 'down
  1570.                         ltr%% = ltr%% - 1
  1571.                         IF ltr%% = 63 THEN ltr%% = 90
  1572.                     CASE 13, 27
  1573.                         exitflag%% = TRUE
  1574.                 END SELECT
  1575.                 IF ltr%% = 64 THEN ltr%% = 32
  1576.                 names(lv%%) = CHR$(ltr%%)
  1577.                 IF ltr%% = 32 THEN ltr%% = 64
  1578.                 G.HName3 = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1579.                 _PRINTSTRING (150, 370), G.HName3
  1580.                 LINE (150 + ((lv%% - 1) * 16), 390)-(166 + ((lv%% - 1) * 16), 392), _RGB32(212, 64, 48), BF
  1581.                 _DELAY .02
  1582.                 LINE (150, 390)-(256, 392), _RGB32(0, 0, 0), BF
  1583.             LOOP UNTIL exitflag%%
  1584.         END IF
  1585.         _KEYCLEAR
  1586.  
  1587.     ELSE
  1588.         ShowHighScoreB
  1589.         IF P.Score > G.HScore1B THEN
  1590.             G.HScore1B = P.Score: G.Hlevel1B = G.Level
  1591.             _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1B)))) + LTRIM$(STR$(G.HScore1B))
  1592.             _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1B)))) + LTRIM$(STR$(G.Hlevel1B))
  1593.             lv%% = 1: ltr%% = 65: G.HName1B = "      "
  1594.             FOR w%% = 1 TO 6
  1595.                 names(w%%) = " "
  1596.             NEXT w%%
  1597.             DO
  1598.                 kbd& = _KEYHIT
  1599.                 SELECT CASE kbd&
  1600.                     CASE 19200 'left
  1601.                         IF lv%% > 1 THEN lv%% = lv%% - 1
  1602.                         ltr%% = ASC(names(lv%%))
  1603.                     CASE 19712 'right
  1604.                         IF lv%% < 6 THEN lv%% = lv%% + 1
  1605.                         ltr%% = ASC(names(lv%%))
  1606.                     CASE 18432 'up
  1607.                         ltr%% = ltr%% + 1
  1608.                         IF ltr%% = 91 THEN ltr%% = 64
  1609.                     CASE 20480 'down
  1610.                         ltr%% = ltr%% - 1
  1611.                         IF ltr%% = 63 THEN ltr%% = 90
  1612.                     CASE 13, 27
  1613.                         exitflag%% = TRUE
  1614.                 END SELECT
  1615.                 IF ltr%% = 64 THEN ltr%% = 32
  1616.                 names(lv%%) = CHR$(ltr%%)
  1617.                 IF ltr%% = 32 THEN ltr%% = 64
  1618.                 G.HName1B = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1619.                 _PRINTSTRING (150, 306), G.HName1B
  1620.                 LINE (150 + ((lv%% - 1) * 16), 326)-(166 + ((lv%% - 1) * 16), 328), _RGB32(212, 64, 48), BF
  1621.                 _DELAY .02
  1622.                 LINE (150, 326)-(256, 328), _RGB32(0, 0, 0), BF
  1623.             LOOP UNTIL exitflag%%
  1624.         ELSEIF P.Score > G.HScore2B THEN
  1625.             G.HScore2B = P.Score: G.Hlevel2B = G.Level
  1626.             _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2B)))) + LTRIM$(STR$(G.HScore2B))
  1627.             _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2B)))) + LTRIM$(STR$(G.Hlevel2B))
  1628.             lv%% = 1: ltr%% = 65: G.HName2B = "      "
  1629.             FOR w%% = 1 TO 6
  1630.                 names(w%%) = " "
  1631.             NEXT w%%
  1632.             DO
  1633.                 kbd& = _KEYHIT
  1634.                 SELECT CASE kbd&
  1635.                     CASE 19200 'left
  1636.                         IF lv%% > 1 THEN lv%% = lv%% - 1
  1637.                         ltr%% = ASC(names(lv%%))
  1638.                     CASE 19712 'right
  1639.                         IF lv%% < 6 THEN lv%% = lv%% + 1
  1640.                         ltr%% = ASC(names(lv%%))
  1641.                     CASE 18432 'up
  1642.                         ltr%% = ltr%% + 1
  1643.                         IF ltr%% = 91 THEN ltr%% = 64
  1644.                     CASE 20480 'down
  1645.                         ltr%% = ltr%% - 1
  1646.                         IF ltr%% = 63 THEN ltr%% = 90
  1647.                     CASE 13, 27
  1648.                         exitflag%% = TRUE
  1649.                 END SELECT
  1650.                 IF ltr%% = 64 THEN ltr%% = 32
  1651.                 names(lv%%) = CHR$(ltr%%)
  1652.                 IF ltr%% = 32 THEN ltr%% = 64
  1653.                 G.HName2B = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1654.                 _PRINTSTRING (150, 338), G.HName2B
  1655.                 LINE (150 + ((lv%% - 1) * 16), 358)-(166 + ((lv%% - 1) * 16), 360), _RGB32(212, 64, 48), BF
  1656.                 _DELAY .02
  1657.                 LINE (150, 358)-(256, 360), _RGB32(0, 0, 0), BF
  1658.             LOOP UNTIL exitflag%%
  1659.         ELSEIF P.Score > G.HScore3B THEN
  1660.             G.HScore3B = P.Score: G.Hlevel3B = G.Level
  1661.             _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3B)))) + LTRIM$(STR$(G.HScore3B))
  1662.             _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3B)))) + LTRIM$(STR$(G.Hlevel3B))
  1663.             lv%% = 1: ltr%% = 65: G.HName3B = "      "
  1664.             FOR w%% = 1 TO 6
  1665.                 names(w%%) = " "
  1666.             NEXT w%%
  1667.             DO
  1668.                 kbd& = _KEYHIT
  1669.                 SELECT CASE kbd&
  1670.                     CASE 19200 'left
  1671.                         IF lv%% > 1 THEN lv%% = lv%% - 1
  1672.                         ltr%% = ASC(names(lv%%))
  1673.                     CASE 19712 'right
  1674.                         IF lv%% < 6 THEN lv%% = lv%% + 1
  1675.                         ltr%% = ASC(names(lv%%))
  1676.                     CASE 18432 'up
  1677.                         ltr%% = ltr%% + 1
  1678.                         IF ltr%% = 91 THEN ltr%% = 64
  1679.                     CASE 20480 'down
  1680.                         ltr%% = ltr%% - 1
  1681.                         IF ltr%% = 63 THEN ltr%% = 90
  1682.                     CASE 13, 27
  1683.                         exitflag%% = TRUE
  1684.                 END SELECT
  1685.                 IF ltr%% = 64 THEN ltr%% = 32
  1686.                 names(lv%%) = CHR$(ltr%%)
  1687.                 IF ltr%% = 32 THEN ltr%% = 64
  1688.                 G.HName3B = names(1) + names(2) + names(3) + names(4) + names(5) + names(6)
  1689.                 _PRINTSTRING (150, 370), G.HName3B
  1690.                 LINE (150 + ((lv%% - 1) * 16), 390)-(166 + ((lv%% - 1) * 16), 392), _RGB32(212, 64, 48), BF
  1691.                 _DELAY .02
  1692.                 LINE (150, 390)-(256, 392), _RGB32(0, 0, 0), BF
  1693.             LOOP UNTIL exitflag%%
  1694.         END IF
  1695.         _KEYCLEAR
  1696.     END IF
  1697.  
  1698. SUB ShowHighScoreA
  1699.     _PRINTSTRING (150, 306), G.HName1
  1700.     _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1)))) + LTRIM$(STR$(G.HScore1))
  1701.     _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1)))) + LTRIM$(STR$(G.Hlevel1))
  1702.     _PRINTSTRING (150, 338), G.HName2
  1703.     _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2)))) + LTRIM$(STR$(G.HScore2))
  1704.     _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2)))) + LTRIM$(STR$(G.Hlevel2))
  1705.     _PRINTSTRING (150, 370), G.HName3
  1706.     _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3)))) + LTRIM$(STR$(G.HScore3))
  1707.     _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3)))) + LTRIM$(STR$(G.Hlevel3))
  1708.  
  1709. SUB ShowHighScoreB
  1710.     _PRINTSTRING (150, 306), G.HName1B
  1711.     _PRINTSTRING (264, 306), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore1B)))) + LTRIM$(STR$(G.HScore1B))
  1712.     _PRINTSTRING (376, 306), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel1B)))) + LTRIM$(STR$(G.Hlevel1B))
  1713.     _PRINTSTRING (150, 338), G.HName2B
  1714.     _PRINTSTRING (264, 338), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore2B)))) + LTRIM$(STR$(G.HScore2B))
  1715.     _PRINTSTRING (376, 338), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel2B)))) + LTRIM$(STR$(G.Hlevel2B))
  1716.     _PRINTSTRING (150, 370), G.HName3B
  1717.     _PRINTSTRING (264, 370), LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.HScore3B)))) + LTRIM$(STR$(G.HScore3B))
  1718.     _PRINTSTRING (376, 370), LEFT$("00", 2 - LEN(LTRIM$(STR$(G.Hlevel3B)))) + LTRIM$(STR$(G.Hlevel3B))
  1719.  
  1720. SUB MoveLeft
  1721.     SELECT CASE P.Piece
  1722.         CASE T, J, L
  1723.             SELECT CASE P.Orent
  1724.                 CASE 1, 2, 3
  1725.                     IF P.PieceX = 1 THEN P.PieceX = 2
  1726.                 CASE 4
  1727.                     IF P.PieceX = 0 THEN P.PieceX = 1
  1728.             END SELECT
  1729.         CASE Z
  1730.             SELECT CASE P.Orent
  1731.                 CASE 1 TO 4
  1732.                     IF P.PieceX = 1 THEN P.PieceX = 2
  1733.             END SELECT
  1734.         CASE S
  1735.             SELECT CASE P.Orent
  1736.                 CASE 1, 3
  1737.                     IF P.PieceX = 1 THEN P.PieceX = 2
  1738.                 CASE 2, 4
  1739.                     IF P.PieceX = 0 THEN P.PieceX = 1
  1740.             END SELECT
  1741.         CASE O
  1742.             SELECT CASE P.Orent
  1743.                 CASE 1 TO 4
  1744.                     IF P.PieceX = 1 THEN P.PieceX = 2
  1745.             END SELECT
  1746.         CASE I
  1747.             SELECT CASE P.Orent
  1748.                 CASE 2, 4
  1749.                     IF P.PieceX = 0 THEN P.PieceX = 1
  1750.                 CASE 1, 3
  1751.                     IF P.PieceX = 1 THEN P.PieceX = 2
  1752.             END SELECT
  1753.     END SELECT
  1754.  
  1755. SUB MoveRight
  1756.     SELECT CASE P.Piece
  1757.         CASE T, J, L
  1758.             SELECT CASE P.Orent
  1759.                 CASE 1, 3, 4
  1760.                     IF P.PieceX = 10 THEN P.PieceX = 9
  1761.                 CASE 2
  1762.                     IF P.PieceX = 11 THEN P.PieceX = 10
  1763.             END SELECT
  1764.         CASE Z
  1765.             SELECT CASE P.Orent
  1766.                 CASE 1, 3
  1767.                     IF P.PieceX = 10 THEN P.PieceX = 9
  1768.                 CASE 2, 4
  1769.                     IF P.PieceX = 11 THEN P.PieceX = 10
  1770.             END SELECT
  1771.         CASE S
  1772.             SELECT CASE P.Orent
  1773.                 CASE 1, 3
  1774.                     IF P.PieceX = 10 THEN P.PieceX = 9
  1775.                 CASE 2, 4
  1776.                     IF P.PieceX = 10 THEN P.PieceX = 9
  1777.             END SELECT
  1778.         CASE O
  1779.             SELECT CASE P.Orent
  1780.                 CASE 1 TO 4
  1781.                     IF P.PieceX = 11 THEN P.PieceX = 10
  1782.             END SELECT
  1783.         CASE I
  1784.             SELECT CASE P.Orent
  1785.                 CASE 2, 4
  1786.                     IF P.PieceX = 11 THEN P.PieceX = 10
  1787.                 CASE 1, 3
  1788.                     IF P.PieceX = 9 THEN P.PieceX = 8
  1789.             END SELECT
  1790.     END SELECT
  1791.  
  1792. SUB StartData
  1793.     IF G.HScore1 = 0 THEN
  1794.         G.BGMVol = 50
  1795.         G.SFXVol = 50
  1796.         G.Mode = TypeA
  1797.         G.BGM = Song1
  1798.         G.HScore1 = 15000
  1799.         G.HScore2 = 10000
  1800.         G.HScore3 = 5000
  1801.         G.Hlevel1 = 10
  1802.         G.Hlevel2 = 5
  1803.         G.Hlevel3 = 1
  1804.         G.HName1 = "Narika"
  1805.         G.HName2 = "Cobalt"
  1806.         G.HName3 = "Ninten"
  1807.         G.HScore1B = 5000
  1808.         G.HScore2B = 3000
  1809.         G.HScore3B = 1000
  1810.         G.Hlevel1B = 10
  1811.         G.Hlevel2B = 5
  1812.         G.Hlevel3B = 1
  1813.         G.HName1B = "Nobody"
  1814.         G.HName2B = "anybdy"
  1815.         G.HName3B = "losers"
  1816.  
  1817.         G.Level = 0
  1818.         P.Score = 0
  1819.     ELSE
  1820.         G.GameOverFlag = FALSE
  1821.         G.Level = 0
  1822.         P.Score = 0
  1823.         P.Lines = 0
  1824.         BoardSetup
  1825.     END IF
  1826.  
  1827. SUB BTypeHeight
  1828.     'Btype height * 3 lines
  1829.     IF G.Height > 0 THEN
  1830.         FOR y%% = 20 TO (20 - (G.Height * 3)) + 1 STEP -1
  1831.             FOR x%% = 1 TO 10
  1832.                 garbage%% = INT(RND * 100) + 1
  1833.                 IF garbage%% > 45 THEN Board(x%%, y%%) = INT(RND * 3)
  1834.             NEXT x%%
  1835.         NEXT y%%
  1836.     END IF
  1837.  
  1838. SUB GameModeA
  1839.     LINE (0, 0)-(799, 480), _RGB32(0, 0, 0), BF
  1840.     _PUTIMAGE (5, 5), FieldA, _DISPLAY, (64, 16)-(574, 462)
  1841.     P.NextP = INT(RND * 7) + 1
  1842.     NewPiece
  1843.     PlaceTetraNome
  1844.     TIMER(TI(G.Level)) ON
  1845.     DO
  1846.         KBD& = _KEYHIT
  1847.         SELECT CASE KBD&
  1848.             CASE 19200 'left
  1849.                 IF NOT CollisionLeft THEN
  1850.                     IF G.Sound THEN _SNDPLAY SFX(4)
  1851.                     P.PieceX = P.PieceX - 1
  1852.                     MoveLeft
  1853.                 END IF
  1854.             CASE 19712 'right
  1855.                 IF NOT CollisionRight THEN
  1856.                     IF G.Sound THEN _SNDPLAY SFX(4)
  1857.                     P.PieceX = P.PieceX + 1
  1858.                     MoveRight
  1859.                 END IF
  1860.             CASE 20480 'Down
  1861.                 IF ButtonHeld%% = FALSE THEN 'if player holds the down arrow switch to faster timer
  1862.                     TIMER(TI(G.Level)) OFF
  1863.                     TIMER(TI(10)) ON
  1864.                     ButtonHeld%% = TRUE
  1865.                 END IF
  1866.             CASE 32 'space
  1867.                 'rotational point is second block, top row if app.
  1868.                 IF NOT CollisionRotate THEN
  1869.                     P.Orent = P.Orent + 1
  1870.                     IF P.Orent = 5 THEN P.Orent = 1
  1871.                     IF G.Sound THEN _SNDPLAY SFX(3)
  1872.                     SELECT CASE P.Piece
  1873.                         CASE T, J, L
  1874.                             'if piece is to close to edge to rotate then bump it out 1
  1875.                             IF P.PieceX = 1 AND P.Orent <> 4 THEN P.PieceX = 2
  1876.                             IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1877.                         CASE Z
  1878.                             IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1879.                         CASE O
  1880.                         CASE S
  1881.                             IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1882.                         CASE I
  1883.                             IF P.PieceX = 1 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 2
  1884.                             IF P.PieceX = 10 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 8
  1885.                     END SELECT
  1886.                 END IF
  1887.                 _KEYCLEAR
  1888.             CASE 27 'Esc
  1889.                 exitflag%% = TRUE
  1890.                 QuitGameFlag%% = TRUE
  1891.         END SELECT
  1892.  
  1893.         IF NOT _KEYDOWN(20480) AND ButtonHeld%% THEN 'if player releases the down arrow restore timer
  1894.             ButtonHeld%% = FALSE
  1895.             TIMER(TI(10)) OFF
  1896.             TIMER(TI(G.Level)) ON
  1897.             P.bonus = 0
  1898.         END IF
  1899.  
  1900.         LINE (197, 85)-(197 + 159, 85 + 319), _RGB32(0, 0, 0), BF
  1901.         DrawBoard
  1902.         PlaceTetraNome
  1903.         _DELAY .01
  1904.         IF G.GameOverFlag THEN exitflag%% = TRUE
  1905.     LOOP UNTIL exitflag%%
  1906.     TIMER(TI(G.Level)) OFF
  1907.  
  1908. SUB GameModeB
  1909.     LINE (0, 0)-(799, 480), _RGB32(0, 0, 0), BF
  1910.     _PUTIMAGE (5, 5), FieldB, _DISPLAY, (64, 16)-(574, 462)
  1911.     P.NextP = INT(RND * 7) + 1
  1912.     BTypeHeight
  1913.     NewPiece
  1914.     PlaceTetraNome
  1915.     TIMER(TI(G.Level)) ON
  1916.     DO
  1917.         KBD& = _KEYHIT
  1918.         SELECT CASE KBD&
  1919.             CASE 19200 'left
  1920.                 IF NOT CollisionLeft THEN
  1921.                     IF G.Sound THEN _SNDPLAY SFX(4)
  1922.                     P.PieceX = P.PieceX - 1
  1923.                     MoveLeft
  1924.                 END IF
  1925.             CASE 19712 'right
  1926.                 IF NOT CollisionRight THEN
  1927.                     IF G.Sound THEN _SNDPLAY SFX(4)
  1928.                     P.PieceX = P.PieceX + 1
  1929.                     MoveRight
  1930.                 END IF
  1931.             CASE 20480 'Down
  1932.                 IF ButtonHeld%% = FALSE THEN 'if player holds the down arrow switch to faster timer
  1933.                     TIMER(TI(G.Level)) OFF
  1934.                     TIMER(TI(10)) ON
  1935.                     ButtonHeld%% = TRUE
  1936.                 END IF
  1937.             CASE 32 'space
  1938.                 'rotational point is second block, top row if app.
  1939.                 IF NOT CollisionRotate THEN
  1940.                     IF G.Sound THEN _SNDPLAY SFX(3)
  1941.                     P.Orent = P.Orent + 1
  1942.                     IF P.Orent = 5 THEN P.Orent = 1
  1943.                     SELECT CASE P.Piece
  1944.                         CASE T, J, L
  1945.                             'if piece is to close to edge to rotate then bump it out 1
  1946.                             IF P.PieceX = 1 AND P.Orent <> 4 THEN P.PieceX = 2
  1947.                             IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1948.                         CASE Z
  1949.                             IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1950.                         CASE O
  1951.                         CASE S
  1952.                             IF P.PieceX = 10 AND P.Orent <> 2 THEN P.PieceX = 9
  1953.                         CASE I
  1954.                             IF P.PieceX = 1 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 2
  1955.                             IF P.PieceX = 10 AND (P.Orent <> 1 OR P.Orent <> 3) THEN P.PieceX = 8
  1956.                     END SELECT
  1957.                 END IF
  1958.                 _KEYCLEAR
  1959.             CASE 27 'Esc
  1960.                 exitflag%% = TRUE
  1961.                 QuitGameFlag%% = TRUE
  1962.         END SELECT
  1963.  
  1964.         IF NOT _KEYDOWN(20480) AND ButtonHeld%% THEN 'if player releases the down arrow restore timer
  1965.             ButtonHeld%% = FALSE
  1966.             TIMER(TI(10)) OFF
  1967.             TIMER(TI(G.Level)) ON
  1968.             P.bonus = 0
  1969.         END IF
  1970.  
  1971.         LINE (197, 85)-(197 + 159, 85 + 319), _RGB32(0, 0, 0), BF
  1972.         DrawBoard
  1973.         PlaceTetraNome
  1974.         _DELAY .01
  1975.         IF G.GameOverFlag THEN exitflag%% = TRUE
  1976.     LOOP UNTIL exitflag%%
  1977.     TIMER(TI(G.Level)) OFF
  1978.  
  1979. SUB DisplayClickOptions
  1980.     _PRINTSTRING (570, 130), "Click here"
  1981.     _PRINTSTRING (570, 150), "to Continue"
  1982.  
  1983.     _PRINTSTRING (570, 200), "Click here"
  1984.     _PRINTSTRING (570, 220), "to go Back"
  1985.  
  1986.     _PRINTSTRING (570, 400), "Click here"
  1987.     _PRINTSTRING (570, 420), "Exit Game"
  1988.  
  1989. FUNCTION LoadGFX& (Foff&, Size&)
  1990.     IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1991.     OPEN "temp.dat" FOR BINARY AS #3
  1992.     dat$ = SPACE$(Size&)
  1993.     GET #1, Foff&, dat$
  1994.     PUT #3, , dat$
  1995.     CLOSE #3
  1996.     LoadGFX& = _LOADIMAGE("temp.dat", 32)
  1997.  
  1998. SUB EndScreenB
  1999.  
  2000.     ST1& = _FREETIMER
  2001.     ON TIMER(ST1&, .025) TypeBAnimation
  2002.     CLS
  2003.     COLOR _RGB32(250, 250, 250), _RGB32(0, 89, 251)
  2004.     LINE (0, 0)-(512, 480), _RGB32(0, 0, 0), BF
  2005.     _PUTIMAGE (5, 5), EndScrnB, _DISPLAY, (64, 16)-(574, 462)
  2006.     _PUTIMAGE (112, 68), EndScrnB, _DISPLAY, (100, 180)-(210, 220)
  2007.     _PUTIMAGE (116, 71), EndScrnB, _DISPLAY, (176, 80)-(254, 93)
  2008.     _PUTIMAGE (116, 89), EndScrnB, _DISPLAY, (176, 96)-(272, 110)
  2009.     v$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(P.Score)))) + LTRIM$(STR$(P.Score))
  2010.     v1$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.Level * 1000)))) + LTRIM$(STR$(G.Level * 1000))
  2011.     v2$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(G.Height * 1000)))) + LTRIM$(STR$(G.Height * 1000))
  2012.     v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  2013.     _PRINTSTRING (225, 50), v$, _DISPLAY
  2014.     _PRINTSTRING (225, 68), v1$, _DISPLAY
  2015.     _PRINTSTRING (225, 86), v2$, _DISPLAY
  2016.     _PRINTSTRING (225, 130), v3$, _DISPLAY
  2017.  
  2018.     _PUTIMAGE (0, 0), _DISPLAY, Temp&, (0, 0)-(511, 479) 'make backup of screen
  2019.     TIMER(ST1&) ON
  2020.     _DELAY 1
  2021.     total& = P.Score
  2022.     _PRINTSTRING (225, 50), v3$, _DISPLAY
  2023.  
  2024.     current = _DEST
  2025.     _DEST Temp&
  2026.     _PRINTSTRING (225, 50), v3$, Temp&
  2027.     _DEST current
  2028.  
  2029.  
  2030.  
  2031.     v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  2032.     _PRINTSTRING (225, 130), v3$, _DISPLAY
  2033.  
  2034.  
  2035.     _DEST Temp&
  2036.     _PRINTSTRING (225, 130), v3$, Temp&
  2037.     _DEST current
  2038.  
  2039.     _DELAY .25
  2040.     b1% = G.Level * 1000
  2041.     FOR w% = b1% TO 0 STEP -100
  2042.         total& = total& + 100
  2043.         v1$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(w%)))) + LTRIM$(STR$(w%))
  2044.         _PRINTSTRING (225, 68), v1$, _DISPLAY
  2045.  
  2046.         _DEST Temp&
  2047.         _PRINTSTRING (225, 68), v1$, Temp&
  2048.         _DEST current
  2049.  
  2050.  
  2051.         v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  2052.         _PRINTSTRING (225, 130), v3$, _DISPLAY
  2053.  
  2054.         _DEST Temp&
  2055.         _PRINTSTRING (225, 130), v3$, Temp&
  2056.         _DEST current
  2057.  
  2058.         _DELAY .05
  2059.     NEXT w%
  2060.     b1% = G.Height * 1000
  2061.     FOR w% = b1% TO 0 STEP -100
  2062.         total& = total& + 100
  2063.         v2$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(w%)))) + LTRIM$(STR$(w%))
  2064.         _PRINTSTRING (225, 86), v2$, _DISPLAY
  2065.  
  2066.         _DEST Temp&
  2067.         _PRINTSTRING (225, 86), v2$, Temp&
  2068.         _DEST current
  2069.  
  2070.         v3$ = LEFT$("000000", 6 - LEN(LTRIM$(STR$(total&)))) + LTRIM$(STR$(total&))
  2071.         _PRINTSTRING (225, 130), v3$, _DISPLAY
  2072.  
  2073.         _DEST Temp&
  2074.         _PRINTSTRING (225, 130), v3$, Temp&
  2075.         _DEST current
  2076.  
  2077.         _DELAY .05
  2078.     NEXT w%
  2079.  
  2080.     _DEST Temp&
  2081.     COLOR _RGB32(254, 254, 254), _RGB32(0, 0, 0)
  2082.     _DEST current
  2083.  
  2084.     DO: _DELAY .02: LOOP UNTIL INKEY$ = CHR$(13)
  2085.     TIMER(ST1&) OFF
  2086.     TIMER(ST1&) FREE
  2087.  
  2088. SUB TypeBAnimation
  2089.     STATIC Frame%%, Xloc%(5), Yloc%(5)
  2090.     _FONT 16
  2091.     SELECT CASE G.Level
  2092.         CASE 0
  2093.             FOR w%% = 1 TO G.Height + 1
  2094.                 '     LOCATE w%%, 65: PRINT Xloc%(w%%); Frame%%
  2095.                 IF Yloc%(w%%) = 0 THEN Yloc%(w%%) = INT(RND * 300) + 100
  2096.                 '    IF Yloc%(w%%) > 120 AND Yloc%(w%%) < 146 THEN Yloc%(w%%) = Yloc%(w%%) + INT(RND * 64) + 16
  2097.                 IF Xloc%(w%%) = 0 THEN Xloc%(w%%) = INT(RND * 100) - 50
  2098.                 IF Xloc%(w%%) > 32 THEN LINE (Xloc%(w%%), Yloc%(w%%))-(Xloc%(w%%) + 16, Yloc%(w%%) + 16), _RGB32(0, 89, 251), B
  2099.                 '    _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), EndScrnB, _DISPLAY, (59 + Xloc%(w%%), 11 + Yloc%(w%%))-(59 + Xloc%(w%%) + 16, 11 + Yloc%(w%%) + 16)
  2100.                 _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), Temp&, _DISPLAY, (Xloc%(w%%), Yloc%(w%%))-(Xloc%(w%%) + 16, Yloc%(w%%) + 16)
  2101.  
  2102.                 Xloc%(w%%) = Xloc%(w%%) + 1: IF Xloc%(w%%) > 460 THEN Xloc%(w%%) = INT(RND * 100) - 50: Yloc%(w%%) = INT(RND * 300) + 100
  2103.                 SELECT CASE Frame%%
  2104.                     CASE 1 TO 12
  2105.                         IF Xloc%(w%%) > 32 THEN _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), EndSprtA, _DISPLAY, (50, 77)-(65, 92)
  2106.                     CASE 13 TO 24
  2107.                         IF Xloc%(w%%) > 32 THEN _PUTIMAGE (Xloc%(w%%), Yloc%(w%%)), EndSprtA, _DISPLAY, (66, 77)-(81, 92)
  2108.                 END SELECT
  2109.                 Frame%% = Frame%% + 1: IF Frame%% = 25 THEN Frame%% = 1
  2110.             NEXT w%%
  2111.         CASE 1
  2112.         CASE 2
  2113.         CASE 3
  2114.         CASE 4
  2115.  
  2116.     END SELECT
  2117.     _FONT FFX(1)
  2118.  
  2119.  

i know not, if it is so as you need.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem with _PRINTSTRING
« Reply #5 on: October 16, 2018, 01:34:01 pm »
The issue here is this one, broken down for simplicity's sake:

Code: QB64: [Select]
  1. one = _NEWIMAGE(640, 480, 32)
  2. two = _NEWIMAGE(640, 480, 32)
  3. SCREEN one
  4.  
  5. _PRINTSTRING (1, 1), "Hello", one
  6. _PRINTSTRING (7 * 8, 1), "World", two

_PRINTSTRING should print to the screen we specify, but it's not. 

As per: http://qb64.org/wiki/PRINTSTRING

Quote
Syntax
_PRINTSTRING(column, row), textExpression$[, imageHandle&]

Parameters
column and row are INTEGER or LONG starting PIXEL (graphic) column and row coordinates to set text or custom fonts.
textExpression$ is any literal or variable string value of text to be displayed.
imageHandle& is the optional image or destination to use. Zero designates current SCREEN page.

The imagehandle isn't working as intended with _PRINTSTRING.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem with _PRINTSTRING
« Reply #6 on: October 16, 2018, 10:02:23 pm »
....
The imagehandle isn't working as intended with _PRINTSTRING.

Ok so that part is not on me then. Good for once.

Silly me to think that when I change the font it should be Globally changed as in 'for the whole program' not just one screen layer. same for changing the COLOR too. Although I do concede that I see where it could be useful to have different fonts and COLOR setting for different layers, I just don't find it as intuitive that way.

is there any chance the ImageHandle& in _PRINTSTRING can be looked into?
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Problem with _PRINTSTRING
« Reply #7 on: October 16, 2018, 10:04:13 pm »
Each image has its own settings regarding color and font.

We’ll look into the handle issue.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem with _PRINTSTRING
« Reply #8 on: October 17, 2018, 12:43:47 pm »
Each image has its own settings regarding color and font.

We’ll look into the handle issue.

There's a really simple fix for this issue (tested on my machine, but I can't imagine that it wouldn't work on all OSes and versions). 

Open libqb.cpp.

Find the sub for printstring.  It should be down around line 18757 and look like:         void sub__printstring(float x,float y,qbs* text,int32 i,int32 passed){

Right below the if newerror line, add this little tidbit:

Code: QB64: [Select]
  1.             if (passed&2) {
  2.                 int32 old_dest = func__dest();
  3.                 sub__dest(i);
  4.             }

The above basically says, "If we pass _PRINTSTRING a handle, swap our dest over to that handle.  No need for error checking here, as sub__dest will handle that for us.

Now, here's the only part which I found to be a slight PITA -- Before each RETURN in that function, change the dest back:

Code: QB64: [Select]
  1.             if (passed&2) sub__dest(old_dest);

Since there's a ton of early exit returns (in case of errors at various steps along the way of printing), that's several different spots where we'd have to reset the DEST in case we exit the routine early...

It's probably not the most elegant of fixes, but it works, and I've always been a hack who's been more concerned about "does it do what I want", than a guy who says, "does it look pretty?"...

Feel free to make the changes and test it out for yourself if you want.  It seemed the simplest way, to me, to get _PRINTSTRING to do what it's supposed to, in this case.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: Problem with _PRINTSTRING
« Reply #9 on: October 17, 2018, 12:52:50 pm »
If it's a fix, please take some time to apply the changes to the development branch.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem with _PRINTSTRING
« Reply #10 on: October 17, 2018, 12:54:59 pm »
Try this out to make certain that it doesn't break anything with Linux/Mac first:


EDIT: 

And a quick little test program to try the changes with:

Code: QB64: [Select]
  1. one = _NEWIMAGE(640, 480, 32)
  2. two = _NEWIMAGE(640, 480, 32)
  3.  
  4. _PRINTSTRING (1, 1), "one", one
  5. _PRINTSTRING (100, 100), "two", two
  6. _PRINTSTRING (5, 5), "zero" 'screen zero which we start with, just to show the DEST didn't actually change after the _PRINTSTING calls
  7.  
  8. SCREEN one
  9. SCREEN two
  10.  
« Last Edit: October 17, 2018, 12:58:47 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Problem with _PRINTSTRING
« Reply #11 on: October 17, 2018, 01:12:32 pm »
Steve,
You put the libqb.cpp in the Internal\c  folder right? Cause its not doing anything different for me.
Still displaying to the main screen. or not at all.
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem with _PRINTSTRING
« Reply #12 on: October 17, 2018, 01:20:17 pm »
run the "purge_libqb_only.bat" in the same directory, after copying it over.  Then edit your program (just a hit of a space or backspace will work fine to tell the IDE to freshly compile and not just run the last version), and compile, to see the changes.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Problem with _PRINTSTRING
« Reply #13 on: October 17, 2018, 02:23:56 pm »
Pushed the edit into the Development branch of QB64.  If there's an issue with Linux/Mac not working properly with it, it'll be easy enough to revert back out later.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: Problem with _PRINTSTRING
« Reply #14 on: October 17, 2018, 03:36:28 pm »
Thanks, Steve!