Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Cobalt

Pages: [1] 2 3 ... 8
1
QB64 Discussion / Why is my END IF tabbed(spaced) wrong?
« on: February 15, 2022, 12:30:44 pm »
Everything else being spaced correctly why not this END IF? Both auto spacing and auto Indent is on. Can not recall ever seeing this before.
Pulled out just the code displaying the situation, and added the type and dims so there would be no errors stopping the auto format and it still happens. Through out the rest of the code all the other END IFs are spaced correctly, this is the only one.

Code: QB64: [Select]
  1. TYPE Offset_data
  2.     X AS INTEGER
  3.     Y AS INTEGER
  4.     Xs AS _BYTE
  5.     Ys AS _BYTE
  6.  
  7. DIM SHARED Layer(32) AS LONG, Sprites(64) AS Offset_data
  8. DIM SHARED DungeonMaps(9, 7, 3) AS _BYTE
  9. Game.Scale = 1
  10.  
  11. SUB Draw_Mini_Map
  12.     FOR y%% = 0 TO 3: FOR x%% = 0 TO 7
  13.         IF DungeonMaps(Link.Dungeon, x%%, y%%) THEN
  14.             _PUTIMAGE (16 + 8 * x%%, 16 + 8 * y%%)-STEP(Sprites(39 + DungeonMaps(Link.Dungeon, x%%, y%%)).Xs * Game.Scale, Sprites(39 + DungeonMaps(Link.Dungeon, x%%, y%%)).Ys * Game.Scale), Layer(9), Layer(1), (Sprites(39 + DungeonMaps(Link.Dungeon, x%%, y%%)).X, Sprites(39 + DungeonMaps(Link.Dungeon, x%%, y%%)).Y)-STEP(Sprites(39 + DungeonMaps(Link.Dungeon, x%%, y%%)).Xs * Game.Scale, Sprites(39 + DungeonMaps(Link.Dungeon, x%%, y%%)).Ys * Game.Scale)
  15.             END IF
  16.     NEXT x%%, y%%
  17.     _PUTIMAGE (14 + Link.World_X * 4, 16 + Link.World_Y * 4)-STEP(2, 2), Layer(9), Layer(1), (618, 126)-STEP(2, 2) 'Map location beacon
  18.  

  [ You are not allowed to view this attachment ]  

2
QB64 Discussion / Possible issue with Select Case
« on: February 07, 2022, 04:52:48 pm »
Ran across this today, could some of you other guys test and confirm the issue?

You should get a beep, if not then there seems to be a problem with CASE # TO #

Found in current stable version, tested in latest DB(well a week old or so) same issue for me in both.

And YES the TO keyword is allowed and used in this manner. (see image)

Code: QB64: [Select]
  1. x%% = 15
  2.  CASE 16 TO 11 'full smoke
  3.   '    _PUTIMAGE (Objects(i%%).X, Objects(i%%).Y)-STEP(15, 15), Layer(7), Layer(10), (239 + 17 * 0, 1)-STEP(15, 15)
  4.   BEEP
  5.  CASE 10 TO 5 '2\3 smoke
  6.   '    _PUTIMAGE (Objects(i%%).X, Objects(i%%).Y)-STEP(15, 15), Layer(7), Layer(10), (239 + 17 * 1, 1)-STEP(15, 15)
  7.  CASE 4 TO 1 '1\3 smoke
  8.   '    _PUTIMAGE (Objects(i%%).X, Objects(i%%).Y)-STEP(15, 15), Layer(7), Layer(10), (239 + 17 * 2, 1)-STEP(15, 15)
  9.  CASE 0 'display object
  10.   Result%% = TRUE
  11.  

  [ You are not allowed to view this attachment ]  

3
QB64 Discussion / Why is an empty include file "not found"?
« on: January 27, 2022, 01:27:26 pm »
Was prepping my program to chuck some finalized SUBs into an include file and pre-made the include file and added the include line and it gave the error that the file was not found.

Whats the deal?

  [ You are not allowed to view this attachment ]  

4
QB64 Discussion / Double Check on order of operations
« on: January 22, 2022, 02:43:56 pm »
So in our order of operations, are * and /(and \) on the same level or does one take precedence over the other?
for instance if we have;

Scale%% = 3
Xloc% = 450 - 16 * 11 \ 2 * Scale%%

Would everything after the `-` evaluate from left to right or would(should) both multiplications go then the division? Since both Multiply and Divide are secondary operations(following Exponents and SQR).
I know the `-` goes last, but was curious if this would run straight or if I have to waste extra time and characters adding () around parts of it.(my testing says the latter, but wanted to make sure my testing was correct)

funny how you can spend years coding and never run across something then out of the blue...

5
QB64 Discussion / Small hiccup in ABS
« on: January 04, 2022, 12:57:43 pm »
Found this small hiccup in our ABS function. As ABS typically turns a negative(-) number into a positive one. however it is failing to do so with the BYTE type at a value of -128 as demonstrated by the following code.

Code: QB64: [Select]
  1. Shift%% = 127
  2. Shift%% = Shift%% + 1
  3. PRINT ABS(Shift%%); Shift%%
  4.  
  5.  
  6. Shift%% = Shift%% + 1
  7. PRINT ABS(Shift%%); Shift%%
  8.  
output:

-128  -128

127  -127

the -128 fails to print positive with ABS but the -127(and on) works correctly.
seems to be this way from 1.1 build 82(oldest I have at the ready) clear  up to 2.0.2 4d85302

Update, further testing show it does this with INTEGER(at -32768) and LONG(at -2147483648) too. However INTEGER64 works correctly.

6
Programs / Zelda 64(NES Zelda Clone) Demo
« on: December 19, 2021, 09:41:26 pm »
After taking a peek at Craz1000's Master Sword game (based on the NES game Zelda) reminded me of my Zelda Clone I started in March 2018! So I brought it up, deleted all the code and started from scratch!
And here is my past Weeks worth of work on it!

Temporary controls(Defaults)

Letter controls are UPPER CASE!

A -  Start Button
B -  Select Button (change selection(option) in game selection screen)
Space Bar - Button A (attack)
Enter - Button B(not used yet)
Arrow Keys - Map navigation, letter selection

The Title Scroll works!
The Game Selection menus all work, Pick a game to resume, Register a name, and Elimination Mode.
Once Registering and picking your character you can Explore the map.
At the moment the map is empty, no creatures to combat, No caves or dungeons to enter. You do start with the first sword so blast and slash away!

took me a few hours to get the map traversing done, took 4 DAYS to get the title screen and game selection screens working!

Really putting this up here to see what people think of the Title screen and Selection screens, and to see if anyone can break those parts.

I should warn you it is possible to get stuck, if you change map screens and the next screen bottle necks down you can wind up stuck in rock. There is no way to undo this yet, you have to quit.

As I do not have the OPTIONS screen done yet, there is one option you can manually play with if you like, the Scale option. There are 3 settings; LINE 116:G.Scale_Factor = 1
1- Small(actual game size) 256x224px
2- Normal 512x448px
3- Large 768x672px

at scale 1 a debugging map of the game is displayed at the top of the screen, the yellow square is you.

(developed in 2.0.2, but tested on 1.4,1.5,and 1.6 all work[should work with all versions back to 1.1build82])

Code: QB64: [Select]
  1. 'Zelda Clone take 2
  2.  
  3. TYPE ControllerKeys
  4.  KBCon_Up AS LONG
  5.  KBCon_Down AS LONG
  6.  KBCon_Left AS LONG
  7.  KBCon_Right AS LONG
  8.  KBCon_Select AS LONG
  9.  KBCon_Start AS LONG
  10.  KBCon_A_Button AS LONG
  11.  KBCon_B_Button AS LONG
  12.  
  13. TYPE Game_Data
  14.  Impactflag AS _BYTE
  15.  Scale_Factor AS _BYTE
  16.  Scale_X AS _BYTE
  17.  Scale_Y AS _BYTE
  18.  NextScreen AS _BYTE
  19.  Wtime AS _BYTE
  20.  Atime AS _BYTE
  21.  Wframe AS _BYTE
  22.  Aframe AS _BYTE
  23.  Projectile_Count AS _BYTE
  24.  LoadedGame AS _BYTE 'which game is loaded?(1-3)
  25.  
  26. TYPE Projectile_Data
  27.  Id AS _BYTE '       Kind of projectile; Sword\Arrow\Rock\Ball
  28.  Xloc AS INTEGER '   Projectile location
  29.  Yloc AS INTEGER '
  30.  Direction AS _BYTE 'Direction Projectile is traveling
  31.  Hits AS _BYTE '     Hits per projectile\(AKA:damage) in half heart increments
  32.  Owner AS _BYTE '    Who shot the projectile
  33.  
  34. TYPE Links_Data
  35.  '-----Position data-----
  36.  World AS _BYTE '           Player in Overworld or Underworld
  37.  World_X AS _BYTE '         Overworld X position
  38.  World_Y AS _BYTE '         Overworld Y position
  39.  Tile_X AS _UNSIGNED _BYTE 'Array X location:for Collision\entrances
  40.  Tile_Y AS _BYTE '          Array Y location:for Collision\entrances
  41.  Screen_X AS INTEGER '      X Position on screen
  42.  Screen_Y AS INTEGER '      Y Position on screen
  43.  Direction AS _BYTE '       Direction player is moving\facing
  44.  '-----------------------
  45.  '------Status Data------
  46.  Hearts AS _BYTE '    Units of health: 2 units(halves) per heart
  47.  Containers AS _BYTE 'Max number of health: total full hearts
  48.  Hits AS _BYTE '      Used when Link has defence rings;Blue = 2 hits per 1\2 heart, Red = 4 hits per 1\2 heart
  49.  '-----------------------
  50.  '------Items Data-------
  51.  Sword AS _BYTE ' which Sword does player have? Wooden-1,Silver-2,Magical-3
  52.  Weapon AS _BYTE 'Which Weapon is in hand A? Wooden-1,Silver-2,Magical-3,Wand-4
  53.  Ring AS _BYTE 'which does player have? 0-none, 1-blue,2-red
  54.  '-----------------------
  55.  '------Extra Data-------
  56.  Action AS _BYTE '          is player; using an item, Aquiring an item\sword, or aquiring a piece of the triforce?
  57.  Shot AS _BYTE '            player has shot sword
  58.  Projectile_id AS _BYTE '
  59.  Played AS _UNSIGNED _BYTE 'how many times has player played?
  60.  Beaten AS _BYTE '          Has player beaten Game 1? Game 2?
  61.  '-----------------------
  62.  
  63. TYPE Map_Data
  64.  Id AS _UNSIGNED _BYTE 'Tile id
  65.  Hidden AS _BYTE '      is there something under the tile?
  66.  Burnable AS _BYTE '    can the tile be burnt with candle?
  67.  Pushable AS _BYTE '    can the tile be moved by pushing?
  68.  PushableXtra AS _BYTE 'can the tile be moved by pushing with braclet?
  69.  Is_Shop AS _BYTE '     is there a shop here?(shop\gift\gamble)
  70.  Walkable AS _BYTE '    can the tile be walk upon?
  71.  
  72.  
  73. CONST TRUE = -1, FALSE = NOT TRUE, None = 0
  74. CONST Up = 3, Right = 2, Left = 1, Down = 0, SELECT_BUTTON = 4, START_BUTTON = 5, BUTTON_B = 6, BUTTON_A = 7
  75. CONST OverWorld = 0, UnderWorld = 1
  76. CONST Walking = 1, Useing = 2, GetItem = 3, GetTriforce = 4, Attack = 5
  77. CONST Key_Right = 19712, Key_Left = 19200, Key_Up = 18432, Key_Down = 20480
  78. CONST Key_Space = 32, Key_Enter = 13
  79. CONST Default_Key_Right = 19712, Default_Key_Left = 19200, Default_Key_Up = 18432, Default_Key_Down = 20480
  80. CONST Default_A_Button = 32, Default_B_Button = 13, Default_Start_Button = 65, Default_Select_Button = 66
  81. CONST Sword = 1, Arrow = 2, Rock = 3, Ball = 4, Boomerang = 5
  82. CONST Player = 1, Monster = 2
  83. CONST Item = 0, Slash = 1, Stairs = 2, SwordShot = 3
  84.  
  85. DIM SHARED Layer(16) AS LONG, Hyrule(255, 87) AS Map_Data, Link AS Links_Data, Reset_Link AS Links_Data
  86. DIM SHARED C AS ControllerKeys, G AS Game_Data, P(16) AS Projectile_Data, Letter(44) AS STRING * 1
  87. DIM SHARED Offset_X(3) AS INTEGER, Offset_Y(3) AS INTEGER, Cave(15, 10) AS Map_Data
  88. DIM SHARED BGM(8) AS LONG, SFX(10) AS LONG, FFX(1) AS LONG
  89. DIM SHARED Records(3) AS Links_Data, Nick(3) AS STRING * 8 'loading\registering\elimination
  90.  
  91. SCREEN _NEWIMAGE(800, 600, 32)
  92.  
  93. Layer(0) = _DISPLAY
  94. Layer(1) = _NEWIMAGE(800, 600, 32) 'temp layer
  95. Layer(2) = _NEWIMAGE(640, 480, 256) 'palettized sprite sheet for color shifting
  96. Layer(3) = _NEWIMAGE(800, 600, 32) 'Map background prebuild layer
  97. Layer(4) = _NEWIMAGE(800, 600, 32) 'Mob layer
  98. Layer(5) = _NEWIMAGE(800, 600, 32) 'Sprite layer, moveable\burnable items + bomb holes + pickups
  99. Layer(6) = _NEWIMAGE(12288, 4224, 32) 'PreBuilt Map, upto 300%, for easier map scrolling.
  100. Layer(8) = _NEWIMAGE(800, 600, 32) 'debug map display
  101. Layer(16) = _NEWIMAGE(800, 600, 32) 'temp
  102.  
  103. MFI_Loader "Zelda.MFI"
  104.  
  105. _CLEARCOLOR _RGB32(31), Layer(7)
  106. _CLEARCOLOR _RGB32(116), Layer(12)
  107.  
  108.  
  109. '==================================
  110. G.Scale_Factor = 1
  111. G.Scale_X = 16 * G.Scale_Factor - 1
  112. G.Scale_Y = 16 * G.Scale_Factor - 1
  113. Link.Screen_X = Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor * 7) + 8 * G.Scale_Factor '392
  114. Link.Screen_Y = Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor * 5) '292
  115. Nick(0) = "": Nick(1) = "": Nick(2) = "": Nick(3) = ""
  116. '==================================
  117.  
  118. 'OPEN "debug.txt" FOR OUTPUT AS #6
  119. Build_Map_Screen 16 * Link.World_X, 11 * Link.World_Y
  120. ClearLayer Layer(6)
  121. Build_Map_in_Totallity 'prebuild the entire map at the current scale factor
  122. ClearLayer Layer(1)
  123. _FONT FFX(0), Layer(1)
  124. _FONT FFX(0), Layer(16)
  125. Title_Screen
  126. Select_Screen
  127.  
  128.  SELECT CASE Get_Input
  129.   CASE BUTTON_A
  130.    IF G.Aframe = 0 AND G.Atime = 0 THEN _SNDPLAY SFX(Slash): Link.Action = Attack: Press = Press + 1
  131.    Check_Link_Sword_Shot
  132.   CASE Up
  133.    IF Link.Action <> Attack THEN Link.Direction = Up: Link.Action = Walking
  134.   CASE Down
  135.    IF Link.Action <> Attack THEN Link.Direction = Down: Link.Action = Walking
  136.   CASE Right
  137.    IF Link.Action <> Attack THEN Link.Direction = Right: Link.Action = Walking
  138.   CASE Left
  139.    IF Link.Action <> Attack THEN Link.Direction = Left: Link.Action = Walking
  140.    IF Link.Action = Walking THEN Link.Action = None
  141.  
  142.  IF Link.Action = GetItem OR Link.Action = GetTriforce THEN
  143.   IF NOT _SNDPLAYING(Temp&) THEN Link.Action = None
  144.  '------Graphx build------
  145.  _PUTIMAGE , Layer(3), Layer(1)
  146.  IF Link.Action = Walking THEN Move_Link
  147.  IF Link.Shot THEN Move_Sword_Shot
  148.  IF G.Impactflag THEN Impact 0, 0
  149.  Place_Link
  150.  ' _PRINTSTRING (0, 0), STR$(Link.Tile_X) + STR$(Link.Tile_Y) + STR$(G.Projectile_Count), Layer(1)
  151.  IF G.Scale_Factor = 1 THEN _PUTIMAGE , Layer(8), Layer(1)
  152.  _DEST Layer(1)
  153.  LINE (100 + 2 * Link.Tile_X, 0 + 2 * Link.Tile_Y)-STEP(1, 1), _RGB32(255, 255, 0), BF
  154.  _PUTIMAGE , Layer(1), Layer(0)
  155.  ClearLayer Layer(1)
  156.  '------------------------
  157.  IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  158.  _LIMIT 60
  159. LOOP UNTIL ExitFlag%%
  160.  
  161.  
  162. SUB Add_Projectile (What%%, Who%%)
  163.  SELECT CASE What%%
  164.   CASE Sword
  165.    P(G.Projectile_Count).Owner = Who%%
  166.    P(G.Projectile_Count).Id = Sword
  167.    P(G.Projectile_Count).Direction = Link.Direction
  168.    IF Who%% = Player THEN
  169.     P(G.Projectile_Count).Xloc = Link.Screen_X
  170.     P(G.Projectile_Count).Yloc = Link.Screen_Y
  171.    ELSE
  172.    END IF
  173.    G.Projectile_Count = G.Projectile_Count + 1
  174.  
  175. SUB Remove_Projectile (What%%, Who%%)
  176.  SELECT CASE What%%
  177.   CASE Sword
  178.    IF Who%% = Player THEN
  179.     G.Projectile_Count = G.Projectile_Count - 1
  180.    END IF
  181.  
  182. SUB Build_Cave_Screen
  183.  FOR Y%% = 0 TO 10
  184.   FOR X%% = 0 TO 15
  185.    Place_Tile_On_Screen (16 * G.Scale_Factor) * X%%, (16 * G.Scale_Factor) * Y%%, Cave(X%%, Y%%).Id, Layer(3)
  186.   NEXT
  187.  
  188. SUB Build_Map_Screen (Map_X~%%, Map_Y%%)
  189.  _DEST Layer(8)
  190.  FOR Y%% = 0 TO 10
  191.   FOR X%% = 0 TO 15
  192.    Place_Tile_On_Screen (16 * G.Scale_Factor) * X%%, (16 * G.Scale_Factor) * Y%%, Hyrule(Map_X~%% + X%%, Map_Y%% + Y%%).Id, Layer(3)
  193.   NEXT
  194.  FOR Y%% = 0 TO 87
  195.   FOR x~%% = 0 TO 255
  196.    IF Hyrule(x~%%, Y%%).Walkable = FALSE THEN LINE (100 + 2 * x~%%, 0 + 2 * Y%%)-STEP(1, 1), _RGB32(255), BF
  197.   NEXT
  198.  _DEST Layer(0)
  199.  
  200. SUB Build_Map_in_Totallity
  201.  FOR Y%% = 0 TO 87
  202.   FOR X~%% = 0 TO 255
  203.    tile~%% = Hyrule(X~%%, Y%%).Id
  204.    Gy% = 17 * (tile~%% \ 20) 'get which row it comes from
  205.    Gx% = 17 * (tile~%% MOD 20) 'which column position
  206.    _PUTIMAGE ((16 * G.Scale_Factor) * X~%%, (16 * G.Scale_Factor) * Y%%)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(6), (1 + Gx%, 1 + Gy%)-STEP(15, 15)
  207.   NEXT
  208.  
  209. SUB Check_Link_Location
  210.  Ax% = Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
  211.  Ay% = Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
  212.  Tx~%% = (Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  213.  Ty%% = (Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) - 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  214.  IF Hyrule(Tx~%%, Ty%%).Is_Shop THEN Enter_Shop Hyrule(Tx~%%, Ty%%).Is_Shop
  215.  
  216.  
  217. SUB Enter_Shop (Which%%)
  218.  
  219. SUB Check_Link_Sword_Shot 'Can Link shoot his sword?
  220.  IF Link.Hearts = Link.Containers * 2 THEN 'Link has full hearts and can shoot
  221.   IF NOT _SNDPLAYING(SFX(SwordShot)) THEN 'Link did not just shoot
  222.    IF NOT G.Impactflag THEN 'Link's last shot has finished
  223.     IF NOT Link.Shot THEN
  224.      _SNDPLAY SFX(SwordShot)
  225.      Link.Shot = TRUE
  226.      Add_Projectile Sword, Player
  227.     END IF
  228.    END IF
  229.   END IF
  230.  
  231. SUB ClearLayer (L&)
  232.  _DEST L&
  233.  CLS
  234.  
  235. SUB ClearLayerTrans (L&)
  236.  _DEST L&
  237.  CLS , 0
  238.  
  239. SUB DarkenImage (Image AS LONG, Value_From_0_To_1 AS SINGLE)
  240.  IF Value_From_0_To_1 <= 0 OR Value_From_0_To_1 >= 1 OR _PIXELSIZE(Image) <> 4 THEN EXIT SUB
  241.  DIM Buffer AS _MEM: Buffer = _MEMIMAGE(Image) 'Get a memory reference to our image
  242.  DIM Frac_Value AS LONG: Frac_Value = Value_From_0_To_1 * 65536 'Used to avoid slow floating point calculations
  243.  DIM O AS _OFFSET, O_Last AS _OFFSET
  244.  O = Buffer.OFFSET 'We start at this offset
  245.  O_Last = Buffer.OFFSET + _WIDTH(Image) * _HEIGHT(Image) * 4 'We stop when we get to this offset
  246.  'use on error free code ONLY!
  247.  DO
  248.   _MEMPUT Buffer, O, _MEMGET(Buffer, O, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  249.   _MEMPUT Buffer, O + 1, _MEMGET(Buffer, O + 1, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  250.   _MEMPUT Buffer, O + 2, _MEMGET(Buffer, O + 2, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  251.   O = O + 4
  252.  LOOP UNTIL O = O_Last
  253.  'turn checking back on when done!
  254.  _MEMFREE Buffer
  255.  
  256. SUB Fade_Out (L&)
  257.  FOR n! = 1 TO 0.5 STEP -0.05
  258.   i2& = _COPYIMAGE(L&)
  259.   DarkenImage i2&, n!
  260.   _PUTIMAGE (0, 0), i2&, Layer(0)
  261.   _FREEIMAGE i2&
  262.   _DELAY .03
  263.  
  264. SUB Fade_In (L&)
  265.  FOR n! = 0.01 TO 1 STEP 0.05
  266.   i2& = _COPYIMAGE(L&)
  267.   DarkenImage i2&, n!
  268.   _PUTIMAGE (0, 0), i2&, Layer(0)
  269.   _FREEIMAGE i2&
  270.   _DELAY .03
  271.  
  272. FUNCTION Find_First_Available%% (Which%%, Start%%)
  273.  Selection%% = Start%% 'always start at the first saved game slot then check
  274.  DO 'lets find the first available selection (if there are any saved games)
  275.   IF Selection%% < 4 THEN
  276.    IF Which%% = 0 THEN IF RTRIM$(Nick(Selection%%)) = "" THEN Selection%% = Selection%% + 1 ELSE Good_Selection%% = TRUE
  277.    IF Which%% = 1 THEN IF RTRIM$(Nick(Selection%%)) = "" THEN Good_Selection%% = TRUE ELSE Selection%% = Selection%% + 1
  278.   ELSE '4 and 5 are always good selections
  279.    Good_Selection%% = TRUE
  280.   END IF
  281.  LOOP UNTIL Good_Selection%%
  282.  Find_First_Available = Selection%%
  283.  
  284. FUNCTION Get_Input%% ()
  285.  Result%% = TRUE '-1 for no input
  286.  ' SELECT CASE G.ControlType
  287.  '  CASE TRUE 'Keyboard input
  288.  IF _KEYDOWN(C.KBCon_Up) THEN Result%% = Up
  289.  IF _KEYDOWN(C.KBCon_Down) THEN Result%% = Down
  290.  IF _KEYDOWN(C.KBCon_Left) THEN Result%% = Left
  291.  IF _KEYDOWN(C.KBCon_Right) THEN Result%% = Right
  292.  IF _KEYDOWN(C.KBCon_Select) THEN Result%% = SELECT_BUTTON: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_Select)
  293.  IF _KEYDOWN(C.KBCon_Start) THEN Result%% = START_BUTTON: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_Start)
  294.  IF _KEYDOWN(C.KBCon_A_Button) THEN Result%% = BUTTON_A: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_A_Button)
  295.  IF _KEYDOWN(C.KBCon_B_Button) THEN Result%% = BUTTON_B: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_B_Button)
  296.  '  CASE FALSE 'joystick input
  297.  'IF C.Control_Pad THEN
  298.  'IF NOT G.Flag THEN DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad)
  299.  'IF NOT C.BAD_Pad THEN
  300.  ' nul%% = AxisPower(CJR%%, CJL%%, CJU%%, CJD%%) 'read directional axis values
  301.  ' IF CJU%% THEN Result%% = Up
  302.  ' IF CJD%% THEN Result%% = Down
  303.  ' IF CJL%% THEN Result%% = Left
  304.  ' IF CJR%% THEN Result%% = Right
  305.  'ELSE
  306.  '   IF _BUTTON(C.Joy_Button_Up) THEN Result%% = Up ': Joy_Lock_Button (C.Joy_Button_Up)
  307.  '   IF _BUTTON(C.Joy_Button_Down) THEN Result%% = Down ': Joy_Lock_Button (C.Joy_Button_Down)
  308.  '   IF _BUTTON(C.Joy_Button_Left) THEN Result%% = Left ': Joy_Lock_Button (C.Joy_Button_Left)
  309.  '   IF _BUTTON(C.Joy_Button_Right) THEN Result%% = Right ': Joy_Lock_Button (C.Joy_Button_Right)
  310.  ' END IF
  311.  '  IF _BUTTON(C.Joy_Select) THEN Result%% = SELECT_BUTTON: Joy_Lock_Button (C.Joy_Select)
  312.  '  IF _BUTTON(C.Joy_Start) THEN Result%% = START_BUTTON: Joy_Lock_Button (C.Joy_Start)
  313.  '  IF _BUTTON(C.Joy_A_Button) THEN Result%% = BUTTON_A: Joy_Lock_Button (C.Joy_A_Button)
  314.  '  IF _BUTTON(C.Joy_B_Button) THEN Result%% = BUTTON_B: Joy_Lock_Button (C.Joy_B_Button)
  315.  ' END IF
  316.  ' END SELECT
  317.  Get_Input = Result%%
  318.  
  319. SUB Link_Attack
  320.  SELECT CASE Link.Direction
  321.   CASE Up
  322.    Ox%% = 0: Oy%% = -14 * G.Scale_Factor
  323.   CASE Down
  324.    Ox%% = 0: Oy%% = 14 * G.Scale_Factor
  325.   CASE Left
  326.    Ox%% = -14 * G.Scale_Factor + G.Aframe * (4 * G.Scale_Factor): Oy%% = 0
  327.   CASE Right
  328.    Ox%% = 14 * G.Scale_Factor - G.Aframe * (4 * G.Scale_Factor): Oy%% = 0
  329.  SELECT CASE G.Aframe
  330.   CASE 0
  331.    _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * (Link.Direction + 8), 137)-STEP(15, 15)
  332.   CASE 1
  333.    _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * (Link.Direction + 8), 137)-STEP(15, 15)
  334.    _PUTIMAGE (Link.Screen_X + Ox%%, Link.Screen_Y + Oy%%)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 51 * Link.Weapon, 171 + 17 * Link.Direction)-STEP(15, 15)
  335.   CASE 2
  336.    _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 34 * Link.Direction + 17, 137)-STEP(15, 15)
  337.    _PUTIMAGE (Link.Screen_X + Ox%%, Link.Screen_Y + Oy%%)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 51 * Link.Weapon + 17, 171 + 17 * Link.Direction)-STEP(15, 15)
  338.   CASE 3
  339.    _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 34 * Link.Direction + 0, 137)-STEP(15, 15)
  340.    _PUTIMAGE (Link.Screen_X + Ox%%, Link.Screen_Y + Oy%%)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 51 * Link.Weapon + 34, 171 + 17 * Link.Direction)-STEP(15, 15)
  341.   CASE ELSE 'attack animation finished
  342.    G.Atime = 0: G.Aframe = 0: Link.Action = None
  343.    _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 34 * Link.Direction + 17 * Frame%%, 137)-STEP(15, 15)
  344.  
  345. FUNCTION Link_Collision%% (Dir%%)
  346.  Result%% = FALSE 'start at no collision
  347.  'get links center point x\y tile position to check for collision
  348.  Ax% = Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
  349.  Ay% = Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
  350.  'we now have the tile that Links center pixel is in!
  351.  SELECT CASE Dir%%
  352.   CASE Up
  353.    Tx~%% = (Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  354.    Ty%% = (Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) - 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  355.    IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  356.   CASE Down
  357.    Tx~%% = (Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  358.    Ty%% = (2 + Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) + 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  359.    IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  360.   CASE Left
  361.    Tx~%% = (Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) - 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  362.    Ty%% = (Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  363.    IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  364.   CASE Right
  365.    Tx~%% = (2 + Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  366.    Ty%% = (Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  367.    IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  368.  Link.Tile_X = Tx~%%
  369.  Link.Tile_Y = Ty%%
  370.  Link_Collision = Result%%
  371.  
  372. SUB Move_Link
  373.  SELECT CASE Link.Direction
  374.   CASE Up
  375.    IF NOT Link_Collision(Up) THEN 'nothing blocking Link
  376.     IF Link.Screen_Y > Offset_Y(G.Scale_Factor) THEN 'Link is not at the edge of the screen
  377.      Link.Screen_Y = Link.Screen_Y - 2 * G.Scale_Factor
  378.     ELSE 'player is at edge of screen to shift to next one.
  379.      G.NextScreen = Up
  380.      Shift_New_Map_Screen
  381.     END IF
  382.    END IF
  383.   CASE Down
  384.    IF NOT Link_Collision(Down) THEN 'nothing blocking Link
  385.     IF Link.Screen_Y < (Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor * 10)) THEN 'Link is not at the edge of the screen
  386.      Link.Screen_Y = Link.Screen_Y + 2 * G.Scale_Factor
  387.     ELSE 'player is at edge of screen to shift to next one.
  388.      G.NextScreen = Down
  389.      Shift_New_Map_Screen
  390.     END IF
  391.    END IF
  392.   CASE Left
  393.    IF NOT Link_Collision(Left) THEN 'nothing blocking Link
  394.     IF Link.Screen_X > Offset_X(G.Scale_Factor) THEN 'Link is not at the edge of the screen
  395.      Link.Screen_X = Link.Screen_X - 2 * G.Scale_Factor
  396.     ELSE 'player is at edge of screen to shift to next one.
  397.      G.NextScreen = Left
  398.      Shift_New_Map_Screen
  399.     END IF
  400.    END IF
  401.   CASE Right
  402.    IF NOT Link_Collision(Right) THEN 'nothing blocking Link
  403.     IF Link.Screen_X < (Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor * 15)) THEN 'Link is not at the edge of the screen
  404.      Link.Screen_X = Link.Screen_X + 2 * G.Scale_Factor
  405.     ELSE 'player is at edge of screen to shift to next one.
  406.      G.NextScreen = Right
  407.      Shift_New_Map_Screen
  408.     END IF
  409.    END IF
  410.  
  411. SUB Move_Sword_Shot
  412.  STATIC Xloc AS INTEGER, Yloc AS INTEGER, Direction AS _BYTE, Fstp AS _BYTE, Frame AS _BYTE
  413.  IF Direction = -1 OR Xloc = 0 THEN 'if no direction assigned then assign one
  414.   Direction = Link.Direction
  415.   Xloc = Link.Screen_X
  416.   Yloc = Link.Screen_Y
  417.  SELECT CASE Direction
  418.   CASE Up
  419.    Yloc = Yloc - 4 * G.Scale_Factor
  420.   CASE Down
  421.    Yloc = Yloc + 4 * G.Scale_Factor
  422.   CASE Left
  423.    Xloc = Xloc - 4 * G.Scale_Factor
  424.   CASE Right
  425.    Xloc = Xloc + 4 * G.Scale_Factor
  426.  _PUTIMAGE (Xloc, Yloc)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * Frame + 68 * Direction, 239)-STEP(15, 15)
  427.  SELECT CASE G.Scale_Factor
  428.   CASE 1
  429.    IF Xloc <= 272 OR Xloc >= 514 OR Yloc <= 212 OR Yloc >= 372 THEN Done%% = TRUE
  430.   CASE 2
  431.    IF Xloc <= 140 OR Xloc >= 630 OR Yloc <= 100 OR Yloc >= 430 THEN Done%% = TRUE
  432.   CASE 3
  433.    IF Xloc <= 16 OR Xloc >= 744 OR Yloc <= 96 OR Yloc >= 559 THEN Done%% = TRUE
  434.  IF Done%% THEN Link.Shot = FALSE: G.Impactflag = TRUE: Impact Xloc, Yloc: Direction = -1: Remove_Projectile Sword, Player
  435.  Fstp = Fstp + 1
  436.  IF Fstp = 2 THEN Fstp = 0: Frame = Frame + 1
  437.  IF Frame = 4 THEN Frame = 0
  438.  
  439. SUB Impact (X%, Y%)
  440.  STATIC Frame AS _BYTE, Fstp AS _BYTE, Xloc(3) AS INTEGER, Yloc(3) AS INTEGER
  441.  IF Frame = -1 OR Xloc(2) = 0 THEN
  442.   Fstp = 0
  443.   FOR i%% = 0 TO 3: Xloc(i%%) = X% + 8 * G.Scale_Factor: Yloc(i%%) = Y% + 8 * G.Scale_Factor: NEXT i%%
  444.  Xloc(0) = Xloc(0) - G.Scale_Factor: Yloc(0) = Yloc(0) - G.Scale_Factor
  445.  Xloc(1) = Xloc(1) + G.Scale_Factor: Yloc(1) = Yloc(1) - G.Scale_Factor
  446.  Xloc(2) = Xloc(2) + G.Scale_Factor: Yloc(2) = Yloc(2) + G.Scale_Factor
  447.  Xloc(3) = Xloc(3) - G.Scale_Factor: Yloc(3) = Yloc(3) + G.Scale_Factor
  448.  FOR i%% = 0 TO 3
  449.   SELECT CASE i%%
  450.    CASE 0
  451.     _PUTIMAGE (Xloc(i%%) - 16, Yloc(i%%) - 16)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (205 + 17 * Frame, 205)-STEP(15, 15)
  452.    CASE 1
  453.     _PUTIMAGE (Xloc(i%%) + 16, Yloc(i%%) - 16)-STEP(-G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (205 + 17 * Frame, 205)-STEP(15, 15)
  454.    CASE 2
  455.     _PUTIMAGE (Xloc(i%%) + 16, Yloc(i%%) + 16)-STEP(-G.Scale_X, -G.Scale_Y), Layer(7), Layer(1), (205 + 17 * Frame, 205)-STEP(15, 15)
  456.    CASE 3
  457.     _PUTIMAGE (Xloc(i%%) - 16, Yloc(i%%) + 16)-STEP(G.Scale_X, -G.Scale_Y), Layer(7), Layer(1), (205 + 17 * Frame, 205)-STEP(15, 15)
  458.  NEXT i%%
  459.  Fstp = Fstp + 1
  460.  Frame = Frame + 1
  461.  IF Frame = 4 THEN Frame = 0
  462.  IF Fstp = 16 THEN Frame = -1: G.Impactflag = FALSE
  463.  
  464. SUB Place_Link
  465.  STATIC Ftime AS _BYTE, Frame AS _BYTE
  466.  IF Link.Action = Walking THEN 'while Link is moving
  467.   G.Wtime = G.Wtime + 1 'Increment frame time
  468.   IF G.Wtime = 8 THEN
  469.    IF G.Wframe THEN G.Wframe = 0 ELSE G.Wframe = 1 'change frame
  470.    G.Wtime = 0 'reset frame time
  471.   END IF
  472.   _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 34 * Link.Direction + 17 * G.Wframe, 137)-STEP(15, 15)
  473.  ELSEIF Link.Action = Useing THEN 'when Link uses an item
  474.   Ftime = Ftime + 1 'Increment frame time
  475.   IF Ftime = 32 THEN Link.Action = None: Ftime = 0 'action is done
  476.   _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * (Link.Direction + 8), 137)-STEP(15, 15)
  477.  ELSEIF Link.Action = GetItem THEN 'When Link gets a sword\item or buys something
  478.   'Held while music plays
  479.   _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * 12, 137)-STEP(15, 15)
  480.  ELSEIF Link.Action = GetTriforce THEN 'When Link recovers a Triforce piece
  481.   'Held while music plays
  482.   _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * 13, 137)-STEP(15, 15)
  483.  ELSEIF Link.Action = Attack THEN
  484.   G.Atime = G.Atime + 1 'Increment frame time
  485.   IF G.Atime = 4 THEN G.Aframe = G.Aframe + 1: G.Atime = 0 'change frame:reset frame time
  486.   Link_Attack
  487.  ELSE 'Link is standing Still(Action=None)
  488.   G.Atime = 0: G.Aframe = 0
  489.   G.Wtime = 0: G.Wframe = 0
  490.   _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 34 * Link.Direction + 17 * Frame%%, 137)-STEP(15, 15)
  491.  
  492. SUB Place_Player_Record (I%%, Where%)
  493.  SELECT CASE Where%
  494.   CASE 0
  495.    IF Records(I%% + 1).Beaten THEN _PUTIMAGE (260, 228 + 48 * I%%)-STEP(15, 31), Layer(12), Layer(16), (64, 247)-STEP(7, 15) 'Player 1 Sword
  496.    _PUTIMAGE (236, 234 + 48 * I%%)-STEP(31, 31), Layer(12), Layer(16), (1 + 17 * Records(I%% + 1).Ring, 230)-STEP(15, 15) 'Player 1 Link (green)
  497.    _PRINTSTRING (284, 232 + 48 * I%%), RTRIM$(Nick(I%% + 1)), Layer(16) 'player 1 name
  498.    _PRINTSTRING (284, 248 + 48 * I%%), LEFT$("   ", 3 - LEN(LTRIM$(RTRIM$(STR$(Records(I%% + 1).Played))))) + LTRIM$(STR$(Records(I%% + 1).Played)), Layer(16) 'player 1 tries
  499.    FOR j%% = 1 TO Records(I%% + 1).Containers
  500.     IF j%% < 4 THEN 'first 3 hearts are red
  501.      _PUTIMAGE (428 + 16 * j%%, 232 + 48 * I%%)-STEP(15, 15), Layer(12), Layer(16), (52, 230)-STEP(7, 7) 'Player 1 hearts red
  502.     ELSE
  503.      IF j%% < 9 THEN
  504.       _PUTIMAGE (428 + 16 * j%%, 232 + 48 * I%%)-STEP(15, 15), Layer(12), Layer(16), (73, 267)-STEP(7, 7) 'Player 1 hearts white
  505.      ELSE
  506.       _PUTIMAGE (428 + 16 * (j%% - 8), 232 + 64 * I%%)-STEP(15, 15), Layer(12), Layer(16), (73, 267)-STEP(7, 7) 'Player 1 hearts white
  507.      END IF
  508.     END IF
  509.    NEXT j%%
  510.   CASE 1
  511.    IF Records(I%% + 1).Beaten THEN _PUTIMAGE (326, 148 + 48 * (I%% - 1))-STEP(15, 31), Layer(12), Layer(16), (64, 247)-STEP(7, 15) 'Player 1 Sword
  512.    _PUTIMAGE (300, 154 + 48 * (I%%))-STEP(31, 31), Layer(12), Layer(16), (1 + 17 * Records(I%% + 1).Ring, 230)-STEP(15, 15) 'Player 1 Link (green)
  513.    _PRINTSTRING (364, 152 + 48 * (I%%)), RTRIM$(Nick(I%% + 1)), Layer(1)
  514.  
  515.  
  516. SUB Place_Tile_On_Screen (X%, Y%, Tile~%%, L&)
  517.  Gy% = 17 * (Tile~%% \ 20) 'get which row it comes from
  518.  Gx% = 17 * (Tile~%% MOD 20) 'which column position
  519.  _PUTIMAGE (Offset_X(G.Scale_Factor) + X%, Offset_Y(G.Scale_Factor) + Y%)-STEP(G.Scale_X, G.Scale_Y), Layer(7), L&, (1 + Gx%, 1 + Gy%)-STEP(15, 15)
  520.  
  521. SUB Scroll_Screen_II (Dir%%)
  522.  Cx% = Offset_X(G.Scale_Factor) 'top left corner location of map displayed
  523.  Cy% = Offset_Y(G.Scale_Factor)
  524.  Sfx% = 16 * 16 * G.Scale_Factor 'size of the map display
  525.  Sfy% = 11 * 16 * G.Scale_Factor
  526.  Lwx% = 16 * 16 * G.Scale_Factor * Link.World_X 'map area link is in
  527.  Lwy% = 11 * 16 * G.Scale_Factor * Link.World_Y
  528.  SELECT CASE Dir%%
  529.   CASE Up
  530.    FOR y% = 0 TO Sfy% STEP 2 * G.Scale_Factor
  531.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx%, Lwy% - y%)-STEP(Sfx%, Sfy%)
  532.     IF y% > 16 * G.Scale_Factor THEN Link.Screen_Y = Link.Screen_Y + 2 * G.Scale_Factor
  533.     Place_Link
  534.     _LIMIT 60
  535.     _PUTIMAGE , Layer(1), Layer(0)
  536.    NEXT
  537.    Link.World_Y = Link.World_Y - 1
  538.   CASE Down
  539.    FOR y% = 0 TO Sfy% STEP 2 * G.Scale_Factor
  540.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx%, Lwy% + y%)-STEP(Sfx%, Sfy%)
  541.     IF y% > 16 * G.Scale_Factor THEN Link.Screen_Y = Link.Screen_Y - 2 * G.Scale_Factor
  542.     Place_Link
  543.     _LIMIT 60
  544.     _PUTIMAGE , Layer(1), Layer(0)
  545.    NEXT
  546.    Link.World_Y = Link.World_Y + 1
  547.   CASE Left
  548.    FOR x% = 0 TO Sfx% STEP 2 * G.Scale_Factor
  549.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx% - x%, Lwy%)-STEP(Sfx%, Sfy%)
  550.     IF x% > 16 * G.Scale_Factor THEN Link.Screen_X = Link.Screen_X + 2 * G.Scale_Factor
  551.     Place_Link
  552.     _LIMIT 60
  553.     _PUTIMAGE , Layer(1), Layer(0)
  554.    NEXT
  555.    Link.World_X = Link.World_X - 1
  556.   CASE Right
  557.    FOR x% = 0 TO Sfx% STEP 2 * G.Scale_Factor
  558.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx% + x%, Lwy%)-STEP(Sfx%, Sfy%)
  559.     IF x% > 16 * G.Scale_Factor THEN Link.Screen_X = Link.Screen_X - 2 * G.Scale_Factor
  560.     Place_Link
  561.     _LIMIT 60
  562.     _PUTIMAGE , Layer(1), Layer(0)
  563.    NEXT
  564.    Link.World_X = Link.World_X + 1
  565.  Place_Link
  566.  Lwx% = 16 * 16 * G.Scale_Factor * Link.World_X
  567.  Lwy% = 11 * 16 * G.Scale_Factor * Link.World_Y
  568.  _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(3), (Lwx%, Lwy%)-STEP(Sfx%, Sfy%) 'move new screen to layer(3)
  569.  
  570. SUB Shift_New_Map_Screen
  571.  SELECT CASE G.NextScreen
  572.   CASE Up
  573.    Scroll_Screen_II Up
  574.   CASE Down
  575.    Scroll_Screen_II Down
  576.   CASE Left
  577.    Scroll_Screen_II Left
  578.   CASE Right
  579.    Scroll_Screen_II Right
  580.  G.NextScreen = -1
  581.  
  582. SUB Title_Screen
  583.  _CLEARCOLOR _RGB32(21), Layer(9)
  584.  _CLEARCOLOR _RGB32(21), Layer(10)
  585.  _SNDVOL BGM(0), .33
  586.  _SNDLOOP BGM(0)
  587.  DO
  588.   F%% = 0: F% = 0: ExitFlag%% = FALSE
  589.   DO: _LIMIT 60: LOOP WHILE _SNDGETPOS(BGM(0)) > 10
  590.   DO
  591.    _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (0, 0)-STEP(255, 223)
  592.    SELECT CASE F%%
  593.     CASE 12 TO 18
  594.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0)-STEP(71, 71)
  595.     CASE 19 TO 24
  596.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 72)-STEP(71, 71)
  597.     CASE 25 TO 36
  598.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 144)-STEP(71, 71)
  599.     CASE 37 TO 52
  600.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 72)-STEP(71, 71)
  601.     CASE 53 TO 59
  602.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 0)-STEP(71, 71)
  603.    END SELECT
  604.    _PUTIMAGE (304, 523 - 112), Layer(10), Layer(1), (0 + 64 * wave%%, 0)-STEP(63, 111)
  605.    _PUTIMAGE , Layer(1), Layer(0)
  606.    _LIMIT 90
  607.    F%% = F%% + 1
  608.    IF F%% = 60 THEN F%% = 0
  609.    IF F%% MOD 2 = 0 THEN wave%% = wave%% + 1
  610.    IF wave%% = 16 THEN wave%% = 0
  611.    IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  612.   LOOP UNTIL _SNDGETPOS(BGM(0)) > 8.4 OR ExitFlag%%
  613.  
  614.   IF NOT ExitFlag%% THEN
  615.    'start the title fade
  616.    _DEST Layer(1)
  617.    F%% = 0
  618.    DO
  619.     SELECT CASE F%
  620.      CASE 0 TO 13
  621.       LINE (144, 76)-STEP(511, 447), _RGB32(202, 241, 159), BF
  622.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (361, 0)-STEP(255, 223)
  623.      CASE 13 TO 24
  624.       LINE (144, 76)-STEP(511, 447), _RGB32(182, 216, 255), BF
  625.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (361, 0)-STEP(255, 223)
  626.      CASE 25 TO 34
  627.       LINE (144, 76)-STEP(511, 447), _RGB32(166, 229, 255), BF
  628.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (361, 0)-STEP(255, 223)
  629.      CASE 35 TO 42
  630.       LINE (144, 76)-STEP(511, 447), _RGB32(165, 238, 223), BF
  631.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (617, 0)-STEP(255, 223)
  632.      CASE 43 TO 48
  633.       LINE (144, 76)-STEP(511, 447), _RGB32(37, 190, 255), BF
  634.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (617, 0)-STEP(255, 223)
  635.      CASE 49 TO 52
  636.       LINE (144, 76)-STEP(511, 447), _RGB32(0, 109, 181), BF
  637.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (617, 0)-STEP(255, 223)
  638.      CASE 53 TO 57
  639.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (873, 0)-STEP(255, 223)
  640.       Wf% = 112
  641.      CASE 58 TO 61
  642.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1129, 0)-STEP(255, 223)
  643.       Wf% = 224
  644.      CASE 62 TO 363
  645.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1385, 0)-STEP(255, 223)
  646.       Wf% = 336
  647.      CASE 364 TO 385
  648.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1641, 0)-STEP(255, 223)
  649.       Wf% = 448
  650.      CASE 386 TO 393
  651.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1897, 0)-STEP(255, 223)
  652.       Wf% = 560
  653.     END SELECT
  654.     _PUTIMAGE (304, 523 - 112), Layer(10), Layer(1), (0 + 64 * wave%%, 0 + Wf%)-STEP(63, 111)
  655.     _PUTIMAGE , Layer(1), Layer(0)
  656.     _LIMIT 90
  657.     F% = F% + 1
  658.     IF F% = 394 THEN ExitFlag%% = TRUE
  659.     IF F% MOD 2 = 0 THEN wave%% = wave%% + 1
  660.     IF wave%% = 16 THEN wave%% = 0
  661.     IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  662.    LOOP UNTIL ExitFlag%%
  663.    ExitFlag%% = FALSE
  664.   END IF
  665.   ClearLayer Layer(0)
  666.   ClearLayer Layer(1)
  667.   IF NOT ExitFlag%% THEN
  668.    'Title scroll
  669.    DO: _LIMIT 60: IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  670.    LOOP UNTIL _SNDGETPOS(BGM(0)) > 16 OR ExitFlag%%
  671.    F% = 0
  672.    IF NOT ExitFlag%% THEN
  673.     DO
  674.      SELECT CASE F%
  675.       CASE 0 TO 223
  676.        _PUTIMAGE (144, 76)-STEP(511, 447), Layer(11), Layer(1), (0, -223 + F%)-STEP(255, 223)
  677.       CASE IS >= 354
  678.        IF blink% THEN
  679.         _PUTIMAGE (72, 332)-STEP(7, 15), Layer(7), Layer(11), (247, 154)-STEP(7, 15) 'heart
  680.         _PUTIMAGE (72, 464)-STEP(7, 15), Layer(7), Layer(11), (213, 171)-STEP(7, 15) 'Ruby
  681.         _PUTIMAGE (120, 1432)-STEP(15, 15), Layer(7), Layer(11), (239, 188)-STEP(15, 15) 'Triforce
  682.        ELSE
  683.         _PUTIMAGE (72, 332)-STEP(7, 15), Layer(7), Layer(11), (239, 154)-STEP(7, 15) 'heart
  684.         _PUTIMAGE (72, 464)-STEP(7, 15), Layer(7), Layer(11), (205, 171)-STEP(7, 15) 'Ruby
  685.         _PUTIMAGE (120, 1432)-STEP(15, 15), Layer(7), Layer(11), (222, 188)-STEP(15, 15) 'Triforce
  686.        END IF
  687.        IF Fblink% THEN
  688.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (256, 188)-STEP(7, 15) 'fairy blank
  689.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (281, 154)-STEP(7, 15) 'fairy
  690.        ELSE
  691.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (256, 188)-STEP(7, 15) 'fairy blank
  692.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (273, 154)-STEP(7, 15) 'fairy
  693.        END IF
  694.        _PUTIMAGE (144, 76)-STEP(511, 447), Layer(11), Layer(1), (0, F% - 354)-STEP(255, 223)
  695.      END SELECT
  696.      _PUTIMAGE , Layer(1), Layer(0)
  697.      _LIMIT 30
  698.      F% = F% + 1
  699.      IF F% = 1762 THEN F% = F% - 1 'ExitFlag%% = TRUE
  700.      B% = B% + 1
  701.      IF B% = 4 THEN blink% = NOT blink%: B% = 0
  702.      IF B% MOD 2 = 0 THEN Fblink% = NOT Fblink%
  703.      IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  704.     LOOP UNTIL _SNDGETPOS(BGM(0)) >= 79.75 OR ExitFlag%%
  705.     ExitFlag%% = FALSE
  706.    END IF
  707.   END IF
  708.  
  709.  LOOP UNTIL ExitFlag%%
  710.  _DEST Layer(0)
  711.  _SNDSTOP BGM(0)
  712.  DO: LOOP UNTIL Get_Input%% = -1
  713.  
  714.  
  715. FUNCTION Projectile_Collision%%
  716.  Result%% = FALSE
  717.  FOR i%% = 0 TO G.Projectile_Count
  718.  Projectile_Collision = Result%%
  719.  
  720. SUB Select_Screen
  721.  ClearLayer Layer(16)
  722.  IF _FILEEXISTS("Zelda.MSF") THEN 'load saved data
  723.   OPEN "Zelda.MSF" FOR BINARY AS #1
  724.   FOR I%% = 1 TO 3 'load all 3 records
  725.    GET #1, , Nick(I%%)
  726.    GET #1, , Records(I%%)
  727.    IF Selection%% = 0 THEN IF RTRIM$(Nick(I%%)) <> "" THEN Selection%% = I%%
  728.   NEXT I%%
  729.   CLOSE #1
  730.  ELSE 'file doesn't exist so make it.
  731.   Reset_Record 1
  732.   Reset_Record 2
  733.   Reset_Record 3
  734.   Save_Records
  735.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (1, 1)-STEP(255, 223) 'background
  736.  FOR I%% = 1 TO 3
  737.   IF RTRIM$(Nick(I%%)) <> "" THEN Place_Player_Record I%% - 1, 0
  738.  NEXT I%%
  739.  IF Record_Count%% = 0 THEN Selection%% = 4 ELSE Selection%% = 1
  740.  Selection%% = Find_First_Available(0, 1)
  741.  DO
  742.   _PUTIMAGE , Layer(16), Layer(1)
  743.   SELECT CASE Get_Input%%
  744.    CASE START_BUTTON
  745.     SELECT CASE Selection%%
  746.      CASE 1 TO 3
  747.       Link = Records(Selection%%)
  748.       Exitflag%% = TRUE
  749.      CASE 4
  750.       DO: LOOP UNTIL Get_Input%% = -1
  751.       nul%% = Register(nul%%)
  752.       OPEN "Zelda.MSF" FOR BINARY AS #1 'update records
  753.       FOR I%% = 1 TO 3
  754.        PUT #1, , Nick(I%%)
  755.        PUT #1, , Link
  756.        IF RTRIM$(Nick(I%%)) <> "" THEN Place_Player_Record I%% - 1, 0
  757.       NEXT I%%
  758.       CLOSE #1
  759.      CASE 5
  760.       DO: LOOP UNTIL Get_Input%% = -1
  761.       Elimination_Mode
  762.       nul%% = Register(nul%%) 'go straight to register mode after elimination
  763.     END SELECT
  764.    CASE SELECT_BUTTON
  765.     Selection%% = Selection%% + 1
  766.     IF Selection%% = 6 THEN Selection%% = 1
  767.     Selection%% = Find_First_Available(0, Selection%%)
  768.     DO: LOOP UNTIL Get_Input%% = -1
  769.    CASE ELSE
  770.     _PRINTSTRING (0, 20), STR$(SELECT_BUTTON), Layer(1)
  771.  
  772.   SELECT CASE Selection%%
  773.    CASE 1
  774.     _PUTIMAGE (220, 242)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Player 1
  775.    CASE 2
  776.     _PUTIMAGE (220, 290)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Player 2
  777.    CASE 3
  778.     _PUTIMAGE (220, 338)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Player 3
  779.    CASE 4
  780.     _PUTIMAGE (220, 394)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'register
  781.    CASE 5
  782.     _PUTIMAGE (220, 426)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Elimination
  783.   _PRINTSTRING (0, 0), STR$(Selection%%), Layer(1)
  784.   _PUTIMAGE , Layer(1), Layer(0)
  785.   _LIMIT 60
  786.   IF INKEY$ = CHR$(27) THEN Exitflag%% = TRUE
  787.  LOOP UNTIL Exitflag%%
  788.  
  789. FUNCTION Register%% (Records%%)
  790.  DIM Names(2, 8) AS STRING * 1
  791.  Result%% = Records%%
  792.  Tmp& = _COPYIMAGE(Layer(16))
  793.  ClearLayer Layer(16)
  794.  ClearLayer Layer(1)
  795.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (258, 1)-STEP(255, 223) 'background
  796.  FOR i%% = 1 TO 3
  797.   IF RTRIM$(Nick(i%%)) <> "" THEN Place_Player_Record i%% - 1, 1
  798.  NEXT i%%
  799.  IF i%% > 0 THEN Selection%% = i%% ELSE Selection%% = 1
  800.  FOR i%% = 1 TO 3
  801.   IF RTRIM$(Nick(i%%)) = "" THEN _PUTIMAGE (300, 154 + 48 * (i%% - 1))-STEP(31, 31), Layer(12), Layer(16), (1, 230)-STEP(15, 15) 'Player 1 Link (green)
  802.  NEXT i%%
  803.  _CLEARCOLOR _RGB32(0), Layer(16)
  804.  _PUTIMAGE , Layer(16), Layer(1)
  805.  _DEST Layer(1)
  806.  Current_Letter%% = 1
  807.  Selection%% = Find_First_Available(1, 1)
  808.  DO
  809.  
  810.   SELECT CASE Get_Input%%
  811.    CASE Up
  812.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  813.     Ly% = Ly% - 1
  814.     IF Ly% = -1 THEN Ly% = 3
  815.     Current_Letter%% = Current_Letter%% - 11
  816.     IF Current_Letter%% < 0 THEN Current_Letter%% = 44 - ABS(Current_Letter%%)
  817.    CASE Down
  818.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  819.     Ly% = Ly% + 1
  820.     IF Ly% = 4 THEN Ly% = 0
  821.     Current_Letter%% = Current_Letter%% + 11
  822.     IF Current_Letter%% > 44 THEN Current_Letter%% = Current_Letter%% - 44
  823.    CASE Left
  824.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  825.     Lx% = Lx% - 1
  826.     IF Lx% = -1 THEN Lx% = 10: Ly% = Ly% - 1: IF Ly% = -1 THEN Ly% = 3
  827.     Current_Letter%% = Current_Letter%% - 1
  828.     IF Current_Letter%% = 0 THEN Current_Letter%% = 44
  829.    CASE Right
  830.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  831.     Lx% = Lx% + 1
  832.     IF Lx% = 11 THEN Lx% = 0: Ly% = Ly% + 1: IF Ly% = 4 THEN Ly% = 0
  833.     Current_Letter%% = Current_Letter%% + 1
  834.     IF Current_Letter%% = 45 THEN Current_Letter%% = 1
  835.    CASE BUTTON_A OR BUTTON_B
  836.     IF Selection%% <> 4 THEN 'only allow buttons if valid name entry selection
  837.      _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current Nick Letter
  838.      Names(Selection%% - 1, Length%%) = Letter(Current_Letter%%)
  839.      Length%% = Length%% + 1
  840.      IF Length%% = 8 THEN Length%% = 0
  841.     END IF
  842.    CASE START_BUTTON
  843.     SELECT CASE Selection%%
  844.      CASE 4 'end
  845.       FOR j%% = 0 TO 2
  846.        a$ = ""
  847.        IF RTRIM$(Nick(j%% + 1)) = "" THEN
  848.         FOR i%% = 0 TO 7
  849.          IF ASC(Names(j%%, i%%)) > 31 THEN a$ = a$ + Names(j%%, i%%)
  850.         NEXT
  851.         Nick(j%% + 1) = a$
  852.        END IF
  853.       NEXT
  854.       ExitFlag%% = TRUE
  855.     END SELECT
  856.    CASE SELECT_BUTTON 'Change to different name or end registration
  857.     _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current Nick Letter
  858.     _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'heart selection
  859.     Selection%% = Selection%% + 1: Length%% = 0 'reset the name position when changing.
  860.     IF Selection%% = 5 THEN Selection%% = 1
  861.     _PRINTSTRING (0, 0), STR$(Selection%%), Layer(1)
  862.     Selection%% = Find_First_Available(1, Selection%%)
  863.    CASE ELSE
  864.     LINE (0, 0)-STEP(160, 40), _RGB32(0), BF
  865.     _PRINTSTRING (0, 20), STR$(Selection%%), Layer(1)
  866.   DO: LOOP UNTIL Get_Input%% = -1
  867.  
  868.   _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'heart selection
  869.   IF Selection%% <> 4 THEN
  870.    FOR j%% = 0 TO 8
  871.     IF Names(Selection%% - 1, j%%) > CHR$(31) THEN _PRINTSTRING (364 + 16 * j%%, 152 + 48 * (Selection%% - 1)), Names(Selection%% - 1, j%%), Layer(1)
  872.    NEXT j%%
  873.   END IF
  874.   _PUTIMAGE , Layer(1), Layer(0)
  875.   IF blink%% AND Selection%% <> 4 THEN
  876.    _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (61, 230)-STEP(7, 7) 'Current Nick Letter
  877.    _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (61, 230)-STEP(7, 7) 'Current selected Letter
  878.   ELSE
  879.    _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current Nick Letter
  880.    _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  881.   END IF
  882.   _PUTIMAGE , Layer(16), Layer(1)
  883.   b%% = b%% + 1
  884.   IF b%% = 8 THEN blink%% = NOT blink%%: b%% = 0
  885.   _LIMIT 60
  886.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  887.  LOOP UNTIL ExitFlag%%
  888.  ClearLayer Layer(16)
  889.  _PUTIMAGE , Tmp&, Layer(16)
  890.  _FREEIMAGE Tmp&
  891.  Save_Records
  892.  FOR i%% = 1 TO 3
  893.   IF RTRIM$(Nick(i%%)) <> "" THEN Place_Player_Record i%% - 1, 0
  894.  NEXT i%%
  895.  Register = Result%%
  896.  
  897. SUB Elimination_Mode
  898.  Tmp& = _COPYIMAGE(Layer(16))
  899.  ClearLayer Layer(16)
  900.  ClearLayer Layer(1)
  901.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (515, 1)-STEP(255, 223) 'background
  902.  FOR i%% = 1 TO 3
  903.   IF RTRIM$(Nick(i%%)) <> "" THEN Place_Player_Record i%% - 1, 1
  904.  NEXT i%%
  905.  _PUTIMAGE , Layer(16), Layer(0)
  906.  IF i%% > 0 THEN Selection%% = i%% ELSE Selection%% = 1
  907.  FOR i%% = 1 TO 3 'remove the erased game from the background screens
  908.   IF RTRIM$(Nick(i%%)) = "" THEN _PUTIMAGE (300, 154 + 48 * (i%% - 1))-STEP(31, 31), Layer(12), Layer(16), (1, 230)-STEP(15, 15) 'Player 1 Link (green)
  909.  NEXT i%%
  910.  _CLEARCOLOR _RGB32(0), Layer(16)
  911.  _PUTIMAGE , Layer(16), Layer(1)
  912.  _DEST Layer(1)
  913.  Current_Letter%% = 1
  914.  Selection%% = 1
  915.  DO
  916.   _PUTIMAGE , Layer(16), Layer(1)
  917.   SELECT CASE Get_Input%%
  918.    CASE START_BUTTON
  919.     SELECT CASE Selection%%
  920.      CASE 1 TO 3
  921.       Nick(Selection%%) = ""
  922.       Reset_Record Selection%%
  923.       _PUTIMAGE (364, 152 + 48 * (Selection%% - 1))-STEP(159, 31), Layer(12), Layer(16), (86, 240)-STEP(7, 7) 'black out
  924.       _PUTIMAGE (236, 232 + 48 * (Selection%% - 1))-STEP(159, 33), Layer(12), Tmp&, (86, 240)-STEP(7, 7) 'black out name
  925.       _PUTIMAGE (428, 232 + 48 * (Selection%% - 1))-STEP(127, 31), Layer(12), Tmp&, (86, 240)-STEP(7, 7) 'black out hearts
  926.      CASE 4
  927.       ExitFlag%% = TRUE
  928.     END SELECT
  929.    CASE SELECT_BUTTON
  930.     _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'heart selection black out
  931.     Selection%% = Selection%% + 1
  932.     IF Selection%% = 5 THEN Selection%% = 1
  933.    CASE ELSE
  934.     _PRINTSTRING (0, 20), STR$(SELECT_BUTTON), Layer(1)
  935.   DO: LOOP UNTIL Get_Input%% = -1
  936.   _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (73, 267)-STEP(7, 7) 'heart selection
  937.   _PUTIMAGE , Layer(1), Layer(0)
  938.   _LIMIT 60
  939.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  940.  LOOP UNTIL ExitFlag%%
  941.  ClearLayer Layer(16)
  942.  _PUTIMAGE , Tmp&, Layer(16)
  943.  _FREEIMAGE Tmp&
  944.  
  945. SUB Reset_Record (Which%%)
  946.  Records(Which%%) = Reset_Link
  947.  
  948. SUB Save_Records
  949.  OPEN "Zelda.MSF" FOR BINARY AS #1
  950.  FOR I%% = 1 TO 3
  951.   PUT #1, , Nick(I%%)
  952.   PUT #1, , Records(I%%)
  953.  NEXT I%%
  954.  CLOSE #1
  955.  
  956. SUB MFI_Loader (FN$)
  957.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  958.  GET #1, , c~%% 'retrieve number of files
  959.  FOR I~%% = 1 TO c~%%
  960.   GET #1, , FOffset(I~%%)
  961.   GET #1, , Size(I~%%)
  962.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  963.  NEXT I~%%
  964.  Layer(7) = LoadGFX(FOffset(1), Size(1)) '_LOADIMAGE("overworldtiles.bmp", 32)
  965.  Layer(9) = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("TitleScreen.bmp", 32)
  966.  Layer(10) = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("Titlefalls.bmp", 32)
  967.  Layer(11) = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("Titlescroll.bmp", 32)
  968.  Layer(12) = LoadGFX(FOffset(5), Size(5)) '_LOADIMAGE("selectionscreen.bmp", 32)
  969.  
  970.  SFX(0) = LoadSFX(FOffset(6), Size(6))
  971.  SFX(1) = LoadSFX(FOffset(7), Size(7))
  972.  SFX(2) = LoadSFX(FOffset(8), Size(8))
  973.  SFX(3) = LoadSFX(FOffset(9), Size(9))
  974.  BGM(0) = LoadSFX(FOffset(10), Size(10))
  975.  FFX(0) = LoadFFX(FOffset(11), Size(11), 16)
  976.  LoadData FOffset(12), Size(12)
  977.  
  978.  CLOSE #1
  979.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  980.  
  981. FUNCTION LoadGFX& (Foff&, Size&)
  982.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  983.  OPEN "temp.dat" FOR BINARY AS #3
  984.  dat$ = SPACE$(Size&)
  985.  GET #1, Foff&, dat$
  986.  PUT #3, , dat$
  987.  CLOSE #3
  988.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  989.  
  990. FUNCTION LoadFFX& (Foff&, Size&, Fize%%)
  991.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  992.  OPEN "temp.dat" FOR BINARY AS #3
  993.  dat$ = SPACE$(Size&)
  994.  GET #1, Foff&, dat$
  995.  PUT #3, , dat$
  996.  CLOSE #3
  997.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, "monospace")
  998.  
  999. FUNCTION LoadSFX& (Foff&, Size&)
  1000.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1001.  OPEN "temp.dat" FOR BINARY AS #3
  1002.  dat$ = SPACE$(Size&)
  1003.  GET #1, Foff&, dat$
  1004.  PUT #3, , dat$
  1005.  CLOSE #3
  1006.  LoadSFX& = _SNDOPEN("temp.dat")
  1007.  
  1008. SUB LoadData (Foff&, Size&)
  1009.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1010.  OPEN "temp.dat" FOR BINARY AS #3
  1011.  dat$ = SPACE$(Size&)
  1012.  GET #1, Foff&, dat$
  1013.  PUT #3, , dat$
  1014.  CLOSE #3
  1015.  
  1016.  F1 = FREEFILE
  1017.  OPEN "temp.dat" FOR BINARY AS #F1
  1018.  GET #F1, , Hyrule()
  1019.  GET #F1, , Link
  1020.  GET #F1, , C
  1021.  GET #F1, , G
  1022.  GET #F1, , Offset_X()
  1023.  GET #F1, , Offset_Y()
  1024.  FOR I%% = 1 TO 44
  1025.   GET #F1, , Letter(I%%)
  1026.  NEXT I%%
  1027.  CLOSE #F1
  1028.  
  1029.  

7
QB64 Discussion / Lacking QB4.5 error catch
« on: December 16, 2021, 04:48:27 pm »
so in QB4.5 if you type the following line you will get an error at run time

Code: QB64: [Select]
  1. END of

However this is allowed in QB64(2.0.2); IDE does not flag, even the compilation does not fail.(just what happens to the 'of'?)

Found this when I accidentally hit the 'o' instead of 'i'. was supposed to be END IF not END OF but it wasn't flagged.

8
QB64 Discussion / IF THEN issue using AND, I think I'm losing my mind!
« on: December 10, 2021, 06:31:38 pm »
given the following:

Code: QB64: [Select]
  1.  
  2.  P.Mouse_over_R = 16
  3.  P.Mouse_over_B = 15
  4.  'The following IF THEN fails even though both values are TRUE(non 0)
  5.  IF P.Mouse_over_R  AND P.Mouse_over_B THEN
  6.    REM Mouse_Over_Data _MOUSEX, _MOUSEY, P.World_X + P.Mouse_over_R - 1, P.World_Y + P.Mouse_over_B - 1
  7.   ELSE
  8.    _PRINTSTRING (0, 0), STR$(P.Mouse_over_R) + STR$(P.Mouse_over_B), _Display
  9.  
FAILS!

BUT given these values...

Code: QB64: [Select]
  1.  
  2.  P.Mouse_over_R = 9
  3.  P.Mouse_over_B = 7
  4.  'The following IF THEN passes
  5.  IF P.Mouse_over_R  AND P.Mouse_over_B THEN
  6.    REM Mouse_Over_Data _MOUSEX, _MOUSEY, P.World_X + P.Mouse_over_R - 1, P.World_Y + P.Mouse_over_B - 1
  7.   ELSE
  8.    _PRINTSTRING (0, 0), STR$(P.Mouse_over_R) + STR$(P.Mouse_over_B), _Display
  9.   END IF
  10.  
WORKS?

So why? In both scenarios the values are non 0 but one works one doesn't?
Now if I add " > 0" to both checks it works all the time, but why is that needed?
What neuron-connections in my brain have failed and made me forget something about 'AND'?

9
QB64 Discussion / A question about _INFLATE$\_DEFLATE$ usage
« on: December 08, 2021, 04:23:35 pm »
I was looking into using these commands for my World Builder program to help with the saved map size issue it is facing now. Recent changes, things I just did last night and today, have ballooned the file size to several megs.

Looking at the WIKI the commands take string values. Now my map data is made up of UDTs and integer arrays. How would I go about using these commands to compress the map size when saved?

10
QB64 Discussion / Refresh my memory please, dealing with multiple '='
« on: December 05, 2021, 01:08:49 pm »
So why do multiple '=' on the same line act like a comparative instead of assignment?

Code: QB64: [Select]
  1. A% = 101
  2. B% = A% 'Assignment =
  3. C% = A% = 99 'comparative =:  C% = 0(false)
  4. D% = A% = B% 'comparative =: D% = -1(true)
  5.  

I can't seem to remember why this is. That only the first = is treated as an assignment and all others as comparatives.

11
QB64 Discussion / A question about Recursion and STATIC arrays
« on: December 01, 2021, 12:52:25 pm »
If I have a Function that I want to attempt recursion with that has a STATIC array defined within it, does the data in the array remain for each recursion or is it a new static array for each time the function recurses?

In my mind I see it as being the same array each time the function is called, either in recursion or by the main loop. As STATIC variables within a sub or function are supposed to remain between calls. I'm just not sure if thats how it actually works during recursion, or if anybody has done this before.

I just don't want to waste a lot of time trying to code this out if its not how things are supposed to work in the first place and then spend countless hours trying to figure out why it doesn't work correctly then.

Of course if there is no experience out there then my option is simply to give it a go and pray for a good result I guess.  It however takes less time to ask, than to blindly charge in and try to fix a mangled mess later.

12
So I can stop running into this:

In file included from qbx.cpp:2185:
..\\temp\\main.txt: In function 'void SUB_SAVE_IT(qbs*)':
..\\temp\\main.txt:3329:137: error: lvalue required as unary '&' operand
 sub_put(qbr(*_SUB_SAVE_IT_SINGLE_F),NULL,byte_element((uint64)(&(qbs_new_fixed(&((uint8*)(__ARRAY_STRING255_DIALOGS[0]))[(0)*255],255,1))),(255*(__ARRAY_STRING255_DIALOGS[2]&1)*__ARRAY_STRING255_DIALOGS[5])-(255*(0)),byte_element_118),0);
compilation terminated due to -Wfatal-errors.


13
Programs / World Explorer BETA
« on: November 28, 2021, 02:03:25 pm »
The counter part of the World Builder program. A quick Demo of how the maps created with the World Builder program are used.

The Explore-able area is limited to roughly 16x16 for this quick demo. Still some slight hiccups with the layering effect.

Arrow Keys move the player
Space bar interacts with a few areas on screen.

I hope to include the addition of Interactive areas on the screen to be create-able within the World Builder program itself. but as for now they are hard coded in the World Explorer program and will show up even in other maps at the moment.

Sample Map included, but you can make one with the latest World Builder program, to try your own map you must simply change line 49 to the name of your map.

Code: QB64: [Select]
  1. TYPE World_Tiles
  2.  Id AS INTEGER 'ground
  3.  Deco AS INTEGER 'decorations(trees\bushes\ect)
  4.  Lay3 AS INTEGER 'a third layer of map tiles
  5.  Walkable AS _BYTE 'can player walk on this tile?
  6.  
  7. TYPE Player_Data
  8.  World_X AS _UNSIGNED INTEGER 'world size is 0-65535 tiles^2 (4,294,967,295 tiles total)
  9.  World_Y AS _UNSIGNED INTEGER
  10.  Local_X AS INTEGER
  11.  Local_Y AS INTEGER
  12.  Direction AS _BYTE
  13.  Frame AS _BYTE
  14.  
  15. SCREEN _NEWIMAGE(840, 640, 32)
  16. _TITLE "World Explorer V1.0"
  17.  
  18. CONST Key_Right = 19712, Key_Left = 19200, Key_Up = 18432, Key_Down = 20480
  19. CONST Key_Space = 32, Key_Enter = 13
  20. CONST Down = 0, Left = 1, Right = 2, Up = 3, InterAct = 4
  21. CONST TRUE = -1, FALSE = NOT TRUE
  22.  
  23. DIM SHARED Layer(16) AS LONG, World(255, 255) AS World_Tiles
  24. DIM SHARED P AS Player_Data, Yo%%
  25.  
  26. Layer(0) = _DISPLAY
  27. Layer(1) = _NEWIMAGE(840, 640, 32) 'composite layer
  28. 'Layer(2) = _LOADIMAGE("linear_tiles.bmp", 32) 'world tiles
  29. Layer(3) = _NEWIMAGE(840, 640, 32)
  30. 'Layer(4) = _LOADIMAGE("Character3.bmp", 32) 'world tiles
  31. Layer(5) = _NEWIMAGE(840, 640, 32)
  32.  
  33. MFI_Loader "WorldExplorer.MFI"
  34.  
  35. _CLEARCOLOR _RGB32(0), Layer(2)
  36. _CLEARCOLOR _RGB32(0), Layer(3)
  37. _CLEARCOLOR _RGB32(0), Layer(5)
  38. _CLEARCOLOR _RGB32(43, 133, 133), Layer(4)
  39. P.World_X = 0
  40. P.World_Y = 0
  41. P.Local_X = 32
  42. P.Local_Y = 32
  43.  
  44. Load_it "take2"
  45.  
  46. Draw_World_Area
  47.  
  48.  
  49.  SELECT CASE Get_Input
  50.   CASE Down
  51.    Moving%% = TRUE
  52.    P.Direction = Down
  53.    IF P.Local_Y < 600 THEN P.Local_Y = P.Local_Y + 1
  54.    IF Collision_World THEN P.Local_Y = P.Local_Y - 1
  55.   CASE Left
  56.    Moving%% = TRUE
  57.    P.Direction = Left
  58.    IF P.Local_X > 2 THEN P.Local_X = P.Local_X - 1
  59.    IF Collision_World THEN P.Local_X = P.Local_X + 1
  60.   CASE Right
  61.    Moving%% = TRUE
  62.    P.Direction = Right
  63.    IF P.Local_X < 600 THEN P.Local_X = P.Local_X + 1
  64.    IF Collision_World THEN P.Local_X = P.Local_X - 1
  65.   CASE Up
  66.    Moving%% = TRUE
  67.    P.Direction = Up
  68.    IF P.Local_Y > 2 THEN P.Local_Y = P.Local_Y - 1
  69.    IF Collision_World THEN P.Local_Y = P.Local_Y + 1
  70.   CASE InterAct
  71.    _DELAY .1
  72.    InterActions
  73.    P.Frame = 0
  74.    Moving%% = FALSE
  75.  IF Moving%% THEN Animate_Character
  76.  
  77.  _PUTIMAGE , Layer(3), Layer(1)
  78.  Draw_Character 0, 0, P.Frame
  79.  _PUTIMAGE , Layer(5), Layer(1)
  80.  _PUTIMAGE , Layer(1), Layer(0)
  81.  ClearLayer Layer(1)
  82.  _LIMIT 60
  83.  IF INKEY$ = CHR$(27) THEN ExitFlag%% = -1
  84. LOOP UNTIL ExitFlag%%
  85.  
  86. SUB Animate_Character
  87.  STATIC Frame%%
  88.  Frame%% = Frame%% + 1
  89.  IF Frame%% = 15 THEN P.Frame = P.Frame + 1: Frame%% = 0
  90.  IF P.Frame = 4 THEN P.Frame = 0
  91.  
  92. SUB Draw_World_Area
  93.  FOR Y%% = 0 TO 19
  94.   FOR X%% = 0 TO 19
  95.    Draw_Sprite X%%, Y%%, World(P.World_X + X%%, P.World_Y + Y%%).Id
  96.    IF World(P.World_X + X%%, P.World_Y + Y%%).Deco THEN
  97.     Draw_Deco_Sprite X%%, Y%%, World(P.World_X + X%%, P.World_Y + Y%%).Deco, Layer(3)
  98.    END IF
  99.    IF World(P.World_X + X%%, P.World_Y + Y%%).Lay3 THEN
  100.     Draw_Deco_Sprite X%%, Y%%, World(P.World_X + X%%, P.World_Y + Y%%).Lay3, Layer(5)
  101.    END IF
  102.   NEXT X%%
  103.  NEXT Y%%
  104.  
  105. SUB Draw_Sprite (X%%, Y%%, id%)
  106.  _PUTIMAGE (X%% * 32, Y%% * 32), Layer(2), Layer(3), (0 + id% * 32, 0)-STEP(31, 31)
  107.  
  108. SUB Draw_Deco_Sprite (x%%, y%%, id%, L&)
  109.  _PUTIMAGE (x%% * 32, y%% * 32), Layer(2), L&, (0 + id% * 32, 0)-STEP(31, 31)
  110.  
  111. SUB Load_it (File$)
  112.  F = FREEFILE
  113.  IF File$ = "" THEN File$ = "Defualt"
  114.  File$ = LTRIM$(RTRIM$(File$)) 'no spaces allowed
  115.   IF _FILEEXISTS(File$+".MAP") = FALSE THEN PRINT File$ + ".MAP is missing.": END
  116.  OPEN File$ + ".MAP" FOR BINARY AS #F 'Save
  117.  GET #F, , World()
  118.  CLOSE #F
  119.  
  120. SUB Draw_Character (x%%, y%%, id%)
  121.  _PUTIMAGE (P.Local_X + x%% * 32, P.Local_Y + y%% * 32), Layer(4), Layer(1), (0 + id% * 32, 0 + 48 * P.Direction)-STEP(30, 47)
  122.  
  123. FUNCTION Get_Input%% ()
  124.  Result%% = TRUE '-1 for no input
  125.  ' IF _KEYDOWN(ESC_Key) THEN Result%% = ESC
  126.  IF _KEYDOWN(Key_Up) THEN Result%% = Up
  127.  IF _KEYDOWN(Key_Down) THEN Result%% = Down
  128.  IF _KEYDOWN(Key_Left) THEN Result%% = Left
  129.  IF _KEYDOWN(Key_Right) THEN Result%% = Right
  130.  IF _KEYDOWN(Key_Space) THEN Result%% = InterAct
  131.  Get_Input%% = Result%%
  132.  
  133. SUB ClearLayer (L&)
  134.  _DEST L&
  135.  CLS
  136.  
  137. SUB ClearLayerTrans (L&)
  138.  _DEST L&
  139.  CLS , 0
  140.  
  141. FUNCTION Collision_World%%
  142.  Result%% = TRUE
  143.  SELECT CASE P.Direction 'adjust collision detection point based on direction of travel
  144.   CASE Down
  145.    Yo%% = 1
  146.   CASE Up
  147.    Yo%% = 1
  148.   CASE Left
  149.    Yo%% = 1
  150.   CASE Right
  151.    Yo%% = 1
  152.  IF World(Tile(P.Local_X + 16), Tile(P.Local_Y + 0) + Yo%%).Walkable THEN Result%% = FALSE
  153.  
  154.  _PUTIMAGE (650, 100)-STEP(63, 16), Layer(1), Layer(3), (700, 500)-STEP(32, 16)
  155.  _PRINTSTRING (650, 100), STR$(Tile(P.Local_X + 16)) + STR$(Tile(P.Local_Y) + Yo%%), Layer(3)
  156.  Collision_World = Result%%
  157.  
  158. FUNCTION Tile% (value%)
  159.  Result% = value% \ 32
  160.  Tile = Result%
  161.  
  162. SUB InterActions
  163.  SELECT CASE P.Direction
  164.   CASE Up
  165.    IF Tile(P.Local_X + 16) = 1 AND Tile(P.Local_Y) - 1 + Yo%% = 6 THEN 'sign post
  166.     tmp& = _COPYIMAGE(Layer(0))
  167.     _KEYCLEAR
  168.     _DEST Layer(1)
  169.     DO
  170.      _PUTIMAGE , tmp&, Layer(1)
  171.      LINE (P.Local_X + 32, P.Local_Y + 16)-STEP(191, 40), _RGBA32(112, 32, 192, 144), BF
  172.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 26), "This is a sign post.", Layer(1)
  173.      _PUTIMAGE , Layer(1), Layer(0)
  174.      _LIMIT 60
  175.      IF Get_Input <> TRUE THEN ExitFlag%% = TRUE
  176.     LOOP UNTIL ExitFlag%%
  177.     _KEYCLEAR
  178.     _FREEIMAGE tmp&
  179.     _DEST Layer(0)
  180.    END IF
  181.  
  182.    IF Tile(P.Local_X + 16) = 1 AND Tile(P.Local_Y) - 1 + Yo%% = 13 THEN 'Grave Stone
  183.     tmp& = _COPYIMAGE(Layer(0))
  184.     _KEYCLEAR
  185.     _DEST Layer(1)
  186.     DO
  187.      _PUTIMAGE , tmp&, Layer(1)
  188.      LINE (P.Local_X + 32, P.Local_Y + 16)-STEP(191, 48), _RGBA32(112, 32, 192, 144), BF
  189.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 26), "Here lies: Cobalt", Layer(1)
  190.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 42), "33AE - 121AE", Layer(1)
  191.      _PUTIMAGE , Layer(1), Layer(0)
  192.      _LIMIT 60
  193.      IF Get_Input <> TRUE THEN ExitFlag%% = TRUE
  194.     LOOP UNTIL ExitFlag%%
  195.     _KEYCLEAR
  196.     _FREEIMAGE tmp&
  197.     _DEST Layer(0)
  198.    END IF
  199.  
  200.    IF Tile(P.Local_X + 16) = 7 AND Tile(P.Local_Y) - 1 + Yo%% = 11 THEN 'Front door
  201.     tmp& = _COPYIMAGE(Layer(0))
  202.     _KEYCLEAR
  203.     _DEST Layer(1)
  204.     DO
  205.      _PUTIMAGE , tmp&, Layer(1)
  206.      LINE (P.Local_X + 32, P.Local_Y + 16)-STEP(191, 48), _RGBA32(112, 32, 192, 144), BF
  207.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 26), "'Knock Knock...'", Layer(1)
  208.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 42), "There is no answer.", Layer(1)
  209.      _PUTIMAGE , Layer(1), Layer(0)
  210.      _LIMIT 60
  211.      IF Get_Input <> TRUE THEN ExitFlag%% = TRUE
  212.     LOOP UNTIL ExitFlag%%
  213.     _KEYCLEAR
  214.     _FREEIMAGE tmp&
  215.     _DEST Layer(0)
  216.    END IF
  217.  
  218.    IF Tile(P.Local_X + 16) = 6 AND Tile(P.Local_Y) - 1 + Yo%% = 4 THEN 'Well
  219.     tmp& = _COPYIMAGE(Layer(0))
  220.     _KEYCLEAR
  221.     _DEST Layer(1)
  222.     DO
  223.      _PUTIMAGE , tmp&, Layer(1)
  224.      LINE (P.Local_X + 32, P.Local_Y + 16)-STEP(191, 48), _RGBA32(112, 32, 192, 144), BF
  225.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 26), "It is a well.", Layer(1)
  226.      _PRINTSTRING (P.Local_X + 42, P.Local_Y + 42), "Wow it is deep!", Layer(1)
  227.      _PUTIMAGE , Layer(1), Layer(0)
  228.      _LIMIT 60
  229.      IF Get_Input <> TRUE THEN ExitFlag%% = TRUE
  230.     LOOP UNTIL ExitFlag%%
  231.     _KEYCLEAR
  232.     _FREEIMAGE tmp&
  233.     _DEST Layer(0)
  234.    END IF
  235.  
  236.  
  237. SUB MFI_Loader (FN$)
  238.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  239.   IF _FILEEXISTS(FN$) = FALSE THEN PRINT FN$ + " is missing. This file needs downloaded": END
  240.  GET #1, , c~%% 'retrieve number of files
  241.  FOR I~%% = 1 TO c~%%
  242.   GET #1, , FOffset(I~%%)
  243.   GET #1, , Size(I~%%)
  244.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  245.  NEXT I~%%
  246.  
  247.  Layer(2) = LoadGFX(FOffset(1), Size(1)) 'tiles
  248.  Layer(4) = LoadGFX(FOffset(2), Size(2)) 'characters
  249.  
  250.  CLOSE #1
  251.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  252.  
  253. FUNCTION LoadGFX& (Foff&, Size&)
  254.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  255.  OPEN "temp.dat" FOR BINARY AS #3
  256.  dat$ = SPACE$(Size&)
  257.  GET #1, Foff&, dat$
  258.  PUT #3, , dat$
  259.  CLOSE #3
  260.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  261.  


14
Programs / Tile Based World Maker! (FIXED update 7)
« on: November 23, 2021, 09:06:35 pm »
So I was fiddling with making a Program to create maps for a game and thought I might share it and see if you guys would want to create some custom maps?

Plus it could use some stress testing.

The interface is mouse based. Click and release, NOT CLICK AND DRAG.(although you can add to the map by clicking and dragging with left and right buttons, but not the middle button.)

To use, you click on a tile, then click the tile either in the BASE, DECO, or AUTOMATIC areas.

Left button allows selection of a tile from the tile list area to be placed in the BASE, DECO, or AUTOMATIC area.
Right button cancels the selection

In the Map grid:
Left button adds the DECO tile to the map.
Right button clears the DECO and restores the BASE tile.
Middle button places the AUTOMATIC area on the map. Now this has an issue if you click and drag, and it will cause errors.Fixed

The AUTOMATIC area allows you to pre-make a 3x3 area that can be used over and over. Right clicking in the AUTOMATIC area erases it.

The yellow box on the "Mini Map" shows what area you are currently working in. right now the Mini Map only shows the BASE tiles no DECO tiles. This may not change due to the Mini Map being a 256x256 render of the full map which is 8192x8192.(32:1 ratio)
(FYI: DECO is short for Decorations)

There are currently 960 tiles to choose from.
this is due to the limitations of image format sizes, BMP max out at roughly 32k px. and my imaging software maxes the PNG out at roughly 30k. (I will need to come up with a round about way to make it capable of larger sets)
Only the first 8 tiles can be used for the BASE.

Maps can be saved(and loaded!) with up to 32 character long names, leaving the name blank names it "DEFUALT" no spaces allowed. Extension is automatically set to ".MAP".  Can only save to the program directory at the moment.


I think that is it, tell me what you think!
(this requires a MFI file, so be sure to download it.)

Fixed an issue where the decorations would not draw correctly when you moved on the map.(11\24\2021)
Fixed an issue where the decorations displayed outside the map grid area(11\24\2021)
Added the ability to place SINGLE tiles straight to the map area. (as recommended by Bplus)
Added a 3rd layer to the placement of tiles for more depth.
Fixed issue with erasing decorations after moving in the map.(11/27/2021)

Video Demo:(outdated)
https://youtu.be/0K6pmuGXY-Q



15
Programs / Gapper, Give it a try! (updated[11/19/21])
« on: November 18, 2021, 01:36:35 pm »
So I present Gapper. Surf the grid changing its color to rack up points. But beware the Seeker who is out to get you!

Being absurdly busy of late this has taken far longer than it should of, but its coming along.

There is a few things to iron out yet; Bonus squares, the ability to "Gap", the 5000 point bonus life, and the high score list.
But based on my trial runs everything seems to be working as close to original as possible. Granted my own tests hardly find anything that might be hidden or obscure. So I could use some other players to make sure they can not find anything!

The seeker has a very subtle speed curve and wont reach full speed till closer to Level 8 now.

need to find a way to add the intro screens as data without it taking 2.4mb of space(original BMP was only 900k)

Controls: Arrow Keys
                Space Bar- place a temporary gap in the line.
(introduced a bug, you only get an extra life if you have exact multiples of 5000! fixing this soon) Fixed(again)
Code: QB64: [Select]
  1. 'Gapper(1986) Clone
  2. '10\25\2019 Cobalt
  3. 'ÃInital Start; Layout, Gapper, Seeker, L1 Grid finished [13:55EDT]
  4. 'ÀCorreted 'Catcher' to 'Seeker' as per original game
  5. '10\31\2021
  6. 'ÃFixed Seeker movement issue with help from Bplus and Keybone, used ABS as per Bplus
  7. 'Àadded startup screen, player initials input,game options
  8. '11\1\2021
  9. 'ÃAdded the instructions screens
  10. 'Àenabled collision of Seeker and Gapper
  11. '11\11\2021
  12. 'ÃFinished all 8 boards
  13. '11\13\2021
  14. 'ÃInserted Bplus's code for detecting completed boxes.
  15. '11\14\2021
  16. 'ÃIntegrated Bplus's code for detecting completed boxes and filling them.
  17. 'ÃAdded score amount to filled boxes
  18. 'ÃLevels now end when boxes are full
  19. 'ÀScore is now kept
  20. '11\15\2021
  21. 'ÃFixed a few minor bugs with help from Bplus
  22. 'ÃReplaced each level creation sub with a master so now all levels created with in a single sub, saved ~210 lines
  23. 'ÀChanged Seeker speed to use reducing timer to move faster as levels progress.
  24. '11\18\2021
  25. 'ÃAdded extra life at 5000 point intervals
  26. 'ÀAdded ability to create "Gaps" on board
  27.  
  28. TYPE GameData
  29.  Player AS STRING * 4
  30.  Score AS LONG
  31.  Lives AS _BYTE
  32.  Level AS _BYTE
  33.  GX AS INTEGER 'Gapper X location
  34.  GY AS INTEGER 'Gapper Y location
  35.  GD AS _BYTE 'Gapper direction
  36.  SX AS INTEGER
  37.  SY AS INTEGER
  38.  SS AS _BYTE 'Seeker speed
  39.  SD AS _BYTE 'Seeker direction
  40.  Start AS _BYTE 'is level started or not(nothing happens until started)
  41.  FPS AS INTEGER
  42.  Quit AS _BYTE
  43.  Caught AS _BYTE 'has the seeker caught the gapper?
  44.  Gapped AS _BYTE 'has the player used the gap feature?
  45.  Gap_time AS SINGLE 'the time the gap was placed. Gaps last less time at higher levels
  46.  'board info
  47.  CellHeight AS _BYTE
  48.  CellWidth AS _BYTE
  49.  Rows AS _BYTE
  50.  Columns AS _BYTE
  51.  Offx AS _BYTE
  52.  Offy AS _BYTE
  53.  Needed AS _BYTE 'number of cells needing finished to win level
  54.  Finished AS _BYTE 'number of cells currently boxed in
  55.  
  56. TYPE High_Scores
  57.  Nam AS STRING * 4
  58.  Score AS LONG
  59.  Level AS INTEGER
  60.  
  61. CONST TRUE = -1, FALSE = NOT TRUE, Gapper = 1, Seeker = 2
  62. CONST UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4
  63. CONST Key_Right = 19712, Key_Left = 19200, Key_Up = 18432, Key_Down = 20480
  64. CONST Key_Space = 32, Key_Enter = 13
  65. CONST Cyan = &HFF10E0E0~& '_RGB32(0, 170, 170)
  66. CONST Magenta = &HFFC040C0~&
  67. CONST OffWhite = &HFFC0C0C0~&
  68. CONST Brown = &HFFB06000~&
  69. CONST Yellow = &HFFFFFF00~&
  70. CONST Black = &HFF000000~&
  71. CONST DB_Blue = &HFF0000FF~&
  72.  
  73. Level_data:
  74. DATA 104,60,3,3,4,10,9,0,14,626,374
  75. DATA 76,44,4,4,8,12,16,8,18,616,370
  76. DATA 60,36,5,5,10,10,25,12,14,612,374
  77. DATA 48,24,7,6,16,16,42,24,26,600,362
  78. DATA 36,24,7,8,16,16,44,24,26,458,362
  79. DATA 36,24,7,8,16,16,40,168,26,458,362
  80. DATA 36,24,7,8,16,16,44,168,26,600,362
  81. DATA 36,24,7,8,16,16,56,24,26,600,362
  82.  
  83. SCREEN _NEWIMAGE(640, 440, 32)
  84. DIM SHARED Layer(11) AS LONG, G AS GameData, Frames%
  85. DIM SHARED Scores(10) AS High_Scores
  86. DIM SHARED FinishedBox(72) AS _BYTE, T1 AS LONG, T2 AS LONG
  87.  
  88. Layer(0) = _DISPLAY
  89. Layer(1) = _NEWIMAGE(640, 440, 32) 'mix layer
  90. Layer(2) = _NEWIMAGE(320, 220, 32) 'Grid Layer
  91. Layer(3) = _NEWIMAGE(640, 440, 32) 'Sprite layer
  92. Layer(4) = _NEWIMAGE(320, 220, 32) 'Info layer
  93. Layer(5) = _NEWIMAGE(640, 440, 32) 'Collision 'Gapper\Catcher' layer
  94. Layer(6) = _NEWIMAGE(640, 440, 32) 'Collision 'Grid' layer
  95. Layer(7) = _NEWIMAGE(640, 440, 32) 'debug layer
  96. Layer(8) = _NEWIMAGE(320, 220, 32) 'Menu layer
  97. Layer(9) = _NEWIMAGE(320, 240, 32) 'instructions layer
  98. Layer(10) = _NEWIMAGE(320, 8, 32) 'title bar layer
  99. Layer(11) = _NEWIMAGE(320, 220, 32) 'point test location layer
  100.  
  101. _FONT 8, Layer(4)
  102. _FONT 8, Layer(8)
  103. _FONT 8, Layer(9)
  104. _FONT 8, Layer(10)
  105. _FONT 8, Layer(2)
  106. _CLEARCOLOR _RGB32(0, 0, 0), Layer(3)
  107. _CLEARCOLOR _RGB32(0, 0, 0), Layer(7)
  108.  
  109. _SOURCE Layer(6)
  110. ON TIMER(T1, 1) FPS
  111. ON TIMER(T2, .05) Move_Seeker
  112.  
  113. Game_INIT
  114. Title_Startup
  115.  
  116.  
  117. SUB Play_game
  118.  DO
  119.   IF _KEYDOWN(27) THEN ExitFlag%% = TRUE: G.Quit = TRUE
  120.   IF _KEYDOWN(Key_Up) THEN
  121.    G.Start = TRUE
  122.    IF NOT Collision_Grid(Gapper, UP) THEN G.GD = UP
  123.   END IF
  124.   IF _KEYDOWN(Key_Down) THEN
  125.    G.Start = TRUE
  126.    IF NOT Collision_Grid(Gapper, DOWN) THEN G.GD = DOWN
  127.   END IF
  128.   IF _KEYDOWN(Key_Left) THEN
  129.    G.Start = TRUE
  130.    IF NOT Collision_Grid(Gapper, LEFT) THEN G.GD = LEFT
  131.   END IF
  132.   IF _KEYDOWN(Key_Right) THEN
  133.    G.Start = TRUE
  134.    IF NOT Collision_Grid(Gapper, RIGHT) THEN G.GD = RIGHT
  135.   END IF
  136.   IF _KEYDOWN(32) AND G.Gapped = FALSE AND G.Start THEN
  137.    G.Gapped = TRUE
  138.    G.Score = G.Score - 5
  139.    Create_Gap
  140.   END IF
  141.   IF G.Start THEN Move_Gapper ':Move_Seeker
  142.   IF G.Gapped THEN Time_Gap 'if there is a gap then check how long its been there
  143.  
  144.   FOR i%% = 1 TO G.Columns * G.Rows
  145.    IF BoxSurrounded(i%%) THEN FinishedBox(i%%) = TRUE
  146.    IF FinishedBox(i%%) THEN FillBox i%%
  147.   NEXT i%%
  148.  
  149.   Game_Data_Update
  150.   _PUTIMAGE (0, 0)-STEP(639, 15), Layer(10), Layer(1) 'title bar
  151.   _PUTIMAGE , Layer(4), Layer(1) 'information bar
  152.   _PUTIMAGE , Layer(2), Layer(1) 'game board
  153.   Place_Gapper
  154.   Place_Seeker
  155.   IF G.Caught THEN 'seeker caught 'em
  156.    ClearLayer Layer(5)
  157.    Reset_Pos
  158.    DrawBoard
  159.    G.Lives = G.Lives - 1
  160.    IF G.Lives = -1 THEN ExitFlag%% = TRUE
  161.   END IF
  162.   ' _PRINTSTRING (600, 0), STR$(G.FPS), Layer(7)
  163.   _PUTIMAGE , Layer(7), Layer(1) 'debug layer
  164.   _PUTIMAGE , Layer(1), Layer(0)
  165.   _LIMIT 60
  166.   ClearLayer Layer(1)
  167.   Frames% = Frames% + 1
  168.   IF G.Finished = G.Needed THEN _DELAY .5: Change_Level
  169.  LOOP UNTIL ExitFlag%%
  170.  
  171. SUB Place_Gapper
  172.  old& = _DEST
  173.  _DEST Layer(5)
  174.  LINE (G.GX - 2, G.GY - 2)-STEP(20, 18), Black, BF
  175.  'place gapper-----
  176.  _PUTIMAGE (G.GX, G.GY), Layer(3), Layer(1), (318, 218)-STEP(15, 13)
  177.  'place Gapper shadow
  178.  _PUTIMAGE (G.GX, G.GY), Layer(3), Layer(5), (318, 218)-STEP(15, 13)
  179.  ' _DEST old&
  180.  
  181. SUB Place_Seeker
  182.  'place Seeker----
  183.  _PUTIMAGE (G.SX, G.SY), Layer(3), Layer(1), (341, 218)-STEP(14, 11)
  184.  '-----------------
  185.  
  186.  
  187. SUB Game_INIT
  188.  _DEST Layer(3)
  189.  'Player----
  190.  DRAW "c" + STR$(Cyan) + "drurd8l2dr3u9d2rd5ru5rd5ru5ru2d9r3ul2u8r2dlbl3c" + STR$(Magenta) + "u3ld3lu3ld3"
  191.  DRAW "bd7d3ru3rd3ru3bu3br3r4ul4bl9l4dr4"
  192.  '----------
  193.  DRAW "br20bu7"
  194.  'Seeker----
  195.  DRAW "c" + STR$(Cyan) + "r3dl3bd10r3ul3br10r3dl3bu10r3ul3c" + STR$(Magenta) + "bd2brl3dr3bd5l3dr3bl6l3ur3"
  196.  DRAW "bu5l3ur3d2lr5dl5dr5dl5"
  197.  '------------
  198.  Title_Header
  199.  _DEST Layer(5)
  200.  LINE (0, 0)-STEP(639, 439), Black, BF
  201.  _DEST Layer(0)
  202.  G.Score = 0
  203.  G.Lives = 2
  204.  G.Level = 1
  205.  
  206. SUB Title_Header
  207.  'Header
  208.  _DEST Layer(10)
  209.  LINE (84, 0)-STEP(151, 8), Magenta, BF
  210.  LINE (132, 0)-STEP(52, 8), Cyan, BF
  211.  COLOR Magenta
  212.  _PRINTSTRING (135, 1), "GAPPER"
  213.  COLOR OffWhite
  214.  
  215. SUB Game_Data_Update
  216.  'Info area updating ---------------
  217.  _PRINTSTRING (7, 192), "Score[      ]    Lives[ ]    Level[  ]", Layer(4)
  218.  _PRINTSTRING (95 - ((LEN(LTRIM$(STR$(G.Score))) - 1) * 8), 192), LTRIM$(STR$(G.Score)), Layer(4)
  219.  _PRINTSTRING (191, 192), LTRIM$(STR$(G.Lives)), Layer(4)
  220.  _PRINTSTRING (295 - ((LEN(LTRIM$(STR$(G.Level))) - 1) * 8), 192), LTRIM$(STR$(G.Level)), Layer(4)
  221.  '-----------------------------------
  222.  
  223. SUB DrawBoard
  224.  _DEST Layer(2)
  225.  SELECT CASE G.Level
  226.   CASE 1 TO 8 'draw level 1 grid
  227.    Master_Level G.Level
  228.   CASE ELSE 'after level 8 board is random between 5 and 8
  229.    Master_Level INT(RND * 4) + 5
  230.  _DEST Layer(0)
  231.  ClearLayer Layer(6)
  232.  _PUTIMAGE , Layer(2), Layer(6) 'make a copy for the collision layer
  233.  
  234. SUB ClearLayer (L&)
  235.  _DEST L&
  236.  CLS
  237.  
  238. SUB ClearLayerTrans (L&)
  239.  _DEST L&
  240.  CLS , 0
  241.  
  242. FUNCTION Collision_Seeker%%
  243.  Result%% = FALSE
  244.  _SOURCE Layer(5)
  245.  IF POINT(G.SX, G.SY) <> Black THEN Result%% = TRUE
  246.  IF POINT(G.SX + 8, G.SY) <> Black THEN Result%% = TRUE
  247.  IF POINT(G.SX, G.SY + 8) <> Black THEN Result%% = TRUE
  248.  IF POINT(G.SX + 8, G.SY + 8) <> Black THEN Result%% = TRUE
  249.  Collision_Seeker = Result%%
  250.  _SOURCE Layer(6)
  251.  
  252. FUNCTION Collision_Grid%% (who%%, Direction%%)
  253.  Result%% = TRUE 'always assume collision
  254.  SELECT CASE who%% 'who are we checking collision for?
  255.   CASE Gapper
  256.    SELECT CASE Direction%%
  257.     CASE UP 'see if there is grid up from Gappers position
  258.      Check~& = POINT(G.GX + 8, G.GY + 5)
  259.     CASE DOWN 'see if there is Grid below Gapper
  260.      Check~& = POINT(G.GX + 8, G.GY + 9)
  261.     CASE LEFT 'check for grid to the left of Gapper
  262.      Check~& = POINT(G.GX + 6, G.GY + 7)
  263.     CASE RIGHT 'Check for grid to the Right of Gapper
  264.      Check~& = POINT(G.GX + 10, G.GY + 7)
  265.    END SELECT
  266.   CASE Seeker
  267.    SELECT CASE Direction%%
  268.     CASE UP 'see if there is grid up from Gappers position
  269.      Check~& = POINT(G.SX + 8, G.SY + 5)
  270.     CASE DOWN 'see if there is Grid below Gapper
  271.      Check~& = POINT(G.SX + 8, G.SY + 9)
  272.     CASE LEFT 'check for grid to the left of Gapper
  273.      Check~& = POINT(G.SX + 6, G.SY + 7)
  274.     CASE RIGHT 'Check for grid to the Right of Gapper
  275.      Check~& = POINT(G.SX + 10, G.SY + 7)
  276.    END SELECT
  277.  Blue~%% = _BLUE32(Check~&) 'check for Blue, grid is Cyan in color
  278.  IF Blue~%% THEN Result%% = FALSE 'there is grid to move onto, no collision with edge of grid
  279.  Collision_Grid = Result%%
  280.  '_SOURCE Layer(0)
  281.  
  282. SUB Move_Seeker
  283.  IF G.Start THEN
  284.   Seeker_Logic
  285.   SELECT CASE G.SD
  286.    CASE UP
  287.     IF NOT Collision_Grid(Seeker, UP) THEN G.SY = G.SY - 2
  288.    CASE DOWN
  289.     IF NOT Collision_Grid(Seeker, DOWN) THEN G.SY = G.SY + 2
  290.    CASE LEFT
  291.     IF NOT Collision_Grid(Seeker, LEFT) THEN G.SX = G.SX - 2
  292.    CASE RIGHT
  293.     IF NOT Collision_Grid(Seeker, RIGHT) THEN G.SX = G.SX + 2
  294.  IF Collision_Seeker THEN G.Caught = TRUE
  295.  
  296. SUB Move_Gapper
  297.  SELECT CASE G.GD
  298.   CASE UP
  299.    IF NOT Collision_Grid(Gapper, UP) THEN G.GY = G.GY - 2
  300.   CASE DOWN
  301.    IF NOT Collision_Grid(Gapper, DOWN) THEN G.GY = G.GY + 2
  302.   CASE LEFT
  303.    IF NOT Collision_Grid(Gapper, LEFT) THEN G.GX = G.GX - 2
  304.   CASE RIGHT
  305.    IF NOT Collision_Grid(Gapper, RIGHT) THEN G.GX = G.GX + 2
  306.  Color_Line
  307.  
  308. SUB Seeker_Logic
  309.  DistX% = (G.SX - G.GX) 'find X distance between seeker and gapper
  310.  DistY% = (G.SY - G.GY) 'find Y distance between Seeker and Gapper
  311.  IF ABS(DistX%) > ABS(DistY%) THEN 'if player is farther on the X then
  312.   IF DistX% < 0 THEN
  313.    Turn_Seeker RIGHT 'try going right to get closer
  314.   ELSE
  315.    Turn_Seeker LEFT 'try going left to get closer
  316.   END IF
  317.  ELSE 'player is farther on the Y then
  318.   IF DistY% < 0 THEN
  319.    Turn_Seeker DOWN 'try going down to get closer
  320.   ELSE
  321.    Turn_Seeker UP 'try going up to get closer
  322.   END IF
  323.  
  324. SUB Turn_Seeker (Direction%%)
  325.  SELECT CASE Direction%%
  326.   CASE UP
  327.    IF NOT Collision_Grid(Seeker, UP) THEN G.SD = UP
  328.   CASE DOWN
  329.    IF NOT Collision_Grid(Seeker, DOWN) THEN G.SD = DOWN
  330.   CASE LEFT
  331.    IF NOT Collision_Grid(Seeker, LEFT) THEN G.SD = LEFT
  332.   CASE RIGHT
  333.    IF NOT Collision_Grid(Seeker, RIGHT) THEN G.SD = RIGHT
  334.  
  335. SUB Color_Line
  336.  _DEST Layer(2)
  337.  LINE (4 + G.GX \ 2, 3 + G.GY \ 2)-STEP(0, 0), Magenta, BF
  338.  _DEST Layer(0)
  339.  
  340. SUB FPS
  341.  G.FPS = Frames%
  342.  Frames% = 0
  343.  
  344. SUB Title_Startup
  345.  Load_Scores
  346.  _DEST Layer(8)
  347.  LINE (84, 0)-STEP(151, 8), Brown, BF
  348.  LINE (132, 0)-STEP(52, 8), Cyan, BF
  349.  COLOR Brown
  350.  _PRINTSTRING (135, 1), "GAPPER"
  351.  LINE (0, 140)-STEP(639, 8), Brown, BF
  352.  COLOR Black
  353.  _PRINTSTRING (0, 141), "Score:"
  354.  _PRINTSTRING (220, 141), "Level:"
  355.  _PRINTSTRING (100 - (LEN(LTRIM$(STR$(G.Score))) * 8), 141), STR$(G.Score) + "."
  356.  _PRINTSTRING (284 - (LEN(LTRIM$(STR$(G.Level))) * 8), 141), STR$(G.Level)
  357.  
  358.  COLOR Yellow
  359.  _PRINTSTRING (100, 160), "P: Play a game."
  360.  _PRINTSTRING (100, 170), "Q: Quit"
  361.  _PRINTSTRING (100, 180), "N: New Player"
  362.  _PRINTSTRING (100, 190), "I: Instuctions"
  363.  
  364.  Get_Player
  365.  IF Search_For_Player THEN AddPlayer 'first time this player has played!
  366.  Display_HighScores
  367.  Get_Menu_Selection
  368.  
  369. SUB Get_Player
  370.  Blink%% = TRUE: I$ = ""
  371.  _DEST Layer(8)
  372.  COLOR Magenta
  373.  LINE (0, 210)-STEP(219, 9), Black, BF
  374.  _PRINTSTRING (0, 210), "Enter your initials:"
  375.  COLOR OffWhite
  376.  DO 'Initials input Loop
  377.   KBD& = _KEYHIT
  378.   SELECT CASE KBD&
  379.    CASE 8 'delete
  380.     IF LEN(I$) THEN I$ = LEFT$(I$, LEN(I$) - 1)
  381.     LINE (168, 210)-(248, 219), Black, BF
  382.    CASE 32 TO 122 'characters
  383.     IF LEN(I$) < 3 THEN I$ = I$ + CHR$(KBD&)
  384.     LINE (168, 210)-(248, 219), Black, BF
  385.    CASE 13 'accept input(if any)
  386.     IF RTRIM$(I$) <> "" THEN ExitFlag%% = TRUE ELSE BEEP
  387.    CASE 27
  388.     ExitFlag%% = TRUE
  389.     G.Quit = TRUE
  390.   COLOR OffWhite
  391.   _PRINTSTRING (168, 210), I$
  392.   IF Blink%% THEN COLOR Black ELSE COLOR OffWhite
  393.   _PRINTSTRING (168 + LEN(I$) * 8, 210), "_"
  394.   _PUTIMAGE , Layer(8), _DISPLAY
  395.   _LIMIT 30
  396.   t%% = t%% + 1
  397.   IF t%% = 4 THEN Blink%% = NOT Blink%%: t%% = 0
  398.  LOOP UNTIL ExitFlag%%
  399.  G.Player = I$
  400.  
  401. SUB Get_Menu_Selection
  402.  LINE (0, 210)-STEP(200, 9), Black, BF
  403.  _PRINTSTRING (0, 210), "Please enter selection:  "
  404.  DO
  405.   KBD& = _KEYHIT
  406.   SELECT CASE KBD&
  407.    CASE ASC("p") OR ASC("P")
  408.     New_Game
  409.     DrawBoard
  410.     TIMER(T1&) ON
  411.     TIMER(T2&) ON
  412.     Play_game
  413.     TIMER(T1&) OFF
  414.     TIMER(T2&) OFF
  415.  
  416.     CLS
  417.     _KEYCLEAR
  418.    CASE ASC("q") OR ASC("Q")
  419.     ExitFlag%% = TRUE
  420.     G.Quit = TRUE
  421.    CASE ASC("n") OR ASC("N")
  422.     Get_Player
  423.     LINE (0, 210)-STEP(200, 9), Black, BF
  424.     _PRINTSTRING (0, 210), "Please enter selection:  "
  425.    CASE ASC("i") OR ASC("I")
  426.     Instructions
  427.    CASE 27
  428.     'ExitFlag%% = TRUE
  429.     'G.Quit = TRUE
  430.   _PUTIMAGE , Layer(8), _DISPLAY
  431.  LOOP UNTIL ExitFlag%%
  432.  
  433. SUB Display_HighScores
  434.  _DEST Layer(8)
  435.  IF LTRIM$(RTRIM$(Scores(1).Nam)) <> "" THEN
  436.   COLOR Magenta
  437.   _PRINTSTRING (0, 24), "High scores:"
  438.   FOR i%% = 1 TO 10
  439.    IF G.Player = Scores(i%%).Nam THEN
  440.     COLOR Yellow 'player shows up Yellow
  441.    ELSEIF i%% = 1 THEN
  442.     COLOR Magenta 'High score if not player shows magenta
  443.    ELSE
  444.     COLOR OffWhite 'everybody else is off white
  445.    END IF
  446.   NEXT i%%
  447.  
  448. SUB Instructions
  449.  ClearLayer Layer(0)
  450.  _DEST Layer(9)
  451.  LINE (84, 0)-STEP(151, 8), Brown, BF
  452.  LINE (132, 0)-STEP(52, 8), Cyan, BF
  453.  COLOR Brown
  454.  _PRINTSTRING (135, 1), "GAPPER"
  455.  COLOR OffWhite
  456.  _PRINTSTRING (84, 10), "OBJECT"
  457.  _PRINTSTRING (1, 20), "To color all the blue lines"
  458.  _PRINTSTRING (1, 30), "red by moving your man GAPPER"
  459.  _PRINTSTRING (1, 40), "with the arrow keys.  At the"
  460.  _PRINTSTRING (1, 50), "same time, you myst avoid"
  461.  _PRINTSTRING (1, 60), "the SEEKER."
  462.  
  463.  _PRINTSTRING (84, 80), "POINTS"
  464.  _PRINTSTRING (1, 90), "Fifty points are awarded for"
  465.  _PRINTSTRING (1, 100), "each square that you surround"
  466.  _PRINTSTRING (1, 110), "in red.  100 points are given"
  467.  _PRINTSTRING (1, 120), "when you encircle the extra"
  468.  _PRINTSTRING (1, 130), "point box while it is on. Each"
  469.  _PRINTSTRING (1, 140), "gap costs 5 points."
  470.  
  471.  _PRINTSTRING (84, 150), "GAPPING"
  472.  _PRINTSTRING (1, 160), "You can create a temporary"
  473.  _PRINTSTRING (1, 170), "gap in the lines by pressing"
  474.  _PRINTSTRING (1, 180), "the SPACE bar or RETURN.  The"
  475.  _PRINTSTRING (1, 190), "word ON appears as long as the"
  476.  _PRINTSTRING (1, 200), "gap is active.  Neither you nor"
  477.  _PRINTSTRING (1, 210), "the seeker can cross the gap."
  478.  
  479.  _PRINTSTRING (0, 230), "Press a key..."
  480.  _PUTIMAGE , Layer(9), _DISPLAY
  481.  _DELAY .5
  482.  'end of page 1
  483.  DO: _LIMIT 24: LOOP WHILE INKEY$ = ""
  484.  CLS
  485.  LINE (84, 0)-STEP(151, 8), Brown, BF
  486.  LINE (132, 0)-STEP(52, 8), Cyan, BF
  487.  COLOR Brown
  488.  _PRINTSTRING (135, 1), "GAPPER"
  489.  COLOR OffWhite
  490.  _PRINTSTRING (84, 10), "LEVELS"
  491.  _PRINTSTRING (1, 20), "The level increases each time"
  492.  _PRINTSTRING (1, 30), "you complete a screen.  The"
  493.  _PRINTSTRING (1, 40), "seeker gets faster, the gap"
  494.  _PRINTSTRING (1, 50), "time shorter and there will"
  495.  _PRINTSTRING (1, 60), "be more boxes."
  496.  
  497.  _PRINTSTRING (84, 80), "LIVES"
  498.  _PRINTSTRING (1, 90), "You start out with 2 extra"
  499.  _PRINTSTRING (1, 100), "men.  One more will be given"
  500.  _PRINTSTRING (1, 110), "for each 5000 points."
  501.  
  502.  _PRINTSTRING (84, 130), "START"
  503.  _PRINTSTRING (1, 140), "When the grid appears, you"
  504.  _PRINTSTRING (1, 150), "Will be in the top left and"
  505.  _PRINTSTRING (1, 160), "the seeker at the low right."
  506.  _PRINTSTRING (1, 170), "Press a key to begin each new"
  507.  _PRINTSTRING (1, 180), "screen."
  508.  
  509.  _PRINTSTRING (0, 230), "Press a key..."
  510.  'end of page 2
  511.  _PUTIMAGE , Layer(9), _DISPLAY
  512.  _DELAY .5
  513.  DO: _LIMIT 24: LOOP WHILE INKEY$ = ""
  514.  ClearLayer Layer(0)
  515.  
  516. SUB Load_Scores
  517.  OPEN "Gapper.HSL" FOR BINARY AS #1
  518.  GET #1, , Count%%
  519.  FOR i%% = 1 TO Count%%
  520.   GET #1, , Scores(i%%).Nam
  521.   GET #1, , Scores(i%%)
  522.   GET #1, , Scores(i%%)
  523.  NEXT i%%
  524.  CLOSE #1
  525.  
  526. FUNCTION Search_For_Player
  527.  FOR i%% = 1 TO 10
  528.   IF G.Player = Scores(i%%).Nam THEN Result%% = TRUE: i%% = 11 ELSE Result%% = FALSE
  529.  NEXT i%%
  530.  Search_For_Player = Result%%
  531.  
  532. SUB AddPlayer
  533.  OPEN "Gapper.HSL" FOR BINARY AS #1
  534.  GET #1, , Count%%
  535.  IF Count%% < 10 THEN Count%% = Count%% + 1
  536.  PUT #1, 1, Count%%
  537.  PUT #1, 1 + 10 * Count%%, G.Player
  538.  PUT #1, , NULL& 'filler for score
  539.  PUT #1, , NULL% 'filler for level
  540.  CLOSE #1
  541.  Load_Scores 'reload score list
  542.  
  543. SUB Reset_Pos
  544.  PLAY "o1l32aacceegg"
  545.  _DELAY .25
  546.  G.Start = FALSE
  547.  G.Caught = FALSE
  548.  G.Finished = 0
  549.  ClearLayerTrans Layer(2)
  550.  FOR i%% = 0 TO 72
  551.   FinishedBox(i%%) = FALSE
  552.  NEXT i%%
  553.  
  554.  
  555.  
  556. FUNCTION BoxSurrounded%% (boxNumber AS INTEGER) 'save already tested boxes in shared array BoxesSurrounded()
  557.  'Bplus contributed code. 11\12\2021
  558.  'some variables changed to use existing, `**` comments are added
  559.  _SOURCE Layer(2)
  560.  IF FinishedBox(boxNumber) = 0 THEN '**Is the box completed already?
  561.   row = INT((boxNumber - 1) / G.Columns) '[cellsPerCpl)] '**which row
  562.   col = (boxNumber - 1) MOD G.Columns + 1 '[cellsAcross + 1] '**which column
  563.  
  564.   Good%% = TRUE
  565.   FOR I% = row * G.CellHeight TO (row + 1) * G.CellHeight STEP 4 '**No need to check every pixel
  566.    IF POINT(G.Offx + (col - 1) * G.CellWidth, G.Offy + I%) <> Magenta THEN I% = 9999: Good%% = FALSE ' False Baox not surrounded
  567.    IF POINT(G.Offx + col * G.CellWidth, G.Offy + I%) <> Magenta THEN I% = 9999: Good%% = FALSE
  568.   NEXT I%
  569.  
  570.   IF Good%% THEN '**only check other lines if it hasn't failed yet
  571.    FOR I% = (col - 1) * G.CellWidth TO col * G.CellWidth STEP 4 '**No need to check every pixel
  572.     IF POINT(G.Offx + I%, G.Offy + row * G.CellHeight) <> Magenta THEN I% = 9999: Good%% = FALSE ' False Baox not surrounded
  573.     IF POINT(G.Offx + I%, G.Offy + (row + 1) * G.CellHeight) <> Magenta THEN I% = 9999: Good%% = FALSE
  574.    NEXT I%
  575.   END IF
  576.   IF Good%% THEN BoxSurrounded = -1: G.Finished = G.Finished + 1: G.Score = G.Score + 50: PLAY "o3l54eeggee": Check_Score 'all OK
  577.   BoxSurrounded = -1
  578.  _SOURCE Layer(6)
  579.  
  580. SUB FillBox (boxNumber)
  581.  ' _DELAY .25
  582.  _DEST Layer(2)
  583.  row = INT((boxNumber - 1) / G.Columns)
  584.  col = (boxNumber - 1) MOD G.Columns + 1
  585.  LINE (G.Offx + (col - 1) * G.CellWidth + 3, G.Offy + row * G.CellHeight + 3)-STEP(G.CellWidth - 6, G.CellHeight - 6), OffWhite, BF
  586.  COLOR Black
  587.  _PRINTSTRING (G.Offx + (col - 1) * G.CellWidth + 3 + (INT(G.CellWidth \ 2) - 8), G.Offy + row * G.CellHeight + 3 + (INT(G.CellHeight \ 2) - 8)), "50", Layer(2)
  588.  COLOR OffWhite
  589.  _DEST Layer(0)
  590.  
  591. SUB Change_Level
  592.  G.Level = G.Level + 1
  593.  speed! = (.05 - (G.Level / 1000) * 5)
  594.  IF speed! <= .015 THEN speed! = .015
  595.  ON TIMER(T2, speed!) Move_Seeker
  596.  ClearLayerTrans Layer(2)
  597.  ClearLayer Layer(5)
  598.  ClearLayer Layer(6)
  599.  DrawBoard
  600.  G.Finished = 0
  601.  FOR i%% = 0 TO 72
  602.   FinishedBox(i%%) = FALSE
  603.  NEXT i%%
  604.  
  605. SUB Master_Level (Level)
  606.  G.Start = FALSE
  607.  RESTORE Level_data
  608.  FOR i%% = 1 TO Level 'load level data
  609.   READ G.CellWidth, G.CellHeight, G.Rows, G.Columns, G.Offx, G.Offy, G.Needed, G.GX, G.GY, G.SX, G.SY
  610.  NEXT i%%
  611.  SELECT CASE Level 'create levels
  612.   CASE 1 TO 4, 8
  613.    FOR i%% = 0 TO G.Rows
  614.     LINE (G.Offx, G.Offy + i%% * G.CellHeight)-STEP(G.CellWidth * G.Columns, 0), Cyan 'horizontal lines
  615.    NEXT i%%
  616.    FOR i%% = 0 TO G.Columns
  617.     LINE (G.Offx + i%% * G.CellWidth, G.Offy)-STEP(0, G.CellHeight * G.Rows), Cyan 'vertical lines
  618.    NEXT i%%
  619.   CASE 5 ' "Â" shaped level
  620.    FOR i%% = 0 TO 4
  621.     LINE (16, 16 + i%% * 24)-STEP(288, 0), Cyan 'horizontal lines
  622.     LINE (88 + i%% * 36, 16)-STEP(0, 168), Cyan 'vertical lines
  623.    NEXT i%%
  624.    FOR i%% = 0 TO 2
  625.     LINE (88, 136 + i%% * 24)-STEP(144, 0), Cyan 'horizontal lines
  626.     LINE (16 + i%% * 36, 16)-STEP(0, 96), Cyan 'vertical lines
  627.     LINE (268 + i%% * 36, 16)-STEP(0, 96), Cyan 'vertical lines
  628.    NEXT i%%
  629.   CASE 6 ' "Å" shaped level
  630.    FOR i%% = 0 TO 3
  631.     LINE (16, 64 + i%% * 24)-STEP(288, 0), Cyan 'horizontal lines
  632.     LINE (88 + i%% * 36, 16)-STEP(0, 168), Cyan 'vertical lines
  633.    NEXT i%%
  634.    LINE (88 + i%% * 36, 16)-STEP(0, 168), Cyan 'vertical lines
  635.  
  636.    FOR i%% = 0 TO 1
  637.     LINE (88, 16 + i%% * 24)-STEP(144, 0), Cyan 'horizontal lines
  638.     LINE (88, 160 + i%% * 24)-STEP(144, 0), Cyan 'horizontal lines
  639.     LINE (16 + i%% * 36, 64)-STEP(0, 72), Cyan 'vertical lines
  640.     LINE (268 + i%% * 36, 64)-STEP(0, 72), Cyan 'vertical lines
  641.    NEXT i%%
  642.   CASE 7 ' "Á" shaped level
  643.    FOR i%% = 0 TO 4
  644.     LINE (16, 88 + i%% * 24)-STEP(288, 0), Cyan 'horizontal lines
  645.     LINE (88 + i%% * 36, 16)-STEP(0, 168), Cyan 'vertical lines
  646.    NEXT i%%
  647.    FOR i%% = 0 TO 1
  648.     LINE (88, 16 + i%% * 24)-STEP(144, 0), Cyan 'horizontal lines
  649.     LINE (16 + i%% * 36, 88)-STEP(0, 96), Cyan 'vertical lines
  650.     LINE (268 + i%% * 36, 88)-STEP(0, 96), Cyan 'vertical lines
  651.    NEXT i%%
  652.    LINE (88, 16 + i%% * 24)-STEP(144, 0), Cyan 'horizontal lines
  653.  
  654. SUB Check_Score
  655.  STATIC Current_life AS _BYTE
  656.  IF G.Score = 0 THEN Current_life = 0 'reset on new game
  657.  IF INT(G.Score \ 5000) = Current_life + 1 THEN 'Bonus Life, only worry about the thousands place to
  658.   '                                                            avoid issues with non-5000 exact multiples
  659.   Current_life = Current_life + 1
  660.   G.Lives = G.Lives + 1
  661.   TIMER(T2) OFF
  662.   _DELAY .05
  663.   PLAY "o6l32GFED#"
  664.   TIMER(T2) ON
  665.  
  666. SUB Create_Gap
  667.  STATIC X%, Y%, D%
  668.  IF G.Gapped THEN 'when a new gap is made get the pos. this sub is called to erase too
  669.   X% = G.GX + 8 'Xpos of gapper center
  670.   Y% = G.GY + 7 'Ypos of gapper center
  671.   D% = G.GD 'direction of gap(up\down or left\right)
  672.   G.Gap_time = TIMER
  673.   CASE UP, DOWN
  674.    _DEST Layer(6) 'draw the gap to the detection layer
  675.    IF G.Gapped THEN LINE (X%, Y% - 1)-STEP(0, 2), Black ELSE LINE (X%, Y% - 1)-STEP(0, 2), Cyan 'erase or restore
  676.    _DEST Layer(2) 'also display gap on visual layer (can only gap where you've been so restore to Magenta)
  677.    'layer 2 is 320x220 so we must half the x,y points
  678.    IF G.Gapped THEN LINE (.5 * X%, .5 * Y% - 3)-STEP(0, 5), Black ELSE LINE (.5 * X%, .5 * Y% - 3)-STEP(0, 5), Magenta 'erase or restore
  679.   CASE LEFT, RIGHT
  680.    _DEST Layer(6) 'draw the gap to the detection layer
  681.    IF G.Gapped THEN LINE (X% - 1, Y% - 1)-STEP(2, 1), Black, BF ELSE LINE (X% - 1, Y% - 1)-STEP(2, 1), Cyan, BF 'erase or restore
  682.    _DEST Layer(2) 'also display gap on visual layer (can only gap where you've been so restore to Magenta)
  683.    'layer 2 is 320x220 so we must half the x,y points
  684.    IF G.Gapped THEN LINE (.5 * X% - 3, .5 * Y% - 1)-STEP(5, 1), Black, BF ELSE LINE (.5 * X% - 3, .5 * Y% - 1)-STEP(5, 1), Magenta, BF 'erase or restore
  685.  ' _DEST Layer(0)
  686.  ' CLS
  687.  ' _PUTIMAGE , Layer(2), Layer(0)
  688.  ' G.GY = G.GY + 16
  689.  ' _PUTIMAGE (G.GX, G.GY), Layer(3), Layer(0), (318, 218)-STEP(15, 13)
  690.  ' END
  691.  
  692. SUB Time_Gap
  693.  IF G.Level <= 20 THEN Max_Time! = 500 - (G.Level * 20) ELSE Max_Time! = 100
  694.  Max_Time! = Max_Time! / 100 'convert to seconds (5 sec to 1 sec)
  695.  
  696.  IF G.Gap_time + Max_Time! <= TIMER THEN 'gap time up
  697.   G.Gapped = FALSE
  698.   Create_Gap 'call the SUB again to fill in gap
  699.  
  700. SUB New_Game
  701.  G.Score = 0
  702.  G.Lives = 2
  703.  FOR i%% = 0 TO 72
  704.   FinishedBox(i%%) = FALSE
  705.  NEXT i%%
  706.  ClearLayerTrans Layer(2)
  707.  Check_Score 'reset extra lives counter
  708.  

Pages: [1] 2 3 ... 8