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.


Messages - Cobalt

Pages: 1 2 [3] 4 5 ... 59
31
QB64 Discussion / Re: A useful audio resource site
« on: January 25, 2022, 05:25:19 pm »
We can't-- at least not dependably.  Download a batch of wav files for your project.  How many of them work?  How many won't work?  There's no way to know without attempting to load and manually test each one, and who wants to do that??

Guess I'm just too picky on where I get my wav files.

Though now that I think about it, this isn't the first time someone has found audio files that wouldn't load.

this nice quote might help explain the problem some:
Quote
A Bastardized Standard
The WAVE format is sort of a bastardized standard that was concocted by too many "cooks" who didn't properly coordinate the addition of "ingredients" to the "soup". Unlike with the AIFF standard which was mostly designed by a small, coordinated group, the WAVE format has had all manner of much-too-independent, uncoordinated aberrations inflicted upon it. The net result is that there are far too many chunks that may be found in a WAVE file -- many of them duplicating the same information found in other chunks (but in an unnecessarily different way) simply because there have been too many programmers who took too many liberties with unilaterally adding their own additions to the WAVE format without properly coming to a concensus of what everyone else needed (and therefore it encouraged an "every man for himself" attitude toward adding things to this "standard"). One example is the Instrument chunk versus the Sampler chunk. Another example is the Note versus Label chunks in an Associated Data List. I don't even want to get into the totally irresponsible proliferation of compressed formats. (ie, It seems like everyone and his pet Dachshound has come up with some compressed version of storing wave data -- like we need 100 different ways to do that). Furthermore, there are lots of inconsistencies, for example how 8-bit data is unsigned, but 16-bit data is signed.

also from the same paper:

Quote
I've attempted to document only those aspects that you're very likely to encounter in a WAVE file. I suggest that you concentrate upon these and refuse to support the work of programmers who feel the need to deviate from a standard with inconsistent, proprietary, self-serving, unnecessary extensions. Please do your part to rein in half-assed programming.

32
QB64 Discussion / Re: A useful audio resource site
« on: January 25, 2022, 05:04:18 pm »
But who is kicking out all the .wav files with crazy formats, must be an advantage to .wav file creators to have new probably more flexible formats.
seems to be a very old encoding developed in the early 70s for use in phone calls. Why somebody would still use it in the past 20 years I don't even want to wonder, or Steve's audio resources are as old as he is?! 😜

All you have to do is try the sounds in the package and you'll see we can't make use of them.  QB64 fails to load and decode them properly.
The way you put it sounded more like we can't open WAV files at all.

33
QB64 Discussion / Re: A useful audio resource site
« on: January 25, 2022, 12:37:27 pm »
I think the most glaring difference is the Format Type value, which in the original O.wav file is 7 (???) and not a 1(PCM).

So what ever format 7 is the codec used by QB64 cannot decode it.

if you change it to a 1 the file loads and plays in a distorted way.

note: A Format Type 7 seems to be some kind of 4bit ADPCM encoded.

34
QB64 Discussion / Re: A useful audio resource site
« on: January 25, 2022, 12:19:52 pm »
Are there different formats for .WAV?

apparently there is. Looking at the HEX layout of the O.wav file and the HEX layout of the same file exported from Audacity they are completely different.

  [ You are not allowed to view this attachment ]  

35
QB64 Discussion / Re: A useful audio resource site
« on: January 25, 2022, 10:55:49 am »
but with QB64 -- and that's with the fact that these are WAV files which we *should* be able to work with, but we can't. 


What do you mean by, "..but we can't."?

36
QB64 Discussion / Re: A lesson on how to break QB64
« on: January 24, 2022, 07:15:11 pm »
You must be using Wincraps 10 or above, Vista gives no such problems with the QB64 IDE.
Granted it cant save, just gives the error "Cannot Save file", but I can Save As with no issues
It compiles and runs just fine, and when I try to load a file still tries to load from Foo which is funny cause its not there anymore!

But the IDE seems to run just fine. tried this with 1.5 and 2.0.2

37
QB64 Discussion / Re: Double Check on order of operations
« on: January 22, 2022, 03:08:02 pm »
I think it's the same between two + and/or - operators, left to right = right to left.

eg /2 is same as *.5

what made me question was I did this;

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

and received a Division by Zero error. which seems to suggest that * goes before \(/) in QB64

38
QB64 Discussion / Re: Select Case
« on: January 22, 2022, 02:46:25 pm »
The way you have described what you're trying to accomplish SELECT CASE isn't going to work for you.

You will need to use an IF THEN nest.

39
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...

40
QB64 Discussion / Re: Shell Copy (small bug ?)
« on: January 21, 2022, 09:58:16 pm »
P.S. I don't know the meaning of the idiomatic phrase at the head of Cobalt's post (in my language there is no such saying), but I assume that perhaps it is better not to know it.

It means people need to chill out and lighten up. Referring to the people complaining about your attachments when there is no need to.

41
QB64 Discussion / Re: Shell Copy (small bug ?)
« on: January 21, 2022, 05:33:36 pm »
Dang, some people need to un-bunch their panties.


Well! In this case I was not asking for a solution, I was pointing out a fact.
And "stupidly" I thought it could be useful to someone.

About the solution was intuitive. Yes, but only after understanding that "+" disturbs the interpreter. Normally why should I worry about the folder name affecting the result of the routine?

Anyway thanks for your attention.

Perhaps a better title to the Topic would be "Shell Copy: something worth noting."?
Share code however you like.
At one time I was putting over 150k characters into the code box before Fellippe ask me not to, because it was bogging the site down. 😜

42
QB64 Discussion / Re: Multiple Panels
« on: January 19, 2022, 11:06:46 am »
Perhaps find an old game called EGA TREK for inspiration on the "panel" layout.

43
QB64 Discussion / Re: Trying to load an Atari disk image into memory
« on: January 19, 2022, 10:54:48 am »
Just what do you have myarray() DIMed as anyhow?
why not just GET #1,, myarray()?
If you know the file size anyway?(and even if you don't you still could)

Code: QB64: [Select]
  1. DIM myarray(92176) AS STRING '(or myarray as string *92176, or myarray(lof(1)) as string [after the OPEN] or even myarray(lof(1)) as _UNSIGNED _BYTE)
  2. OPEN "KWEST01B.XFD" FOR BINARY AS #1
  3. GET #1, , myarray()
  4.  

PS, just out of curiosity, do you realize just how big "myarray(1 To 92176) As String * 92176" that array is? 8,496,414,976 bytes!!!
do you really need 8gigs+ to load it?

44
Programs / Re: WIP: game input mapping for gamepad, keyboard, v0.90
« on: January 06, 2022, 10:12:58 pm »
  • The mapping part lets you map keys from the keyboard but for some reason the test routine that lets you move objects around the screen isn't reading the keyboard input.
  • Digital joysticks don't allow continuous movement.

If you don't get these figured out soon, perhaps take a look at my Zelda clone work. Mainly the Get_Input%% FUNCTION and Custom_Controls SUB. They might be of some help figuring out why you currently having trouble. Its got a few comments but feel free to ask if you still have trouble.

it would also be interesting to see how my setup works with a joypad that gives analog axis Values.

I recommend customizing the controls before you try actually playing the game, default START BUTTON is A(upper case) SELECT BUTTON is B(upper case)
the Options menu sliders are mouse controlled. And the custom controls menu is used with mouse too.

This is the last update of this version of my Zelda clone, as I messed the data structure up and cant get certain effects and extras to work. Also at some point I broke the ability to shoot the sword,(you still can but it throws some errors you have to OK though).
But you can watch the title sequence, explore the world, enter some caves, and collect the wood sword

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.  Control_Pad AS _BYTE 'which Gamepad\Joystick Device Is player Using?
  13.  BAD_Pad AS _BYTE 'option for Buttons As Directions
  14.  Joy_Up AS _BYTE 'axis for up
  15.  Joy_Up_Val AS _BYTE 'axis value for up
  16.  Joy_Down AS _BYTE 'axis for down
  17.  Joy_Down_Val AS _BYTE 'axis value for down
  18.  Joy_Left AS _BYTE 'axis for left
  19.  Joy_Left_Val AS _BYTE 'axis value for left
  20.  Joy_Right AS _BYTE 'axis for right
  21.  Joy_Right_Val AS _BYTE 'axis value for right
  22.  Joy_Select AS _BYTE
  23.  Joy_Start AS _BYTE
  24.  Joy_A_Button AS _BYTE
  25.  Joy_B_Button AS _BYTE
  26.  Joy_Button_Up AS _BYTE 'for people whos controllers give BUTTON states for direction keys
  27.  Joy_Button_Down AS _BYTE 'or just want to use buttons for the direction keys.
  28.  Joy_Button_Left AS _BYTE '""""
  29.  Joy_Button_Right AS _BYTE 'however this fails to work so may not be implemented.
  30.  
  31. TYPE Game_Data
  32.  Impactflag AS _BYTE
  33.  Scale_Factor AS _BYTE
  34.  Scale_X AS _BYTE
  35.  Scale_Y AS _BYTE
  36.  NextScreen AS _BYTE
  37.  Wtime AS _BYTE
  38.  Atime AS _BYTE
  39.  Wframe AS _BYTE
  40.  Aframe AS _BYTE
  41.  Projectile_Count AS _BYTE 'Number of projectiles (including bombs) on screen
  42.  LoadedGame AS _BYTE '  which game is loaded?(1-3)
  43.  MSTR_Vol AS _BYTE '    Master Volume level
  44.  SFX_Vol AS _BYTE '     Sound FX Volume level
  45.  BGM_vol AS _BYTE '     Music Volume level
  46.  ControlType AS _BYTE ' player using Keyboard or Joypad?
  47.  Device_Count AS _BYTE 'Total input Devices aviliable
  48.  ItemCount AS _BYTE '   Number of items on screen
  49.  Collected AS _BYTE '   item link just picked up
  50.  
  51. TYPE Projectile_Data
  52.  Id AS _BYTE '       Kind of projectile; Sword\Arrow\Rock\Ball
  53.  Xloc AS INTEGER '   Projectile location
  54.  Yloc AS INTEGER '
  55.  Direction AS _BYTE 'Direction Projectile is traveling
  56.  Hits AS _BYTE '     Hits per projectile\(AKA:damage) in half heart increments
  57.  Owner AS _BYTE '    Who shot the projectile
  58.  
  59. TYPE Links_Data
  60.  '-----Position data-----
  61.  World AS _BYTE '           Player in Overworld or Underworld
  62.  World_X AS _BYTE '         Overworld X position
  63.  World_Y AS _BYTE '         Overworld Y position
  64.  Tile_X AS _UNSIGNED _BYTE 'Array X location:for Collision\entrances
  65.  Tile_Y AS _BYTE '          Array Y location:for Collision\entrances
  66.  Screen_X AS INTEGER '      X Position on screen
  67.  Screen_Y AS INTEGER '      Y Position on screen
  68.  Direction AS _BYTE '       Direction player is moving\facing
  69.  '-----------------------
  70.  '------Status Data------
  71.  Hearts AS _BYTE '    Units of health: 2 units(halves) per heart
  72.  Containers AS _BYTE 'Max number of health: total full hearts
  73.  Hits AS _BYTE '      Used when Link has defence rings;Blue = 2 hits per 1\2 heart, Red = 4 hits per 1\2 heart
  74.  Max_Bombs AS _BYTE ' how many bombs can Link carry
  75.  '-----------------------
  76.  '------Items Data-------
  77.  Sword AS _BYTE '      Which Sword does player have? Wooden-1,Silver-2,Magical-3
  78.  Weapon AS _BYTE '     Which Weapon is in hand A? Wooden-1,Silver-2,Magical-3,Wand-4
  79.  Ring AS _BYTE '       Which does player have? 0-none, 1-blue,2-red
  80.  Has_Bow AS _BYTE
  81.  Has_Wand AS _BYTE
  82.  Has_Bait AS _BYTE
  83.  Has_Arrow AS _BYTE
  84.  Has_Boomerang AS _BYTE
  85.  Has_Bombs AS _BYTE
  86.  Has_Bracelet AS _BYTE
  87.  Has_Book AS _BYTE
  88.  Has_MagicKey AS _BYTE
  89.  Has_Candle AS _BYTE ' 1-Blue, 2-Red
  90.  Has_Letter AS _BYTE ' 1-letter, 2-Blue Potion, 3-Red Potion
  91.  Has_Ladder AS _BYTE
  92.  Has_Raft AS _BYTE
  93.  Has_Ring AS _BYTE '   1-Blue, 2-Red
  94.  Has_Shield AS _BYTE ' Player has Magic Shield
  95.  Keys AS _BYTE '
  96.  Ruby AS _UNSIGNED _BYTE '
  97.  TriForce AS _BYTE '   each bit represents a collected piece
  98.  Has_Map AS INTEGER '  each bit represents a dungeon map
  99.  Has_Compass AS INTEGER ' each bit represents a dungeon compass
  100.  '-----------------------
  101.  '------Extra Data-------
  102.  Action AS _BYTE '          is player; using an item, Aquiring an item\sword, or aquiring a piece of the triforce?
  103.  Shot AS _BYTE '            player has shot sword
  104.  Projectile_id AS _BYTE '
  105.  Played AS _UNSIGNED _BYTE 'how many times has player played?
  106.  Beaten AS _BYTE '          Has player beaten Game 1? Game 2?
  107.  Shown_Letter AS _BYTE '    Has player shown Old woman the letter?
  108.  '-----------------------
  109.  
  110. TYPE Map_Data
  111.  Id AS _UNSIGNED _BYTE '      Tile id
  112.  Id2 AS _UNSIGNED _BYTE '     if hidden what is under top tile
  113.  Hidden AS _BYTE '            is there something under the tile?
  114.  Burnable AS _BYTE '          can the tile be burnt with candle?
  115.  Pushable AS _BYTE '          can the tile be moved by pushing?
  116.  Bombable AS _BYTE '          can the tile be blown up with bomb?
  117.  PushableXtra AS _BYTE '      can the tile be moved by pushing with braclet?
  118.  Is_Shop AS _BYTE '           is there a shop here?(shop\gift\gamble)
  119.  Is_Secret AS _BYTE '         secrets under bushes dont walk in, just jump in.
  120.  Is_Dungeon AS _BYTE '        is this a dungeon entrace? contains which one
  121.  Walkable AS _BYTE '          can the tile be walk upon?
  122.  Can_Awaken AS _BYTE '        touching the tile awakens the monster (graves and statues)
  123.  Is_Open AS _BYTE '           the player has blown up\burnt\pushed the tile out of the way
  124.  Linked_X AS _UNSIGNED _BYTE 'acts upon a different tile
  125.  Linked_Y AS _BYTE
  126.  Candle_Used AS _BYTE '       the player used the candle
  127.  Movement_Special AS _BYTE '  can the player move freely?
  128.  
  129.  Mob_List AS _UNSIGNED _BYTE 'Which Monsters appear on map segment
  130.  
  131. TYPE KeyCodeData
  132.  Nam AS STRING * 8
  133.  Value AS LONG
  134.  
  135. TYPE DEVICE_Info
  136.  Buttons AS INTEGER
  137.  Axis_p AS _BYTE
  138.  
  139. TYPE Drop_Data
  140.  ID AS _BYTE '         What is it?
  141.  Xloc AS INTEGER '     X location of the item\collision box
  142.  Yloc AS INTEGER '     Y location of the item\collision box
  143.  Xsiz AS _BYTE '       Xsize of the collision box
  144.  Ysiz AS _BYTE '       Ysize of the collision box
  145.  Is_Special AS _BYTE ' Is this a special pickup? pauses game while Link lifts the item
  146.  Death AS INTEGER '     items vanish after 90sec(by game count not timer) except for Special items
  147.  
  148. TYPE Item_Data
  149.  Sprite_X AS INTEGER 'Items sprite sheet location
  150.  Sprite_Y AS INTEGER '
  151.  BoxSize_X AS _BYTE 'Sprites size(8x8,8x16,16x16)
  152.  BoxSize_Y AS _BYTE
  153.  
  154. TYPE Shop_Data
  155.  Item AS _BYTE
  156.  
  157. CONST TRUE = -1, FALSE = NOT TRUE, None = 0
  158. CONST Up = 3, Right = 2, Left = 1, Down = 0, SELECT_BUTTON = 4, START_BUTTON = 5, BUTTON_B = 6, BUTTON_A = 7
  159. CONST OverWorld = 0, UnderWorld = 1
  160. CONST Walking = 1, Useing = 2, GetItem = 3, GetTriforce = 4, Attack = 5
  161. CONST Key_Right = 19712, Key_Left = 19200, Key_Up = 18432, Key_Down = 20480
  162. CONST Key_Space = 32, Key_Enter = 13
  163. CONST Default_Key_Right = 19712, Default_Key_Left = 19200, Default_Key_Up = 18432, Default_Key_Down = 20480
  164. CONST Default_A_Button = 32, Default_B_Button = 13, Default_Start_Button = 65, Default_Select_Button = 66
  165. CONST Sword = 1, Arrow = 2, Rock = 3, Ball = 4, Boomerang = 5
  166. CONST Player = 1, Monster = 2, KeyBoard = -1, JoyPad = 0, GO_IN = 1, GO_OUT = 2
  167. CONST Items = 0, Slash = 1, Stairs = 2, SwordShot = 3
  168.  
  169. DIM SHARED Layer(24) AS LONG, Hyrule(255, 87) AS Map_Data, Link AS Links_Data, Reset_Link AS Links_Data
  170. DIM SHARED C AS ControllerKeys, G AS Game_Data, P(16) AS Projectile_Data, Letter(44) AS STRING * 1
  171. DIM SHARED Offset_X(3) AS INTEGER, Offset_Y(3) AS INTEGER, Cave(15, 10) AS Map_Data
  172. DIM SHARED BGM(8) AS LONG, SFX(10) AS LONG, FFX(1) AS LONG, TFX(8) AS LONG
  173. DIM SHARED Records(3) AS Links_Data, Nick(3) AS STRING * 8 'loading\registering\elimination
  174. DIM SHARED KeyCodes(134) AS KeyCodeData, DeviceData(16) AS DEVICE_Info
  175. DIM SHARED Drop(17) AS Drop_Data, Item(37) AS Item_Data, Shop(17, 3) AS Shop_Data
  176. '-------------Graphical setup------------
  177. SCREEN _NEWIMAGE(800, 600, 32)
  178. Layer(0) = _DISPLAY
  179. Layer(1) = _NEWIMAGE(800, 600, 32) 'temp layer
  180. Layer(2) = _NEWIMAGE(640, 480, 256) 'palettized sprite sheet for color shifting
  181. Layer(3) = _NEWIMAGE(800, 600, 32) 'Map background prebuild layer
  182. Layer(4) = _NEWIMAGE(800, 600, 32) 'Mob layer
  183. Layer(5) = _NEWIMAGE(800, 600, 32) 'Sprite layer, moveable\burnable items + bomb holes + pickups
  184. Layer(6) = _NEWIMAGE(12288, 4224, 32) 'PreBuilt Map, upto 300%, for easier map scrolling.
  185. Layer(8) = _NEWIMAGE(800, 600, 32) 'debug map display
  186. Layer(16) = _NEWIMAGE(800, 600, 32) 'temp
  187. Layer(19) = _NEWIMAGE(800, 600, 32) 'item\creature collision layer
  188. MFI_Loader "Zelda.MFI"
  189. _FONT FFX(0), Layer(1)
  190. _FONT FFX(0), Layer(3)
  191. _FONT FFX(0), Layer(16)
  192. _CLEARCOLOR _RGB32(31), Layer(7)
  193. _CLEARCOLOR _RGB32(116), Layer(12)
  194. _CLEARCOLOR _RGB32(116), Layer(17)
  195. '----------------------------------------
  196. TFX(0) = _FREETIMER
  197. ON TIMER(TFX(0), .016) Flame_Burn_Cave
  198. '==================================
  199. G.Scale_Factor = 2
  200. G.Scale_X = 16 * G.Scale_Factor - 1
  201. G.Scale_Y = 16 * G.Scale_Factor - 1
  202. Link.Screen_X = Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor * 7) + 8 * G.Scale_Factor '392
  203. Link.Screen_Y = Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor * 5) '292
  204. Nick(0) = "": Nick(1) = "": Nick(2) = "": Nick(3) = ""
  205. G.BGM_vol = 66
  206. G.SFX_Vol = 75
  207. G.MSTR_Vol = 100
  208. 'OPEN "debug.txt" FOR OUTPUT AS #6
  209. '==================================
  210.  
  211. Get_JoyPads
  212. G.ControlType = KeyBoard
  213. Title_Screen
  214. Select_Screen
  215.  
  216. Build_Map_Screen 16 * Link.World_X, 11 * Link.World_Y
  217. ClearLayer Layer(6)
  218. Build_Map_in_Totallity 'prebuild the entire map at the current scale factor
  219. ClearLayer Layer(1)
  220. _SOURCE Layer(19)
  221.  IF Link.Action <> GetItem THEN
  222.   SELECT CASE Get_Input
  223.    CASE BUTTON_A
  224.     IF Link.Sword <> FALSE THEN
  225.      IF G.Aframe = 0 AND G.Atime = 0 THEN _SNDPLAY SFX(Slash): Link.Action = Attack: Press = Press + 1
  226.      Check_Link_Sword_Shot
  227.     END IF
  228.    CASE Up
  229.     IF Link.Action <> Attack THEN Link.Direction = Up: Link.Action = Walking
  230.    CASE Down
  231.     IF Link.Action <> Attack THEN Link.Direction = Down: Link.Action = Walking
  232.    CASE Right
  233.     IF Link.Action <> Attack THEN Link.Direction = Right: Link.Action = Walking
  234.    CASE Left
  235.     IF Link.Action <> Attack THEN Link.Direction = Left: Link.Action = Walking
  236.    CASE ELSE
  237.     IF Link.Action = Walking THEN Link.Action = None
  238.  
  239.  IF Link.Action = GetItem OR Link.Action = GetTriforce THEN
  240.   IF NOT _SNDPLAYING(SFX(Items)) THEN Link.Action = None: G.Collected = -1
  241.  IF Link.World = OverWorld AND Hyrule(Link.Tile_X, Link.Tile_Y).Is_Shop THEN Enter_Shop Hyrule(Link.Tile_X, Link.Tile_Y).Is_Shop
  242.  '-------Items code----------
  243.  IF G.ItemCount THEN Age_items 'only run if there are items to age
  244.  IF Link_Object_Collision THEN Pickup_Item G.Collected
  245.  '---------------------------
  246.  '------Graphx build------
  247.  _PUTIMAGE , Layer(3), Layer(1)
  248.  _PUTIMAGE , Layer(5), Layer(1)
  249.  IF Link.Action = Walking THEN Move_Link
  250.  IF Link.Shot THEN Move_Sword_Shot
  251.  IF G.Impactflag THEN Impact 0, 0
  252.  IF G.ItemCount THEN Display_drops
  253.  IF Link.Action = GetItem THEN Display_Lifted_Item
  254.  _PRINTSTRING (0, 570), STR$(Link.Action) + STR$(G.Collected), Layer(1)
  255.  Place_Link
  256.  IF G.Scale_Factor = 1 THEN _PUTIMAGE , Layer(8), Layer(1)
  257.  IF G.Scale_Factor = 1 THEN _DEST Layer(1): LINE (100 + 2 * Link.Tile_X, 0 + 2 * Link.Tile_Y)-STEP(1, 1), _RGB32(255, 255, 0), BF
  258.  _PUTIMAGE , Layer(1), Layer(0)
  259.  ClearLayer Layer(1)
  260.  '------------------------
  261.  IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  262.  _LIMIT 60
  263. LOOP UNTIL ExitFlag%%
  264.  
  265. _PUTIMAGE , Layer(19), Layer(0)
  266. SUB Add_Projectile (What%%, Who%%)
  267.  SELECT CASE What%%
  268.   CASE Sword
  269.    P(G.Projectile_Count).Owner = Who%%
  270.    P(G.Projectile_Count).Id = Sword
  271.    P(G.Projectile_Count).Direction = Link.Direction
  272.    IF Who%% = Player THEN
  273.     P(G.Projectile_Count).Xloc = Link.Screen_X
  274.     P(G.Projectile_Count).Yloc = Link.Screen_Y
  275.    ELSE
  276.    END IF
  277.    G.Projectile_Count = G.Projectile_Count + 1
  278.  
  279. SUB Age_items
  280.  FOR i%% = 0 TO G.ItemCount - 1
  281.   IF Drop(i%%).Death > 0 THEN Drop(i%%).Death = Drop(i%%).Death - 1 'only age normal drops and live drops
  282.   IF Drop(i%%).Death = 0 THEN
  283.    Reduce%% = Reduce%% + 1
  284.    Kill_Item i%%
  285.   END IF
  286.  NEXT i%%
  287.  G.ItemCount = G.ItemCount - Reduce%%
  288.  IF Reduce%% <> 0 THEN Build_Item_Collision_layer 'update the collsion layer if some items have died off
  289.  
  290. SUB Remove_Projectile (What%%, Who%%)
  291.  SELECT CASE What%%
  292.   CASE Sword
  293.    IF Who%% = Player THEN
  294.     G.Projectile_Count = G.Projectile_Count - 1
  295.    END IF
  296.  
  297. SUB Build_Cave_Screen
  298.  FOR Y%% = 0 TO 10
  299.   FOR X%% = 0 TO 15
  300.    Place_Tile_On_Screen (16 * G.Scale_Factor) * X%%, (16 * G.Scale_Factor) * Y%%, Cave(X%%, Y%%).Id, Layer(3)
  301.   NEXT
  302.  
  303. SUB Build_Item_Collision_layer
  304.  _DEST Layer(19)
  305.  LINE (0, 0)-STEP(799, 599), _RGB32(0), BF 'faster than CLS???
  306.  FOR i%% = 0 TO G.ItemCount - 1
  307.   LINE (Drop(i%%).Xloc, Drop(i%%).Yloc)-STEP(Item(Drop(i%%).ID).BoxSize_X * G.Scale_Factor - 1, Item(Drop(i%%).ID).BoxSize_Y * G.Scale_Factor - 1), _RGB32(1 + i%%, 0, 100), BF 'item mask for collision
  308.  NEXT i%%
  309.  _DEST Layer(1)
  310.  
  311. SUB Build_Map_Screen (Map_X~%%, Map_Y%%)
  312.  _DEST Layer(8)
  313.  FOR Y%% = 0 TO 10
  314.   FOR X%% = 0 TO 15
  315.    Place_Tile_On_Screen (16 * G.Scale_Factor) * X%%, (16 * G.Scale_Factor) * Y%%, Hyrule(Map_X~%% + X%%, Map_Y%% + Y%%).Id, Layer(3)
  316.   NEXT
  317.  FOR Y%% = 0 TO 87
  318.   FOR x~%% = 0 TO 255
  319.    IF Hyrule(x~%%, Y%%).Walkable = FALSE THEN LINE (100 + 2 * x~%%, 0 + 2 * Y%%)-STEP(1, 1), _RGB32(255), BF
  320.   NEXT
  321.  _DEST Layer(0)
  322.  
  323. SUB Build_Map_in_Totallity
  324.  FOR Y%% = 0 TO 87
  325.   FOR X~%% = 0 TO 255
  326.    tile~%% = Hyrule(X~%%, Y%%).Id
  327.    Gy% = 17 * (tile~%% \ 20) 'get which row it comes from
  328.    Gx% = 17 * (tile~%% MOD 20) 'which column position
  329.    _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)
  330.   NEXT
  331.  
  332. SUB Check_Link_Location
  333.  Ax% = Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
  334.  Ay% = Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
  335.  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
  336.  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
  337.  IF Hyrule(Tx~%%, Ty%%).Is_Shop THEN Enter_Shop Hyrule(Tx~%%, Ty%%).Is_Shop
  338.  
  339.  
  340.  
  341. SUB Check_Link_Sword_Shot 'Can Link shoot his sword?
  342.  IF Link.Hearts = Link.Containers * 2 THEN 'Link has full hearts and can shoot
  343.   IF NOT _SNDPLAYING(SFX(SwordShot)) THEN 'Link did not just shoot
  344.    IF NOT G.Impactflag THEN 'Link's last shot has finished
  345.     IF NOT Link.Shot THEN
  346.      _SNDPLAY SFX(SwordShot)
  347.      Link.Shot = TRUE
  348.      Add_Projectile Sword, Player
  349.     END IF
  350.    END IF
  351.   END IF
  352.  
  353. SUB ClearLayer (L&)
  354.  _DEST L&
  355.  CLS
  356.  
  357. SUB ClearLayerTrans (L&)
  358.  _DEST L&
  359.  CLS , 0
  360.  
  361. SUB DarkenImage (Image AS LONG, Value_From_0_To_1 AS SINGLE)
  362.  IF Value_From_0_To_1 <= 0 OR Value_From_0_To_1 >= 1 OR _PIXELSIZE(Image) <> 4 THEN EXIT SUB
  363.  DIM Buffer AS _MEM: Buffer = _MEMIMAGE(Image) 'Get a memory reference to our image
  364.  DIM Frac_Value AS LONG: Frac_Value = Value_From_0_To_1 * 65536 'Used to avoid slow floating point calculations
  365.  DIM O AS _OFFSET, O_Last AS _OFFSET
  366.  O = Buffer.OFFSET 'We start at this offset
  367.  O_Last = Buffer.OFFSET + _WIDTH(Image) * _HEIGHT(Image) * 4 'We stop when we get to this offset
  368.  'use on error free code ONLY!
  369.  DO
  370.   _MEMPUT Buffer, O, _MEMGET(Buffer, O, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  371.   _MEMPUT Buffer, O + 1, _MEMGET(Buffer, O + 1, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  372.   _MEMPUT Buffer, O + 2, _MEMGET(Buffer, O + 2, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  373.   O = O + 4
  374.  LOOP UNTIL O = O_Last
  375.  'turn checking back on when done!
  376.  _MEMFREE Buffer
  377.  
  378. SUB Display_drops
  379.  FOR i%% = 0 TO G.ItemCount
  380.   _PUTIMAGE (Drop(i%%).Xloc, Drop(i%%).Yloc)-STEP(Item(Drop(i%%).ID).BoxSize_X * G.Scale_Factor - 1, Item(Drop(i%%).ID).BoxSize_Y * G.Scale_Factor - 1), Layer(7), Layer(1), (Item(Drop(i%%).ID).Sprite_X, Item(Drop(i%%).ID).Sprite_Y)-STEP(Item(Drop(i%%).ID).BoxSize_X - 1, Item(Drop(i%%).ID).BoxSize_Y - 1)
  381.  NEXT i%%
  382.  
  383. SUB Display_Lifted_Item
  384.  _PUTIMAGE (Link.Screen_X, Link.Screen_Y - 16 * G.Scale_Factor)-STEP(Item(G.Collected + 1).BoxSize_X * G.Scale_Factor - 1, Item(G.Collected + 1).BoxSize_Y * G.Scale_Factor - 1), Layer(7), Layer(1), (Item(G.Collected + 1).Sprite_X, Item(G.Collected + 1).Sprite_Y)-STEP(Item(G.Collected + 1).BoxSize_X - 1, Item(G.Collected + 1).BoxSize_Y - 1)
  385.  
  386. SUB Drop_Item (Id%%, X%, Y%, Status%%)
  387.  Drop(G.ItemCount).ID = Id%%
  388.  Drop(G.ItemCount).Xloc = X%
  389.  Drop(G.ItemCount).Yloc = Y%
  390.  Drop(G.ItemCount).Xsiz = Item(Id%%).BoxSize_X * G.Scale_Factor
  391.  Drop(G.ItemCount).Ysiz = Item(Id%%).BoxSize_X * G.Scale_Factor
  392.  Drop(G.ItemCount).Is_Special = Status%%
  393.  IF Status%% = FALSE THEN
  394.   Drop(G.ItemCount).Death = 5400 'clicks[60 per second]
  395.   Drop(G.ItemCount).Death = -1 'special items dont die
  396.  G.ItemCount = G.ItemCount + 1
  397.  Build_Item_Collision_layer
  398.  
  399. SUB Enter_Shop (Which%%)
  400.  'covers all cave screens; Shop\Gamble\Old Man\Old Woman\Information\Gifts\ and Thefts
  401.  IF NOT Hyrule(Link.Tile_X, Link.Tile_Y).Burnable THEN Walk_InOut GO_IN
  402.  Build_Cave_Screen
  403.  X% = Offset_X(G.Scale_Factor)
  404.  Y% = Offset_Y(G.Scale_Factor)
  405.  _PUTIMAGE , Layer(3), Layer(1)
  406.  Link.World = UnderWorld
  407.  SELECT CASE Which%%
  408.   CASE 1 'get the wood sword
  409.    'place the old man
  410.    IF Link.Sword = 0 THEN 'only show if player has not taken the wooden sword yet.
  411.     _PRINTSTRING (X% + 16 * G.Scale_Factor + 64, Y% + 16 * G.Scale_Factor + 48), "It's dangerous to go", Layer(3)
  412.     _PRINTSTRING (X% + 16 * G.Scale_Factor + 96, Y% + 16 * G.Scale_Factor + 64), "alone, take this.", Layer(3)
  413.     _PUTIMAGE (X% + (16 * G.Scale_Factor * 7.5), Y% + (16 * G.Scale_Factor * 4))-STEP(G.Scale_X, G.Scale_Y), Layer(17), Layer(3), (1, 11)-STEP(15, 15)
  414.     Drop_Item Shop(1, 1).Item, X% + (16 * G.Scale_Factor * 7.75), Y% + (16 * G.Scale_Factor * 5.5), TRUE
  415.    END IF
  416.   CASE 2 'Shop 1: Sheild 160, Key 100, Blue Candle 60
  417.   CASE 3 'old woman with life potions
  418.   CASE 4 'Shop 2: Sheild 130, Bomb 20, Arrow 80
  419.   CASE 5 'Shop 3: Blue Ring 250, Key 80, Bait 60
  420.   CASE 6 'Old woman:"Meet the Old man":"At the Grave"
  421.   CASE 7 'Old Woman: Informant
  422.   CASE 8 'Old Man: Life bottle or Heart Container "Take any one you want"
  423.   CASE 9 'Moblin: Gambling game
  424.   CASE 10 'Old Man: "Show this to the":"Old woman" Get the Letter
  425.  
  426. SUB Fade_Out (L&)
  427.  FOR n! = 1 TO 0.5 STEP -0.05
  428.   i2& = _COPYIMAGE(L&)
  429.   DarkenImage i2&, n!
  430.   _PUTIMAGE (0, 0), i2&, Layer(0)
  431.   _FREEIMAGE i2&
  432.   _DELAY .03
  433.  
  434. SUB Fade_In (L&)
  435.  FOR n! = 0.01 TO 1 STEP 0.05
  436.   i2& = _COPYIMAGE(L&)
  437.   DarkenImage i2&, n!
  438.   _PUTIMAGE (0, 0), i2&, Layer(0)
  439.   _FREEIMAGE i2&
  440.   _DELAY .03
  441.  
  442. FUNCTION Find_First_Available%% (Which%%, Start%%)
  443.  Selection%% = Start%% 'always start at the first saved game slot then check
  444.  DO 'lets find the first available selection (if there are any saved games)
  445.   IF Selection%% < 4 THEN
  446.    IF Which%% = 0 THEN IF RTRIM$(Nick(Selection%%)) = "" THEN Selection%% = Selection%% + 1 ELSE Good_Selection%% = TRUE
  447.    IF Which%% = 1 THEN IF RTRIM$(Nick(Selection%%)) = "" THEN Good_Selection%% = TRUE ELSE Selection%% = Selection%% + 1
  448.   ELSE '4 and 5 are always good selections
  449.    Good_Selection%% = TRUE
  450.   END IF
  451.  LOOP UNTIL Good_Selection%%
  452.  Find_First_Available = Selection%%
  453.  
  454. SUB Flame_Burn_Cave
  455.  STATIC Frame%%, Tick%%
  456.  X% = Offset_X(G.Scale_Factor)
  457.  Y% = Offset_Y(G.Scale_Factor)
  458.  _PUTIMAGE (X% + (16 * G.Scale_Factor * 4.5), Y% + (16 * G.Scale_Factor * 4))-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(3), (290, 256)-STEP(15, 15)
  459.  _PUTIMAGE (X% + (16 * G.Scale_Factor * 10.5), Y% + (16 * G.Scale_Factor * 4))-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(3), (290, 256)-STEP(15, 15)
  460.  IF Frame%% THEN
  461.   _PUTIMAGE (X% + (16 * G.Scale_Factor * 4.5), Y% + (16 * G.Scale_Factor * 4))-STEP(G.Scale_X, G.Scale_Y), Layer(17), Layer(3), (52, 11)-STEP(15, 15)
  462.   _PUTIMAGE (X% + (16 * G.Scale_Factor * 10.5), Y% + (16 * G.Scale_Factor * 4))-STEP(G.Scale_X, G.Scale_Y), Layer(17), Layer(3), (52, 11)-STEP(15, 15)
  463.   _PUTIMAGE (X% + (16 * G.Scale_Factor * 5.5), Y% + (16 * G.Scale_Factor * 4))-STEP(-G.Scale_X, G.Scale_Y), Layer(17), Layer(3), (52, 11)-STEP(15, 15)
  464.   _PUTIMAGE (X% + (16 * G.Scale_Factor * 11.5), Y% + (16 * G.Scale_Factor * 4))-STEP(-G.Scale_X, G.Scale_Y), Layer(17), Layer(3), (52, 11)-STEP(15, 15)
  465.  Tick%% = Tick%% + 1
  466.  IF Tick%% = 8 THEN Frame%% = NOT Frame%%: Tick%% = 0
  467.  
  468. FUNCTION Get_Input%% ()
  469.  Result%% = TRUE '-1 for no input
  470.  SELECT CASE G.ControlType
  471.   CASE TRUE 'Keyboard input
  472.    IF _KEYDOWN(C.KBCon_Up) THEN Result%% = Up
  473.    IF _KEYDOWN(C.KBCon_Down) THEN Result%% = Down
  474.    IF _KEYDOWN(C.KBCon_Left) THEN Result%% = Left
  475.    IF _KEYDOWN(C.KBCon_Right) THEN Result%% = Right
  476.    IF _KEYDOWN(C.KBCon_Select) THEN Result%% = SELECT_BUTTON: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_Select)
  477.    IF _KEYDOWN(C.KBCon_Start) THEN Result%% = START_BUTTON: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_Start)
  478.    IF _KEYDOWN(C.KBCon_A_Button) THEN Result%% = BUTTON_A: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_A_Button)
  479.    IF _KEYDOWN(C.KBCon_B_Button) THEN Result%% = BUTTON_B: ' DO: LOOP WHILE _KEYDOWN(C.KBCon_B_Button)
  480.   CASE FALSE 'joystick input
  481.    IF C.Control_Pad THEN
  482.     DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad)
  483.     IF NOT C.BAD_Pad THEN
  484.      nul%% = AxisPower(CJR%%, CJL%%, CJU%%, CJD%%) 'read directional axis values
  485.      IF CJU%% THEN Result%% = Up
  486.      IF CJD%% THEN Result%% = Down
  487.      IF CJL%% THEN Result%% = Left
  488.      IF CJR%% THEN Result%% = Right
  489.     ELSE
  490.      IF _BUTTON(C.Joy_Button_Up) THEN Result%% = Up ': Joy_Lock_Button (C.Joy_Button_Up)
  491.      IF _BUTTON(C.Joy_Button_Down) THEN Result%% = Down ': Joy_Lock_Button (C.Joy_Button_Down)
  492.      IF _BUTTON(C.Joy_Button_Left) THEN Result%% = Left ': Joy_Lock_Button (C.Joy_Button_Left)
  493.      IF _BUTTON(C.Joy_Button_Right) THEN Result%% = Right ': Joy_Lock_Button (C.Joy_Button_Right)
  494.     END IF
  495.     IF _BUTTON(C.Joy_Select) THEN Result%% = SELECT_BUTTON ': Joy_Lock_Button (C.Joy_Select)
  496.     IF _BUTTON(C.Joy_Start) THEN Result%% = START_BUTTON ': Joy_Lock_Button (C.Joy_Start)
  497.     IF _BUTTON(C.Joy_A_Button) THEN Result%% = BUTTON_A ': Joy_Lock_Button (C.Joy_A_Button)
  498.     IF _BUTTON(C.Joy_B_Button) THEN Result%% = BUTTON_B ': Joy_Lock_Button (C.Joy_B_Button)
  499.    END IF
  500.  Get_Input = Result%%
  501.  
  502. SUB Impact (X%, Y%)
  503.  STATIC Frame AS _BYTE, Fstp AS _BYTE, Xloc(3) AS INTEGER, Yloc(3) AS INTEGER
  504.  IF Frame = -1 OR Xloc(2) = 0 THEN
  505.   Fstp = 0
  506.   FOR i%% = 0 TO 3: Xloc(i%%) = X% + 8 * G.Scale_Factor: Yloc(i%%) = Y% + 8 * G.Scale_Factor: NEXT i%%
  507.  Xloc(0) = Xloc(0) - G.Scale_Factor: Yloc(0) = Yloc(0) - G.Scale_Factor
  508.  Xloc(1) = Xloc(1) + G.Scale_Factor: Yloc(1) = Yloc(1) - G.Scale_Factor
  509.  Xloc(2) = Xloc(2) + G.Scale_Factor: Yloc(2) = Yloc(2) + G.Scale_Factor
  510.  Xloc(3) = Xloc(3) - G.Scale_Factor: Yloc(3) = Yloc(3) + G.Scale_Factor
  511.  FOR i%% = 0 TO 3
  512.   SELECT CASE i%%
  513.    CASE 0
  514.     _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)
  515.    CASE 1
  516.     _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)
  517.    CASE 2
  518.     _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)
  519.    CASE 3
  520.     _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)
  521.  NEXT i%%
  522.  Fstp = Fstp + 1
  523.  Frame = Frame + 1
  524.  IF Frame = 4 THEN Frame = 0
  525.  IF Fstp = 16 THEN Frame = -1: G.Impactflag = FALSE
  526.  
  527. SUB Kill_Item (I%%)
  528.  Drop(I%%) = Drop(17) 'erase data in this drop(#17 is always blank)
  529.  FOR j%% = I%% TO G.ItemCount
  530.   SWAP Drop(j%%), Drop(I%%)
  531.  NEXT j%%
  532.  
  533. SUB Link_Attack
  534.  SELECT CASE Link.Direction
  535.   CASE Up
  536.    Ox%% = 0: Oy%% = -14 * G.Scale_Factor
  537.   CASE Down
  538.    Ox%% = 0: Oy%% = 14 * G.Scale_Factor
  539.   CASE Left
  540.    Ox%% = -14 * G.Scale_Factor + G.Aframe * (4 * G.Scale_Factor): Oy%% = 0
  541.   CASE Right
  542.    Ox%% = 14 * G.Scale_Factor - G.Aframe * (4 * G.Scale_Factor): Oy%% = 0
  543.  SELECT CASE G.Aframe
  544.   CASE 0
  545.    _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)
  546.   CASE 1
  547.    _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)
  548.    _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)
  549.   CASE 2
  550.    _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)
  551.    _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)
  552.   CASE 3
  553.    _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)
  554.    _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)
  555.   CASE ELSE 'attack animation finished
  556.    G.Atime = 0: G.Aframe = 0: Link.Action = None
  557.    _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)
  558.  
  559. FUNCTION Link_Collision%% (Dir%%)
  560.  Result%% = FALSE 'start at no collision
  561.  SELECT CASE Link.World
  562.   CASE OverWorld
  563.    'get links center point x\y tile position to check for collision
  564.    Ax% = Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
  565.    Ay% = Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
  566.    'we now have the tile that Links center pixel is in!
  567.    SELECT CASE Dir%%
  568.     CASE Up
  569.      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
  570.      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
  571.      IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  572.     CASE Down
  573.      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
  574.      Ty%% = (2 + Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) + 2 * G.Scale_Factor + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  575.      IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  576.     CASE Left
  577.      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
  578.      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
  579.      IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  580.     CASE Right
  581.      Tx~%% = (2 + Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + 2 * G.Scale_Factor + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  582.      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
  583.      IF NOT Hyrule(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  584.    END SELECT
  585.    Link.Tile_X = Tx~%%
  586.    Link.Tile_Y = Ty%%
  587.   CASE UnderWorld
  588.    'get links center point x\y tile position to check for collision
  589.    Ax% = 0 'Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
  590.    Ay% = 0 'Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
  591.    'we now have the tile that Links center pixel is in!
  592.    SELECT CASE Dir%%
  593.     CASE Up
  594.      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
  595.      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
  596.      IF NOT Cave(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  597.     CASE Down
  598.      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
  599.      Ty%% = (2 + Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) + 2 * G.Scale_Factor + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
  600.      IF NOT Cave(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  601.     CASE Left
  602.      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
  603.      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
  604.      IF NOT Cave(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  605.     CASE Right
  606.      Tx~%% = (2 + Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + 2 * G.Scale_Factor + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
  607.      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
  608.      IF NOT Cave(Tx~%%, Ty%%).Walkable THEN Result%% = TRUE
  609.    END SELECT
  610.  Link_Collision = Result%%
  611.  
  612. FUNCTION Link_Object_Collision%%
  613.  Result%% = FALSE
  614.  FOR y%% = 0 TO 8 * G.Scale_Factor
  615.   FOR x%% = 0 TO 8 * G.Scale_Factor
  616.    IF _RED32(POINT(x%% + Link.Screen_X + 4 * G.Scale_Factor, y%% + Link.Screen_Y + 4 * G.Scale_Factor)) <> 0 THEN
  617.     G.Collected = _RED32(POINT(x%% + Link.Screen_X + 4 * G.Scale_Factor, y%% + Link.Screen_Y + 4 * G.Scale_Factor)) - 1
  618.     Result%% = TRUE
  619.     x%% = 8 * G.Scale_Factor + 1: y%% = 8 * G.Scale_Factor + 1
  620.    END IF
  621.   NEXT x%%
  622.  NEXT y%%
  623.  _PRINTSTRING (0, 0), STR$(G.Collected), Layer(3)
  624.  Link_Object_Collision = Result%%
  625.  
  626. SUB Move_Link
  627.  SELECT CASE Link.Direction
  628.   CASE Up
  629.    IF NOT Link_Collision(Up) THEN 'nothing blocking Link
  630.     IF Link.Screen_Y > Offset_Y(G.Scale_Factor) THEN 'Link is not at the edge of the screen
  631.      Link.Screen_Y = Link.Screen_Y - 2 * G.Scale_Factor
  632.     ELSE 'player is at edge of screen to shift to next one.
  633.      G.NextScreen = Up
  634.      Shift_New_Map_Screen
  635.     END IF
  636.    END IF
  637.   CASE Down
  638.    IF NOT Link_Collision(Down) THEN 'nothing blocking Link
  639.     IF Link.Screen_Y < (Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor * 10)) THEN 'Link is not at the edge of the screen
  640.      Link.Screen_Y = Link.Screen_Y + 2 * G.Scale_Factor
  641.     ELSEIF Link.World = OverWorld THEN 'player is at edge of screen to shift to next one.
  642.      G.NextScreen = Down
  643.      Shift_New_Map_Screen
  644.     ELSE 'link is in the underworld
  645.      Walk_InOut GO_OUT
  646.     END IF
  647.    END IF
  648.   CASE Left
  649.    IF NOT Link_Collision(Left) THEN 'nothing blocking Link
  650.     IF Link.Screen_X > Offset_X(G.Scale_Factor) THEN 'Link is not at the edge of the screen
  651.      Link.Screen_X = Link.Screen_X - 2 * G.Scale_Factor
  652.     ELSE 'player is at edge of screen to shift to next one.
  653.      G.NextScreen = Left
  654.      Shift_New_Map_Screen
  655.     END IF
  656.    END IF
  657.   CASE Right
  658.    IF NOT Link_Collision(Right) THEN 'nothing blocking Link
  659.     IF Link.Screen_X < (Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor * 15)) THEN 'Link is not at the edge of the screen
  660.      Link.Screen_X = Link.Screen_X + 2 * G.Scale_Factor
  661.     ELSE 'player is at edge of screen to shift to next one.
  662.      G.NextScreen = Right
  663.      Shift_New_Map_Screen
  664.     END IF
  665.    END IF
  666.  
  667.  
  668. SUB Move_Sword_Shot
  669.  STATIC Xloc AS INTEGER, Yloc AS INTEGER, Direction AS _BYTE, Fstp AS _BYTE, Frame AS _BYTE
  670.  IF Direction = -1 OR Xloc = 0 THEN 'if no direction assigned then assign one
  671.   Direction = Link.Direction
  672.   Xloc = Link.Screen_X
  673.   Yloc = Link.Screen_Y
  674.  SELECT CASE Direction
  675.   CASE Up
  676.    Yloc = Yloc - 4 * G.Scale_Factor
  677.   CASE Down
  678.    Yloc = Yloc + 4 * G.Scale_Factor
  679.   CASE Left
  680.    Xloc = Xloc - 4 * G.Scale_Factor
  681.   CASE Right
  682.    Xloc = Xloc + 4 * G.Scale_Factor
  683.  _PUTIMAGE (Xloc, Yloc)-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(1), (1 + 17 * Frame + 68 * Direction, 239)-STEP(15, 15)
  684.  SELECT CASE G.Scale_Factor
  685.   CASE 1
  686.    IF Xloc <= 272 OR Xloc >= 514 OR Yloc <= 212 OR Yloc >= 372 THEN Done%% = TRUE
  687.   CASE 2
  688.    IF Xloc <= 140 OR Xloc >= 630 OR Yloc <= 100 OR Yloc >= 430 THEN Done%% = TRUE
  689.   CASE 3
  690.    IF Xloc <= 16 OR Xloc >= 744 OR Yloc <= 96 OR Yloc >= 559 THEN Done%% = TRUE
  691.  IF Done%% THEN Link.Shot = FALSE: G.Impactflag = TRUE: Impact Xloc, Yloc: Direction = -1: Remove_Projectile Sword, Player
  692.  Fstp = Fstp + 1
  693.  IF Fstp = 2 THEN Fstp = 0: Frame = Frame + 1
  694.  IF Frame = 4 THEN Frame = 0
  695.  
  696. SUB Pickup_Item (Id%%)
  697.  X% = Offset_X(G.Scale_Factor)
  698.  Y% = Offset_Y(G.Scale_Factor)
  699.  IF Drop(Id%%).Is_Special THEN _SNDPLAY SFX(Items): Link.Action = GetItem
  700.  SELECT CASE Drop(Id%%).ID
  701.   CASE 1, 2, 3 'Swords
  702.    Link.Sword = Drop(Id%%).ID
  703.   CASE 4 'bow
  704.    Link.Has_Bow = TRUE
  705.   CASE 5 'wand
  706.    Link.Has_Wand = TRUE
  707.   CASE 6 'Bait
  708.    Link.Has_Bait = TRUE
  709.   CASE 7, 8 'arrows
  710.    Link.Has_Arrow = Drop(Id%%).ID - 6 '1-arrow, 2-Silver arrow
  711.   CASE 9, 10 'boomerang
  712.    Link.Has_Boomerang = Drop(Id%%).ID - 8 '1-wood boomerang, 2-magic boomerang
  713.   CASE 11 'bombs
  714.    IF Drop(Id%%).Is_Special OR Drop(Id%%).Death = TRUE THEN '
  715.     Link.Max_Bombs = Link.Max_Bombs + 4
  716.    ELSE
  717.     Link.Has_Bombs = Link.Has_Bombs + 4
  718.     IF Link.Has_Bombs > Link.Max_Bombs THEN Link.Has_Bombs = Link.Max_Bombs
  719.    END IF
  720.   CASE 12, 13, 14 'letter, Blue and Red potions
  721.    Link.Has_Letter = Drop(Id%%).ID - 11
  722.   CASE 15 'dungeon maps
  723.   CASE 16 'magic book
  724.    Link.Has_Book = TRUE
  725.   CASE 17 'raft
  726.    Link.Has_Raft = TRUE
  727.   CASE 18
  728.    Link.Has_Ladder = TRUE
  729.   CASE 19, 20 'hearts
  730.    Link.Hearts = Link.Hearts + 2
  731.    IF Link.Hearts > Link.Containers * 2 THEN Link.Hearts = Link.Containers * 2
  732.   CASE 21 'heart container
  733.    Link.Containers = Link.Containers + 1
  734.   CASE 22, 23 'fairy
  735.   CASE 24 'stop watch
  736.   CASE 25 'Ruby x1
  737.    IF Link.Ruby + 1 <= 255 THEN Link.Ruby = Link.Ruby + 1
  738.   CASE 26 'Ruby x5
  739.    test% = Link.Ruby + 5
  740.    IF test% > 255 THEN Link.Ruby = 255 ELSE Link.Ruby = Link.Ruby + 5
  741.   CASE 27, 28 'Blue, Red Candle
  742.    Link.Has_Candle = Drop(Id%%).ID - 26
  743.   CASE 29, 30
  744.    Link.Has_Ring = Drop(Id%%).ID - 28
  745.   CASE 31
  746.    Link.Has_Shield = TRUE
  747.   CASE 32
  748.    Link.Has_Bracelet = TRUE
  749.   CASE 33
  750.    IF Link.Keys < 8 THEN Link.Keys = Link.Keys + 1
  751.   CASE 34
  752.    Link.Has_MagicKey = TRUE
  753.   CASE 35 'compass
  754.   CASE 36, 37 'triforce
  755.  Kill_Item G.Collected 'remove the item from the Drop array
  756.  IF NOT _SNDPLAYING(SFX(Items)) THEN G.Collected = -1
  757.  G.ItemCount = G.ItemCount - 1
  758.  Build_Item_Collision_layer
  759.  IF Link.World = UnderWorld THEN
  760.   X% = Offset_X(G.Scale_Factor)
  761.   Y% = Offset_Y(G.Scale_Factor)
  762.   _PUTIMAGE (X% + 16 * G.Scale_Factor + 64, Y% + 16 * G.Scale_Factor + 48)-STEP(352, 48), Layer(7), Layer(3), (290, 256)-STEP(15, 15)
  763.   _PUTIMAGE (X% + (16 * G.Scale_Factor * 7.5), Y% + (16 * G.Scale_Factor * 4))-STEP(G.Scale_X, G.Scale_Y), Layer(7), Layer(3), (290, 256)-STEP(15, 15)
  764.  
  765. SUB Place_Link
  766.  STATIC Ftime AS _BYTE, Frame AS _BYTE
  767.  IF Link.Action = Walking THEN 'while Link is moving
  768.   G.Wtime = G.Wtime + 1 'Increment frame time
  769.   IF G.Wtime = 8 THEN
  770.    IF G.Wframe THEN G.Wframe = 0 ELSE G.Wframe = 1 'change frame
  771.    G.Wtime = 0 'reset frame time
  772.   END IF
  773.   _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)
  774.  ELSEIF Link.Action = Useing THEN 'when Link uses an item
  775.   Ftime = Ftime + 1 'Increment frame time
  776.   IF Ftime = 32 THEN Link.Action = None: Ftime = 0 'action is done
  777.   _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)
  778.  ELSEIF Link.Action = GetItem THEN 'When Link gets a sword\item or buys something
  779.   'Held while music plays
  780.   _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)
  781.  ELSEIF Link.Action = GetTriforce THEN 'When Link recovers a Triforce piece
  782.   'Held while music plays
  783.   _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)
  784.  ELSEIF Link.Action = Attack THEN
  785.   G.Atime = G.Atime + 1 'Increment frame time
  786.   IF G.Atime = 4 THEN G.Aframe = G.Aframe + 1: G.Atime = 0 'change frame:reset frame time
  787.   Link_Attack
  788.  ELSE 'Link is standing Still(Action=None)
  789.   G.Atime = 0: G.Aframe = 0
  790.   G.Wtime = 0: G.Wframe = 0
  791.   _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)
  792.  
  793. SUB Place_Player_Record (I%%, Where%)
  794.  SELECT CASE Where%
  795.   CASE 0
  796.    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
  797.    _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)
  798.    _PRINTSTRING (284, 232 + 48 * I%%), RTRIM$(Nick(I%% + 1)), Layer(16) 'player 1 name
  799.    _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
  800.    FOR j%% = 1 TO Records(I%% + 1).Containers
  801.     IF j%% < 4 THEN 'first 3 hearts are red
  802.      _PUTIMAGE (428 + 16 * j%%, 232 + 48 * I%%)-STEP(15, 15), Layer(12), Layer(16), (52, 230)-STEP(7, 7) 'Player 1 hearts red
  803.     ELSE
  804.      IF j%% < 9 THEN
  805.       _PUTIMAGE (428 + 16 * j%%, 232 + 48 * I%%)-STEP(15, 15), Layer(12), Layer(16), (73, 267)-STEP(7, 7) 'Player 1 hearts white
  806.      ELSE
  807.       _PUTIMAGE (428 + 16 * (j%% - 8), 232 + 64 * I%%)-STEP(15, 15), Layer(12), Layer(16), (73, 267)-STEP(7, 7) 'Player 1 hearts white
  808.      END IF
  809.     END IF
  810.    NEXT j%%
  811.   CASE 1
  812.    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
  813.    _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)
  814.    _PRINTSTRING (364, 152 + 48 * (I%%)), RTRIM$(Nick(I%% + 1)), Layer(1)
  815.  
  816.  
  817. SUB Place_Tile_On_Screen (X%, Y%, Tile~%%, L&)
  818.  Gy% = 17 * (Tile~%% \ 20) 'get which row it comes from
  819.  Gx% = 17 * (Tile~%% MOD 20) 'which column position
  820.  _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)
  821.  
  822. SUB Scroll_Screen_II (Dir%%)
  823.  Cx% = Offset_X(G.Scale_Factor) 'top left corner location of map displayed
  824.  Cy% = Offset_Y(G.Scale_Factor)
  825.  Sfx% = 16 * 16 * G.Scale_Factor 'size of the map display
  826.  Sfy% = 11 * 16 * G.Scale_Factor
  827.  Lwx% = 16 * 16 * G.Scale_Factor * Link.World_X 'map area link is in
  828.  Lwy% = 11 * 16 * G.Scale_Factor * Link.World_Y
  829.  SELECT CASE Dir%%
  830.   CASE Up
  831.    FOR y% = 0 TO Sfy% STEP 2 * G.Scale_Factor
  832.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx%, Lwy% - y%)-STEP(Sfx%, Sfy%)
  833.     IF y% > 16 * G.Scale_Factor THEN Link.Screen_Y = Link.Screen_Y + 2 * G.Scale_Factor
  834.     Place_Link
  835.     _LIMIT 60
  836.     _PUTIMAGE , Layer(1), Layer(0)
  837.    NEXT
  838.    Link.World_Y = Link.World_Y - 1
  839.   CASE Down
  840.    FOR y% = 0 TO Sfy% STEP 2 * G.Scale_Factor
  841.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx%, Lwy% + y%)-STEP(Sfx%, Sfy%)
  842.     IF y% > 16 * G.Scale_Factor THEN Link.Screen_Y = Link.Screen_Y - 2 * G.Scale_Factor
  843.     Place_Link
  844.     _LIMIT 60
  845.     _PUTIMAGE , Layer(1), Layer(0)
  846.    NEXT
  847.    Link.World_Y = Link.World_Y + 1
  848.   CASE Left
  849.    FOR x% = 0 TO Sfx% STEP 2 * G.Scale_Factor
  850.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx% - x%, Lwy%)-STEP(Sfx%, Sfy%)
  851.     IF x% > 16 * G.Scale_Factor THEN Link.Screen_X = Link.Screen_X + 2 * G.Scale_Factor
  852.     Place_Link
  853.     _LIMIT 60
  854.     _PUTIMAGE , Layer(1), Layer(0)
  855.    NEXT
  856.    Link.World_X = Link.World_X - 1
  857.   CASE Right
  858.    FOR x% = 0 TO Sfx% STEP 2 * G.Scale_Factor
  859.     _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(1), (Lwx% + x%, Lwy%)-STEP(Sfx%, Sfy%)
  860.     IF x% > 16 * G.Scale_Factor THEN Link.Screen_X = Link.Screen_X - 2 * G.Scale_Factor
  861.     Place_Link
  862.     _LIMIT 60
  863.     _PUTIMAGE , Layer(1), Layer(0)
  864.    NEXT
  865.    Link.World_X = Link.World_X + 1
  866.  Place_Link
  867.  Lwx% = 16 * 16 * G.Scale_Factor * Link.World_X
  868.  Lwy% = 11 * 16 * G.Scale_Factor * Link.World_Y
  869.  _PUTIMAGE (Cx%, Cy%)-STEP(Sfx%, Sfy%), Layer(6), Layer(3), (Lwx%, Lwy%)-STEP(Sfx%, Sfy%) 'move new screen to layer(3)
  870.  
  871. SUB Shift_New_Map_Screen
  872.  SELECT CASE G.NextScreen
  873.   CASE Up
  874.    Scroll_Screen_II Up
  875.   CASE Down
  876.    Scroll_Screen_II Down
  877.   CASE Left
  878.    Scroll_Screen_II Left
  879.   CASE Right
  880.    Scroll_Screen_II Right
  881.  G.NextScreen = -1
  882.  
  883. SUB Title_Screen
  884.  _CLEARCOLOR _RGB32(21), Layer(9)
  885.  _CLEARCOLOR _RGB32(21), Layer(10)
  886.  _SNDVOL BGM(0), .33
  887.  _SNDLOOP BGM(0)
  888.  DO
  889.   F%% = 0: F% = 0: ExitFlag%% = FALSE
  890.   DO: _LIMIT 60: LOOP WHILE _SNDGETPOS(BGM(0)) > 10
  891.   DO
  892.    _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (0, 0)-STEP(255, 223)
  893.    SELECT CASE F%%
  894.     CASE 12 TO 18
  895.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0)-STEP(71, 71)
  896.     CASE 19 TO 24
  897.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 72)-STEP(71, 71)
  898.     CASE 25 TO 36
  899.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 144)-STEP(71, 71)
  900.     CASE 37 TO 52
  901.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 72)-STEP(71, 71)
  902.     CASE 53 TO 59
  903.      _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer(9), Layer(1), (289, 0 + 0)-STEP(71, 71)
  904.    END SELECT
  905.    _PUTIMAGE (304, 523 - 112), Layer(10), Layer(1), (0 + 64 * wave%%, 0)-STEP(63, 111)
  906.    _PUTIMAGE , Layer(1), Layer(0)
  907.    _LIMIT 90
  908.    F%% = F%% + 1
  909.    IF F%% = 60 THEN F%% = 0
  910.    IF F%% MOD 2 = 0 THEN wave%% = wave%% + 1
  911.    IF wave%% = 16 THEN wave%% = 0
  912.    IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  913.   LOOP UNTIL _SNDGETPOS(BGM(0)) > 8.4 OR ExitFlag%%
  914.  
  915.   IF NOT ExitFlag%% THEN
  916.    'start the title fade
  917.    _DEST Layer(1)
  918.    F%% = 0
  919.    DO
  920.     SELECT CASE F%
  921.      CASE 0 TO 13
  922.       LINE (144, 76)-STEP(511, 447), _RGB32(202, 241, 159), BF
  923.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (361, 0)-STEP(255, 223)
  924.      CASE 13 TO 24
  925.       LINE (144, 76)-STEP(511, 447), _RGB32(182, 216, 255), BF
  926.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (361, 0)-STEP(255, 223)
  927.      CASE 25 TO 34
  928.       LINE (144, 76)-STEP(511, 447), _RGB32(166, 229, 255), BF
  929.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (361, 0)-STEP(255, 223)
  930.      CASE 35 TO 42
  931.       LINE (144, 76)-STEP(511, 447), _RGB32(165, 238, 223), BF
  932.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (617, 0)-STEP(255, 223)
  933.      CASE 43 TO 48
  934.       LINE (144, 76)-STEP(511, 447), _RGB32(37, 190, 255), BF
  935.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (617, 0)-STEP(255, 223)
  936.      CASE 49 TO 52
  937.       LINE (144, 76)-STEP(511, 447), _RGB32(0, 109, 181), BF
  938.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (617, 0)-STEP(255, 223)
  939.      CASE 53 TO 57
  940.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (873, 0)-STEP(255, 223)
  941.       Wf% = 112
  942.      CASE 58 TO 61
  943.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1129, 0)-STEP(255, 223)
  944.       Wf% = 224
  945.      CASE 62 TO 363
  946.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1385, 0)-STEP(255, 223)
  947.       Wf% = 336
  948.      CASE 364 TO 385
  949.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1641, 0)-STEP(255, 223)
  950.       Wf% = 448
  951.      CASE 386 TO 393
  952.       _PUTIMAGE ((800 - 512) \ 2, (600 - 448) \ 2)-STEP(511, 447), Layer(9), Layer(1), (1897, 0)-STEP(255, 223)
  953.       Wf% = 560
  954.     END SELECT
  955.     _PUTIMAGE (304, 523 - 112), Layer(10), Layer(1), (0 + 64 * wave%%, 0 + Wf%)-STEP(63, 111)
  956.     _PUTIMAGE , Layer(1), Layer(0)
  957.     _LIMIT 90
  958.     F% = F% + 1
  959.     IF F% = 394 THEN ExitFlag%% = TRUE
  960.     IF F% MOD 2 = 0 THEN wave%% = wave%% + 1
  961.     IF wave%% = 16 THEN wave%% = 0
  962.     IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  963.    LOOP UNTIL ExitFlag%%
  964.    ExitFlag%% = FALSE
  965.   END IF
  966.   ClearLayer Layer(0)
  967.   ClearLayer Layer(1)
  968.   IF NOT ExitFlag%% THEN
  969.    'Title scroll
  970.    DO: _LIMIT 60: IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  971.    LOOP UNTIL _SNDGETPOS(BGM(0)) > 16 OR ExitFlag%%
  972.    F% = 0
  973.    IF NOT ExitFlag%% THEN
  974.     DO
  975.      SELECT CASE F%
  976.       CASE 0 TO 223
  977.        _PUTIMAGE (144, 76)-STEP(511, 447), Layer(11), Layer(1), (0, -223 + F%)-STEP(255, 223)
  978.       CASE IS >= 354
  979.        IF blink% THEN
  980.         _PUTIMAGE (72, 332)-STEP(7, 15), Layer(7), Layer(11), (247, 154)-STEP(7, 15) 'heart
  981.         _PUTIMAGE (72, 464)-STEP(7, 15), Layer(7), Layer(11), (213, 171)-STEP(7, 15) 'Ruby
  982.         _PUTIMAGE (120, 1432)-STEP(15, 15), Layer(7), Layer(11), (239, 188)-STEP(15, 15) 'Triforce
  983.        ELSE
  984.         _PUTIMAGE (72, 332)-STEP(7, 15), Layer(7), Layer(11), (239, 154)-STEP(7, 15) 'heart
  985.         _PUTIMAGE (72, 464)-STEP(7, 15), Layer(7), Layer(11), (205, 171)-STEP(7, 15) 'Ruby
  986.         _PUTIMAGE (120, 1432)-STEP(15, 15), Layer(7), Layer(11), (222, 188)-STEP(15, 15) 'Triforce
  987.        END IF
  988.        IF Fblink% THEN
  989.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (256, 188)-STEP(7, 15) 'fairy blank
  990.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (281, 154)-STEP(7, 15) 'fairy
  991.        ELSE
  992.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (256, 188)-STEP(7, 15) 'fairy blank
  993.         _PUTIMAGE (72, 400)-STEP(7, 15), Layer(7), Layer(11), (273, 154)-STEP(7, 15) 'fairy
  994.        END IF
  995.        _PUTIMAGE (144, 76)-STEP(511, 447), Layer(11), Layer(1), (0, F% - 354)-STEP(255, 223)
  996.      END SELECT
  997.      _PUTIMAGE , Layer(1), Layer(0)
  998.      _LIMIT 30
  999.      F% = F% + 1
  1000.      IF F% = 1762 THEN F% = F% - 1 'ExitFlag%% = TRUE
  1001.      B% = B% + 1
  1002.      IF B% = 4 THEN blink% = NOT blink%: B% = 0
  1003.      IF B% MOD 2 = 0 THEN Fblink% = NOT Fblink%
  1004.      IF Get_Input = START_BUTTON THEN ExitFlag%% = TRUE
  1005.     LOOP UNTIL _SNDGETPOS(BGM(0)) >= 79.75 OR ExitFlag%%
  1006.     ExitFlag%% = FALSE
  1007.    END IF
  1008.   END IF
  1009.  
  1010.  LOOP UNTIL ExitFlag%%
  1011.  _DEST Layer(0)
  1012.  _SNDSTOP BGM(0)
  1013.  DO: LOOP UNTIL Get_Input%% = -1
  1014.  
  1015.  
  1016. FUNCTION Projectile_Collision%%
  1017.  Result%% = FALSE
  1018.  FOR i%% = 0 TO G.Projectile_Count
  1019.  Projectile_Collision = Result%%
  1020.  
  1021.  
  1022. SUB Walk_InOut (Which%%)
  1023.  STATIC Shrink%%, Entry_X, Entry_Y
  1024.  SELECT CASE G.Scale_Factor
  1025.   CASE 1
  1026.    MoveY%% = 2
  1027.   CASE 2
  1028.    MoveY%% = 5
  1029.   CASE 3
  1030.    MoveY%% = 8
  1031.  
  1032.  SELECT CASE Which%%
  1033.   CASE GO_IN
  1034.    Link.Screen_X = 16 * G.Scale_Factor * (Link.Tile_X - Link.World_X * 16) + Offset_X(G.Scale_Factor)
  1035.    FOR y% = 0 TO MoveY%% 'move link into the cave opening
  1036.     _PUTIMAGE , Layer(3), Layer(1) 'place map image
  1037.     G.Wtime = G.Wtime + 1 'Increment frame time
  1038.     IF G.Wtime >= 2 THEN
  1039.      IF G.Wframe THEN G.Wframe = 0 ELSE G.Wframe = 1 'change frame
  1040.      G.Wtime = 0 'reset frame time
  1041.     END IF
  1042.     Link.Screen_Y = Link.Screen_Y - 2
  1043.     _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)
  1044.     _PUTIMAGE , Layer(1), Layer(0)
  1045.     _DELAY .033
  1046.    NEXT y%
  1047.  
  1048.    _SNDPLAY SFX(Stairs)
  1049.    DO 'have link walk `down` into the cave
  1050.     _PUTIMAGE , Layer(3), Layer(1) 'place map image
  1051.  
  1052.     G.Wtime = G.Wtime + 1 'Increment frame time
  1053.     IF G.Wtime = 8 THEN
  1054.      Shrink%% = Shrink%% + 2
  1055.      Link.Screen_Y = Link.Screen_Y + 2 * G.Scale_Factor
  1056.      IF G.Wframe THEN G.Wframe = 0 ELSE G.Wframe = 1 'change frame
  1057.      G.Wtime = 0 'reset frame time
  1058.     END IF
  1059.     _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y - Shrink%% * G.Scale_Factor), Layer(7), Layer(1), (1 + 34 * Link.Direction + 17 * G.Wframe, 137)-STEP(15, 15 - Shrink%%)
  1060.     _PUTIMAGE , Layer(1), Layer(0)
  1061.     _LIMIT 45
  1062.    LOOP WHILE _SNDPLAYING(SFX(Stairs))
  1063.    Entry_X = Link.Screen_X
  1064.    Entry_Y = Link.Screen_Y
  1065.    Link.Screen_X = Offset_X(G.Scale_Factor) + 16 * G.Scale_Factor * 7.5
  1066.    Link.Screen_Y = Offset_Y(G.Scale_Factor) + 16 * G.Scale_Factor * 9
  1067.    TIMER(TFX(0)) ON
  1068.   CASE GO_OUT
  1069.    TIMER(TFX(0)) OFF
  1070.    Build_Map_Screen 16 * Link.World_X, 11 * Link.World_Y
  1071.    Link.Screen_X = Entry_X 'Offset_X(G.Scale_Factor) + 16 * G.Scale_Factor * (Link.Tile_X - Link.World_X * 16)
  1072.    Link.Screen_Y = Entry_Y 'Offset_Y(G.Scale_Factor) + 16 * G.Scale_Factor * (Link.Tile_Y - Link.World_Y * 11)
  1073.    _SNDPLAY SFX(Stairs)
  1074.    DO 'have link walk `down` into the cave
  1075.     _PUTIMAGE , Layer(3), Layer(1) 'place map image
  1076.  
  1077.     G.Wtime = G.Wtime + 1 'Increment frame time
  1078.     IF G.Wtime = 8 THEN
  1079.      Shrink%% = Shrink%% - 2
  1080.      Link.Screen_Y = Link.Screen_Y - 2 * G.Scale_Factor
  1081.      IF G.Wframe THEN G.Wframe = 0 ELSE G.Wframe = 1 'change frame
  1082.      G.Wtime = 0 'reset frame time
  1083.     END IF
  1084.     _PUTIMAGE (Link.Screen_X, Link.Screen_Y)-STEP(G.Scale_X, G.Scale_Y - Shrink%% * G.Scale_Factor), Layer(7), Layer(1), (1 + 34 * Link.Direction + 17 * G.Wframe, 137)-STEP(15, 15 - Shrink%%)
  1085.  
  1086.     _PUTIMAGE , Layer(1), Layer(0)
  1087.     _LIMIT 45
  1088.    LOOP WHILE _SNDPLAYING(SFX(Stairs))
  1089.  
  1090.    FOR y% = 0 TO 16 'move link into the cave opening
  1091.     _PUTIMAGE , Layer(3), Layer(1) 'place map image
  1092.     G.Wtime = G.Wtime + 1 'Increment frame time
  1093.     IF G.Wtime >= 2 THEN
  1094.      IF G.Wframe THEN G.Wframe = 0 ELSE G.Wframe = 1 'change frame
  1095.      G.Wtime = 0 'reset frame time
  1096.     END IF
  1097.     Link.Screen_Y = Link.Screen_Y + 2
  1098.     _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)
  1099.     _PUTIMAGE , Layer(1), Layer(0)
  1100.     _DELAY .016
  1101.    NEXT y%
  1102.  
  1103.    Link.World = OverWorld
  1104.    Link.Tile_Y = Link.Tile_Y + 1
  1105.    Shrink%% = 0
  1106.  
  1107. SUB Build_Custom_Control_Screen (L&())
  1108.  'setup custom controls screen
  1109.  _PUTIMAGE (120, 72), Layer(18), L&(2)
  1110.  _DEST L&(2)
  1111.  'up arrow
  1112.  LINE (208, 168)-(112, 172), _RGB32(255, 127, 0), BF
  1113.  LINE (112, 172)-(116, 500), _RGB32(255, 127, 0), BF
  1114.  LINE (112, 500)-(292, 504), _RGB32(255, 127, 0), BF
  1115.  'left arrow
  1116.  LINE (172, 200)-(128, 204), _RGB32(92, 192, 0), BF
  1117.  LINE (128, 204)-(132, 456), _RGB32(92, 192, 0), BF
  1118.  LINE (128, 456)-(320, 460), _RGB32(92, 192, 0), BF
  1119.  'down arrow
  1120.  LINE (208, 252)-(144, 256), _RGB32(0, 127, 255), BF
  1121.  LINE (144, 256)-(148, 412), _RGB32(0, 127, 255), BF
  1122.  LINE (144, 412)-(336, 416), _RGB32(0, 127, 255), BF
  1123.  'right arrow
  1124.  LINE (256, 224)-(260, 280), _RGB32(0, 64, 160), BF
  1125.  LINE (160, 280)-(260, 284), _RGB32(0, 64, 160), BF
  1126.  LINE (160, 284)-(164, 366), _RGB32(0, 64, 160), BF
  1127.  LINE (160, 366)-(340, 370), _RGB32(0, 64, 160), BF
  1128.  'select
  1129.  LINE (344, 252)-(348, 500), _RGB32(255, 64, 0), BF
  1130.  LINE (344, 500)-(516, 504), _RGB32(255, 64, 0), BF
  1131.  'start
  1132.  LINE (408, 252)-(412, 456), _RGB32(212, 0, 16), BF
  1133.  LINE (408, 456)-(576, 460), _RGB32(212, 0, 16), BF
  1134.  'B Button
  1135.  LINE (506, 248)-(510, 296), _RGB32(64, 92, 212), BF
  1136.  LINE (420, 296)-(510, 300), _RGB32(64, 92, 212), BF
  1137.  LINE (420, 300)-(424, 416), _RGB32(64, 92, 212), BF
  1138.  LINE (420, 412)-(576, 416), _RGB32(64, 92, 212), BF
  1139.  'A Button
  1140.  LINE (576, 248)-(580, 312), _RGB32(80, 64, 180), BF
  1141.  LINE (436, 312)-(580, 316), _RGB32(80, 64, 180), BF
  1142.  LINE (436, 312)-(440, 368), _RGB32(80, 64, 180), BF
  1143.  LINE (436, 368)-(608, 372), _RGB32(80, 64, 180), BF
  1144.  'setup click layer  40,32 offset
  1145.  _DEST L&(3)
  1146.  LINE (200, 164)-STEP(35, 30), _RGB(1, 0, 0), BF 'up
  1147.  LINE (200, 230)-STEP(35, 30), _RGB(2, 0, 0), BF 'down
  1148.  LINE (168, 198)-STEP(35, 30), _RGB(3, 0, 0), BF 'left
  1149.  LINE (236, 198)-STEP(35, 30), _RGB(4, 0, 0), BF 'right
  1150.  
  1151.  LINE (318, 232)-STEP(45, 20), _RGB(5, 0, 0), BF 'Select
  1152.  LINE (388, 232)-STEP(45, 20), _RGB(6, 0, 0), BF 'Start
  1153.  
  1154.  LINE (478, 212)-STEP(58, 60), _RGB(7, 0, 0), BF 'Button A
  1155.  LINE (548, 212)-STEP(58, 60), _RGB(8, 0, 0), BF 'Button B
  1156.  
  1157.  _PRINTSTRING (96, 0), "Click on the controller button you wish to customize, Press the new key.", L&(2)
  1158.  _PRINTSTRING (144, 16), "Tab to switch Control type. When done click EXIT when done.", L&(2)
  1159.  _PRINTSTRING (96, 32), "With a JOYPAD: TYPE I-use axis for movement, TYPE II-use buttons to move.", L&(2)
  1160.  _DEST L&(0)
  1161.  
  1162. SUB Custom_Controls
  1163.  OldD& = _DEST
  1164.  OldS& = _SOURCE
  1165.  DIM Clayer(4) AS LONG
  1166.  Clayer(0) = _DISPLAY
  1167.  Clayer(1) = _NEWIMAGE(800, 600, 32)
  1168.  Clayer(2) = _NEWIMAGE(800, 600, 32)
  1169.  Clayer(3) = _NEWIMAGE(800, 600, 32)
  1170.  ClearLayer Clayer(2)
  1171.  ClearLayerTrans Clayer(4)
  1172.  Build_Custom_Control_Screen Clayer()
  1173.  _FONT FFX(0), Clayer(1)
  1174.  _FONT FFX(0), Clayer(4)
  1175.  _DEST Clayer(1)
  1176.  _SOURCE Clayer(3)
  1177.  DO
  1178.  
  1179.   KBD& = _KEYHIT
  1180.   IF KBD& < 0 THEN KBD& = 0 'handle button up `-` codes
  1181.  
  1182.   IF (NOT G.ControlType) AND Master%% THEN
  1183.    Nul%% = _DEVICEINPUT(C.Control_Pad)
  1184.    IF NOT C.BAD_Pad THEN
  1185.     IF Master%% > 4 THEN
  1186.      FOR i%% = 1 TO _LASTBUTTON(C.Control_Pad)
  1187.       IF _BUTTON(i%%) THEN Bselect%% = i%%: i%% = _LASTBUTTON(C.Control_Pad) + 1
  1188.      NEXT i%%
  1189.     ELSE
  1190.      FOR i%% = 1 TO _LASTAXIS(C.Control_Pad)
  1191.       test%% = _AXIS(i%%)
  1192.       IF test%% THEN Aselect%% = i%%: i%% = _LASTAXIS(C.Control_Pad)
  1193.      NEXT i%%
  1194.     END IF
  1195.    ELSE
  1196.     FOR i%% = 1 TO _LASTBUTTON(C.Control_Pad)
  1197.      IF _BUTTON(i%%) THEN Bselect%% = i%%: i%% = _LASTBUTTON(C.Control_Pad) + 1
  1198.     NEXT i%%
  1199.    END IF
  1200.   END IF
  1201.  
  1202.   _PUTIMAGE , Clayer(2), Clayer(1)
  1203.   Nul%% = _MOUSEINPUT
  1204.   X% = _MOUSEX: Y% = _MOUSEY
  1205.   Selection%% = _RED32(POINT(X%, Y%)) 'is mouse over anything?
  1206.  
  1207.   IF Master%% THEN Selection%% = Master%% 'keep selection locked until key press
  1208.  
  1209.    IF NOT Master%% THEN Master%% = Selection%% 'if no Master selection set then set it.
  1210.    IF ExitSet%% THEN ExitFlag%% = TRUE
  1211.    IF X% > 640 AND X% < 770 AND Y% > 440 AND Y% < 475 THEN C.BAD_Pad = NOT C.BAD_Pad 'toggle controller directional type
  1212.   END IF
  1213.  
  1214.   IF Master%% AND G.ControlType THEN 'once player clicks and controller is Keyboard
  1215.    IF KBD& <> ESC_Key THEN
  1216.     Set_KeyBoard_Control Master%%, KBD&
  1217.    END IF
  1218.   ELSEIF Master%% AND (NOT G.ControlType) THEN 'once player clicks and controller is Joy Pad
  1219.    SELECT CASE Master%%
  1220.     CASE 1 'Up arrow
  1221.      IF Aselect%% THEN
  1222.       C.Joy_Up = Aselect%%
  1223.       IF test%% < 0 THEN C.Joy_Up_Val = TRUE ELSE C.Joy_Up_Val = 1
  1224.       Master%% = FALSE 'unlock selection with button press
  1225.       Aselect%% = 0
  1226.      ELSEIF Bselect%% AND C.BAD_Pad THEN
  1227.       C.Joy_Button_Up = Bselect%%
  1228.       Master%% = FALSE 'unlock selection with button press
  1229.       Bselect%% = 0
  1230.      END IF
  1231.     CASE 2 'Down arrow
  1232.      IF Aselect%% THEN
  1233.       C.Joy_Down = Aselect%%
  1234.       IF test%% < 0 THEN C.Joy_Down_Val = TRUE ELSE C.Joy_Down_Val = 1
  1235.       Master%% = FALSE 'unlock selection with button press
  1236.       Aselect%% = 0
  1237.      ELSEIF Bselect%% AND C.BAD_Pad THEN
  1238.       C.Joy_Button_Down = Bselect%%
  1239.       Master%% = FALSE 'unlock selection with button press
  1240.       Bselect%% = 0
  1241.      END IF
  1242.     CASE 3 'left arrow
  1243.      IF Aselect%% THEN
  1244.       C.Joy_Left = Aselect%%
  1245.       IF test%% < 0 THEN C.Joy_Left_Val = TRUE ELSE C.Joy_Left_Val = 1
  1246.       Master%% = FALSE 'unlock selection with button press
  1247.       Aselect%% = 0
  1248.      ELSEIF Bselect%% AND C.BAD_Pad THEN
  1249.       C.Joy_Button_Left = Bselect%%
  1250.       Master%% = FALSE 'unlock selection with button press
  1251.       Bselect%% = 0
  1252.      END IF
  1253.     CASE 4 'right arrow
  1254.      IF Aselect%% THEN
  1255.       C.Joy_Right = Aselect%%
  1256.       IF test%% < 0 THEN C.Joy_Right_Val = TRUE ELSE C.Joy_Right_Val = 1
  1257.       Master%% = FALSE 'unlock selection with button press
  1258.       Aselect%% = 0
  1259.      ELSEIF Bselect%% AND C.BAD_Pad THEN
  1260.       C.Joy_Button_Right = Bselect%%
  1261.       Master%% = FALSE 'unlock selection with button press
  1262.       Bselect%% = 0
  1263.      END IF
  1264.     CASE 5 'select
  1265.      IF Bselect%% THEN C.Joy_Select = Bselect%%: Master%% = FALSE 'unlock selection with button press
  1266.      Bselect%% = 0
  1267.     CASE 6 'start
  1268.      IF Bselect%% THEN C.Joy_Start = Bselect%%: Master%% = FALSE 'unlock selection with button press
  1269.      Bselect%% = 0
  1270.     CASE 7 'b
  1271.      IF Bselect%% THEN C.Joy_B_Button = Bselect%%: Master%% = FALSE 'unlock selection with button press
  1272.      Bselect%% = 0
  1273.     CASE 8 'a
  1274.      IF Bselect%% THEN C.Joy_A_Button = Bselect%%: Master%% = FALSE 'unlock selection with button press
  1275.      Bselect%% = 0
  1276.    END SELECT
  1277.  
  1278.   END IF
  1279.  
  1280.   IF KBD& = 9 THEN G.ControlType = NOT G.ControlType ': LINE (128, 350)-STEP(496, 160), _RGB32(0), BF
  1281.   IF (NOT G.ControlType) AND C.Control_Pad = 0 THEN 'setup joy pad
  1282.    IF G.Device_Count <= 2 THEN 'is there a joy pad to use?
  1283.     _PUTIMAGE (188, 100)-STEP(384, 48), Layer(12), Clayer(0), (86, 240)-STEP(7, 7) 'black out name
  1284.     _PRINTSTRING (192, 108), " NO OTHER DEVICE FOUND", Clayer(0)
  1285.     _PRINTSTRING (288, 126), " PRESS TAB", Clayer(0)
  1286.     _KEYCLEAR
  1287.     DO: _LIMIT 30: LOOP UNTIL INKEY$ = CHR$(9)
  1288.     _KEYCLEAR
  1289.     G.ControlType = TRUE
  1290.    ELSE
  1291.     Select_Device
  1292.    END IF
  1293.   END IF
  1294.  
  1295.   'Screen Updating
  1296.   Display_Keys G.ControlType
  1297.   Highlite_Select Selection%%
  1298.   ExitSet%% = Display_Exit_Controls(X%, Y%)
  1299.   IF NOT G.ControlType THEN Display_BAD_Controller_Option
  1300.   '---------------------------------------------------------------------------------------------------------
  1301.   '  _PUTIMAGE , Clayer(4), Clayer(1)
  1302.   _PUTIMAGE , Clayer(1), Clayer(0)
  1303.   _LIMIT 30
  1304.   IF (NOT G.ControlType) THEN DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad)
  1305.  
  1306.  LOOP UNTIL ExitFlag%%
  1307.  
  1308.  _DEST OldD&
  1309.  _SOURCE OldS&
  1310.  
  1311. SUB Select_Device
  1312.  'removing the first 2 devices, assuming keyboard=1 and mouse=2
  1313.  IF G.Device_Count > 3 THEN
  1314.   DO
  1315.    KBD$ = INKEY$
  1316.    _PUTIMAGE , Layer(16), Layer(1)
  1317.    '   Draw_Window 4, 7, 30, 1 + (G.Device_Count - 2) * 2, Layer(1)
  1318.    FOR i%% = 3 TO G.Device_Count
  1319.     temp$ = Device_Name$(i%%)
  1320.     _PRINTSTRING (16 * 12 - LEN(temp$) \ 2, 16 * (8 + (i%% - 3))), LTRIM$(STR$(i%%)) + "-" + temp$
  1321.    NEXT i%%
  1322.    _PRINTSTRING (16 * 6 + 8, 16 * (8 + (i%% - 3)) + 2), "Press Number of controller"
  1323.    _PUTIMAGE , Layer(1), Layer(0)
  1324.    _LIMIT 30
  1325.    IF VAL(KBD$) > 2 AND VAL(KBD$) <= G.Device_Count THEN C.Control_Pad = VAL(KBD$): ExitFlag%% = TRUE
  1326.    IF KBD$ = CHR$(27) THEN CLOSE: END
  1327.   LOOP UNTIL ExitFlag%%
  1328.  ELSE 'if there is only 1 control device to choose from auto assign
  1329.   C.Control_Pad = 3
  1330.  
  1331.  
  1332. SUB Display_Keys (ID%%)
  1333.  IF ID%% THEN
  1334.   _PRINTSTRING (312, 116), "Keyboard"
  1335.   _PRINTSTRING (144, 480), ControlName(C.KBCon_Up)
  1336.   _PRINTSTRING (176, 392), ControlName(C.KBCon_Down)
  1337.   _PRINTSTRING (160, 436), ControlName(C.KBCon_Left)
  1338.   _PRINTSTRING (192, 348), ControlName(C.KBCon_Right)
  1339.   _PRINTSTRING (468, 348), ControlName(C.KBCon_A_Button)
  1340.   _PRINTSTRING (450, 392), ControlName(C.KBCon_B_Button)
  1341.   _PRINTSTRING (376, 480), ControlName(C.KBCon_Select)
  1342.   _PRINTSTRING (444, 436), ControlName(C.KBCon_Start)
  1343.   _PRINTSTRING (312, 116), "JoyPad-" + LTRIM$(STR$(C.Control_Pad))
  1344.   IF NOT C.BAD_Pad THEN
  1345.    IF C.Joy_Up = -22 THEN
  1346.     _PRINTSTRING (144, 480), "UnDefined"
  1347.    ELSE
  1348.     IF C.Joy_Up_Val < 0 THEN a$ = " -" ELSE a$ = " +"
  1349.     _PRINTSTRING (144, 480), "Axis:" + STR$(C.Joy_Up) + a$
  1350.    END IF
  1351.    IF C.Joy_Down = -22 THEN
  1352.     _PRINTSTRING (176, 392), "UnDefined"
  1353.    ELSE
  1354.     IF C.Joy_Down_Val < 0 THEN a$ = " -" ELSE a$ = " +"
  1355.     _PRINTSTRING (176, 392), "Axis:" + STR$(C.Joy_Down) + a$
  1356.    END IF
  1357.    IF C.Joy_Left = -22 THEN
  1358.     _PRINTSTRING (160, 436), "UnDefined"
  1359.    ELSE
  1360.     IF C.Joy_Left_Val < 0 THEN a$ = " -" ELSE a$ = " +"
  1361.     _PRINTSTRING (160, 436), "Axis:" + STR$(C.Joy_Left) + a$
  1362.    END IF
  1363.    IF C.Joy_Right = -22 THEN
  1364.     _PRINTSTRING (192, 348), "UnDefined"
  1365.    ELSE
  1366.     IF C.Joy_Right_Val < 0 THEN a$ = " -" ELSE a$ = " +"
  1367.     _PRINTSTRING (192, 348), "Axis:" + STR$(C.Joy_Right) + a$
  1368.    END IF
  1369.   ELSE
  1370.    IF C.Joy_Button_Up = -22 THEN
  1371.     _PRINTSTRING (144, 480), "UnDefined"
  1372.    ELSE
  1373.     _PRINTSTRING (144, 480), "Button:" + STR$(C.Joy_Button_Up) + a$
  1374.    END IF
  1375.    IF C.Joy_Button_Down = -22 THEN
  1376.     _PRINTSTRING (176, 392), "UnDefined"
  1377.    ELSE
  1378.     _PRINTSTRING (176, 392), "Button:" + STR$(C.Joy_Button_Down) + a$
  1379.    END IF
  1380.    IF C.Joy_Button_Left = -22 THEN
  1381.     _PRINTSTRING (160, 436), "UnDefined"
  1382.    ELSE
  1383.     _PRINTSTRING (160, 436), "Button:" + STR$(C.Joy_Button_Left) + a$
  1384.    END IF
  1385.    IF C.Joy_Button_Right = -22 THEN
  1386.     _PRINTSTRING (192, 348), "UnDefined"
  1387.    ELSE
  1388.     _PRINTSTRING (192, 348), "Button:" + STR$(C.Joy_Button_Right) + a$
  1389.    END IF
  1390.   END IF
  1391.   IF C.Joy_Select = -22 THEN _PRINTSTRING (376, 480), "UnDefined" ELSE _PRINTSTRING (376, 480), "Button:" + STR$(C.Joy_Select)
  1392.   IF C.Joy_Start = -22 THEN _PRINTSTRING (444, 436), "UnDefined" ELSE _PRINTSTRING (444, 436), "Button:" + STR$(C.Joy_Start)
  1393.   IF C.Joy_A_Button = -22 THEN _PRINTSTRING (468, 348), "UnDefined" ELSE _PRINTSTRING (468, 348), "Button:" + STR$(C.Joy_A_Button)
  1394.   IF C.Joy_B_Button = -22 THEN _PRINTSTRING (450, 392), "UnDefined" ELSE _PRINTSTRING (450, 392), "Button:" + STR$(C.Joy_B_Button)
  1395.  
  1396. FUNCTION Display_Exit_Controls%% (X%, Y%)
  1397.  IF X% > 640 AND X% < 720 AND Y% > 390 AND Y% < 425 THEN
  1398.   LINE (640, 390)-STEP(80, 35), _RGB32(255, 32, 8), BF
  1399.   _PRINTSTRING (650, 400), "EXIT"
  1400.   Result%% = TRUE
  1401.   LINE (640, 390)-STEP(80, 35), _RGB32(160, 72, 16), BF
  1402.   _PRINTSTRING (650, 400), "EXIT"
  1403.   Result%% = FALSE
  1404.  Display_Exit_Controls = Result%%
  1405.  
  1406. SUB Set_KeyBoard_Control (Master%%, KBD&)
  1407.  SELECT CASE Master%%
  1408.   CASE 1 'Up arrow
  1409.    IF KBD& THEN C.KBCon_Up = KBD&: Master%% = FALSE 'unlock selection with key press
  1410.   CASE 2 'down arrow
  1411.    IF KBD& THEN C.KBCon_Down = KBD&: Master%% = FALSE 'unlock selection with key press
  1412.   CASE 3 'left arrow
  1413.    IF KBD& THEN C.KBCon_Left = KBD&: Master%% = FALSE 'unlock selection with key press
  1414.   CASE 4 'right arrow
  1415.    IF KBD& THEN C.KBCon_Right = KBD&: Master%% = FALSE 'unlock selection with key press
  1416.   CASE 5 'select
  1417.    IF KBD& THEN C.KBCon_Select = KBD&: Master%% = FALSE 'unlock selection with key press
  1418.   CASE 6 'start
  1419.    IF KBD& THEN C.KBCon_Start = KBD&: Master%% = FALSE 'unlock selection with key press
  1420.   CASE 7 'b
  1421.    IF KBD& THEN C.KBCon_B_Button = KBD&: Master%% = FALSE 'unlock selection with key press
  1422.   CASE 8 'a
  1423.    IF KBD& THEN C.KBCon_A_Button = KBD&: Master%% = FALSE 'unlock selection with key press
  1424.  
  1425. SUB Highlite_Select (ID%%)
  1426.  STATIC Factor%%
  1427.  IF ID%% THEN Factor%% = Factor%% + 16 'mouse over highlight color shift
  1428.  IF Factor%% >= 120 THEN Factor%% = 0
  1429.  SELECT CASE ID%% 'highlight which control mouse is over.
  1430.   CASE 1 'up
  1431.    LINE (112, 500)-(292, 504), _RGB32(255 - Factor%%, 127 + Factor%%, 0 + Factor%%), BF
  1432.   CASE 2 'down
  1433.    LINE (144, 412)-(336, 416), _RGB32(0 + Factor%%, 127 - Factor%%, 255 - Factor%%), BF
  1434.   CASE 3 'left
  1435.    LINE (128, 456)-(320, 460), _RGB32(92 + Factor%%, 192 - Factor%%, 0 + Factor%%), BF
  1436.   CASE 4 'right
  1437.    LINE (160, 366)-(340, 370), _RGB32(0 + Factor%%, 64 + Factor%%, 160 - Factor%%), BF
  1438.   CASE 5 'select
  1439.    LINE (344, 500)-(496, 504), _RGB32(255 - Factor%%, 64 + Factor%%, 0 - Factor%%), BF
  1440.   CASE 6 'start
  1441.    LINE (408, 456)-(576, 460), _RGB32(212 - Factor%%, 0 + Factor%%, 16 + Factor%%), BF
  1442.   CASE 7 'B
  1443.    LINE (420, 412)-(576, 416), _RGB32(64 + Factor%%, 92 + Factor%%, 212 - Factor%%), BF
  1444.   CASE 8 'A
  1445.    LINE (436, 368)-(608, 372), _RGB32(80 + Factor%%, 64 + Factor%%, 180 - Factor%%), BF
  1446.  
  1447. SUB Get_JoyPads
  1448.  'load input device details Max:16
  1449.  G.Device_Count = _DEVICES
  1450.  IF G.Device_Count > 16 THEN G.Device_Count = 16 'limit total devices to 16
  1451.  FOR I%% = 1 TO G.Device_Count
  1452.   DeviceData(I%%).Buttons = _LASTBUTTON(I%%) ' number of buttons on the device
  1453.   DeviceData(I%%).Axis_p = _LASTAXIS(I%%) 'number of axis on the device
  1454.  NEXT I%%
  1455.  IF G.Device_Count < 3 THEN G.ControlType = TRUE 'no joypads detected
  1456.  
  1457. SUB Display_BAD_Controller_Option
  1458.  IF C.BAD_Pad THEN
  1459.   LINE (640, 440)-STEP(130, 35), _RGB32(255, 16, 8), BF
  1460.   _PRINTSTRING (650, 450), "TYPE II"
  1461.   Result%% = TRUE
  1462.   LINE (640, 440)-STEP(130, 35), _RGB32(16, 72, 240), BF
  1463.   _PRINTSTRING (660, 450), "TYPE I"
  1464.   Result%% = FALSE
  1465.  
  1466. FUNCTION ControlName$ (id&)
  1467.  Result$ = "#ERROR#"
  1468.  FOR i~%% = 0 TO 133
  1469.   IF KeyCodes(i~%%).Value = id& THEN Result$ = KeyCodes(i~%%).Nam: i~%% = 135
  1470.  NEXT i~%%
  1471.  IF i~%% = 134 THEN Result$ = "Unknown#"
  1472.  ControlName = Result$
  1473.  
  1474. FUNCTION AxisPower%% (CJR%%, CJL%%, CJU%%, CJD%%)
  1475.  CJR%% = _AXIS(C.Joy_Right)
  1476.  CJL%% = _AXIS(C.Joy_Left)
  1477.  CJU%% = _AXIS(C.Joy_Up)
  1478.  CJD%% = _AXIS(C.Joy_Down)
  1479.  IF CJR%% = C.Joy_Right_Val THEN CJL%% = 0: CJR%% = TRUE ELSE CJR%% = 0
  1480.  IF CJD%% = C.Joy_Down_Val THEN CJU%% = 0: CJD%% = TRUE ELSE CJD%% = 0
  1481.  AxisPower = nul%%
  1482.  
  1483. SUB Save_Config
  1484.  IF _FILEEXISTS("DW1CS.CFG") THEN KILL "DW1CS.CFG"
  1485.  CF = FREEFILE
  1486.  OPEN "DW1CS.CFG" FOR BINARY AS #CF
  1487.  Ver~& = CurrentVer
  1488.  PUT #CF, , Ver~&
  1489.  PUT #CF, , C
  1490.  PUT #CF, , G.ControlType
  1491.  ' PUT #CF, , G.TextClick
  1492.  PUT #CF, , G.BGM_vol
  1493.  PUT #CF, , G.SFX_Vol
  1494.  ' PUT #CF, , G.SkipIntro
  1495.  CLOSE #CF
  1496.  
  1497. SUB MFI_Loader (FN$)
  1498.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  1499.  GET #1, , c~%% 'retrieve number of files
  1500.  FOR I~%% = 1 TO c~%%
  1501.   GET #1, , FOffset(I~%%)
  1502.   GET #1, , Size(I~%%)
  1503.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  1504.  NEXT I~%%
  1505.  Layer(7) = LoadGFX(FOffset(1), Size(1)) '_LOADIMAGE("overworldtiles.bmp", 32)
  1506.  Layer(9) = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("TitleScreen.bmp", 32)
  1507.  Layer(10) = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("Titlefalls.bmp", 32)
  1508.  Layer(11) = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("Titlescroll.bmp", 32)
  1509.  Layer(12) = LoadGFX(FOffset(5), Size(5)) '_LOADIMAGE("selectionscreen.bmp", 32)
  1510.  Layer(18) = LoadGFX(FOffset(13), Size(13)) '_LOADIMAGE("gfx\png\controller.png", 32)
  1511.  Layer(17) = LoadGFX(FOffset(14), Size(14)) '_LOADIMAGE("gfx\png\21189.png", 32)
  1512.  
  1513.  SFX(0) = LoadSFX(FOffset(6), Size(6))
  1514.  SFX(1) = LoadSFX(FOffset(7), Size(7))
  1515.  SFX(2) = LoadSFX(FOffset(8), Size(8))
  1516.  SFX(3) = LoadSFX(FOffset(9), Size(9))
  1517.  BGM(0) = LoadSFX(FOffset(10), Size(10))
  1518.  FFX(0) = LoadFFX(FOffset(11), Size(11), 16)
  1519.  LoadData FOffset(12), Size(12)
  1520.  
  1521.  CLOSE #1
  1522.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1523.  
  1524. FUNCTION LoadGFX& (Foff&, Size&)
  1525.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1526.  OPEN "temp.dat" FOR BINARY AS #3
  1527.  dat$ = SPACE$(Size&)
  1528.  GET #1, Foff&, dat$
  1529.  PUT #3, , dat$
  1530.  CLOSE #3
  1531.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  1532.  
  1533. FUNCTION LoadFFX& (Foff&, Size&, Fize%%)
  1534.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1535.  OPEN "temp.dat" FOR BINARY AS #3
  1536.  dat$ = SPACE$(Size&)
  1537.  GET #1, Foff&, dat$
  1538.  PUT #3, , dat$
  1539.  CLOSE #3
  1540.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, "monospace")
  1541.  
  1542. FUNCTION LoadSFX& (Foff&, Size&)
  1543.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1544.  OPEN "temp.dat" FOR BINARY AS #3
  1545.  dat$ = SPACE$(Size&)
  1546.  GET #1, Foff&, dat$
  1547.  PUT #3, , dat$
  1548.  CLOSE #3
  1549.  LoadSFX& = _SNDOPEN("temp.dat")
  1550.  
  1551. SUB LoadData (Foff&, Size&)
  1552.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  1553.  OPEN "temp.dat" FOR BINARY AS #3
  1554.  dat$ = SPACE$(Size&)
  1555.  GET #1, Foff&, dat$
  1556.  PUT #3, , dat$
  1557.  CLOSE #3
  1558.  
  1559.  F1 = FREEFILE
  1560.  OPEN "temp.dat" FOR BINARY AS #F1
  1561.  GET #F1, , Hyrule()
  1562.  GET #F1, , Link
  1563.  GET #F1, , C
  1564.  GET #F1, , G
  1565.  GET #F1, , Offset_X()
  1566.  GET #F1, , Offset_Y()
  1567.  FOR I%% = 1 TO 44
  1568.   GET #F1, , Letter(I%%)
  1569.  NEXT I%%
  1570.  GET #F1, , KeyCodes()
  1571.  GET #F1, , Cave()
  1572.  GET #F1, , Item()
  1573.  GET #F1, , Shop()
  1574.  CLOSE #F1
  1575.  
  1576. SUB Select_Screen
  1577.  ClearLayer Layer(16)
  1578.  IF _FILEEXISTS("Zelda.MSF") THEN 'load saved data
  1579.   OPEN "Zelda.MSF" FOR BINARY AS #1
  1580.   FOR I%% = 1 TO 3 'load all 3 records
  1581.    GET #1, , Nick(I%%)
  1582.    GET #1, , Records(I%%)
  1583.    IF Selection%% = 0 THEN IF RTRIM$(Nick(I%%)) <> "" THEN Selection%% = I%%
  1584.   NEXT I%%
  1585.   CLOSE #1
  1586.  ELSE 'file doesn't exist so make it.
  1587.   Reset_Record 1
  1588.   Reset_Record 2
  1589.   Reset_Record 3
  1590.   Save_Records
  1591.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (1, 1)-STEP(255, 223) 'background
  1592.  FOR I%% = 1 TO 3
  1593.   IF RTRIM$(Nick(I%%)) <> "" THEN Place_Player_Record I%% - 1, 0
  1594.  NEXT I%%
  1595.  IF Record_Count%% = 0 THEN Selection%% = 4 ELSE Selection%% = 1
  1596.  Selection%% = Find_First_Available(0, 1)
  1597.  
  1598.  DO
  1599.   _PUTIMAGE , Layer(16), Layer(1)
  1600.   SELECT CASE Get_Input%%
  1601.    CASE START_BUTTON
  1602.     SELECT CASE Selection%%
  1603.      CASE 1 TO 3
  1604.       Link = Records(Selection%%)
  1605.       Exitflag%% = TRUE
  1606.      CASE 4
  1607.       DO: LOOP UNTIL Get_Input%% = -1
  1608.       nul%% = Register(nul%%)
  1609.       OPEN "Zelda.MSF" FOR BINARY AS #1 'update records
  1610.       FOR I%% = 1 TO 3
  1611.        PUT #1, , Nick(I%%)
  1612.        PUT #1, , Link
  1613.        IF RTRIM$(Nick(I%%)) <> "" THEN Place_Player_Record I%% - 1, 0
  1614.       NEXT I%%
  1615.       CLOSE #1
  1616.      CASE 5
  1617.       DO: LOOP UNTIL Get_Input%% = -1
  1618.       Elimination_Mode
  1619.       nul%% = Register(nul%%) 'go straight to register mode after elimination
  1620.      CASE 6 'options screen
  1621.       DO: LOOP UNTIL Get_Input%% = -1
  1622.       Options
  1623.     END SELECT
  1624.    CASE SELECT_BUTTON
  1625.     Selection%% = Selection%% + 1
  1626.     IF Selection%% = 7 THEN Selection%% = 1
  1627.     Selection%% = Find_First_Available(0, Selection%%)
  1628.     DO: LOOP UNTIL Get_Input%% = -1
  1629.    CASE ELSE
  1630.     _PRINTSTRING (0, 20), STR$(SELECT_BUTTON), Layer(1)
  1631.  
  1632.   SELECT CASE Selection%%
  1633.    CASE 1
  1634.     _PUTIMAGE (220, 242)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Player 1
  1635.    CASE 2
  1636.     _PUTIMAGE (220, 290)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Player 2
  1637.    CASE 3
  1638.     _PUTIMAGE (220, 338)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Player 3
  1639.    CASE 4
  1640.     _PUTIMAGE (220, 394)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'register
  1641.    CASE 5
  1642.     _PUTIMAGE (220, 426)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Elimination
  1643.    CASE 6
  1644.     _PUTIMAGE (220, 458)-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'Options
  1645.   _PRINTSTRING (0, 0), STR$(Selection%%), Layer(1)
  1646.   _PUTIMAGE , Layer(1), Layer(0)
  1647.   _LIMIT 60
  1648.   IF INKEY$ = CHR$(27) THEN Exitflag%% = TRUE
  1649.  LOOP UNTIL Exitflag%%
  1650.  
  1651. FUNCTION Register%% (Records%%)
  1652.  DIM Names(2, 8) AS STRING * 1
  1653.  Result%% = Records%%
  1654.  Tmp& = _COPYIMAGE(Layer(16))
  1655.  ClearLayer Layer(16)
  1656.  ClearLayer Layer(1)
  1657.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (258, 1)-STEP(255, 223) 'background
  1658.  FOR i%% = 1 TO 3
  1659.   IF RTRIM$(Nick(i%%)) <> "" THEN Place_Player_Record i%% - 1, 1
  1660.  NEXT i%%
  1661.  IF i%% > 0 THEN Selection%% = i%% ELSE Selection%% = 1
  1662.  FOR i%% = 1 TO 3
  1663.   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)
  1664.  NEXT i%%
  1665.  _CLEARCOLOR _RGB32(0), Layer(16)
  1666.  _PUTIMAGE , Layer(16), Layer(1)
  1667.  _DEST Layer(1)
  1668.  Current_Letter%% = 1
  1669.  Selection%% = Find_First_Available(1, 1)
  1670.  DO
  1671.  
  1672.   SELECT CASE Get_Input%%
  1673.    CASE Up
  1674.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  1675.     Ly% = Ly% - 1
  1676.     IF Ly% = -1 THEN Ly% = 3
  1677.     Current_Letter%% = Current_Letter%% - 11
  1678.     IF Current_Letter%% < 0 THEN Current_Letter%% = 44 - ABS(Current_Letter%%)
  1679.    CASE Down
  1680.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  1681.     Ly% = Ly% + 1
  1682.     IF Ly% = 4 THEN Ly% = 0
  1683.     Current_Letter%% = Current_Letter%% + 11
  1684.     IF Current_Letter%% > 44 THEN Current_Letter%% = Current_Letter%% - 44
  1685.    CASE Left
  1686.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  1687.     Lx% = Lx% - 1
  1688.     IF Lx% = -1 THEN Lx% = 10: Ly% = Ly% - 1: IF Ly% = -1 THEN Ly% = 3
  1689.     Current_Letter%% = Current_Letter%% - 1
  1690.     IF Current_Letter%% = 0 THEN Current_Letter%% = 44
  1691.    CASE Right
  1692.     _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  1693.     Lx% = Lx% + 1
  1694.     IF Lx% = 11 THEN Lx% = 0: Ly% = Ly% + 1: IF Ly% = 4 THEN Ly% = 0
  1695.     Current_Letter%% = Current_Letter%% + 1
  1696.     IF Current_Letter%% = 45 THEN Current_Letter%% = 1
  1697.    CASE BUTTON_A OR BUTTON_B
  1698.     IF Selection%% <> 4 THEN 'only allow buttons if valid name entry selection
  1699.      _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current Nick Letter
  1700.      Names(Selection%% - 1, Length%%) = Letter(Current_Letter%%)
  1701.      Length%% = Length%% + 1
  1702.      IF Length%% = 8 THEN Length%% = 0
  1703.     END IF
  1704.    CASE START_BUTTON
  1705.     SELECT CASE Selection%%
  1706.      CASE 4 'end
  1707.       FOR j%% = 0 TO 2
  1708.        a$ = ""
  1709.        IF RTRIM$(Nick(j%% + 1)) = "" THEN
  1710.         FOR i%% = 0 TO 7
  1711.          IF ASC(Names(j%%, i%%)) > 31 THEN a$ = a$ + Names(j%%, i%%)
  1712.         NEXT
  1713.         Nick(j%% + 1) = a$
  1714.        END IF
  1715.       NEXT
  1716.       ExitFlag%% = TRUE
  1717.     END SELECT
  1718.    CASE SELECT_BUTTON 'Change to different name or end registration
  1719.     _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current Nick Letter
  1720.     _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'heart selection
  1721.     Selection%% = Selection%% + 1: Length%% = 0 'reset the name position when changing.
  1722.     IF Selection%% = 5 THEN Selection%% = 1
  1723.     _PRINTSTRING (0, 0), STR$(Selection%%), Layer(1)
  1724.     Selection%% = Find_First_Available(1, Selection%%)
  1725.    CASE ELSE
  1726.     LINE (0, 0)-STEP(160, 40), _RGB32(0), BF
  1727.     _PRINTSTRING (0, 20), STR$(Selection%%), Layer(1)
  1728.   DO: LOOP UNTIL Get_Input%% = -1
  1729.  
  1730.   _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'heart selection
  1731.   IF Selection%% <> 4 THEN
  1732.    FOR j%% = 0 TO 8
  1733.     IF Names(Selection%% - 1, j%%) > CHR$(31) THEN _PRINTSTRING (364 + 16 * j%%, 152 + 48 * (Selection%% - 1)), Names(Selection%% - 1, j%%), Layer(1)
  1734.    NEXT j%%
  1735.   END IF
  1736.   _PUTIMAGE , Layer(1), Layer(0)
  1737.   IF blink%% AND Selection%% <> 4 THEN
  1738.    _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (61, 230)-STEP(7, 7) 'Current Nick Letter
  1739.    _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (61, 230)-STEP(7, 7) 'Current selected Letter
  1740.   ELSE
  1741.    _PUTIMAGE (364 + 16 * Length%%, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current Nick Letter
  1742.    _PUTIMAGE (236 + 32 * Lx%, 328 + 32 * Ly%)-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'Current selected Letter
  1743.   END IF
  1744.   _PUTIMAGE , Layer(16), Layer(1)
  1745.   b%% = b%% + 1
  1746.   IF b%% = 8 THEN blink%% = NOT blink%%: b%% = 0
  1747.   _LIMIT 60
  1748.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  1749.  LOOP UNTIL ExitFlag%%
  1750.  ClearLayer Layer(16)
  1751.  _PUTIMAGE , Tmp&, Layer(16)
  1752.  _FREEIMAGE Tmp&
  1753.  Save_Records
  1754.  FOR i%% = 1 TO 3
  1755.   IF RTRIM$(Nick(i%%)) <> "" THEN Place_Player_Record i%% - 1, 0
  1756.  NEXT i%%
  1757.  Register = Result%%
  1758.  
  1759. SUB Elimination_Mode
  1760.  Tmp& = _COPYIMAGE(Layer(16))
  1761.  ClearLayer Layer(16)
  1762.  ClearLayer Layer(1)
  1763.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (515, 1)-STEP(255, 223) 'background
  1764.  FOR i%% = 1 TO 3
  1765.   IF RTRIM$(Nick(i%%)) <> "" THEN Place_Player_Record i%% - 1, 1
  1766.  NEXT i%%
  1767.  _PUTIMAGE , Layer(16), Layer(0)
  1768.  IF i%% > 0 THEN Selection%% = i%% ELSE Selection%% = 1
  1769.  FOR i%% = 1 TO 3 'remove the erased game from the background screens
  1770.   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)
  1771.  NEXT i%%
  1772.  _CLEARCOLOR _RGB32(0), Layer(16)
  1773.  _PUTIMAGE , Layer(16), Layer(1)
  1774.  _DEST Layer(1)
  1775.  Current_Letter%% = 1
  1776.  Selection%% = 1
  1777.  DO
  1778.   _PUTIMAGE , Layer(16), Layer(1)
  1779.   SELECT CASE Get_Input%%
  1780.    CASE START_BUTTON
  1781.     SELECT CASE Selection%%
  1782.      CASE 1 TO 3
  1783.       Nick(Selection%%) = ""
  1784.       Reset_Record Selection%%
  1785.       _PUTIMAGE (364, 152 + 48 * (Selection%% - 1))-STEP(159, 31), Layer(12), Layer(16), (86, 240)-STEP(7, 7) 'black out
  1786.       _PUTIMAGE (236, 232 + 48 * (Selection%% - 1))-STEP(159, 33), Layer(12), Tmp&, (86, 240)-STEP(7, 7) 'black out name
  1787.       _PUTIMAGE (428, 232 + 48 * (Selection%% - 1))-STEP(127, 31), Layer(12), Tmp&, (86, 240)-STEP(7, 7) 'black out hearts
  1788.      CASE 4
  1789.       ExitFlag%% = TRUE
  1790.     END SELECT
  1791.    CASE SELECT_BUTTON
  1792.     _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'heart selection black out
  1793.     Selection%% = Selection%% + 1
  1794.     IF Selection%% = 5 THEN Selection%% = 1
  1795.    CASE ELSE
  1796.     _PRINTSTRING (0, 20), STR$(SELECT_BUTTON), Layer(1)
  1797.   DO: LOOP UNTIL Get_Input%% = -1
  1798.   _PUTIMAGE (274, 152 + 48 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (73, 267)-STEP(7, 7) 'heart selection
  1799.   _PUTIMAGE , Layer(1), Layer(0)
  1800.   _LIMIT 60
  1801.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  1802.  LOOP UNTIL ExitFlag%%
  1803.  ClearLayer Layer(16)
  1804.  _PUTIMAGE , Tmp&, Layer(16)
  1805.  _FREEIMAGE Tmp&
  1806.  
  1807. SUB Reset_Record (Which%%)
  1808.  Records(Which%%) = Reset_Link
  1809.  
  1810. SUB Save_Records
  1811.  OPEN "Zelda.MSF" FOR BINARY AS #1
  1812.  FOR I%% = 1 TO 3
  1813.   PUT #1, , Nick(I%%)
  1814.   PUT #1, , Records(I%%)
  1815.  NEXT I%%
  1816.  CLOSE #1
  1817.  
  1818. SUB Options
  1819.  STATIC BGMV AS SINGLE, SFXV AS SINGLE, MSTR AS SINGLE
  1820.  Selection%% = 1
  1821.  MSTR = G.MSTR_Vol / 100
  1822.  BGMV = G.BGM_vol / 100
  1823.  SFXV = G.SFX_Vol / 100
  1824.  
  1825.  Tmp& = _COPYIMAGE(Layer(16))
  1826.  ClearLayer Layer(16)
  1827.  ClearLayer Layer(1)
  1828.  _PUTIMAGE (140, 72)-STEP(511, 447), Layer(12), Layer(16), (772, 1)-STEP(255, 223) 'background
  1829.  _PRINTSTRING (128, 144), "Master Volume:", Layer(16)
  1830.  _PRINTSTRING (128, 176), "Music  Volume:", Layer(16)
  1831.  _PRINTSTRING (128, 208), "Sounds Volume:", Layer(16)
  1832.  _PRINTSTRING (128, 256), "Scale Factor :", Layer(16)
  1833.  _PRINTSTRING (128, 352), "Controler Setup", Layer(16)
  1834.  _PRINTSTRING (128, 384), "OPTIONS EXIT", Layer(16)
  1835.  _DEST Layer(1)
  1836.  DO
  1837.   _PUTIMAGE , Layer(16), Layer(1)
  1838.  
  1839.   SELECT CASE Get_Input%%
  1840.    CASE START_BUTTON
  1841.     SELECT CASE Selection%%
  1842.      CASE 1
  1843.       DO: LOOP UNTIL Get_Input%% = -1
  1844.       Custom_Controls
  1845.      CASE 2
  1846.       ExitFlag%% = TRUE
  1847.     END SELECT
  1848.    CASE SELECT_BUTTON
  1849.     _PUTIMAGE (112, 352 + 32 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (86, 240)-STEP(7, 7) 'heart selection black out
  1850.     Selection%% = Selection%% + 1
  1851.     IF Selection%% = 3 THEN Selection%% = 1
  1852.    CASE ELSE
  1853.   DO: LOOP UNTIL Get_Input%% = -1
  1854.  
  1855.    IF Locked%% = 0 THEN 'player just clicked mouse
  1856.     X% = _MOUSEX: y% = _MOUSEY
  1857.     IF X% > 359 AND X% < 617 THEN 'mouse is in the volume slider area
  1858.      IF y% > 143 AND y% < 160 THEN Locked%% = 1 'master volume slider selected
  1859.      IF y% > 175 AND y% < 192 THEN Locked%% = 2 'Music volume slider selected
  1860.      IF y% > 207 AND y% < 224 THEN Locked%% = 3 'Sounds volume slider selected
  1861.      IF y% > 255 AND y% < 272 THEN Locked%% = 4 'Scale slider selected
  1862.     END IF
  1863.    ELSE 'player has a selected volume slider
  1864.     X% = _MOUSEX
  1865.     IF X% > 359 AND X% < 617 THEN 'mouse is in the volume slider area
  1866.      NewVol! = (X% - 359) / 256
  1867.      SELECT CASE Locked%%
  1868.       CASE 1 'set new master volume
  1869.        MSTR = NewVol!
  1870.       CASE 2 'set new Music volume
  1871.        BGMV = NewVol!
  1872.       CASE 3 'set new sounds volume
  1873.        SFXV = NewVol!
  1874.       CASE 4 'set new scale
  1875.        SELECT CASE NewVol!
  1876.         CASE 0 TO .33 '1x scale
  1877.          G.Scale_Factor = 1
  1878.         CASE .34 TO .66 '2x scale
  1879.          G.Scale_Factor = 2
  1880.         CASE .67 TO 1 '3x scale
  1881.          G.Scale_Factor = 3
  1882.        END SELECT
  1883.      END SELECT
  1884.     END IF
  1885.    END IF
  1886.   ELSEIF Locked%% THEN 'player released the mouse button
  1887.    Locked%% = FALSE
  1888.   END IF
  1889.   Update_Volume_Bars MSTR, BGMV, SFXV
  1890.   _PUTIMAGE (112, 352 + 32 * (Selection%% - 1))-STEP(15, 15), Layer(12), Layer(1), (73, 247)-STEP(7, 7) 'heart selection
  1891.   _PUTIMAGE , Layer(1), Layer(0)
  1892.   _LIMIT 60
  1893.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  1894.  LOOP UNTIL ExitFlag%%
  1895.  '------Make the changes final-----
  1896.  G.MSTR_Vol = INT(MSTR * 100)
  1897.  G.BGM_vol = INT(BGMV * MSTR * 100)
  1898.  G.SFX_Vol = INT(SFXV * MSTR * 100)
  1899.  G.Scale_X = 16 * G.Scale_Factor - 1
  1900.  G.Scale_Y = 16 * G.Scale_Factor - 1
  1901.  Link.Screen_X = Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor * 7) + 8 * G.Scale_Factor '392
  1902.  Link.Screen_Y = Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor * 5) '292
  1903.  '---------------------------------
  1904.  ClearLayer Layer(16)
  1905.  _PUTIMAGE , Tmp&, Layer(16)
  1906.  _FREEIMAGE Tmp&
  1907.  
  1908. SUB Update_Volume_Bars (M!, B!, S!)
  1909.  LINE (360, 144)-STEP(16 * 16, 16), _RGB32(0 + INT(255 * M!), 255 - INT(255 * M!), 0), BF
  1910.  LINE (360, 176)-STEP(16 * 16, 16), _RGB32(0 + INT(255 * (B! * M!)), 255 - INT(255 * (B! * M!)), 0), BF
  1911.  LINE (360, 208)-STEP(16 * 16, 16), _RGB32(0 + INT(255 * (S! * M!)), 255 - INT(255 * (S! * M!)), 0), BF
  1912.  LINE (360, 256)-STEP(16 * 16, 16), _RGB32(0 + 128 * (G.Scale_Factor - 1), 255 - 128 * (G.Scale_Factor - 1), 0), BF
  1913.  LINE (360 + (256 * M!), 144)-STEP(1, 20), _RGB32(224, 224, 224), B
  1914.  LINE (360 + (256 * B!), 176)-STEP(1, 20), _RGB32(224, 224, 224), B
  1915.  LINE (360 + (256 * S!), 208)-STEP(1, 20), _RGB32(224, 224, 224), B
  1916.  LINE (360 + 128 * (G.Scale_Factor - 1), 256)-STEP(1, 20), _RGB32(224, 224, 224), B
  1917.  _PRINTSTRING (640, 144), LTRIM$(STR$(INT(M! * 100))) + "%"
  1918.  _PRINTSTRING (640, 176), LTRIM$(STR$(INT((B! * M!) * 100))) + "%"
  1919.  _PRINTSTRING (640, 208), LTRIM$(STR$(INT((S! * M!) * 100))) + "%"
  1920.  _PRINTSTRING (640, 256), LTRIM$(STR$(G.Scale_Factor)) + "x"
  1921.  a$ = LTRIM$(STR$(256 * G.Scale_Factor)) + "x" + LTRIM$(STR$(224 * G.Scale_Factor))
  1922.  _PRINTSTRING (440, 276), a$
  1923.  

45
QB64 Discussion / Re: Small hiccup in ABS
« on: January 04, 2022, 09:29:08 pm »
So be it.

The wiki has been updated to NOTE this limitation of ABS to save future users the headache.

You may double check my wording to make sure I have it correct.

Pages: 1 2 [3] 4 5 ... 59