Author Topic: A Demo with a problem  (Read 3453 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
A Demo with a problem
« on: February 10, 2019, 08:27:10 pm »
Thought I would let you guys have a look at my current project, not quite as far along as I wanted before posting a demo but I have found myself with an issue I can't nail down. there is a section of text that prints fine the first time the routine is run but then it vanishes the next time. This code will probably be beyond most though I think I've done a fair job of using descriptive variables and routine names. the problem seems to be somewhere in the Build_Contract_Window and KB_Print_wrap routines. as part of the villain contract information suddenly stops printing after its been printed once, but the rest still prints correctly.

Code: QB64: [Select]
  1. TYPE MapSquare
  2.  Terrain AS _BYTE '     tile id
  3.  Playerseen AS _BYTE '  has player seen area?(for minimap)
  4.  IsScepter AS _BYTE '   Scepters hiding place?
  5.  IsTreasure AS _BYTE '  is there treasure on map square?
  6.  IsArmy AS _BYTE '      is there an army on map square?(fight)
  7.  IsArtifact AS _BYTE '  is there an artifact on map square?
  8.  IsBand AS _BYTE '      is there a roaming band of creatures on map square?(hire)
  9.  IsPlayer AS _BYTE '    is the player on map square?
  10.  IsBoat AS _BYTE '      is the boat located on map square?
  11.  IsTown AS _BYTE '      is there a town on map square? value indicates which town
  12.  IsCastle AS _BYTE '    is there a castle on map square(entrance)? value indicates which castle
  13.  IsSign AS _BYTE '      is there a road sign on map square? value indicates which sign data
  14.  IsDwelling AS _BYTE '  which type 1-plains, 2-forest, 3-hills, 4-dungeons
  15.  IsBridge AS _BYTE '    has player used Bridge spell? which direction 1-horz 2-vert
  16.  IsBlock AS _BYTE '     does this square block armies? (3 blocks around Maximus castle)
  17.  Units AS _BYTE '       which type of unit 1-25 (peasants to dragons for to join)
  18.  Population AS INTEGER 'how many left to hire
  19.  Start_Population AS INTEGER
  20.  
  21. TYPE Cords
  22.  Xloc AS _BYTE
  23.  Yloc AS _BYTE
  24.  Land AS _BYTE
  25.  
  26. TYPE Player_Data
  27.  Class AS _BYTE
  28.  Promotion AS _BYTE
  29.  Leadership AS _UNSIGNED INTEGER '  affects maximum number of units player can control
  30.  Control_Bonus AS _UNSIGNED INTEGER 'the Raise control spell affects this value
  31.  Commission AS INTEGER '            castles add 250
  32.  Gold AS LONG '
  33.  SpellPower AS _BYTE '              power of cast spells
  34.  MaxSpells AS _BYTE '               total # of spells player can purchase(finding in chests can go beyond)
  35.  VilliansCaught AS _BYTE '
  36.  Artifacts AS _BYTE '               number of artifacts found 250*difficulty
  37.  Castles AS _BYTE '                 number of castle garrisoned 500*difficulty
  38.  Deaths AS _UNSIGNED INTEGER '      followers killed, reduces score
  39.  Score AS _UNSIGNED INTEGER '       sum of artifacts found+villians caught- followers killed
  40.  Maps_Aquired AS _BYTE '            maps to travel to other lands
  41.  Maps_Full AS _BYTE '               has player found map orb showing all map area
  42.  Artifacts_Aquired AS _UNSIGNED _BYTE
  43.  Puzzle_Peices AS LONG '            Which peices have been uncovered
  44.  Magic_Learned AS _BYTE '           Does player have magic ability yet?
  45.  Seige_Bought AS _BYTE '            Has player purchased seige weapons yet?
  46.  Current_Contract AS _BYTE '        Who is the player looking for?
  47.  MapXPos AS INTEGER '               Players X Pixel location on map
  48.  MapYpos AS INTEGER '               Players Y Pixel location on map
  49.  Current_Land AS _BYTE '            Which land is player exploring?
  50.  Travel_Mode AS _BYTE '             Player on land, water, or air(horse, boat, dragon)
  51.  Has_Boat AS _BYTE '                has player leased a Boat?
  52.  Moving AS _BYTE '                   is player moving or standing?
  53.  Facing AS _BYTE '                  Last way player was moving Left or Right
  54.  Last_Seen_Boat AS Cords '          Where the player left the boat X,Y,Land
  55.  
  56. TYPE GameData
  57.  Days AS INTEGER
  58.  TimeStop AS _UNSIGNED INTEGER
  59.  GameTimer AS LONG
  60.  Level AS _BYTE
  61.  Window_Animation AS _BYTE
  62.  In_Combat AS _BYTE '         Is the player in combat? stops time
  63.  In_Menu AS _BYTE '           Does player have menu up? stops time
  64.  Last_Cast AS _BYTE '         last spell cast by player
  65.  HDR_Text AS STRING * 38 '    text for window header
  66.  Scepter_X AS _BYTE '         Scepters X location
  67.  Scepter_Y AS _BYTE '         Scepters Y location
  68.  Scepter_Land AS _BYTE '      Which Land the Scepter is in.
  69.  QuitGame AS _BYTE '          master quit flag
  70.  WinGame AS _BYTE '           set when player finds scepter
  71.  BGM AS _BYTE '               BackGound music ON\OFF
  72.  SFX AS _BYTE '               Sound FX ON\OFF
  73.  Combat_speed AS _BYTE '      Combat speed 0-9(fast - slow)
  74.  BGM_VOL AS _BYTE
  75.  SFX_VOL AS _BYTE
  76.  
  77. TYPE StatData
  78.  Leadership AS INTEGER
  79.  Commission AS INTEGER
  80.  SpellPower AS _BYTE
  81.  MaxSpells AS _BYTE
  82.  
  83. TYPE Standing_Army
  84.  Unit AS _BYTE
  85.  
  86. TYPE Unit_Data
  87.  Unit_Name AS STRING * 12 '
  88.  HitPts AS _UNSIGNED _BYTE '
  89.  AttackLo AS _BYTE '         Lower end damage
  90.  AttackHi AS _BYTE '         Higher end damage
  91.  Shoot AS _BYTE '            Does the creature have ranged attacks?(1{arrows},2{fireball},3{lightning},4{boulders})
  92.  ShootLo AS _BYTE '          Lower end damage
  93.  ShootHi AS _BYTE '          upper end damage
  94.  Movement AS _BYTE '         How many spaces may creature move in one turn?(1,2,3,4,99{fly})
  95.  Cost AS INTEGER '           How much to hire
  96.  ShotCount AS _BYTE '        How many times can creature use its ranged attacks?
  97.  Grouping AS _BYTE '         Morale grouping value(1,2,3,4,5)
  98.  Skill_Level AS _BYTE '      Skill Level determines damage ratio
  99.  
  100. TYPE ContractData
  101.  Villain AS STRING * 24 '      Villains name
  102.  Alias AS STRING * 24 '        Villains Alias if one
  103.  Bounty AS _UNSIGNED INTEGER ' How Much Villan is worth
  104.  LastSeen AS _BYTE '           Continent villain was last seen on
  105.  Castle AS _BYTE '             Castle Villain is held up in
  106.  Is_Known AS _BYTE '           Triggered if player knows which castle villain is located
  107.  Description AS STRING * 130
  108.  Crimes AS STRING * 146
  109.  Caught AS _BYTE
  110.  
  111. TYPE TownData
  112.  The_Name AS STRING * 12
  113.  Unit AS _BYTE ' displays which Unit type
  114.  Spell AS _BYTE ' Selling which spell
  115.  Castle AS _BYTE 'Has Information on which castle
  116.  GateX AS _BYTE ' where player locates with Town Gate spell
  117.  GateY AS _BYTE ' where player locates with Town Gate spell
  118.  Land AS _BYTE '  used with gate spell
  119.  MapX AS _BYTE '  where in map X
  120.  MapY AS _BYTE '  where in map Y
  121.  Visited AS _BYTE 'has player been here?
  122.  BoatX AS _BYTE ' where the boat shows when rented
  123.  BoatY AS _BYTE ' where the boat shows when rented
  124.  
  125. TYPE CastleData
  126.  The_Name AS STRING * 12
  127.  GateX AS _BYTE ' where player locates with castle Gate spell
  128.  GateY AS _BYTE ' where player locates with castle Gate spell
  129.  Land AS _BYTE '  used with gate spell
  130.  MapX AS _BYTE '  where in map X
  131.  MapY AS _BYTE '  where in map Y
  132.  Visited AS _BYTE 'has player been here?
  133.  Owner AS _BYTE ' who occupies this castle?
  134.  
  135. TYPE Spell_Data
  136.  Spell_Name AS STRING * 14
  137.  Cost AS INTEGER
  138.  
  139. TYPE Control_Keys
  140.  Up_Key AS LONG
  141.  Down_Key AS LONG
  142.  Left_Key AS LONG
  143.  Right_Key AS LONG
  144.  A_Button AS LONG
  145.  B_Button AS LONG
  146.  C_Button AS LONG
  147.  Start_Button AS LONG
  148.  
  149. TYPE Signs
  150.  SignText AS STRING * 64 'What the sign says.
  151.  MapXLoc AS _BYTE
  152.  MapYLoc AS _BYTE
  153.  Land AS _BYTE '
  154.  
  155. SCREEN _NEWIMAGE(640, 480, 32)
  156.  
  157. CONST TRUE = -1, FALSE = NOT TRUE, LEFT = 0, RIGHT = 1, CENTER = 2
  158. CONST KNIGHT = 0, PALADIN = 1, SORCERESS = 2, BARBARIAN = 3
  159. CONST EASY = 1, NORM = 2, HARD = 3, IMPOSSIBLE = 4
  160. CONST MAIN = 1, SAVE = 2, LOAD = 4, HORZ = 1, VERT = 2
  161. CONST CONTINENTIA = 1, FORESTRIA = 2, ARCHIPELIA = 3, SAHARIA = 4
  162. CONST MASTERESC = 27, TOWN = 5, CASTLE = 6, RIGHT_FACE = 1, LEFT_FACE = 2
  163. CONST HORSE = 1, BOAT = 2, DRAGON = 3
  164.  
  165. DIM SHARED Maps(-1 TO 65, -1 TO 65, 4) AS MapSquare 'all 4 land maps terrain data
  166. DIM SHARED Land(-3 TO 68, -3 TO 68) AS MapSquare 'current land map data
  167. DIM SHARED Layer(16) AS LONG, P AS Player_Data, G AS GameData
  168. DIM SHARED Title(3, 3) AS STRING, Names(3) AS STRING, PX.Army(5) AS Standing_Army
  169. DIM SHARED PX.Spells(16) AS _BYTE, Control AS Control_Keys, CX.Army(5) AS Standing_Army
  170. DIM SHARED Stats(3, 3) AS StatData, Units(25) AS Unit_Data, Villains(17) AS ContractData
  171. DIM SHARED Lands(4) AS STRING, Castles(27) AS CastleData, Towns(27) AS TownData
  172. DIM SHARED BackGround_Color(4) AS _UNSIGNED LONG, Spells(16) AS Spell_Data
  173. DIM SHARED Puzzle(4, 4) AS _BYTE, Sign(70) AS Signs
  174. DIM SHARED GFX_Size(64) AS LONG, GFX_FOffset&(64)
  175.  
  176. G.GameTimer = _FREETIMER
  177. ON TIMER(G.GameTimer, .125) ClockTick
  178.  
  179. Build_Layers
  180.  
  181. MapTerrain:
  182. 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 #¨"
  183. 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 #ê"
  184. DATA " #æ$ %(& #0$ %(& ##$ %)& #,$%,-()* -$+& #,$%%, -(+ %#,(* -$9:;+ %#& #(' -#412* -$> #,' -$( )#* -&(3?-(*-BCD()*-> #(' -$412* -#> #,A8 -#40012)*()*-405-.? -#(3/5-> #'$,-(*--.@? -#> #-A 7%84005405 -%.2)*-./5--> #''--.2))3/5-67G #3A 7(8 -#4005-45--6G #'A784 0$567G #>A 7%8 -%6G #*A 7&G #FA 7%G #n$ %&& #0$ %(& #:$ %#, -&+& #,$%%,< H&=+ %&& #3' -%(* -$+& #*$,<HHO P&L H&=+ %$& #.A8 -#(32))*--+& #'$%,<OM N$IPM N'IL H$=+ %$& #)$,--(3/ 0#5-<=> #''<HOMF())*KMF -'EI P$L H$=+%& #''--(3/59:;--KJ> #''ENNF-401?KJ--6 7#8--EIM N%IPLH=> #''--./5-BCD--EF> #'A8 -&.?KJ-->$%&' -#KJ( )#*K P#J> #'A8-.? -'67G #('<HH=()3?KJ--+,-+,--<OJ./01?KPPMF> #('-45-68 -#6G #*'KPPJ4005KL= -(KPJ.?-.?KPPJ6G #(' -$+,--6G #+'ENIL H$OPL H&=-KPJ45-45KPPJ+& #('-<= -%> #,A78KPPMNNIPM N&F-KPLH=--<OPPL=> #'$,-KLHH=-6G #.'ENNF--KPJ( )%*-ENNIJ--E N$F> #''--KMNNF6G #/' -&KMF./ 0#1? -$KJ -(> #''--EF--6G #0'< H%OJ(3?9:;.2*<=-KL H'=> #'' -&+%%& #.'E N%IJ.@?BCD.@?KJ-E N%IPPJ> #''--<= -%+& #-' -&KJ412*-(3/5KJ -'KPMF> #'A8-KLH= -$> #,$,< H#=-KL=405-405<OL H%=-KMF6G #('-ENNF-<=-+& #+'<O P#J-EILHH=-<HHO P'J-EF6G #)' -&KLH=+& #*'KPPMNF--EIPPJ-E N(IPJ-67G #)$,--<=--ENIJ-> #($%,KPPJ(*-(*KPPJ -*KPJ6G #*$,<=-EF -$EF6G #'$,<HOPPJ.?-.?KPPL H(=-KPJ+& #*'-EF -$(* -#> #'$,-E N#IJ.2)3?KPM N&IPPJ-KPL=+& #)' -&(3?--6G #'' -&KJ4 0#5ENF--9:;-ENIJ-KPPL=+%%& #&' -#())3/567G #'$,<HH=--KL= -)BCD -#KJ-K P$HH=+& #%A8--4 0#56G #)'<OPPLHHOPJ-< H$= -&<HOJ-KMNNIPPL=> #&A 7'G #*'K P#M N$F-KPMNIL H&OPPJ-KJ--E N#F> #9'KMNIJ( )#*-KPJ-E N*F-KJ -'> #8$,EF-KJ./01?-EIJ -.KJ--<HH=6G #8' -$KJ45-45--KJ--<H=-< H'OLHHOMNF> #9'<H=-KL=--<H=-KL=-KPJ-K P*MNF67G #+$ %#& #)'EILHOPJ--EIJ-KPLHOPJ-K P*J67G #,$,9:;+%& #'A8ENIPPL=--KJ-KPM N#F-ENI P#M N$F> #,$%,-BCD--+%& #&A78ENIPL=-EF-ENF6 7%8EIPMF6 7$G #+$, -'68-+& #'A78ENNF6 7&G #%A8ENF6G #0'(* -#68-+,--> #)A 7$G #-A 7#G #1'4568-+, -%+& #QA8->' -$<H=--> #R'-+,-<HHOPL=-+& #QA8 -#KPPMNNF--> #5$ %#& #8' -#KPPJ -%+& #1$%%, -#+%%& #5A8--ENILHH= -#+& #/$,<= -%<=+%& #4A8 -#ENNIJ -$+%%& #+$,<OLH=-<HOLH=+%& #3A8 -%KLHH= -$+ %+,<OMNNF-E N#IJ--> #4A 7#8-ENNIL= -0ENF -%9:;KL=-+& #7A 7#8ENF -#< H#=--())* -&()*-BCDEIL=-+%& #9A 7%8ENIPL=-4012)*--()3/5 -%ENF-(*> #?A78ENNF -#4005--4005 -#68 -%45> #AA 7(8 -)67GA 7'G #JA 7)G #ó"
  185. DATA " #£$ %'& #E$ %+& #%' -'+%& #>$ %$, -++& #$'-<=QR -$+ %&& #,$ %&&$%%, -(Q U%R--> #$'-EF]XUR -)+ %&&##$%%, -&+, -$Q U&V W%XR-> #$'-QUVWWX U'R -(+%%, -$QUUR -$<=QV W+YZT-> #$'-] W,X U$R<= -&QUUVWWX U#REF] W&YZ[ W#\<=-> #$'-] W#Y Z&[ W&\EFQ U%V W)XUUV W&XRS[WW\EF-> #$'-S[WW\< H$=] W&XUUV W:XR]WWXR--> #$'--S[W\KMNNIJ]WWY Z%[ W(Y Z$[ W.XV W#\--> #$A8--]W\KJ--KJ]WW\( )#*S Z%[WW\())*]WY Z%[ W)YZT-6G #%A8-]W\KLHHOJ]WW\401@2))* -#SZZT401?]W\( )#*S[ W(\ -#> #''-]W\E N$F]WWXUR401@@? -#()* -#.?]YT40012*SZ[ W&\-67G #''-]WX U$R-S Z$T--4012 )#3/5--(3?ST -$./5--S Z#[WW\-+& #('-] W%YT-( )%* -#41/ 0#5 -#.@2* -%.?--( )#*]WW\--+& #''-] W%\()3/ 0#1? -$.? -'41/5 -$(32))3/01?]WW\ -#> #''-] W%\4005-68.?--68.? -#(* -#.?6778-. @%?-45]WW\<=-> #''-]WWYZZT -%+,.?--+,.? -#.? -#.?+%%,-./ 0#1?--QVWW\EF-+& #%$,-]WW\())* -%(32 )$32 )#32 )#32 )%3?9:;.?--] W#XUR--> #%'--]WW\41@2* -$./ 061?BCD.2)*] W%XR-> #%'-QVWWXR41@2 )$3? -6.? -#401?] W&\-> #$$,-] W$XR41/ 0$1?-( )**-( )%*-45 -%45] W$YZT-> #$'--] W%XR.?-9:;.?-./ 0&1/05-4 0$1? -(QUV W$\ -#> #$'-QV W&\45-BCD.?-.? -&.? -(.2 )'*SZ[ W$\-67G #$'-SZ[ W%XUR -$.?-.?-()*-(32 )&*-./ 0&12)*S[ W#\-+& #%'-<=] W'XR())3?-.?-./5-4 0'1?-.? -&4012*] W#\--> #%'-EF]WWY Z%T4001?-.?-.? -*.?-.2 )$* -#405] W#XR-+& #$'-QUVWW\())* -%.?-.?-.?-( )&*-.?-./ 0#12)*--QUV W#YT--> #$'-] W$\4012* -$.?-.?-.?-./ 0$1?-.2)3?68-4012)*S[ W$\<=-> #$'-]WYZZT--412 )$3?-.?-.?-.? -$.?-./01?+, -#4012*] W$\EF-> #$'-]W\()* -#4 0%1?-.?-.2)3? -$.?-.?-.2* -&405] W$XUR-> #$'-]W\.@2* -$6778.?-.?-./012))*-.?-45-.@2 )#*Q U$V W&\-> #$'-]W\4012)*--+%%,.?-.?-.?-4 0#5-.? -$./ 0$5] W*YT-> #$'-]WXUR4012 )&3?-.?-.? -'.?-(*-.? -%SZ[ W(\--> #$'-]WWYT--./ 0&1?-.?-.2 )#*-()32)3?-.?-( )$*] W'YT-6G #$'-]WW\())3? -&.?-.?-4001/5-4 0$1?-.2)3/001?S[ W%YT--> #%'-]WW\4 0#5 -#())3?-.? -$.? -'.?-.@@/5--.2*] W%\--6G #%'-S[WXUR -$()3 @#?-.2*-()32)*-(*-(3?-./05 -#405] W$YT-6G #&'--] W#\( )#3/ 0#1?-405-401/05-45-405-.? -%QUUV W$\--> #'A8-S[WW\4 0$5 -#.? -'.? -*.? -$QV W'\-6G #('--SZ[X U%R -#.2 )'32 )*32*--QV W(\-> #)A8-<=] W#YZZT())3 @#/ 0$1@@/ 0%1/0012*-S[ W(\-+& #($,-EF]WWYT())3/ 0#1/5 -$.@/5 -%.?68.@2)*SZ[ W%YT--> #('--QUVWW\(3@@/5 -#.? -$(3@? -$()3?+,40012)*] W%\<=-> #('-QV W$\4 0#5 -#(32* -#.@@? -#(3/05--QUR401?] W%\EF-> #('-S[ W$X U&R(3@@2)*-4012*--405Q U#VWXUR45] W%XR--> #('--] W+\4 0#1@?QUR412*Q U#V W'XUUV W%YT-6G #(A8-S[WY Z&[WX U#R41?]WXR405] W4\--> #*'--]W\< H$=S[ W$XR.?]WWX U#V W%Y Z&[ W'\-6G #*A8-]W\EIMNIL=] W%\45] W,\9:;<H=] W'\-+& #*$,-]WXRKJ-KMF] W%XUUV W,\BCDKPJ] W'\--> #)$,--]WW\EF-EFQV W5\ -#ENF] W'XR-> #($,--QVWWX U%V W/Y Z#[WWX U&V W#YZZ[W\-+& #''--QV W+Y Z&[ W&\<H=] W-\--]W\--+%& #%'-QV W*YZT -&SZ[ W#YTENFSZZ[ W*XUUVWXR -#+& #$'-] W&Y Z$T -#6778 -#S Z#T -'S Z([ W'XUR--> #$'-SZZ[WYZT -&67G##A78 -'6 7#8 -*SZZ[ W&XR-> #$'-<=-SZT -#6 7$G #&A 7'G ##A 7(8 -$S Z%[YT-> #$'-EF -%67G #@A778 -'ST--> #$' -%677G #EA 7%8 -$6G #$A 7%G #NA 7$G #¢"
  186.  
  187. BackgroundColors:
  188. DATA 4282417216,4282400896,4286595136,4286611584
  189. Lands:
  190. DATA "Continentia","Forestria","Archipelia","Saharia"
  191. Names:
  192. DATA "Sir Crimsaun","Lord Palmer","Tynnestra","Mad Moham"
  193. Titles:
  194. DATA "Knight","General","Marshal","Lord"
  195. DATA "Paladin","Crusader","Avenger","Champion"
  196. DATA "Sorceress","Magcian","Mage","Archmage"
  197. DATA "Barbarian","Chieftain","Warlord","Overlord"
  198. Advancement:
  199. DATA 100,2,1,1000,7500,100,3,1,1000,0,300,4,1,2000,0,500,5,2,4000,0
  200. DATA 80,3,1,1000,10000,80,4,2,1000,0,240,5,2,2000,0,400,6,2,4000,0
  201. DATA 60,5,2,3000,10000,60,8,3,1000,0,180,10,5,1000,0,300,12,5,1000,0
  202. DATA 100,2,1,2000,7500,100,2,1,2000,0,300,3,1,2000,0,500,3,1,2000,0
  203. Units:
  204. '    name     ,hp ,AtkL,AtkH,Sht,SL,Mv,Cost,Shts,Grp,ShtL,ShtH
  205. DATA Peasant,1,1,1,0,1,1,10,0,1,0,0
  206. DATA Sprite,1,1,2,0,1,99,10,0,3,0,0
  207. DATA Militia,2,1,2,0,2,2,50,0,1,0,0
  208. DATA Wolf,3,1,3,0,2,3,40,0,4,0,0
  209. DATA Skeleton,3,1,2,0,2,2,40,0,5,0,0
  210. DATA Zombie,5,2,2,0,2,1,50,0,5,0,0
  211. DATA Gnome,5,1,3,0,2,1,60,0,3,0,0
  212. DATA Orc,5,2,3,1,2,2,75,6,4,1,2
  213. DATA Archer,10,1,2,1,2,2,250,12,2,1,3
  214. DATA Elf,10,1,2,1,3,3,200,24,3,2,4
  215. DATA Pikeman,10,2,4,0,3,2,300,0,2,0,0
  216. DATA Nomad,15,2,4,0,3,2,300,0,3,0,0
  217. DATA Dwarf,20,2,4,0,3,1,300,0,3,0,0
  218. DATA Ghost,10,3,4,0,4,3,400,0,5,0,0
  219. DATA Knight,35,6,10,0,5,1,1000,0,2,0,0
  220. DATA Ogre,40,3,5,0,4,1,750,0,4,0,0
  221. DATA Barbarian,40,1,6,0,4,3,750,0,3,0,0
  222. DATA Troll,50,2,5,0,4,1,1000,0,4,0,0
  223. DATA Calvery,20,3,5,0,4,4,800,0,2,0,0
  224. DATA Druid,25,2,3,1,5,2,750,3,3,10,10
  225. DATA Archmage,25,2,3,1,5,99,1200,2,3,25,25
  226. DATA Vampire,30,3,6,0,5,99,1500,0,5,0,0
  227. DATA Giant,60,10,20,1,5,3,2000,6,3,5,10
  228. DATA Deamon,50,5,7,0,6,99,3000,0,5,0,0
  229. DATA Dragon,200,25,50,0,6,99,5000,0,4,0,0
  230.  
  231. Contract_Data:
  232. DATA "Murray the Miser","None",5000,1
  233. DATA "Threadbare clothes, bald patch with hair combed to cover it, incessant cough."
  234. 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."
  235.  
  236. DATA "Hack the Rogue","The Spitter",6000,1
  237. DATA "Bushy ebon beard stained with tobacco juice, numerous battle scars, brash, arrogant behavior."
  238. DATA "Along with many minor infractions, Hack is wanted for conspiracy against the Crown and grave-robbing."
  239.  
  240. DATA "Princess Aimola","Lady Deceit",7000,1
  241. DATA "Excessive use of make-up to hide aging features, ever-present lace handkerchief."
  242. DATA "The Princess violated her status as a visiting dignitary by encouraging a murder and joining the conspiracy against the Crown."
  243.  
  244. DATA "Baron Johnno Makahl","Johnno",8000,1
  245. DATA "Expensive and gaudy clothes, overweight, and a scruffy beard."
  246. DATA "Johnno is wanted for various crimes against the Kingdom, including leading a direct assualt against the Crown and conspiracy."
  247.  
  248. DATA "Dread Pirate Rob","Terror of the Sea",9000,1
  249. DATA "Pencil thin moustache and elegantly trimmed beard never without a rapier."
  250. DATA "Rob is wanted for piracy as well as conspiracy and for breaking out five traitors sentenced to death in the Royal Dungeons."
  251.  
  252. DATA "Caneghor the Mystic","The Majestic Sage",10000,1
  253. DATA "Voluminous robes, bald head, magic symbols engraved on body, levitating ability."
  254. DATA "Caneghor is wanted for grave robbing, conspiracy against the Crown, and plundering the Royal Library."
  255.  
  256. DATA "Sir Moradon the Cruel","None",12000,2
  257. DATA "Always wearing armor and concealed weapons, has two prominent front teeth and an unkept beard."
  258. DATA "Sir Moradon, an emissary from another land, is wanted for joining a conspiracy to topple the kingdom."
  259.  
  260. DATA "Prince Barrowpine","The Elf Lord",14000,2
  261. DATA "Pointed ears, sharp elfin features, pale blue eyes with no whites, glimmering enchanted coin."
  262. DATA "The prince is one of the leaders of the conspiracy against the Crown, he also traffics stolen artifacts."
  263.  
  264. DATA "Bargash Eyesore","Old One Eye",16000,2
  265. DATA "Single eye centered in middle of forehead, over ten feet tall, only hair on body is in beard."
  266. DATA "Bargash is wanted for conspiracy against the Crown and for leading an outright attack against the King."
  267.  
  268. DATA "Rinaldus Drybone","The Death Lord",18000,2
  269. DATA "Rinaldus is a magically animated skeleton, an undead, he is easily identifiable by the ancient crown he wears."
  270. DATA "Rinaldus is wanted for conspiracy against the Crown and leading a rebellion on the continent of Saharia."
  271.  
  272. DATA "Ragface","None",20000,3
  273. DATA "Ragface is an undead, he is covered from head to foot in moldering green strips of cloth. A rotting smell follows him."
  274. DATA "Conspiracy against the Crown and leading an insurrection in Saharia."
  275.  
  276. DATA "Mahk Bellowspeak","Bruiser",25000,3
  277. DATA "Bright orange body hair on a fluorescent green body, a tendency to shout for no apparent reason."
  278. DATA "Mahk is wanted for the conspiracy against the Crown, leading a jail break, and for piracy on the open seas."
  279.  
  280. DATA "Auric Whiteskin","The Barbarian",30000,3
  281. DATA "Auric is heavily muscled and wears a protective skin made from the hides of baby lambs."
  282. DATA "Auric is wanted for conspiracy and for leading the rebellion of the continent Saharia."
  283.  
  284. DATA "Czar Nickolai the Mad","The Mad Czar",35000,3
  285. DATA "The Czar has eyes which change color constantly, also a sulphuric smell emanates from his body."
  286. DATA "The Czar is wanted for conspiracy against the Crown, violating diplomatic status, and murder."
  287.  
  288. DATA "Magus Deathspell","None",40000,4
  289. DATA "Pupil-less eyes, flowing white beard, always wears crimson robes and a matching skull cap."
  290. DATA "Magus is wanted for conspiracy against the Crown and for practicing forbidden magics."
  291.  
  292. DATA "Urthrax Killspite","The Demon King",45000,4
  293. DATA "Green, scaly skin, glowing red eyes, horns protruding from sides of head, over 7 feet tall."
  294. DATA "Urthrax is wanted for conspiracy against the Crown."
  295.  
  296. DATA "Arech Dragonbreath","Mastermind",50000,4
  297. DATA "Arech is an immense dragon with a green body and blue wings, he breathes fire."
  298. DATA "Arech is wanted for leading the conspiracy against the Crown, arranging jailbreaks, formenting rebellion, stealing the Sceptre of Order."
  299.  
  300. CastleData:
  301. DATA "Azram       ",30,26,1,30,27
  302. DATA "Basefit     ",47,05,2,47,6
  303. DATA "Cancomar    ",36,48,1,36,49
  304. DATA "Duvock      ",30,17,2,30,18
  305. DATA "Endryx      ",11,45,3,11,46
  306. DATA "Faxis       ",22,48,1,22,49
  307. DATA "Goobare     ",41,35,3,41,36
  308. DATA "Hyppus      ",43,26,3,43,27
  309. DATA "Irok        ",11,29,1,11,30
  310. DATA "Jhan        ",41,33,2,41,34
  311. DATA "Kookamunga  ",57,57,1,57,58
  312. DATA "Lorsche     ",52,56,3,52,57
  313. DATA "Mooseweigh  ",25,38,2,25,39
  314. DATA "Nilslag     ",22,23,1,22,24
  315. DATA "Ophiraund   ",06,56,1,6,57
  316. DATA "Portalis    ",58,22,1,58,23
  317. DATA "Quinderwitch",42,55,2,42,56
  318. DATA "Rythacon    ",54,05,1,54,6
  319. DATA "Spockana    ",17,38,4,17,39
  320. DATA "Tylitch     ",09,17,3,9,18
  321. DATA "Uzare       ",41,11,4,41,12
  322. DATA "Vutar       ",40,04,1,40,5
  323. DATA "Wankelforte ",40,40,1,40,41
  324. DATA "Xelox       ",45,05,3,45,6
  325. DATA "Yeneverre   ",19,18,2,19,19
  326. DATA "Zyzzarzaz   ",46,42,4,46,43
  327. TownData:
  328. DATA "Anomaly       ",0,0,04,35,23,2,34,23
  329. DATA "Bayside       ",0,0,15,48,58,1,41,58
  330. DATA "Centrapf      ",0,0,08,09,38,3,9,39
  331. DATA "Dark Corner   ",0,0,17,58,59,2,58,60
  332. DATA "Elan's Landing",0,0,13,03,36,2,3,37
  333. DATA "Fjord         ",0,0,23,47,35,1,46,35
  334. DATA "Grimwold      ",0,0,19,09,59,4,9,60
  335. DATA "Hunterville   ",0,1,22,12,04,1,12,3
  336. DATA "Isla Vista    ",0,0,18,56,05,1,57,5
  337. DATA "Japper        ",0,0,24,13,08,3,13,7
  338. DATA "Kings Haven   ",0,0,14,16,21,1,17,21
  339. DATA "Lake Veiw     ",0,0,06,16,44,1,17,44
  340. DATA "Midland       ",0,0,10,57,33,2,58,33
  341. DATA "Nyre          ",0,0,16,50,14,1,50,13
  342. DATA "Overthere     ",0,0,12,57,56,3,57,57
  343. DATA "Paths end     ",0,0,03,38,49,1,38,50
  344. DATA "Quiln Point   ",0,0,09,13,27,1,14,27
  345. DATA "Riverton      ",0,0,01,29,11,1,29,12
  346. DATA "Simpleton     ",0,0,07,12,60,3,13,60
  347. DATA "Topshore      ",0,0,05,05,49,3,5,50
  348. DATA "Underfoot     ",0,0,02,57,04,2,58,4
  349. DATA "Vengance      ",0,0,21,06,03,4,7,3
  350. DATA "Woods End     ",0,0,25,03,09,2,3,8
  351. DATA "Xoctan        ",0,0,11,51,29,1,51,28
  352. DATA "Yakonia       ",0,0,20,50,08,3,49,8
  353. DATA "Zaezoizu      ",0,0,26,58,47,4,58,48
  354. SpellData:
  355. DATA "Bridge",100,"Time Stop",200,"Find Villain",1000,"Castle Gate",1000,"Town Gate",500,"Instant Army",1000,"Raise Control",500
  356. DATA "Close",2000,"Teleport",500,"FireBall",1500,"Lightning",500,"Freeze",300,"Resurrect",5000,"Turn Undead",2000
  357. PuzzleData:
  358. 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
  359. SignData:
  360. DATA "Rent a boat and sail the seas. Explore the easy way!",14,3,1
  361. DATA "Treasure Island",3,3,1
  362. DATA "Aurange is north",5,6,1
  363. DATA "The Secptre will never be fonud!",3,9,1
  364. DATA "King's Tresure Garden",12,10,1
  365. DATA "There are two artifacts per continent.",15,10,1
  366. DATA "Pond of Peril",20,16,1
  367. DATA "Peasant Way",25,11,1
  368. DATA "Six villains rule Continentia.",38,3,1
  369. DATA "It takes time to cross the desert.",45,16,1
  370. DATA "Wonder Woods",40,12,1
  371. DATA "Dead End",32,18,1
  372. DATA "Irok guards the north",10,28,1
  373. DATA "A-maze-ing Forest",15,33,1
  374. DATA "All maps are found in chests",58,33,1
  375. DATA "Bridge Port",51,38,1
  376. DATA "Hidden Grove",34,39,1
  377. DATA "Secret Pass",9,41,1
  378. DATA "Pirate's Cove",7,55,1
  379. DATA "Isle of Death",24,49,1
  380. DATA "Boon Docks",43,59,1
  381. DATA "Welcome to Kookamunga!",55,59,1
  382.  
  383. DATA "Wood's End is south.",3,15,2
  384. DATA "Time is on our side.",42,3,2
  385. DATA "Passage to Basefit.",52,3,2
  386. DATA "The end is near.",57,11,2
  387. DATA "Peasants are fodder!",59,22,2
  388. DATA "Remember, whereever you go there you are.",60,28,2
  389. DATA "Undead are everywhere!",41,15,2
  390. DATA "The ogres are back... and they're hungry!",27,14,2
  391. DATA "Treasure at the river's end.",22,14,2
  392. DATA "Monster Way",18,26,2
  393. DATA "There is one town for each castle.",42,27,2
  394. DATA "No Trespassing!",37,35,2
  395. DATA "You'll never find the Sceptre here!",39,39,2
  396. DATA "Crossroads",22,34,2
  397. DATA "Forestria maze entrance!",7,32,2
  398. DATA "Beware the moors!",6,37,2
  399. DATA "Wrong Way!",16,58,2
  400. DATA "Don't go any farther!",22,49,2
  401. DATA "Stay on the road!",64,48,2
  402. DATA "Your Quest is doomed!",56,39,2
  403. DATA "Four villains rule Forestria",55,60,2
  404.  
  405. DATA "Welcome to Archipelia!",10,60,3
  406. DATA "The islands hide treasures.",3,56,3
  407. DATA "Four villains rule here.",11,50,3
  408. DATA "There are five islands here.",9,33,3
  409. DATA "Swamplands",6,16,3
  410. DATA "There's no turning back!",28,6,3
  411. DATA "Pirate's Treasure Trove",25,22,3
  412. DATA "Pirates have no mercy!",29,28,3
  413. DATA "Corak was here!",37,22,3
  414. DATA "The dead live!",40,28,3
  415. DATA "Thieves will be eaten!",53,24,3
  416. DATA "Pool of Prosperity",41,43,3
  417. DATA "Maximus will DIE!",34,39,3
  418. DATA "Time is on our side!",31,56,3
  419. DATA "Down with the King!",51,35,3
  420.  
  421. DATA "Your army will perish here!",40,11,4
  422. DATA "Three villains rule Saharia.",52,9,4
  423. DATA "Oasis",39,18,4
  424. DATA "Wading Pool",14,30,4
  425. DATA "There is no escaping the prophecy!",18,38,4
  426. DATA "Time is running out!",17,46,4
  427. DATA "this place is a nightmare!",11,59,4
  428. DATA "Treasure Trough",25,47,4
  429. DATA "Treasure Zone",35,50,4
  430. DATA "Rest Stop",43,49,4
  431. DATA "Volcano Guardian",47,42,4
  432. DATA "Oasis of Plenty",46,33,4
  433.  
  434. villainarmydata:
  435. DATA 50,20,25,30,25,0,3,1,0,0
  436. DATA 10,30,20,60,40,11,2,2,0,0
  437. DATA 75,50,20,20,5,1,1,4,5,15
  438. DATA 30,20,10,5,5,3,7,8,17,12
  439. DATA 50,50,10,10,5,2,2,8,9,16
  440. DATA 200,10,10,5,5,1,13,14,20,20
  441.  
  442. DATA 100,25,20,15,15,3,9,11,19,15
  443. DATA 30,30,10,30,300,10,21,20,11,2
  444. DATA 150,20,10,5,80,8,16,18,23,4
  445. DATA 500,100,30,10,5,5,6,14,22,24
  446.  
  447. DATA 600,200,50,20,10,5,6,14,22,24
  448. DATA 30,5,30,200,200,23,25,16,8,7
  449. DATA 300,40,20,100,700,7,17,23,12,1
  450. DATA 40,100,80,60,5,9,11,19,15,25
  451.  
  452. DATA 30,50,100,500,5000,24,22,21,7,1
  453. DATA 50,10,200,250,60,24,25,19,15,21
  454. DATA 100,25,25,100,100,25,25,25,24,22
  455.  
  456. Load_Data
  457. '---------------starting stats-------------------
  458. G.Days = 900
  459. G.TimeStop = 0
  460. G.Level = EASY
  461. P.Class = KNIGHT
  462. P.Promotion = 0
  463. P.Maps_Aquired = 1
  464. P.Artifacts_Aquired = 0
  465. P.Puzzle_Peices = 2 ^ 25 - 1
  466. P.Magic_Learned = FALSE
  467. P.Seige_Bought = FALSE
  468.  
  469. P.Current_Contract = 1 '<------------------
  470.  
  471. P.MapXPos = 1386 '96 * 14.5
  472. P.MapYpos = 80 * 5
  473. P.Current_Land = CONTINENTIA
  474. P.Travel_Mode = HORSE
  475. '------------------------------------------------
  476. '--------------Basic Controls--------------------
  477. Control.Up_Key = 18432
  478. Control.Down_Key = 20480
  479. Control.Left_Key = 19200
  480. Control.Right_Key = 19712
  481. Control.Start_Button = 13 'enter
  482. Control.A_Button = 97 '    a
  483. Control.B_Button = 115 '   s
  484. Control.C_Button = 100 '   d
  485. G.BGM = TRUE
  486. G.SFX = TRUE
  487. G.Combat_speed = 5
  488. G.BGM_VOL = 50
  489. G.SFX_VOL = 50
  490.  
  491.  
  492. PX.Spells(2) = 0
  493.  
  494. PX.Army(0).Unit = 3
  495. PX.Army(0).Count = 20
  496. PX.Army(1).Unit = 9
  497. PX.Army(1).Count = 2
  498. PX.Army(2).Unit = 11
  499. PX.Army(2).Count = 2
  500. PX.Army(3).Unit = 19
  501. PX.Army(3).Count = 2
  502. PX.Army(4).Unit = 4
  503. PX.Army(4).Count = 2
  504.  
  505. G.HDR_Text = Names(P.Class) + " the " + Title(P.Class, P.Promotion)
  506.  
  507. Add_Player_Advancement 'players first advnacement from Nobody to hero set base values
  508.  
  509. Place_Extras
  510.  
  511. Set_BackGround_Color
  512.  
  513. G.Scepter_Land = CONTINENTIA
  514. Hide_Scepter G.Scepter_Land
  515. Swap_Map P.Current_Land, LOAD
  516. Build_Map 13
  517.  
  518. 'Swap_Map FORESTRIA, LOAD
  519. 'Build_Map 14
  520. 'Swap_Map ARCHIPELIA, LOAD
  521. 'Build_Map 15
  522. 'Swap_Map SAHARIA, LOAD
  523. 'Build_Map 16
  524.  
  525.  
  526.  
  527. 'Build_Map 13
  528. 'Build_Main_Window
  529. 'Build_Town_Window
  530. '_PUTIMAGE , Layer(1), Layer(0)
  531. 'END
  532.  
  533. G.In_Combat = FALSE
  534. TIMER(G.GameTimer) ON
  535.  KBD& = _KEYHIT
  536.  SELECT CASE KBD&
  537.   CASE Control.A_Button, Control.C_Button
  538.    Build_Menu_Window
  539.   CASE Control.B_Button
  540.   CASE MASTERESC
  541.    Exitflag%% = TRUE
  542.  
  543.  IF P.Travel_Mode = HORSE OR P.Travel_Mode = BOAT THEN speed%% = 6
  544.  IF P.Travel_Mode = DRAGON THEN speed%% = 8
  545.  IF In_Desert AND P.Travel_Mode = HORSE THEN speed%% = speed%% - 2
  546.  
  547.  OldX% = P.MapXPos: OldY% = P.MapYpos
  548.  
  549.  IF _KEYDOWN(Control.Up_Key) AND _KEYDOWN(Control.Left_Key) THEN
  550.   P.Facing = LEFT_FACE: P.Moving = TRUE
  551.   P.MapXPos = P.MapXPos - speed%%
  552.   IF Movement_Allowed <> TRUE THEN P.MapXPos = OldX%
  553.   P.MapYpos = P.MapYpos + speed%%
  554.   IF Movement_Allowed <> TRUE THEN P.MapYpos = OldY%
  555.  ELSEIF _KEYDOWN(Control.Up_Key) AND _KEYDOWN(Control.Right_Key) THEN
  556.   P.Facing = RIGHT_FACE: P.Moving = TRUE
  557.   P.MapXPos = P.MapXPos + speed%%
  558.   IF Movement_Allowed <> TRUE THEN P.MapXPos = OldX%
  559.   P.MapYpos = P.MapYpos + speed%%
  560.   IF Movement_Allowed <> TRUE THEN P.MapYpos = OldY%
  561.  ELSEIF _KEYDOWN(Control.Down_Key) AND _KEYDOWN(Control.Left_Key) THEN
  562.   P.Facing = LEFT_FACE: P.Moving = TRUE
  563.   P.MapXPos = P.MapXPos - speed%%
  564.   IF Movement_Allowed <> TRUE THEN P.MapXPos = OldX%
  565.   P.MapYpos = P.MapYpos - speed%%
  566.   IF Movement_Allowed <> TRUE THEN P.MapYpos = OldY%
  567.  ELSEIF _KEYDOWN(Control.Down_Key) AND _KEYDOWN(Control.Right_Key) THEN
  568.   P.Facing = RIGHT_FACE: P.Moving = TRUE
  569.   P.MapXPos = P.MapXPos + speed%%
  570.   IF Movement_Allowed <> TRUE THEN P.MapXPos = OldX%
  571.   P.MapYpos = P.MapYpos - speed%%
  572.   IF Movement_Allowed <> TRUE THEN P.MapYpos = OldY%
  573.  ELSEIF _KEYDOWN(Control.Up_Key) THEN
  574.   P.Moving = TRUE
  575.   P.MapYpos = P.MapYpos + speed%%
  576.   IF Movement_Allowed <> TRUE THEN P.MapYpos = OldY%
  577.  ELSEIF _KEYDOWN(Control.Down_Key) THEN
  578.   P.Moving = TRUE
  579.   P.MapYpos = P.MapYpos - speed%%
  580.   IF Movement_Allowed <> TRUE THEN P.MapYpos = OldY%
  581.  ELSEIF _KEYDOWN(Control.Left_Key) THEN
  582.   P.Facing = LEFT_FACE: P.Moving = TRUE
  583.   P.MapXPos = P.MapXPos - speed%%
  584.   IF Movement_Allowed <> TRUE THEN P.MapXPos = OldX%
  585.  ELSEIF _KEYDOWN(Control.Right_Key) THEN
  586.   P.Facing = RIGHT_FACE: P.Moving = TRUE
  587.   P.MapXPos = P.MapXPos + speed%%
  588.   IF Movement_Allowed <> TRUE THEN P.MapXPos = OldX%
  589.   P.Moving = FALSE
  590.  
  591.  '-----------the Boundries of Fantasia-----------
  592.  IF P.MapXPos < 224 AND P.Maps_Aquired = 1 THEN P.MapXPos = 224 ELSE Build_Travel_Window
  593.  IF P.MapXPos > 6432 AND P.Maps_Aquired = 1 THEN P.MapXPos = 6432 ELSE Build_Travel_Window
  594.  IF P.MapYpos < -136 AND P.Maps_Aquired = 1 THEN P.MapYpos = -136 ELSE Build_Travel_Window
  595.  IF P.MapYpos > 5080 AND P.Maps_Aquired = 1 THEN P.MapYpos = 5080 ELSE Build_Travel_Window
  596.  '-----------------------------------------------
  597.  Check_Map_Squares
  598.  Build_Main_Window
  599.  Build_Map_View2
  600.  Draw_Player
  601.  _PUTIMAGE , Layer(1), Layer(0)
  602.  Update_Map_Squares OldX%, OldY%
  603.  X%% = P.MapXPos / 96 - .49 - 3
  604.  Y%% = 65 - P.MapYpos / 80 - .49 - 1
  605.  LOCATE 1, 1: PRINT P.MapXPos; P.MapYpos; X%%; Y%%; In_Desert; G.Window_Animation; Movement_Allowed
  606.  _DELAY .005
  607.  IF G.WinGame THEN G.QuitGame = TRUE 'victory
  608. LOOP UNTIL G.QuitGame OR Exitflag%%
  609.  
  610. IF G.WinGame THEN Build_Victory_March
  611. TIMER(G.GameTimer) OFF
  612. IF G.WinGame THEN Build_Victory_March
  613.  
  614. 'DumpMap
  615.  
  616. SUB Update_Map_Squares (OX%, OY%)
  617.  X%% = P.MapXPos / 96 - .49 - 3
  618.  Y%% = 64 - P.MapYpos / 80 - .49 - 1
  619.  OldX%% = OX% / 96 - .49 - 3
  620.  OldY%% = 64 - OY% / 80 - .49 - 1
  621.  Land(OldX%%, OldY%%).IsPlayer = FALSE
  622.  Land(X%%, Y%%).IsPlayer = TRUE
  623.  
  624. SUB Check_Map_Squares
  625.  X%% = P.MapXPos / 96 - .49 - 3
  626.  Y%% = 64 - P.MapYpos / 80 - .49 - 1
  627.  IF Land(X%%, Y%%).IsTown AND Land(X%%, Y%%).IsPlayer = FALSE THEN Build_Town_Window 'only enter town if player just entered square
  628.  IF Land(X%%, Y%%).IsSign THEN behappy = TRUE
  629.  IF Land(X%%, Y%%).IsTreasure THEN behappy = TRUE
  630.  IF Land(X%%, Y%%).IsArtifact THEN behappy = TRUE
  631.  
  632. SUB Build_Town_Window
  633.  STATIC Last_Choice AS _BYTE
  634.  DIM ContractAvail(5) AS _BYTE 'current contracts available' only 5 at a time
  635.  '-------------load Villain contracts------------
  636.  i%% = 1: j%% = 1
  637.  IF P.VilliansCaught < 17 THEN
  638.   DO
  639.    IF Villains(i%%).Caught THEN
  640.     i%% = i%% + 1
  641.    ELSE
  642.     ContractAvail(j%%) = i%%
  643.     IF P.Current_Contract = ContractAvail(j%%) THEN current%% = j%%
  644.     j%% = j%% + 1
  645.     i%% = i%% + 1
  646.    END IF
  647.    IF i%% = 18 THEN Full%% = TRUE 'if player has caught more than 12 then there wont be 5
  648.    IF j%% = 6 THEN Full%% = TRUE
  649.  
  650.   LOOP UNTIL Full%%
  651.  '-----------------------------------------------
  652.  Selection%% = Last_Choice
  653.  j%% = j%% - 1
  654.  X%% = P.MapXPos / 96 - .49 - 3
  655.  Y%% = 64 - P.MapYpos / 80 - .49 - 1
  656.  _PUTIMAGE (16, 63)-STEP(479, 239), Layer(4), Layer(1), (0, 0)-STEP(239, 119)
  657.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(8), Layer(1), (16, 300)-STEP(479, 147)
  658.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(2), Layer(1), (320, 0)-STEP(239, 73)
  659.  KB_Print 16, 316, "Town of", 0, LEFT
  660.  KB_Print 144, 316, Towns(Land(X%%, Y%%).IsTown).The_Name, 0, LEFT
  661.  IF P.VilliansCaught < 17 THEN KB_Print 48, 348, "Get New Contract", 0, LEFT
  662.  IF NOT P.Has_Boat THEN
  663.   KB_Print 48, 364, "Rent Boat", 0, LEFT
  664.   IF P.Artifacts_Aquired AND 4 THEN b$ = "(100 week)" ELSE b$ = "(500 week)"
  665.   KB_Print 204, 364, b$, 0, LEFT
  666.   KB_Print 48, 364, "Cancel Rental", 0, LEFT
  667.  KB_Print 48, 380, "Gather Information", 0, LEFT
  668.  IF NOT P.Seige_Bought THEN KB_Print 48, 412, "Buy Seige Weapons (3000)", 0, LEFT
  669.  b$ = RTRIM$(Spells(Towns(Land(X%%, Y%%).IsTown).Spell).Spell_Name)
  670.  c$ = " spell (" + LTRIM$(STR$(Spells(Towns(Land(X%%, Y%%).IsTown).Spell).Cost)) + ")"
  671.  KB_Print 48, 396, b$ + c$, 0, LEFT
  672.  KB_Print 352, 332, "GP=", 0, LEFT
  673.  _PUTIMAGE , Layer(1), Layer(9)
  674.  DO
  675.   KBD& = _KEYHIT
  676.   SELECT CASE KBD&
  677.    CASE Control.Up_Key
  678.     Selection%% = Selection%% - 1
  679.     IF P.VilliansCaught = 17 THEN 'has player caught all villians?
  680.      IF Selection%% < 1 THEN Selection%% = 1
  681.     ELSE
  682.      IF Selection%% < 0 THEN Selection%% = 0
  683.     END IF
  684.     G.HDR_Text = Names(P.Class) + " the " + Title(P.Class, P.Promotion)
  685.     Window_Header
  686.     _PUTIMAGE , Layer(1), Layer(9)
  687.    CASE Control.Down_Key
  688.     Selection%% = Selection%% + 1
  689.     IF P.Seige_Bought THEN 'has player already bought the seige weapons?
  690.      IF Selection%% > 3 THEN Selection%% = 3
  691.     ELSE
  692.      IF Selection%% > 4 THEN Selection%% = 4
  693.     END IF
  694.     G.HDR_Text = Names(P.Class) + " the " + Title(P.Class, P.Promotion)
  695.     Window_Header
  696.     _PUTIMAGE , Layer(1), Layer(9)
  697.    CASE Control.A_Button
  698.     Last_Choice = Selection%%
  699.     SELECT CASE Selection%%
  700.      CASE 0
  701.       IF current%% <= j%% AND j%% > 1 THEN current%% = current%% + 1
  702.       IF current%% > j%% THEN current%% = 1
  703.       P.Current_Contract = ContractAvail(current%%)
  704.       _PUTIMAGE , Layer(9), Layer(11) 'save current town temp layer
  705.       Build_Contract_Window
  706.       _PUTIMAGE , Layer(11), Layer(9) 'restore current town temp layer
  707.      CASE 1
  708.       Rent_Boat Land(X%%, Y%%).IsTown
  709.      CASE 2
  710.      CASE 3
  711.       Buy_Spell Towns(Land(X%%, Y%%).IsTown).Spell
  712.      CASE 4
  713.       IF Buy_Seige THEN
  714.        Selection%% = 3: Last_Choice = 3
  715.       END IF
  716.     END SELECT
  717.    CASE Control.B_Button
  718.     exitflag%% = TRUE
  719.     G.HDR_Text = Names(P.Class) + " the " + Title(P.Class, P.Promotion)
  720.    CASE MASTERESC
  721.     exitflag%% = TRUE
  722.     G.QuitGame = TRUE
  723.   IF P.Gold < 10000 THEN G$ = LTRIM$(STR$(P.Gold)) ELSE G$ = Special_K_Value(P.Gold)
  724.   KB_Print 400, 332, G$, 0, LEFT
  725.   Display_Selection_Arrow 32, 346 + (16 * Selection%%)
  726.   Run_Animations
  727.   _PUTIMAGE , Layer(1), Layer(0)
  728.   _PUTIMAGE , Layer(9), Layer(1)
  729.   LOCATE 1, 1: PRINT Selection%%
  730.   _DELAY .005
  731.  LOOP UNTIL exitflag%%
  732.  
  733. SUB Rent_Boat (TID%%)
  734.  IF NOT P.Has_Boat THEN
  735.   IF P.Artifacts_Aquired AND 4 THEN 'does player have the anchor?
  736.    IF P.Gold > 100 THEN 'then player pays 100
  737.     P.Has_Boat = TRUE
  738.     P.Gold = P.Gold - 100
  739.     _PUTIMAGE (48, 364)-STEP(368, 16), Layer(8), Layer(1), (48, 364)-STEP(368, 16)
  740.     KB_Print 48, 364, "Cancel Rental", 0, LEFT
  741.     _PUTIMAGE , Layer(1), Layer(9)
  742.    ELSE
  743.     G.HDR_Text = "     You do not have enough gold!"
  744.     Window_Header
  745.     _PUTIMAGE , Layer(1), Layer(9)
  746.    END IF
  747.   ELSEIF P.Gold > 500 THEN ' else player pays 500
  748.    P.Has_Boat = TRUE
  749.    P.Gold = P.Gold - 500
  750.    _PUTIMAGE (48, 364)-STEP(368, 16), Layer(8), Layer(1), (48, 364)-STEP(368, 16)
  751.    KB_Print 48, 364, "Cancel Rental", 0, LEFT
  752.    _PUTIMAGE , Layer(1), Layer(9)
  753.   ELSE
  754.    G.HDR_Text = "     You do not have enough gold!"
  755.    Window_Header
  756.    _PUTIMAGE , Layer(1), Layer(9)
  757.   END IF
  758.   IF P.Has_Boat THEN
  759.    P.Last_Seen_Boat.Xloc = Towns(TID%%).BoatX
  760.    P.Last_Seen_Boat.Yloc = Towns(TID%%).BoatY
  761.    P.Last_Seen_Boat.Land = P.Current_Land
  762.    Place_Boat
  763.   END IF
  764.  ELSE 'player has boat so un-have it
  765.   P.Has_Boat = FALSE
  766.   Remove_Boat
  767.   _PUTIMAGE (48, 364)-STEP(368, 16), Layer(8), Layer(1), (48, 364)-STEP(368, 16)
  768.   KB_Print 48, 364, "Rent Boat", 0, LEFT
  769.   IF P.Artifacts_Aquired AND 4 THEN b$ = "(100 week)" ELSE b$ = "(500 week)"
  770.   KB_Print 204, 364, b$, 0, LEFT
  771.   _PUTIMAGE , Layer(1), Layer(9)
  772.  
  773. SUB Buy_Spell (ID%%)
  774.  IF P.Gold > Spells(ID%%).Cost THEN
  775.   IF Total_Spells < P.MaxSpells THEN
  776.    PX.Spells(ID%%) = PX.Spells(ID%%) + 1
  777.    P.Gold = P.Gold - Spells(ID%%).Cost
  778.    G.HDR_Text = "    You can learn" + STR$(P.MaxSpells - Total_Spells) + " more spells!"
  779.    Window_Header
  780.    _PUTIMAGE , Layer(1), Layer(9)
  781.   ELSE
  782.    G.HDR_Text = "  You can not learn anymore spells!"
  783.    Window_Header
  784.    _PUTIMAGE , Layer(1), Layer(9)
  785.   END IF
  786.   G.HDR_Text = "     You do not have enough gold!"
  787.   Window_Header
  788.   _PUTIMAGE , Layer(1), Layer(9)
  789.  
  790. FUNCTION Buy_Seige%%
  791.  IF P.Gold > 3000 THEN
  792.   P.Seige_Bought = TRUE
  793.   P.Gold = P.Gold - 3000
  794.   Result%% = TRUE
  795.   _PUTIMAGE (48, 412)-STEP(400, 16), Layer(8), Layer(1), (48, 364)-STEP(400, 16)
  796.   _PUTIMAGE , Layer(1), Layer(9)
  797.   G.HDR_Text = "     You do not have enough gold!"
  798.   Window_Header
  799.   _PUTIMAGE , Layer(1), Layer(9)
  800.   Result%% = FALSE
  801.  Buy_Seige = Result%%
  802.  
  803. FUNCTION Total_Spells%%
  804.  Result%% = 0
  805.  FOR i%% = 1 TO 14
  806.   Result%% = Result%% + PX.Spells(i%%)
  807.  NEXT i%%
  808.  Total_Spells = Result%%
  809.  
  810. FUNCTION Movement_Allowed
  811.  'check whether or not a player can move into a square
  812.  'changes player from horse to boat and back again when going
  813.  'from land to water and vice-versa,also updates where boat is in the world
  814.  X%% = P.MapXPos / 96 - .49 - 3
  815.  Y%% = 64 - P.MapYpos / 80 - .49 - 1
  816.  Result%% = FALSE
  817.  'horse travel
  818.  IF P.Travel_Mode = HORSE THEN
  819.   SELECT CASE Land(X%%, Y%%).Terrain
  820.    CASE 10
  821.     Result%% = TRUE
  822.    CASE 1 TO 4, 8, 9, 19, 20, 21, 27, 30, 36 'shore
  823.     IF P.Has_Boat THEN
  824.      Result%% = TRUE
  825.      P.Travel_Mode = BOAT
  826.      Land(X%%, Y%%).IsBoat = FALSE 'stop static display of boat
  827.      Remove_Boat
  828.     ELSE
  829.      Result%% = Land(X%%, Y%%).Terrain
  830.     END IF
  831.    CASE ELSE
  832.     Result%% = Land(X%%, Y%%).Terrain
  833.  ELSEIF P.Travel_Mode = BOAT THEN
  834.   SELECT CASE Land(X%%, Y%%).Terrain
  835.    CASE 10
  836.     Land(X%%, Y%%).IsBoat = TRUE 'map location displays boat
  837.     P.Last_Seen_Boat.Xloc = X%%
  838.     P.Last_Seen_Boat.Yloc = Y%%
  839.     P.Last_Seen_Boat.Land = P.Current_Land
  840.     Place_Boat
  841.     P.Travel_Mode = HORSE
  842.     Result%% = TRUE
  843.    CASE 0 TO 4, 8, 9, 19, 20, 21, 27, 30, 36 'shore
  844.     Result%% = TRUE
  845.    CASE ELSE
  846.     Result%% = FALSE
  847.  
  848.  Movement_Allowed = Result%%
  849.  
  850. SUB Remove_Boat
  851.  L%% = 12 + P.Last_Seen_Boat.Land
  852.  ix%% = Land(P.Last_Seen_Boat.Xloc, P.Last_Seen_Boat.Yloc).Terrain MOD 13
  853.  IF Land(P.Last_Seen_Boat.Xloc, P.Last_Seen_Boat.Yloc).Terrain > 12 THEN iy%% = Land(P.Last_Seen_Boat.Xloc, P.Last_Seen_Boat.Yloc).Terrain \ 13 ELSE iy%% = 0
  854.  _PUTIMAGE (288 + P.Last_Seen_Boat.Xloc * 96, 240 + P.Last_Seen_Boat.Yloc * 80)-STEP(95, 79), Layer(3), Layer(L%%), (0 + 48 * ix%%, 0 + 40 * iy%%)-STEP(47, 39)
  855.  
  856. SUB Place_Boat
  857.  L%% = 12 + P.Last_Seen_Boat.Land
  858.  _PUTIMAGE (288 + P.Last_Seen_Boat.Xloc * 96, 240 + P.Last_Seen_Boat.Yloc * 80)-STEP(91, 63), Layer(5), Layer(L%%), (0 + G.Window_Animation * 46, 800 + (4 * 32))-STEP(45, 31)
  859.  
  860. SUB Build_Map_View2
  861.  X% = P.MapXPos ' / 48
  862.  Y% = (65 * 80) - P.MapYpos
  863.  sy% = Y% - 48 * 2
  864.  sx% = X% - 40 * 2
  865.  IF sy%% < 0 THEN sy%% = 0
  866.  IF sx%% < 0 THEN sx%% = 0
  867.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(13), Layer(1), (P.MapXPos - 192, Y% - 120)-STEP(479, 383)
  868.  
  869. FUNCTION In_Desert
  870.  X%% = P.MapXPos / 96 - .49
  871.  Y%% = 65 - P.MapYpos / 80 - .49
  872.  IF Land(X%%, Y%%).Terrain >= 46 AND Land(X%%, Y%%).Terrain <= 58 THEN Result%% = TRUE ELSE Result%% = FALSE
  873.  In_Desert = Result%%
  874.  
  875. SUB Build_Travel_Window
  876.  
  877. FUNCTION DecodeMaps% (M$)
  878.  FOR i% = 1 TO LEN(M$)
  879.   c$ = MID$(M$, i%, 1)
  880.   IF c$ = CHR$(32) THEN 'RLE trigger
  881.    c$ = MID$(M$, i% + 1, 1) 'repeated value
  882.    EL~%% = ASC(MID$(M$, i% + 2, 1)) - 32 'repeat count
  883.    FOR l~%% = 1 TO EL~%%
  884.     UnEnc$ = UnEnc$ + c$
  885.    NEXT l~%%
  886.    i% = i% + 2
  887.   ELSE 'write single value
  888.    UnEnc$ = UnEnc$ + c$
  889.   END IF
  890.  NEXT i%
  891.  
  892.  
  893.  IF LEN(UnEnc$) = 4096 THEN 'uncompressed map size is 4k only pass if len is this number!
  894.   i% = 1
  895.   FOR y%% = 0 TO 63
  896.    FOR x%% = 0 TO 63
  897.     Land(x%%, y%%).Terrain = ASC(MID$(UnEnc$, i%, 1)) - 35
  898.     i% = i% + 1
  899.    NEXT x%%
  900.   NEXT y%%
  901.   DecodeMaps = TRUE
  902.   PRINT "error"
  903.   DecodeMaps = LEN(UnEnc$)
  904.  
  905. SUB Build_Army_Window
  906.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(8), Layer(1), (0, 15)-STEP(639, 447)
  907.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  908.  Window_Header
  909.  
  910.  FOR i%% = 0 TO 4
  911.   _PUTIMAGE (0, 51 + i%% * 80)-STEP(639, 91), Layer(2), Layer(1), (300, 600)-STEP(319, 45)
  912.   IF PX.Army(i%%).Unit THEN Unit_Data i%%, i%%
  913.  NEXT i%%
  914.  _PUTIMAGE , Layer(1), Layer(9)
  915.  DO
  916.   FOR i%% = 0 TO 4
  917.    IF PX.Army(i%%).Unit THEN Unit_Animation 24, 63 + i%% * 80, PX.Army(i%%).Unit, RIGHT_FACE
  918.   NEXT i%%
  919.   _PUTIMAGE , Layer(1), Layer(0)
  920.   _PUTIMAGE , Layer(9), Layer(1)
  921.   _DELAY .025
  922.  
  923.  LOOP UNTIL _KEYHIT = Control.B_Button
  924.  
  925. SUB Unit_Animation (x%, y%, Unit%%, Face%%)
  926.  IF Face%% = RIGHT_FACE THEN
  927.   _PUTIMAGE (x%, y%)-STEP(87, 63), Layer(5), Layer(1), (0 + (48 * G.Window_Animation), 0 + (Unit%% - 1) * 32)-STEP(47, 31)
  928.   _PUTIMAGE (x% + 87, y%)-STEP(-87, 63), Layer(5), Layer(1), (0 + (48 * G.Window_Animation), 0 + (Unit%% - 1) * 32)-STEP(47, 31)
  929.  
  930. SUB Unit_Data (Unit%%, Slot%%)
  931.  y% = 80 * Slot%%
  932.  ID%% = PX.Army(Unit%%).Unit
  933.  a$ = Units(ID%%).Unit_Name
  934.  IF PX.Army(Unit%%).Count > 1 THEN
  935.   IF RIGHT$(RTRIM$(a$), 1) = "f" THEN a$ = LEFT$(a$, LEN(RTRIM$(a$)) - 1) + "ves" ELSE a$ = RTRIM$(a$) + "s"
  936.  b~% = PX.Army(Unit%%).Count
  937.  IF b~% > 1000 THEN b$ = Special_K_Value(b~%) ELSE b$ = LTRIM$(STR$(b~%))
  938.  a$ = b$ + " " + a$
  939.  IF Units(ID%%).Movement = 99 THEN M$ = " Fly" ELSE M$ = STR$(Units(ID%%).Movement)
  940.  KB_Print 112, y% + 80, a$, 0, LEFT
  941.  KB_Print 112, y% + 96, "SL:" + STR$(Units(ID%%).Skill_Level) + "  MV:" + M$, 0, LEFT
  942.  KB_Print 112, y% + 112, "Morale: " + Units_Morale(Unit%%), 0, LEFT
  943.  KB_Print 358, y% + 80, "HitPts: " + Units_HP(Unit%%), 0, LEFT
  944.  KB_Print 358, y% + 96, "Damage: " + Units_Attack(Unit%%), 0, LEFT
  945.  KB_Print 358, y% + 112, "G-Cost: " + Units_Cost(Unit%%), 0, LEFT
  946.  
  947. FUNCTION Units_Morale$ (Unit%%)
  948.  DIM Rack(5) AS _BYTE
  949.  IF Units(PX.Army(Unit%%).Unit).Grouping = 1 THEN a%% = 0: b%% = 0: c%% = 0: d%% = -1: e%% = -1
  950.  IF Units(PX.Army(Unit%%).Unit).Grouping = 2 THEN a%% = 0: b%% = 0: c%% = 0: d%% = 0: e%% = -1
  951.  IF Units(PX.Army(Unit%%).Unit).Grouping = 3 THEN a%% = 0: b%% = 0: c%% = 1: d%% = -1: e%% = -1
  952.  IF Units(PX.Army(Unit%%).Unit).Grouping = 4 THEN a%% = 0: b%% = 0: c%% = 0: d%% = 1: e%% = 0
  953.  IF Units(PX.Army(Unit%%).Unit).Grouping = 5 THEN a%% = 0: b%% = 0: c%% = 0: d%% = 0: e%% = 0
  954.  Total%% = 0
  955.  FOR i%% = 1 TO 5
  956.   IF i%% <> Unit%% THEN
  957.    SELECT CASE Units(PX.Army(i%%).Unit).Grouping
  958.     CASE 1
  959.      Total%% = Total%% + a%%
  960.     CASE 2
  961.      Total%% = Total%% + b%%
  962.     CASE 3
  963.      Total%% = Total%% + c%%
  964.     CASE 4
  965.      Total%% = Total%% + d%%
  966.     CASE 5
  967.      Total%% = Total%% + e%%
  968.    END SELECT
  969.   END IF
  970.  NEXT i%%
  971.  IF Total%% = 0 THEN Result$ = "Norm"
  972.  IF Total%% < 0 THEN Result$ = "Low"
  973.  IF Total%% > 0 THEN Result$ = "High"
  974.  Units_Morale = Result$
  975.  
  976. FUNCTION Units_HP$ (unit%%)
  977.  Result~% = Units(PX.Army(unit%%).Unit).HitPts * PX.Army(unit%%).Count
  978.  IF Result~% > 1000 THEN Result$ = Special_K_Value(Result~%) ELSE Result$ = LTRIM$(STR$(Result~%))
  979.  Units_HP = Result$
  980.  
  981. FUNCTION Units_Attack$ (unit%%)
  982.  lo~% = Units(PX.Army(unit%%).Unit).AttackLo * PX.Army(unit%%).Count
  983.  hi~% = Units(PX.Army(unit%%).Unit).AttackHi * PX.Army(unit%%).Count
  984.  IF lo~% > 1000 THEN lo$ = Special_K_Value(lo~%) ELSE lo$ = LTRIM$(STR$(lo~%))
  985.  IF hi~% > 1000 THEN hi$ = Special_K_Value(hi~%) ELSE hi$ = LTRIM$(STR$(hi~%))
  986.  Result$ = lo$ + "-" + hi$
  987.  Units_Attack = Result$
  988.  
  989. FUNCTION Units_Cost$ (unit%%)
  990.  Result~% = (Units(PX.Army(unit%%).Unit).Cost * PX.Army(unit%%).Count) \ 10
  991.  IF Result~% >= 10000 THEN Result$ = Special_K_Value(Result~%) ELSE Result$ = LTRIM$(STR$(Result~%))
  992.  Units_Cost = Result$
  993.  
  994. SUB Build_Contract_Window
  995.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(8), Layer(1), (16, 63)-STEP(479, 383)
  996.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(2), Layer(1), (560, 0)-STEP(239, 191)
  997.  IF P.Current_Contract THEN
  998.   Contract_Animation 0
  999.   KB_Print 16, 175, "Name: " + Villains(P.Current_Contract).Villain, 0, LEFT
  1000.   KB_Print 16, 191, "Alias: " + Villains(P.Current_Contract).Alias, 0, LEFT
  1001.   KB_Print 16, 207, "Reward: " + Contract_Reward(Villains(P.Current_Contract).Bounty), 0, LEFT
  1002.   KB_Print 16, 223, "Last Seen: " + Lands(Villains(P.Current_Contract).LastSeen), 0, LEFT
  1003.   KB_Print 16, 239, "Castle: " + Castles(Villains(P.Current_Contract).Is_Known).The_Name, 0, LEFT
  1004.   KB_Print 16, 255, "Distinguishing Features: ", 0, LEFT
  1005.   y% = 272 'allows for different lenths of discriptions cause the routine changes the value
  1006.   KB_Print_Wrap 48, y%, Villains(P.Current_Contract).Description, 432
  1007.   KB_Print 16, y%, "Crimes: ", 0, LEFT
  1008.  
  1009.   KB_Print_Wrap 48, y%, "      " + Villains(P.Current_Contract).Crimes, 432
  1010.  
  1011.   KB_Print 79, 239, "You have no contract.", 0, LEFT
  1012.  _PUTIMAGE , Layer(1), Layer(9)
  1013.  DO
  1014.   _PUTIMAGE , Layer(1), Layer(9)
  1015.   Contract_Animation 0
  1016.   Run_Animations
  1017.   _PUTIMAGE , Layer(1), Layer(0)
  1018.   _DELAY .025
  1019.  LOOP UNTIL _KEYHIT = Control.B_Button
  1020.  
  1021.  
  1022. FUNCTION Contract_Reward$ (value~%)
  1023.  temp$ = LTRIM$(STR$(value~%))
  1024.  Result$ = LEFT$(temp$, LEN(temp$) - 3) + "," + RIGHT$(temp$, 3) + " Gold"
  1025.  Contract_Reward = Result$
  1026.  
  1027. SUB Build_MiniMap_Window
  1028.  _PUTIMAGE (90, 80)-STEP(319, 351), Layer(8), Layer(1), (90, 80)-STEP(319, 351)
  1029.  _PUTIMAGE (90, 80)-STEP(319, 351), Layer(2), Layer(1), (304, 224)-STEP(159, 175)
  1030.  KB_Print 90, 400, "X=   Position Y=", 0, LEFT
  1031.  X%% = (P.MapXPos / 96) - 3
  1032.  Y%% = P.MapYpos / 80
  1033.  IF X%% >= 0 THEN X$ = LTRIM$(STR$(X%%)) ELSE X$ = "**"
  1034.  IF Y%% >= 0 THEN Y$ = LTRIM$(STR$(Y%%)) ELSE Y$ = "**"
  1035.  KB_Print 122, 400, X$, 0, LEFT
  1036.  KB_Print 378, 400, Y$, 0, RIGHT
  1037.  KB_Print 240, 96, Lands(P.Current_Land), 0, CENTER
  1038.  Draw_MiniMap_Terrain
  1039.  Draw_Minimap_Objects
  1040.  _PUTIMAGE , Layer(1), Layer(9)
  1041.  DO
  1042.   _PUTIMAGE , Layer(9), Layer(1)
  1043.   Draw_Minimap_Player
  1044.   Run_Animations
  1045.   _PUTIMAGE , Layer(1), Layer(0)
  1046.   _DELAY .025
  1047.  LOOP UNTIL _KEYHIT = Control.B_Button
  1048.  
  1049. SUB Draw_MiniMap_Terrain
  1050.  _DEST Layer(1)
  1051.  LINE (122, 128)-STEP(255, 255), _RGB32(0, 32, 128), BF 'oceanic back ground
  1052.  FOR y%% = 0 TO 63
  1053.   FOR x%% = 0 TO 63
  1054.    SELECT CASE Land(x%%, y%%).Terrain
  1055.     CASE 0 'water
  1056.     CASE 1 TO 4, 8, 9, 19, 20, 21, 27, 30, 36 'shore
  1057.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(32, 96, 192), BF
  1058.     CASE 10 'grass land
  1059.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(32, 160, 0), BF
  1060.     CASE 5, 6, 7, 11 TO 18, 28, 29 'mountain
  1061.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(128, 64, 0), BF
  1062.     CASE 22 TO 24, 31 TO 33 'castle
  1063.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(224, 224, 224), BF
  1064.     CASE 25, 26, 34, 35, 37 TO 45 'forest
  1065.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(0, 96, 0), BF
  1066.     CASE 46 TO 58 'desert
  1067.      LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(224, 224, 0), BF
  1068.    END SELECT
  1069.   NEXT x%%
  1070.  NEXT y%%
  1071.  _DEST Layer(0)
  1072.  
  1073. SUB Draw_Minimap_Objects
  1074.  'sign posts, towns, treasures, armys, dwellings, artifacts
  1075.  _DEST Layer(1)
  1076.  FOR y%% = 0 TO 63
  1077.   FOR x%% = 0 TO 63
  1078.    test%% = Land(x%%, y%%).IsTreasure OR Land(x%%, y%%).IsArmy OR Land(x%%, y%%).IsArtifact OR Land(x%%, y%%).IsBand
  1079.    test%% = test%% OR Land(x%%, y%%).IsTown OR Land(x%%, y%%).IsSign OR Land(x%%, y%%).IsBlock
  1080.    IF test%% THEN
  1081.     LINE (122 + x%% * 4, 128 + y%% * 4)-STEP(3, 3), _RGB32(224, 0, 0), BF
  1082.    END IF
  1083.   NEXT x%%
  1084.  NEXT y%%
  1085.  _DEST Layer(0)
  1086.  
  1087. SUB Draw_Minimap_Player
  1088.  _DEST Layer(1)
  1089.  X%% = (P.MapXPos / 96) - 3 - .49
  1090.  Y%% = 63 - P.MapYpos / 80 - .49
  1091.  f~%% = G.Window_Animation * 48
  1092.  IF X%% < 0 THEN X%% = 0
  1093.  IF X%% > 63 THEN X%% = 63
  1094.  IF Y%% < 0 THEN Y%% = 0
  1095.  IF Y%% > 63 THEN Y%% = 63
  1096.  LINE (122 + X%% * 4, 128 + Y%% * 4)-STEP(3, 3), _RGB32(255 - f~%%, 255 - f~%%, 255 - f~%%), BF
  1097.  AX! = P.MapXPos / 96 - 3
  1098.  AX! = INT(AX! * 100)
  1099.  AY! = 63 - P.MapYpos / 80
  1100.  AY! = INT(AY! * 100)
  1101.  
  1102.  LOCATE 1, 48: PRINT X%%; Y%%; AX! / 100; AY! / 100
  1103.  _DEST Layer(0)
  1104.  
  1105. SUB Build_Stat_Window
  1106.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(8), Layer(1), (0, 15)-STEP(639, 447)
  1107.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  1108.  SELECT CASE P.Class
  1109.   CASE KNIGHT '96,104
  1110.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (464, 224)-STEP(95, 103)
  1111.   CASE PALADIN
  1112.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (560, 224)-STEP(95, 103)
  1113.   CASE SORCERESS
  1114.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (464, 328)-STEP(95, 103)
  1115.   CASE BARBARIAN
  1116.    _PUTIMAGE (16, 63)-STEP(191, 207), Layer(2), Layer(1), (560, 328)-STEP(95, 103)
  1117.  FOR i%% = 0 TO 3
  1118.   _PUTIMAGE (16 + i%% * 96, 271)-STEP(95, 175), Layer(2), Layer(1), (256, 416)-STEP(47, 87)
  1119.  NEXT i%%
  1120.  _PUTIMAGE (400, 271)-STEP(111, 175), Layer(2), Layer(1), (512, 472)-STEP(55, 87)
  1121.  _PUTIMAGE (512, 271)-STEP(111, 175), Layer(2), Layer(1), (512, 472)-STEP(55, 87)
  1122.  IF P.Maps_Aquired AND 1 THEN _PUTIMAGE (412, 287)-STEP(87, 63), Layer(2), Layer(1), (256, 504)-STEP(43, 31)
  1123.  IF P.Maps_Aquired AND 2 THEN _PUTIMAGE (412, 367)-STEP(87, 63), Layer(2), Layer(1), (256, 536)-STEP(43, 31)
  1124.  IF P.Maps_Aquired AND 4 THEN _PUTIMAGE (524, 287)-STEP(87, 63), Layer(2), Layer(1), (256, 568)-STEP(43, 31)
  1125.  IF P.Maps_Aquired AND 8 THEN _PUTIMAGE (524, 367)-STEP(87, 63), Layer(2), Layer(1), (256, 600)-STEP(43, 31)
  1126.  IF P.Artifacts_Aquired AND 1 THEN _PUTIMAGE (28, 287)-STEP(71, 63), Layer(2), Layer(1), (656, 224)-STEP(35, 31)
  1127.  IF P.Artifacts_Aquired AND 2 THEN _PUTIMAGE (28, 367)-STEP(71, 63), Layer(2), Layer(1), (656, 256)-STEP(35, 31)
  1128.  IF P.Artifacts_Aquired AND 4 THEN _PUTIMAGE (124, 287)-STEP(71, 63), Layer(2), Layer(1), (692, 224)-STEP(35, 31)
  1129.  IF P.Artifacts_Aquired AND 8 THEN _PUTIMAGE (124, 367)-STEP(71, 63), Layer(2), Layer(1), (692, 256)-STEP(35, 31)
  1130.  IF P.Artifacts_Aquired AND 16 THEN _PUTIMAGE (220, 287)-STEP(71, 63), Layer(2), Layer(1), (656, 288)-STEP(35, 31)
  1131.  IF P.Artifacts_Aquired AND 32 THEN _PUTIMAGE (220, 367)-STEP(71, 63), Layer(2), Layer(1), (656, 320)-STEP(35, 31)
  1132.  IF P.Artifacts_Aquired AND 64 THEN _PUTIMAGE (316, 287)-STEP(71, 63), Layer(2), Layer(1), (692, 288)-STEP(35, 31)
  1133.  IF P.Artifacts_Aquired AND 128 THEN _PUTIMAGE (316, 367)-STEP(71, 63), Layer(2), Layer(1), (692, 320)-STEP(35, 31)
  1134.  
  1135.  Window_Header
  1136.  
  1137.  KB_Print 210, 79, Names(P.Class) + " the " + Title(P.Class, P.Promotion), 0, LEFT
  1138.  
  1139.  KB_Print 210, 111, "Leadership", 0, LEFT
  1140.  KB_Print 210, 127, "Commission/Week", 0, LEFT
  1141.  KB_Print 210, 143, "Gold", 0, LEFT
  1142.  KB_Print 210, 159, "Spell Power", 0, LEFT
  1143.  KB_Print 210, 175, "Max # of Spells ", 0, LEFT
  1144.  KB_Print 210, 191, "Villians caught", 0, LEFT
  1145.  KB_Print 210, 207, "Artifacts found", 0, LEFT
  1146.  KB_Print 210, 223, "Castles garrisoned", 0, LEFT
  1147.  KB_Print 210, 239, "Followers killed", 0, LEFT
  1148.  KB_Print 210, 255, "Current score", 0, LEFT
  1149.  
  1150.  KB_Print 600, 111, STR$(P.Leadership), 0, RIGHT
  1151.  KB_Print 600, 127, STR$(P.Commission), 0, RIGHT
  1152.  KB_Print 600, 143, STR$(P.Gold), 0, RIGHT
  1153.  KB_Print 600, 159, STR$(P.SpellPower), 0, RIGHT
  1154.  KB_Print 600, 175, STR$(P.MaxSpells), 0, RIGHT
  1155.  KB_Print 600, 191, STR$(P.VilliansCaught), 0, RIGHT
  1156.  KB_Print 600, 207, STR$(P.Artifacts), 0, RIGHT
  1157.  KB_Print 600, 223, STR$(P.Castles), 0, RIGHT
  1158.  KB_Print 600, 239, STR$(P.Deaths), 0, RIGHT
  1159.  KB_Print 600, 255, STR$(P.Score), 0, RIGHT
  1160.  _PUTIMAGE , Layer(1), Layer(0)
  1161.  DO: _DELAY .01: LOOP UNTIL _KEYHIT = Control.B_Button
  1162.  
  1163. SUB Build_Main_Window
  1164.  _PUTIMAGE , Layer(8), Layer(1)
  1165.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  1166.  Window_Header
  1167.  _PUTIMAGE (496, 47)-STEP(143, 415), Layer(2), Layer(1), (728, 192)-STEP(71, 207)
  1168.  _PUTIMAGE (524, 63)-STEP(87, 63), Layer(4), Layer(1), (240, 704)-STEP(43, 31)
  1169.  _PUTIMAGE (524, 143)-STEP(87, 63), Layer(4), Layer(1), (372, 672)-STEP(43, 31)
  1170.  _PUTIMAGE (524, 223)-STEP(87, 63), Layer(4), Layer(1), (328, 672)-STEP(43, 31)
  1171.  _PUTIMAGE (524, 303)-STEP(87, 63), Layer(4), Layer(1), (240, 672)-STEP(43, 31)
  1172.  _PUTIMAGE (524, 383)-STEP(87, 63), Layer(4), Layer(1), (284, 672)-STEP(43, 31)
  1173.  Draw_Coins
  1174.  Cover_Puzzle
  1175.  Run_Animations
  1176.  
  1177. SUB Draw_Coins
  1178.  Gp~% = P.Gold \ 10000
  1179.  Sp%% = (P.Gold \ 1000) MOD 10
  1180.  Cp%% = (P.Gold \ 100) MOD 10
  1181.  IF Gp~% > 10 THEN Gp~% = 10: Sp%% = 10: Cp%% = 10 'over 100k gold all stacks full!
  1182.  FOR i%% = 1 TO 10
  1183.   IF i%% <= Gp~% THEN _PUTIMAGE (530, 431 - 4 * i%%)-STEP(15, 9), Layer(2), Layer(1), (364, 219)-STEP(7, 4)
  1184.   IF i%% <= Sp%% THEN _PUTIMAGE (560, 431 - 4 * i%%)-STEP(15, 9), Layer(2), Layer(1), (372, 219)-STEP(7, 4)
  1185.   IF i%% <= Cp%% THEN _PUTIMAGE (592, 431 - 4 * i%%)-STEP(15, 9), Layer(2), Layer(1), (380, 219)-STEP(7, 4)
  1186.  NEXT i%%
  1187.  
  1188. SUB Cover_Puzzle
  1189.  FOR i%% = 0 TO 24
  1190.   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)
  1191.   x%% = x%% + 16
  1192.   IF x%% = 80 THEN x%% = 0: y%% = y%% + 12
  1193.  NEXT i%%
  1194.  
  1195. SUB Magic_Animation
  1196.  IF P.Magic_Learned THEN
  1197.   _PUTIMAGE (524, 223)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 576)-STEP(43, 31) 'magic power frames
  1198.  
  1199. SUB Seige_Animation
  1200.  IF P.Seige_Bought THEN
  1201.   _PUTIMAGE (524, 143)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 544)-STEP(43, 31) 'magic power frames
  1202.  
  1203. SUB Contract_Animation (Loca%%)
  1204.  IF Loca%% = MAIN THEN Xo% = 524: Yo% = 63 ELSE Xo% = 211: Yo% = 91
  1205.  IF P.Current_Contract THEN
  1206.   y% = 32 * (P.Current_Contract - 1)
  1207.   _PUTIMAGE (Xo%, Yo%)-STEP(87, 63), Layer(4), Layer(1), (240 + (44 * G.Window_Animation), 0 + y%)-STEP(43, 31) 'magic power frames
  1208.  
  1209. SUB Build_Spell_Window
  1210.  
  1211.  FOR i%% = 1 TO 7
  1212.   IF Last_Cast = 0 AND PX.Spells(i%%) <> 0 THEN Last_Cast = i%%
  1213.   ASPC%% = ASPC%% + PX.Spells(i%%)
  1214.   CSPC%% = CSPC%% + PX.Spells(7 + i%%)
  1215.  NEXT i%%
  1216.  
  1217.  _PUTIMAGE (90, 80)-STEP(319, 351), Layer(2), Layer(1), (304, 224)-STEP(159, 175)
  1218.  _PUTIMAGE (100, 74)-STEP(299, 347), Layer(8), Layer(1), (0, 0)-STEP(299, 347)
  1219.  KB_Print 90, 98, "Adventuring Spells", 0, LEFT
  1220.  KB_Print 122, 276, "Combat Spells", 0, LEFT
  1221.  FOR i%% = 1 TO 7
  1222.   KB_Print 154, 114 + i%% * 16, LTRIM$(STR$(PX.Spells(i%%))), 0, RIGHT
  1223.   KB_Print 170, 114 + i%% * 16, Spells(i%%).Spell_Name, 0, LEFT
  1224.   KB_Print 154, 290 + i%% * 16, LTRIM$(STR$(PX.Spells(7 + i%%))), 0, RIGHT
  1225.   KB_Print 170, 290 + i%% * 16, Spells(7 + i%%).Spell_Name, 0, LEFT
  1226.  NEXT i%%
  1227.  
  1228.  IF G.In_Combat THEN
  1229.   IF CSPC%% = 0 THEN
  1230.    _PUTIMAGE (16, 29)-STEP(608, 17), Layer(8), Layer(1), (0, 16)-STEP(608, 17)
  1231.    KB_Print 2, 31, "You have no Combat Spell to cast!", 0, LEFT
  1232.   ELSE
  1233.    Spell_Selection
  1234.   END IF
  1235.   IF ASPC%% = 0 THEN
  1236.    _PUTIMAGE (16, 29)-STEP(608, 17), Layer(8), Layer(1), (0, 16)-STEP(608, 17)
  1237.    KB_Print 2, 31, "You have no Adventuring Spell to cast!", 0, LEFT
  1238.   ELSE
  1239.    Spell_Selection
  1240.   END IF
  1241.  
  1242. SUB Display_Selection_Arrow (X%, Y%)
  1243.  _PUTIMAGE (X%, Y%)-STEP(23, 15), Layer(2), Layer(1), (388 + G.Window_Animation * 12, 216)-STEP(11, 7)
  1244.  
  1245. SUB Spell_Selection
  1246.  STATIC Last_Combat AS _BYTE, Last_Adventure AS _BYTE
  1247.  IF PX.Spells(Last_Combat) = 0 THEN Last_Combat = 0
  1248.  IF PX.Spells(Last_Adventure) = 0 THEN Last_Adventure = 0
  1249.  
  1250.  FOR i%% = 1 TO 7
  1251.   IF Last_Combat = 0 AND PX.Spells(7 + i%%) <> 0 THEN Last_Combat = 7 + i%%
  1252.   IF Last_Adventure = 0 AND PX.Spells(i%%) <> 0 THEN Last_Adventure = i%%
  1253.  NEXT i%%
  1254.  _PUTIMAGE , Layer(1), Layer(9) 'save screen so we don't have to constantly recreate it.
  1255.  
  1256.  IF G.In_Combat THEN Selection%% = Last_Combat ELSE Selection%% = Last_Adventure
  1257.  
  1258.  DO
  1259.   KBD& = _KEYHIT
  1260.   SELECT CASE KBD&
  1261.    CASE Control.Up_Key
  1262.     good%% = FALSE
  1263.     Selection%% = Selection%% - 1
  1264.     DO
  1265.      'find next available spell
  1266.      IF G.In_Combat AND Selection%% = 7 THEN Selection%% = 14
  1267.      IF NOT G.In_Combat AND Selection%% = 0 THEN Selection%% = 7
  1268.      IF PX.Spells(Selection%%) THEN good%% = TRUE ELSE Selection%% = Selection%% - 1
  1269.     LOOP UNTIL good%%
  1270.    CASE Control.Down_Key
  1271.     good%% = FALSE
  1272.     Selection%% = Selection%% + 1
  1273.     DO
  1274.      'find next available spell
  1275.      IF G.In_Combat AND Selection%% = 15 THEN Selection%% = 8
  1276.      IF NOT G.In_Combat AND Selection%% = 8 THEN Selection%% = 1
  1277.      IF PX.Spells(Selection%%) THEN good%% = TRUE ELSE Selection%% = Selection%% + 1
  1278.     LOOP UNTIL good%%
  1279.    CASE Control.A_Button
  1280.     IF G.In_Combat THEN Last_Combat = Selection%% ELSE Last_Adventure = Selection%%
  1281.     exitflag%% = TRUE
  1282.     PX.Spells(Selection%%) = PX.Spells(Selection%%) - 1
  1283.     Cast_Spells Selection%%
  1284.    CASE Control.B_Button
  1285.     exitflag%% = TRUE
  1286.    CASE MASTERESC
  1287.     exitflag%% = TRUE
  1288.   _PUTIMAGE , Layer(9), Layer(1)
  1289.   IF G.In_Combat THEN
  1290.    Display_Selection_Arrow 112, 288 + (16 * (Selection%% - 7)) 'in combat
  1291.   ELSE
  1292.    Display_Selection_Arrow 112, 114 + (16 * Selection%%) 'adventuring
  1293.   END IF
  1294.   Run_Animations
  1295.   _PUTIMAGE , Layer(1), Layer(0)
  1296.   LOCATE 1, 1: PRINT Selection%%
  1297.   _DELAY .025
  1298.  LOOP UNTIL exitflag%%
  1299.  
  1300. SUB Cast_Spells (Spell%%)
  1301.  SELECT CASE Spell%%
  1302.   CASE 1 'bridge spell
  1303.   CASE 2 'TimeStop Spell
  1304.    G.TimeStop = G.TimeStop + (10 * P.SpellPower)
  1305.   CASE 3 'Find Villain
  1306.    Villains(P.Current_Contract).Is_Known = Villains(P.Current_Contract).Castle
  1307.   CASE 4 'castle gate
  1308.    FOR i%% = 1 TO 26
  1309.     v%% = v%% + ABS(Castles(i%%).Visited) 'has player been to any castles?
  1310.    NEXT i%%
  1311.    IF v%% = 0 THEN G.HDR_Text = "  You have not been to any castles!": Window_Header
  1312.    IF v%% THEN Build_Gate_Window CASTLE
  1313.   CASE 5 'town gate
  1314.    FOR i%% = 1 TO 26
  1315.     v%% = v%% + ABS(Towns(i%%).Visited) 'has player been to any towns?
  1316.    NEXT i%%
  1317.    IF v%% = 0 THEN G.HDR_Text = "   You have not been to any towns!": Window_Header
  1318.    IF v%% THEN Build_Gate_Window TOWN
  1319.   CASE 6 'Instant Army
  1320.   CASE 7 'Raise control
  1321.    P.Control_Bonus = P.Control_Bonus + 100 * P.SpellPower
  1322.    IF P.Control_Bonus + P.Leadership > 65535 THEN P.Control_Bonus = 65535 - P.Leadership
  1323.  
  1324. SUB Build_Gate_Window (Spell%%)
  1325.  Build_Main_Window
  1326.  _PUTIMAGE (15, 63)-STEP(479, 383), Layer(2), Layer(1), (560, 0)-STEP(239, 191)
  1327.  IF Spell%% = TOWN THEN a$ = "Towns" ELSE a$ = "Castles"
  1328.  KB_Print 48, 96, a$ + " you have been to", 0, LEFT
  1329.  KB_Print 80, 384, "Revisit which " + a$, 0, LEFT
  1330.  FOR i%% = 1 TO 13
  1331.   IF Spell%% = TOWN AND Towns(i%%).Visited THEN
  1332.    KB_Print 48, 128 + i%% * 16, Towns(i%%).The_Name, 0, LEFT
  1333.    KB_Print 272, 128 + i%% * 16, Towns(13 + i%%).The_Name, 0, LEFT
  1334.   END IF
  1335.   IF Spell%% = CASTLE AND Castles(i%%).Visited THEN
  1336.    KB_Print 48, 128 + i%% * 16, Castles(i%%).The_Name, 0, LEFT
  1337.    KB_Print 272, 128 + i%% * 16, Castles(13 + i%%).The_Name, 0, LEFT
  1338.   END IF
  1339.  NEXT i%%
  1340.  
  1341. SUB Gate_Selection
  1342.  _PUTIMAGE , Layer(1), Layer(9) 'save screen so we don't have to constantly recreate it.
  1343.  
  1344.  IF G.In_Combat THEN Selection%% = Last_Combat ELSE Selection%% = Last_Adventure
  1345.  
  1346.  DO
  1347.   KBD& = _KEYHIT
  1348.   SELECT CASE KBD&
  1349.    CASE Control.Up_Key
  1350.     good%% = FALSE
  1351.     Selection%% = Selection%% - 1
  1352.     DO
  1353.      'find next available town or castle
  1354.      IF Selection%% < 1 THEN Selection%% = 26
  1355.      IF Towns(Selection%%).Visited THEN good%% = TRUE ELSE Selection%% = Selection%% + 1
  1356.     LOOP UNTIL good%%
  1357.    CASE Control.Down_Key
  1358.     good%% = FALSE
  1359.     Selection%% = Selection%% + 1
  1360.     DO
  1361.      'find next available town or castle
  1362.      IF Selection%% > 26 THEN Selection%% = 1
  1363.      IF Towns(Selection%%).Visited THEN good%% = TRUE ELSE Selection%% = Selection%% + 1
  1364.     LOOP UNTIL good%%
  1365.    CASE Control.A_Button
  1366.     exitflag%% = TRUE
  1367.    CASE Control.B_Button
  1368.     exitflag%% = TRUE
  1369.    CASE MASTERESC
  1370.     exitflag%% = TRUE
  1371.  
  1372.   _PUTIMAGE , Layer(9), Layer(1)
  1373.   IF Selection%% < 13 THEN x%% = 16: y%% = Selection%% ELSE x%% = 250: y%% = Selection%% - 13
  1374.   Display_Selection_Arrow x%%, 128 + (16 * y%%) 'adventuring
  1375.  
  1376.   _PUTIMAGE , Layer(1), Layer(0)
  1377.   _DELAY .025
  1378.  LOOP UNTIL exitflag%%
  1379.  
  1380. SUB Build_Puzzle_Window
  1381.  
  1382.  X%% = G.Scepter_X ' / 48
  1383.  Y%% = G.Scepter_Y ' / 40
  1384.  Land%% = 13 + G.Scepter_Land
  1385.  sy%% = Y%% - 2
  1386.  sx%% = X%% - 2
  1387.  IF sy%% < 0 THEN sy%% = 0
  1388.  IF sx%% < 0 THEN sx%% = 0
  1389.  _PUTIMAGE (16, 64)-STEP(479, 383), Layer(13), Layer(1), (288 + 96 * sx%%, 224 + 80 * sy%%)-STEP(479, 383)
  1390.  
  1391.  _PUTIMAGE (16, 63)-STEP(239, 383), Layer(2), Layer(1), (0, 416)-STEP(119, 191)
  1392.  _PUTIMAGE (494, 63)-STEP(-239, 383), Layer(2), Layer(1), (0, 416)-STEP(119, 191)
  1393.  _PUTIMAGE , Layer(1), Layer(9)
  1394.  xo% = 36: yo% = 95
  1395.  DO
  1396.   _PUTIMAGE , Layer(9), Layer(1)
  1397.   FOR Y%% = 0 TO 4
  1398.    FOR X%% = 0 TO 4
  1399.     IF Puzzle(X%%, Y%%) > 16 THEN
  1400.      y% = 32 * (Puzzle(X%%, Y%%) - 17)
  1401.      IF NOT Villains(Puzzle(X%%, Y%%) - 17).Caught THEN
  1402.       _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
  1403.      END IF
  1404.     ELSE
  1405.      IF Puzzle(X%%, Y%%) >= 4 THEN y% = 32 * 20: XA%% = Puzzle(X%%, Y%%) - 4 ELSE y% = 32 * 19: XA%% = Puzzle(X%%, Y%%)
  1406.      IF (P.Artifacts_Aquired AND 2 ^ Puzzle(X%%, Y%%)) = FALSE THEN
  1407.       _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
  1408.      END IF
  1409.     END IF
  1410.    NEXT X%%
  1411.   NEXT Y%%
  1412.   Run_Animations
  1413.   _PUTIMAGE , Layer(1), Layer(0)
  1414.   _DELAY .025
  1415.  
  1416.  LOOP UNTIL _KEYHIT = Control.B_Button
  1417.  
  1418. SUB Build_Menu_Window
  1419.  STATIC Last_Choice AS _BYTE
  1420.  G.In_Menu = TRUE
  1421.  '304,472  208,128
  1422.  _PUTIMAGE (48, 127)-STEP(415, 255), Layer(8), Layer(1), (48, 160)-STEP(415, 255)
  1423.  _PUTIMAGE (48, 127)-STEP(415, 255), Layer(2), Layer(1), (304, 472)-STEP(207, 127)
  1424.  _PUTIMAGE , Layer(1), Layer(9)
  1425.  Selection%% = Last_Choice
  1426.  IF Selection%% = 0 THEN Selection%% = 1
  1427.  
  1428.  DO
  1429.   KBD& = _KEYHIT
  1430.   SELECT CASE KBD&
  1431.    CASE Control.Up_Key
  1432.     Selection%% = Selection%% - 1
  1433.     IF Selection%% <= 0 THEN Selection%% = 12 'correction for the gap in choices
  1434.     IF Selection%% = 11 THEN Selection%% = 10 'correction for the gap in choices
  1435.    CASE Control.Down_Key
  1436.     Selection%% = Selection%% + 1
  1437.     IF Selection%% >= 13 THEN Selection%% = 1
  1438.    CASE Control.A_Button
  1439.     Last_Choice = Selection%%
  1440.     RunIt%% = TRUE
  1441.     exitflag%% = TRUE
  1442.    CASE Control.B_Button
  1443.     exitflag%% = TRUE
  1444.    CASE MASTERESC
  1445.     exitflag%% = TRUE
  1446.     G.QuitGame = TRUE
  1447.   _PUTIMAGE , Layer(9), Layer(1)
  1448.   IF Selection%% = 11 THEN Selection%% = 12 'correction for the gap in choices
  1449.   Display_Selection_Arrow 69, 140 + (16 * Selection%%) 'adventuring
  1450.   Run_Animations
  1451.   _PUTIMAGE , Layer(1), Layer(0)
  1452.   LOCATE 1, 1: PRINT Selection%%
  1453.   _DELAY .025
  1454.  LOOP UNTIL exitflag%%
  1455.  IF RunIt%% THEN Run_Menu_Choice Selection%%
  1456.  G.In_Menu = FALSE
  1457.  
  1458. SUB Run_Menu_Choice (Opt%%)
  1459.  Build_Main_Window
  1460.  Build_Map_View2
  1461.  Draw_Player
  1462.  SELECT CASE Opt%%
  1463.   CASE 1 'view army
  1464.    Build_Army_Window
  1465.   CASE 2 'view stats
  1466.    Build_Stat_Window
  1467.   CASE 3 'view mini map
  1468.    Build_MiniMap_Window
  1469.   CASE 4 'use spells
  1470.    Build_Spell_Window
  1471.   CASE 5 'view contract info
  1472.    Build_Contract_Window
  1473.   CASE 6 'wait till end of week
  1474.    IF G.TimeStop THEN G.TimeStop = 0
  1475.    drop%% = G.Days MOD 10
  1476.    IF drop%% = 0 OR drop%% = 5 THEN G.Days = G.Days - 5 ELSE G.Days = G.Days - (G.Days MOD 5)
  1477.    Build_EndOfWeek_Window
  1478.   CASE 7 'look at puzzle
  1479.    Build_Puzzle_Window
  1480.   CASE 8 'search area
  1481.    Build_Search_Window
  1482.   CASE 9 'dismiss army
  1483.    Build_Dismiss_Window
  1484.   CASE 10 'game options
  1485.    Build_Control_Window
  1486.   CASE 12 'save game
  1487.  G.In_Menu = TRUE
  1488.  
  1489. SUB Build_Dismiss_Window
  1490.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(8), Layer(1), (16, 300)-STEP(479, 147)
  1491.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(2), Layer(1), (320, 0)-STEP(239, 73)
  1492.  KB_Print 80, 316, "Dismiss which army?", 0, LEFT
  1493.  _PUTIMAGE , Layer(1), Layer(9)
  1494.  Selection%% = 0
  1495.  DO
  1496.   KBD& = _KEYHIT
  1497.   SELECT CASE KBD&
  1498.    CASE Control.Up_Key
  1499.     Selection%% = Selection%% - 1
  1500.     IF Selection%% <= -1 THEN Selection%% = 0
  1501.    CASE Control.Down_Key
  1502.     Selection%% = Selection%% + 1
  1503.     IF Selection%% >= 4 THEN Selection%% = Selection%% - 1
  1504.     IF PX.Army(Selection%%).Unit = 0 THEN Selection%% = Selection%% - 1
  1505.    CASE Control.A_Button
  1506.     IF Selection%% = 0 THEN 'check and make sure player has more than one army
  1507.      IF PX.Army(1).Unit = 0 THEN 'player is trying to dismiss last army
  1508.       _PUTIMAGE , Layer(9), Layer(1)
  1509.       _PUTIMAGE (16, 31)-STEP(606, 15), Layer(8), Layer(1), (16, 31)-STEP(606, 15)
  1510.       KB_Print 2, 31, "  You man not dismiss your last army!", 0, LEFT
  1511.       _PUTIMAGE , Layer(1), Layer(9)
  1512.      ELSE
  1513.       Dismiss_Army Selection%%
  1514.      END IF
  1515.     ELSE 'if player isn't dismissing army 0 then they have more than one.
  1516.      Dismiss_Army Selection%%
  1517.      Selection%% = Selection%% - 1 'bump the arrow up one space
  1518.     END IF
  1519.    CASE Control.B_Button
  1520.     exitflag%% = TRUE
  1521.    CASE MASTERESC
  1522.     exitflag%% = TRUE
  1523.   _PUTIMAGE , Layer(9), Layer(1)
  1524.   FOR i%% = 0 TO 4
  1525.    IF PX.Army(i%%).Unit THEN KB_Print 272, 348 + i%% * 16, Units(PX.Army(i%%).Unit).Unit_Name, 0, CENTER
  1526.   NEXT i%%
  1527.   Display_Selection_Arrow 164, 346 + (16 * Selection%%)
  1528.   Run_Animations
  1529.   _PUTIMAGE , Layer(1), Layer(0)
  1530.   _DELAY .025
  1531.  LOOP UNTIL exitflag%%
  1532.  
  1533. SUB Dismiss_Army (Unit%%)
  1534.  FOR i%% = Unit%% TO 3
  1535.   SWAP PX.Army(i%%), PX.Army(i%% + 1)
  1536.  NEXT i%%
  1537.  PX.Army(i%%).Unit = 0
  1538.  PX.Army(i%%).Count = 0
  1539.  
  1540. SUB Build_Search_Window
  1541.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(8), Layer(1), (16, 300)-STEP(479, 147)
  1542.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(2), Layer(1), (320, 0)-STEP(239, 73)
  1543.  KB_Print 16, 316, "Search...", 0, LEFT
  1544.  a$ = "It will take"
  1545.  IF P.VilliansCaught = 17 THEN a$ = a$ + " 1 " ELSE a$ = a$ + " 10 "
  1546.  a$ = a$ + "day to do a"
  1547.  KB_Print 24, 348, a$, 0, LEFT
  1548.  KB_Print 16, 364, "search of this area, search?", 0, LEFT
  1549.  KB_Print 224, 396, "No", 0, LEFT
  1550.  KB_Print 224, 412, "Yes", 0, LEFT
  1551.  _PUTIMAGE , Layer(1), Layer(9)
  1552.  Selection%% = 0
  1553.  DO
  1554.   KBD& = _KEYHIT
  1555.   SELECT CASE KBD&
  1556.    CASE Control.Up_Key
  1557.     Selection%% = 0
  1558.    CASE Control.Down_Key
  1559.     Selection%% = 1
  1560.    CASE Control.A_Button
  1561.     exitflag%% = TRUE
  1562.     IF Selection%% = 1 THEN search_area
  1563.    CASE Control.B_Button
  1564.     exitflag%% = TRUE
  1565.    CASE MASTERESC
  1566.     exitflag%% = TRUE
  1567.     G.QuitGame = TRUE
  1568.   _PUTIMAGE , Layer(9), Layer(1)
  1569.   Display_Selection_Arrow 212, 394 + (16 * Selection%%)
  1570.   Run_Animations
  1571.   _PUTIMAGE , Layer(1), Layer(0)
  1572.   _DELAY .025
  1573.  LOOP UNTIL exitflag%%
  1574.  
  1575. SUB search_area
  1576.  X%% = P.MapXPos / 48
  1577.  Y%% = 63 - P.MapYpos / 40
  1578.  IF Land(X%%, Y%%).IsScepter THEN
  1579.   G.WinGame = TRUE
  1580.   IF P.VilliansCaught = 17 THEN
  1581.    G.TimeStop = 0
  1582.    G.Days = G.Days - 1
  1583.   ELSE
  1584.    G.TimeStop = 0
  1585.    G.Days = G.Days - 5
  1586.    Build_Main_Window
  1587.    Build_Map_View
  1588.    Draw_Player
  1589.    Build_EndOfWeek_Window
  1590.    Draw_Coins
  1591.    G.Days = G.Days - 5
  1592.    Build_Main_Window
  1593.    Build_Map_View
  1594.    Draw_Player
  1595.    Build_EndOfWeek_Window
  1596.   END IF
  1597.  
  1598. SUB Build_Victory_March
  1599.  py% = 0: px%% = 4
  1600.  DO
  1601.   FOR y%% = 0 TO 5
  1602.    FOR x%% = 0 TO 6
  1603.     _PUTIMAGE (0 + x%% * 96, 63 + y%% * 80)-STEP(95, 79), Layer(3), Layer(1), (0 + 48 * 10, 0 + 40 * 0)-STEP(47, 39)
  1604.    NEXT x%%
  1605.   NEXT y%%
  1606.   x%% = 0: y%% = 0: Facing%% = RIGHT_FACE
  1607.   FOR i%% = 1 TO 25
  1608.    Unit_Animation 28 + x%% * 98, 63 + y%% * 80, i%%, Facing%%
  1609.    x%% = x%% + 1
  1610.    IF x%% = 4 THEN x%% = 5: Facing%% = LEFT_FACE 'skip this space and flip facing
  1611.    IF x%% = 6 THEN x%% = 0: y%% = y%% + 1: Facing%% = RIGHT_FACE
  1612.   NEXT i%%
  1613.   _PUTIMAGE (28 + px%% * 98, 630 - py%)-STEP(87, 63), Layer(5), Layer(1), (0 + G.Window_Animation * 44, 800 + 2 * 32)-STEP(43, 31)
  1614.  
  1615.   _PUTIMAGE (0, 15)-STEP(639, 32), Layer(8), Layer(1), (0, 15)-STEP(639, 32)
  1616.   _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  1617.   Window_Header
  1618.  
  1619.   _PUTIMAGE (0, 0), Layer(1), Layer(10), (0, 15)-STEP(639, 448)
  1620.   _PUTIMAGE (0, 15), Layer(10), Layer(0)
  1621.   _DELAY .02
  1622.   py% = py% + 3
  1623.   IF py% = 639 THEN exitflag%% = TRUE
  1624.  LOOP UNTIL INKEY$ = CHR$(27) OR exitflag%%
  1625.  Display_Victory
  1626.  
  1627. SUB Display_Victory
  1628.  _DEST Layer(1)
  1629.  LINE (0, 0)-STEP(639, 479), _RGB32(0, 0, 0), BF
  1630.  _DEST Layer(0)
  1631.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(8), Layer(1), (0, 15)-STEP(639, 447)
  1632.  _PUTIMAGE (0, 15)-STEP(639, 447), Layer(2), Layer(1), (0, 0)-STEP(319, 223)
  1633.  Window_Header
  1634.  _PUTIMAGE (16, 63)-STEP(287, 383), Layer(6), Layer(1), (640, 0)-STEP(143, 191)
  1635.  _PUTIMAGE (304, 63)-STEP(319, 383), Layer(6), Layer(1), (640, 192)-STEP(159, 191)
  1636.  KB_Print 304, 112, Names(P.Class) + "!", 0, LEFT
  1637.  KB_Print 592, 400, STR$(Player_Score), 0, RIGHT
  1638.  _PUTIMAGE , Layer(1), Layer(0)
  1639.  
  1640. SUB Build_Control_Window
  1641.  _PUTIMAGE (96, 175)-STEP(319, 143), Layer(8), Layer(1), (96, 175)-STEP(319, 143)
  1642.  _PUTIMAGE (96, 175)-STEP(319, 143), Layer(2), Layer(1), (304, 400)-STEP(159, 71)
  1643.  _PUTIMAGE , Layer(1), Layer(9)
  1644.  Selection%% = 0
  1645.  DO
  1646.   KBD& = _KEYHIT
  1647.   SELECT CASE KBD&
  1648.    CASE Control.Up_Key
  1649.     Selection%% = Selection%% - 1
  1650.     IF Selection%% = -1 THEN Selection%% = 0
  1651.    CASE Control.Down_Key
  1652.     Selection%% = Selection%% + 1
  1653.     IF Selection%% = 3 THEN Selection%% = 2
  1654.    CASE Control.A_Button
  1655.     Run_Control_Option Selection%%
  1656.    CASE Control.B_Button
  1657.     exitflag%% = TRUE
  1658.    CASE Control.C_Button 'used for decreasing combat speed
  1659.     Run_Control_Option Selection%% + 10
  1660.    CASE MASTERESC
  1661.     exitflag%% = TRUE
  1662.     G.QuitGame = TRUE
  1663.   _PUTIMAGE , Layer(9), Layer(1)
  1664.   Display_Selection_Arrow 128, 238 + (16 * Selection%%)
  1665.   IF G.BGM THEN BGMV$ = "on" ELSE BGMV$ = "off"
  1666.   IF G.SFX THEN SFXV$ = "on" ELSE SFXV$ = "off"
  1667.   KB_Print 240, 239, BGMV$, 0, LEFT
  1668.   KB_Print 240, 255, SFXV$, 0, LEFT
  1669.   KB_Print 336, 271, STR$(G.Combat_speed), 0, LEFT
  1670.   Run_Animations
  1671.  
  1672.   _PUTIMAGE , Layer(1), Layer(0)
  1673.   _DELAY .025
  1674.  LOOP UNTIL exitflag%%
  1675.  
  1676. SUB Run_Control_Option (Opt%%)
  1677.  SELECT CASE Opt%%
  1678.   CASE 0 'Back ground music
  1679.    IF G.BGM = TRUE THEN G.BGM = FALSE ELSE G.BGM = TRUE
  1680.   CASE 1 'Sound FX
  1681.    IF G.SFX = TRUE THEN G.SFX = FALSE ELSE G.SFX = TRUE
  1682.   CASE 2 'Combat speed faster
  1683.    G.Combat_speed = G.Combat_speed - 1
  1684.    IF G.Combat_speed = -1 THEN G.Combat_speed = 9
  1685.   CASE 12 'combat speed slower
  1686.    G.Combat_speed = G.Combat_speed + 1
  1687.    IF G.Combat_speed = 10 THEN G.Combat_speed = 0
  1688.   CASE 3 'extra options
  1689.    Build_Extra_Options_Window
  1690.    Build_Main_Window
  1691.    Build_Map_View
  1692.    Draw_Player
  1693.    _PUTIMAGE (96, 175)-STEP(319, 143), Layer(8), Layer(1), (96, 175)-STEP(319, 143)
  1694.    _PUTIMAGE (96, 175)-STEP(319, 143), Layer(2), Layer(1), (304, 400)-STEP(159, 71)
  1695.    _PUTIMAGE , Layer(1), Layer(9)
  1696.  
  1697. SUB Build_Extra_Options_Window
  1698.  _PUTIMAGE , Layer(9), Layer(1)
  1699.  _PUTIMAGE (90, 79)-STEP(319, 351), Layer(8), Layer(1), (90, 79)-STEP(319, 351)
  1700.  _PUTIMAGE (90, 79)-STEP(319, 351), Layer(2), Layer(1), (304, 224)-STEP(159, 175)
  1701.  KB_Print 232, 96, "Xtra Options", 0, CENTER
  1702.  _DEST Layer(1)
  1703.  LINE (152, 112)-STEP(192, 1), _RGB32(255, 255, 255), BF
  1704.  LINE (154, 114)-STEP(192, 1), _RGB32(16, 96, 16), BF
  1705.  _DEST Layer(0)
  1706.  KB_Print 232, 128, "Music Volume: ", 0, CENTER
  1707.  KB_Print 232, 144, "Sound Volume: ", 0, CENTER
  1708.  KB_Print 120, 176, "Up      : UP Arw", 0, LEFT
  1709.  KB_Print 120, 192, "Down    : DN Arw", 0, LEFT
  1710.  KB_Print 120, 208, "Left    : LT Arw", 0, LEFT
  1711.  KB_Print 120, 224, "Right   : RT Arw", 0, LEFT
  1712.  KB_Print 120, 240, "A Button: A", 0, LEFT
  1713.  KB_Print 120, 256, "B Button: S", 0, LEFT
  1714.  KB_Print 120, 272, "C Button: D", 0, LEFT
  1715.  KB_Print 120, 288, "Start   : Enter", 0, LEFT
  1716.  _PUTIMAGE , Layer(1), Layer(9)
  1717.  
  1718.  Selection%% = 0
  1719.  DO
  1720.   KBD& = _KEYHIT
  1721.   SELECT CASE KBD&
  1722.    CASE Control.Up_Key
  1723.     Selection%% = Selection%% - 1
  1724.     IF Selection%% = -1 THEN Selection%% = 0
  1725.    CASE Control.Down_Key
  1726.     Selection%% = Selection%% + 1
  1727.     IF Selection%% = 2 THEN Selection%% = 1
  1728.    CASE Control.A_Button
  1729.     Run_Extra_Option Selection%%
  1730.    CASE Control.B_Button
  1731.     exitflag%% = TRUE
  1732.    CASE Control.C_Button 'used for decreasing
  1733.     Run_Extra_Option Selection%% + 10
  1734.    CASE MASTERESC
  1735.     exitflag%% = TRUE
  1736.     G.QuitGame = TRUE
  1737.  
  1738.   _PUTIMAGE , Layer(9), Layer(1)
  1739.   Display_Selection_Arrow 108, 125 + (16 * Selection%%)
  1740.   KB_Print 368, 129, STR$(G.BGM_VOL), 0, RIGHT
  1741.   KB_Print 368, 145, STR$(G.SFX_VOL), 0, RIGHT
  1742.   Run_Animations
  1743.   _PUTIMAGE , Layer(1), Layer(0)
  1744.   _DELAY .025
  1745.  LOOP UNTIL exitflag%%
  1746.  
  1747. SUB Run_Extra_Option (Opt%%)
  1748.  SELECT CASE Opt%%
  1749.   CASE 0 'Back ground music vol-
  1750.    IF G.BGM_VOL > 0 THEN G.BGM_VOL = G.BGM_VOL - 2
  1751.   CASE 1 'Sound FX vol-
  1752.    IF G.SFX_VOL > 0 THEN G.SFX_VOL = G.SFX_VOL - 2
  1753.   CASE 10 'Back ground music vol+
  1754.    IF G.BGM_VOL < 100 THEN G.BGM_VOL = G.BGM_VOL + 2
  1755.   CASE 11 'Sound FX vol+
  1756.    IF G.SFX_VOL < 100 THEN G.SFX_VOL = G.SFX_VOL + 2
  1757.  
  1758. SUB Build_EndOfWeek_Window
  1759.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(8), Layer(1), (16, 300)-STEP(479, 147)
  1760.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(2), Layer(1), (320, 0)-STEP(239, 73)
  1761.  KB_Print 16, 316, "Week #" + EOW_Week, 0, LEFT
  1762.  KB_Print 16, 348, "Astrologers proclaim:", 0, LEFT
  1763.  Dwelling$ = EOW_Dwelling
  1764.  KB_Print 16, 364, "Week of the " + Dwelling$, 0, LEFT
  1765.  KB_Print 16, 396, "All " + Dwelling$ + " dwellings are", 0, LEFT
  1766.  KB_Print 16, 412, "repopulated.", 0, LEFT
  1767.  
  1768.  DO
  1769.   KBD& = _KEYHIT
  1770.   SELECT CASE KBD&
  1771.    CASE Control.A_Button, Control.B_Button, Control.C_Button
  1772.     exitflag%% = TRUE
  1773.   Run_Animations
  1774.   _PUTIMAGE , Layer(1), Layer(0)
  1775.   _DELAY .025
  1776.  LOOP UNTIL exitflag%%
  1777.  exitflag%% = FALSE
  1778.  Build_Budget_window
  1779.  
  1780. FUNCTION EOW_Week$
  1781.  SELECT CASE G.Level
  1782.   CASE 1
  1783.    Result$ = STR$((900 - G.Days) / 5)
  1784.   CASE 2
  1785.    Result$ = STR$((600 - G.Days) / 5)
  1786.   CASE 4
  1787.    Result$ = STR$((400 - G.Days) / 5)
  1788.   CASE 8
  1789.    Result$ = STR$((200 - G.Days) / 5)
  1790.  Result$ = LTRIM$(Result$)
  1791.  EOW_Week = Result$
  1792.  
  1793. FUNCTION EOW_Dwelling$
  1794.  Un%% = INT(RND * 25) + 1
  1795.  IF VAL(EOW_Week) MOD 20 = 0 THEN
  1796.   Result$ = Units(1).Unit_Name
  1797.   Repopulate 1
  1798.   Change_Ghosts
  1799.   Result$ = Units(Un%%).Unit_Name
  1800.   Repopulate Un%%
  1801.  EOW_Dwelling = RTRIM$(Result$)
  1802.  
  1803. SUB Build_Budget_window
  1804.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(8), Layer(1), (16, 300)-STEP(479, 147)
  1805.  _PUTIMAGE (16, 300)-STEP(479, 147), Layer(2), Layer(1), (320, 0)-STEP(239, 73)
  1806.  KB_Print 16, 316, "Week #" + EOW_Week, 0, LEFT
  1807.  KB_Print 464, 316, "Budget", 0, RIGHT
  1808.  KB_Print 16, 348, "On Hand", 0, LEFT
  1809.  KB_Print 16, 364, "Payment", 0, LEFT
  1810.  KB_Print 16, 380, "Boat", 0, LEFT
  1811.  KB_Print 16, 396, "Army", 0, LEFT
  1812.  KB_Print 16, 412, "Balance", 0, LEFT
  1813.  KB_Print 224, 348, Special_K_Value(P.Gold), 0, RIGHT
  1814.  KB_Print 224, 364, Special_K_Value(P.Commission), 0, RIGHT
  1815.  b% = 0
  1816.  IF P.Has_Boat THEN
  1817.   IF P.Artifacts_Aquired AND 4 THEN b% = 100 ELSE b% = 500
  1818.  KB_Print 224, 380, LTRIM$(STR$(b%)), 0, RIGHT
  1819.  KB_Print 224, 396, Special_K_Value(Army_Cost), 0, RIGHT
  1820.  P.Gold = P.Gold + (P.Commission + (P.Castles * 250) - Army_Cost - b%)
  1821.  KB_Print 224, 412, Special_K_Value(P.Gold), 0, RIGHT
  1822.  FOR i%% = 0 TO 4
  1823.   IF PX.Army(i%%).Unit THEN
  1824.    KB_Print 240, 348 + i%% * 16, RTRIM$(Units(PX.Army(i%%).Unit).Unit_Name), 0, LEFT
  1825.    KB_Print 464, 348 + i%% * 16, Special_K_Value(Units(PX.Army(i%%).Unit).Cost * PX.Army(i%%).Count \ 2), 0, RIGHT
  1826.   END IF
  1827.  NEXT i%%
  1828.  
  1829.  DO
  1830.   KBD& = _KEYHIT
  1831.   SELECT CASE KBD&
  1832.    CASE Control.A_Button, Control.B_Button, Control.C_Button
  1833.     exitflag%% = TRUE
  1834.   Run_Animations
  1835.   _PUTIMAGE , Layer(1), Layer(0)
  1836.   _DELAY .025
  1837.  LOOP UNTIL exitflag%%
  1838.  exitflag%% = FALSE
  1839.  
  1840. FUNCTION Army_Cost~%
  1841.  FOR i%% = 0 TO 4
  1842.   Result~% = Result~% + Units(PX.Army(i%%).Unit).Cost * PX.Army(i%%).Count
  1843.  NEXT i%%
  1844.  Result~% = Result~% \ 2
  1845.  Army_Cost = Result~%
  1846.  
  1847. SUB Repopulate (Units%%)
  1848.  FOR y%% = 0 TO 63
  1849.   FOR x%% = 0 TO 63
  1850.    IF Land(x%%, y%%).IsDwelling THEN
  1851.     IF Land(x%%, y%%).Units = Units%% THEN
  1852.      IF Land(x%%, y%%).Population >= Land(x%%, y%%).Start_Population THEN 'if no units missing add a few
  1853.       Land(x%%, y%%).Population = Land(x%%, y%%).Population + INT(RND * (Land(x%%, y%%).Start_Population / 10)) + 1
  1854.      ELSE 'if player had hired units then refill
  1855.       Land(x%%, y%%).Population = Land(x%%, y%%).Start_Population + INT(RND * (Land(x%%, y%%).Start_Population / 10)) + 1
  1856.      END IF
  1857.     END IF
  1858.    END IF
  1859.   NEXT x%%
  1860.  NEXT y%%
  1861.  
  1862. SUB Change_Ghosts
  1863.  FOR i%% = 1 TO 26
  1864.   IF Castles(i%%).Owner = PLAYER THEN 'only if player controls castle
  1865.    FOR j%% = 0 TO 4
  1866.     IF CX.Army(j%%).Unit = 14 THEN CX.Army(j%%).Unit = 1 'change ghosts to peasants
  1867.    NEXT j%%
  1868.   END IF
  1869.  NEXT i%%
  1870.  
  1871. SUB Swap_Map (ID%%, Action%%)
  1872.  FOR Y%% = 0 TO 63
  1873.   FOR X%% = 0 TO 63
  1874.    IF Action%% = SAVE THEN Maps(X%%, Y%%, ID%%).Terrain = Land(X%%, Y%%).Terrain
  1875.    IF Action%% = LOAD THEN Land(X%%, Y%%) = Maps(X%%, Y%%, ID%%)
  1876.   NEXT X%%
  1877.  NEXT Y%%
  1878.  
  1879. SUB Build_Map_View
  1880.  X%% = P.MapXPos / 48
  1881.  Y%% = 63 - P.MapYpos / 40
  1882.  sy%% = Y%% - 2
  1883.  sx%% = X%% - 2
  1884.  IF sy%% < 0 THEN sy%% = 0
  1885.  IF sx%% < 0 THEN sx%% = 0
  1886.  _PUTIMAGE (16, 63)-STEP(479, 383), Layer(13), Layer(1), (288 + 96 * sx%%, 224 + 80 * sy%%)-STEP(479, 383)
  1887.  
  1888. SUB Build_Map (ID%%)
  1889.  _DEST Layer(ID%%)
  1890.  LINE (0, 0)-(6720, 5600), _RGB32(4, 164, 164), BF
  1891.  _DEST Layer(0)
  1892.  FOR y%% = 0 TO 63
  1893.   FOR x%% = 0 TO 63
  1894.    ix%% = Land(x%%, y%%).Terrain MOD 13
  1895.    IF Land(x%%, y%%).Terrain > 12 THEN iy%% = Land(x%%, y%%).Terrain \ 13 ELSE iy%% = 0
  1896.    _PUTIMAGE (288 + x%% * 96, 240 + y%% * 80)-STEP(95, 79), Layer(3), Layer(ID%%), (0 + 48 * ix%%, 0 + 40 * iy%%)-STEP(47, 39)
  1897.    Add_Map_Extras x%%, y%%, ID%%
  1898.   NEXT x%%
  1899.  NEXT y%%
  1900.  
  1901. SUB Draw_Player
  1902.  SELECT CASE P.Travel_Mode
  1903.   CASE HORSE
  1904.    IF P.Facing = RIGHT_FACE THEN YO%% = 0
  1905.    IF P.Facing = LEFT_FACE THEN YO%% = 2
  1906.    IF P.Moving THEN YO%% = YO%% + 1
  1907.   CASE BOAT
  1908.    IF P.Facing = RIGHT_FACE THEN YO%% = 4
  1909.    IF P.Facing = LEFT_FACE THEN YO%% = 6
  1910.    IF P.Moving THEN YO%% = YO%% + 1
  1911.   CASE DRAGON
  1912.    IF P.Facing = RIGHT_FACE THEN YO%% = 8
  1913.    IF P.Facing = LEFT_FACE THEN YO%% = 9
  1914.  
  1915.  _PUTIMAGE (166, 203)-STEP(91, 63), Layer(5), Layer(1), (0 + G.Window_Animation * 46, 800 + (YO%% * 32))-STEP(45, 31)
  1916.  
  1917.  
  1918. SUB Place_Extras
  1919.  '----------------Place towns-----------------------
  1920.  '---------Make sure all spells are available-----
  1921.  Towns(8).Spell = 1 'this town always has bridge
  1922.  FOR i%% = 2 TO 14
  1923.   good%% = FALSE
  1924.   DO
  1925.    t%% = INT(RND * 26) + 1
  1926.    IF Towns(t%%).Spell = 0 THEN good%% = TRUE
  1927.   LOOP UNTIL good%%
  1928.   Towns(t%%).Spell = i%%
  1929.  NEXT i%%
  1930.  '------------------------------------------------
  1931.  FOR i%% = 1 TO 26
  1932.   Maps(Towns(i%%).MapX, Towns(i%%).MapY, Towns(i%%).Land).IsTown = i%%
  1933.   IF Towns(i%%).Spell = 0 THEN Towns(i%%).Spell = INT(RND * 14) + 1 'fill remaining towns with random spells
  1934.  NEXT i%%
  1935.  '--------------------------------------------------
  1936.  '---------------Place SignPosts------------------
  1937.  FOR i%% = 1 TO 26
  1938.   Maps(Sign(i%%).MapXLoc, Sign(i%%).MapYLoc, Sign(i%%).Land).IsSign = i%%
  1939.  NEXT i%%
  1940.  '------------------------------------------------
  1941.  '--------------Set Path blocks-------------------
  1942.  Maps(7, 63 - 8, 1).IsBlock = TRUE
  1943.  Maps(17, 63 - 7, 1).IsBlock = TRUE
  1944.  Maps(17, 63 - 6, 1).IsBlock = TRUE
  1945.  '------------------------------------------------
  1946.  
  1947. SUB Add_Map_Extras (X%%, Y%%, ID%%)
  1948.  IF Land(X%%, Y%%).IsTown THEN _PUTIMAGE (288 + X%% * 96, 240 + Y%% * 80)-STEP(95, 79), Layer(3), Layer(ID%%), (480, 160)-STEP(47, 39)
  1949.  IF Land(X%%, Y%%).IsSign THEN _PUTIMAGE (288 + X%% * 96, 240 + Y%% * 80)-STEP(95, 79), Layer(3), Layer(ID%%), (432, 160)-STEP(47, 39)
  1950.  IF Land(X%%, Y%%).IsBridge THEN _PUTIMAGE (288 + X%% * 96, 240 + Y%% * 80)-STEP(95, 79), Layer(3), Layer(ID%%), (336 + Land(X%%, Y%%).IsBridge * 48, 160)-STEP(47, 39)
  1951.  
  1952. SUB Hide_Scepter (Land%%)
  1953.  good%% = FALSE
  1954.  DO
  1955.   x%% = INT(RND * 59) + 3
  1956.   y%% = INT(RND * 59) + 3
  1957.   IF Maps(x%%, y%%, Land%%).Terrain = 10 THEN good%% = TRUE
  1958.  LOOP UNTIL good%%
  1959.  G.Scepter_X = x%%
  1960.  G.Scepter_Y = y%%
  1961.  Maps(x%%, y%%, Land%%).IsScepter = TRUE
  1962.  
  1963. SUB KB_Print (x%, y%, Txt$, Null%%, Aline%%)
  1964.  Xo% = 0: Yo% = 672 'sheet offsets
  1965.  Mx%% = LEN(Txt$)
  1966.  IF Aline%% = RIGHT THEN Ax% = LEN(Txt$) * 16: x% = x% - Ax%
  1967.  IF Aline%% = CENTER THEN Ax% = LEN(Txt$) * 8: x% = x% - Ax%
  1968.  FOR i~%% = 1 TO Mx%%
  1969.   So% = (ASC(MID$(Txt$, i~%%, 1)) - 31) * 8
  1970.   _PUTIMAGE (x% + (i~%% * 16), y%)-STEP(15, 15), Layer(2), Layer(1), (Xo% + So%, Yo%)-STEP(7, 7)
  1971.  NEXT i~%%
  1972.  
  1973. SUB KB_Print_Wrap (X%, Y%, txt$, MaxX%)
  1974.  DIM Lines(10) AS STRING
  1975.  'max number of characters with Wrap max of MaxX%%
  1976.  IF MaxX% THEN SMx%% = INT(MaxX% / 16) ELSE SMx%% = LEN(txt$)
  1977.  LOCATE 1, 1: PRINT SMx%%; MaxX%;
  1978.  Finished%% = FALSE
  1979.  DO
  1980.   Mx%% = SMx%% 'restore Mx to Starting Mx(Mx= Max X length in pixels)
  1981.   IF MID$(txt$, Mx%%, 1) = " " THEN
  1982.    ' text is nice enough to land on a space
  1983.    j%% = j%% + 1
  1984.    Lines(j%%) = LEFT$(txt$, Mx%%)
  1985.    txt$ = MID$(txt$, Mx%% + 1)
  1986.   ELSE
  1987.    ' back track to find first space
  1988.    Found%% = FALSE
  1989.    DO
  1990.     IF MID$(txt$, Mx%%, 1) = " " THEN Found%% = TRUE ELSE Mx%% = Mx%% - 1
  1991.    LOOP UNTIL Found%%
  1992.    j%% = j%% + 1 'set to next line
  1993.    Lines(j%%) = MID$(txt$, 1, Mx%%)
  1994.    txt$ = MID$(txt$, Mx%% + 1) 'reduce string length
  1995.   END IF
  1996.   IF RTRIM$(txt$) = "" THEN Finished%% = TRUE
  1997.  LOOP UNTIL Finished%%
  1998.  
  1999.  'print wraped lines
  2000.  FOR I%% = 1 TO j%%
  2001.   KB_Print X%, Y%, Lines(I%%), 0, LEFT
  2002.   Y% = Y% + 16
  2003.  NEXT I%%
  2004.  
  2005. FUNCTION Special_K_Value$ (Value~%)
  2006.  IF Value~% > 1000 THEN
  2007.   Result$ = LTRIM$(STR$(INT(Value~% \ 1000)))
  2008.   Result$ = Result$ + "K"
  2009.   Result$ = LTRIM$(STR$(Value~%))
  2010.  Special_K_Value = Result$
  2011.  
  2012. SUB Window_Header
  2013.  _PUTIMAGE (16, 30)-STEP(608, 18), Layer(8), Layer(1), (16, 30)-STEP(608, 18) 'clean header area
  2014.  KB_Print 2, 31, G.HDR_Text, 0, LEFT
  2015.  IF INSTR(RTRIM$(G.HDR_Text), Names(P.Class)) THEN
  2016.   IF G.TimeStop THEN
  2017.    KB_Print 398, 31, "TimeStop:", 0, LEFT
  2018.    KB_Print 606, 31, STR$(G.TimeStop), 0, RIGHT
  2019.   ELSE
  2020.    KB_Print 398, 31, "Days Left:", 0, LEFT
  2021.    KB_Print 606, 31, STR$(G.Days), 0, RIGHT
  2022.   END IF
  2023.  
  2024. SUB ClockTick
  2025.  STATIC CurrentCount~%%, AnimationCount~%%
  2026.  
  2027.  AnimationCount~%% = AnimationCount~%% + 1
  2028.  
  2029.  IF (NOT G.In_Menu) AND (NOT G.In_Combat) THEN 'time pauses when in a menu window or combat
  2030.   CurrentCount~%% = CurrentCount~%% + 1
  2031.   IF G.TimeStop THEN
  2032.    IF CurrentCount~%% > 3 THEN G.TimeStop = G.TimeStop - 1: CurrentCount~%% = 0
  2033.   ELSE
  2034.    IF CurrentCount~%% > 127 THEN G.Days = G.Days - 1: CurrentCount~%% = 0
  2035.   END IF
  2036.  
  2037.  IF AnimationCount~%% > 0 THEN G.Window_Animation = G.Window_Animation + 1: AnimationCount~%% = 0
  2038.  IF G.Window_Animation > 3 THEN G.Window_Animation = 0
  2039.  
  2040. SUB Add_Player_Advancement
  2041.  P.Leadership = P.Leadership + Stats(P.Class, P.Promotion).Leadership
  2042.  P.Commission = P.Commission + Stats(P.Class, P.Promotion).Commission
  2043.  P.SpellPower = P.SpellPower + Stats(P.Class, P.Promotion).SpellPower
  2044.  P.MaxSpells = P.MaxSpells + Stats(P.Class, P.Promotion).MaxSpells
  2045.  P.Gold = P.Gold + Stats(P.Class, P.Promotion).Gold 'just for starting gold at moment
  2046.  
  2047. SUB Set_BackGround_Color
  2048.  _DEST Layer(8)
  2049.  LINE (0, 16)-(639, 448), BackGround_Color(G.Level), BF
  2050.  _DEST Layer(0)
  2051.  
  2052. FUNCTION Player_Score
  2053.  'g.level=1,2,4,8 so half final results to make .5,1,2,4(easy, normal, hard, impossible)
  2054.  Result~% = P.Artifacts * (250 * G.Level) / 2
  2055.  Result~% = Result~% + P.Castles * (100 * G.Level) / 2
  2056.  Result~% = Result~% + P.VilliansCaught * (500 * G.Level) / 2
  2057.  Result~% = Result~% - (P.Deaths * G.Level) / 2
  2058.  Player_Score = Result~%
  2059.  
  2060.  
  2061. SUB Run_Animations
  2062.  Magic_Animation
  2063.  Seige_Animation
  2064.  Contract_Animation MAIN
  2065.  IF P.Has_Boat AND P.Travel_Mode <> BOAT THEN Place_Boat
  2066.  
  2067. SUB Load_Data
  2068.  '-----------------Data loader--------------------
  2069.  RESTORE SignData
  2070.  FOR i%% = 1 TO 70
  2071.   READ Sign(i%%).SignText
  2072.   READ Sign(i%%).MapXLoc
  2073.   READ Sign(i%%).MapYLoc
  2074.   READ Sign(i%%).Land
  2075.   Sign(i%%).MapYLoc = 63 - Sign(i%%).MapYLoc 'correct Y value for bottom start
  2076.  NEXT i%%
  2077.  
  2078.  RESTORE MapTerrain
  2079.  READ Map1$
  2080.  Map01% = DecodeMaps(Map1$)
  2081.  Swap_Map CONTINENTIA, SAVE
  2082.  READ Map1$
  2083.  Map02% = DecodeMaps(Map1$)
  2084.  Swap_Map FORESTRIA, SAVE
  2085.  READ Map1$
  2086.  Map03% = DecodeMaps(Map1$)
  2087.  Swap_Map ARCHIPELIA, SAVE
  2088.  READ Map1$
  2089.  Map04% = DecodeMaps(Map1$)
  2090.  Swap_Map SAHARIA, SAVE
  2091.  
  2092.  IF Map01% <> TRUE THEN PRINT "Continentia map error"
  2093.  IF Map02% <> TRUE THEN PRINT "Forestria map error"
  2094.  IF Map03% <> TRUE THEN PRINT "Archipelia map error": END
  2095.  IF Map04% <> TRUE THEN PRINT "Saharia map error": END
  2096.  
  2097.  RESTORE Lands
  2098.  FOR i%% = 1 TO 4
  2099.   READ Lands(i%%)
  2100.  NEXT i%%
  2101.  
  2102.  RESTORE Names
  2103.  FOR i%% = 0 TO 3
  2104.   READ Names(i%%)
  2105.  NEXT i%%
  2106.  RESTORE Titles
  2107.  FOR i%% = 0 TO 3
  2108.   FOR j%% = 0 TO 3
  2109.    READ Title(i%%, j%%)
  2110.   NEXT j%%
  2111.  NEXT i%%
  2112.  RESTORE Advancement
  2113.  FOR i%% = 0 TO 3
  2114.   FOR j%% = 0 TO 3
  2115.    READ Stats(i%%, j%%).Leadership
  2116.    READ Stats(i%%, j%%).MaxSpells
  2117.    READ Stats(i%%, j%%).SpellPower
  2118.    READ Stats(i%%, j%%).Commission
  2119.    READ Stats(i%%, j%%).Gold
  2120.   NEXT j%%
  2121.  NEXT i%%
  2122.  RESTORE Units
  2123.  FOR i%% = 1 TO 25
  2124.   READ Units(i%%).Unit_Name
  2125.   READ Units(i%%).HitPts
  2126.   READ Units(i%%).AttackLo
  2127.   READ Units(i%%).AttackHi
  2128.   READ Units(i%%).Shoot
  2129.   READ Units(i%%).Skill_Level
  2130.   READ Units(i%%).Movement
  2131.   READ Units(i%%).Cost
  2132.   READ Units(i%%).Shoot
  2133.   READ Units(i%%).Grouping
  2134.   READ Units(i%%).ShootLo
  2135.   READ Units(i%%).ShootHi
  2136.  NEXT i%%
  2137.  RESTORE Contract_Data
  2138.  FOR i%% = 1 TO 17
  2139.   READ Villains(i%%).Villain
  2140.   READ Villains(i%%).Alias
  2141.   READ Villains(i%%).Bounty
  2142.   READ Villains(i%%).LastSeen
  2143.   READ Villains(i%%).Description
  2144.   READ Villains(i%%).Crimes
  2145.   Villains(i%%).Is_Known = FALSE
  2146.  NEXT i%%
  2147.  RESTORE CastleData
  2148.  FOR i%% = 1 TO 26
  2149.   READ Castles(i%%).The_Name
  2150.   READ Castles(i%%).GateX
  2151.   READ Castles(i%%).GateY
  2152.   READ Castles(i%%).Land
  2153.   READ Castles(i%%).MapX
  2154.   READ Castles(i%%).MapY
  2155.   Castles(i%%).MapY = 63 - Castles(i%%).MapY 'correct Y value for bottom start
  2156.  NEXT i%%
  2157.  Castles(0).The_Name = "Unknown"
  2158.  RESTORE TownData
  2159.  FOR i%% = 1 TO 26
  2160.   READ Towns(i%%).The_Name
  2161.   READ Towns(i%%).Unit
  2162.   READ Towns(i%%).Spell
  2163.   READ Towns(i%%).Castle
  2164.   READ Towns(i%%).GateX
  2165.   READ Towns(i%%).GateY
  2166.   READ Towns(i%%).Land
  2167.   READ Towns(i%%).MapX
  2168.   READ Towns(i%%).MapY
  2169.   Towns(i%%).MapY = 63 - Towns(i%%).MapY 'correct Y value for bottom start
  2170.   IF i%% = 8 THEN Towns(i%%).BoatX = 11: Towns(i%%).BoatY = 63 - 3
  2171.  NEXT i%%
  2172.  RESTORE BackgroundColors
  2173.  FOR i%% = 1 TO 4
  2174.   READ BackGround_Color(i%%)
  2175.  NEXT i%%
  2176.  RESTORE SpellData
  2177.  FOR i%% = 1 TO 14
  2178.   READ Spells(i%%).Spell_Name
  2179.   READ Spells(i%%).Cost
  2180.  NEXT i%%
  2181.  RESTORE PuzzleData
  2182.  FOR y%% = 0 TO 4
  2183.   FOR x%% = 0 TO 4
  2184.    READ Puzzle(x%%, y%%)
  2185.   NEXT x%%
  2186.  NEXT y%%
  2187.  '------------------------------------------------
  2188.  
  2189.  
  2190. SUB DumpMap
  2191.  OPEN "debug.txt" FOR OUTPUT AS #1
  2192.  FOR y%% = 0 TO 63
  2193.   FOR x%% = 0 TO 63
  2194.    PRINT #1, Maps(x%%, y%%, 1).Terrain;
  2195.   NEXT x%%
  2196.   PRINT #1,
  2197.  NEXT y%%
  2198.  
  2199. SUB Build_Layers
  2200.  '------------------Layer loader------------------
  2201.  GFX_Loader
  2202.  Layer(0) = _DISPLAY
  2203.  Layer(1) = _NEWIMAGE(640, 480, 32)
  2204.  Layer(2) = LoadGFX&(GFX_FOffset&(1), GFX_Size(1))
  2205.  Layer(3) = LoadGFX&(GFX_FOffset&(2), GFX_Size(2))
  2206.  Layer(4) = LoadGFX&(GFX_FOffset&(3), GFX_Size(3))
  2207.  Layer(5) = LoadGFX&(GFX_FOffset&(4), GFX_Size(4))
  2208.  Layer(6) = LoadGFX&(GFX_FOffset&(5), GFX_Size(5))
  2209.  'Layer(2) = _LOADIMAGE("Windows.bmp", 32)
  2210.  'Layer(3) = _LOADIMAGE("MapTiles.bmp", 32)
  2211.  'Layer(4) = _LOADIMAGE("BackGrounds.bmp", 32)
  2212.  'Layer(5) = _LOADIMAGE("Units.bmp", 32)
  2213.  'Layer(6) = _LOADIMAGE("StartScreens.bmp", 32)
  2214.  Layer(8) = _NEWIMAGE(640, 480, 32) 'background color layer
  2215.  Layer(9) = _NEWIMAGE(640, 480, 32) 'temp layer
  2216.  Layer(10) = _NEWIMAGE(640, 448, 32) 'victory march layer
  2217.  Layer(11) = _NEWIMAGE(640, 480, 32) 'temp layer 2(in town for contract window)
  2218.  Layer(13) = _NEWIMAGE(6720, 5600, 32) 'Continentia
  2219.  'Layer(14) = _NEWIMAGE(6720, 5600, 32) 'Forestria
  2220.  'Layer(15) = _NEWIMAGE(6720, 5600, 32) 'Archipelia
  2221.  'Layer(16) = _NEWIMAGE(6720, 5600, 32) 'Saharia
  2222.  
  2223.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(2)
  2224.  _CLEARCOLOR _RGB32(76, 76, 140), Layer(2)
  2225.  _CLEARCOLOR _RGB32(64, 64, 128), Layer(6)
  2226.  _CLEARCOLOR _RGB32(0, 0, 0), Layer(5)
  2227.  '------------------------------------------------
  2228.  CLOSE 1
  2229.  
  2230. SUB GFX_Loader
  2231.  '-------------layer loader-----------------------
  2232.  OPEN "KingsBounty64.gfx" FOR BINARY AS #1
  2233.  GET #1, , c~%% 'number of records
  2234.  FOR w% = 1 TO c~%%
  2235.   GET #1, , GFX_FOffset&(w%)
  2236.   GET #1, , GFX_Size(w%)
  2237.   GFX_FOffset&(w%) = GFX_FOffset&(w%) + 1
  2238.  '------------------------------------------------
  2239.  
  2240. FUNCTION LoadGFX& (Foff&, Size&)
  2241.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  2242.  OPEN "temp.dat" FOR BINARY AS #3
  2243.  dat$ = SPACE$(Size&)
  2244.  GET #1, Foff&, dat$
  2245.  PUT #3, , dat$
  2246.  CLOSE #3
  2247.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  2248.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  2249.  
  2250. FUNCTION LoadSFX& (Foff&, Size&)
  2251.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  2252.  OPEN "temp.dat" FOR BINARY AS #3
  2253.  dat$ = SPACE$(Size&)
  2254.  GET #1, Foff&, dat$
  2255.  PUT #3, , dat$
  2256.  CLOSE #3
  2257.  LoadSFX& = _SNDOPEN("temp.dat")
  2258.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  2259.  

when you run the code press 'a' then arrow down to Contract Information then press 'a' again. and the whole description is there. now press 's' to exit the window and press 'a' again to show it, Bam! the Distinguishing Features no longer displays. now exit the window again('s') then exit the menu ('s' again) move down to the town below. when you enter the town press 'a' to get a New Contract and the Distinguishing Features displays correctly for the next Villain. However cycle through the contracts(there are 5 you can choose) until it goes back to 'Murry' and Bam again, the Distinguishing Features are all missing now.( to quit the program normally you need to exit the town('s') then press ESC)
My question is what is happening to the Distinguishing Features text? and Why?

as with all my projects you'll need the GFX file to run it. and a fairly recent DB of QB64 just to be safe. I have had issues with the 4 Map DATA lines corrupting when copy and pasting them, so good luck. eventually all the data will be pulled from a file rather than stored in the program, should remove that issue. Have also had unexplained IDE crashes with this code as well, but no problems on my end compiling it as of yet.
Developed on a Windows machine, and not that its probably an issue yet, but you'll want roughly 200-256megs of ram free. I disabled 3 of the map layers so it should be around there and haven't add the sound fx yet.

control keys are a,s,d (sega genesis A,B,C buttons and  'd' is only used in the Game controls to change the battle speed at the moment) and the arrow keys. they are case sensitive at the movement and need to be lower case. eventually the controls will be customize-able but not yet. you can rent a boat and explore the map, the boat doesn't anchor quite right yet though but its not an issue for this demo(if you park right you can 'erase' the towns, but still enter them!). I fixed my main issue with the mapping but its still has a few little details I need to fix, but you should be able to go on any of the 'walk-able' tiles. castles cannot be entered yet but you can (i think) visit all the towns. the time changes correctly But the 'end of week' report doesn't come up yet so you wont get any gold and once you use it up you will have to restart(although if you choose 'wait till end of week' or 'Search area' that should trigger an end of week event.) not sure what happens if the Days Left goes negative, probably crash cause I haven't gotten to the Lose Game stuff yet.

Anyhow enjoy what you can of it and let me know if any of you can find the issue with the Contract display or find other major issues, I know of a few but there are probably more I have not come across yet.
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A Demo with a problem
« Reply #1 on: February 10, 2019, 09:03:53 pm »
I have error on line 2400 when try to run code...

Cobalt do you know the old problem, "Once you use the _DISPLAY command, you will always have to use it to see anything unless you turn it off. " ?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: A Demo with a problem
« Reply #2 on: February 10, 2019, 09:08:41 pm »
If it isn't a problem with _DISPLAY....

I don't have all the things together I'd need to run this right now, but question... Did you remember to reset the variable current%% in your code to reload that villain information? If not, the line:  P.Current_Contract = ContractAvail(current%%) might not be what you need it to be.

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: A Demo with a problem
« Reply #3 on: February 10, 2019, 10:14:22 pm »
I have error on line 2400 when try to run code...

Cobalt do you know the old problem, "Once you use the _DISPLAY command, you will always have to use it to see anything unless you turn it off. " ?

you have to download the GFX file.
I never use the _DISPLAY command. Simply due to that fact.
« Last Edit: February 11, 2019, 01:54:31 am by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: A Demo with a problem
« Reply #4 on: February 10, 2019, 10:22:24 pm »
If it isn't a problem with _DISPLAY....

I don't have all the things together I'd need to run this right now, but question... Did you remember to reset the variable current%% in your code to reload that villain information? If not, the line:  P.Current_Contract = ContractAvail(current%%) might not be what you need it to be.

Pete

that variable (current%%) is only used within the Build_Town_Window routine to know which contract the player is currently on out of the 5 available contracts, not the Build_Contract_Window. And Build_Contract_Window is what displays the Villains information. it is called from both the Build_Town_Window routine and Run_Menu_Choice routine.
Granted after becoming radioactive I only have a half-life!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: A Demo with a problem
« Reply #5 on: February 10, 2019, 11:45:14 pm »
I was able to understand the problem a little by not using the KB_Print_Wrap function. If I use the non-wrapping version, but then only take the first 10 characters of the Description field, it gives the same result each time (nothing special about the number 10):

Code: QB64: [Select]
  1.     IF P.Current_Contract THEN
  2.         Contract_Animation 0
  3.         KB_Print 16, 175, "Name: " + Villains(P.Current_Contract).Villain, 0, LEFT
  4.         KB_Print 16, 191, "Alias: " + Villains(P.Current_Contract).Alias, 0, LEFT
  5.         KB_Print 16, 207, "Reward: " + Contract_Reward(Villains(P.Current_Contract).Bounty), 0, LEFT
  6.         KB_Print 16, 223, "Last Seen: " + Lands(Villains(P.Current_Contract).LastSeen), 0, LEFT
  7.         KB_Print 16, 239, "Castle: " + Castles(Villains(P.Current_Contract).Is_Known).The_Name, 0, LEFT
  8.         KB_Print 16, 255, "Distinguishing Features: " + LEFT$(Villains(P.Current_Contract).Description, 10), 0, LEFT
  9.         y% = 272 'allows for different lenths of discriptions cause the routine changes the value
  10.         'KB_Print_Wrap 48, y%, Villains(P.Current_Contract).Description, 432
  11.         KB_Print 16, y%, "Crimes: ", 0, LEFT
  12.  
  13.         KB_Print_Wrap 48, y%, "      " + Villains(P.Current_Contract).Crimes, 432
  14.  
  15.     ELSE

At face value, it seems that KB_Print_Wrap depends on variables outside the function itself and the arguments passed to it (globals, in other words)... I would comb over the code and check that certain globals aren't being messed with by something else. This is gonna be a subtle thing to debug, as KB_Print_Wrap is only called twice in the whole code.
« Last Edit: February 10, 2019, 11:52:33 pm by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: A Demo with a problem
« Reply #6 on: February 10, 2019, 11:52:46 pm »
VEatch may help as you can watch the variable value as it updates while the program runs.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: A Demo with a problem
« Reply #7 on: February 10, 2019, 11:54:54 pm »
Oooooh yeah duh! Dude VW is probably what you need! I don't suppose it'll be cranky while tracking a few thousand lines.

As a complete aside, I had a blast exploring the map on my rented boat - almost forgot to hunt for the problem. Bravo on this project!
You're not done when it works, you're done when it's right.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: A Demo with a problem
« Reply #8 on: February 11, 2019, 12:46:39 am »
I'd just change the code to print the value of the array instead of the string. That way, you might get a clue from the value. If it was supposed to be three and on the second run it is something else, that should help you track it down.

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: A Demo with a problem
« Reply #9 on: February 11, 2019, 01:51:54 am »
found it... the routine itself was the problem, it was changing the data in the array when it wrapped it.
   txt$ = MID$(txt$, Mx%% + 1) 'reduce string length
since in QB64 even the subs act like QB45 functions and can change the variables passed to it(heck I was using that feature even"  y% = 272 'allows for different lengths of descriptions cause the routine changes the value")

but it still leaves me scratching my head because riddle me this batman, why did it only affect the villains description and not the crimes? they are both printed by the KB_Print_Wrap routine. and therefore should have both been erased by that 'reduce' line. if they both had been affected by it it might have been easier to pick out, but since it only affected one string array and not the other had to keep rereading the code till it finally clicked that I was manipulating the passed string value directly.

As a complete aside, I had a blast exploring the map on my rented boat - almost forgot to hunt for the problem. Bravo on this project!

were you able to make things disappear by 'parking' the boat on them? the towns and sign posts should be affected. they still show up on the minimap(as red squares) though. will be a total of 4 maps in the end. For the original game, might add 1 or 2 for a KB2 if I feel ambitious later, granted each map is using ~150meg ram so I may have to revert to my other option of loading maps on demand for that, though there is a speed hitch with that.
Granted after becoming radioactive I only have a half-life!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: A Demo with a problem
« Reply #10 on: February 11, 2019, 02:07:36 am »
At face value, it seems that KB_Print_Wrap depends on variables outside the function itself and the arguments passed to it (globals, in other words)... I would comb over the code and check that certain globals aren't being messed with by something else. This is gonna be a subtle thing to debug, as KB_Print_Wrap is only called twice in the whole code.

I missed that part of your post a moment ago. Actually KB_Print_Wrap is totally self sufficient, using only what you pass it. KB_Print, though, does rely on the Layer() array for image handles used by _PUTIMAGE.  When I have to write something like a custom print routine I like to make it as self sufficient as possible. In case I so desire to use it in other projects at a later time. Adding 2 arguments to handle the image handle aspect is something I may investigate at a later time.
Granted after becoming radioactive I only have a half-life!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: A Demo with a problem
« Reply #11 on: February 18, 2019, 04:38:45 pm »
HI
great  hunt for the bug with a good result!
More minds work well together!

Looking at code in QB64IDE at line of code 111 there is this

Quote
    Alias AS STRING * 24 '        Villains Alias if one   
the IDE make one color (that used for the keywords) for the whole line of code until apostrophe.
But why does it not trigger the error "name already in use" for Alias keyword?
Is it a rule or a bug?

Fine game Cobalt!
Programming isn't difficult, only it's  consuming time and coffee