Author Topic: Phantasy Star I:Some Progress being made.  (Read 3085 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Phantasy Star I:Some Progress being made.
« on: June 26, 2021, 06:58:32 pm »
Tell me what you think guys. Almost have the first town completely interactive. You can enter the houses and shops and talk with locals.
There is one house thats not done yet, so his door is locked. :)  and there is a 🐞 in the Second Hand shop so you can't access the BUY menu. not sure on that yet, just saw it when I made sure the combined code ran. you can exit the town and explore the map though collision checking is on now so you can only travel a small area of the 1st world map. You can enter any town you can see. the caves are still out yet so no exploring there. that will be once the towns and villages are stocked with NPCs.  There are a few missing NPCs in the first town, as I have been focusing on getting the buildings working.

Controls are:
Arrow Keys - Movement
ENTER - to progress dialogs\ make choices

and as always don't forget the MFI file below.

Code: QB64: [Select]
  1. 'World of Palma; Exploration demo update
  2. '6/26/2021
  3. 'Collision checking ON version
  4. 'Cobalt
  5.  
  6. REM'$include:'PS1_Types.bas'
  7. REM'$include:'PS1_Arrays.bas'
  8. REM'$include:'PS1_Const.bas'
  9. TYPE ControllerKeys
  10.  KBCon_Up AS LONG
  11.  KBCon_Down AS LONG
  12.  KBCon_Left AS LONG
  13.  KBCon_Right AS LONG
  14.  KBCon_Select AS LONG
  15.  KBCon_Start AS LONG
  16.  KBCon_A_Button AS LONG
  17.  KBCon_B_Button AS LONG
  18.  
  19.  Control_Pad AS _BYTE 'which Gamepad\Joystick Device Is player Using?
  20.  BAD_Pad AS _BYTE 'option for Buttons As Directions
  21.  Joy_Up AS _BYTE 'axis for up
  22.  Joy_Up_Val AS _BYTE 'axis value for up
  23.  Joy_Down AS _BYTE 'axis for down
  24.  Joy_Down_Val AS _BYTE 'axis value for down
  25.  Joy_Left AS _BYTE 'axis for left
  26.  Joy_Left_Val AS _BYTE 'axis value for left
  27.  Joy_Right AS _BYTE 'axis for right
  28.  Joy_Right_Val AS _BYTE 'axis value for right
  29.  Joy_Select AS _BYTE
  30.  Joy_Start AS _BYTE
  31.  Joy_A_Button AS _BYTE
  32.  Joy_B_Button AS _BYTE
  33.  Joy_Button_Up AS _BYTE 'for people whos controllers give BUTTON states for direction keys
  34.  Joy_Button_Down AS _BYTE 'or just want to use buttons for the direction keys.
  35.  Joy_Button_Left AS _BYTE '""""
  36.  Joy_Button_Right AS _BYTE 'however this fails to work so may not be implemented.
  37.  
  38. TYPE Player
  39.  N AS STRING * 4
  40.  Hp AS INTEGER
  41.  Mp AS INTEGER
  42.  Level AS _BYTE
  43.  Wepn AS _BYTE
  44.  Armr AS _BYTE
  45.  Shld AS _BYTE
  46.  Combat AS _BYTE 'Spells used in combat
  47.  NonCombat AS _BYTE 'Spells used out of combat
  48.  Wx AS INTEGER 'players map tile location
  49.  Wy AS INTEGER
  50.  Tx AS _BYTE 'players pixel location when moving, also players dungeon cords
  51.  Ty AS _BYTE
  52.  Fr AS _BYTE
  53.  Is_Intown AS _BYTE
  54.  In_Dungeon AS _BYTE
  55.  Status AS _BYTE 'stoned, tied up, dead
  56.  
  57. TYPE Encounters
  58.  Nam AS STRING * 8 '     Monster name
  59.  Hp AS _UNSIGNED _BYTE ' Health
  60.  MHp AS _UNSIGNED _BYTE ' Health
  61.  Atp AS _UNSIGNED _BYTE ' Attack Power
  62.  Dfp AS _UNSIGNED _BYTE ' Defence Power
  63.  Exp AS _UNSIGNED _BYTE ' Experiance
  64.  Mes AS _UNSIGNED _BYTE ' Meseta(gold)
  65.  Num AS _BYTE '           How many show up
  66.  Flee AS _UNSIGNED _BYTE 'Difficulty in running away (0-255 where 0 is bad)
  67.  Trap AS _BYTE '          is their treasure trapped (0-255 where 0 is good)
  68.  Kind AS _UNSIGNED _BYTE 'Kind of trap(arrow or blast)
  69.  Drop AS _BYTE '          Item Dropped if any
  70.  Odds AS _UNSIGNED _BYTE 'How likey to drop item (0-255 where 0 is no drop)
  71.  Talk AS _BYTE '          can talk to normally
  72.  Chat AS _BYTE '          can talk to magically
  73.  Rope AS _BYTE '          can use rope against
  74.  Prot AS _BYTE '          can use protect against
  75.  Myst AS _BYTE '          mystery???
  76.  Special AS _BYTE '       special attack(rope,cure,fire,ect)
  77.  Status AS _BYTE
  78.  
  79. TYPE Monsters
  80.  Nam AS STRING * 8 '     Monster name
  81.  Hp AS _UNSIGNED _BYTE ' Health
  82.  MHp AS _UNSIGNED _BYTE ' Health
  83.  Atp AS _UNSIGNED _BYTE ' Attack Power
  84.  Dfp AS _UNSIGNED _BYTE ' Defence Power
  85.  Exp AS _UNSIGNED _BYTE ' Experiance
  86.  Mes AS _UNSIGNED _BYTE ' Meseta(gold)
  87.  Num AS _BYTE '           How many show up
  88.  Flee AS _UNSIGNED _BYTE 'Difficulty in running away (0-255 where 0 is bad)
  89.  Trap AS _BYTE '          is their treasure trapped (0-255 where 0 is good)
  90.  Kind AS _UNSIGNED _BYTE 'Kind of trap(arrow or blast)
  91.  Drop AS _BYTE '          Item Dropped if any
  92.  Odds AS _UNSIGNED _BYTE 'How likey to drop item (0-255 where 0 is no drop)
  93.  Talk AS _BYTE '          can talk to normally
  94.  Chat AS _BYTE '          can talk to magically
  95.  Rope AS _BYTE '          can use rope against
  96.  Prot AS _BYTE '          can use protect against
  97.  Myst AS _BYTE '          mystery???
  98.  Special AS _BYTE '       special attack(rope,cure,fire,ect)
  99.  
  100. TYPE Enter_Exit
  101.  Map AS _BYTE
  102.  Xloc AS _BYTE
  103.  Yloc AS _BYTE
  104.  
  105. TYPE Game_Data
  106.  SavedGames AS _BYTE
  107.  Sounds_ON AS _BYTE
  108.  SFX_Vol AS _BYTE
  109.  Music_Vol AS _BYTE
  110.  ColorShift AS _BYTE 'Allows selection highlighting for Options menu
  111.  Device_Count AS _BYTE
  112.  ControlType AS _BYTE
  113.  CurrentBGM AS _BYTE
  114.  Meseta AS LONG
  115.  Party_Size AS _BYTE
  116.  In_Battle AS _BYTE
  117.  Pack_Count AS _BYTE 'how many items are in the pack
  118.  Facing AS _BYTE 'what direction is player facing
  119.  Moving AS _BYTE
  120.  CurrentFloor AS _BYTE 'what dungeon floor is player on?
  121.  Battle_Count AS _BYTE '
  122.  Wall_Cast AS _BYTE
  123.  Prot_Cast AS _BYTE
  124.  Runaway AS _BYTE
  125.  Chest_Wait AS _BYTE
  126.  Last_Church AS _BYTE 'What was the last church visted by player
  127.  
  128. TYPE Items
  129.  Nam AS STRING * 8
  130.  Pwr AS _BYTE
  131.  Cost AS INTEGER
  132.  Alis AS _BYTE
  133.  Myau AS _BYTE
  134.  Odin AS _BYTE
  135.  Noah AS _BYTE
  136.  CanSell AS _BYTE
  137.  CanDrop AS _BYTE
  138.  Is_Type AS _BYTE
  139.  
  140. TYPE PlayerLeveling
  141.  HitPts AS _UNSIGNED _BYTE
  142.  AttVal AS _UNSIGNED _BYTE
  143.  DefVal AS _UNSIGNED _BYTE
  144.  MagPts AS _UNSIGNED _BYTE
  145.  Combat AS LONG
  146.  NonCbt AS LONG
  147.  
  148. TYPE WorldTiles
  149.  Is_Walkable AS _BYTE
  150.  Is_Animated AS _BYTE
  151.  Encounter_Group AS _BYTE 'what types of creature encounters possible
  152.  Is_Village AS _BYTE
  153.  Is_Cave AS _BYTE 'Covers all Cave-like locations
  154.  Display_Layer AS _BYTE '
  155.  Search_Item AS _BYTE 'is there something to find? Most of these require a Flag set too
  156.  
  157. TYPE TownTiles
  158.  Is_Walkable AS _BYTE
  159.  Is_Animated AS _BYTE
  160.  Is_NPC_Location AS _BYTE 'where the NPCs stand
  161.  Is_Building AS _UNSIGNED _BYTE 'covers shops and houses
  162.  Is_Exit AS _BYTE
  163.  Search_Item AS _BYTE 'is there something to find? Most of these require a Flag set too
  164.  Dialogs AS INTEGER 'used with NPCs in Building for conversations
  165.  Setting AS _BYTE 'building inside and npc image to use
  166.  
  167. TYPE Spells
  168.  Nam AS STRING * 4
  169.  Cost AS _BYTE
  170.  
  171. TYPE KeyCodeData
  172.  Nam AS STRING * 8
  173.  Value AS LONG
  174.  
  175. TYPE DEVICE_Info
  176.  Buttons AS INTEGER
  177.  Axis_p AS _BYTE
  178.  
  179. TYPE PlayerSpellList
  180.  link AS _BYTE
  181.  
  182. TYPE Shopdata
  183.  Which AS _BYTE 'kind and location of shop(town, village\armory,secondhand,firstfoods)
  184.  items AS _BYTE 'number of items
  185.  Ilist AS _BYTE 'array link listing items for sale
  186.  Clist AS _BYTE 'array link listing cost of items
  187.  
  188. TYPE StartData
  189.  Map AS _BYTE
  190. TYPE ExitData
  191.  Map AS _BYTE
  192. TYPE NPCData
  193.  ID AS INTEGER
  194.  Msg AS INTEGER
  195. SCREEN _NEWIMAGE(700, 480, 32)
  196. DIM SHARED P(3) AS Player, Pack(23) AS _BYTE
  197. DIM SHARED M(74) AS Monsters, Pl(3, 30) AS PlayerLeveling, I(64) AS Items
  198. DIM SHARED S(18) AS Spells, PSL(3, 1, 4) AS PlayerSpellList
  199. DIM SHARED Dialog(1800) AS STRING, D(3) AS STRING * 5
  200. DIM SHARED KeyCodes(134) AS KeyCodeData, DeviceData(16) AS DEVICE_Info
  201. DIM SHARED TownMap(9, 54, 39) AS TownTiles '_UNSIGNED _BYTE
  202. DIM SHARED Map(128, 96) AS WorldTiles '_UNSIGNED _BYTE
  203. DIM SHARED Layer(127) AS LONG, SFX(64) AS LONG, BGM(32) AS LONG
  204. DIM SHARED G AS Game_Data, SavedNames(5) AS STRING * 5, C AS ControllerKeys, F(127) AS _BYTE
  205. DIM SHARED DungeonMap(9, 15, 15) AS _BYTE, DungeonMaster(127, 127) AS _BYTE
  206. DIM SHARED Chat(255, 31) AS INTEGER
  207. DIM SHARED Shops(32) AS Shopdata, ShopItems(32, 3) AS _BYTE, ShopCost(32, 3) AS INTEGER
  208. DIM SHARED Encounters(94, 7) AS _BYTE, Churches(-1 TO 32) AS Enter_Exit
  209. DIM SHARED frame%, FPSC%
  210.  
  211. DIM SHARED AlisAnim(4) AS _BYTE
  212. DIM SHARED AnimationOrder(3, 8) '8 frames for sync between Waves\marsh and Shore animations
  213. DIM SHARED NPC(127) AS NPCData, MSG$(127)
  214. DIM SHARED Enter(10) AS StartData
  215. DIM SHARED Exits(10) AS ExitData
  216. 'time for the layer system
  217. Layer(0) = _DISPLAY
  218. Layer(1) = _NEWIMAGE(640, 480, 32)
  219. Layer(2) = _NEWIMAGE(640, 480, 32)
  220. Layer(127) = _NEWIMAGE(640, 480, 32) 'temp junk layer
  221.  
  222. MFI_Loader "PhantasyStarI.MFI"
  223.  
  224. _CLEARCOLOR _RGB32(222, 223, 99), Layer(9)
  225. _CLEARCOLOR _RGB32(62), Layer(7)
  226. CONST Default_Key_Right = 19712, Default_Key_Left = 19200, Default_Key_Up = 18432, Default_Key_Down = 20480
  227. CONST Default_A_Button = 32, Default_B_Button = 13, Default_Start_Button = 65, Default_Select_Button = 66
  228. CONST ESC_Key = 27, ESC = 99
  229. CONST TRUE = -1, FALSE = NOT TRUE
  230. CONST New_Game = 101, Loaded_Game = 102
  231. CONST DOWN = 0, LEFT = 3, UP = 1, RIGHT = 2, SELECT_BUTTON = 4, START_BUTTON = 5, BUTTON_B = 6, BUTTON_A = 7
  232. CONST None = 0, WoodCane = 1, Short_Sword = 2, Iron_Sword = 3, Wand = 4, Iron_Fang = 5
  233. CONST Iron_Axe = 6, Titanium_Sword = 7, Ceramic_Sword = 8, Needle_Gun = 9, Silver_Fang = 10
  234. CONST Heat_Gun = 11, Light_Saber = 12, Laser_Gun = 13, Laconian_Sword = 14, Laconian_Axe = 15
  235. CONST Leather_Armor = 16, White_Mantle = 17, Light_Suit = 18, Iron_Armor = 19, Thick_Fur = 20
  236. CONST Zirconium_Armor = 21, Diamond_Armor = 22, Laconian_Armor = 23, Frad_Mantle = 24, Leather_Shield = 25
  237. CONST Bronze_Shield = 26, Iron_Shield = 27, Ciramic_Shield = 28, Glove = 29, Laser_Shield = 30
  238. CONST Mirror_Shield = 31, Laconian_Shield = 32, LandRover = 33, HoverCraft = 34, Ice_Digger = 35
  239. CONST Cola = 36, Burger = 37, Flute = 38, Flash = 39, Escaper = 40, Transer = 41
  240. CONST Magic_Hat = 42, Alsulin = 43, PolyMaterial = 44, Dungeon_Key = 45, Sphere = 46
  241. CONST Torch = 47, Prism = 48, Nuts = 49, Hapsby = 50, RoadPass = 51
  242. CONST PassPort = 52, Compass = 53, Cake = 54, Letter = 55, Laconian_Pot = 56
  243. CONST Magic_Lamp = 57, Amber_Eye = 58, Gas_Shield = 59, Crystal = 60, M_System = 61
  244. CONST Mirical_Key = 62, Zillion = 63, Secrets = 64
  245. CONST Weapon = 1, Armor = 2, Shield = 3, Special = 4, Consumeable = 5
  246. CONST NORTH = 0, EAST = 1, WEST = 2, SOUTH = 3
  247. CONST Alive = 0, Stoned = 1, Tied_Up = 2, Dead = 3
  248. 'Dungeon Constants 0-NONE, 9-Unknown
  249. CONST Wall = 1, FloorUp = 2, FloorDown = 3, UnlockedDoor = 4, D_KeyDoor = 5, M_KeyDoor = 6
  250. CONST FakeWall = 7, Object = 8, ExitUP = 10, ExitDown = 11, ExitDoor = 12, ExitDoorLocked = 13
  251. CONST ExitMagicDoor = 14, OpenDoor = UnlockedDoor + &H80
  252. CONST Magic_Bye = 1, Magic_Chat = 2, Magic_Cure = 3, Magic_Exit = 4, Magic_Fire = 5, Magic_Fly = 6
  253. CONST Magic_Heal = 7, Magic_Help = 8, Magic_Open = 9, Magic_Prot = 10, Magic_Rise = 11
  254. CONST Magic_Rope = 12, Magic_Tele = 13, Magic_Terr = 14, Magic_Thun = 15, Magic_Trap = 16
  255. CONST Magic_Wall = 17, Magic_Wind = 18
  256. CONST Max_Pack_Count = 24
  257. CONST Medusa_Cave = 2
  258.  
  259. 'place the conveyor system in corect world location
  260. CONST Conveyor_1_Pos_X = 32 * 82
  261. CONST Conveyor_1_Pos_Y = 32 * 53 + 8
  262. CONST Conveyor_2_Pos_X = 32 * 79 + 8
  263. CONST Conveyor_2_Pos_Y = 32 * 56
  264. CONST Conveyor_Frame_Speed = 2
  265. '--------------------------------------------------
  266. 'Eppi Cover location
  267. CONST Eppi_Cover_Pos_X = 32 * 94
  268. CONST Eppi_Cover_Pos_Y = 32 * 85
  269. '--------------------------------------------------
  270. DATA 0,1,2,3,4,4,1,0: 'shore animation order
  271. FOR i%% = 0 TO 7
  272.  READ AnimationOrder(1, i%%)
  273. NEXT i%%
  274. DATA 0,1,2,1: 'animation frame order
  275. FOR i%% = 0 TO 3
  276.  READ AlisAnim(i%%)
  277. NEXT i%%
  278. DATA 36,18,0: 'Enter camineet
  279. DATA 22,28,2: 'Enter parolit
  280. DATA 11,19,3: 'Enter Scion
  281. DATA 22,24,7: 'Enter Eppi
  282.  
  283. DATA 85,47,-1: 'exit to camineet to overworld
  284. DATA 36,20,1: 'enter space port from camineet
  285. DATA 10,20,0: 'enter camineet from space port
  286. DATA 24,11,2: 'enter parolit from space port
  287. DATA 24,27,1: 'enter space port from parolit
  288. DATA 73,58,-1: 'exit parolit to overworld
  289. DATA 102,46,-1: 'exit Scion to overworld
  290. DATA 85,80,-1: 'Exit Eppi to Overworld
  291. FOR En%% = 1 TO 4
  292.  READ Enter(En%%).X, Enter(En%%).Y, Enter(En%%).Map
  293. NEXT En%%
  294. FOR Ex%% = 1 TO 8
  295.  READ Exits(Ex%%).X, Exits(Ex%%).Y, Exits(Ex%%).Map
  296. NEXT Ex%%
  297. 'Enter Camineet from over world
  298. Map(82, 46).Is_Village = 1
  299. Map(83, 46).Is_Village = 1
  300. Map(82, 47).Is_Village = 1
  301. Map(83, 47).Is_Village = 1
  302. 'enter Parolit from Over world
  303. Map(70, 58).Is_Village = 2
  304. Map(71, 58).Is_Village = 2
  305. Map(70, 57).Is_Village = 2
  306. Map(71, 57).Is_Village = 2
  307. 'Enter Scion from Over world
  308. Map(103, 46).Is_Village = 3
  309. Map(104, 46).Is_Village = 3
  310. Map(103, 45).Is_Village = 3
  311. Map(104, 45).Is_Village = 3
  312. 'Enter Eppi from Over world(with compass only)
  313. Map(85, 78).Is_Village = 4
  314. Map(86, 78).Is_Village = 4
  315. Map(85, 79).Is_Village = 4
  316. Map(86, 79).Is_Village = 4
  317. '------------------------------
  318. 'Exit Camineet to over world
  319. TownMap(0, 37, 18).Is_Exit = 1
  320. TownMap(0, 38, 18).Is_Exit = 1
  321. TownMap(0, 19, 27).Is_Exit = 1
  322. TownMap(0, 20, 27).Is_Exit = 1
  323. 'Exit Camineet to Space port(if player has roadpass
  324. TownMap(0, 9, 19).Is_Exit = 2
  325. TownMap(0, 9, 20).Is_Exit = 2
  326. '------------------------------
  327. 'Exit Space Port to Camineet
  328. TownMap(1, 38, 20).Is_Exit = 3
  329. 'Exit Space Port to Parolit
  330. TownMap(1, 24, 29).Is_Exit = 4
  331. TownMap(1, 25, 29).Is_Exit = 4
  332. '------------------------------
  333. 'Exit Parolit to Space Port
  334. TownMap(2, 24, 10).Is_Exit = 5
  335. 'Exit Parolit to Over World
  336. TownMap(2, 22, 27).Is_Exit = 6
  337. TownMap(2, 23, 27).Is_Exit = 6
  338. '------------------------------
  339. 'Exit Scion to Overworld
  340. TownMap(3, 10, 19).Is_Exit = 7
  341. '------------------------------
  342. 'Exit Eppi to Overworld
  343. TownMap(7, 22, 25).Is_Exit = 8
  344. TownMap(7, 23, 25).Is_Exit = 8
  345. TownMap(7, 22, 25).Is_Walkable = -1
  346. TownMap(7, 23, 25).Is_Walkable = -1
  347. '------------------------------
  348. 'NPC data fields
  349. 'Camineet
  350. DATA 5,36,17,0
  351. DATA 5,38,20,0
  352. DATA 5,10,21,1
  353. DATA 5,10,19,1
  354. DATA 5,18,27,2
  355. DATA 5,21,27,2
  356. DATA 4,22,10,
  357. DATA 4,20,16,
  358. DATA 4,22,24,
  359. DATA 4,13,23,
  360. FOR i%% = 0 TO 5
  361.  READ NPC(i%%).ID, NPC(i%%).X, NPC(i%%).Y
  362. NEXT i%%
  363. '----------------------------------------
  364. 'NPC Messages
  365. DATA "You had better not leave the residential area"
  366.  
  367. ON TIMER(T2!, 1) FPS
  368. TIMER(T2!) ON
  369. INIT_Controls
  370. Load_New_Game_Stats
  371.  
  372.  IF CheckFlag%% THEN Location_Checker P(0).Is_Intown, P(0).Wx, P(0).Wy: CheckFlag%% = FALSE
  373.  IF P(0).Is_Intown > -1 THEN
  374.   TownMap_Tile_loader P(0).Wx, P(0).Wy, P(0).Tx, P(0).Ty 'Mapx%, Mapy%, Playrx%, Playry%
  375.   Map_Loader_tiled_Base P(0).Wx, P(0).Wy, P(0).Tx, P(0).Ty 'Mapx%, Mapy%, Playrx%, Playry%
  376.  Debugging
  377.  Place_Alis
  378.  _PUTIMAGE , Layer(2), Layer(1)
  379.  ClearLayerTrans Layer(2)
  380.  _PUTIMAGE (0, 0), Layer(1), _DISPLAY
  381.  frame% = frame% + 1
  382.  '-----------------Controls------------------
  383.  IF _KEYDOWN(Default_Key_Up) AND (NOT G.Moving) THEN G.Facing = UP: G.Moving = TRUE
  384.  IF _KEYDOWN(Default_Key_Left) AND (NOT G.Moving) THEN G.Facing = LEFT: G.Moving = TRUE
  385.  IF _KEYDOWN(Default_Key_Right) AND (NOT G.Moving) THEN G.Facing = RIGHT: G.Moving = TRUE
  386.  IF _KEYDOWN(Default_Key_Down) AND (NOT G.Moving) THEN G.Facing = DOWN: G.Moving = TRUE
  387.  IF _KEYDOWN(27) THEN exitflag%% = -1
  388.  SELECT CASE G.Facing
  389.   CASE UP
  390.    IF Collision(P(0).Wx, P(0).Wy - 1) THEN G.Moving = FALSE
  391.   CASE DOWN
  392.    IF Collision(P(0).Wx, P(0).Wy + 1) THEN G.Moving = FALSE
  393.   CASE LEFT
  394.    IF Collision(P(0).Wx - 1, P(0).Wy) THEN G.Moving = FALSE
  395.   CASE RIGHT
  396.    IF Collision(P(0).Wx + 1, P(0).Wy) THEN G.Moving = FALSE
  397.  
  398.  '--------------------------------------------
  399.  '----------------Movement--------------------
  400.  IF G.Moving THEN
  401.   SELECT CASE G.Facing
  402.    CASE UP
  403.     P(0).Ty = P(0).Ty + 2
  404.     IF (ABS(P(0).Ty) MOD 32) = 0 THEN G.Moving = FALSE: P(0).Wy = P(0).Wy - 1: P(0).Ty = 0: CheckFlag%% = TRUE
  405.     IF NOT _KEYDOWN(Default_Key_Up) THEN Ft%% = 0: P(0).Fr = 0 ELSE G.Moving = TRUE
  406.    CASE DOWN
  407.     P(0).Ty = P(0).Ty - 2
  408.     IF (P(0).Ty MOD 32) = 0 THEN G.Moving = FALSE: P(0).Wy = P(0).Wy + 1: P(0).Ty = 0: CheckFlag%% = TRUE
  409.     IF NOT _KEYDOWN(Default_Key_Down) THEN Ft%% = 0: P(0).Fr = 0 ELSE G.Moving = TRUE
  410.    CASE LEFT
  411.     P(0).Tx = P(0).Tx + 2
  412.     IF (ABS(P(0).Tx) MOD 32) = 0 THEN G.Moving = FALSE: P(0).Wx = P(0).Wx - 1: P(0).Tx = 0: CheckFlag%% = TRUE
  413.     IF NOT _KEYDOWN(Default_Key_Left) THEN Ft%% = 0: P(0).Fr = 0 ELSE G.Moving = TRUE
  414.    CASE RIGHT
  415.     P(0).Tx = P(0).Tx - 2
  416.     IF (P(0).Tx MOD 32) = 0 THEN G.Moving = FALSE: P(0).Wx = P(0).Wx + 1: P(0).Tx = 0: CheckFlag%% = TRUE
  417.     IF NOT _KEYDOWN(Default_Key_Right) THEN Ft%% = 0: P(0).Fr = 0 ELSE G.Moving = TRUE
  418.  IF G.Moving THEN Ft%% = Ft%% + 1
  419.  IF Ft%% = 8 THEN P(0).Fr = P(0).Fr + 1: Ft%% = 0
  420.  IF P(0).Fr = 4 THEN P(0).Fr = 0
  421.  'Correct for map wrap
  422.  IF P(0).Wx = 128 THEN P(0).Wx = 0
  423.  IF P(0).Wx = -1 THEN P(0).Wx = 127
  424.  IF P(0).Wy = 96 THEN P(0).Wy = 0
  425.  IF P(0).Wy = -1 THEN P(0).Wy = 95
  426.  '--------------------
  427.  
  428.  _LIMIT 60
  429. LOOP UNTIL exitflag%%
  430. TIMER(T2!) OFF
  431. _DEST Layer(0)
  432.  
  433. FUNCTION Collision (X1%, Y1%)
  434.  Result%% = TRUE 'always assume collision
  435.  IF P(0).Is_Intown > -1 THEN
  436.   IF TownMap(P(0).Is_Intown, X1%, Y1%).Is_Walkable THEN Result%% = FALSE
  437.   IF Map(X1%, Y1%).Is_Walkable THEN Result%% = FALSE
  438.  Collision = Result%%
  439.  
  440. SUB Map_Loader_tiled_Base (X1%, Y1%, Sx%, Sy%)
  441.  STATIC SubFrame(3) AS _BYTE, MainFrame(3) AS _BYTE, Triggered%%
  442.  FOR x% = -1 TO 20
  443.   FOR y% = -1 TO 15
  444.    mx% = X1% + x% - 9 '-9 to center on player character
  445.    my% = Y1% + y% - 7 '-7 to center(ish) on player character
  446.    '------Adjust for map wrap around------
  447.    IF mx% < 0 THEN mx% = 128 + mx% 'use addition cause mx% is a negative
  448.    IF mx% > 127 THEN mx% = mx% - 128
  449.    IF my% < 0 THEN my% = 96 + my% 'use addition cause my% is a negative
  450.    IF my% > 95 THEN my% = my% - 96
  451.    '--------------------------------------
  452.    'main map tiles
  453.    _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), Layer(4), Layer(Map(mx%, my%).Display_Layer), (0 + Map(mx%, my%).Id * 34, 0)-STEP(31, 31)
  454.    'animated map tiles
  455.    IF Map(mx%, my%).Is_Animated THEN
  456.     SELECT CASE Map(mx%, my%).Id
  457.      CASE 1 TO 4 'waves
  458.       _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), Layer(6), Layer(1), (544 + MainFrame(1) * 34, 0)-STEP(31, 31)
  459.      CASE 21 TO 25 'marsh
  460.       _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), Layer(6), Layer(1), (544 + (Map(mx%, my%).Id - 21) * 34, 34 + MainFrame(1) * 34)-STEP(31, 31)
  461.      CASE 5 TO 20 'shore
  462.       _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), Layer(6), Layer(1), ((Map(mx%, my%).Id - 5) * 34, AnimationOrder(1, MainFrame(2)) * 34)-STEP(31, 31)
  463.     END SELECT
  464.    END IF
  465.   NEXT y%
  466.  NEXT x%
  467.  'Horizontal conveyor
  468.  _PUTIMAGE (Sx% + Conveyor_1_Pos_X - (X1% * 32), Sy% + Conveyor_1_Pos_Y - (Y1% * 32)), Layer(5), Layer(2), (0, 0 + (MainFrame(0) * 34))-STEP(255, 31)
  469.  'vertical conveyor
  470.  _PUTIMAGE (Sx% + Conveyor_2_Pos_X - (X1% * 32), Sy% + Conveyor_2_Pos_Y - (Y1% * 32)), Layer(5), Layer(2), (257 + (MainFrame(0) * 34), 0)-STEP(31, 223)
  471.  'Unless Player has compass Hide the Village of Eppi
  472.  IF Has_Compass = FALSE THEN
  473.   _PUTIMAGE (Sx% + Eppi_Cover_Pos_X - (X1% * 32), Sy% + Eppi_Cover_Pos_Y - (Y1% * 32)), Layer(4), Layer(1), (34 * 27, 0)-STEP(31, 31)
  474.   _PUTIMAGE (32 + Sx% + Eppi_Cover_Pos_X - (X1% * 32), Sy% + Eppi_Cover_Pos_Y - (Y1% * 32)), Layer(4), Layer(1), (34 * 27, 0)-STEP(31, 31)
  475.   _PUTIMAGE (Sx% + Eppi_Cover_Pos_X - (X1% * 32), 32 + Sy% + Eppi_Cover_Pos_Y - (Y1% * 32)), Layer(4), Layer(1), (34 * 27, 0)-STEP(31, 31)
  476.   _PUTIMAGE (32 + Sx% + Eppi_Cover_Pos_X - (X1% * 32), 32 + Sy% + Eppi_Cover_Pos_Y - (Y1% * 32)), Layer(4), Layer(1), (34 * 27, 0)-STEP(31, 31)
  477.  FOR i%% = 0 TO 2
  478.   SubFrame(i%%) = SubFrame(i%%) + 1
  479.   IF SubFrame(0) = 5 + Conveyor_Frame_Speed THEN MainFrame(0) = MainFrame(0) + Conveyor_Frame_Speed: SubFrame(0) = 0
  480.   IF SubFrame(1) = 16 THEN MainFrame(1) = MainFrame(1) + 1: SubFrame(1) = 0
  481.   IF SubFrame(2) = 24 THEN MainFrame(2) = MainFrame(2) + 1: SubFrame(2) = 0
  482.  NEXT i%%
  483.  IF MainFrame(0) = 8 THEN MainFrame(0) = 0
  484.  IF MainFrame(1) = 4 THEN MainFrame(1) = 0
  485.  IF MainFrame(2) = 8 THEN MainFrame(2) = 0
  486.  
  487. SUB TownMap_Tile_loader (X1%, Y1%, Sx%, Sy%)
  488.  FOR x% = -1 TO 20
  489.   FOR y% = -1 TO 15
  490.    mx% = X1% + x% - 9 '-9 to center on player character
  491.    my% = Y1% + y% - 7 '-7 to center(ish) on player character
  492.    'town map tiles
  493.    _PUTIMAGE (Sx% + x% * 32, Sy% + y% * 32)-STEP(31, 31), Layer(3), Layer(1), (0 + TownMap(P(0).Is_Intown, mx%, my%).Id * 34, 0)-STEP(31, 31)
  494.   NEXT
  495.  
  496. SUB FPS
  497.  ' STATIC LastCount%
  498.  FPSC% = frame%
  499.  frame% = 0
  500.  
  501. SUB Place_Alis
  502.  IF NOT G.Moving THEN
  503.   _PUTIMAGE (290, 210)-STEP(31, 45), Layer(7), Layer(1), (0 + 17 * G.Facing, 120)-STEP(15, 22)
  504.   _PUTIMAGE (290, 210)-STEP(31, 45), Layer(7), Layer(1), (68 + 51 * G.Facing + AlisAnim(P(0).Fr) * 17, 120)-STEP(15, 22)
  505.  
  506. SUB Location_Checker (Map%%, X%, Y%)
  507.  OldX% = X%
  508.  OldY% = Y%
  509.  OldMap%% = Map%%
  510.  IF P(0).Is_Intown > -1 THEN
  511.  
  512.   IF TownMap(Map%%, X%, Y%).Is_Building THEN
  513.    SELECT CASE TownMap(Map%%, X%, Y%).Is_Building
  514.     CASE &HFF 'flaged conversations
  515.      Build_House_Setting TownMap(Map%%, X%, Y%).Setting
  516.      Flagged_Conversations TownMap(Map%%, X%, Y%).Dialogs
  517.      Back_Up_Player
  518.     CASE &H80 'Enter a Dungeon area
  519.     CASE &H40 'shops
  520.      ClearLayer Layer(1)
  521.      Shop TownMap(Map%%, X%, Y%).Dialogs
  522.      Back_Up_Player
  523.      Input_OR_Wait 128
  524.     CASE &H20 'town Exit
  525.      'currently handled with IS_EXIT
  526.     CASE &H10 'interactive Conversation
  527.      '     Build_House_Setting TownMap(Map%%, X%, Y%).Setting
  528.      Create_Dialog_Box 9, 21, 4, 18
  529.      TimedPrint 10, 23, "THE DOOR IS LOCKED", 20 '
  530.      Input_OR_Wait 128
  531.      Back_Up_Player
  532.     CASE &H08 'church
  533.      ClearLayer Layer(1)
  534.      G.Last_Church = P(0).Is_Intown ' visited church so set this as the return point for FLY
  535.      Church TownMap(Map%%, X%, Y%).Setting 'carrys the church ID value for look
  536.      Back_Up_Player
  537.      Input_OR_Wait 128
  538.     CASE &H01 'standard dialog
  539.      Build_House_Setting TownMap(Map%%, X%, Y%).Setting
  540.      Conversations TownMap(Map%%, X%, Y%).Dialogs
  541.      Back_Up_Player
  542.    END SELECT
  543.   END IF
  544.   IF TownMap(Map%%, X%, Y%).Is_Exit THEN
  545.    P(0).Is_Intown = Exits(TownMap(OldMap%%, OldX%, OldY%).Is_Exit).Map
  546.    P(0).Wx = Exits(TownMap(OldMap%%, OldX%, OldY%).Is_Exit).X
  547.    P(0).Wy = Exits(TownMap(OldMap%%, OldX%, OldY%).Is_Exit).Y
  548.   END IF
  549.  
  550.   IF Map(X%, Y%).Is_Village THEN
  551.    IF Map(X%, Y%).Is_Village = 4 THEN
  552.     IF Has_Compass THEN 'Can only enter Eppi when you have the compass
  553.      P(0).Is_Intown = Enter(Map(OldX%, OldY%).Is_Village).Map
  554.      P(0).Wx = Enter(Map(OldX%, OldY%).Is_Village).X
  555.      P(0).Wy = Enter(Map(OldX%, OldY%).Is_Village).Y
  556.     END IF
  557.    ELSE
  558.     P(0).Is_Intown = Enter(Map(OldX%, OldY%).Is_Village).Map
  559.     P(0).Wx = Enter(Map(OldX%, OldY%).Is_Village).X
  560.     P(0).Wy = Enter(Map(OldX%, OldY%).Is_Village).Y
  561.    END IF
  562.   END IF
  563.  
  564. REM '$include:'PS1_Conversation_subs.bas'
  565.  
  566. SUB Load_New_Game_Stats
  567.  P(0).N = "ALIS"
  568.  P(0).Hp = 16
  569.  P(0).Mp = 0
  570.  P(0).MHp = 16
  571.  P(0).MMp = 0
  572.  P(0).Wepn = Short_Sword
  573.  P(0).Armr = Leather_Armor
  574.  P(0).Shld = None
  575.  P(0).Attk = 8
  576.  P(0).Defn = 8
  577.  '---------------
  578.  P(1).N = "MYAU"
  579.  P(1).Hp = 22
  580.  P(1).Mp = 0
  581.  P(1).MHp = 22
  582.  P(1).MMp = 0
  583.  P(1).Wepn = None
  584.  P(1).Armr = None
  585.  P(1).Shld = None
  586.  P(1).Attk = 18
  587.  P(1).Defn = 22
  588.  '---------------
  589.  P(2).N = "ODIN"
  590.  P(2).Hp = 42
  591.  P(2).Mp = 0
  592.  P(2).MHp = 42
  593.  P(2).MMp = 0
  594.  P(2).Wepn = Iron_Axe
  595.  P(2).Armr = Leather_Armor
  596.  P(2).Shld = None
  597.  P(2).Attk = 13
  598.  P(2).Defn = 13
  599.  '---------------
  600.  P(3).N = "LAIA" 'More feminine than Noah
  601.  P(3).Hp = 45
  602.  P(3).Mp = 12
  603.  P(3).MHp = 45
  604.  P(3).MMp = 12
  605.  P(3).Wepn = WoodCane
  606.  P(3).Armr = White_Mantle
  607.  P(3).Shld = None
  608.  P(3).Attk = 18
  609.  P(3).Defn = 30
  610.  '---------------
  611.  G.Meseta = 0
  612.  G.Party_Size = 0 'start with only Alis
  613.  FOR i%% = 0 TO 23
  614.   Pack(i%%) = 0
  615.  NEXT i%%
  616.  FOR i%% = 0 TO 3
  617.   P(i%%).Level = 1
  618.   P(i%%).Exp = 0
  619.   P(i%%).Combat = -1
  620.   P(i%%).NonCombat = -1
  621.   P(0).Is_Intown = 0 'Town ID for Camineet (-1 if not in a town)
  622.   P(i%%).Wx = 33 'Start outside Alis's home
  623.   P(i%%).Wy = 13
  624.   P(i%%).Tx = 0
  625.   P(i%%).Ty = 0
  626.   P(i%%).Fr = 0
  627.  NEXT i%%
  628.  P(3).Combat = 0
  629.  P(3).NonCombat = 0
  630.  FOR i%% = 0 TO 127
  631.   F(i%%) = FALSE
  632.  NEXT i%%
  633.  
  634. SUB Back_Up_Player
  635.  'Move player back to space where they enter building from
  636.  G.Moving = FALSE
  637.  SELECT CASE G.Facing
  638.   CASE UP
  639.    P(0).Wy = P(0).Wy + 1
  640.   CASE DOWN
  641.    P(0).Wy = P(0).Wy - 1
  642.   CASE LEFT
  643.    P(0).Wx = P(0).Wx + 1
  644.   CASE RIGHT
  645.    P(0).Wx = P(0).Wx - 1
  646.  FOR i%% = 1 TO 3 'make sure whole party is in correct location
  647.   P(i%%).Wx = P(0).Wx
  648.   P(i%%).Wy = P(0).Wy
  649.  NEXT i%%
  650.  G.Facing = DOWN
  651.  
  652. SUB Place_NPC (Who%%)
  653.  _PUTIMAGE (281, 200)-STEP(75, 183), Layer(9), Layer(1), (0 + Who%% * 39, 450)-STEP(37, 92)
  654.  
  655. SUB Build_House_Setting (id%%)
  656.  ClearLayer Layer(1)
  657.  '-----------------Setup screen--------------
  658.  'BGI -if bit 7 set then use alt scene layout
  659.  _PUTIMAGE (64, 48)-STEP(511, 383), Layer(8), Layer(1), (256 * ABS(_READBIT(id%%, 7)), 192)-STEP(255, 191)
  660.  'Character - can be red, green or blue man
  661.  Char~%% = _SHL(id%%, 4) 'bump 4 high bits(4-7)
  662.  Char~%% = _SHR(Char~%%, 4) 'reset to find what type of NPC
  663.  IF Char~%% > 0 THEN Place_NPC Char~%% 'no robo-gaurds in houses
  664.  _PUTIMAGE (0, 0), Layer(1), Layer(0)
  665.  '---------------------------------------------
  666.  
  667. SUB ClearLayer (L&)
  668.  old& = _DEST
  669.  _DEST L&
  670.  CLS ' ,0
  671.  _DEST old&
  672.  
  673. SUB ClearLayerTrans (L&)
  674.  old& = _DEST
  675.  _DEST L&
  676.  CLS , 0
  677.  _DEST old&
  678.  
  679. SUB Debugging
  680.  IF P(0).Is_Intown > -1 THEN
  681.   _PRINTSTRING (640, 45), "ID-" + STR$(TownMap(P(0).Is_Intown, P(0).Wx, P(0).Wy).Id), Layer(0)
  682.   _PRINTSTRING (640, 60), "UP-" + STR$(TownMap(P(0).Is_Intown, P(0).Wx, P(0).Wy - 1).Id) + " ", Layer(0)
  683.   _PRINTSTRING (640, 75), "DN-" + STR$(TownMap(P(0).Is_Intown, P(0).Wx, P(0).Wy + 1).Id) + " ", Layer(0)
  684.   _PRINTSTRING (640, 90), "LT-" + STR$(TownMap(P(0).Is_Intown, P(0).Wx - 1, P(0).Wy).Id) + " ", Layer(0)
  685.   _PRINTSTRING (640, 105), "RT-" + STR$(TownMap(P(0).Is_Intown, P(0).Wx + 1, P(0).Wy).Id) + " ", Layer(0)
  686.   _PRINTSTRING (640, 120), "XT-" + STR$(TownMap(P(0).Is_Intown, P(0).Wx, P(0).Wy).Is_Exit) + " ", Layer(0)
  687.   _PRINTSTRING (640, 135), "TwN-" + STR$(P(0).Is_Intown) + " ", Layer(0)
  688.   _PRINTSTRING (640, 150), "bd-&H" + HEX$(TownMap(P(0).Is_Intown, P(0).Wx, P(0).Wy).Is_Building) + " ", Layer(0)
  689.  
  690.   _PRINTSTRING (640, 45), "ID-" + STR$(Map(P(0).Wx, P(0).Wy).Id), Layer(0)
  691.   _PRINTSTRING (640, 60), "UP-" + STR$(Map(P(0).Wx, P(0).Wy - 1).Id) + " ", Layer(0)
  692.   _PRINTSTRING (640, 75), "DN-" + STR$(Map(P(0).Wx, P(0).Wy + 1).Id) + " ", Layer(0)
  693.   _PRINTSTRING (640, 90), "LT-" + STR$(Map(P(0).Wx - 1, P(0).Wy).Id) + " ", Layer(0)
  694.   _PRINTSTRING (640, 105), "RT-" + STR$(Map(P(0).Wx + 1, P(0).Wy).Id) + " ", Layer(0)
  695.  _PRINTSTRING (640, 0), "FPS-" + STR$(FPSC%), Layer(0)
  696.  _PRINTSTRING (640, 15), "X-" + STR$(P(0).Wx), Layer(0)
  697.  _PRINTSTRING (640, 30), "Y-" + STR$(P(0).Wy), Layer(0)
  698.  
  699. SUB MFI_Loader (FN$)
  700.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  701.  GET #1, , c~%% 'retrieve number of files
  702.  FOR I~%% = 1 TO c~%%
  703.   GET #1, , FOffset(I~%%)
  704.   GET #1, , Size(I~%%)
  705.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  706.  NEXT I~%%
  707.  
  708.  Layer(3) = LoadGFX(FOffset(5), Size(5)) 'townmap tiles
  709.  Layer(4) = LoadGFX(FOffset(1), Size(1)) '_LOADIMAGE("gfx\maps\PalmaTiles2x2.bmp", 32) '_NEWIMAGE(640, 480, 32)
  710.  Layer(5) = LoadGFX(FOffset(2), Size(2)) '_LOADIMAGE("gfx\maps\conveyoranim.bmp", 32) 'Conveyor
  711.  Layer(6) = LoadGFX(FOffset(3), Size(3)) '_LOADIMAGE("gfx\maps\mapanimation.bmp", 32) 'Water, shore, and marsh frames
  712.  Layer(7) = LoadGFX(FOffset(4), Size(4)) '_LOADIMAGE("gfx\CharacterSheetC.png", 32) '
  713.  Layer(8) = LoadGFX(FOffset(6), Size(6)) 'backgrounds
  714.  Layer(9) = LoadGFX(FOffset(7), Size(7)) 'Cutscene_NPCsprites
  715.  Layer(10) = LoadGFX(FOffset(8), Size(8)) 'Font
  716.  
  717.  
  718.  LoadData FOffset(9), Size(9)
  719.  F1 = FREEFILE
  720.  OPEN "temp.dat" FOR BINARY AS #F1
  721.  PRINT LOF(F1)
  722.  GET #F1, , M()
  723.  GET #F1, , I()
  724.  GET #F1, , S()
  725.  GET #F1, , Pl()
  726.  GET #F1, , PSL()
  727.  GET #F1, , KeyCodes()
  728.  PRINT LOC(F1)
  729.  GET #F1, , Lines_of_Dialog%
  730.  FOR i% = 0 TO Lines_of_Dialog%
  731.   GET #F1, , L~%%
  732.   Dialog(i%) = SPACE$(L~%%)
  733.   GET #F1, , Dialog(i%)
  734.  NEXT i%
  735.  FOR i%% = 0 TO 3
  736.   GET #F1, , D(i%%)
  737.  NEXT i%%
  738.  GET #F1, , Encounters()
  739.  GET #F1, , DungeonMaster()
  740.  GET #F1, , Shops()
  741.  GET #F1, , ShopItems()
  742.  GET #F1, , ShopCost()
  743.  GET #F1, , Chat()
  744.  PRINT LOC(F1)
  745.  GET #F1, , TownMap()
  746.  PRINT LOC(F1)
  747.  GET #F1, , Map()
  748.  PRINT LOC(F1)
  749.  CLOSE #F1
  750.  ' END
  751.  CLOSE #1
  752.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  753.  
  754. SUB LoadData (Foff&, Size&)
  755.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  756.  OPEN "temp.dat" FOR BINARY AS #3
  757.  dat$ = SPACE$(Size&)
  758.  GET #1, Foff&, dat$
  759.  PUT #3, , dat$
  760.  CLOSE #3
  761.  
  762. REM '$include:'MFI_Loader2.bi'
  763.  
  764. FUNCTION LoadGFX& (Foff&, Size&)
  765.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  766.  OPEN "temp.dat" FOR BINARY AS #3
  767.  dat$ = SPACE$(Size&)
  768.  GET #1, Foff&, dat$
  769.  PUT #3, , dat$
  770.  CLOSE #3
  771.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  772.  
  773. FUNCTION LoadFFX& (Foff&, Size&, Fize%%)
  774.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  775.  OPEN "temp.dat" FOR BINARY AS #3
  776.  dat$ = SPACE$(Size&)
  777.  GET #1, Foff&, dat$
  778.  PUT #3, , dat$
  779.  CLOSE #3
  780.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, "monospace")
  781.  
  782. FUNCTION LoadSFX& (Foff&, Size&)
  783.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  784.  OPEN "temp.dat" FOR BINARY AS #3
  785.  dat$ = SPACE$(Size&)
  786.  GET #1, Foff&, dat$
  787.  PUT #3, , dat$
  788.  CLOSE #3
  789.  LoadSFX& = _SNDOPEN("temp.dat")
  790.  
  791. REM'$include:'PS1_PrintSubs.bas'
  792. REM'$include:'PS1_Controls.bas'
  793. REM'$include:'PS1_Conversation_testing.bas'
  794. SUB PS_Print (X%, Y%, TxT$, L&)
  795.  L% = LEN(TxT$)
  796.  FOR i%% = 1 TO L%
  797.   By%% = 0
  798.   IF MID$(TxT$, i%%, 1) = CHR$(34) OR MID$(TxT$, i%%, 1) = CHR$(39) THEN By%% = 10
  799.   IF MID$(TxT$, i%%, 1) = CHR$(44) OR MID$(TxT$, i%%, 1) = CHR$(46) THEN By%% = -4
  800.   _PUTIMAGE (X% + i%% * 16, Y% - By%%)-STEP(15, 15), Layer(10), L&, (1 + (10 * (ASC(MID$(TxT$, i%%, 1)) - 32)), 1 + G.ColorShift)-STEP(7, 7)
  801.  
  802. SUB Scroll_Dialog_Box (X%, Y%, H%, W%)
  803.  X% = X% * 16 + 32
  804.  Y% = Y% * 16 + 16
  805.  H% = H% * 16
  806.  W% = W% * 16
  807.  Scrl%% = 32
  808.  temp& = _COPYIMAGE(Layer(0))
  809.  FOR I%% = 0 TO Scrl%% STEP 4
  810.   _PUTIMAGE (X%, Y%)-STEP(W% - 1, H% + 3), temp&, Layer(0), (X%, Y% + 4)-STEP(W% - 1, H% + 3)
  811.   _PUTIMAGE (0, 0), Layer(0), temp&
  812.   _LIMIT 60
  813.  NEXT I%%
  814.  _PUTIMAGE (0, 0), Layer(0), Layer(1)
  815.  _FREEIMAGE temp&
  816.  
  817. SUB TimedPrint (X%, Y%, Txt$, LPS%)
  818.  Speed! = (100 / LPS%) / 100
  819.  FOR i%% = 1 TO LEN(Txt$)
  820.   By%% = 0
  821.   IF MID$(Txt$, i%%, 1) = CHR$(34) OR MID$(Txt$, i%%, 1) = CHR$(39) THEN By%% = 10
  822.   IF MID$(Txt$, i%%, 1) = CHR$(44) OR MID$(Txt$, i%%, 1) = CHR$(46) THEN By%% = -4
  823.   _PUTIMAGE (16 * X% + i%% * 16, 16 * Y% - By%%)-STEP(15, 15), Layer(10), Layer(1), (1 + (10 * (ASC(MID$(Txt$, i%%, 1)) - 32)), 1)-STEP(7, 7)
  824.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  825.   _DELAY Speed!
  826.  NEXT i%%
  827.  
  828. SUB Create_Dialog_Box (X%, Y%, H%, W%)
  829.  Top$ = "a"
  830.  Bot$ = "g"
  831.  FOR i%% = 1 TO W%
  832.   Top$ = Top$ + "b"
  833.   Bot$ = Bot$ + "h"
  834.  NEXT i%%
  835.  Top$ = Top$ + "c"
  836.  Bot$ = Bot$ + "i"
  837.  sid$ = "d" + SPACE$(W%) + "f"
  838.  PS_Print X% * 16, Y% * 16, Top$, Layer(1)
  839.  FOR i%% = 1 TO H%
  840.   PS_Print X% * 16, (Y% + i%%) * 16, sid$, Layer(1)
  841.  NEXT i%%
  842.  PS_Print X% * 16, (Y% + i%%) * 16, Bot$, Layer(1)
  843.  
  844. FUNCTION AxisPower%% (CJR%%, CJL%%, CJU%%, CJD%%)
  845.  CJR%% = _AXIS(C.Joy_Right)
  846.  CJL%% = _AXIS(C.Joy_Left)
  847.  CJU%% = _AXIS(C.Joy_Up)
  848.  CJD%% = _AXIS(C.Joy_Down)
  849.  IF CJR%% = C.Joy_Right_Val THEN CJL%% = 0: CJR%% = TRUE ELSE CJR%% = 0
  850.  IF CJD%% = C.Joy_Down_Val THEN CJU%% = 0: CJD%% = TRUE ELSE CJD%% = 0
  851.  AxisPower = nul%%
  852.  
  853. FUNCTION Get_Input%% ()
  854.  Result%% = TRUE '-1 for no input
  855.  SELECT CASE G.ControlType
  856.   CASE TRUE 'Keyboard input
  857.    IF _KEYDOWN(ESC_Key) THEN Result%% = ESC
  858.    IF _KEYDOWN(C.KBCon_Up) THEN Result%% = UP
  859.    IF _KEYDOWN(C.KBCon_Down) THEN Result%% = DOWN
  860.    IF _KEYDOWN(C.KBCon_Left) THEN Result%% = LEFT
  861.    IF _KEYDOWN(C.KBCon_Right) THEN Result%% = RIGHT
  862.    IF _KEYDOWN(C.KBCon_A_Button) THEN Result%% = BUTTON_A: DO: LOOP WHILE _KEYDOWN(C.KBCon_A_Button)
  863.    IF _KEYDOWN(C.KBCon_B_Button) THEN Result%% = BUTTON_B: DO: LOOP WHILE _KEYDOWN(C.KBCon_B_Button)
  864.  
  865.   CASE FALSE 'joystick input
  866.    IF C.Control_Pad THEN
  867.     'IF NOT G.Flag THEN DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad) 'has to do with moving
  868.     DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad)
  869.     IF NOT C.BAD_Pad THEN
  870.      nul%% = AxisPower(CJR%%, CJL%%, CJU%%, CJD%%) 'read directional axis values
  871.      IF CJU%% THEN Result%% = UP
  872.      IF CJD%% THEN Result%% = DOWN
  873.      IF CJL%% THEN Result%% = LEFT
  874.      IF CJR%% THEN Result%% = RIGHT
  875.     ELSE
  876.      IF _BUTTON(C.Joy_Button_Up) THEN Result%% = UP ': Joy_Lock_Button (C.Joy_Button_Up)
  877.      IF _BUTTON(C.Joy_Button_Down) THEN Result%% = DOWN ': Joy_Lock_Button (C.Joy_Button_Down)
  878.      IF _BUTTON(C.Joy_Button_Left) THEN Result%% = LEFT ': Joy_Lock_Button (C.Joy_Button_Left)
  879.      IF _BUTTON(C.Joy_Button_Right) THEN Result%% = RIGHT ': Joy_Lock_Button (C.Joy_Button_Right)
  880.     END IF
  881.     IF _BUTTON(C.Joy_A_Button) THEN Result%% = BUTTON_A: Joy_Lock_Button (C.Joy_A_Button)
  882.     IF _BUTTON(C.Joy_B_Button) THEN Result%% = BUTTON_B: Joy_Lock_Button (C.Joy_B_Button)
  883.    END IF
  884.  Get_Input = Result%%
  885.  
  886. SUB Get_JoyPads
  887.  'load input device details Max:16
  888.  G.Device_Count = _DEVICES
  889.  IF G.Device_Count > 16 THEN G.Device_Count = 16 'limit total devices to 16
  890.  FOR I%% = 1 TO G.Device_Count
  891.   DeviceData(I%%).Buttons = _LASTBUTTON(I%%) ' number of buttons on the device
  892.   DeviceData(I%%).Axis_p = _LASTAXIS(I%%) 'number of axis on the device
  893.  NEXT I%%
  894.  
  895. SUB INIT_Controls
  896.  'Set Default controls
  897.  C.KBCon_Up = Default_Key_Up
  898.  C.KBCon_Down = Default_Key_Down
  899.  C.KBCon_Left = Default_Key_Left
  900.  C.KBCon_Right = Default_Key_Right
  901.  C.KBCon_Select = Default_Select_Button
  902.  C.KBCon_Start = Default_Start_Button
  903.  C.KBCon_A_Button = Default_A_Button
  904.  C.KBCon_B_Button = Default_B_Button
  905.  C.Joy_Up = -22 'Undefined Joy Pad Controls
  906.  C.Joy_Down = -22 'Undefined
  907.  C.Joy_Left = -22 'Undefined
  908.  C.Joy_Right = -22 'Undefined
  909.  C.Joy_Button_Up = -22 'Undefined Joy Pad Controls
  910.  C.Joy_Button_Down = -22 'Undefined
  911.  C.Joy_Button_Left = -22 'Undefined
  912.  C.Joy_Button_Right = -22 'Undefined
  913.  C.Joy_Select = -22 'Undefined
  914.  C.Joy_Start = -22 'Undefined
  915.  C.Joy_A_Button = -22 'Undefined
  916.  C.Joy_B_Button = -22 'Undefined
  917.  Get_JoyPads 'load posible controller inputs
  918.  G.ControlType = TRUE 'keyboard control
  919.  
  920. SUB Joy_Lock_Button (ID%%)
  921.  ExitFlag%% = FALSE
  922.  DO
  923.   Nul%% = _DEVICEINPUT(C.Control_Pad)
  924.   Nul%% = _BUTTON(ID%%)
  925.   IF Nul%% = FALSE THEN ExitFlag%% = TRUE
  926.  LOOP UNTIL ExitFlag%%
  927.  
  928. SUB Joy_Lock_Axis (ID%%)
  929.  ExitFlag%% = FALSE
  930.  IF NOT G.ControlType THEN
  931.   DO
  932.    Nul%% = _DEVICEINPUT(C.Control_Pad)
  933.    Nul%% = _AXIS(ID%%)
  934.    IF Nul%% = FALSE THEN ExitFlag%% = TRUE
  935.   LOOP UNTIL ExitFlag%%
  936.   DO: LOOP WHILE _DEVICEINPUT(C.Control_Pad)
  937.  
  938. SUB Input_OR_Wait (clicks~%%)
  939.  DO
  940.   pause%% = pause%% + 1
  941.   _LIMIT 60
  942.  LOOP UNTIL pause%% = clicks~%% OR Get_Input = BUTTON_B
  943.  
  944. FUNCTION Yes_No_Box%% (X%, Y%)
  945.  Result%% = TRUE
  946.  'make backup of area under window
  947.  _PUTIMAGE (0, 0), Layer(0), Layer(127), (X% * 16, Y% * 16)-STEP(95, 79)
  948.  Create_Dialog_Box X%, Y%, 3, 3
  949.  PS_Print 16 * (X% + 1), 16 * (Y% + 1), "YES", Layer(1)
  950.  PS_Print 16 * (X% + 1), 16 * (Y% + 3), "NO", Layer(1)
  951.  DO
  952.   C_Input%% = Get_Input
  953.   IF C_Input%% = DOWN OR C_Input%% = UP THEN
  954.    IF NOT KeyStop%% THEN
  955.     IF Opt%% THEN Opt%% = 0 ELSE Opt%% = 1
  956.     KeyStop%% = TRUE
  957.    END IF
  958.   ELSE
  959.    KeyStop%% = FALSE
  960.   END IF
  961.   SELECT CASE Opt%%
  962.    CASE 0
  963.     IF Blinkon%% THEN PS_Print 16 * (X%), 16 * (Y% + 1), "k", Layer(1) ELSE PS_Print 16 * (X%), 16 * (Y% + 1), "d", Layer(1)
  964.     PS_Print 16 * X%, 16 * (Y% + 3), "d", Layer(1)
  965.    CASE 1
  966.     PS_Print 16 * X%, 16 * (Y% + 1), "d", Layer(1)
  967.     IF Blinkon%% THEN PS_Print 16 * X%, 16 * (Y% + 3), "k", Layer(1) ELSE PS_Print 16 * X%, 16 * (Y% + 3), "d", Layer(1)
  968.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  969.   _LIMIT 60
  970.   blink%% = blink%% + 1
  971.   IF blink%% = 10 THEN Blinkon%% = NOT Blinkon%%: blink%% = 0
  972.   IF C_Input%% = BUTTON_B THEN Result%% = Opt%%: ExitFlag%% = TRUE
  973.  LOOP UNTIL ExitFlag%%
  974.  'scroll backup area back in place
  975.  FOR I%% = 0 TO 80 STEP 8
  976.   _PUTIMAGE (X% * 16, Y% * 16), Layer(127), Layer(0), (0, 0)-STEP(95, I%%)
  977.   _LIMIT 60
  978.  NEXT I%%
  979.  Yes_No_Box = Result%%
  980.  
  981. FUNCTION Buy_Sell_Box%% (X%, Y%)
  982.  Result%% = TRUE
  983.  'make backup of area under window
  984.  _PUTIMAGE (0, 0), Layer(0), Layer(127), (X% * 16, Y% * 16)-STEP(111, 95)
  985.  Create_Dialog_Box X%, Y%, 3, 4
  986.  PS_Print 16 * (X% + 1), 16 * (Y% + 1), "BUY", Layer(1)
  987.  PS_Print 16 * (X% + 1), 16 * (Y% + 3), "SELL", Layer(1)
  988.  DO
  989.   C_Input%% = Get_Input
  990.   IF C_Input%% = DOWN OR C_Input%% = UP THEN
  991.    IF NOT KeyStop%% THEN
  992.     IF Opt%% THEN Opt%% = 0 ELSE Opt%% = 1
  993.     KeyStop%% = TRUE
  994.    END IF
  995.   ELSE
  996.    KeyStop%% = FALSE
  997.   END IF
  998.   SELECT CASE Opt%%
  999.    CASE 0
  1000.     IF Blinkon%% THEN PS_Print 16 * (X%), 16 * (Y% + 1), "k", Layer(1) ELSE PS_Print 16 * (X%), 16 * (Y% + 1), "d", Layer(1)
  1001.     PS_Print 16 * X%, 16 * (Y% + 3), "d", Layer(1)
  1002.    CASE 1
  1003.     PS_Print 16 * X%, 16 * (Y% + 1), "d", Layer(1)
  1004.     IF Blinkon%% THEN PS_Print 16 * X%, 16 * (Y% + 3), "k", Layer(1) ELSE PS_Print 16 * X%, 16 * (Y% + 3), "d", Layer(1)
  1005.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  1006.   _LIMIT 60
  1007.   blink%% = blink%% + 1
  1008.   IF blink%% = 10 THEN Blinkon%% = NOT Blinkon%%: blink%% = 0
  1009.   IF C_Input%% = BUTTON_B THEN ExitFlag%% = TRUE
  1010.  LOOP UNTIL ExitFlag%%
  1011.  IF Opt%% = 1 THEN Result%% = Opt%% + 1 'return a 2 to trigger the selling menu
  1012.  FOR I%% = 0 TO 96 STEP 8
  1013.   _PUTIMAGE (X% * 16, Y% * 16), Layer(127), Layer(0), (0, 0)-STEP(111, I%%)
  1014.   _LIMIT 60
  1015.  NEXT I%%
  1016.  Buy_Sell_Box = Result%%
  1017.  
  1018.  
  1019. FUNCTION Player_Select%%
  1020.  Result%% = 0 'Defualt to Alis
  1021.  IF G.Party_Size > 0 THEN
  1022.   'setup the selection box for the number of party memebers
  1023.   Create_Dialog_Box 5, 12, 1 + G.Party_Size * 2, 4
  1024.   FOR i%% = 0 TO G.Party_Size
  1025.    PS_Print 16 * 6, 16 * (13 + (i%% * 2)), P(i%%).N, Layer(1)
  1026.   NEXT i%%
  1027.   tmp& = _COPYIMAGE(Layer(1))
  1028.   DO
  1029.    SELECT CASE Get_Input
  1030.     CASE UP
  1031.      Opt%% = Opt%% - 1
  1032.      IF Opt%% = -1 THEN Opt%% = G.Party_Size
  1033.      DO: LOOP WHILE Get_Input = UP
  1034.      _DELAY .005
  1035.     CASE DOWN
  1036.      Opt%% = Opt%% + 1
  1037.      IF Opt%% = G.Party_Size + 1 THEN Opt%% = 0
  1038.      DO: LOOP WHILE Get_Input = DOWN
  1039.      _DELAY .005
  1040.     CASE BUTTON_B
  1041.      ExitFlag%% = TRUE
  1042.      Result%% = Opt%%
  1043.     CASE ESC
  1044.      ExitFlag%% = TRUE
  1045.    END SELECT
  1046.  
  1047.    IF blinkon%% THEN PS_Print 16 * 5, 16 * (13 + (Opt%% * 2)), "k", Layer(1) ELSE PS_Print 16 * 5, 16 * (13 + (Opt%% * 2)), "d", Layer(1)
  1048.    blink%% = blink%% + 1
  1049.    IF blink%% = 8 AND blinkon%% = 0 THEN blinkon%% = -1: blink%% = 0
  1050.    IF blink%% = 8 AND blinkon%% = -1 THEN blinkon%% = 0: blink%% = 0
  1051.    _PUTIMAGE , Layer(1), Layer(0)
  1052.    _PUTIMAGE , tmp&, Layer(1)
  1053.    _LIMIT 60
  1054.   LOOP UNTIL ExitFlag%%
  1055.   _FREEIMAGE tmp&
  1056.   'if Party consists of only Alis don't bother!
  1057.  Player_Select%% = Result%%
  1058.  
  1059.  
  1060. SUB Flagged_Conversations (ID%%)
  1061.  SELECT CASE ID%%
  1062.   CASE 0 'suelo's house
  1063.    IF F(0) THEN 'if flag is set then just short message and heal player
  1064.     Conversations 2
  1065.     Heal_Party
  1066.    ELSE 'first dialog with Suelo
  1067.     PRINT "convo 1"
  1068.     PRINT Chat(0, 0)
  1069.     Conversations 1
  1070.     F(0) = TRUE
  1071.     Heal_Party
  1072.    END IF
  1073.   CASE 1 'nekise's house
  1074.    IF F(1) THEN 'player already recieved Laconian Pot
  1075.     Conversations 4
  1076.    ELSE 'player recives the Laconian Pot to get Mayu
  1077.     Conversations 3
  1078.     F(1) = TRUE
  1079.     Pack(G.Pack_Count) = Laconian_Pot
  1080.     G.Pack_Count = G.Pack_Count + 1
  1081.    END IF
  1082.   CASE 2 'Camineet Road Guards
  1083.    IF In_Pack(RoadPass) THEN
  1084.    ELSE
  1085.    END IF
  1086.  
  1087. SUB Conversations (id%)
  1088.  Create_Dialog_Box 9, 21, 4, 18
  1089.  FOR i%% = 1 TO Chat(id%, 0) STEP 2
  1090.   IF Scroll%% THEN
  1091.    Scroll_Dialog_Box 9, 21, 4, 18
  1092.    TimedPrint 10, 25, Dialog(Chat(id%, i%%)), 20 '
  1093.   ELSE
  1094.    TimedPrint 10, 23, Dialog(Chat(id%, i%%)), 20 '
  1095.   END IF
  1096.   IF i%% + 1 < Chat(id%, 0) THEN
  1097.    IF Scroll%% THEN Scroll_Dialog_Box 9, 21, 4, 18
  1098.    TimedPrint 10, 25, Dialog(Chat(id%, i%% + 1)), 20 '
  1099.   ELSEIF (i%% MOD 2) = 1 AND (Chat(id%, 0) MOD 2) = 0 THEN 'two line dialog fix hack
  1100.    IF Scroll%% THEN Scroll_Dialog_Box 9, 21, 4, 18
  1101.    TimedPrint 10, 25, Dialog(Chat(id%, i%% + 1)), 20 '
  1102.   END IF
  1103.   Input_OR_Wait 128
  1104.   Scroll%% = TRUE
  1105.  NEXT i%%
  1106.  
  1107. SUB Interative_Conversations (id%%)
  1108.  'conversations requiring YES\NO boxes or other input
  1109.  Create_Dialog_Box 9, 21, 4, 18
  1110.  FOR i%% = 1 TO Chat(id%, 0) STEP 2
  1111.  NEXT i%%
  1112.  
  1113.  
  1114. SUB Heal_Party
  1115.  FOR I%% = 0 TO G.Party_Size
  1116.   P(I%%).Hp = P(I%%).MHp
  1117.   P(I%%).Mp = P(I%%).MMp
  1118.  NEXT I%%
  1119.  
  1120. FUNCTION In_Pack%% (id%%)
  1121.  Result%% = FALSE
  1122.  FOR i%% = 0 TO G.Pack_Count - 1
  1123.   IF Pack(i%%) = id%% THEN Result%% = TRUE: i%% = G.Pack_Count
  1124.  NEXT i%%
  1125.  In_Pack = Result%%
  1126.  
  1127. SUB Church (Which%%)
  1128.  '------------Setup church screen--------------
  1129.  SELECT CASE Which%%
  1130.   CASE 0 'town church
  1131.    'BGI
  1132.    _PUTIMAGE (64, 48)-STEP(511, 383), Layer(8), Layer(1), (0, 1152)-STEP(255, 191)
  1133.    'Character
  1134.    Place_Shop_NPC 13
  1135.    '_PUTIMAGE (281, 200)-STEP(75, 183), NPC&, Temp&, (0 + 13 * 39, 450)-STEP(37, 92)
  1136.   CASE 1 'village church
  1137.    'BGI
  1138.    _PUTIMAGE (64, 48)-STEP(511, 383), Layer(8), Layer(1), (256, 1152)-STEP(255, 191)
  1139.    'Character
  1140.    _PUTIMAGE (281, 200)-STEP(75, 183), NPC&, Temp&, (0 + 13 * 39, 450)-STEP(37, 92)
  1141.  '---------------------------------------------
  1142.  Create_Dialog_Box 9, 21, 4, 18
  1143.  TimedPrint 10, 23, Dialog(1452), 20 'this is a church
  1144.  TimedPrint 10, 25, Dialog(1453), 20 '
  1145.  Input_OR_Wait 128
  1146.  Scroll_Dialog_Box 9, 21, 4, 18
  1147.  TimedPrint 10, 25, Dialog(1454), 20 'anybody need brought back?
  1148.  IF Yes_No_Box(24, 16) = 0 THEN 'need somebody brought back
  1149.   DO
  1150.    IF G.Party_Size > 0 THEN
  1151.     Scroll_Dialog_Box 9, 21, 4, 18
  1152.     TimedPrint 10, 25, Dialog(1461), 20 'Who do you want
  1153.     Scroll_Dialog_Box 9, 21, 4, 18
  1154.     TimedPrint 10, 25, Dialog(1462), 20 'to resurrect
  1155.    END IF
  1156.    Who%% = Player_Select 'which player
  1157.    IF P(Who%%).Status = Dead THEN 'are they really dead?
  1158.     Scroll_Dialog_Box 9, 21, 4, 18
  1159.     TimedPrint 10, 25, Dialog(1464), 20 'That will require
  1160.     Scroll_Dialog_Box 9, 21, 4, 18
  1161.     TimedPrint 10, 25, LTRIM$(STR$(P(Who%%).Level * 20)) + Dialog(1465), 20 'to resurrect
  1162.     IF NOT Yes_No_Box(24, 16) THEN 'if player will pay
  1163.      G.Meseta = G.Meseta - (P(Who%%).Level * 20) 'take fee
  1164.      Scroll_Dialog_Box 9, 21, 4, 18
  1165.      TimedPrint 10, 25, Dialog(1457), 20 'I will now cast
  1166.      Scroll_Dialog_Box 9, 21, 4, 18
  1167.      TimedPrint 10, 25, Dialog(1458), 20 'a spell
  1168.      Input_OR_Wait 30
  1169.      Scroll_Dialog_Box 9, 21, 4, 18
  1170.      TimedPrint 10, 25, Dialog(1459), 20 'ahbra
  1171.      Scroll_Dialog_Box 9, 21, 4, 18
  1172.      TimedPrint 10, 25, Dialog(1460), 20 'cadahbra
  1173.      P(Who%%).Hp = P(Who%%).MHp
  1174.      P(Who%%).Mp = P(Who%%).MMp
  1175.      P(Who%%).Status = Alive
  1176.      Input_OR_Wait 30
  1177.     END IF
  1178.    ELSE 'this person is not dead
  1179.     Scroll_Dialog_Box 9, 21, 4, 18
  1180.     TimedPrint 10, 25, P(Who%%).N + " " + Dialog(1472), 20 'is alive
  1181.    END IF
  1182.    Scroll_Dialog_Box 9, 21, 4, 18
  1183.    TimedPrint 10, 25, Dialog(1463), 20 'anyone else
  1184.    IF Yes_No_Box(24, 16) THEN ExitFlag%% = TRUE
  1185.   LOOP UNTIL ExitFlag%%
  1186.  ELSE 'just checking stats
  1187.  Scroll_Dialog_Box 9, 21, 4, 18
  1188.  TimedPrint 10, 25, Dialog(1470), 20 'May the gods
  1189.  Scroll_Dialog_Box 9, 21, 4, 18
  1190.  TimedPrint 10, 25, Dialog(1471), 20 'watch over you.
  1191.  Input_OR_Wait 128
  1192.  Scroll_Dialog_Box 9, 21, 4, 18
  1193.  TimedPrint 10, 25, Dialog(1466), 20 'To Advance to
  1194.  Scroll_Dialog_Box 9, 21, 4, 18
  1195.  TimedPrint 10, 25, Dialog(1467), 20 'the next level,
  1196.  Input_OR_Wait 128
  1197.  FOR i%% = 0 TO G.Party_Size
  1198.   IF P(i%%).Status = Alive THEN 'only display players who are alive
  1199.    IF P(i%%).Level < 30 THEN
  1200.     Scroll_Dialog_Box 9, 21, 4, 18
  1201.     TimedPrint 10, 25, P(i%%).N + " " + Dialog(1468) + STR$(Pl(i%%, P(i%%).Level + 1).ExpPts - P(i%%).Exp), 20 'needs
  1202.     Scroll_Dialog_Box 9, 21, 4, 18
  1203.     TimedPrint 10, 25, Dialog(1469), 20 'the next level,
  1204.     Input_OR_Wait 128
  1205.    ELSE 'player is maxed out
  1206.     Scroll_Dialog_Box 9, 21, 4, 18
  1207.     TimedPrint 10, 25, P(i%%).N + " " + Dialog(1566), 20 'is strong
  1208.     Scroll_Dialog_Box 9, 21, 4, 18
  1209.     TimedPrint 10, 25, Dialog(1567), 20 'enough already.
  1210.     Input_OR_Wait 128
  1211.    END IF
  1212.   END IF
  1213.  NEXT i%%
  1214.  
  1215. SUB Shop (ID%%)
  1216.  '------------Setup shop screen--------------
  1217.  'BGI -if bit 7 set then use alt shop layout
  1218.  BGI~%% = _SHL(Shops(ID%%).Which, 1) 'bump bit 7 then
  1219.  BGI~%% = _SHR(BGI~%%, 5) 'reset to find what type of shop(0-7 only 3 kinds though 0-2)
  1220.  _PUTIMAGE (64, 48)-STEP(511, 383), Layer(8), Layer(1), (256 * _READBIT(Shops(ID%%).Which, 7), 384 + (192 * BGI~%%))-STEP(255, 191)
  1221.  'Character - can be red, green or blue man
  1222.  Char~%% = _SHL(Shops(ID%%).Which, 4) 'bump 4 high bits(4-7)
  1223.  Char~%% = _SHR(Char~%%, 4) 'reset to find what type of shop owner
  1224.  Place_Shop_NPC Char~%%
  1225.  _PUTIMAGE , Layer(1), Layer(0)
  1226.  '---------------------------------------------
  1227.  Create_Dialog_Box 9, 21, 4, 18
  1228.  SELECT CASE BGI~%%
  1229.   CASE 2
  1230.    TimedPrint 10, 23, Dialog(1408), 20 'this is an armory
  1231.    TimedPrint 10, 25, Dialog(1409), 20 'want to buy
  1232.    Input_OR_Wait 128
  1233.    Scroll_Dialog_Box 9, 21, 4, 18
  1234.    TimedPrint 10, 25, Dialog(1410), 20 'something
  1235.    Result%% = Yes_No_Box(24, 16)
  1236.   CASE 1
  1237.    TimedPrint 10, 23, Dialog(1420), 20 'this is a
  1238.    TimedPrint 10, 25, Dialog(1421), 20 'First foods shop
  1239.    Input_OR_Wait 128
  1240.    Scroll_Dialog_Box 9, 21, 4, 18
  1241.    TimedPrint 10, 25, Dialog(1422), 20 'like to
  1242.    Scroll_Dialog_Box 9, 21, 4, 18
  1243.    TimedPrint 10, 25, Dialog(1423), 20 'buy something
  1244.    Result%% = Yes_No_Box(24, 16)
  1245.   CASE 0
  1246.    TimedPrint 10, 23, Dialog(1420), 20 'this is a
  1247.    TimedPrint 10, 25, Dialog(1425), 20 'this is second hand
  1248.    Input_OR_Wait 128
  1249.    Scroll_Dialog_Box 9, 21, 4, 18
  1250.    TimedPrint 10, 25, Dialog(1426), 20 'help you
  1251.    Result%% = Buy_Sell_Box(9, 16)
  1252.  
  1253.  
  1254.  IF Result%% = 0 THEN 'wish to buy something? Yes
  1255.   DO
  1256.    Scroll_Dialog_Box 9, 21, 4, 18
  1257.    TimedPrint 10, 25, Dialog(1412), 20 'which do you
  1258.    Scroll_Dialog_Box 9, 21, 4, 18
  1259.    TimedPrint 10, 25, Dialog(1413), 20 'want to buy
  1260.    Display_Meseta_Box 25, 3
  1261.    IF Select_Shop_Item(ID%%, Buy%%) <> TRUE THEN
  1262.     IF G.Meseta >= ShopCost(ID%%, Buy%%) THEN 'check players on hand cash
  1263.      IF G.Pack_Count < Max_Pack_Count THEN 'does player have room to carry more
  1264.       Scroll_Dialog_Box 9, 21, 4, 18
  1265.       Pack(G.Pack_Count) = ShopItems(ID%%, Buy%%)
  1266.       G.Pack_Count = G.Pack_Count + 1
  1267.       G.Meseta = G.Meseta - ShopCost(ID%%, Buy%%)
  1268.       TimedPrint 10, 25, Dialog(1414), 20 'Thank you
  1269.       Scroll_Dialog_Box 9, 21, 4, 18
  1270.       TimedPrint 10, 25, Dialog(1415), 20 'anything else
  1271.       Display_Meseta_Box 25, 3
  1272.       IF Yes_No_Box(24, 16) THEN ExitFlag%% = TRUE ELSE Buy%% = -1
  1273.      ELSE 'player has no room
  1274.       Scroll_Dialog_Box 9, 21, 4, 18
  1275.       TimedPrint 10, 25, Dialog(1416), 20 'dont have
  1276.       Scroll_Dialog_Box 9, 21, 4, 18
  1277.       TimedPrint 10, 25, Dialog(1417), 20 'the space
  1278.       Input_OR_Wait 30
  1279.       Msg%% = 2 'display secondary leave message
  1280.       ExitFlag%% = TRUE
  1281.      END IF
  1282.     ELSE 'player doesn't have the cash
  1283.      Scroll_Dialog_Box 9, 21, 4, 18
  1284.      TimedPrint 10, 25, Dialog(1550), 20 'dont have
  1285.      Scroll_Dialog_Box 9, 21, 4, 18
  1286.      TimedPrint 10, 25, Dialog(1551), 20 'the money
  1287.      Input_OR_Wait 30
  1288.      Msg%% = 3 ' alt leave message
  1289.      ExitFlag%% = TRUE
  1290.     END IF
  1291.    ELSE
  1292.     ExitFlag%% = TRUE
  1293.    END IF
  1294.   LOOP UNTIL ExitFlag%% = TRUE
  1295.  ELSEIF Result%% = 2 THEN 'sell an item at the second hand store
  1296.   DO
  1297.    Scroll_Dialog_Box 9, 21, 4, 18
  1298.    TimedPrint 10, 25, Dialog(1427), 20 'what do you
  1299.    Scroll_Dialog_Box 9, 21, 4, 18
  1300.    TimedPrint 10, 25, Dialog(1428), 20 'want to sell?
  1301.  
  1302.    IF Run_Item_Selection_Menu(ID%%) >= 0 THEN
  1303.     Scroll_Dialog_Box 9, 21, 4, 18
  1304.     TimedPrint 10, 25, RTRIM$(I(Pack(ID%%)).Nam) + Dialog(1429), 20 'this item
  1305.     Scroll_Dialog_Box 9, 21, 4, 18
  1306.     TimedPrint 10, 25, Dialog(1430), 20 'to sell....
  1307.     Input_OR_Wait 128
  1308.     Scroll_Dialog_Box 9, 21, 4, 18
  1309.     TimedPrint 10, 25, Dialog(1431) + STR$(I(Pack(ID%%)).Cost \ 2), 20 'how about this
  1310.     Scroll_Dialog_Box 9, 21, 4, 18
  1311.     TimedPrint 10, 25, Dialog(1432), 20 'much
  1312.     IF Yes_No_Box(24, 16) = 0 THEN
  1313.      G.Meseta = G.Meseta + I(Pack(ID%%)).Cost \ 2
  1314.      Reduce_Pack ID%%
  1315.      Scroll_Dialog_Box 9, 21, 4, 18
  1316.      TimedPrint 10, 25, Dialog(1414), 20 'Thank you
  1317.      Scroll_Dialog_Box 9, 21, 4, 18
  1318.      TimedPrint 10, 25, Dialog(1415), 20 'anything else?
  1319.      IF Yes_No_Box(24, 16) THEN ExitFlag%% = TRUE
  1320.     END IF
  1321.  
  1322.    ELSE 'player either has nothing to sell or changed mind
  1323.     Msg%% = 0
  1324.     ExitFlag%% = TRUE
  1325.    END IF
  1326.   LOOP UNTIL ExitFlag%%
  1327.  
  1328.  Scroll_Dialog_Box 9, 21, 4, 18
  1329.  SELECT CASE Msg%%
  1330.   CASE 2
  1331.    Scroll_Dialog_Box 9, 21, 4, 18
  1332.    TimedPrint 10, 25, Dialog(1418), 20 '
  1333.    Scroll_Dialog_Box 9, 21, 4, 18
  1334.    TimedPrint 10, 25, Dialog(1419), 20 '
  1335.   CASE 3
  1336.    TimedPrint 10, 25, Dialog(1552), 20 'not enough cash leaving
  1337.    TimedPrint 10, 25, Dialog(1411), 20 'normal leaving
  1338.  
  1339. SUB Display_Meseta_Box (X%%, Y%%)
  1340.  Create_Dialog_Box X%%, Y%%, 1, 8
  1341.  PS_Print 16 * (X%% + 1), 16 * (Y%% + 1), "MST", Layer(1)
  1342.  PS_Print 16 * (X%% + (9 - LEN(LTRIM$(RTRIM$(STR$(G.Meseta)))))), 16 * (Y%% + 1), LTRIM$(STR$(G.Meseta)), Layer(1)
  1343.  
  1344. FUNCTION Select_Shop_Item (ID%%, What%%)
  1345.  Result%% = -1 'return this if player cancels
  1346.  Create_Dialog_Box 9, 3, 6, 14
  1347.  FOR i%% = 0 TO Shops(ID%%).items - 1
  1348.   PS_Print 16 * 10, 16 * (5 + 2 * i%%), I(ShopItems(ID%%, i%%)).Nam, Layer(1)
  1349.   PS_Print 16 * (10 + 14 - LEN(LTRIM$(RTRIM$(STR$(ShopCost(ID%%, i%%)))))), 16 * (5 + 2 * i%%), LTRIM$(STR$(ShopCost(ID%%, i%%))), Layer(1)
  1350.  NEXT i%%
  1351.  
  1352.  tmp& = _COPYIMAGE(Layer(1))
  1353.  DO
  1354.   SELECT CASE Get_Input
  1355.    CASE UP
  1356.     Opt%% = Opt%% - 1
  1357.     IF Opt%% = -1 THEN Opt%% = Shops(ID%%).items - 1
  1358.     DO: LOOP WHILE Get_Input = UP
  1359.    CASE DOWN
  1360.     Opt%% = Opt%% + 1
  1361.     IF Opt%% = Shops(ID%%).items THEN Opt%% = 0
  1362.     DO: LOOP WHILE Get_Input = DOWN
  1363.    CASE BUTTON_B
  1364.     ExitFlag%% = TRUE
  1365.     What%% = Opt%%
  1366.     Result%% = Opt%%
  1367.    CASE ESC
  1368.     ExitFlag%% = TRUE
  1369.  
  1370.   IF blinkon%% THEN PS_Print 16 * 9, 16 * (5 + (Opt%% * 2)), "k", Layer(1) ELSE PS_Print 16 * 9, 16 * (5 + (Opt%% * 2)), "d", Layer(1)
  1371.  
  1372.   blink%% = blink%% + 1
  1373.   IF blink%% = 8 AND blinkon%% = 0 THEN blinkon%% = -1: blink%% = 0
  1374.   IF blink%% = 8 AND blinkon%% = -1 THEN blinkon%% = 0: blink%% = 0
  1375.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  1376.   _PUTIMAGE (0, 0), tmp&, Layer(1)
  1377.   _LIMIT 60
  1378.  LOOP UNTIL ExitFlag%%
  1379.  _FREEIMAGE tmp&
  1380.  Select_Shop_Item = Result%%
  1381.  
  1382. SUB Load_Data (F$)
  1383.  
  1384.  OPEN F$ FOR BINARY AS #1
  1385.  GET #1, , M()
  1386.  GET #1, , I()
  1387.  GET #1, , S()
  1388.  GET #1, , Pl()
  1389.  GET #1, , PSL()
  1390.  GET #1, , KeyCodes()
  1391.  PRINT LOC(1)
  1392.  GET #1, , Lines_of_Dialog%
  1393.  FOR i% = 0 TO Lines_of_Dialog%
  1394.   GET #1, , L~%%
  1395.   Dialog(i%) = SPACE$(L~%%)
  1396.   GET #1, , Dialog(i%)
  1397.  NEXT i%
  1398.  FOR i%% = 0 TO 3
  1399.   GET #1, , D(i%%)
  1400.  NEXT i%%
  1401.  GET #1, , Encounters()
  1402.  GET #1, , DungeonMaster()
  1403.  GET #1, , Shops()
  1404.  GET #1, , ShopItems()
  1405.  GET #1, , ShopCost()
  1406.  GET #1, , Chat()
  1407.  CLOSE #1
  1408.  
  1409.  
  1410. SUB Place_Shop_NPC (Who%%)
  1411.  _PUTIMAGE (281, 202)-STEP(75, 101), Layer(9), Layer(1), (0 + Who%% * 39, 450)-STEP(37, 51)
  1412.  
  1413. FUNCTION Run_Item_Selection_Menu%% (ID%%)
  1414.  Result%% = -1
  1415.  'create a backup of the area under window
  1416.  _PUTIMAGE (0, 0), Layer(0), Layer(127), (16 * 26, 16 * 5)-STEP(159, 335)
  1417.  IF G.Pack_Count THEN 'only run if player has an Item
  1418.   IF G.Pack_Count > 8 THEN
  1419.    start%% = 1 'start printing items 1 space lower to allow for the NEXT option
  1420.    Create_Dialog_Box 25, 5, 19, 8
  1421.    PS_Print 16 * 26, 16 * 8, "NEXT", Layer(1)
  1422.    First%% = 0 'start with the first item , incremented witht the NEXT option
  1423.    Last%% = 7 'print up to 8(0-7) items per screen
  1424.   ELSE
  1425.    start%% = 0 'start printing normally due to no NEXT option
  1426.    First%% = 0
  1427.    Last%% = G.Pack_Count - 1
  1428.    Create_Dialog_Box 25, 5, 17, 8
  1429.   END IF
  1430.   PS_Print 16 * 26, 16 * 6, "MST", Layer(1)
  1431.   PS_Print 16 * (34 - LEN(LTRIM$(STR$(G.Meseta)))), 16 * 6, LTRIM$(STR$(G.Meseta)), Layer(1)
  1432.   _PUTIMAGE (0, 0), Layer(1), Layer(0) 'move our creation to display
  1433.   temp& = _COPYIMAGE(Layer(0)) 'create a temp layer of display to use as a base image
  1434.   DO
  1435.    SELECT CASE Get_Input
  1436.     CASE UP
  1437.      Opt%% = Opt%% - 1
  1438.      IF Opt%% = -1 THEN Opt%% = Last%% + start%%
  1439.      DO: LOOP WHILE Get_Input = UP
  1440.      _DELAY .005
  1441.     CASE DOWN
  1442.      Opt%% = Opt%% + 1
  1443.      IF Opt%% = Last%% + start%% + 1 THEN Opt%% = 0
  1444.      DO: LOOP WHILE Get_Input = DOWN
  1445.      _DELAY .005
  1446.     CASE BUTTON_B
  1447.      IF start%% THEN 'if start is set then there is a next option that must be checked
  1448.       IF Opt%% = 0 THEN
  1449.        Offset%% = Offset%% + 8
  1450.        IF Offset%% > G.Pack_Count THEN Offset%% = 0
  1451.        IF Offset%% = 0 THEN Last%% = 7 ELSE Last%% = G.Pack_Count - Offset%%
  1452.        IF Last%% > 7 THEN Last%% = 7
  1453.       ELSE
  1454.        ExitFlag%% = TRUE
  1455.        Result%% = Opt%% + Offset%%
  1456.       END IF
  1457.      ELSE
  1458.       ExitFlag%% = TRUE
  1459.       Result%% = Opt%%
  1460.      END IF
  1461.     CASE ESC
  1462.      ExitFlag%% = TRUE
  1463.    END SELECT
  1464.    IF blinkon%% THEN PS_Print 16 * 25, 16 * (8 + (Opt%% * 2)), "k", Layer(1) ELSE PS_Print 16 * 25, 16 * (8 + (Opt%% * 2)), "d", Layer(1)
  1465.    blink%% = blink%% + 1
  1466.    IF blink%% = 8 AND blinkon%% = 0 THEN blinkon%% = -1: blink%% = 0
  1467.    IF blink%% = 8 AND blinkon%% = -1 THEN blinkon%% = 0: blink%% = 0
  1468.    FOR I%% = First%% TO Last%%
  1469.     PS_Print 16 * 26, 16 * (8 + (I%% + start%%) * 2), I(Pack(I%% + Offset%%)).Nam, Layer(1)
  1470.    NEXT I%%
  1471.    _PUTIMAGE (0, 0), Layer(1), Layer(0)
  1472.    _PUTIMAGE (0, 0), temp&, Layer(1)
  1473.    _LIMIT 60
  1474.   LOOP UNTIL ExitFlag%%
  1475.   _FREEIMAGE temp&
  1476.  ELSE 'Player has no items to use
  1477.   start%% = 0
  1478.   Create_Dialog_Box 25, 5, 17, 8
  1479.   PS_Print 16 * 26, 16 * 6, "MST", Layer(1)
  1480.   PS_Print 16 * (34 - LEN(LTRIM$(STR$(G.Meseta)))), 16 * 6, LTRIM$(STR$(G.Meseta)), Layer(1)
  1481.   _PUTIMAGE (0, 0), Layer(1), Layer(0)
  1482.   DO: _LIMIT (30): LOOP WHILE Get_Input = TRUE
  1483.  _PUTIMAGE (0, 0), Layer(0), Layer(1)
  1484.  ID%% = Result%%
  1485.  FOR I% = 0 TO 336 STEP 16
  1486.   _PUTIMAGE (26 * 16, 5 * 16), Layer(127), Layer(0), (0, 0)-STEP(159, I%)
  1487.   _LIMIT 60
  1488.  NEXT I%
  1489.  Run_Item_Selection_Menu = Result%%
  1490.  
  1491. SUB Reduce_Pack (id%%)
  1492.  FOR i%% = id%% TO G.Pack_Count - 1
  1493.   SWAP Pack(i%%), Pack(i%% + 1)
  1494.  NEXT i%%
  1495.  Pack(G.Pack_Count - 1) = 0
  1496.  G.Pack_Count = G.Pack_Count - 1
  1497.  
I think the numbering on the code box only goes up to 999?!(1 in the thousands place doesn't show in my firefox)
* PhantasyStarI.MFI (Filesize: 586.36 KB, Downloads: 140)
Granted after becoming radioactive I only have a half-life!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Phantasy Star I:Some Progress being made.
« Reply #1 on: June 27, 2021, 06:00:16 am »
Hi Cobalt
your radioactive light is coming out!

Cool graphic, (who have made the images? ), bad music, bad sound, smooth movement, fine font for text.

2 feedbacks:

 
Fantasy  Feedback1 I cannot enter .jpg


 
Fantasy  Feedback2 Cancel this now .jpg


I got a lot of rest in this Demo world. Good for me.
I like your project and I hope to see news as soon as (ASAP).
Programming isn't difficult, only it's  consuming time and coffee