Author Topic: Program Source code causing lag in the QB64 IDE  (Read 3333 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
Program Source code causing lag in the QB64 IDE
« on: January 28, 2019, 11:51:40 pm »
Getting an odd lag effect while working on my source code. I pulled up the QB64 source and the lag did not happen, and  the QB64 source is a lot bigger than my program. Unless there is something in my code that is causing some kind of slow loop under the hood. although I have had a couple IDE crashes while working on this code too.

its not a lag with the syntax checking, its a lag when navigating the code with the arrow keys or PGUP\PGDN keys.
if I hold them down to move through the code then release the key the IDE keeps scrolling the code to catch up.

Code: QB64: [Select]
  1. '$include: 'saveimage.bi'
  2. TYPE MapSquare
  3.  Terrain AS _BYTE '     tile id
  4.  Playerseen AS _BYTE '  has player seen area?(for minimap)
  5.  IsScepter AS _BYTE '   Scepters hiding place?
  6.  IsTreasure AS _BYTE '  is there treasure on map square?
  7.  IsArmy AS _BYTE '      is there an army on map square?(fight)
  8.  IsArtifact AS _BYTE '  is there an artifact on map square?
  9.  IsBand AS _BYTE '      is there a roaming band of creatures on map square?(hire)
  10.  IsPlayer AS _BYTE '    is the player on map square? on horse, boat, or wing
  11.  IsBoat AS _BYTE '      is the boat located on map square?
  12.  IsTown AS _BYTE '      is there a town on map square? value indicates which town
  13.  IsCastle AS _BYTE '    is there a castle on map square(entrance)? value indicates which castle
  14.  IsSign AS _BYTE '      is there a road sign on map square? value indicates which sign data
  15.  IsDwelling AS _BYTE '  which type 1-plains, 2-forest, 3-hills, 4-dungeons
  16.  IsBridge AS _BYTE '    has player used Bridge spell? which direction 1-horz 2-vert
  17.  IsBlock AS _BYTE '     does this square block armies? (3 blocks around Maximus castle)
  18.  Units AS _BYTE '       which type of unit 1-25 (peasants to dragons)
  19.  Population AS INTEGER 'how many left to hire
  20.  
  21. TYPE Player_Data
  22.  Class AS _BYTE
  23.  Promotion AS _BYTE
  24.  Leadership AS _UNSIGNED INTEGER '  affects maximum number of units player can control
  25.  Control_Bonus AS _UNSIGNED INTEGER 'the Raise control spell affects this value
  26.  Commission AS INTEGER '            castles add 250
  27.  Gold AS LONG '
  28.  SpellPower AS _BYTE '              power of cast spells
  29.  MaxSpells AS _BYTE '               total # of spells player can purchase(finding in chests can go beyond)
  30.  VilliansCaught AS _BYTE '
  31.  Artifacts AS _BYTE '               number of artifacts found 250*difficulty
  32.  Castles AS _BYTE '                 number of castle garrisoned 500*difficulty
  33.  Deaths AS _UNSIGNED INTEGER '      followers killed, reduces score
  34.  Score AS _UNSIGNED INTEGER '       sum of artifacts found+villians caught- followers killed
  35.  Maps_Aquired AS _BYTE
  36.  Maps_Full AS _BYTE '               has player found map orb showing all map area
  37.  Artifacts_Aquired AS _UNSIGNED _BYTE
  38.  Puzzle_Peices AS LONG '            Which peices have been uncovered
  39.  Magic_Learned AS _BYTE '           Does player have magic ability yet?
  40.  Seige_Bought AS _BYTE '            Has player purchased seige weapons yet?
  41.  Current_Contract AS _BYTE '        Who is the player looking for?
  42.  Facing AS _BYTE '                  Last way player was moving Left or Right
  43.  MapXPos AS INTEGER '               Players X Pixel location on map
  44.  MapYpos AS INTEGER '               Players Y Pixel location on map
  45.  Current_Land AS _BYTE '            Which land is player exploring?
  46.  Travel_Mode AS _BYTE '             Player on land, water, or air(horse, boat, dragon)
  47.  
  48. TYPE GameData
  49.  Days AS INTEGER
  50.  TimeStop AS _UNSIGNED INTEGER
  51.  GameTimer AS LONG
  52.  Level AS _BYTE
  53.  Window_Animation AS _BYTE
  54.  In_Combat AS _BYTE '         Is the player in combat? stops time
  55.  In_Menu AS _BYTE '           Does player have menu up? stops time
  56.  Last_Cast AS _BYTE '         last spell cast by player
  57.  HDR_Text AS STRING * 38 '    text for window header
  58.  Scepter_X AS _BYTE '         Scepters X location
  59.  Scepter_Y AS _BYTE '         Scepters Y location
  60.  Scepter_Land AS _BYTE '      Which Land the Scepter is in.
  61.  
  62. TYPE StatData
  63.  Leadership AS INTEGER
  64.  Commission AS INTEGER
  65.  SpellPower AS _BYTE
  66.  MaxSpells AS _BYTE
  67.  
  68. TYPE Standing_Army
  69.  Unit AS _BYTE
  70.  
  71. TYPE Unit_Data
  72.  Unit_Name AS STRING * 12 '
  73.  HitPts AS _UNSIGNED _BYTE '
  74.  AttackLo AS _BYTE '         Lower end damage
  75.  AttackHi AS _BYTE '         Higher end damage
  76.  Shoot AS _BYTE '            Does the creature have ranged attacks?(1{arrows},2{fireball},3{lightning},4{boulders})
  77.  ShootLo AS _BYTE '          Lower end damage
  78.  ShootHi AS _BYTE '          upper end damage
  79.  Movement AS _BYTE '         How many spaces may creature move in one turn?(1,2,3,4,99{fly})
  80.  Cost AS INTEGER '           How much to hire
  81.  ShotCount AS _BYTE '        How many times can creature use its ranged attacks?
  82.  Grouping AS _BYTE '         Morale grouping value(1,2,3,4,5)
  83.  Skill_Level AS _BYTE '      Skill Level determines damage ratio
  84.  
  85. TYPE ContractData
  86.  Villain AS STRING * 24 '      Villains name
  87.  Alias AS STRING * 24 '        Villains Alias if one
  88.  Bounty AS _UNSIGNED INTEGER ' How Much Villan is worth
  89.  LastSeen AS _BYTE '           Continent villain was last seen on
  90.  Castle AS _BYTE '             Castle Villain is held up in
  91.  Is_Known AS _BYTE '           Triggered if player knows which castle villain is located
  92.  Description AS STRING * 130
  93.  Crimes AS STRING * 146
  94.  Caught AS _BYTE
  95.  
  96. TYPE TownData
  97.  The_Name AS STRING * 12
  98.  Unit AS _BYTE ' displays which Unit type
  99.  Spell AS _BYTE ' Selling which spell
  100.  Castle AS _BYTE 'Has Information on which castle
  101.  GateX AS _BYTE ' where player locates with Town Gate spell
  102.  GateY AS _BYTE ' where player locates with Town Gate spell
  103.  Land AS _BYTE '  used with gate spell
  104.  MapX AS _BYTE '  where in map X
  105.  MapY AS _BYTE '  where in map Y
  106.  Visited AS _BYTE 'has player been here?
  107.  
  108. TYPE Spell_Data
  109.  Spell_Name AS STRING * 14
  110.  Cost AS INTEGER
  111.  
  112. TYPE Control_Keys
  113.  Up_Key AS LONG
  114.  Down_Key AS LONG
  115.  Left_Key AS LONG
  116.  Right_Key AS LONG
  117.  A_Button AS LONG
  118.  B_Button AS LONG
  119.  C_Button AS LONG
  120.  Start_Button AS LONG
  121.  
  122. TYPE Signs
  123.  SignText AS STRING * 64 'What the sign says.
  124.  MapXLoc AS _BYTE
  125.  MapYLoc AS _BYTE
  126.  Land AS _BYTE '
  127.  
  128. SCREEN _NEWIMAGE(640, 480, 32)
  129. CONST TRUE = -1, FALSE = NOT TRUE, LEFT = 0, RIGHT = 1, CENTER = 2
  130. CONST KNIGHT = 0, PALADIN = 1, SORCERESS = 2, BARBARIAN = 3
  131. CONST EASY = 1, NORM = 2, HARD = 3, IMPOSSIBLE = 4
  132. CONST MAIN = 1, SAVE = 2, LOAD = 4, HORZ = 1, VERT = 2
  133. CONST CONTINENTIA = 1, FORESTRIA = 2: ARCHIPELIA = 3: SAHARIA = 4
  134. CONST MASTERESC = 27, TOWN = 5, CASTLE = 6
  135.  
  136. DIM SHARED Maps(-1 TO 65, -1 TO 65, 4) AS MapSquare 'all 4 land maps terrain data
  137. DIM SHARED Land(-1 TO 65, -1 TO 65) AS MapSquare 'current land map data
  138. DIM SHARED Layer(16) AS LONG, P AS Player_Data, G AS GameData
  139. DIM SHARED Title(3, 3) AS STRING, Names(3) AS STRING, PX.Army(5) AS Standing_Army
  140. DIM SHARED PX.Spells(16) AS _BYTE, Control AS Control_Keys
  141. DIM SHARED Stats(3, 3) AS StatData, Units(25) AS Unit_Data, Villains(17) AS ContractData
  142. DIM SHARED Lands(4) AS STRING, Castles(27) AS TownData, Towns(27) AS TownData
  143. DIM SHARED BackGround_Color(4) AS _UNSIGNED LONG, Spells(16) AS Spell_Data
  144. DIM SHARED Puzzle(4, 4) AS _BYTE, Sign(70) AS Signs
  145.  
  146. G.GameTimer = _FREETIMER
  147. ON TIMER(G.GameTimer, .125) ClockTick
  148. MapTerrain:
  149. DATA " #ó$ %(&$ %.&#$&##$ %'& ##$ %.& #%'( )&*+,( ),*+%,+%%,(* -%+ %#,(* -,+& #$'./ 0$12))3/ 0*12 )'32 )#* -&45-6778 -#9:;<=> #$'.?9:;-4001@? -*. @#/001 @#/005 -)+&#A8--BCDEF> #$'.?BCD-678412 )$*-(*--.@@/5--4001? -$6 7(G##A8 -%6G #$'.? -$>#A84 0$1?-.2))3/05 -&.?-677G #+$,6 7#8> #%'.? -#6G##A 7$845-4 0$5 -%68-45-+ %#& #*A7G ##'+& #$'.?-(*>#$%%& ##A78 -)677GA8 -'+ %&& #)A7G #$'.?-.?+%,(*+& #$A 7(8+& ##A 7$8 -)+ %#& #,'.?-.2 )#32*> #-A8+& #'A8--( )#* -%+& #+'.?-401/ 0#5> #$$ %%& ##A7G##$ %$&A7840012 )#*--+& ##$& #%'.? -#.?-677G ##$,-9:;-+& #$$&#'9:;-+%&A7784 0#12*--+ %#,+& #$'.2)*-.?6G #%$,--BCD--+& ##'+%,BCD -#+%&#A 7#8412* -#<H=6G #$'401?-.?+& #$$, -)+&##A8 -(<=+ %$&A8412*--EIJ> #%A78.?-.2*> #$A 7+G ##'-< H$=-KLH= -#+&A8412*--KJ+& #&'.?-41?+& #3'-KM N#F-ENIJ-<H=+&A8412*-KL=> #&'.?--.2*>##$%%& #'$&#$%%,-KJ -'KJ-EIJ-+&A841?-EIJ> #&'.2*-.@?+%%,--+%%&$&##'+%, -$KJ-< H%OJ--KL=-+&A8.?--KJ> #&'.@?-.@2* -(+,+%%, -$<HHOJ-KM N#IPLHHOPJ-->#'.?--KJ> #%$,.@?-41@2*-QR-QR -(<HHOMNNF-KJ9:;KM N%F67G$,.?--KJ> #%'(3/5--4005-ST-ST< H'OPMNF -$KJBCDKJ -&>#$,-.?--EF> #$$,./5 -(< H$OPM N'F -&KJ -#KL H$=6G$,--.? -$> #$'(3? -#()*<HHO P#MNNF -.KL=-<OPPMNNF>$,-()3?<H=-> #$'.@2 )#3/5KM N%F -$< H,OPJ-KMNNF677G'--4005ENF-> #$'4 0&5<OJ -'<HHOM N-F-EF677G$%%, -*> #$'< H'OPJ-< H%OMNNF -'6 7)G#$%, -$(*<=-<H=-> #$'KM N(F-KM N%F -#6 7&G#$ %), -$()3?EF-ENF6G #$'KJ -*EF -#6 7%G$ %',-()*-( )(3@/5 -&> #%'KL H#=<HH= -#6 7#G$ %%,( )(3/5-401@/001 @#?--<H=--+& #$'E N$FENNF--6G#$%%,( )%3/ 0(5QUUR405--.@/05--ENF677G #$A86778--9:;-->##'())3/ 0%5-QURQ U$VWWXRQR--41? -#6 7#G #('>#$,--BCD-->##'4 0#5Q U&VWXV W#YZ[WWXV\QR-45-67G##$& #(AG#A78 -&>##' -%]Y[WY Z#[WWVWW\-] W$\STQR--> ##$,+& #'$& ##A8 -%>##'( )#*STS[\9:;SZ[ W#XUV W$XUR]\-->#$%,<=+& #%$,+%%&#A78 -#+&#'40012)*QV\BCD68] W+YT]\-6G#'<=KL=+& #$'<HH=> ##A7867G#' -#401?]W\ -#+,S[WWV W#Y W#XR]\->#$,KLOPL=> #$'ENNF+ %$&AG ##'--9:;.?SZX U$RQV W$YZ[ W#YTST->#'<OM N#F> #$A78 -'+ %#&#'--BCD.2)*]WY[WXVWYZ[W\-]WY[\QUR->#'KPJ9:;6G #&'-( )#* -%>#A8 -$.@@?SZT] W$XUVWXUVYTSTS[\->#'EIJBCD+& #&'-./01? -%+%&A 7#84012))*S[ W#Y W&XRQR-ST->#A8KJ--<=> #$$%,-.?-.2 )#* -#+ %#&A8-40012*S Z#[YZ[ W$\]\ -$+&#'EF-<OJ> #$' -#.?-./001? -'>#A 7#8412))*-STQVWWYZTST-QR-->#A8--ENF> #$'-()3?-.?--.? -'+ %$&'-40012))*S Z#TQR -#ST-->##A 7$8> #$'-./05-.2*-.2)*678 -'>A78--40012))*--ST -'+ %#& ##AG #$'-.? -#.@?-401?+&' -$<=-+%&' -%40012 )#*--(*-(*-(*-+%& #''-.2)*-.@? -#.2*+,--<HOJ-<=>'--<= -$4 0$5--45-45-45 -#>#$& #$'-./05-412)*-.@2))*-KMNF-KJ>'--KLHH= -#< H#= -(<H=-+%,> #$'(3? -$4005-4 0#1?-KJ -#KJ>A8-ENIPL H#OMNIJ--<=-<=-ENF -#6G #$'41?-(* -*.?-EF-<HOJ+&' -#ENIPMNIJ-KJ--EF-EF -%67G #%A8.?-.2)*-( )$*-.2)*--ENNF->A778--ENF-KJ-EF -#6 7(G #('.?-4005-4 0#1?-./05 -'+%%&A78 -$EF -&>##$& #,$,.?--9; -#9;-.2)3? -,+%&A78 -%<=677G##'+%%&$%%& #%'-.2*-BD -#BD-./005--( )'* -#+%&A78 -#KJ>##$&$, -#+,<=> #%A8./5-9;9:;9;-45 -%. @#/0012)*-<=+%&A778EF>#$,+, -&KJ+& #%'45--BDBCDBD -%())3/005--4005-EF--+%%&A77G$,-<=-9:;-<OJ6G #%A8--<=9;-9;<=--()3 @#? -.9:;> ##$,<HOJ-BCD-ENF> #%$%A8-EFBD-BDEF--4001@@2 )** -#BCD>#$%,<OMNF -&67G #%'->' -+68--4 0,12)* -$>$,<HMNF--678686G #''->A78-678 -%>' -$6 7$8 -%4005-686GA8ENF6786G$,>AG #(A7G##A7G#A 7%GA 7$G #$A 7*GAG##A 7#G#AG#A7G #¿"
  150. DATA " #e$& #$$ %*& #&$ %%&#$ %)&$ %*& #'$%,+ %$, -*+ %&, -%+%, -)+, -*+& #&' -%()*-(* -#()* -*()* -%( )%* -$())* -&> #&'-(*--405-.?--(3@?--(*--( )#3@2)* -#./ 0#1?-())3/05 -#(*-+& #$$,-.2* -%.?-(3/05-(32*-4001 @$2)*-.?9:;.2)3/005 -$(3?--> #$'--412 )%3?-.@? -#.@@? -$./001/05-.?BCD4 0#5 -&(3@?--> #$' -#.@/ 0%5-.@2 )#3@@2 )$3?--.? -#.? -)( )$3/05--> #$A8--.@? -'./ 0+1@?--.2 )#32 ))3 @%? -$> #%A8-41?-())*-(3?6 7)8412*-./ 0,1/ 0%1? -#6G #&'--.?-4012)3/5>$ %'&A8405-456 7*8.? -%.? -#> #''--.? -#.@@/56G'( )%*+&A 7&G$ %(&'.2 )#*-.?--6G #&$,--.? -#./056G#'./ 0#12*+& #%$%,( )&*>'./001?-.?--+& #%$,-()32)*-.?67G$%,.? -#412*+&##$%,()3 @&?>'.?--.?-.2*--+& #$'--./001?-.?>#$,()3? -$.@2*>#$,()3/ 0#1/005>'.?--.?-.@? -#> #$'--.?--.?-.?+%,(3/05-(*-401?>#A841@? -#.?-67G'.?-(3?-405 -#> #$'--45--.?-.? -#.@? -#.? -#.?+&#A841? -#.?->##'.?-.@? -'> #$' -%(3?-.2 )#3/5 -#.?-()32*+&#A8.?-()3?-+%%,.?-412* -#<H=> #$' -#()3/5-./ 0$5 -#(3?-40012*+&#'.?-4012 )%3?--412*--ENF> #$'-()3@/5--.? -&()3@? -$.@2*+&'.? -#401 @%2*--.@2* -$> #$'-. @#?--(3?-())*-41@@2)*--.@/56G'.2)* -#4 0%12*-4012* -#> #$'-.@@/5--.@?-401?--./ 0#5-(3/56G$,./12)* -'405 -#.@2*-6G #$'-./05 -#.@? -#.?--.?-9:;-./56G$,(3?4012 )%* -'401?-> #%'-45 -#()3@2 )#3?--.?-BCD-.?6G#'(3/5--4 0%12* -(.?-> #%' -$()3/01@@/005--.? -%.?>$%,.@? -)412 )#* -$45-> #%' -$.@@5-./05 -$(32)*-()3?>'()3@2 )'*--401@@2* -&> #%'--()3@?--45 -#())3/005-401?>'./ 0)12* -#./012)*-(*6G #%A8-.@@/5 -%()3@/05 -&45>'45 -&9:;412)*-45-401?-.?> #''-41/5 -#())3/005 -*>A8 -'BCD-401? -&45-45> #''--45 -#(3@@/5 -'( )$*+&'())* -'68.2 )#* -'> #'A8 -%(3@@/5--<=--()3/0012*>'.@@2))* -$+,401@@?-(* -#6G$& #&A8 -#(3@/05--<OJ--.@/5--405>'4001@@2)* -&41@?-45--6G$,> #''--(3/05 -#<OMF-(3/5 -&>' -#4 0#12)* -#6841? -$6G$,-> #''-(3/5 -#<HOMF--./5 -#<=-->'<H= -$41@2*--+,-.2* -#>#'--> #''-.@? -#<OPMF--(3? -#<OJ-->'ENF -%4012* -$.@2*-->$,--> #''-./5 -#KMNF--(3/5--<OMF-->' -#Q U#R--41? -$4005-->' -#> #%$%,-45 -#<OJ -$405--<OMF -#>'<=-]YZ[\ -#45<H=-<HH=-->A8--> #$$, -&<HOPL= -'<OPJ -#6G'KJ-]\-]\--<HHOPJ-KPPJ-->#A78> #$'--< H$O P$L H'OMNF-67G#'EF-]XUV\-<OMNNIJ-KPPL=-+%&#AG #$'-<OM N)IPPM N$F -#> ##A8--S Z#T<OMF--EF-ENNIJ -#+%& #%'-KPJ -)KPMF -&67G #$A8 -%<OPJ -)KLH= -#> #%'-KPJ-< H%=-KMF -#6 7#G #'A8 -#<OMNF-<HH=-<=-KPPL=--+& #$'-KPJ-KPMNNIJ-KJ9:;->$%&##$ %#&##A8--KPJ -#KPPJ-KJ-ENIPJ-<=> #$'-EIJ-EIJ--EF-KJBCD->'->#$,9:;> ##A8-KPLH=-ENNF-KJ -#KPJ-EF> #$'--KJ--KJ -%KJ -$>'->#'-BCD+& ##'-ENIPJ -&KJ-<HOMF--6G #$'--KL=-KL H%OL H#=>A7G#' -%> ##' -#EIL H&OJ-KPPJ677G #%'--EIJ-E N*IJ+& ##A 7%G ##'(*--KM N'F-EIPJ> #(' -#KJ -,KJ-+&#$%%& #&$,45--KJ -*KPJ+& #''(*-KJ-<HH=-<=-<=-KJ-6G#'--> #$$%, -$<OL H(=-KPL=+%& #%'45-KJ-KPMF-KJ-KJ-EF6G##A77G ##$, -%<OMNIM N%IJ-KPPLH=+& #$' -#KLHOMF--KLHOJ-67G##$ %',< H%OMF-KJ -%KJ-E N#IL=> #$'-<HOMNIJ--<PPMNF6G#$%%,< H'OM N%F--EF-<H=-EF -%KPJ> #$'-ENNF-KLHHOMNF67G$%,<HHOPM N&F -+KPJ -$<=-<OPJ> #$' -&KM N#F67G#$,<HOM N#F -(<HH= -#<HHOPLH=-<OJ-KPPJ> #$'-())*-EF6 7#G$%%,<OPMF -%< H&OPPL=--E N$IPJ-KPLHOMNF> #$A84005677G#$%%,<=-ENNF--< H#O P#M N%IL= -#9:;KPJ-EIPPMF-6G #%A 7$G$ %#,<HHOJ -&<O P$MNNF6 7#8EIL=--BCDKPJ--ENNF--> #($ %#,< H#O P#LHH=-<HOM N$F677G ##A8EIL= -#<OMF -'6G #%$%%, -#<O P(MNF-ENNF -%> #&$,-EIL H#OMF -(> #&' -&E N)F -(6 7#G #&' -#E N%F -#6 7%G #&A 79G #*A 7-G #Ω"
  151.  
  152. BackgroundColors:
  153. DATA 4282417216,4282400896,4286595136,4286611584
  154. Lands:
  155. DATA "Continentia","Forestria","Archipelia","Saharia"
  156. Names:
  157. DATA "Sir Crimsaun","Lord Palmer","Tynnestra","Mad Moham"
  158. Titles:
  159. DATA "Knight","General","Marshal","Lord"
  160. DATA "Paladin","Crusader","Avenger","Champion"
  161. DATA "Sorceress","Magcian","Mage","Archmage"
  162. DATA "Barbarian","Chieftain","Warlord","Overlord"
  163. Advancement:
  164. DATA 100,2,1,1000,7500,100,3,1,1000,0,300,4,1,2000,0,500,5,2,4000,0
  165. DATA 80,3,1,1000,10000,80,4,2,1000,0,240,5,2,2000,0,400,6,2,4000,0
  166. DATA 60,5,2,3000,10000,60,8,3,1000,0,180,10,5,1000,0,300,12,5,1000,0
  167. DATA 100,2,1,2000,7500,100,2,1,2000,0,300,3,1,2000,0,500,3,1,2000,0
  168. Units:
  169. '    name     ,hp ,AtkL,AtkH'Sht,SL,Mv,Cost,Shts,Grp,ShtL,ShtH
  170. DATA Peasant,1,1,1,0,1,1,10,0,1,0,0
  171. DATA Sprite,1,1,2,0,1,99,10,0,3,0,0
  172. DATA Militia,2,1,2,0,2,2,50,0,1,0,0
  173. DATA Wolf,3,1,3,0,2,3,40,0,4,0,0
  174. DATA Skeleton,3,1,2,0,2,2,40,0,5,0,0
  175. DATA Zombie,5,2,2,0,2,1,50,0,5,0,0
  176. DATA Gnome,5,1,3,0,2,1,60,0,3,0,0
  177. DATA Orc,5,2,3,1,2,2,75,6,4,1,2
  178. DATA Archer,10,1,2,1,2,2,250,12,2,1,3
  179. DATA Elf,10,1,2,1,3,3,200,24,3,2,4
  180. DATA Pikeman,10,2,4,0,3,2,300,0,2,0,0
  181. DATA Nomad,15,2,4,0,3,2,300,0,3,0,0
  182. DATA Dwarf,20,2,4,0,3,1,300,0,3,0,0
  183. DATA Ghost,10,3,4,0,4,3,400,0,5,0,0
  184. DATA Knight,35,6,10,0,5,1,1000,0,2,0,0
  185. DATA Ogre,40,3,5,0,4,1,750,0,4,0,0
  186. DATA Barbarian,40,1,6,0,4,3,750,0,3,0,0
  187. DATA Troll,50,2,5,0,4,1,1000,0,4,0,0
  188. DATA Calvery,20,3,5,0,4,4,800,0,2,0,0
  189. DATA Druid,25,2,3,1,5,2,750,3,3,10,10
  190. DATA Archmage,25,2,3,1,5,99,1200,2,3,25,25
  191. DATA Vampire,30,3,6,0,5,99,1500,0,5,0,0
  192. DATA Giant,60,10,20,1,5,3,2000,6,3,5,10
  193. DATA Deamon,50,5,7,0,6,99,3000,0,5,0,0
  194. DATA Dragon,200,25,50,0,6,99,5000,0,4,0,0
  195.  
  196. Contract_Data:
  197. DATA "Murray the Miser","None",5000,1
  198. DATA "Threadbare clothes, bald patch with hair combed to cover it, incessant cough."
  199. DATA "Murray is wanted for various petty crimes as well as for treason.  He allowed a group of pirates to enter the castle and free criminals."
  200.  
  201. DATA "Hack the Rogue","The Spitter",6000,1
  202. DATA "Bushy ebon beard stained with tobacco juice, numerous battle scars, brash, arrogant behavior."
  203. DATA "Along with many minor infractions, Hack is wanted for conspiracy against the Crown and grave-robbing."
  204.  
  205. DATA "Princess Aimola","Lady Deceit",7000,1
  206. DATA "Excessive use of make-up to hide aging features, ever-present lace handkerchief."
  207. DATA "The Princess violated her status as a visiting dignitary by encouraging a murder and joining the conspiracy against the Crown."
  208.  
  209. DATA "Baron Johnno Makahl","Johnno",8000,1
  210. DATA "Expensive and gaudy clothes, overweight, and a scruffy beard."
  211. DATA "Johnno is wanted for various crimes against the Kingdom, including leading a direct assualt against the Crown and conspiracy."
  212.  
  213. DATA "Dread Pirate Rob","Terror of the Sea",9000,1
  214. DATA "Pencil thin moustache and elegantly trimmed beard never without a rapier."
  215. DATA "Rob is wanted for piracy as well as conspiracy and for breaking out five traitors sentenced to death in the Royal Dungeons."
  216.  
  217. DATA "Caneghor the Mystic","The Majestic Sage",10000,1
  218. DATA "Voluminous robes, bald head, magic symbols engraved on body, levitating ability."
  219. DATA "Caneghor is wanted for grave robbing, conspiracy against the Crown, and plundering the Royal Library."
  220.  
  221. DATA "Sir Moradon the Cruel","None",12000,2
  222. DATA "Always wearing armor and concealed weapons, has two prominent front teeth and an unkept beard."
  223. DATA "Sir Moradon, an emissary from another land, is wanted for joining a conspiracy to topple the kingdom."
  224.  
  225. DATA "Prince Barrowpine","The Elf Lord",14000,2
  226. DATA "Pointed ears, sharp elfin features, pale blue eyes with no whites, glimmering enchanted coin."
  227. DATA "The prince is one of the leaders of the conspiracy against the Crown, he also traffics stolen artifacts."
  228.  
  229. DATA "Bargash Eyesore","Old One Eye",16000,2
  230. DATA "Single eye centered in middle of forehead, over ten feet tall, only hair on body is in beard."
  231. DATA "Bargash is wanted for conspiracy against the Crown and for leading an outright attack against the King."
  232.  
  233. DATA "Rinaldus Drybone","The Death Lord",18000,2
  234. DATA "Rinaldus is a magically animated skeleton, an undead, he is easily identifiable by the ancient crown he wears."
  235. DATA "Rinaldus is wanted for conspiracy against the Crown and leading a rebellion on the continent of Saharia."
  236.  
  237. DATA "Ragface","None",20000,3
  238. DATA "Ragface is an undead, he is covered from head to foot in moldering green strips of cloth. A rotting smell follows him."
  239. DATA "Conspiracy against the Crown and leading an insurrection in Saharia."
  240.  
  241. DATA "Mahk Bellowspeak","Bruiser",25000,3
  242. DATA "Bright orange body hair on a fluorescent green body, a tendency to shout for no apparent reason."
  243. DATA "Mahk is wanted for the conspiracy against the Crown, leading a jail break, and for piracy on the open seas."
  244.  
  245. DATA "Auric Whiteskin","The Barbarian",30000,3
  246. DATA "Auric is heavily muscled and wears a protective skin made from the hides of baby lambs."
  247. DATA "Auric is wanted for conspiracy and for leading the rebellion of the continent Saharia."
  248.  
  249. DATA "Czar Nickolai the Mad","The Mad Czar",35000,3
  250. DATA "The Czar has eyes which change color constantly, also a sulphuric smell emanates from his body."
  251. DATA "The Czar is wanted for conspiracy against the Crown, violating diplomatic status, and murder."
  252.  
  253. DATA "Magus Deathspell","None",40000,4
  254. DATA "Pupil-less eyes, flowing white beard, always wears crimson robes and a matching skull cap."
  255. DATA "Magus is wanted for conspiracy against the Crown and for practicing forbidden magics."
  256.  
  257. DATA "Urthrax Killspite","The Demon King",45000,4
  258. DATA "Green, scaly skin, glowing red eyes, horns protruding from sides of head, over 7 feet tall."
  259. DATA "Urthrax is wanted for conspiracy against the Crown."
  260.  
  261. DATA "Arech Dragonbreath","Mastermind",50000,4
  262. DATA "Arech is an immense dragon with a green body and blue wings, he breathes fire."
  263. DATA "Arech is wanted for leading the conspiracy against the Crown, arranging jailbreaks, formenting rebellion, stealing the Sceptre of Order."
  264.  
  265. CastleData:
  266. DATA "Azram       ",30,26,1,30,27
  267. DATA "Basefit     ",47,05,2,47,6
  268. DATA "Cancomar    ",36,48,1,36,49
  269. DATA "Duvock      ",30,17,2,30,18
  270. DATA "Endryx      ",11,45,3,11,46
  271. DATA "Faxis       ",22,48,1,22,49
  272. DATA "Goobare     ",41,35,3,41,36
  273. DATA "Hyppus      ",43,26,3,43,27
  274. DATA "Irok        ",11,29,1,11,30
  275. DATA "Jhan        ",41,33,2,41,34
  276. DATA "Kookamunga  ",57,57,1,57,58
  277. DATA "Lorsche     ",52,56,3,52,57
  278. DATA "Mooseweigh  ",25,38,2,25,39
  279. DATA "Nilslag     ",22,23,1,22,24
  280. DATA "Ophiraund   ",06,56,1,6,57
  281. DATA "Portalis    ",58,22,1,58,23
  282. DATA "Quinderwitch",42,55,2,42,56
  283. DATA "Rythacon    ",54,05,1,54,6
  284. DATA "Spockana    ",17,38,4,17,39
  285. DATA "Tylitch     ",09,17,3,9,18
  286. DATA "Uzare       ",41,11,4,41,12
  287. DATA "Vutar       ",40,04,1,40,5
  288. DATA "Wankelforte ",40,40,1,40,41
  289. DATA "Xelox       ",45,05,3,45,6
  290. DATA "Yeneverre   ",19,18,2,19,19
  291. DATA "Zyzzarzaz   ",46,42,4,46,43
  292. TownData:
  293. DATA "Anomaly       ",0,0,04,35,23,2,34,23
  294. DATA "Bayside       ",0,0,15,48,58,1,41,58
  295. DATA "Centrapf      ",0,0,08,09,38,3,9,39
  296. DATA "Dark Corner   ",0,0,17,58,59,2,58,60
  297. DATA "Elan's Landing",0,0,13,03,36,2,3,37
  298. DATA "Fjord         ",0,0,23,47,35,1,46,35
  299. DATA "Grimwold      ",0,0,19,09,59,4,9,60
  300. DATA "Hunterville   ",0,1,22,12,04,1,12,3
  301. DATA "Isla Vista    ",0,0,18,56,05,1,57,5
  302. DATA "Japper        ",0,0,24,13,08,3,13,7
  303. DATA "Kings Haven   ",0,0,14,16,21,1,17,21
  304. DATA "Lake Veiw     ",0,0,06,16,44,1,17,44
  305. DATA "Midland       ",0,0,10,57,33,2,58,33
  306. DATA "Nyre          ",0,0,16,50,14,1,50,13
  307. DATA "Overthere     ",0,0,12,57,56,3,57,57
  308. DATA "Paths end     ",0,0,03,38,49,1,38,50
  309. DATA "Quiln Point   ",0,0,09,13,27,1,14,27
  310. DATA "Riverton      ",0,0,01,29,11,1,29,12
  311. DATA "Simpleton     ",0,0,07,12,60,3,13,60
  312. DATA "Topshore      ",0,0,05,05,49,3,5,50
  313. DATA "Underfoot     ",0,0,02,57,04,2,58,4
  314. DATA "Vengance      ",0,0,21,06,03,4,7,3
  315. DATA "woods end     ",0,0,25,03,09,2,3,8
  316. DATA "Xoctan        ",0,0,11,51,29,1,51,28
  317. DATA "Yakonia       ",0,0,20,50,08,3,49,8
  318. DATA "Zaezoizu      ",0,0,26,58,47,4,58,48
  319. SpellData:
  320. DATA "Bridge",100,"Time Stop",200,"Find Villain",1000,"Castle Gate",1000,"Town Gate",500,"Instant Army",1000,"Raise Control",500
  321. DATA "Close",2000,"Teleport",500,"FireBall",1500,"Lightning",500,"Freeze",300,"Resurrect",5000,"Turn Undead",2000
  322. PuzzleData:
  323. DATA 7,22,2,18,4,20,30,25,28,23,0,27,33,31,6,17,32,29,26,21,1,24,5,19,3
  324. SignData:
  325. DATA "Rent a boat and sail the seas. Explore the easy way!",14,3,1
  326. DATA "Treasure Island",3,3,1
  327. DATA "Aurange is north",5,6,1
  328. DATA "The Secptre will never be fonud!",3,9,1
  329. DATA "King's Tresure Garden",12,10,1
  330. DATA "There are two artifacts per continent.",15,10,1
  331. DATA "Pond of Peril",20,16,1
  332. DATA "Peasant Way",25,11,1
  333. DATA "Six villains rule Continentia.",38,3,1
  334. DATA "It takes time to cross the desert.",45,16,1
  335. DATA "Wonder Woods",40,12,1
  336. DATA "Dead End",32,18,1
  337. DATA "Irok guards the north",10,28,1
  338. DATA "A-maze-ing Forest",15,33,1
  339. DATA "All maps are found in chests",58,33,1
  340. DATA "Bridge Port",51,38,1
  341. DATA "Hidden Grove",34,39,1
  342. DATA "Secret Pass",9,41,1
  343. DATA "Pirate's Cove",7,55,1
  344. DATA "Isle of Death",24,49,1
  345. DATA "Boon Docks",43,59,1
  346. DATA "Welcome to Kookamunga!",55,59,1
  347.  
  348. DATA "Wood's End is south.",3,15,2
  349. DATA "Time is on our side.",42,3,2
  350. DATA "Passage to Basefit.",52,3,2
  351. DATA "The end is near.",57,11,2
  352. DATA "Peasants are fodder!",59,22,2
  353. DATA "Remember, whereever you go there you are.",60,28,2
  354. DATA "Undead are everywhere!",41,15,2
  355. DATA "The ogres are back... and they're hungry!",27,14,2
  356. DATA "Treasure at the river's end.",22,14,2
  357. DATA "Monster Way",18,26,2
  358. DATA "There is one town for each castle.",42,27,2
  359. DATA "No Trespassing!",37,35,2
  360. DATA "You'll never find the Sceptre here!",39,39,2
  361. DATA "Crossroads",22,34,2
  362. DATA "Forestria maze entrance!",7,32,2
  363. DATA "Beware the moors!",6,37,2
  364. DATA "Wrong Way!",16,58,2
  365. DATA "Don't go any farther!",22,49,2
  366. DATA "Stay on the road!",64,48,2
  367. DATA "Your Quest is doomed!",56,39,2
  368. DATA "Four villains rule Forestria",55,60,2
  369.  
  370. DATA "Welcome to Archipelia!",10,60,3
  371. DATA "The islands hide treasures.",3,56,3
  372. DATA "Four villains rule here.",11,50,3
  373. DATA "There are five islands here.",9,33,3
  374. DATA "Swamplands",6,16,3
  375. DATA "There's no turning back!",28,6,3
  376. DATA "Pirate's Treasure Trove",25,22,3
  377. DATA "Pirates have no mercy!",29,28,3
  378. DATA "Corak was here!",37,22,3
  379. DATA "The dead live!",40,28,3
  380. DATA "Thieves will be eaten!",53,24,3
  381. DATA "Pool of Prosperity",41,43,3
  382. DATA "Maximus will DIE!",34,39,3
  383. DATA "Time is on our side!",31,56,3
  384. DATA "Down with the King!",51,35,3
  385.  
  386. DATA "Your army will perish here!",40,11,4
  387. DATA "Three villains rule Saharia.",52,9,4
  388. DATA "Oasis",39,18,4
  389. DATA "Wading Pool",14,30,4
  390. DATA "There is no escaping the prophecy!",18,38,4
  391. DATA "Time is running out!",17,46,4
  392. DATA "this place is a nightmare!",11,59,4
  393. DATA "Treasure Trough",25,47,4
  394. DATA "Treasure Zone",35,50,4
  395. DATA "Rest Stop",43,49,4
  396. DATA "Volcano Guardian",47,42,4
  397. DATA "Oasis of Plenty",46,33,4
  398.  
  399. '------------------Layer loader------------------
  400. Layer(0) = _DISPLAY
  401. Layer(1) = _NEWIMAGE(640, 480, 32)
  402. Layer(2) = _LOADIMAGE("Windows.bmp", 32)
  403. Layer(3) = _LOADIMAGE("MapTiles.bmp", 32)
  404. Layer(4) = _LOADIMAGE("BackGrounds.bmp", 32)
  405. Layer(5) = _LOADIMAGE("Units.bmp", 32)
  406. Layer(6) = _NEWIMAGE(500, 400, 32) 'map predraw
  407. Layer(8) = _NEWIMAGE(640, 480, 32) 'background color layer
  408. Layer(9) = _NEWIMAGE(640, 480, 32) 'temp layer
  409. Layer(13) = _NEWIMAGE(6720, 5600, 32) 'Continentia
  410. Layer(14) = _NEWIMAGE(6720, 5600, 32) 'Forestria
  411. Layer(15) = _NEWIMAGE(6720, 5600, 32) 'Archipelia
  412. Layer(16) = _NEWIMAGE(6720, 5600, 32) 'Saharia
  413.  
  414. _CLEARCOLOR _RGB32(0, 0, 0), Layer(2)
  415. _CLEARCOLOR _RGB32(76, 76, 140), Layer(2)
  416. _CLEARCOLOR _RGB32(0, 0, 0), Layer(5)
  417. '------------------------------------------------
  418. Load_Data
  419. '---------------starting stats-------------------
  420. G.Days = 900
  421. G.TimeStop = 0
  422. G.Level = EASY
  423. P.Class = KNIGHT
  424. P.Promotion = 0
  425. P.Maps_Aquired = 1
  426. P.Artifacts_Aquired = 0
  427. P.Puzzle_Peices = 2 ^ 25 - 1
  428. P.Magic_Learned = FALSE
  429. P.Seige_Bought = FALSE
  430. P.Current_Contract = 0
  431. P.MapXPos = 48 * 11
  432. P.MapYpos = 40 * 5
  433. P.Current_Land = CONTINENTIA
  434. '------------------------------------------------
  435. '--------------Basic Controls--------------------
  436. Control.Up_Key = 18432
  437. Control.Down_Key = 20480
  438. Control.Left_Key = 19200
  439. Control.Right_Key = 19712
  440. Control.Start_Button = 13 'enter
  441. Control.A_Button = 97 '    a
  442. Control.B_Button = 115 '   s
  443. Control.C_Button = 100 '   d
  444.  
  445. PX.Spells(1) = 5
  446. PX.Spells(3) = 5
  447. PX.Spells(5) = 5
  448. PX.Spells(7) = 5
  449. PX.Army(0).Unit = 3
  450. PX.Army(0).Count = 20
  451. PX.Army(1).Unit = 9
  452. PX.Army(1).Count = 2
  453. PX.Army(2).Unit = 11
  454. PX.Army(2).Count = 2
  455. PX.Army(3).Unit = 19
  456. PX.Army(3).Count = 2
  457. PX.Army(4).Unit = 4
  458. PX.Army(4).Count = 2
  459.  
  460. G.HDR_Text = Names(P.Class) + " the " + Title(P.Class, P.Promotion)
  461.  
  462. Add_Player_Advancement 'players first advnacement from Nobody to hero set base values
  463. Place_Extras
  464. Set_BackGround_Color
  465.  
  466. G.Scepter_Land = CONTINENTIA
  467. Hide_Scepter G.Scepter_Land
  468. Swap_Map P.Current_Land, LOAD
  469. Build_Map 13
  470.  
  471. 'Swap_Map FORESTRIA, LOAD
  472. 'Build_Map 14
  473.  
  474.  
  475.  
  476.  
  477. 'Build_Map 13
  478. G.In_Combat = FALSE
  479. 'TIMER(G.GameTimer) ON
  480. 'DO
  481. Build_Main_Window
  482. Build_Map_View
  483. Draw_Player
  484. Build_Dismiss_Window
  485. 'Build_Menu_Window
  486. _PUTIMAGE , Layer(1), Layer(0)
  487. '_DELAY .01
  488. 'LOOP UNTIL INKEY$ = CHR$(27)
  489. 'TIMER(G.GameTimer) OFF
  490. 'DumpMap
  491. 'SaveBMP "Continentia.bmp", Layer(13), 0, 0, 6719, 5599
  492.  
  493. SUB Build_Stat_Window
  494.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(8), Layer(1), (0, 15)-STEP(639, 447)
  495.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  496.  SELECT CASE P.Class
  497.   CASE KNIGHT '96,104
  498.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (464, 224)-STEP(95, 103)
  499.   CASE PALADIN
  500.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (560, 224)-STEP(95, 103)
  501.   CASE SORCERESS
  502.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (464, 328)-STEP(95, 103)
  503.   CASE BARBARIAN
  504.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (560, 328)-STEP(95, 103)
  505.  FOR i%% = 0 TO 3
  506.   _PUTIMAGE (16 + i%% * 96, 271)-STEP(95, 175), Layer(2), Layer(1), (256, 416)-STEP(47, 87)
  507.  NEXT i%%
  508.  _PUTIMAGE (400, 271)-STEP(111, 175), Layer(2), Layer(1), (512, 472)-STEP(55, 87)
  509.  _PUTIMAGE (512, 271)-STEP(111, 175), Layer(2), Layer(1), (512, 472)-STEP(55, 87)
  510.  IF P.Maps_Aquired AND 1 THEN _PUTIMAGE (412, 287)-STEP(87, 63), Layer(2), Layer(1), (256, 504)-STEP(43, 31)
  511.  IF P.Maps_Aquired AND 2 THEN _PUTIMAGE (412, 367)-STEP(87, 63), Layer(2), Layer(1), (256, 536)-STEP(43, 31)
  512.  IF P.Maps_Aquired AND 4 THEN _PUTIMAGE (524, 287)-STEP(87, 63), Layer(2), Layer(1), (256, 568)-STEP(43, 31)
  513.  IF P.Maps_Aquired AND 8 THEN _PUTIMAGE (524, 367)-STEP(87, 63), Layer(2), Layer(1), (256, 600)-STEP(43, 31)
  514.  IF P.Artifacts_Aquired AND 1 THEN _PUTIMAGE (28, 287)-STEP(71, 63), Layer(2), Layer(1), (656, 224)-STEP(35, 31)
  515.  IF P.Artifacts_Aquired AND 2 THEN _PUTIMAGE (28, 367)-STEP(71, 63), Layer(2), Layer(1), (656, 256)-STEP(35, 31)
  516.  IF P.Artifacts_Aquired AND 4 THEN _PUTIMAGE (124, 287)-STEP(71, 63), Layer(2), Layer(1), (692, 224)-STEP(35, 31)
  517.  IF P.Artifacts_Aquired AND 8 THEN _PUTIMAGE (124, 367)-STEP(71, 63), Layer(2), Layer(1), (692, 256)-STEP(35, 31)
  518.  IF P.Artifacts_Aquired AND 16 THEN _PUTIMAGE (220, 287)-STEP(71, 63), Layer(2), Layer(1), (656, 288)-STEP(35, 31)
  519.  IF P.Artifacts_Aquired AND 32 THEN _PUTIMAGE (220, 367)-STEP(71, 63), Layer(2), Layer(1), (656, 320)-STEP(35, 31)
  520.  IF P.Artifacts_Aquired AND 64 THEN _PUTIMAGE (316, 287)-STEP(71, 63), Layer(2), Layer(1), (692, 288)-STEP(35, 31)
  521.  IF P.Artifacts_Aquired AND 128 THEN _PUTIMAGE (316, 367)-STEP(71, 63), Layer(2), Layer(1), (692, 320)-STEP(35, 31)
  522.  
  523.  Window_Header
  524.  
  525.  KB_Print 210, 79, Names(P.Class) + " the " + Title(P.Class, P.Promotion), 0, LEFT
  526.  
  527.  KB_Print 210, 111, "Leadership", 0, LEFT
  528.  KB_Print 210, 127, "Commission/Week", 0, LEFT
  529.  KB_Print 210, 143, "Gold", 0, LEFT
  530.  KB_Print 210, 159, "Spell Power", 0, LEFT
  531.  KB_Print 210, 175, "Max # of Spells ", 0, LEFT
  532.  KB_Print 210, 191, "Villians caught", 0, LEFT
  533.  KB_Print 210, 207, "Artifacts found", 0, LEFT
  534.  KB_Print 210, 223, "Castles garrisoned", 0, LEFT
  535.  KB_Print 210, 239, "Followers killed", 0, LEFT
  536.  KB_Print 210, 255, "Current score", 0, LEFT
  537.  
  538.  KB_Print 600, 111, STR$(P.Leadership), 0, RIGHT
  539.  KB_Print 600, 127, STR$(P.Commission), 0, RIGHT
  540.  KB_Print 600, 143, STR$(P.Gold), 0, RIGHT
  541.  KB_Print 600, 159, STR$(P.SpellPower), 0, RIGHT
  542.  KB_Print 600, 175, STR$(P.MaxSpells), 0, RIGHT
  543.  KB_Print 600, 191, STR$(P.VilliansCaught), 0, RIGHT
  544.  KB_Print 600, 207, STR$(P.Artifacts), 0, RIGHT
  545.  KB_Print 600, 223, STR$(P.Castles), 0, RIGHT
  546.  KB_Print 600, 239, STR$(P.Deaths), 0, RIGHT
  547.  KB_Print 600, 255, STR$(P.Score), 0, RIGHT
  548.  _PUTIMAGE , Layer(1), Layer(0)
  549.  DO: _DELAY .01: LOOP UNTIL _KEYHIT = Control.B_Button
  550.  
  551. SUB Window_Header
  552.  KB_Print 2, 31, G.HDR_Text, 0, LEFT
  553.  IF INSTR(RTRIM$(G.HDR_Text), Names(P.Class)) THEN
  554.   IF G.TimeStop THEN
  555.    KB_Print 398, 31, "TimeStop:", 0, LEFT
  556.    KB_Print 606, 31, STR$(G.TimeStop), 0, RIGHT
  557.   ELSE
  558.    KB_Print 398, 31, "Days Left:", 0, LEFT
  559.    KB_Print 606, 31, STR$(G.Days), 0, RIGHT
  560.   END IF
  561.  
  562. SUB KB_Print (x%, y%, Txt$, Null%%, Aline%%)
  563.  Xo% = 0: Yo% = 672 'sheet offsets
  564.  Mx%% = LEN(Txt$)
  565.  IF Aline%% = RIGHT THEN Ax% = LEN(Txt$) * 16: x% = x% - Ax%
  566.  IF Aline%% = CENTER THEN Ax% = LEN(Txt$) * 8: x% = x% - Ax%
  567.  FOR i~%% = 1 TO Mx%%
  568.   So% = (ASC(MID$(Txt$, i~%%, 1)) - 31) * 8
  569.   _PUTIMAGE (x% + (i~%% * 16), y%)-STEP(15, 15), Layer(2), Layer(1), (Xo% + So%, Yo%)-STEP(7, 7)
  570.  NEXT i~%%
  571.  
  572. SUB KB_Print_Wrap (X%, Y%, txt$, MaxX%)
  573.  DIM Lines(10) AS STRING
  574.  'max number of characters with Wrap max of MaxX%%
  575.  IF MaxX% THEN SMx%% = INT(MaxX% / 16) ELSE SMx%% = LEN(txt$)
  576.  LOCATE 1, 1: PRINT SMx%%; MaxX%;
  577.  Finished%% = FALSE
  578.  DO
  579.   Mx%% = SMx%% 'restore Mx to Starting Mx(Mx= Max X length in pixels)
  580.   IF MID$(txt$, Mx%%, 1) = " " THEN
  581.    ' text is nice enough to land on a space
  582.    '   PRINT "lined up?"; MID$(txt$, Mx%%, 7): END
  583.    j%% = j%% + 1
  584.    Lines(j%%) = LEFT$(txt$, Mx%%)
  585.    txt$ = MID$(txt$, Mx%% + 1)
  586.   ELSE
  587.    ' back track to find first space
  588.    Found%% = FALSE
  589.    DO
  590.     IF MID$(txt$, Mx%%, 1) = " " THEN Found%% = TRUE ELSE Mx%% = Mx%% - 1
  591.    LOOP UNTIL Found%%
  592.    j%% = j%% + 1 'set to next line
  593.    Lines(j%%) = MID$(txt$, 1, Mx%%)
  594.    txt$ = MID$(txt$, Mx%% + 1) 'reduce string length
  595.   END IF
  596.   IF RTRIM$(txt$) = "" THEN Finished%% = TRUE
  597.  LOOP UNTIL Finished%%
  598.  
  599.  'print wraped lines
  600.  FOR I%% = 1 TO j%%
  601.   KB_Print X%, Y%, Lines(I%%), 0, LEFT
  602.   Y% = Y% + 16
  603.  NEXT I%%
  604.  
  605. SUB ClockTick
  606.  STATIC CurrentCount~%%, AnimationCount~%%
  607.  
  608.  AnimationCount~%% = AnimationCount~%% + 1
  609.  
  610.  IF (NOT G.In_Menu) AND (NOT G.In_Combat) THEN 'time pauses when in a menu window or combat
  611.   CurrentCount~%% = CurrentCount~%% + 1
  612.   IF G.TimeStop THEN
  613.    IF CurrentCount~%% > 3 THEN G.TimeStop = G.TimeStop - 1: CurrentCount~%% = 0
  614.   ELSE
  615.    IF CurrentCount~%% > 127 THEN G.Days = G.Days - 1: CurrentCount~%% = 0
  616.   END IF
  617.  
  618.  IF AnimationCount~%% > 0 THEN G.Window_Animation = G.Window_Animation + 1: AnimationCount~%% = 0
  619.  IF G.Window_Animation > 3 THEN G.Window_Animation = 0
  620.  
  621. SUB Add_Player_Advancement
  622.  P.Leadership = P.Leadership + Stats(P.Class, P.Promotion).Leadership
  623.  P.Commission = P.Commission + Stats(P.Class, P.Promotion).Commission
  624.  P.SpellPower = P.SpellPower + Stats(P.Class, P.Promotion).SpellPower
  625.  P.MaxSpells = P.MaxSpells + Stats(P.Class, P.Promotion).MaxSpells
  626.  P.Gold = P.Gold + Stats(P.Class, P.Promotion).Gold 'just for starting gold at moment
  627.  
  628. SUB Build_Main_Window
  629.  _PUTIMAGE , Layer(8), Layer(1)
  630.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  631.  Window_Header
  632.  _PUTIMAGE (496, 47)-STEP(143, 415), Layer(2), Layer(1), (728, 192)-STEP(71, 207)
  633.  _PUTIMAGE (524, 63)-STEP(87, 63), Layer(4), Layer(1), (240, 704)-STEP(43, 31)
  634.  _PUTIMAGE (524, 143)-STEP(87, 63), Layer(4), Layer(1), (372, 672)-STEP(43, 31)
  635.  _PUTIMAGE (524, 223)-STEP(87, 63), Layer(4), Layer(1), (328, 672)-STEP(43, 31)
  636.  _PUTIMAGE (524, 303)-STEP(87, 63), Layer(4), Layer(1), (240, 672)-STEP(43, 31)
  637.  _PUTIMAGE (524, 383)-STEP(87, 63), Layer(4), Layer(1), (284, 672)-STEP(43, 31)
  638.  Draw_Coins
  639.  Cover_Puzzle
  640.  Magic_Animation
  641.  Seige_Animation
  642.  Contract_Animation MAIN
  643.  
  644. SUB Draw_Coins
  645.  Gp~% = P.Gold \ 10000
  646.  Sp%% = (P.Gold \ 1000) MOD 10
  647.  Cp%% = (P.Gold \ 100) MOD 10
  648.  IF Gp~% > 10 THEN Gp~% = 10: Sp%% = 10: Cp%% = 10 'over 100k gold all stacks full!
  649.  FOR i%% = 1 TO 10
  650.   IF i%% <= Gp~% THEN _PUTIMAGE (530, 431 - 4 * i%%)-STEP(15, 9), Layer(2), Layer(1), (364, 219)-STEP(7, 4)
  651.   IF i%% <= Sp%% THEN _PUTIMAGE (560, 431 - 4 * i%%)-STEP(15, 9), Layer(2), Layer(1), (372, 219)-STEP(7, 4)
  652.   IF i%% <= Cp%% THEN _PUTIMAGE (592, 431 - 4 * i%%)-STEP(15, 9), Layer(2), Layer(1), (380, 219)-STEP(7, 4)
  653.  NEXT i%%
  654.  
  655. SUB Cover_Puzzle
  656.  FOR i%% = 0 TO 24
  657.   IF P.Puzzle_Peices AND (2 ^ i%%) THEN _PUTIMAGE (528 + x%%, 305 + y%%)-STEP(15, 11), Layer(2), Layer(1), (356, 218)-STEP(7, 5)
  658.   x%% = x%% + 16
  659.   IF x%% = 80 THEN x%% = 0: y%% = y%% + 12
  660.  NEXT i%%
  661.  
  662. SUB Magic_Animation
  663.  IF P.Magic_Learned THEN
  664.   _PUTIMAGE (524, 223)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 576)-STEP(43, 31) 'magic power frames
  665.  
  666. SUB Seige_Animation
  667.  IF P.Seige_Bought THEN
  668.   _PUTIMAGE (524, 143)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 544)-STEP(43, 31) 'magic power frames
  669.  
  670. SUB Contract_Animation (Loca%%)
  671.  IF Loca%% = MAIN THEN Xo% = 524: Yo% = 63 ELSE Xo% = 211: Yo% = 91
  672.  IF P.Current_Contract THEN
  673.   y% = 32 * (P.Current_Contract - 1)
  674.   _PUTIMAGE (Xo%, Yo%)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 0 + y%)-STEP(43, 31) 'magic power frames
  675.  
  676. SUB Build_Army_Window
  677.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(8), Layer(1), (0, 15)-STEP(639, 447)
  678.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  679.  Window_Header
  680.  
  681.  FOR i%% = 0 TO 4
  682.   _PUTIMAGE (0, 51 + i%% * 80)-STEP(639, 91), Layer(2), Layer(1), (300, 600)-STEP(319, 45)
  683.   IF PX.Army(i%%).Unit THEN Unit_Data i%%, i%%
  684.  NEXT i%%
  685.  _PUTIMAGE , Layer(1), Layer(9)
  686.  DO
  687.   FOR i%% = 0 TO 4
  688.    IF PX.Army(i%%).Unit THEN Unit_Animation 24, 63 + i%% * 80, PX.Army(i%%).Unit
  689.   NEXT i%%
  690.   _PUTIMAGE , Layer(1), Layer(0)
  691.   _PUTIMAGE , Layer(9), Layer(1)
  692.   _DELAY .025
  693.  
  694.  LOOP UNTIL _KEYHIT = Control.B_Button
  695.  
  696. SUB Unit_Animation (x%, y%, Unit%%)
  697.  _PUTIMAGE (x%, y%)-STEP(87, 63), Layer(5), Layer(1), (0 + (48 * G.Window_Animation), 0 + (Unit%% - 1) * 32)-STEP(47, 31)
  698.  
  699. SUB Unit_Data (Unit%%, Slot%%)
  700.  y% = 80 * Slot%%
  701.  ID%% = PX.Army(Unit%%).Unit
  702.  a$ = Units(ID%%).Unit_Name
  703.  IF PX.Army(Unit%%).Count > 1 THEN
  704.   IF RIGHT$(RTRIM$(a$), 1) = "f" THEN a$ = LEFT$(a$, LEN(RTRIM$(a$)) - 1) + "ves" ELSE a$ = RTRIM$(a$) + "s"
  705.  b~% = PX.Army(Unit%%).Count
  706.  IF b~% > 1000 THEN b$ = Special_K_Value(b~%) ELSE b$ = LTRIM$(STR$(b~%))
  707.  a$ = b$ + " " + a$
  708.  IF Units(ID%%).Movement = 99 THEN M$ = " Fly" ELSE M$ = STR$(Units(ID%%).Movement)
  709.  KB_Print 112, y% + 80, a$, 0, LEFT
  710.  KB_Print 112, y% + 96, "SL:" + STR$(Units(ID%%).Skill_Level) + "  MV:" + M$, 0, LEFT
  711.  KB_Print 112, y% + 112, "Morale: " + Units_Morale(Unit%%), 0, LEFT
  712.  KB_Print 358, y% + 80, "HitPts: " + Units_HP(Unit%%), 0, LEFT
  713.  KB_Print 358, y% + 96, "Damage: " + Units_Attack(Unit%%), 0, LEFT
  714.  KB_Print 358, y% + 112, "G-Cost: " + Units_Cost(Unit%%), 0, LEFT
  715.  
  716. FUNCTION Units_Morale$ (Unit%%)
  717.  DIM Rack(5) AS _BYTE
  718.  IF Units(PX.Army(Unit%%).Unit).Grouping = 1 THEN a%% = 0: b%% = 0: c%% = 0: d%% = -1: e%% = -1
  719.  IF Units(PX.Army(Unit%%).Unit).Grouping = 2 THEN a%% = 0: b%% = 0: c%% = 0: d%% = 0: e%% = -1
  720.  IF Units(PX.Army(Unit%%).Unit).Grouping = 3 THEN a%% = 0: b%% = 0: c%% = 1: d%% = -1: e%% = -1
  721.  IF Units(PX.Army(Unit%%).Unit).Grouping = 4 THEN a%% = 0: b%% = 0: c%% = 0: d%% = 1: e%% = 0
  722.  IF Units(PX.Army(Unit%%).Unit).Grouping = 5 THEN a%% = 0: b%% = 0: c%% = 0: d%% = 0: e%% = 0
  723.  Total%% = 0
  724.  FOR i%% = 1 TO 5
  725.   IF i%% <> Unit%% THEN
  726.    SELECT CASE Units(PX.Army(i%%).Unit).Grouping
  727.     CASE 1
  728.      Total%% = Total%% + a%%
  729.     CASE 2
  730.      Total%% = Total%% + b%%
  731.     CASE 3
  732.      Total%% = Total%% + c%%
  733.     CASE 4
  734.      Total%% = Total%% + d%%
  735.     CASE 5
  736.      Total%% = Total%% + e%%
  737.    END SELECT
  738.   END IF
  739.  NEXT i%%
  740.  IF Total%% = 0 THEN Result$ = "Norm"
  741.  IF Total%% < 0 THEN Result$ = "Low"
  742.  IF Total%% > 0 THEN Result$ = "High"
  743.  Units_Morale = Result$
  744.  
  745. FUNCTION Units_HP$ (unit%%)
  746.  Result~% = Units(PX.Army(unit%%).Unit).HitPts * PX.Army(unit%%).Count
  747.  IF Result~% > 1000 THEN Result$ = Special_K_Value(Result~%) ELSE Result$ = LTRIM$(STR$(Result~%))
  748.  Units_HP = Result$
  749.  
  750. FUNCTION Units_Attack$ (unit%%)
  751.  lo~% = Units(PX.Army(unit%%).Unit).AttackLo * PX.Army(unit%%).Count
  752.  hi~% = Units(PX.Army(unit%%).Unit).AttackHi * PX.Army(unit%%).Count
  753.  IF lo~% > 1000 THEN lo$ = Special_K_Value(lo~%) ELSE lo$ = LTRIM$(STR$(lo~%))
  754.  IF hi~% > 1000 THEN hi$ = Special_K_Value(hi~%) ELSE hi$ = LTRIM$(STR$(hi~%))
  755.  Result$ = lo$ + "-" + hi$
  756.  Units_Attack = Result$
  757.  
  758. FUNCTION Units_Cost$ (unit%%)
  759.  Result~% = (Units(PX.Army(unit%%).Unit).Cost * PX.Army(unit%%).Count) \ 10
  760.  IF Result~% >= 10000 THEN Result$ = Special_K_Value(Result~%) ELSE Result$ = LTRIM$(STR$(Result~%))
  761.  Units_Cost = Result$
  762.  
  763. FUNCTION Special_K_Value$ (Value~%)
  764.  Result$ = LTRIM$(STR$(INT(Value~% \ 1000)))
  765.  Result$ = Result$ + "K"
  766.  Special_K_Value = Result$
  767.  
  768. SUB Build_Contract_Window
  769.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(8), Layer(1), (16, 63)-STEP(479, 383)
  770.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(2), Layer(1), (560, 0)-STEP(239, 191)
  771.  IF P.Current_Contract THEN
  772.   Contract_Animation 0
  773.   KB_Print 16, 175, "Name: " + Villains(P.Current_Contract).Villain, 0, LEFT
  774.   KB_Print 16, 191, "Alias: " + Villains(P.Current_Contract).Alias, 0, LEFT
  775.   KB_Print 16, 207, "Reward: " + Contract_Reward(Villains(P.Current_Contract).Bounty), 0, LEFT
  776.   KB_Print 16, 223, "Last Seen: " + Lands(Villains(P.Current_Contract).LastSeen), 0, LEFT
  777.   KB_Print 16, 239, "Castle: " + Castles(Villains(P.Current_Contract).Is_Known).The_Name, 0, LEFT
  778.   KB_Print 16, 255, "Distinguishing Features: ", 0, LEFT
  779.   y% = 272 'allows for different lenths of discriptions cause the routine changes the value
  780.   KB_Print_Wrap 48, y%, Villains(P.Current_Contract).Description, 432
  781.   KB_Print 16, y%, "Crimes: ", 0, LEFT
  782.  
  783.   KB_Print_Wrap 48, y%, "      " + Villains(P.Current_Contract).Crimes, 432
  784.  
  785.   KB_Print 79, 239, "You have no contract.", 0, LEFT
  786.  _PUTIMAGE , Layer(1), Layer(9)
  787.  DO
  788.   _PUTIMAGE , Layer(1), Layer(9)
  789.   Contract_Animation 0
  790.   _PUTIMAGE , Layer(1), Layer(0)
  791.   _DELAY .01
  792.  LOOP UNTIL _KEYHIT = Control.B_Button
  793.  
  794.  
  795. FUNCTION Contract_Reward$ (value~%)
  796.  temp$ = LTRIM$(STR$(value~%))
  797.  Result$ = LEFT$(temp$, LEN(temp$) - 3) + "," + RIGHT$(temp$, 3) + " Gold"
  798.  Contract_Reward = Result$
  799.  
  800. SUB Build_MiniMap_Window
  801.  _PUTIMAGE (90, 80)-STEP(319, 351), Layer(8), Layer(1), (90, 80)-STEP(319, 351)
  802.  _PUTIMAGE (90, 80)-STEP(319, 351), Layer(2), Layer(1), (304, 224)-STEP(159, 175)
  803.  KB_Print 90, 400, "X=   Position Y=", 0, LEFT
  804.  X%% = P.MapXPos / 48
  805.  Y%% = P.MapYpos / 40
  806.  IF X%% >= 0 THEN X$ = LTRIM$(STR$(X%%)) ELSE X$ = "**"
  807.  IF Y%% >= 0 THEN Y$ = LTRIM$(STR$(Y%%)) ELSE Y$ = "**"
  808.  KB_Print 122, 400, X$, 0, LEFT
  809.  KB_Print 378, 400, Y$, 0, RIGHT
  810.  KB_Print 240, 96, Lands(P.Current_Land), 0, CENTER
  811.  Draw_MiniMap_Terrain
  812.  Draw_Minimap_Objects
  813.  _PUTIMAGE , Layer(1), Layer(9)
  814.  DO
  815.   _PUTIMAGE , Layer(9), Layer(1)
  816.   Draw_Minimap_Player
  817.   _PUTIMAGE , Layer(1), Layer(0)
  818.   _DELAY .025
  819.  LOOP UNTIL _KEYHIT = Control.B_Button
  820.  
  821. SUB Draw_MiniMap_Terrain
  822.  _DEST Layer(1)
  823.  LINE (122, 128)-STEP(255, 255), _RGB32(0, 32, 128), BF
  824.  FOR y%% = 0 TO 63
  825.   FOR x%% = 0 TO 63
  826.    SELECT CASE Land(x%%, y%%).Terrain
  827.     CASE 0 'water
  828.     CASE 1 TO 4, 8, 9, 19, 20, 21, 27, 30, 36 'shore
  829.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(32, 96, 192), BF
  830.     CASE 10 'grass land
  831.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(32, 160, 0), BF
  832.     CASE 5, 6, 7, 11 TO 18, 28, 29 'mountain
  833.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(128, 64, 0), BF
  834.     CASE 22 TO 24, 31 TO 33 'castle
  835.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(224, 224, 224), BF
  836.     CASE 25, 26, 34, 35, 37 TO 45 'forest
  837.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(0, 96, 0), BF
  838.     CASE 46 TO 58 'desert
  839.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(224, 224, 0), BF
  840.    END SELECT
  841.   NEXT x%%
  842.  NEXT y%%
  843.  _DEST Layer(0)
  844.  
  845. SUB Draw_Minimap_Objects
  846.  'sign posts, towns, treasures, armys, dwellings, artifacts
  847.  FOR y%% = 0 TO 63
  848.   FOR x%% = 0 TO 63
  849.    test%% = Land(x%%, y%%).IsTreasure OR Land(x%%, y%%).IsArmy OR Land(x%%, y%%).IsArtifact OR Land(x%%, y%%).IsBand
  850.    test%% = test%% OR Land(x%%, y%%).IsTown OR Land(x%%, y%%).IsSign OR Land(x%%, y%%).IsBlock
  851.    IF test%% THEN
  852.     LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(224, 0, 0), BF
  853.    END IF
  854.   NEXT x%%
  855.  NEXT y%%
  856.  
  857. SUB Draw_Minimap_Player
  858.  _DEST Layer(1)
  859.  X%% = P.MapXPos / 48
  860.  Y%% = 63 - P.MapYpos / 40
  861.  f~%% = G.Window_Animation * 48
  862.  LINE (122 + X%% * 4, 128 + Y%% * 4)-STEP(3, 3), _RGB32(255 - f~%%, 255 - f~%%, 255 - f~%%), BF
  863.  _DEST Layer(0)
  864.  
  865. SUB Set_BackGround_Color
  866.  _DEST Layer(8)
  867.  LINE (0, 16)-(639, 448), BackGround_Color(G.Level), BF
  868.  _DEST Layer(0)
  869.  
  870. SUB Swap_Map (ID%%, Action%%)
  871.  FOR Y%% = 0 TO 63
  872.   FOR X%% = 0 TO 63
  873.    IF Action%% = SAVE THEN Maps(X%%, Y%%, ID%%).Terrain = Land(X%%, Y%%).Terrain
  874.    IF Action%% = LOAD THEN Land(X%%, Y%%) = Maps(X%%, Y%%, ID%%)
  875.   NEXT X%%
  876.  NEXT Y%%
  877.  
  878. SUB Build_Map_View
  879.  X%% = P.MapXPos / 48
  880.  Y%% = 63 - P.MapYpos / 40
  881.  sy%% = Y%% - 2
  882.  sx%% = X%% - 2
  883.  IF sy%% < 0 THEN sy%% = 0
  884.  IF sx%% < 0 THEN sx%% = 0
  885.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(13), Layer(1), (288 + 96 * sx%%, 224 + 80 * sy%%)-STEP(479, 383)
  886.  
  887. SUB Build_Map (ID%%)
  888.  _DEST Layer(ID%%)
  889.  LINE (0, 0)-(6720, 5600), _RGB32(4, 164, 164), BF
  890.  _DEST Layer(0)
  891.  FOR y%% = 0 TO 63
  892.   FOR x%% = 0 TO 63
  893.    ix%% = Land(x%%, y%%).Terrain MOD 13
  894.    IF Land(x%%, y%%).Terrain > 12 THEN iy%% = Land(x%%, y%%).Terrain \ 13 ELSE iy%% = 0
  895.    _PUTIMAGE (288 + x%% * 96, 240 + y%% * 80)-STEP(95, 79), Layer(3), Layer(ID%%), (0 + 48 * ix%%, 0 + 40 * iy%%)-STEP(47, 39)
  896.    Add_Map_Extras x%%, y%%
  897.   NEXT x%%
  898.  NEXT y%%
  899.  
  900. SUB Draw_Player
  901.  _PUTIMAGE (210, 224)-STEP(87, 63), Layer(5), Layer(1), (0 + G.Window_Animation * 44, 800 + P.Travel_Mode * 32)-STEP(43, 31)
  902.  
  903. SUB Place_Extras
  904.  FOR i%% = 1 TO 26
  905.   Maps(Towns(i%%).MapX, Towns(i%%).MapY, Towns(i%%).Land).IsTown = i%%
  906.  NEXT i%%
  907.  
  908. SUB Add_Map_Extras (X%%, Y%%)
  909.  IF Land(X%%, Y%%).IsTown THEN _PUTIMAGE (288 + X%% * 96, 240 + Y%% * 80)-STEP(95, 79), Layer(3), Layer(13), (480, 160)-STEP(47, 39)
  910.  IF Land(X%%, Y%%).IsSign THEN _PUTIMAGE (288 + X%% * 96, 240 + Y%% * 80)-STEP(95, 79), Layer(3), Layer(13), (432, 160)-STEP(47, 39)
  911.  IF Land(X%%, Y%%).IsBridge THEN _PUTIMAGE (288 + X%% * 96, 240 + Y%% * 80)-STEP(95, 79), Layer(3), Layer(13), (336 + Land(X%%, Y%%).IsBridge * 48, 160)-STEP(47, 39)
  912.  
  913. SUB Build_Spell_Window
  914.  
  915.  FOR i%% = 1 TO 7
  916.   IF Last_Cast = 0 AND PX.Spells(i%%) <> 0 THEN Last_Cast = i%%
  917.   ASPC%% = ASPC%% + PX.Spells(i%%)
  918.   CSPC%% = CSPC%% + PX.Spells(7 + i%%)
  919.  NEXT i%%
  920.  
  921.  _PUTIMAGE (90, 80)-STEP(319, 351), Layer(2), Layer(1), (304, 224)-STEP(159, 175)
  922.  _PUTIMAGE (100, 74)-STEP(299, 347), Layer(8), Layer(1), (0, 0)-STEP(299, 347)
  923.  KB_Print 90, 98, "Adventuring Spells", 0, LEFT
  924.  KB_Print 122, 276, "Combat Spells", 0, LEFT
  925.  FOR i%% = 1 TO 7
  926.   KB_Print 154, 114 + i%% * 16, LTRIM$(STR$(PX.Spells(i%%))), 0, RIGHT
  927.   KB_Print 170, 114 + i%% * 16, Spells(i%%).Spell_Name, 0, LEFT
  928.   KB_Print 154, 290 + i%% * 16, LTRIM$(STR$(PX.Spells(7 + i%%))), 0, RIGHT
  929.   KB_Print 170, 290 + i%% * 16, Spells(7 + i%%).Spell_Name, 0, LEFT
  930.  NEXT i%%
  931.  
  932.  IF G.In_Combat THEN
  933.   IF CSPC%% = 0 THEN
  934.    _PUTIMAGE (16, 29)-STEP(608, 17), Layer(8), Layer(1), (0, 16)-STEP(608, 17)
  935.    KB_Print 2, 31, "You have no Combat Spell to cast!", 0, LEFT
  936.   ELSE
  937.    Spell_Selection
  938.   END IF
  939.   IF ASPC%% = 0 THEN
  940.    _PUTIMAGE (16, 29)-STEP(608, 17), Layer(8), Layer(1), (0, 16)-STEP(608, 17)
  941.    KB_Print 2, 31, "You have no Adventuring Spell to cast!", 0, LEFT
  942.   ELSE
  943.    Spell_Selection
  944.   END IF
  945.  
  946. SUB Display_Selection_Arrow (X%, Y%)
  947.  _PUTIMAGE (X%, Y%)-STEP(23, 15), Layer(2), Layer(1), (388 + G.Window_Animation * 12, 216)-STEP(11, 7)
  948.  
  949. SUB Spell_Selection
  950.  STATIC Last_Combat AS _BYTE, Last_Adventure AS _BYTE
  951.  IF PX.Spells(Last_Combat) = 0 THEN Last_Combat = 0
  952.  IF PX.Spells(Last_Adventure) = 0 THEN Last_Adventure = 0
  953.  
  954.  FOR i%% = 1 TO 7
  955.   IF Last_Combat = 0 AND PX.Spells(7 + i%%) <> 0 THEN Last_Combat = 7 + i%%
  956.   IF Last_Adventure = 0 AND PX.Spells(i%%) <> 0 THEN Last_Adventure = i%%
  957.  NEXT i%%
  958.  _PUTIMAGE , Layer(1), Layer(9) 'save screen so we don't have to constantly recreate it.
  959.  
  960.  IF G.In_Combat THEN Selection%% = Last_Combat ELSE Selection%% = Last_Adventure
  961.  
  962.  DO
  963.   KBD& = _KEYHIT
  964.   SELECT CASE KBD&
  965.    CASE Control.Up_Key
  966.     good%% = FALSE
  967.     Selection%% = Selection%% - 1
  968.     DO
  969.      'find next available spell
  970.      IF G.In_Combat AND Selection%% = 7 THEN Selection%% = 14
  971.      IF NOT G.In_Combat AND Selection%% = 0 THEN Selection%% = 7
  972.      IF PX.Spells(Selection%%) THEN good%% = TRUE ELSE Selection%% = Selection%% - 1
  973.     LOOP UNTIL good%%
  974.    CASE Control.Down_Key
  975.     good%% = FALSE
  976.     Selection%% = Selection%% + 1
  977.     DO
  978.      'find next available spell
  979.      IF G.In_Combat AND Selection%% = 15 THEN Selection%% = 8
  980.      IF NOT G.In_Combat AND Selection%% = 8 THEN Selection%% = 1
  981.      IF PX.Spells(Selection%%) THEN good%% = TRUE ELSE Selection%% = Selection%% + 1
  982.     LOOP UNTIL good%%
  983.    CASE Control.A_Button
  984.     IF G.In_Combat THEN Last_Combat = Selection%% ELSE Last_Adventure = Selection%%
  985.     exitflag%% = TRUE
  986.     PX.Spells(Selection%%) = PX.Spells(Selection%%) - 1
  987.     Cast_Spells Selection%%
  988.    CASE Control.B_Button
  989.     exitflag%% = TRUE
  990.    CASE MASTERESC
  991.     exitflag%% = TRUE
  992.   _PUTIMAGE , Layer(9), Layer(1)
  993.   IF G.In_Combat THEN
  994.    Display_Selection_Arrow 112, 288 + (16 * (Selection%% - 7)) 'in combat
  995.   ELSE
  996.    Display_Selection_Arrow 112, 114 + (16 * Selection%%) 'adventuring
  997.   END IF
  998.   _PUTIMAGE , Layer(1), Layer(0)
  999.   LOCATE 1, 1: PRINT Selection%%
  1000.   _DELAY .025
  1001.  LOOP UNTIL exitflag%%
  1002.  
  1003. SUB Cast_Spells (Spell%%)
  1004.  SELECT CASE Spell%%
  1005.   CASE 1 'bridge spell
  1006.   CASE 2 'TimeStop Spell
  1007.    G.TimeStop = G.TimeStop + (10 * P.SpellPower)
  1008.   CASE 3 'Find Villain
  1009.    Villains(P.Current_Contract).Is_Known = Villains(P.Current_Contract).Castle
  1010.   CASE 4 'castle gate
  1011.    FOR i%% = 1 TO 26
  1012.     v%% = v%% + ABS(Castles(i%%).Visited) 'has player been to any castles?
  1013.    NEXT i%%
  1014.    IF v%% = 0 THEN G.HDR_Text = "  You have not been to any castles!": Window_Header
  1015.    IF v%% THEN Build_Gate_Window CASTLE
  1016.   CASE 5 'town gate
  1017.    FOR i%% = 1 TO 26
  1018.     v%% = v%% + ABS(Towns(i%%).Visited) 'has player been to any towns?
  1019.    NEXT i%%
  1020.    IF v%% = 0 THEN G.HDR_Text = "   You have not been to any towns!": Window_Header
  1021.    IF v%% THEN Build_Gate_Window TOWN
  1022.   CASE 6 'Instant Army
  1023.   CASE 7 'Raise control
  1024.    P.Control_Bonus = P.Control_Bonus + 100 * P.SpellPower
  1025.    IF P.Control_Bonus + P.Leadership > 65535 THEN P.Control_Bonus = 65535 - P.Leadership
  1026.  
  1027. SUB Build_Gate_Window (Spell%%)
  1028.  Build_Main_Window
  1029.  _PUTIMAGE (15, 63)-STEP(479, 383), Layer(2), Layer(1), (560, 0)-STEP(239, 191)
  1030.  IF Spell%% = TOWN THEN a$ = "Towns" ELSE a$ = "Castles"
  1031.  KB_Print 48, 96, a$ + " you have been to", 0, LEFT
  1032.  KB_Print 80, 384, "Revisit which " + a$, 0, LEFT
  1033.  FOR i%% = 1 TO 13
  1034.   IF Spell%% = TOWN AND Towns(i%%).Visited THEN
  1035.    KB_Print 48, 128 + i%% * 16, Towns(i%%).The_Name, 0, LEFT
  1036.    KB_Print 272, 128 + i%% * 16, Towns(13 + i%%).The_Name, 0, LEFT
  1037.   END IF
  1038.   IF Spell%% = CASTLE AND Castles(i%%).Visited THEN
  1039.    KB_Print 48, 128 + i%% * 16, Castles(i%%).The_Name, 0, LEFT
  1040.    KB_Print 272, 128 + i%% * 16, Castles(13 + i%%).The_Name, 0, LEFT
  1041.   END IF
  1042.  NEXT i%%
  1043.  
  1044. SUB Gate_Selection
  1045.  _PUTIMAGE , Layer(1), Layer(9) 'save screen so we don't have to constantly recreate it.
  1046.  
  1047.  IF G.In_Combat THEN Selection%% = Last_Combat ELSE Selection%% = Last_Adventure
  1048.  
  1049.  DO
  1050.   KBD& = _KEYHIT
  1051.   SELECT CASE KBD&
  1052.    CASE Control.Up_Key
  1053.     good%% = FALSE
  1054.     Selection%% = Selection%% - 1
  1055.     DO
  1056.      'find next available town or castle
  1057.      IF Selection%% < 1 THEN Selection%% = 26
  1058.      IF Towns(Selection%%).Visited THEN good%% = TRUE ELSE Selection%% = Selection%% + 1
  1059.     LOOP UNTIL good%%
  1060.    CASE Control.Down_Key
  1061.     good%% = FALSE
  1062.     Selection%% = Selection%% + 1
  1063.     DO
  1064.      'find next available town or castle
  1065.      IF Selection%% > 26 THEN Selection%% = 1
  1066.      IF Towns(Selection%%).Visited THEN good%% = TRUE ELSE Selection%% = Selection%% + 1
  1067.     LOOP UNTIL good%%
  1068.    CASE Control.A_Button
  1069.     exitflag%% = TRUE
  1070.    CASE Control.B_Button
  1071.     exitflag%% = TRUE
  1072.    CASE MASTERESC
  1073.     exitflag%% = TRUE
  1074.  
  1075.   _PUTIMAGE , Layer(9), Layer(1)
  1076.   IF Selection%% < 13 THEN x%% = 16: y%% = Selection%% ELSE x%% = 250: y%% = Selection%% - 13
  1077.   Display_Selection_Arrow x%%, 128 + (16 * y%%) 'adventuring
  1078.  
  1079.   _PUTIMAGE , Layer(1), Layer(0)
  1080.   _DELAY .025
  1081.  LOOP UNTIL exitflag%%
  1082.  
  1083. SUB Build_Puzzle_Window
  1084.  
  1085.  X%% = G.Scepter_X ' / 48
  1086.  Y%% = G.Scepter_Y ' / 40
  1087.  Land%% = 13 + G.Scepter_Land
  1088.  sy%% = Y%% - 2
  1089.  sx%% = X%% - 2
  1090.  IF sy%% < 0 THEN sy%% = 0
  1091.  IF sx%% < 0 THEN sx%% = 0
  1092.  _PUTIMAGE (16, 64)-STEP(479, 383), Layer(13), Layer(1), (288 + 96 * sx%%, 224 + 80 * sy%%)-STEP(479, 383)
  1093.  
  1094.  _PUTIMAGE (16, 63)-STEP(239, 383), Layer(2), Layer(1), (0, 416)-STEP(119, 191)
  1095.  _PUTIMAGE (494, 63)-STEP(-239, 383), Layer(2), Layer(1), (0, 416)-STEP(119, 191)
  1096.  _PUTIMAGE , Layer(1), Layer(9)
  1097.  xo% = 36: yo% = 95
  1098.  DO
  1099.   _PUTIMAGE , Layer(9), Layer(1)
  1100.   FOR Y%% = 0 TO 4
  1101.    FOR X%% = 0 TO 4
  1102.     IF Puzzle(X%%, Y%%) > 16 THEN
  1103.      y% = 32 * (Puzzle(X%%, Y%%) - 17)
  1104.      IF NOT Villains(Puzzle(X%%, Y%%) - 17).Caught THEN
  1105.       _PUTIMAGE (xo% + X%% * 88, yo% + Y%% * 64)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 0 + y%)-STEP(43, 31) 'magic power frames
  1106.      END IF
  1107.     ELSE
  1108.      IF Puzzle(X%%, Y%%) >= 4 THEN y% = 32 * 20: XA%% = Puzzle(X%%, Y%%) - 4 ELSE y% = 32 * 19: XA%% = Puzzle(X%%, Y%%)
  1109.      IF (P.Artifacts_Aquired AND 2 ^ Puzzle(X%%, Y%%)) = FALSE THEN
  1110.       _PUTIMAGE (xo% + X%% * 88, yo% + Y%% * 64)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * XA%%), 0 + y%)-STEP(43, 31) 'magic power frames
  1111.      END IF
  1112.     END IF
  1113.    NEXT X%%
  1114.   NEXT Y%%
  1115.   _PUTIMAGE , Layer(1), Layer(0)
  1116.   _DELAY .025
  1117.  
  1118.  LOOP UNTIL _KEYHIT = Control.B_Button
  1119.  
  1120. SUB Hide_Scepter (Land%%)
  1121.  good%% = FALSE
  1122.  DO
  1123.   x%% = INT(RND * 59) + 3
  1124.   y%% = INT(RND * 59) + 3
  1125.   IF Maps(x%%, y%%, Land%%).Terrain = 10 THEN good%% = TRUE
  1126.  LOOP UNTIL good%%
  1127.  G.Scepter_X = x%%
  1128.  G.Scepter_Y = y%%
  1129.  Maps(x%%, y%%, Land%%).IsScepter = TRUE
  1130.  
  1131. SUB Load_Data
  1132.  '-----------------Data loader--------------------
  1133.  RESTORE SignData
  1134.  FOR i%% = 1 TO 70
  1135.   READ Sign(i%%).SignText
  1136.   READ Sign(i%%).MapXLoc
  1137.   READ Sign(i%%).MapYLoc
  1138.   READ Sign(i%%).Land
  1139.  NEXT i%%
  1140.  
  1141.  RESTORE MapTerrain
  1142.  READ Map1$
  1143.  Map01% = DecodeMaps(Map1$)
  1144.  Swap_Map CONTINENTIA, SAVE
  1145.  READ Map1$
  1146.  Map02% = DecodeMaps(Map1$)
  1147.  Swap_Map FORESTRIA, SAVE
  1148.  
  1149.  RESTORE Lands
  1150.  FOR i%% = 1 TO 4
  1151.   READ Lands(i%%)
  1152.  NEXT i%%
  1153.  
  1154.  RESTORE Names
  1155.  FOR i%% = 0 TO 3
  1156.   READ Names(i%%)
  1157.  NEXT i%%
  1158.  RESTORE Titles
  1159.  FOR i%% = 0 TO 3
  1160.   FOR j%% = 0 TO 3
  1161.    READ Title(i%%, j%%)
  1162.   NEXT j%%
  1163.  NEXT i%%
  1164.  RESTORE Advancement
  1165.  FOR i%% = 0 TO 3
  1166.   FOR j%% = 0 TO 3
  1167.    READ Stats(i%%, j%%).Leadership
  1168.    READ Stats(i%%, j%%).MaxSpells
  1169.    READ Stats(i%%, j%%).SpellPower
  1170.    READ Stats(i%%, j%%).Commission
  1171.    READ Stats(i%%, j%%).Gold
  1172.   NEXT j%%
  1173.  NEXT i%%
  1174.  RESTORE Units
  1175.  FOR i%% = 1 TO 25
  1176.   READ Units(i%%).Unit_Name
  1177.   READ Units(i%%).HitPts
  1178.   READ Units(i%%).AttackLo
  1179.   READ Units(i%%).AttackHi
  1180.   READ Units(i%%).Shoot
  1181.   READ Units(i%%).Skill_Level
  1182.   READ Units(i%%).Movement
  1183.   READ Units(i%%).Cost
  1184.   READ Units(i%%).Shoot
  1185.   READ Units(i%%).Grouping
  1186.   READ Units(i%%).ShootLo
  1187.   READ Units(i%%).ShootHi
  1188.  NEXT i%%
  1189.  RESTORE Contract_Data
  1190.  FOR i%% = 1 TO 17
  1191.   READ Villains(i%%).Villain
  1192.   READ Villains(i%%).Alias
  1193.   READ Villains(i%%).Bounty
  1194.   READ Villains(i%%).LastSeen
  1195.   READ Villains(i%%).Description
  1196.   READ Villains(i%%).Crimes
  1197.   Villains(i%%).Is_Known = FALSE
  1198.  NEXT i%%
  1199.  RESTORE CastleData
  1200.  FOR i%% = 1 TO 26
  1201.   READ Castles(i%%).The_Name
  1202.   READ Castles(i%%).GateX
  1203.   READ Castles(i%%).GateY
  1204.   READ Castles(i%%).Land
  1205.   READ Castles(i%%).MapX
  1206.   READ Castles(i%%).MapY
  1207.   Castles(i%%).MapY = 63 - Castles(i%%).MapY 'correct Y value for bottom start
  1208.  NEXT i%%
  1209.  Castles(0).The_Name = "Unknown"
  1210.  RESTORE TownData
  1211.  FOR i%% = 1 TO 26
  1212.   READ Towns(i%%).The_Name
  1213.   READ Towns(i%%).Unit
  1214.   READ Towns(i%%).Spell
  1215.   READ Towns(i%%).Castle
  1216.   READ Towns(i%%).GateX
  1217.   READ Towns(i%%).GateY
  1218.   READ Towns(i%%).Land
  1219.   READ Towns(i%%).MapX
  1220.   READ Towns(i%%).MapY
  1221.   Towns(i%%).MapY = 63 - Towns(i%%).MapY 'correct Y value for bottom start
  1222.  NEXT i%%
  1223.  RESTORE BackgroundColors
  1224.  FOR i%% = 1 TO 4
  1225.   READ BackGround_Color(i%%)
  1226.  NEXT i%%
  1227.  RESTORE SpellData
  1228.  FOR i%% = 1 TO 14
  1229.   READ Spells(i%%).Spell_Name
  1230.   READ Spells(i%%).Cost
  1231.  NEXT i%%
  1232.  RESTORE PuzzleData
  1233.  FOR y%% = 0 TO 4
  1234.   FOR x%% = 0 TO 4
  1235.    READ Puzzle(x%%, y%%)
  1236.   NEXT x%%
  1237.  NEXT y%%
  1238.  '------------------------------------------------
  1239.  
  1240. SUB Build_Menu_Window
  1241.  STATIC Last_Choice AS _BYTE
  1242.  G.In_Menu = TRUE
  1243.  '304,472  208,128
  1244.  _PUTIMAGE (48, 127)-STEP(415, 255), Layer(8), Layer(1), (48, 160)-STEP(415, 255)
  1245.  _PUTIMAGE (48, 127)-STEP(415, 255), Layer(2), Layer(1), (304, 472)-STEP(207, 127)
  1246.  _PUTIMAGE , Layer(1), Layer(9)
  1247.  Selection%% = Last_Choice
  1248.  IF Selection%% = 0 THEN Selection%% = 1
  1249.  DO
  1250.   KBD& = _KEYHIT
  1251.   SELECT CASE KBD&
  1252.    CASE Control.Up_Key
  1253.     Selection%% = Selection%% - 1
  1254.     IF Selection%% <= 0 THEN Selection%% = 12 'correction for the gap in choices
  1255.     IF Selection%% = 11 THEN Selection%% = 10 'correction for the gap in choices
  1256.    CASE Control.Down_Key
  1257.     Selection%% = Selection%% + 1
  1258.     IF Selection%% >= 13 THEN Selection%% = 1
  1259.    CASE Control.A_Button
  1260.     Last_Choice = Selection%%
  1261.     RunIt%% = TRUE
  1262.     exitflag%% = TRUE
  1263.    CASE Control.B_Button
  1264.     exitflag%% = TRUE
  1265.    CASE MASTERESC
  1266.     exitflag%% = TRUE
  1267.   _PUTIMAGE , Layer(9), Layer(1)
  1268.   IF Selection%% = 11 THEN Selection%% = 12 'correction for the gap in choices
  1269.   Display_Selection_Arrow 69, 140 + (16 * Selection%%) 'adventuring
  1270.   _PUTIMAGE , Layer(1), Layer(0)
  1271.   LOCATE 1, 1: PRINT Selection%%
  1272.   _DELAY .025
  1273.  LOOP UNTIL exitflag%%
  1274.  IF RunIt%% THEN Run_Menu_Choice Selection%%
  1275.  
  1276. SUB Run_Menu_Choice (Opt%%)
  1277.  Build_Main_Window
  1278.  Build_Map_View
  1279.  Draw_Player
  1280.  SELECT CASE Opt%%
  1281.   CASE 1 'view army
  1282.    Build_Army_Window
  1283.   CASE 2 'view stats
  1284.    Build_Stat_Window
  1285.   CASE 3 'view mini map
  1286.    Build_MiniMap_Window
  1287.   CASE 4 'use spells
  1288.    Build_Spell_Window
  1289.   CASE 5 'view contract info
  1290.    Build_Contract_Window
  1291.   CASE 6 'wait till end of week
  1292.   CASE 7 'look at puzzle
  1293.    Build_Puzzle_Window
  1294.   CASE 8 'search area
  1295.   CASE 9 'dismiss army
  1296.   CASE 10 'game options
  1297.   CASE 12 'save game
  1298.  G.In_Menu = TRUE
  1299.  
  1300. SUB Build_Dismiss_Window
  1301.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(8), Layer(1), (16, 300)-STEP(479, 147)
  1302.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(2), Layer(1), (320, 0)-STEP(239, 73)
  1303.  KB_Print 80, 316, "Dismiss which army?", 0, LEFT
  1304.  _PUTIMAGE , Layer(1), Layer(9)
  1305.  Selection%% = 0
  1306.  DO
  1307.   KBD& = _KEYHIT
  1308.   SELECT CASE KBD&
  1309.    CASE Control.Up_Key
  1310.     Selection%% = Selection%% - 1
  1311.     IF Selection%% <= -1 THEN Selection%% = 0
  1312.    CASE Control.Down_Key
  1313.     Selection%% = Selection%% + 1
  1314.     IF Selection%% >= 4 THEN Selection%% = Selection%% - 1
  1315.     IF PX.Army(Selection%%).Unit = 0 THEN Selection%% = Selection%% - 1
  1316.    CASE Control.A_Button
  1317.     IF Selection%% = 0 THEN 'check and make sure player has more than one army
  1318.      IF PX.Army(1).Unit = 0 THEN 'player is trying to dismiss last army
  1319.       _PUTIMAGE , Layer(9), Layer(1)
  1320.       _PUTIMAGE (16, 31)-STEP(606, 15), Layer(8), Layer(1), (16, 31)-STEP(606, 15)
  1321.       KB_Print 2, 31, "  You man not dismiss your last army!", 0, LEFT
  1322.       _PUTIMAGE , Layer(1), Layer(9)
  1323.      ELSE
  1324.       Dismiss_Army Selection%%
  1325.      END IF
  1326.     ELSE 'if player isn't dismissing army 0 then they have more than one.
  1327.      Dismiss_Army Selection%%
  1328.      Selection%% = Selection%% - 1 'bump the arrow up one space
  1329.     END IF
  1330.    CASE Control.B_Button
  1331.     exitflag%% = TRUE
  1332.    CASE MASTERESC
  1333.     exitflag%% = TRUE
  1334.   _PUTIMAGE , Layer(9), Layer(1)
  1335.   FOR i%% = 0 TO 4
  1336.    IF PX.Army(i%%).Unit THEN KB_Print 272, 348 + i%% * 16, Units(PX.Army(i%%).Unit).Unit_Name, 0, CENTER
  1337.   NEXT i%%
  1338.   Display_Selection_Arrow 164, 346 + (16 * Selection%%)
  1339.   _PUTIMAGE , Layer(1), Layer(0)
  1340.  LOOP UNTIL exitflag%%
  1341.  
  1342. SUB Dismiss_Army (Unit%%)
  1343.  FOR i%% = Unit%% TO 3
  1344.   SWAP PX.Army(i%%), PX.Army(i%% + 1)
  1345.  NEXT i%%
  1346.  PX.Army(i%%).Unit = 0
  1347.  PX.Army(i%%).Count = 0
  1348.  
  1349.  
  1350.  
  1351. SUB DumpMap
  1352.  OPEN "debug.txt" FOR OUTPUT AS #1
  1353.  FOR y%% = 0 TO 63
  1354.   FOR x%% = 0 TO 63
  1355.    PRINT #1, Maps(x%%, y%%, 1).Terrain;
  1356.   NEXT x%%
  1357.   PRINT #1,
  1358.  NEXT y%%
  1359. '$include:'MapDecode.bi'
  1360. '$include: 'saveimage.bm'
  1361.  
  1362.  

there is the source, with the 3 include files down below and the zlib.dll.(the 2 saveimage files are from Steve's image saving code and they require the dll)

can somebody else load this code and see if there is any lag when trying to navigate the code. It usually takes some coding before it starts to happen, so you may need to add some 'stuff' to the bottom to cause it to start or navigate the code a few times. haven't isolated just when it 'starts' to happen yet. I just start noticing that it slows down while scrolling the longer lines of code and speeding up in areas with shorter lines.

Restarting the IDE seems to reset what ever is slowing down, for a bit anyway.

Going to try and see if I can figure out just what I have to consistently do to get it to slowdown.
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Program Source code causing lag in the QB64 IDE
« Reply #1 on: January 29, 2019, 12:48:36 am »
Slow IDE when editing towards the end of a long source file is a known issue.

Heads up: unrelated to syntax highlighting, as previously believed (by me at least).

Likely related to the way the IDE keeps it all in a single string in memory.

Possible solution: not agreed upon yet.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Program Source code causing lag in the QB64 IDE
« Reply #2 on: January 29, 2019, 01:06:35 am »
That's only 1400+ lines of code. I've put 80,000+ in previous IDE versions with some lag, but not overly annoying. I've been working on programs with 2,000 to 3,000 lines of code quite recently, with no lag.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Program Source code causing lag in the QB64 IDE
« Reply #3 on: January 29, 2019, 10:48:30 am »
That's only 1400+ lines of code. I've put 80,000+ in previous IDE versions with some lag, but not overly annoying. I've been working on programs with 2,000 to 3,000 lines of code quite recently, with no lag.

Pete

Yeah the QB64.bas is a lot more lines too, and a lot larger to boot. even my Tetris clone was bigger. seems to be the more DATA lines I add the faster it starts to slow down and the worse it gets.  Just makes me kinda feel like the problem might be the way DATA lines are handled.(I imagine that has already been looked into though) Been having issues with the IDE ever since I added the two encoded map data lines, 3200+, and 3600+  character data strings, and the more I add it seems to compound the issue but it may just be coincidence.  eventually all the data will be stored in a file package, probably with the images. which will dump several hundred lines of code out of the program, since I wont need all the READ lines. I can just GET it right into the arrays at that point. Keeping the DATA lines until I know for sure I wont need to adjust them anymore.
I have 2 more maps to encode and add as data, will see what happen then.

I know I can always resort to solely using my goto text\hex editor for the main bulk, But I kind of like using the IDE some times.
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Program Source code causing lag in the QB64 IDE
« Reply #4 on: January 30, 2019, 10:46:59 am »
In my experience, sometimes the IDE will get a bit faster if the added DATA lines have a smaller length (for example, only 300 characters per row)