REM'$include:'DW1_Types.bas' REM'$include:'DW1_Const.bas' REM'$include:'DW1_Arrays.bas' REM'$include:'DW1_Layers.bas' REM'$include:'DW1_timers.bas' Age
AS _BYTE 'as player gains experiance levels they age, age negativliy affects stats. WorldX
AS _BYTE 'players location in over world MapX
AS _BYTE 'players location in a castle\town or cave\temple Map
AS _BYTE 'where is player? -1 to 27 (-1 = over world map) Has_Princess
AS _BYTE 'is player carring Princess? Princess_Saved
AS _BYTE 'has player saved Princess? WX
AS _BYTE 'used when player is walking Keys
AS _BYTE 'number of keys player has (6max) Herbs
AS _BYTE 'how many Herbs player has, different from items in pack Has_Stones
AS _BYTE 'does player have stones of sunlight? Cursed
AS _BYTE 'did the player equip a cursed item?
Attk1
AS _BYTE 'special attack 1 - these are additional options to normal physical attack
JustLeft
AS _BYTE 'if player just left town\castle don't reprocess location In_Place
AS _BYTE 'player is in a town\castle LastMove
AS LONG 'timer, if player doesn't press any keys his current stats display Menu
AS _BYTE 'does player have the menu up? Selection
AS _BYTE 'what selection did player make from menu Message
AS INTEGER 'current message displayed via Controls menu Input_Wait
AS _BYTE 'waiting for player input, after message display Action
AS _BYTE 'what action is player currently performing?(talk,search,stair,take,door,spell,item) Lite_Level
AS _BYTE 'how much light is there 0-none, 1-torch 2&3-Radiant Current_BGM
AS _BYTE 'which music is currently in background f
AS INTEGER 'number of cycles completed perframe(AKA:Frames Per Sec) SaveFile
AS _BYTE 'Adventure log player is using to save 1-3 MessageSpeed
AS _BYTE 'how fast messages are displayed 1-3 TextClick
AS _BYTE 'Controls the 'typing' sound when displaying a message Price
AS INTEGER ' price of item used in message processing ItemID
AS _BYTE 'the item player is trying to buy from shop
TYPE Non_Playable_Character
Map
AS _BYTE 'Which town\castle\cave do they live in Lines
AS _BYTE 'What lines do they say Flag
AS _BYTE 'used if they change what they say over time MX
AS _BYTE 'used to adjust position when NPC is moving MY
AS _BYTE '""""""""""""""""""""""""""""""""""""""""""
Sprite_ID
AS _BYTE 'sprite used on tile Is_Town
AS _BYTE 'Town ID/Castle ID Territory
AS _BYTE 'Monster selection ID, determines which monster are picked for battle Is_Exit
AS _BYTE 'does tile lead out of castle or town Has_Special
AS _BYTE 'does search find something here or is special battle here
Has_Left_Throne_Room
AS _BYTE 'set when Player first leave thrown room after starting game. Just_Started
AS _BYTE 'Set when player first starts game Saved_Princess
AS _BYTE 'Set after Player has Brought Princess back Has_Proof
AS _BYTE 'Set when player finds proof of ancestry Made_Bridge
AS _BYTE 'set after player uses Rainbow Drop and makes Bridge YNFlag
AS _BYTE 'set if a message dialog needs a Yes or No response
Direction
AS _BYTE 'going up or down Link
AS _BYTE 'links to which other stairs
C
AS _BYTE 'Character associated with selection
Start_X
AS _BYTE 'when Entering where do you start. Is_Lit
AS _BYTE 'is a Torch or Radiant needed to see?
CONST DOWN
= 0, LEFT
= 1, UP
= 2, RIGHT
= 3 CONST Key_Right
= 19712, Key_Left
= 19200, Key_Up
= 18432, Key_Down
= 20480 CONST A_Button
= 32, B_Button
= 13, Start_Button
= 65, Select_Button
= 66 CONST MoveDown
= 1, MoveLeft
= 2, MoveUp
= 3, MoveRight
= 4 CONST Talking
= 1, Stairs
= 2, Searching
= 3, Spells
= 4, Items
= 5, Doors
= 6, Taking
= 7
DIM SHARED PD
(-1 TO 27) AS Place_Data
'Where the player starts, if map is prelit DIM SHARED Stairs
(127) AS Stair_Data
'Where all stairs in game lead DIM SHARED Chest
(127) AS Treasure_Chest
'Where each chest is and what it contains
DIM SHARED NPC
(127) AS Non_Playable_Character
'Data and controls for NPCs 'DIM SHARED NPCDialog(127, 8) AS NPCMonologue
DIM SHARED LS
(63) AS Name_Select
'used for selecting Hero Name
Layer
(2) = _NEWIMAGE(255 * 32, 255 * 32, 32) 'world mapLayer
(5) = _NEWIMAGE(640, 480, 32) 'temp backup layer for menusLayer
(6) = _NEWIMAGE(352, 128, 32) 'temp layer to scroll textLayer
(7) = _NEWIMAGE(46 * 32, 46 * 32, 32) 'map layerLayer
(8) = _NEWIMAGE(46 * 32, 46 * 32, 32) 'NPC sprite layerLayer
(9) = _NEWIMAGE(640, 480, 32) 'debug info layerLayer
(11) = _NEWIMAGE(640, 480, 32) 'light mask for undergroundLayer
(12) = _NEWIMAGE(1472, 1472, 32) 'NPC sprite Clear layerLayer
(15) = _NEWIMAGE(640, 480, 32) 'Message handler text print layerClearLayerMaster
= _MEMIMAGE(Layer
(12)) '8667136bytes
'Layer(3) = _LOADIMAGE("tilebase2.bmp", 32)
'Layer(4) = _LOADIMAGE("characters.bmp", 32)
'Layer(10) = _LOADIMAGE("controller.bmp", 32)
'Layer(13) = _LOADIMAGE("DragonWarrior1Title.PNG", 32)'title screen
'Layer(14) = _LOADIMAGE("Shine.bmp", 32)'title shine\flare
'DWFont = _LOADFONT("DW1.ttf", 16, "Monospace")
MFI_Loader "DragonWV1.MFI"
_TITLE "'Dragon Warrior I' UniKorn ProDucKions 2019" INIT 'a bit of pre-run setup
'--------------development data-------------------
G.MessageSpeed = 1
G.TextClick = FALSE
G.SaveFile = 1
MenuD(1).HName = "Newton"
MenuD(1).MesSpd = 1
MenuD(1).CurLvl = 0
'--------------------------------------------------
'Run_Title_Screen
'GameStartMenu
IF F.Just_Started
THEN Init_Player
Build_Place_Layer Layer(7), P.Map
F.Has_Left_Throne_Room = TRUE
F.Just_Started = FALSE
P.Has_Princess = FALSE 'TRUE
IF P.Map
>= 0 THEN L%%
= 7: PMX%%
= P.MapX: PMY%%
= P.MapY
ELSE L%%
= 2: PMX%%
= P.WorldX: PMY%%
= P.WorldY
Copy_Map_Layer Layer(L%%), PMX%% + WX%%, PMY%% + WY%%
P.Nam = "Newton"
P.Gold = 200
P.Weapon = 1
Add_To_Inventory 21, 1 'torch
Add_To_Inventory 22, 1 'herb
'Add_To_Inventory 23, 1 'wings
'Add_To_Inventory 24, 1 'dragon's scale
Add_To_Inventory 26, 1 'key
Draw_Stat_Window Layer(1)
Process_Command Command_Window(Layer(1)), Layer(1)
REM'$include:'DW1_MFILoader.bas' REM'$include:'CoreFunctions.bas' REM'$include:'DW1_TitleScreen.bas' REM'$include:'DW1_BeginNewQuest.bas' REM'$include:'DW1_RestoreGameFile.bas' REM'$include:'DW1_GameMenu.bas' REM'$include:'DW1_Playerstats.bas' REM'$include:'DW1_InputWindows.bas' REM'$include:'DW1_Commands.bas'
IF F.Has_Left_Throne_Room
= FALSE
THEN Result%% = Message_Handler(Layer(15), 7) 'game intro message
F.Just_Started = FALSE
Result%% = Message_Handler(Layer(15), 13) 'restarted game message
Result%% = Message_Handler(Layer(15), 14) 'havent left throne room yet
Result%% = Message_Handler(Layer(15), 15) 'havent left throne room yet
NPC_Talk 1
P.Has_Princess = FALSE
P.Princess_Saved = TRUE
NPC_Talk 0
Result%% = Message_Handler(Layer(15), 8) 'returned to king to save
IF Yes_NO_Box
(20, 5, Layer
(1)) THEN 'does player want to save Result%% = Message_Handler(Layer(15), 9) 'player saved
Result%% = Message_Handler(Layer(15), 10) 'does player want to keep playing?
IF Yes_NO_Box
(20, 5, Layer
(1)) THEN 'does player want to keep playing Result%% = Message_Handler(Layer(15), 12) 'keeps playing
Result%% = Message_Handler(Layer(15), 11) 'quits
Result%% = Message_Handler(Layer(15), 21) 'returns princess to throne room
CASE 2 'Guard Roaming throne room IF P.Has_Princess
OR P.Princess_Saved
THEN Result%% = Message_Handler(Layer(15), 27) 'Pricess saved
Result%% = Message_Handler(Layer(15), 24) 'just started
IF Yes_NO_Box
(20, 5, Layer
(1)) THEN 'does player know about princess Result%% = Message_Handler(Layer(15), 26) 'yes
Result%% = Message_Handler(Layer(15), 25) 'no, tell player
CASE 3 'Left hand Gaurd throne room IF F.Has_Left_Throne_Room
= FALSE
THEN Result%% = Message_Handler(Layer(15), 28) '
Result%% = Message_Handler(Layer(15), 29) '
CASE 4 'right hand gaurd throne room IF F.Has_Left_Throne_Room
= FALSE
THEN Result%% = Message_Handler(Layer(15), 30) '
Result%% = Message_Handler(Layer(15), 31) '
CASE 5 'Gaurd Roaming North of Stairs Result%% = Message_Handler(Layer(15), 40) '
G.Price = 85
Result%% = Message_Handler(Layer(15), 49) '
IF Yes_NO_Box
(20, 5, Layer
(1)) THEN 'does player know about princess Result%% = Message_Handler(Layer(15), 51) 'yes
IF P.Gold
>= 85 THEN 'buys a key P.Gold = P.Gold - 85
P.Keys = P.Keys + 1
Result%% = Message_Handler(Layer(15), 52) 'Player has too little gold
ExitFlag%% = TRUE
Result%% = Message_Handler(Layer(15), 53) 'Player has too many keys
ExitFlag%% = TRUE
Result%% = Message_Handler(Layer(15), 50) 'no,
ExitFlag%% = TRUE
ExitFlag%% = FALSE
CASE 7 'Girl by key store Result%% = Message_Handler(Layer(15), 42) '
CASE 8 'Roaming Red Guard Result%% = Message_Handler(Layer(15), 41) '
CASE 9 'Roaming Wizard right of stairs Result%% = Message_Handler(Layer(15), 44) '
CASE 10 'Guard at damage floor room entrance Result%% = Message_Handler(Layer(15), 43) '
CASE 11 'Red Guard in damage floor room Result%% = Message_Handler(Layer(15), 45) '
CASE 12 'Guard north of stairs Result%% = Message_Handler(Layer(15), 32) '
CASE 13 'Guard south of stairs Result%% = Message_Handler(Layer(15), 33) '
Result%% = Message_Handler(Layer(15), 35) '
CASE 15 'boy above treasure room Result%% = Message_Handler(Layer(15), 39) '
CASE 16 'guard in treasure room Result%% = Message_Handler(Layer(15), 38) '
CASE 17 'girl in center area Result%% = Message_Handler(Layer(15), 34) '
CASE 18 'merchant 1 bottom left Result%% = Message_Handler(Layer(15), 36) '
CASE 19 'merchant 2 bottom left Result%% = Message_Handler(Layer(15), 37) '
CASE 20 'Guard standing right of pool Result%% = Message_Handler(Layer(15), 48) '
Result%% = Message_Handler(Layer(15), 47) '
CASE 21 'Guard Roaming right of pool Result%% = Message_Handler(Layer(15), 46) '
CASE 22 'Wizard Bottom Right Result%% = Message_Handler(Layer(15), 54) '
P.MP = P.Max_MP
CASE 23 'Guard Left of entrance Result%% = Message_Handler(Layer(15), 55) '
CASE 24 'guard right of entrance Result%% = Message_Handler(Layer(15), 56) '
CASE 25 'Wizard in castle celar Result%% = Message_Handler(Layer(15), 58) '
Result%% = Message_Handler(Layer(15), 57) '
'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄEnd of Tantegel Castle NPCsÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
CASE 26 'Red gaurd in top right corner Result%% = Message_Handler(Layer(15), 57) '59
CASE 27 'Armory shop keep ExitFlag%% = FALSE
Result%% = Message_Handler(Layer(15), 60) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN 'does player wish to buy something Result%% = Run_Shop(1, Layer(1))
ExitFlag%% = TRUE
G.ItemID = Result%%
Result%% = Message_Handler(Layer(15), 63) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN 'does player wish to buy it IF P.Gold
>= I
(G.ItemID
).Valu
THEN 'player has enough gold 'check and see if player must sell something to buy
temp%% = G.ItemID 'backup the item player wishes to buy
IF G.ItemID
< 8 AND P.Weapon
<> 0 THEN Sell%%
= 1: G.ItemID
= P.Weapon
IF G.ItemID
> 7 AND G.ItemID
< 16 AND P.Armor
<> 0 THEN Sell%%
= 2: G.ItemID
= P.Armor
IF G.ItemID
> 15 AND G.ItemID
< 21 AND P.Shield
<> 0 THEN Sell%%
= 3: G.ItemID
= P.Shield
G.Price
= INT(I
(G.ItemID
).Valu \
2) Result%% = Message_Handler(Layer(15), 67) 'does player wish to sell current equipment
IF Yes_NO_Box
(20, 5, Layer
(1)) THEN 'does player wish to sell it P.Gold = P.Gold + G.Price
G.ItemID = temp%% 'restore the item player wants to buy
P.Weapon = G.ItemID
P.Armor = G.ItemID
P.Shield = G.ItemID
P.Gold = P.Gold - I(G.ItemID).Valu
Draw_Stat_Window Layer(5) 'update the stat window after purchase
Result%% = Message_Handler(Layer(15), 65) '
Result%% = Message_Handler(Layer(15), 64) '
'--------------------------------------------------
ELSE 'player lacks enough gold Result%% = Message_Handler(Layer(15), 66) '
Result%% = Message_Handler(Layer(15), 64) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN ExitFlag%%
= FALSE
ELSE ExitFlag%%
= TRUE
'does player wish to buy anything else Result%% = Message_Handler(Layer(15), 61) 'please come again
Result%% = Message_Handler(Layer(15), 61) '
CASE 28 'woman standing in front of shop Result%% = Message_Handler(Layer(15), 68) '
CASE 29 'boy at entrace of town Result%% = Message_Handler(Layer(15), 69) '
Result%% = Message_Handler(Layer(15), 70) '
CASE 31 'wizard in room, removes curses Result%% = Message_Handler(Layer(15), 72) '
Result%% = Message_Handler(Layer(15), 71) '
CASE 32 'roaming merchant Result%% = Message_Handler(Layer(15), 73) '
CASE 33 'guard to far right Result%% = Message_Handler(Layer(15), 74) '
CASE 34 'Roaming red guard Result%% = Message_Handler(Layer(15), 75) '
Result%% = Message_Handler(Layer(15), 76) '
G.Price = 6
Result%% = Message_Handler(Layer(15), 77) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN 'does player wish to stay at the inn Result%% = Message_Handler(Layer(15), 78) '
P.HP = P.Max_HP
P.MP = P.Max_MP
P.Gold = P.Gold - 6
Result%% = Message_Handler(Layer(15), 79) '
Result%% = Message_Handler(Layer(15), 80) '
CASE 37 'Roaming Red guard in Inn Result%% = Message_Handler(Layer(15), 81) '
Result%% = Message_Handler(Layer(15), 82) '
Result%% = Message_Handler(Layer(15), 83) '
Result%% = Message_Handler(Layer(15), 84) '
CASE 41 'boy roaming across bridge Result%% = Message_Handler(Layer(15), 85) '
CASE 42 'Boy standing across bridge Result%% = Message_Handler(Layer(15), 86) '
CASE 43 'roaming Red guard Result%% = Message_Handler(Layer(15), 87) '
CASE 44 'Girl selling fairy water G.Price = 38
Result%% = Message_Handler(Layer(15), 88) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN 'does player wish to buy fairy water IF P.Gold
>= 38 THEN 'player has enough gold IF P.Items
< 8 THEN 'player has room in pack Result%% = Message_Handler(Layer(15), 90) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN ExitFlag%%
= FALSE
ELSE ExitFlag%%
= TRUE
'does player wish to buy more ELSE 'player is out of room Result%% = Message_Handler(Layer(15), 92) '
ExitFlag%% = TRUE
ELSE 'player lacks enough gold Result%% = Message_Handler(Layer(15), 91) '
ExitFlag%% = TRUE
Result%% = Message_Handler(Layer(15), 89) '
Result%% = Message_Handler(Layer(15), 93) '
IF Buy_Sell_Box
(10, 4, Layer
(1)) THEN 'does player wish to buy '--------------player is buying items---------------------------------------
Result%% = Message_Handler(Layer(15), 99) '
Item%% = Run_Shop(2, Layer(1))
G.ItemID = Item%%
ExitFlag%% = TRUE
IF P.Gold
> I
(Item%%
).Valu
THEN 'dose player have the gold IF P.Items
< 8 AND Item%%
<> 22 THEN 'does player have room or is player buying herbs
P.Gold = P.Gold - I(Item%%).Valu 'remove the cost from players purse
Draw_Stat_Window Layer(5) 'update the stat window after purchase
Add_To_Inventory Item%%, 1 'add the item to players inventory
Result%% = Message_Handler(Layer(15), 100) 'player buys item
ELSE 'players inventory is full or they are buying herbs
IF Item%%
= 22 THEN 'if its a Herb then see if player has less than 6 IF P.Herbs
< 6 THEN 'can player hold more? P.Gold = P.Gold - I(Item%%).Valu
Draw_Stat_Window Layer(5) 'update the stat window after purchase
P.Herbs = P.Herbs + 1
Result%% = Message_Handler(Layer(15), 100) 'player buys item
ELSE 'player has too many herbs Result%% = Message_Handler(Layer(15), 102) '
ELSE 'player has too many items Result%% = Message_Handler(Layer(15), 103) '
ELSE 'player hasn't the gold to buy Result%% = Message_Handler(Layer(15), 101) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN ExitFlag%%
= FALSE
ELSE ExitFlag%%
= TRUE
'does player wish to buy more
ELSE 'or is player going to sell '--------------------------Player is selling Items--------------------------------------
Result%% = Message_Handler(Layer(15), 94) '
Item%% = Run_Item(18, 6, Layer(1))
IF Item%%
< 0 THEN 'player canceled ExitFlag%% = TRUE
G.ItemID = Item%%
G.Price
= INT(I
(G.ItemID
).Valu \
2) Result%% = Message_Handler(Layer(15), 96) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN 'does player wish to sell P.Gold = P.Gold + G.Price 'pay player
Draw_Stat_Window Layer(5) 'update the stat window after purchase
IF G.ItemID
= 22 THEN 'remove the item from players inventory P.Herbs = P.Herbs - 1
P.Keys = P.Keys - 1
' Remove_Inventory G.ItemID, 1
' PRINT "starts at"; P.Items
Drop_Inventory G.ItemID
' PRINT "ends at"; P.Items
' END
Result%% = Message_Handler(Layer(15), 98) '
Result%% = Message_Handler(Layer(15), 97) '
IF Yes_NO_Box
(10, 4, Layer
(1)) THEN 'does player wish to sell anything else ExitFlag%% = FALSE
Result%% = Message_Handler(Layer(15), 95) 'player has no items to sell
ExitFlag%% = TRUE
ExitFlag%% = TRUE
Result%% = Message_Handler(Layer(15), 95) 'player has no items to sell
Result%% = -1
Selection%% = 1
IF P.Herbs
THEN Count%%
= Count%%
+ 1 IF P.Keys
THEN Count%%
= Count%%
+ 1 Count%% = Count%% + P.Items
Draw_Window X%%, Y%%, 11, Count%% * 2 + 1, L&
i%% = 0
_PRINTSTRING (16 * (X%%
+ 2), 16 * (Y%%
+ 1 + (i%%
* 2))), "Herbs", L&
_PRINTSTRING (16 * (28), 16 * (Y%%
+ 1 + (i%%
* 2))), V1$
, L&
i%% = i%% + 1
_PRINTSTRING (16 * (X%%
+ 2), 16 * (Y%%
+ 1 + (i%%
* 2))), "Magic", L&
_PRINTSTRING (16 * (X%%
+ 2), 16 * (Y%%
+ 2 + (i%%
* 2))), " Keys", L&
_PRINTSTRING (16 * (28), 16 * (Y%%
+ 1 + (i%%
* 2))), V1$
, L&
i%% = i%% + 1
Offset%% = Y%% + 1 + (i%% * 2)
FOR j%%
= 0 TO P.Items
- 1 V1$
= RTRIM$(I
(Inventory_Item
(j%%
)).Nam
) _PRINTSTRING (16 * (X%%
+ 2), 16 * (Offset%%
+ ((j%%
) * 2))), V1$
, L&
V1$
= MID$(I
(Inventory_Item
(j%%
)).Nam
, 1, INSTR(I
(Inventory_Item
(j%%
)).Nam
, CHR$(32))) _PRINTSTRING (16 * (X%%
+ 2), 16 * (Offset%%
+ ((j%%
) * 2))), V1$
, L&
_PRINTSTRING (16 * (X%%
+ 2), 16 * (Offset%%
+ ((j%%
) * 2 + 1))), V2$
, L&
IF Frame%%
THEN Display_Selection_Arrow X%%
+ 1, 7 + ((Selection%%
- 1) * 2), L&
ExitFlag%% = TRUE
Selection%% = Selection%% - 1
IF Selection%%
= 0 THEN Selection%%
= 1 Selection%% = Selection%% + 1
IF Selection%%
= P.Items
+ i%%
+ 1 THEN Selection%%
= P.Items
+ i%%
ExitFlag%% = TRUE
Result%% = 22
Result%% = 26
Result%% = 26
Result%% = Inventory_Item(Selection%% - i%% - 1)
ExitFlag%% = TRUE
Result%% = TRUE 'exit shop routine
Run_Item = Result%%
SUB Process_Command
(Opt%%
, L&
) NPC_Talk 45
ExitFlag%% = TRUE
Display_Player_Status L&
Run_Stairs
Result%% = Message_Handler(Layer(15), 2) 'found nothing message
Result%% = Message_Handler(Layer(15), 3) 'no spells yet
' Result%% = Message_Handler(Layer(15), 4) 'no items yet message
Result%% = Run_Item(18, 6, Layer(1))
Result%% = Message_Handler(Layer(15), 5) 'no door here message
Result%% = Message_Handler(Layer(15), 6) 'nothing to take message
ExitFlag%% = TRUE
ExitFlag%% = TRUE
X%% = 10: Y%% = 4
Result%% = FALSE
Selection%% = 1
CASE 1 'breconary armory shop Draw_Window X%%, Y%%, 20, 13, L&
V1$
= RTRIM$(I
(Shop
(1, i%%
)).Nam
) V1$
= MID$(I
(Shop
(1, i%%
)).Nam
, 1, INSTR(I
(Shop
(1, i%%
)).Nam
, CHR$(32))) IF Frame%%
THEN Display_Selection_Arrow X%%
+ 1, 3 + (Selection%%
* 2), L&
ExitFlag%% = TRUE
Selection%% = Selection%% - 1
IF Selection%%
= 0 THEN Selection%%
= 1 Selection%% = Selection%% + 1
IF Selection%%
= 7 THEN Selection%%
= 6 ExitFlag%% = TRUE
Result%% = Shop(1, Selection%%)
ExitFlag%% = TRUE
Result%% = TRUE 'exit shop routine
CASE 2 'breconary item shop buy Draw_Window X%%, Y%%, 20, 7, L&
V1$
= RTRIM$(I
(Shop
(2, i%%
)).Nam
) V1$
= MID$(I
(Shop
(2, i%%
)).Nam
, 1, INSTR(I
(Shop
(2, i%%
)).Nam
, CHR$(32))) IF Frame%%
THEN Display_Selection_Arrow X%%
+ 1, 3 + (Selection%%
* 2), L&
ExitFlag%% = TRUE
Selection%% = Selection%% - 1
IF Selection%%
= 0 THEN Selection%%
= 1 Selection%% = Selection%% + 1
IF Selection%%
= 4 THEN Selection%%
= 3 ExitFlag%% = TRUE
Result%% = Shop(2, Selection%%)
ExitFlag%% = TRUE
Result%% = TRUE 'exit shop routine
CASE 3 'breconary item shop Sell
Draw_Window X%%, Y%%, 20, P.Items * 2 + 1, L&
FOR i%%
= 0 TO P.Items
- 1 V1$
= RTRIM$(I
(Shop
(3, i%%
)).Nam
) _PRINTSTRING (16 * (13), 16 * (3 + ((i%%
+ 1) * 2))), V1$
, L&
V1$
= MID$(I
(Shop
(3, i%%
)).Nam
, 1, INSTR(I
(Shop
(3, i%%
)).Nam
, CHR$(32))) _PRINTSTRING (16 * (13), 16 * (3 + ((i%%
+ 1) * 2))), V1$
, L&
_PRINTSTRING (16 * (13), 16 * (3 + ((i%%
+ 1) * 2) + 1)), V2$
, L&
IF Frame%%
THEN Display_Selection_Arrow X%%
+ 1, 3 + (Selection%%
* 2), L&
ExitFlag%% = TRUE
Selection%% = Selection%% - 1
IF Selection%%
= 0 THEN Selection%%
= 1 Selection%% = Selection%% + 1
IF Selection%%
= P.Items
+ 1 THEN Selection%%
= P.Items
ExitFlag%% = TRUE
Result%% = Shop(3, Selection%% - 1)
ExitFlag%% = TRUE
Result%% = TRUE 'exit shop routine
Run_Shop = Result%%
IF Place
(P.Map
, P.MapX
, P.MapY
).Is_Stairs
THEN IF NOT F.Has_Left_Throne_Room
THEN F.Has_Left_Throne_Room
= TRUE
'if player has just started game
P.Map = Stairs(Place(P.Map, P.MapX, P.MapY).Is_Stairs).Link
'get location information from the linked stair Record.
P.MapX = Stairs(P.Map).X
P.MapY = Stairs(P.Map).Y
IF Stairs
(P.Map
).Map
= -1 THEN P.WorldX
= Stairs
(P.Map
).X: P.WorldY
= Stairs
(P.Map
).Y
P.Map = Stairs(P.Map).Map
IF P.Map
>= 0 THEN Build_Place_Layer Layer
(7), P.Map
' Change_BGM 0
G.Menu = FALSE
Result%% = Message_Handler(Layer(15), 0) 'no stairs here message
IF World
(P.WorldX
, P.WorldY
).Is_Stairs
THEN P.Map = Stairs(World(P.WorldX, P.WorldY).Is_Stairs).Link
'get location information from the linked stair Record.
P.MapX = Stairs(P.Map).X
P.MapY = Stairs(P.Map).Y
P.Map = Stairs(P.Map).Map
Build_Place_Layer Layer(7), P.Map
G.Menu = FALSE
' Change_BGM 0
Result%% = Message_Handler(Layer(15), 0) 'no stairs here message
TotalLines%% = Messages(MSG%, 1) 'number of lines to display
CurrentLine = 1
CMSG% = Lines(Messages(MSG%, 0), DisplayedLines%%) 'Current MeSsaGe line
Processed
= Process_Message_Coding$
(Script
(CMSG%
)): Message_Length
= LEN(Processed
) Message_Length
= LEN(Script
(CMSG%
)) Processed = Script(CMSG%)
'check message length word wrap if needed
IF Message_Length
> 22 AND LineCount
= 0 THEN LineCount
= Process_Word_Wrap
(WLine
(), Processed
) IF Message_Length
<= 22 THEN LineCount
= 1: WLine
(1) = Processed
Slowit = Slowit + 1 'makes the message display at the set speed
IF Slowit
= 2 * G.MessageSpeed
THEN Slowit
= 0: Current_Char
= Current_Char
+ 1:
IF G.TextClick
THEN _SNDPLAY SFX
(3)
_PRINTSTRING (80, 304 + (16 * (Displayed
))), MID$(WLine
(CurrentLine
), 1, Current_Char
), L&
'print message 1 character at a time.
IF Current_Char
= LEN(RTRIM$(WLine
(CurrentLine
))) THEN CurrentLine
= CurrentLine
+ 1: Current_Char
= 0: Displayed
= Displayed
+ 1 IF Displayed
= 8 THEN Scroll_Line L&: Displayed
= Displayed
- 1
IF CurrentLine
= LineCount
+ 1 THEN ExitFlag%%
= TRUE
_PUTIMAGE , Layer
(5), Layer
(1) 'throw the backup layer in Draw_Window 4, 18, 23, 9, Layer(1) 'add message area window
_PUTIMAGE , L&
, Layer
(1) 'move text into window _PUTIMAGE , Layer
(1), Layer
(0) 'move that to screen
ExitFlag%% = FALSE
DisplayedLines%% = DisplayedLines%% + 1
OFFY%% = CurrentLine: CurrentLine = 1: LineCount = 0: Displayed = Displayed + 1
IF DisplayedLines%%
= TotalLines%%
THEN 'are we done displaying message? or Completed%% = TRUE
ELSE 'is there more of message to display _PUTIMAGE , Layer
(5), Layer
(1) 'throw the backup layer in Draw_Window 4, 18, 23, 9, Layer(1) 'add message area window
_PUTIMAGE , L&
, Layer
(1) 'move text into window IF Frame%%
THEN Display_Waiting_Arrow
15, 18 + Displayed
, Layer
(1) _PUTIMAGE , Layer
(1), Layer
(0) 'move that to screen
Processed = "": Message_Length = 0: Result%% = FALSE
CurrentLine = 0: WLine(1) = "": LineCount = 0
Message_Handler = Result%%
FOR i~%%
= 1 TO LEN(Txt$
) 'check message for formating Result$
= Result$
+ RTRIM$(M
(battle%%
).Nam
) i~%% = i~%% + 1
Result$
= Result$
+ RTRIM$(P.Nam
) i~%% = i~%% + 1
Result$
= Result$
+ RTRIM$(I
(G.ItemID
).Nam
) i~%% = i~%% + 1
i~%% = i~%% + 2
' F.YNFlag = TRUE
Temp$
= MID$(Txt$
, i~%%
+ 2) ' G.Yes_Dialog = VAL(MID$(Temp$, 1, INSTR(Temp$, ",") - 0))
' G.No_Dialog = VAL(MID$(Temp$, INSTR(Temp$, ",") + 1))
i~%%
= i~%%
+ 1 + LEN(Temp$
) Result$
= Result$
+ MID$(Txt$
, i~%%
, 1) Process_Message_Coding = Result$
Result%% = 1: I%% = 1
'start on character 22 and work back to a space
x%% = 22: Space%% = FALSE
Lines
(I%%
) = MID$(txt$
, 1, x%%
) txt$
= MID$(txt$
, x%%
+ 1) I%% = I%% + 1
Lines(I%%) = txt$ 'put the last of the text into a line
Result%% = I%%
Process_Word_Wrap = Result%%
ClearLayer Layer(6)
Result~%
= L
(P.Level
) - P.
Exp EXP_Required = Result~%
SUB Draw_Window
(X%%
, Y%%
, Xs%%
, Ys%%
, L&
) 'top corners of window
_PUTIMAGE (X%%
* 16 + Xs%%
* 16, Y%%
* 16)-STEP(15, 15), Layer
(3), L&
, (8, 18)-STEP(7, 7) 'bottom corners of window
_PUTIMAGE (X%%
* 16, Y%%
* 16 + Ys%%
* 16)-STEP(15, 15), Layer
(3), L&
, (16, 18)-STEP(7, 7) _PUTIMAGE (X%%
* 16 + Xs%%
* 16, Y%%
* 16 + Ys%%
* 16)-STEP(15, 15), Layer
(3), L&
, (24, 18)-STEP(7, 7) 'top and bottom of window
_PUTIMAGE (X%%
* 16 + i%%
* 16, Y%%
* 16)-STEP(15, 15), Layer
(3), L&
, (56, 18)-STEP(7, 7) _PUTIMAGE (X%%
* 16 + i%%
* 16, Y%%
* 16 + Ys%%
* 16)-STEP(15, 15), Layer
(3), L&
, (48, 18)-STEP(7, 7) 'left and right sides of window
_PUTIMAGE (X%%
* 16, Y%%
* 16 + 16 * i%%
)-STEP(15, 15), Layer
(3), L&
, (32, 18)-STEP(7, 7) _PUTIMAGE (X%%
* 16 + Xs%%
* 16, Y%%
* 16 + 16 * i%%
)-STEP(15, 15), Layer
(3), L&
, (40, 18)-STEP(7, 7) 'fill in window
_PUTIMAGE ((X%%
+ 1) * 16, (Y%%
+ 1) * 16)-STEP((Xs%%
- 1) * 16, (Ys%%
- 1) * 16), Layer
(3), L&
, (307, 1)-STEP(15, 15)
SUB Display_Selection_Arrow
(X%%
, Y%%
, L&
)
SUB Display_Waiting_Arrow
(X%%
, Y%%
, L&
)
G.f = Frames%
Frames% = 0
G.TextClick = TRUE
F.Just_Started = TRUE
'mapping routines ------------------------------------------
SUB Copy_Map_Layer
(L&
, MX%%
, MY%%
) _PUTIMAGE (16, 16), L&
, Layer
(1), (MX%%
* 32 - 240 + G.X
, MY%%
* 32 - 208 + G.Y
)-STEP(495, 447) _PUTIMAGE (16, 16), L&
, Layer
(1), (128 + MX%%
* 32 - 240 + G.X
, 128 + MY%%
* 32 - 208 + G.Y
)-STEP(495, 447)
SUB Build_World_Layer
(L&
) _PUTIMAGE (32 * X~%%
, 32 * Y~%%
)-STEP(31, 31), Layer
(3), L&
, (1 + 17 * 14, 1)-STEP(15, 15) _PUTIMAGE (128 + 32 * X%%
, 128 + 32 * Y%%
)-STEP(31, 31), Layer
(3), L&
, (1 + 17 * World
(X%%
, Y%%
).Sprite_ID
, 1)-STEP(15, 15)
SUB Build_Place_Layer
(L&
, ID%%
) _PUTIMAGE (0 + 32 * X%%
, 0 + 32 * Y%%
)-STEP(31, 31), Layer
(3), L&
, (1 + 17 * Place
(ID%%
, X%%
, Y%%
).Sprite_ID
, 1)-STEP(15, 15) '-----------------------------------------------------------
'Draw Sprite Routines---------------------------------------
SUB Draw_Player_Sprite
(L&
) IF P.Weapon
AND P.Shield
> 16 THEN 'pick which sprite set to use Y1%% = 3 'has a shield and weapon
Y1%% = 1 'only has weapon
Y1%% = 2 'on has shield
Y1%% = 0 'has nothing
IF P.Armor
> 9 THEN Y1%%
= Y1%%
+ 4 'player has armor
IF P.Has_Princess
THEN Y1%%
= 8 'if player is returning princess over-ride tile set
SX% = 3 + (Frame%% * 16) + (P.Facing * 32)
SY% = 4 + (Y1%% * 18)
SUB Draw_NPC_Sprites
(Count%%
, L&
) ClearLayerADV L&
SX% = 3 + (Frame%% * 16) + (NPC(i%%).Facing * 32)
SY% = 4 + (NPC(i%%).Sprite_ID * 18)
_PUTIMAGE (NPC
(i%%
).X
* 32 + NPC
(i%%
).MX
, NPC
(i%%
).Y
* 32 + NPC
(i%%
).MY
)-STEP(31, 31), Layer
(4), L&
, (SX%
, SY%
)-STEP(15, 15)
'-----------------------------------------------------------
SUB Add_To_Inventory
(Item%%
, Count%%
) STATIC m
AS _MEM 'no need to initialize/free it over and over m
= _MEM(P
) 'Just change where you want to point it to. Pack = m.OFFSET + 28 'æmove to where P .Pack starts at in memory
Match%% = FALSE
P.Herbs = P.Herbs + 1
P.Keys = P.Keys + 1
_MEMPUT m
, Pack
+ P.Items
* 2, Item%%
'POKE _MEMPUT m
, Pack
+ P.Items
* 2 + 1, Count%%
'POKE P.Items = P.Items + 1
STATIC m
AS _MEM 'no need to initialize/free it over and over m
= _MEM(P
) 'Just change where you want to point it to. Pack = m.OFFSET + 28 'æmove to where P .Pack starts at in memory
Result%% = 0
Item_Count = Result%%
STATIC m
AS _MEM 'no need to initialize/free it over and over m
= _MEM(P
) 'Just change where you want to point it to. Pack = m.OFFSET + 28 'æmove to where P .Pack starts at in memory
Result%% = 0
Inventory_Item = Result%%
SUB Remove_Inventory
(Item%%
, Count%%
) STATIC m
AS _MEM 'no need to initialize/free it over and over m
= _MEM(P
) 'Just change where you want to point it to. Pack = m.OFFSET + 28 'æmove to where P .Pack starts at in memory
Match%% = -1
FOR i%%
= 0 TO 15 'find the item 'something went horribly wrong!
temp%% = temp%% - Count%%
IF temp%%
= 0 THEN 'item is out so remove from inventory temp$
= LEFT$(temp$
, Match%%
* 2) + MID$(temp$
, 2 * Match%%
+ 3) P.Items = P.Items - 1
FOR i%%
= l%%
TO 31 'pad temp$ to full 32 characters
_MEMPUT m
, Pack
, temp$
'put invetory back _MEMPUT m
, Pack
+ Match%%
* 2 + 1, temp%%
'put adjusted count back
SUB Drop_Inventory
(ID%%
) STATIC m
AS _MEM 'no need to initialize/free it over and over m
= _MEM(P
) 'Just change where you want to point it to. Pack = m.OFFSET + 28 'æmove to where P .Pack starts at in memory
Match%% = -1
FOR i%%
= 0 TO 15 'find the item 'something went horribly wrong!
temp$
= LEFT$(temp$
, Match%%
* 2) + MID$(temp$
, 2 * Match%%
+ 3)
P.Items = P.Items - 1
FOR i%%
= l%%
TO 31 'pad temp$ to full 32 characters
_MEMPUT m
, Pack
, temp$
'put invetory back
'compute primary Defense value
Result~%% = Player_Defense
'now check for luck bonus good or bad
IF INT(RND * 255) <= (P.Luck \
2) THEN 'if random chance is less than half player luck then give luck adjustment Result~%%
= Result~%%
+ INT(RND * (P.Luck
* 2) - (P.Luck
- (P.Age
* 2))) Player_Battle_Defense = Result~%%
'compute defense value to display in status window and to use in battle defense function
Result~%%
= INT(P.Agility
/ 2) + I
(P.Armor
).Power
+ I
(P.Shield
).Power
Player_Defense = Result~%%
'Compute Attack value to display in status window and to use in battle attack function
Result~%%
= INT(P.Strength
) + I
(P.Weapon
).Power
Player_Attack = Result~%%
'get primary attack value
Result~%% = Player_Attack
C~%% = Chance
IF C~%%
< (P.Luck \
2) THEN 'if random chance is less than half player luck then give luck adjustment Result~%%
= Result~%%
+ INT(RND * (P.Luck
* 2) - (P.Luck
- (P.Age
* 2))) ELSEIF C~%%
>= (128 - P.Luck
/ 16) AND C~%%
<= (128 + P.Luck
/ 16) THEN 'critical hit Result~%%
= Result~%%
+ INT(Result~%%
* .25) 'add 25% to hit value Player_Battle_Attack = Result~%%
IF Player_Battle_Defense
/ 2 > M
(ID%%
).Strength
THEN Miss%%
= INT(M
(ID%%
).Strength
+ 4 / 6) ELSE Miss%%
= FALSE
Low~%% = (M(ID%%).Strength - Player_Battle_Defense / 2) / 4
High~%% = (M(ID%%).Strength - Player_Battle_Defense / 2) / 2
IF (Chance
< P.Luck
/ 4) THEN 'player evades attack(-1) Result%% = TRUE
ELSEIF Miss%%
>= 0 THEN 'not really a miss just a weak hit Result%% = Miss%%
ELSE 'normal attack damage Result%%
= INT(RND * (High~%%
- Low~%%
)) + Low~%%
Enemy_Damage = Result%%
IF Chance
+ P.Luck
/ 2 > 228 THEN 'critical hit Low~%% = (Player_Battle_Attack / 2)
High~%% = (Player_Battle_Attack)
Low~%% = (Player_Battle_Attack - M(ID%%).Agility / 2) / 4
High~%% = (Player_Battle_Attack - M(ID%%).Agility / 2) / 2
Result~%%
= INT(RND * (High~%%
- Low~%%
)) + Low~%%
IF Chance
+ (P.Luck
/ 2) > 127 THEN Result~%%
= 1 Player_Damage = Result~%%
IF Player_Attack
>= M
(ID%%
).Strength
* 2 THEN IF Chance
> 192 THEN Result%%
= TRUE
ELSE Result%%
= FALSE
Enemy_Flee = Result%%
IF P.Agility
* Chance
< M
(Id%%
).Agility
* Chance
* GF
(M
(Id%%
).Group
) THEN Result%% = FALSE 'player is blocked
Result%% = TRUE 'player evades
Player_Flee = Result%%
'if false then enemy goes first else player goes first in battle
IF P.Agility
* Chance
< M
(ID%%
).Agility
* Chance
* GF
(1) THEN Result%% = FALSE 'Monster goes first
Result%% = TRUE 'player Goes first
Battle_Initiative = Result%%
GET #1, , c~%%
'retrieve number of files FOffset&(I~%%) = FOffset&(I~%%) + 1
Layer(10) = LoadGFX(FOffset(1), Size(1))
Layer(3) = LoadGFX(FOffset(2), Size(2))
Layer(4) = LoadGFX(FOffset(3), Size(3))
Layer(13) = LoadGFX(FOffset(14), Size(14))
Layer(14) = LoadGFX(FOffset(15), Size(15))
BGM(-1) = LoadSFX(FOffset(4), Size(4))
BGM(0) = LoadSFX(FOffset(10), Size(10))
BGM(1) = LoadSFX(FOffset(12), Size(12))
BGM(3) = LoadSFX(FOffset(13), Size(13))
SFX(0) = LoadSFX(FOffset(5), Size(5))
SFX(1) = LoadSFX(FOffset(8), Size(8))
SFX(2) = LoadSFX(FOffset(9), Size(9))
SFX(3) = LoadSFX(FOffset(11), Size(11))
Title = LoadSFX(FOffset(16), Size(16))
LoadData FOffset(6), Size(6)
DWFont = LoadFFX(FOffset(7), Size(7), 16)
FUNCTION LoadFFX&
(Foff&
, Size&
, Fize%%
) LoadFFX&
= _LOADFONT("temp.dat", Fize%%
, "monospace")
SUB LoadData
(Foff&
, Size&
)
P.Level = P.Level + 1
P.Age
= P.Age
+ INT(P.Level
* 1.5 - .49) P.Strength
= P.Strength
+ INT(RND * 6) + 1 - INT((-5 + (P.Age
- 20)) * (.15 + ((P.Age
- 17) / 100)) - .49) P.Agility
= P.Agility
+ INT(RND * 6) + 1 - INT((-8 + (P.Age
- 20)) * (.4 + ((P.Age
- 17) / 100)) - .49) P.Luck
= P.Luck
+ INT(RND * 3) + INT(0 + (P.Age
- 25)) * (.4 + ((P.Age
- 17) / 50) + .49) P.Max_HP
= P.Max_HP
+ INT(RND * 10 - (P.Age
/ 10)) + 1 P.Max_MP
= P.Max_MP
+ INT(RND * 5 + (P.Age
/ 10)) Check_Level_Up_Spells
SUB Check_Level_Up_Spells
'give spells to player based on Max_MP
'heal-restores 7-18hp
'hurt-hits enemy for 5-12hp
'sleep-puts enemy to sleep for up to 6 rounds
'radiant-generates light in caves radius x3 for 160 steps
'stopspell-prevents enemy from using magic including healing spells
'outside-teleports player out of a cave\temple
'return- teleports player back to Tantegel castle
'repel-stops attacks from monsters weaker than player for 128 steps
'HealMore-restores 70-110hp
'HurtMore-hits enemy for 58-65hp
'Strengthen-adds 1/4 bonus to players attack strength for duration of battle
'Quicken-adds 1/3 bonus to players defensive strength for duration of battle
'---------------Player starting stats-----------------------
P.Max_HP
= INT(RND * 8) + 12 'start 12-20hp P.HP = P.Max_HP
IF INT(RND * 100) = 95 THEN P.Max_MP
= INT(RND * 3) + 4 '1 in 100 chance of starting with magical powers IF P.Max_MP
THEN P.Spells
= _SETBIT(P.Spells
, 0) 'give player HEAL if they start with magic P.MP = P.Max_MP
P.Strength
= INT(RND * 3) + 2 'determines base attack damage P.Agility
= INT(RND * 2) + 2 'determines base defence\evasion P.Luck
= INT(RND * 5) 'a "chance" bonus to hits and evasions P.Level = 0 'starting at base; first fight elevates to level 1, no xp gain though
P.Age = 17 'level adds to age *1.5 (level 10 adds 15 to age, 20 adds 30, 30 adds 45, max age 72!)
' age affects Strength by subtracting INT((-5 + (Age - 20)) * (.15 + ((Age-17)/100))-.49) ; youth gives strength
' age affects Agility by subtracting INT((-8 + (Age - 20)) * (.4 + ((Age-17)/100))-.49) ; youth gives great agility, age loses agility quickly
' age affects Luck by adding (0 + (Age - 25)) * (.4 + ((Age-17)/50)) ; age adds luck
P.Weapon = 0 'adds to Attack strength , start with Fists
P.Armor = 8 'adds to Defensive strength , start with Loin Cloth
P.Shield = 16 'adds to Defensive strength , start with None
P.Gold = 0
P.WorldX = 44
P.WorldY = 44
P.MapX = 17 'when starting game player always starts here
P.MapY = 18
P.Map = 1
'-----------------------------------------------------------
SUB Draw_Stat_Window
(L&
) Draw_Window 2, 4, 7, 11, L&
_PUTIMAGE (4 * 16 - 2, 4 * 16)-STEP(4 * 15 + 4, 1 * 15), Layer
(3), L&
, (205, 35)-STEP(15, 15)
SUB Display_Player_Status
(L&
) Draw_Window 10, 6, 19, 21, L&
SUB Draw_Command_Window
(L&
) Draw_Window 12, 2, 15, 9, Layer(1)
_PUTIMAGE (16 * 16 - 2, 2 * 16)-STEP(7 * 15 + 4, 1 * 15), Layer
(3), L&
, (205, 35)-STEP(15, 15)
Result%% = FALSE
selection%% = 2
Draw_Window X%%, Y%%, 7, 5, L&
IF Frame%%
THEN Display_Selection_Arrow X%%
+ 1, Y%%
+ (selection%%
* 2), L&
ExitFlag%% = TRUE
selection%% = selection%% - 1
IF selection%%
= 0 THEN selection%%
= 1 selection%% = selection%% + 1
IF selection%%
= 3 THEN selection%%
= 2 ExitFlag%% = TRUE
IF selection%%
= 1 THEN Result%%
= TRUE
ExitFlag%% = TRUE
Yes_NO_Box = Result%%
Result%% = FALSE
selection%% = 1
Draw_Window X%%, Y%%, 7, 5, L&
IF Frame%%
THEN Display_Selection_Arrow X%%
+ 1, Y%%
+ (selection%%
* 2), L&
ExitFlag%% = TRUE
selection%% = selection%% - 1
IF selection%%
= 0 THEN selection%%
= 1 selection%% = selection%% + 1
IF selection%%
= 3 THEN selection%%
= 2 ExitFlag%% = TRUE
IF selection%%
= 1 THEN Result%%
= TRUE
ExitFlag%% = TRUE
Buy_Sell_Box = Result%%
Result%% = FALSE
Selection%% = 1
Draw_Command_Window L&
Display_Selection_Arrow SA(Selection%%).X, SA(Selection%%).Y, L&
IF KBD&
= Key_Up
AND Selection%%
> 1 AND Selection%%
<> 5 THEN Selection%%
= Selection%%
- 1 IF KBD&
= Key_Down
AND Selection%%
< 8 AND Selection%%
<> 4 THEN Selection%%
= Selection%%
+ 1 IF KBD&
= Key_Left
AND Selection%%
> 4 THEN Selection%%
= Selection%%
- 4 IF KBD&
= Key_Right
AND Selection%%
< 5 THEN Selection%%
= Selection%%
+ 4
IF KBD&
= B_Button
THEN ExitFlag%%
= TRUE
IF KBD&
= A_Button
THEN Result%%
= Selection%%: ExitFlag%%
= TRUE
IF KBD&
= 27 THEN ExitFlag%%
= TRUE
Command_Window = Result%%