Author Topic: Tetris 64! (Full release 1.0a[update])  (Read 10705 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
Tetris 64! (Full release 1.0a[update])
« on: October 02, 2018, 09:03:14 pm »
Say hello to Tetris64 and Narika!

Tetris is fully playable, but the high scores don't update yet.
Narika is beta clickable. She still needs a lot of work yet. Still gives you an idea of what I'm going for with her.

some Minor tweaks to hammer out yet but Just wanted to see what people though.
Game Type B is not active yet only Type A selecting Type B will just bypass the second menu and start the game as normal

Controls are as follows in game play:

Down arrow, move the piece down faster
Left and Right arrow, moves the piece in the respective direction
Space, rotates the piece.
ESC, quits

Menus are controled completely by mouse.

at the moment you have to rerun the game if you lose.

*WARNING* Apparently this will not work in LINUX at the moment. I will work on stripping all the audio out and hopefuly that will allow it to work. Sorry I didn't realize LINUX had that big of an issue with it.
« Last Edit: November 03, 2018, 07:38:38 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Tetris 64! (not linux compatable I guess)
« Reply #1 on: October 06, 2018, 02:10:56 am »
I run with 64 bit Linux Mint. Ran the game and heard the girl speak and the background music playing. Switch music on/off ok. Selected level 0 to start with and then it crashed.
Unhandled error #258
Line: 1155 (in main module)
Invalid Handle
Continue?

Looks like it has a problem with the font... I even put the font in the same directory as the 'bas' file...

I also had to include the full file path for all file references...

J

Logic is the beginning of wisdom.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Tetris 64! (not linux compatable I guess)
« Reply #2 on: October 06, 2018, 10:46:22 am »
Thats farther than Vince was able to get. After looking it up I guess its a bit of work to get the OTF to work in Linux. I've converted it to a TTF maybe that will work?
I'm sure I could bypass using a font and just sprite all the characters having a custom print routine but thats far more work than I wanted to put into it really.

Maybe if someone could see if the TTF version of the font would work instead?
just have to change the _loadfont line, the extension from otf to ttf.

haven't heard anything from our MAC using friends, does everything work there? anybody know?

I'll have to go back and add a large number of checks I guess, try to find ways to keep it compatible with as many machines as possible.
Have be working on finishing up the End screens with the various rocket animations based on score. Corrected the drop speeds and scoring too. Soon as I get the High Score routines completed I'll try and see about writing a possible sprite based font. and give that a whorl.
« Last Edit: November 04, 2018, 12:30:32 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Tetris 64! (not linux compatable I guess)
« Reply #3 on: October 06, 2018, 11:09:12 am »
I have updated the Mac to the newest Mojave version and it breaks QB64, won't be able to test it for now.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Tetris 64! (not linux compatable I guess)
« Reply #4 on: October 13, 2018, 01:47:05 pm »
I have updated the code to make Audio completely optional, and have a abridged list of updates made to the code, 'Revision list'? has minor OS checking for the font loading, Windows machines will load the OTF version others will attempt to load the TTF version, this is still experimental.(for me anyway) there is no difference in the font itself just a cross compatibility test on my part.

The graphics are attached below, and code is presented here, still not commented so I don't know if I'd try to read it unless you have unlimited time, and pen and paper at hand. :)
there is a huge amount of repetition to a degree, maybe when alls said and done I'll make some arrays to hold a lot of the numerics and be able to shrink this way down.

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

I've added the TTF version of the font too, in the off chance People not running a Windows OS need it. you will just have to change line 167 from
 FFX(1) = _LOADFONT("temp.dat", 20, "monospace")
to
 FFX(1) = _LOADFONT("NESFONT.TTF", 20, "monospace")

or where ever you need to place the font to work.
if all else fails simply comment out line 169 [IF FFX(1) THEN _FONT FFX(1)] but things won't look right.
« Last Edit: November 04, 2018, 12:30:50 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Tetris 64! (Maybe linux compatable now?)
« Reply #5 on: October 13, 2018, 04:05:40 pm »
Cool. The game runs without error (and sound at the moment...) with only the tinniest bit of 'flicker' when the 'brick' area gets a bit full. That only happened a couple of times. But other than that, the game is playable... and somehow I STILL manage to get killed off... lol

Very nicely done... (not getting me killed off... the overall game... lol)

J

NB: Fonts displayed properly.
Logic is the beginning of wisdom.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Tetris 64! (Maybe linux compatable now?)
« Reply #6 on: October 13, 2018, 05:07:25 pm »
Mission accomplished eh? This was a blast, especially with the old Nintendo graphics. I swear i hear phantom sound effects when playing this, that creepy music too...
You're not done when it works, you're done when it's right.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Tetris 64! (Maybe linux compatable now?)
« Reply #7 on: October 20, 2018, 07:49:57 pm »
Here it is finally, the FULL release of my NES Tetris Clone! Tetris 64!

All the end screen animations for both A-Type and B-type game play are finished. Original music and sound effects are available but not necessary.  To play with music and sound FXs download the SFX file below and flip the REMed\unREMed lines at line 107\108

'LoadGameStuff LoadIt <--- un REMark to load sounds
LoadGameStuff NoSound <----- be sure to REMark this line instead

otherwise you just need the BAS file and the GFX file to play.
there is still a nasty bug in the Rotational Collision routine but I have not been able to find where its hiding, so sometimes a piece will rotate when it should not (this can be helpful sometimes) and sometimes a piece will refuse to rotate when it should(this will make you curse at the screen!)

Menus are Mouse driven and game play is as follows,
Arrow keys:
    Right\left-move the Tetranome right and left 
    Down     -force drop
    Space     - rotates Tetranome

Enter-moves to next screen after end screen animation and enters high score name
Up\Down- in high score screen changes selected letter for name
Right\Left- in high score screen shifts current letter selection right and left!

ESC- quit game while playing only.

Sound effects and music may not be 100% accurate, using an old emulator to capture. and music saved at 96kbs mp3 to reduce size. Speed is a wee bit off of the actually NES version and stops increasing at level 10.

*slight fix made to BAS 10/21/18-14:15
* Tetris.GFX (Filesize: 167.19 KB, Downloads: 193)
* Tetris_original.SFX (Filesize: 2 MB, Downloads: 194)
* Tetris64.bas (Filesize: 94.66 KB, Downloads: 173)
« Last Edit: October 21, 2018, 02:15:16 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Tetris 64! (Full release 1.0)
« Reply #8 on: October 21, 2018, 01:56:55 pm »
I forgot to mention that you will need a recent copy of the DB as I'm using a fix for _PRINTSTRING that Steve made just a few days ago. Should also mention that this was coded using QB64 1.1 build 20171106/82. If anything seems glitchy with newer versions let me know and I'll see if I can rework it with the newest build.
Granted after becoming radioactive I only have a half-life!

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Tetris 64! (Full release 1.0)
« Reply #9 on: October 21, 2018, 03:24:15 pm »
as discussed,

white is qb64's RND distribution
red is the NES generator distribution
yellow is the normal or Gaussian distribution as an example

Code: QB64: [Select]
  1.  
  2.  
  3. 'start with an arbitrary number
  4. 'set to some function of TIMER if you want different random
  5. 'numbers each program execution
  6. a = timer
  7.  
  8. dim x(640), y(640), w(640)
  9. for i=0 to 100000
  10.  
  11.         z = rnd
  12.         x(z*640) = x(z*640) + 1
  13.  
  14.         z = krand#(a)
  15.         y(z*640) = y(z*640) + 1
  16.  
  17.         for j=0 to 500
  18.                 z = z + rnd
  19.         next
  20.         z = z/500
  21.         w(z*640) = w(z*640) + 1
  22.  
  23. for i=0 to 640
  24.         pset (i, x(i))
  25.         pset (i, y(i)), 12
  26.         pset (i, w(i)/50), 14
  27.  
  28. locate 1,1: ? "15 dice rolls:"
  29. for i=0 to 15
  30.         x(i) = int(6*rnd)+1
  31.         y(i) = int(6*krand#(a))+1
  32. s1$ = ""
  33. s2$ = ""
  34. for i=0 to 15
  35.         s1$ = s1$ + ","+str$(x(i))
  36.         s2$ = s2$ + ","+str$(y(i))
  37. locate 2,1: ? s1$
  38. locate 3,1: ? s2$
  39.  
  40.  
  41. 'kobolt's nes random number generator
  42. 'returns a number 0 to 1, a replacement to QB's RND
  43.         dim bit1 as _unsigned integer, bit9 as _unsigned integer
  44.         bit1 = -((a and 1) <> 0)
  45.         bit9 = -((a and 512) <> 0)
  46.         a = (a\2) or (bit1 xor bit9)*32768 '2^15
  47.         krand# = a/65535
  48.  
  49.  
« Last Edit: October 21, 2018, 03:43:25 pm by v »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Tetris 64! (Full release 1.0a[update])
« Reply #10 on: November 03, 2018, 02:02:03 pm »
A small, but BIG 1st!, update for Tetris 64, fixes 2 little bugs, one after you play a game and return to the menus the song selection would reset, though the music plays correct, fixed that to select already chosen music. Two fixed an issue with the background music volume, in the victory and high score screens ,not being adjusted correctly, on full blast, although the background game music was correct. not sure on that one but its fixed now. they should have all been set to the same volume in the MENUONE routine, as it sets 1-5 BGMs to the same volume, but 4 an 5 didn't update apparently.

Never followed up on a program before so this is a first for me. there are a couple things I'd like to address in time, but for the first of a few bug fixes I think this will do.
The download for this reply will be the updated one from now on, and any updates from here on out will be this download.
* Tetris64.bas (Filesize: 95.2 KB, Downloads: 196)
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Tetris 64! (Full release 1.0a[update])
« Reply #11 on: November 03, 2018, 03:04:11 pm »
Congrats on your first, and many happy returns!

Oh, where are the files? Which ones are you using?
« Last Edit: November 03, 2018, 03:25:17 pm by bplus »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Tetris 64! (Full release 1.0a[update])
« Reply #12 on: November 03, 2018, 04:24:45 pm »
I like the graphics. For some reason, I do not hear sound. I downloaded the SFX file here.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Tetris 64! (Full release 1.0a[update])
« Reply #13 on: November 03, 2018, 04:59:12 pm »
OK, got it working, sound is OK too (Windows 10).

I took original rar extracted folder, added Font file and .GFX file twice with new .bas file. You get an empty GFX file created if you compile without one that fools program into thinking it has a GFX file.
« Last Edit: November 03, 2018, 05:11:09 pm by bplus »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Tetris 64! (Full release 1.0a[update])
« Reply #14 on: November 03, 2018, 07:38:20 pm »
I like the graphics. For some reason, I do not hear sound. I downloaded the SFX file here.

some OS versions do not like the sounds so its default is off, you have to switch commented lines.
when you look at the BAS you should see these 2 lines around line 111 or so.

'LoadGameStuff LoadIt
LoadGameStuff NoSound

just flip the comment ' around and the sounds will load.

OK, got it working, sound is OK too (Windows 10).
I took original rar extracted folder, added Font file and .GFX file twice with new .bas file. You get an empty GFX file created if you compile without one that fools program into thinking it has a GFX file.

the correct GFX and SFX are in this earlier reply. and you should just need 3 files a BAS, a GFX, and a SFX
Here it is finally, the FULL release of my NES Tetris Clone! Tetris 64!
« Last Edit: November 03, 2018, 07:42:09 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!