'Zelda Clone take 2
LoadedGame
AS _BYTE 'which game is loaded?(1-3)
Id
AS _BYTE ' Kind of projectile; Sword\Arrow\Rock\Ball Direction
AS _BYTE 'Direction Projectile is traveling Hits
AS _BYTE ' Hits per projectile\(AKA:damage) in half heart increments Owner
AS _BYTE ' Who shot the projectile
'-----Position data-----
World
AS _BYTE ' Player in Overworld or Underworld World_X
AS _BYTE ' Overworld X position World_Y
AS _BYTE ' Overworld Y position Tile_Y
AS _BYTE ' Array Y location:for Collision\entrances Direction
AS _BYTE ' Direction player is moving\facing '-----------------------
'------Status Data------
Hearts
AS _BYTE ' Units of health: 2 units(halves) per heart Containers
AS _BYTE 'Max number of health: total full hearts Hits
AS _BYTE ' Used when Link has defence rings;Blue = 2 hits per 1\2 heart, Red = 4 hits per 1\2 heart '-----------------------
'------Items Data-------
Sword
AS _BYTE ' which Sword does player have? Wooden-1,Silver-2,Magical-3 Weapon
AS _BYTE 'Which Weapon is in hand A? Wooden-1,Silver-2,Magical-3,Wand-4 Ring
AS _BYTE 'which does player have? 0-none, 1-blue,2-red '-----------------------
'------Extra Data-------
Action
AS _BYTE ' is player; using an item, Aquiring an item\sword, or aquiring a piece of the triforce? Shot
AS _BYTE ' player has shot sword Beaten
AS _BYTE ' Has player beaten Game 1? Game 2? '-----------------------
Hidden
AS _BYTE ' is there something under the tile? Burnable
AS _BYTE ' can the tile be burnt with candle? Pushable
AS _BYTE ' can the tile be moved by pushing? PushableXtra
AS _BYTE 'can the tile be moved by pushing with braclet? Is_Shop
AS _BYTE ' is there a shop here?(shop\gift\gamble) Walkable
AS _BYTE ' can the tile be walk upon?
CONST TRUE
= -1, FALSE
= NOT TRUE
, None
= 0 CONST Up
= 3, Right
= 2, Left
= 1, Down
= 0, SELECT_BUTTON
= 4, START_BUTTON
= 5, BUTTON_B
= 6, BUTTON_A
= 7 CONST OverWorld
= 0, UnderWorld
= 1 CONST Walking
= 1, Useing
= 2, GetItem
= 3, GetTriforce
= 4, Attack
= 5 CONST Key_Right
= 19712, Key_Left
= 19200, Key_Up
= 18432, Key_Down
= 20480 CONST Key_Space
= 32, Key_Enter
= 13 CONST Default_Key_Right
= 19712, Default_Key_Left
= 19200, Default_Key_Up
= 18432, Default_Key_Down
= 20480 CONST Default_A_Button
= 32, Default_B_Button
= 13, Default_Start_Button
= 65, Default_Select_Button
= 66 CONST Sword
= 1, Arrow
= 2, Rock
= 3, Ball
= 4, Boomerang
= 5 CONST Player
= 1, Monster
= 2 CONST Item
= 0, Slash
= 1, Stairs
= 2, SwordShot
= 3
Layer
(1) = _NEWIMAGE(800, 600, 32) 'temp layerLayer
(2) = _NEWIMAGE(640, 480, 256) 'palettized sprite sheet for color shiftingLayer
(3) = _NEWIMAGE(800, 600, 32) 'Map background prebuild layerLayer
(4) = _NEWIMAGE(800, 600, 32) 'Mob layerLayer
(5) = _NEWIMAGE(800, 600, 32) 'Sprite layer, moveable\burnable items + bomb holes + pickupsLayer
(6) = _NEWIMAGE(12288, 4224, 32) 'PreBuilt Map, upto 300%, for easier map scrolling.Layer
(8) = _NEWIMAGE(800, 600, 32) 'debug map display
MFI_Loader "Zelda.MFI"
'==================================
G.Scale_Factor = 1
G.Scale_X = 16 * G.Scale_Factor - 1
G.Scale_Y = 16 * G.Scale_Factor - 1
Link.Screen_X = Offset_X(G.Scale_Factor) + (16 * G.Scale_Factor * 7) + 8 * G.Scale_Factor '392
Link.Screen_Y = Offset_Y(G.Scale_Factor) + (16 * G.Scale_Factor * 5) '292
Nick(0) = "": Nick(1) = "": Nick(2) = "": Nick(3) = ""
'==================================
'OPEN "debug.txt" FOR OUTPUT AS #6
Build_Map_Screen 16 * Link.World_X, 11 * Link.World_Y
ClearLayer Layer(6)
Build_Map_in_Totallity 'prebuild the entire map at the current scale factor
ClearLayer Layer(1)
Title_Screen
Select_Screen
IF G.Aframe
= 0 AND G.Atime
= 0 THEN _SNDPLAY SFX
(Slash
): Link.Action
= Attack: Press
= Press
+ 1 Check_Link_Sword_Shot
IF Link.Action
<> Attack
THEN Link.Direction
= Up: Link.Action
= Walking
IF Link.Action
<> Attack
THEN Link.Direction
= Down: Link.Action
= Walking
IF Link.Action
<> Attack
THEN Link.Direction
= Right: Link.Action
= Walking
IF Link.Action
<> Attack
THEN Link.Direction
= Left: Link.Action
= Walking
IF Link.Action
= Walking
THEN Link.Action
= None
IF Link.Action
= GetItem
OR Link.Action
= GetTriforce
THEN '------Graphx build------
IF Link.Action
= Walking
THEN Move_Link
IF Link.Shot
THEN Move_Sword_Shot
IF G.Impactflag
THEN Impact
0, 0 Place_Link
' _PRINTSTRING (0, 0), STR$(Link.Tile_X) + STR$(Link.Tile_Y) + STR$(G.Projectile_Count), Layer(1)
LINE (100 + 2 * Link.Tile_X
, 0 + 2 * Link.Tile_Y
)-STEP(1, 1), _RGB32(255, 255, 0), BF
ClearLayer Layer(1)
'------------------------
SUB Add_Projectile
(What%%
, Who%%
) P(G.Projectile_Count).Owner = Who%%
P(G.Projectile_Count).Id = Sword
P(G.Projectile_Count).Direction = Link.Direction
P(G.Projectile_Count).Xloc = Link.Screen_X
P(G.Projectile_Count).Yloc = Link.Screen_Y
G.Projectile_Count = G.Projectile_Count + 1
SUB Remove_Projectile
(What%%
, Who%%
) G.Projectile_Count = G.Projectile_Count - 1
Place_Tile_On_Screen (16 * G.Scale_Factor) * X%%, (16 * G.Scale_Factor) * Y%%, Cave(X%%, Y%%).Id, Layer(3)
SUB Build_Map_Screen
(Map_X~%%
, Map_Y%%
) Place_Tile_On_Screen (16 * G.Scale_Factor) * X%%, (16 * G.Scale_Factor) * Y%%, Hyrule(Map_X~%% + X%%, Map_Y%% + Y%%).Id, Layer(3)
IF Hyrule
(x~%%
, Y%%
).Walkable
= FALSE
THEN LINE (100 + 2 * x~%%
, 0 + 2 * Y%%
)-STEP(1, 1), _RGB32(255), BF
SUB Build_Map_in_Totallity
tile~%% = Hyrule(X~%%, Y%%).Id
Gy% = 17 * (tile~%% \ 20) 'get which row it comes from
Gx%
= 17 * (tile~%%
MOD 20) 'which column position _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)
Ax% = Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
Ay% = Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
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
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
IF Hyrule
(Tx~%%
, Ty%%
).Is_Shop
THEN Enter_Shop Hyrule
(Tx~%%
, Ty%%
).Is_Shop
SUB Check_Link_Sword_Shot
'Can Link shoot his sword? IF Link.Hearts
= Link.Containers
* 2 THEN 'Link has full hearts and can shoot IF NOT G.Impactflag
THEN 'Link's last shot has finished Link.Shot = TRUE
Add_Projectile Sword, Player
DIM Frac_Value
AS LONG: Frac_Value
= Value_From_0_To_1
* 65536 'Used to avoid slow floating point calculations O = Buffer.OFFSET 'We start at this offset
O_Last
= Buffer.OFFSET
+ _WIDTH(Image
) * _HEIGHT(Image
) * 4 'We stop when we get to this offset 'use on error free code ONLY!
O = O + 4
'turn checking back on when done!
DarkenImage i2&, n!
DarkenImage i2&, n!
FUNCTION Find_First_Available%%
(Which%%
, Start%%
) Selection%% = Start%% 'always start at the first saved game slot then check
DO 'lets find the first available selection (if there are any saved games) IF Which%%
= 0 THEN IF RTRIM$(Nick
(Selection%%
)) = "" THEN Selection%%
= Selection%%
+ 1 ELSE Good_Selection%%
= TRUE
IF Which%%
= 1 THEN IF RTRIM$(Nick
(Selection%%
)) = "" THEN Good_Selection%%
= TRUE
ELSE Selection%%
= Selection%%
+ 1 ELSE '4 and 5 are always good selections Good_Selection%% = TRUE
Find_First_Available = Selection%%
Result%% = TRUE '-1 for no input
' SELECT CASE G.ControlType
' CASE TRUE 'Keyboard input
IF _KEYDOWN(C.KBCon_Select
) THEN Result%%
= SELECT_BUTTON:
' DO: LOOP WHILE _KEYDOWN(C.KBCon_Select) IF _KEYDOWN(C.KBCon_Start
) THEN Result%%
= START_BUTTON:
' DO: LOOP WHILE _KEYDOWN(C.KBCon_Start) IF _KEYDOWN(C.KBCon_A_Button
) THEN Result%%
= BUTTON_A:
' DO: LOOP WHILE _KEYDOWN(C.KBCon_A_Button) IF _KEYDOWN(C.KBCon_B_Button
) THEN Result%%
= BUTTON_B:
' DO: LOOP WHILE _KEYDOWN(C.KBCon_B_Button) ' CASE FALSE 'joystick input
'IF C.Control_Pad THEN
'IF NOT G.Flag THEN DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad)
'IF NOT C.BAD_Pad THEN
' nul%% = AxisPower(CJR%%, CJL%%, CJU%%, CJD%%) 'read directional axis values
' IF CJU%% THEN Result%% = Up
' IF CJD%% THEN Result%% = Down
' IF CJL%% THEN Result%% = Left
' IF CJR%% THEN Result%% = Right
'ELSE
' IF _BUTTON(C.Joy_Button_Up) THEN Result%% = Up ': Joy_Lock_Button (C.Joy_Button_Up)
' IF _BUTTON(C.Joy_Button_Down) THEN Result%% = Down ': Joy_Lock_Button (C.Joy_Button_Down)
' IF _BUTTON(C.Joy_Button_Left) THEN Result%% = Left ': Joy_Lock_Button (C.Joy_Button_Left)
' IF _BUTTON(C.Joy_Button_Right) THEN Result%% = Right ': Joy_Lock_Button (C.Joy_Button_Right)
' END IF
' IF _BUTTON(C.Joy_Select) THEN Result%% = SELECT_BUTTON: Joy_Lock_Button (C.Joy_Select)
' IF _BUTTON(C.Joy_Start) THEN Result%% = START_BUTTON: Joy_Lock_Button (C.Joy_Start)
' IF _BUTTON(C.Joy_A_Button) THEN Result%% = BUTTON_A: Joy_Lock_Button (C.Joy_A_Button)
' IF _BUTTON(C.Joy_B_Button) THEN Result%% = BUTTON_B: Joy_Lock_Button (C.Joy_B_Button)
' END IF
' END SELECT
Get_Input = Result%%
Ox%% = 0: Oy%% = -14 * G.Scale_Factor
Ox%% = 0: Oy%% = 14 * G.Scale_Factor
Ox%% = -14 * G.Scale_Factor + G.Aframe * (4 * G.Scale_Factor): Oy%% = 0
Ox%% = 14 * G.Scale_Factor - G.Aframe * (4 * G.Scale_Factor): Oy%% = 0
_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) _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) _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) _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) _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) _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) _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) G.Atime = 0: G.Aframe = 0: Link.Action = None
_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)
Result%% = FALSE 'start at no collision
'get links center point x\y tile position to check for collision
Ax% = Link.World_X * 16 * (16 * G.Scale_Factor) 'gets the Left most pixel point for the current map screen
Ay% = Link.World_Y * 11 * (16 * G.Scale_Factor) 'gets the Top most pixel point for the current map screen
'we now have the tile that Links center pixel is in!
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
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
IF NOT Hyrule
(Tx~%%
, Ty%%
).Walkable
THEN Result%%
= TRUE
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
Ty%% = (2 + Ay% + Link.Screen_Y - Offset_Y(G.Scale_Factor) + 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent y-offset+50% sprite size
IF NOT Hyrule
(Tx~%%
, Ty%%
).Walkable
THEN Result%%
= TRUE
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
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
IF NOT Hyrule
(Tx~%%
, Ty%%
).Walkable
THEN Result%%
= TRUE
Tx~%% = (2 + Ax% + Link.Screen_X - Offset_X(G.Scale_Factor) + 2 + (16 * G.Scale_Factor \ 2)) \ 16 * G.Scale_Factor 'now add curent x-offset+50% sprite size
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
IF NOT Hyrule
(Tx~%%
, Ty%%
).Walkable
THEN Result%%
= TRUE
Link.Tile_X = Tx~%%
Link.Tile_Y = Ty%%
Link_Collision = Result%%
IF NOT Link_Collision
(Up
) THEN 'nothing blocking Link IF Link.Screen_Y
> Offset_Y
(G.Scale_Factor
) THEN 'Link is not at the edge of the screen Link.Screen_Y = Link.Screen_Y - 2 * G.Scale_Factor
ELSE 'player is at edge of screen to shift to next one. G.NextScreen = Up
Shift_New_Map_Screen
IF NOT Link_Collision
(Down
) THEN 'nothing blocking Link IF Link.Screen_Y
< (Offset_Y
(G.Scale_Factor
) + (16 * G.Scale_Factor
* 10)) THEN 'Link is not at the edge of the screen Link.Screen_Y = Link.Screen_Y + 2 * G.Scale_Factor
ELSE 'player is at edge of screen to shift to next one. G.NextScreen = Down
Shift_New_Map_Screen
IF NOT Link_Collision
(Left
) THEN 'nothing blocking Link IF Link.Screen_X
> Offset_X
(G.Scale_Factor
) THEN 'Link is not at the edge of the screen Link.Screen_X = Link.Screen_X - 2 * G.Scale_Factor
ELSE 'player is at edge of screen to shift to next one. G.NextScreen = Left
Shift_New_Map_Screen
IF NOT Link_Collision
(Right
) THEN 'nothing blocking Link IF Link.Screen_X
< (Offset_X
(G.Scale_Factor
) + (16 * G.Scale_Factor
* 15)) THEN 'Link is not at the edge of the screen Link.Screen_X = Link.Screen_X + 2 * G.Scale_Factor
ELSE 'player is at edge of screen to shift to next one. G.NextScreen = Right
Shift_New_Map_Screen
IF Direction
= -1 OR Xloc
= 0 THEN 'if no direction assigned then assign one Direction = Link.Direction
Xloc = Link.Screen_X
Yloc = Link.Screen_Y
Yloc = Yloc - 4 * G.Scale_Factor
Yloc = Yloc + 4 * G.Scale_Factor
Xloc = Xloc - 4 * G.Scale_Factor
Xloc = Xloc + 4 * G.Scale_Factor
_PUTIMAGE (Xloc
, Yloc
)-STEP(G.Scale_X
, G.Scale_Y
), Layer
(7), Layer
(1), (1 + 17 * Frame
+ 68 * Direction
, 239)-STEP(15, 15) IF Xloc
<= 272 OR Xloc
>= 514 OR Yloc
<= 212 OR Yloc
>= 372 THEN Done%%
= TRUE
IF Xloc
<= 140 OR Xloc
>= 630 OR Yloc
<= 100 OR Yloc
>= 430 THEN Done%%
= TRUE
IF Xloc
<= 16 OR Xloc
>= 744 OR Yloc
<= 96 OR Yloc
>= 559 THEN Done%%
= TRUE
IF Done%%
THEN Link.Shot
= FALSE: G.Impactflag
= TRUE: Impact Xloc
, Yloc: Direction
= -1: Remove_Projectile Sword
, Player
Fstp = Fstp + 1
IF Fstp
= 2 THEN Fstp
= 0: Frame
= Frame
+ 1
Fstp = 0
FOR i%%
= 0 TO 3: Xloc
(i%%
) = X%
+ 8 * G.Scale_Factor: Yloc
(i%%
) = Y%
+ 8 * G.Scale_Factor:
NEXT i%%
Xloc(0) = Xloc(0) - G.Scale_Factor: Yloc(0) = Yloc(0) - G.Scale_Factor
Xloc(1) = Xloc(1) + G.Scale_Factor: Yloc(1) = Yloc(1) - G.Scale_Factor
Xloc(2) = Xloc(2) + G.Scale_Factor: Yloc(2) = Yloc(2) + G.Scale_Factor
Xloc(3) = Xloc(3) - G.Scale_Factor: Yloc(3) = Yloc(3) + G.Scale_Factor
_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) _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) _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) _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) Fstp = Fstp + 1
Frame = Frame + 1
IF Fstp
= 16 THEN Frame
= -1: G.Impactflag
= FALSE
IF Link.Action
= Walking
THEN 'while Link is moving G.Wtime = G.Wtime + 1 'Increment frame time
IF G.Wframe
THEN G.Wframe
= 0 ELSE G.Wframe
= 1 'change frame G.Wtime = 0 'reset frame time
_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) ELSEIF Link.Action
= Useing
THEN 'when Link uses an item Ftime = Ftime + 1 'Increment frame time
IF Ftime
= 32 THEN Link.Action
= None: Ftime
= 0 'action is done _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) ELSEIF Link.Action
= GetItem
THEN 'When Link gets a sword\item or buys something 'Held while music plays
_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) ELSEIF Link.Action
= GetTriforce
THEN 'When Link recovers a Triforce piece 'Held while music plays
_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) G.Atime = G.Atime + 1 'Increment frame time
IF G.Atime
= 4 THEN G.Aframe
= G.Aframe
+ 1: G.Atime
= 0 'change frame:reset frame time Link_Attack
ELSE 'Link is standing Still(Action=None) G.Atime = 0: G.Aframe = 0
G.Wtime = 0: G.Wframe = 0
_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)
SUB Place_Player_Record
(I%%
, Where%
) 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 _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) FOR j%%
= 1 TO Records
(I%%
+ 1).Containers
IF j%%
< 4 THEN 'first 3 hearts are red _PUTIMAGE (428 + 16 * j%%
, 232 + 48 * I%%
)-STEP(15, 15), Layer
(12), Layer
(16), (52, 230)-STEP(7, 7) 'Player 1 hearts red _PUTIMAGE (428 + 16 * j%%
, 232 + 48 * I%%
)-STEP(15, 15), Layer
(12), Layer
(16), (73, 267)-STEP(7, 7) 'Player 1 hearts white _PUTIMAGE (428 + 16 * (j%%
- 8), 232 + 64 * I%%
)-STEP(15, 15), Layer
(12), Layer
(16), (73, 267)-STEP(7, 7) 'Player 1 hearts white 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 _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)
SUB Place_Tile_On_Screen
(X%
, Y%
, Tile~%%
, L&
) Gy% = 17 * (Tile~%% \ 20) 'get which row it comes from
Gx%
= 17 * (Tile~%%
MOD 20) 'which column position _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)
SUB Scroll_Screen_II
(Dir%%
) Cx% = Offset_X(G.Scale_Factor) 'top left corner location of map displayed
Cy% = Offset_Y(G.Scale_Factor)
Sfx% = 16 * 16 * G.Scale_Factor 'size of the map display
Sfy% = 11 * 16 * G.Scale_Factor
Lwx% = 16 * 16 * G.Scale_Factor * Link.World_X 'map area link is in
Lwy% = 11 * 16 * G.Scale_Factor * Link.World_Y
_PUTIMAGE (Cx%
, Cy%
)-STEP(Sfx%
, Sfy%
), Layer
(6), Layer
(1), (Lwx%
, Lwy%
- y%
)-STEP(Sfx%
, Sfy%
) IF y%
> 16 * G.Scale_Factor
THEN Link.Screen_Y
= Link.Screen_Y
+ 2 * G.Scale_Factor
Place_Link
Link.World_Y = Link.World_Y - 1
_PUTIMAGE (Cx%
, Cy%
)-STEP(Sfx%
, Sfy%
), Layer
(6), Layer
(1), (Lwx%
, Lwy%
+ y%
)-STEP(Sfx%
, Sfy%
) IF y%
> 16 * G.Scale_Factor
THEN Link.Screen_Y
= Link.Screen_Y
- 2 * G.Scale_Factor
Place_Link
Link.World_Y = Link.World_Y + 1
_PUTIMAGE (Cx%
, Cy%
)-STEP(Sfx%
, Sfy%
), Layer
(6), Layer
(1), (Lwx%
- x%
, Lwy%
)-STEP(Sfx%
, Sfy%
) IF x%
> 16 * G.Scale_Factor
THEN Link.Screen_X
= Link.Screen_X
+ 2 * G.Scale_Factor
Place_Link
Link.World_X = Link.World_X - 1
_PUTIMAGE (Cx%
, Cy%
)-STEP(Sfx%
, Sfy%
), Layer
(6), Layer
(1), (Lwx%
+ x%
, Lwy%
)-STEP(Sfx%
, Sfy%
) IF x%
> 16 * G.Scale_Factor
THEN Link.Screen_X
= Link.Screen_X
- 2 * G.Scale_Factor
Place_Link
Link.World_X = Link.World_X + 1
Place_Link
Lwx% = 16 * 16 * G.Scale_Factor * Link.World_X
Lwy% = 11 * 16 * G.Scale_Factor * Link.World_Y
_PUTIMAGE (Cx%
, Cy%
)-STEP(Sfx%
, Sfy%
), Layer
(6), Layer
(3), (Lwx%
, Lwy%
)-STEP(Sfx%
, Sfy%
) 'move new screen to layer(3)
Scroll_Screen_II Up
Scroll_Screen_II Down
Scroll_Screen_II Left
Scroll_Screen_II Right
G.NextScreen = -1
F%% = 0: F% = 0: ExitFlag%% = FALSE
_PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (0, 0)-STEP(255, 223) _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer
(9), Layer
(1), (289, 0)-STEP(71, 71) _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer
(9), Layer
(1), (289, 0 + 72)-STEP(71, 71) _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer
(9), Layer
(1), (289, 0 + 144)-STEP(71, 71) _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer
(9), Layer
(1), (289, 0 + 72)-STEP(71, 71) _PUTIMAGE (400 - 74, 300 - 128)-STEP(143, 143), Layer
(9), Layer
(1), (289, 0 + 0)-STEP(71, 71) _PUTIMAGE (304, 523 - 112), Layer
(10), Layer
(1), (0 + 64 * wave%%
, 0)-STEP(63, 111) F%% = F%% + 1
IF wave%%
= 16 THEN wave%%
= 0 IF Get_Input
= START_BUTTON
THEN ExitFlag%%
= TRUE
'start the title fade
F%% = 0
_PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (361, 0)-STEP(255, 223) _PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (361, 0)-STEP(255, 223) _PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (361, 0)-STEP(255, 223) _PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (617, 0)-STEP(255, 223) _PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (617, 0)-STEP(255, 223) _PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (617, 0)-STEP(255, 223) _PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (873, 0)-STEP(255, 223) Wf% = 112
_PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (1129, 0)-STEP(255, 223) Wf% = 224
_PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (1385, 0)-STEP(255, 223) Wf% = 336
_PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (1641, 0)-STEP(255, 223) Wf% = 448
_PUTIMAGE ((800 - 512) \
2, (600 - 448) \
2)-STEP(511, 447), Layer
(9), Layer
(1), (1897, 0)-STEP(255, 223) Wf% = 560
_PUTIMAGE (304, 523 - 112), Layer
(10), Layer
(1), (0 + 64 * wave%%
, 0 + Wf%
)-STEP(63, 111) F% = F% + 1
IF F%
= 394 THEN ExitFlag%%
= TRUE
IF wave%%
= 16 THEN wave%%
= 0 IF Get_Input
= START_BUTTON
THEN ExitFlag%%
= TRUE
ExitFlag%% = FALSE
ClearLayer Layer(0)
ClearLayer Layer(1)
'Title scroll
F% = 0
_PUTIMAGE (144, 76)-STEP(511, 447), Layer
(11), Layer
(1), (0, -223 + F%
)-STEP(255, 223) _PUTIMAGE (120, 1432)-STEP(15, 15), Layer
(7), Layer
(11), (239, 188)-STEP(15, 15) 'Triforce _PUTIMAGE (120, 1432)-STEP(15, 15), Layer
(7), Layer
(11), (222, 188)-STEP(15, 15) 'Triforce _PUTIMAGE (72, 400)-STEP(7, 15), Layer
(7), Layer
(11), (256, 188)-STEP(7, 15) 'fairy blank _PUTIMAGE (72, 400)-STEP(7, 15), Layer
(7), Layer
(11), (256, 188)-STEP(7, 15) 'fairy blank _PUTIMAGE (144, 76)-STEP(511, 447), Layer
(11), Layer
(1), (0, F%
- 354)-STEP(255, 223) F% = F% + 1
IF F%
= 1762 THEN F%
= F%
- 1 'ExitFlag%% = TRUE B% = B% + 1
IF Get_Input
= START_BUTTON
THEN ExitFlag%%
= TRUE
ExitFlag%% = FALSE
Result%% = FALSE
FOR i%%
= 0 TO G.Projectile_Count
Projectile_Collision = Result%%
ClearLayer Layer(16)
FOR I%%
= 1 TO 3 'load all 3 records ELSE 'file doesn't exist so make it. Reset_Record 1
Reset_Record 2
Reset_Record 3
Save_Records
_PUTIMAGE (140, 72)-STEP(511, 447), Layer
(12), Layer
(16), (1, 1)-STEP(255, 223) 'background IF RTRIM$(Nick
(I%%
)) <> "" THEN Place_Player_Record I%%
- 1, 0 IF Record_Count%%
= 0 THEN Selection%%
= 4 ELSE Selection%%
= 1 Selection%% = Find_First_Available(0, 1)
Link = Records(Selection%%)
Exitflag%% = TRUE
nul%% = Register(nul%%)
IF RTRIM$(Nick
(I%%
)) <> "" THEN Place_Player_Record I%%
- 1, 0 Elimination_Mode
nul%% = Register(nul%%) 'go straight to register mode after elimination
Selection%% = Selection%% + 1
IF Selection%%
= 6 THEN Selection%%
= 1 Selection%% = Find_First_Available(0, Selection%%)
_PUTIMAGE (220, 242)-STEP(15, 15), Layer
(12), Layer
(1), (73, 247)-STEP(7, 7) 'Player 1 _PUTIMAGE (220, 290)-STEP(15, 15), Layer
(12), Layer
(1), (73, 247)-STEP(7, 7) 'Player 2 _PUTIMAGE (220, 338)-STEP(15, 15), Layer
(12), Layer
(1), (73, 247)-STEP(7, 7) 'Player 3 _PUTIMAGE (220, 394)-STEP(15, 15), Layer
(12), Layer
(1), (73, 247)-STEP(7, 7) 'register _PUTIMAGE (220, 426)-STEP(15, 15), Layer
(12), Layer
(1), (73, 247)-STEP(7, 7) 'Elimination
Result%% = Records%%
ClearLayer Layer(16)
ClearLayer Layer(1)
_PUTIMAGE (140, 72)-STEP(511, 447), Layer
(12), Layer
(16), (258, 1)-STEP(255, 223) 'background IF RTRIM$(Nick
(i%%
)) <> "" THEN Place_Player_Record i%%
- 1, 1 IF i%%
> 0 THEN Selection%%
= i%%
ELSE Selection%%
= 1 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) Current_Letter%% = 1
Selection%% = Find_First_Available(1, 1)
_PUTIMAGE (236 + 32 * Lx%
, 328 + 32 * Ly%
)-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current selected Letter Ly% = Ly% - 1
Current_Letter%% = Current_Letter%% - 11
IF Current_Letter%%
< 0 THEN Current_Letter%%
= 44 - ABS(Current_Letter%%
) _PUTIMAGE (236 + 32 * Lx%
, 328 + 32 * Ly%
)-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current selected Letter Ly% = Ly% + 1
Current_Letter%% = Current_Letter%% + 11
IF Current_Letter%%
> 44 THEN Current_Letter%%
= Current_Letter%%
- 44 _PUTIMAGE (236 + 32 * Lx%
, 328 + 32 * Ly%
)-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current selected Letter Lx% = Lx% - 1
IF Lx%
= -1 THEN Lx%
= 10: Ly%
= Ly%
- 1:
IF Ly%
= -1 THEN Ly%
= 3 Current_Letter%% = Current_Letter%% - 1
IF Current_Letter%%
= 0 THEN Current_Letter%%
= 44 _PUTIMAGE (236 + 32 * Lx%
, 328 + 32 * Ly%
)-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current selected Letter Lx% = Lx% + 1
IF Lx%
= 11 THEN Lx%
= 0: Ly%
= Ly%
+ 1:
IF Ly%
= 4 THEN Ly%
= 0 Current_Letter%% = Current_Letter%% + 1
IF Current_Letter%%
= 45 THEN Current_Letter%%
= 1 IF Selection%%
<> 4 THEN 'only allow buttons if valid name entry selection _PUTIMAGE (364 + 16 * Length%%
, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current Nick Letter Names(Selection%% - 1, Length%%) = Letter(Current_Letter%%)
Length%% = Length%% + 1
IF Length%%
= 8 THEN Length%%
= 0 a$ = ""
IF ASC(Names
(j%%
, i%%
)) > 31 THEN a$
= a$
+ Names
(j%%
, i%%
) Nick(j%% + 1) = a$
ExitFlag%% = TRUE
CASE SELECT_BUTTON
'Change to different name or end registration _PUTIMAGE (364 + 16 * Length%%
, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current Nick Letter _PUTIMAGE (274, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'heart selection Selection%% = Selection%% + 1: Length%% = 0 'reset the name position when changing.
IF Selection%%
= 5 THEN Selection%%
= 1 Selection%% = Find_First_Available(1, Selection%%)
_PUTIMAGE (274, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (73, 247)-STEP(7, 7) 'heart selection IF Names
(Selection%%
- 1, j%%
) > CHR$(31) THEN _PRINTSTRING (364 + 16 * j%%
, 152 + 48 * (Selection%%
- 1)), Names
(Selection%%
- 1, j%%
), Layer
(1) _PUTIMAGE (364 + 16 * Length%%
, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (61, 230)-STEP(7, 7) 'Current Nick Letter _PUTIMAGE (236 + 32 * Lx%
, 328 + 32 * Ly%
)-STEP(15, 15), Layer
(12), Layer
(1), (61, 230)-STEP(7, 7) 'Current selected Letter _PUTIMAGE (364 + 16 * Length%%
, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current Nick Letter _PUTIMAGE (236 + 32 * Lx%
, 328 + 32 * Ly%
)-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'Current selected Letter b%% = b%% + 1
IF b%%
= 8 THEN blink%%
= NOT blink%%: b%%
= 0 ClearLayer Layer(16)
Save_Records
IF RTRIM$(Nick
(i%%
)) <> "" THEN Place_Player_Record i%%
- 1, 0 Register = Result%%
ClearLayer Layer(16)
ClearLayer Layer(1)
_PUTIMAGE (140, 72)-STEP(511, 447), Layer
(12), Layer
(16), (515, 1)-STEP(255, 223) 'background IF RTRIM$(Nick
(i%%
)) <> "" THEN Place_Player_Record i%%
- 1, 1 IF i%%
> 0 THEN Selection%%
= i%%
ELSE Selection%%
= 1 FOR i%%
= 1 TO 3 'remove the erased game from the background screens 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) Current_Letter%% = 1
Selection%% = 1
Nick(Selection%%) = ""
Reset_Record Selection%%
_PUTIMAGE (364, 152 + 48 * (Selection%%
- 1))-STEP(159, 31), Layer
(12), Layer
(16), (86, 240)-STEP(7, 7) 'black out _PUTIMAGE (236, 232 + 48 * (Selection%%
- 1))-STEP(159, 33), Layer
(12), Tmp&
, (86, 240)-STEP(7, 7) 'black out name _PUTIMAGE (428, 232 + 48 * (Selection%%
- 1))-STEP(127, 31), Layer
(12), Tmp&
, (86, 240)-STEP(7, 7) 'black out hearts ExitFlag%% = TRUE
_PUTIMAGE (274, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (86, 240)-STEP(7, 7) 'heart selection black out Selection%% = Selection%% + 1
IF Selection%%
= 5 THEN Selection%%
= 1 _PUTIMAGE (274, 152 + 48 * (Selection%%
- 1))-STEP(15, 15), Layer
(12), Layer
(1), (73, 267)-STEP(7, 7) 'heart selection ClearLayer Layer(16)
SUB Reset_Record
(Which%%
) Records(Which%%) = Reset_Link
GET #1, , c~%%
'retrieve number of files FOffset&(I~%%) = FOffset&(I~%%) + 1
Layer(7) = LoadGFX(FOffset(1), Size(1)) '_LOADIMAGE("overworldtiles.bmp", 32)
Layer(9) = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("TitleScreen.bmp", 32)
Layer(10) = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("Titlefalls.bmp", 32)
Layer(11) = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("Titlescroll.bmp", 32)
Layer(12) = LoadGFX(FOffset(5), Size(5)) '_LOADIMAGE("selectionscreen.bmp", 32)
SFX(0) = LoadSFX(FOffset(6), Size(6))
SFX(1) = LoadSFX(FOffset(7), Size(7))
SFX(2) = LoadSFX(FOffset(8), Size(8))
SFX(3) = LoadSFX(FOffset(9), Size(9))
BGM(0) = LoadSFX(FOffset(10), Size(10))
FFX(0) = LoadFFX(FOffset(11), Size(11), 16)
LoadData FOffset(12), Size(12)
FUNCTION LoadFFX&
(Foff&
, Size&
, Fize%%
) LoadFFX&
= _LOADFONT("temp.dat", Fize%%
, "monospace")
SUB LoadData
(Foff&
, Size&
)