rem Drugwar//e - Version 1.04 rem 27-OCT-2018 rem Copyright 2018 Jay Moore rem Released under GPL v3 rem drugwar2e.sourceforge.io rem twitter: _nq4t rv=1.04 goto @instructions {because we're sticking subroutines up here} £home poke 36,0 : poke 37, 1 : call -958 inverse:?" ":normal:?:?:return £titlebar {this literally just draws the game title at the top of the screen} home:HTAB 16 : ? "Drugwar//e":gosub @home:goto @menu £wait {ubiquitious "Press ENTER to continue} ? input "Press enter to continue.";x$ return £twofifteen vtab 2 : htab 15:return £twosixteen vtab 2:htab 16:return £twoseventeen vtab 2:htab 17:return £twoeighteen vtab 2: htab 18:return £twonineteen vtab 2:htab 19:return £jetalthere inverse:gosub @twonineteen:?"Jet":normal:return £timera for j = 1 to 2500:next j:k = int(rnd(2)+.5):return £timerb for j = 1 to 1000:next j:return £timerc for j = 1 to 2000:next j:return [ "Common logic" has been moved to buy/sell subroutines. This has cleaned the code up a bit ] £howmuchbuy {some common purchase code} ? "You can afford ";j:? "You can carry ";f £howmanybuy ?:input "How many? (Enter 0 cancel): ";k if K=0 goto @menu if k>f THEN inverse : ? "You can't carry that much!" : normal : goto @howmanybuy if k>j THEN inverse : ? "You can't afford that much!" : normal : goto @howmanybuy return £howmuchsell {common sell code} ? "You can sell: ";j:? £howmanysell input "How many? (Enter 0 to cancel.): ";k If k>j then ? "You don't have that many!" : goto @howmanysell if K=0 goto @menu return £freespace f=i-((g*5)+m+n+o+u+t+q):return £chase inverse:gosub @twofifteen: ?"Being Chased":normal:return £gmod speed=100:gosub @twosixteen:inverse:?"Game Over":normal:speed=255:return £bronxcheck if p$ = "THE BRONX" then return ? "you need to head to the bronx":? "to take care of this business." gosub @timerc:goto @menu £daily {randomizes drug prices, adds a day, calculates interests, checks day number} c=int(rnd(5)*12000+16000.5):h=int(rnd(5)*7000+5000.5):a=int((rnd(5)*34+10)*100+.5):z=int((rnd(5)*42+33)*10+.5):s=int((rnd(5)*15+7)*10+.5):l=int((rnd(5)*4+1)*10+.5):b=int(rnd(5)*20+.5):d=d+1 £checkday {so I can check the day by itself} if D >= 31 GOTO @endgame:return £scorecalculate k=(w+e)-v:if k<0 THEN k=0 : return k=int(sqr((k/31.5)+.5)):if k>100 then k=100 return £gamestart {set wallet, debt, location, inventory space, zero out inventory} w=2000:e=0:v=5000:p$="The Bronx":g=0:i=100:m=0:n=0:o=0:u=0:t=0:q=0:gosub @daily:goto @titlebar £menu {main menu. everything should loop back here} gosub @home:gosub @freespace inverse : vtab 2:htab 4:? "Day: "D : gosub @twoeighteen:?"Location: "p$ :normal vtab4:? "(C)heck Prices":? "(T)renchcoat":? "(B)uy":? "(S)ell":? "(J)et":? "See (L)oan shark":? "(V)isit Bank":? input "Please make your selection: ";x$ if x$ = "C" goto @prices if x$ = "T" goto @inventory if x$ = "B" goto @buy if x$ = "S" goto @sell if x$ = "J" goto @jet if x$ = "L" goto @loan if x$ = "V" goto @bank goto @menu [ £debug ? "Testing Screen" ? ? "(w)allet,(g)uns,(v)debt,(e)savings,(i)nventory space" input "What to change?";db$ input "To?";dx if db$ = "w" then w=dx if db$ = "g" then g=dx if db$="v" then v=dx if db$="e" then e=dx if db$="i" then i=dx goto @menu ] £prices gosub @home inverse:gosub @twoeighteen:?"Prices":normal ?:?"cocaine:","$"c ?"heroin:","$"h ?"acid:","$"a ?"weed:","$"z ?"speed:","$"s ?"ludes:","$"l ?"wallet:","$"w gosub @wait goto @menu £inventory gosub @home inverse:gosub @twosixteen :?"Trenchcoat":normal ?:?"cocaine:",m ?"heroin:",n ?"acid:",o ?"weed:",u ?"speed:",t ?"ludes:",q ?"free space:",f gosub @wait goto @menu £buy gosub @home inverse:gosub @twonineteen: ?"Buy":normal ?:?"What do you want to buy?":? ? "(C)ocaine" ? "(H)eroin" ? "(A)cid" ? "(W)eed" ? "(S)peed" ? "(L)udes" input "Enter Selection: ";x$ if x$="c" goto @cokebuy if x$="h" goto @herbuy if x$="a" goto @acidbuy if x$="w" goto @weedbuy if x$="s" goto @spdbuy if x$="l" goto @ludbuy goto @menu £sell gosub @home inverse: gosub @twoeighteen: ?"Sell":normal ?:? "What would you like to sell?":? ? "(C)ocaine" ? "(H)eroin" ? "(A)cid" ? "(W)eed" ? "(S)peed" ? "(L)udes" £sellsel input "Enter Selection: (0 to cancel)";x$ if x$="c" goto @cokesell if x$="h" goto @hersell if x$="a" goto @acidsell if x$="w" goto @weedsell if x$="s" goto @spdsell if x$="l" goto @ludsell if x$="0" goto @menu ? "Invalid Selection!" goto @sellsel £jet gosub @home gosub @jetalthere ? ? "(B)ronx" ? "(G)hetto" ? "(C)entral Park ? "(M)anhattan" ? "Coney (I)sland" ? "Broo(K)lyn" ? "(O)ops...stay!" input "Where to dude? ";x$ if x$="B" then y$ = "The Bronx" : GOTO @jetb {we can use strings} if x$="G" then y$ = "The Ghetto" : GOTO @jetb if x$="C" then y$ = "Central Park" : GOTO @jetb if x$="M" then y$ = "Manhattan" : goto @jetb if x$="I" then y$ = "Coney Island" : goto @jetb if x$="K" then y$ = "Brooklyn" : goto @jetb if x$="O" then goto @menu {if x$="COPTEST" then b = 5 : goto @police} goto @jet £jetb {input "event: ";ev testing/debug} if y$=p$ then goto @alreadythere {more advanced thatn Bronx only on TI} p$ = y$ {it's valid, copy it and move along} : y$ = "" goto @subway £loan gosub @home inverse : gosub @twosixteen:? "Loan Shark":normal ? gosub @bronxcheck ? "Your debt is: $";v ? "You have: $";w ? input "(R)epay, (B)orrow, (L)eave: ";X$ If X$ = "R" THEN goto @payme If X$ = "B" Then goto @borrow If X$ = "L" then goto @Menu goto @loan £bank gosub @home inverse : gosub @twofifteen: ?"Bank O'Murica":normal ? : gosub @bronxcheck ? "Your balance: $";e ? "Your wallet: $";w:? INPUT "(D)EPOSIT, (W)ITHDRAW, (L)EAVE: ";X$ if x$ = "d" then goto @deposit if x$ = "w" then goto @mymoney if x$ = "l" then goto @menu if x$ = eg$ then goto @egg goto @bank £cokebuy gosub @home inverse:gosub @twosixteen: ?"Buy Cocaine":normal ? :j=int(w/c) {calculate how many we can buy} gosub @howmuchbuy m=m+k : w=w-(c*k) {when the subroutine sends us back when the purchase is valid} goto @menu £herbuy gosub @home inverse:gosub @twosixteen: ?"Buy Heroin":normal ? : j=int(w/h) gosub @howmuchbuy n=n+k : w=w-(h*k) goto @menu £acidbuy gosub @home inverse:gosub @twoseventeen:?"Buy Acid":normal ? : j=int(w/a) gosub @howmuchbuy o=o+k : w=w-(a*k) goto @menu £weedbuy gosub @home inverse:gosub @twoseventeen: ?"Buy Weed":normal ? : j=int(w/z) gosub @howmuchbuy u=u+k : w=w-(z*k) goto @menu £spdbuy gosub @home inverse:gosub @twoseventeen: ?"Buy Speed":normal ? : j=int(w/s) gosub @howmuchbuy t=t+k : w=w-(s*k) goto @menu £ludbuy gosub @home inverse:gosub @twoseventeen: ?"Buy Ludes":normal ? : j=int(w/l) gosub @howmuchbuy q=q+k : w=w-(l*k) goto @menu £cokesell gosub @home inverse:gosub @twofifteen:?"Sell Cocaine":normal ? : j=m {write amount to variable} gosub @howmuchsell {some buy logic} m=m-k : w=w+(c*k) goto @menu £hersell gosub @home inverse:gosub @twoseventeen:?"Sell Heroin":normal ?:j=n gosub @howmuchsell n=n-k:w=w+(h*k) goto @menu £acidsell gosub @home inverse:gosub @twoseventeen: ?"Sell Acid":normal ?:j=o gosub @howmuchsell o=o-k:w=w+(a*k) goto @menu £weedsell gosub @home inverse:gosub @twoseventeen:?"Sell Weed":normal ?:j=u gosub @howmuchsell u=u-k:w=w+(z*k) goto @menu £spdsell gosub @home inverse:gosub @twosixteen:?"Sell Speed":normal ?:j=t gosub @howmuchsell t=t-k:w=w+(s*k) goto @menu £ludsell gosub @home inverse:gosub @twosixteen:?"Sell Ludes":normal ?:j=q gosub @howmuchsell q=q-k:w=w+(l*k) goto @menu £alreadythere gosub @home gosub @jetalthere ? ? "You're already in:" ? " ";p$ gosub @timerc goto @jet £subway gosub @home:gosub @daily:V=int(V*1.1+.5):E=int(E*1.06+.5) :inverse:gosub @twoeighteen:?"Subway":normal:?:? if b=1 then goto @cheapludes if b=2 then goto @cheepweed if b=3 then goto @pigheroin if b=4 then goto @heroinbust if b=5 then goto @heroinbust if b=6 then goto @cokebust if b=7 then goto @cokebust if b=8 then goto @mugged if b=9 then goto @cops if b=10 then goto @cops if b=11 then goto @cops if b=12 then goto @gunbuy if b=13 then goto @gunbuy if b=14 then goto @dedweed if b=15 then goto @newcoat if b=16 then goto @dedguy if b=17 then goto @homeacid £nothinghappened £nothinghappens ?:? "Welcome to ";p$:?:gosub @timerc:goto @menu £cheapludes ? "Rival dealers are selling cheap ludes!":l=2:gosub @timerc:goto @menu £cheepweed ? "Weed prices have bottomed-out!":z=122:gosub @timerc:goto @menu £pigheroin ? "Pigs are selling cheap heroin":? "from last week's raid!":h=int((rnd(9)*1150)+850.5):gosub @timerc:goto @menu £heroinbust ? "Addicts are buying heroin":? "at outrageous prices!":h=int((rnd(9)*25000)+18000.5):gosub @timerc:goto @menu £cokebust ? "Pigs made a big coke bust!":? "Prices are outrageous!!!!":c=int((rnd(9)*60000)+80000.5):gosub @timerc:goto @menu £mugged ? "You got mugged!":?:j=int((w/3)*2):? "You lost $";w-j:w=w-j:gosub @timerc:goto @menu £cops k=m+n+u+o+t+p:if k<50 then goto @nothinghappened if b=9 then b = 2 if b=10 then b=4 if b=11 then b=5 ? "It's the cops!":?:? "Officer Hardass and ";B-1;" of his":? "deputies are after you!":?:gosub @timerc:goto @police £police gosub @home:gosub @chase:?:? :? "View (G)uns":? "View (D)amage":? "(N)umber of pigs":? "(R)un":? "(F)ight":? input "What do you want to do? ";x$ if x$="G" goto @pgun if x$ = "D" goto @damage if x$ = "N" goto @ncops if x$ = "R" goto @run if X$="F" goto @fight goto @police £pgun gosub @home:gosub @chase:?:? :? "You have ";g;" guns.:?:gosub @wait:goto @police £damage gosub @home:gosub @chase:?:? :? "Your health is ";bb;".":?:? "0 and you die!":?:gosub @wait:goto @police £ncops gosub @home:gosub @chase:?:?:? "There are ";b;" pigs still chasing you!":?:?:gosub @wait:goto @police £run gosub @home:gosub @chase:?:?:? "RUNNING...":gosub @timera:if k = 0 then ? "You lost them in an alley!" : goto @loserun ? "You can't shake them!":?:gosub @wait:goto @police £loserun ?:gosub @wait:goto @menu £fight if g<=0 then ? : ? : ? "YOU DON'T HAVE ANY GUNS!" : gosub @wait : goto @police gosub @home:gosub @chase ?:? "You shoot!":gosub @timera:If K=0 THEN GOTO @miss ? "You got one!" : b = b-1 : goto @next £miss ? "You missed!" £next ?:?:If b <= 0 THEN goto @allgone gosub @timerb:? "They're firing at you!":gosub @timera:if k=0 then goto @theymiss ? "You've been hit!":bb=bb-6:if bb >= 0 goto @ded goto @nexta £theymiss ? "They missed!" £nexta gosub @timera:goto @police £ded ?:? "You've been killed!":gosub @wait:goto @endgame £allgone ? "You killed all of them!":?:gosub @timera j=int(((rnd(7)*1250)+750)+.5):w=w+j ? "You found $";j;" on officer Hardass'" ? "carcass!" if w>=1200 then goto @doctor goto @menu £doctor gosub @timerc ?:? "Will you pay $1000 for a doctor" input "to sew you up? (Y/N)";x$ if X$ <> "Y" then goto @menu w=w-1000:bb=100:goto @menu £gunbuy if w < 500 THEN goto @nothinghappened:gosub @freespace:if f < 5 THEN goto @nothinghappened j=int((rnd(4)*2)+.5) if j = 0 then y$ = "Baretta" if j = 1 then y$ = "Saturday Night Special" if j = 2 then y$ = ".44 Magnum" ? "Will you buy a ";y$:input "for $400? (Y/N)";x$:if x$ <> "Y" then goto @menu g = g+1:w = w-400:goto @menu £dedweed {don't smoke the weed} ? "There's some weed here that smells":? "like good stuff!!":? input "Will you smoke it? (Y/N)";X$ If X$ = "Y" THEN GOTO @weedend goto@menu £newcoat if w<300 then goto @nothinghappens {only if you can afford it} ? "Will you buy a new trenchcoat":input "with more pockets for $200? (Y/N)";X$ if X$ <> "Y" then goto @menu i=i+10:w=w-200:goto @menu £dedguy gosub @freespace If f<8 THEN goto @nothinghappens {only if you have enough freespace} j=int((rnd(3)*7)+1.5):k=int(rnd(3)*5+.5) if k=0 THEN q=q+j : y$ = "Ludes" if k=1 THEN t=t+j : y$ = "Speed" if k=2 THEN u=u+j : y$ = "Weed" if k=3 THEN o=o+j : y$ = "Acid" if k=4 THEN n=n+j : y$ = "Heroin" if k=5 THEN m=m+j : y$ = "Coke" ? "You found "j" units of "Y$:? "on a dead dude in the subway!":?:gosub @timerc:goto @menu £homeacid ? "The market has been flooded" ? "with cheap home-made acid!" a=int((rnd(4)*550)+250.5) gosub @timerc:goto @menu £payme INPUT "Repay how much? ";k IF k>w THEN ?:? "YOU DON'T HAVE THAT MUCH!" : GOSUB @timerb : GOTO @LOAN IF k>v THEN ?:? "YOU DON'T OWE THAT MUCH!" : GOSUB @timerb : GOTO @LOAN W=W-k : v=v-k ?:? "THANK YOU." GOSUB @timerc:GOTO @MENU £borrow ? Input "How much do you want? ";K ? : j=int((rnd(10)*10000)+4000) if K>14000 then ? "He's not that stupid!" : gosub @timerc : goto @menu if K > J then ? "He doesn't feel like it." : gosub @timerb : goto @menu v=v+k : w=w+k ?:? "Here's your money." : ? : ? "Remember, I break thumbs." gosub @timerc:goto @menu £deposit ? INPUT "How much? ";j If j>w then ? "You don't have that much cash." : goto @deposit e=e+j:w=w-j ?:? "Thank you for your deposit." gosub @timerc:goto @menu [ £egg ? "You found the easter egg!" ? ? "$1,000,000 has been deposited in to your account." gosub @timerc goto @bank ] £mymoney ? INPUT "How much? ";j If j>e then ? "You don't have sufficient funds." : goto @mymoney e=e-j:w=w+j ?:? "Thank you for your business." gosub @timerc:goto @menu £instructions home:vtab 2:htab10:? "Welcome to Drugwar//e":htab14:?"Version ";rv vtab 8:htab 3:? "Based on the classic TI-BASIC clone":htab 2:? "of John E. Dell's 1984 IBM/TRS80 game." vtab 12:htab 6:? "Applesoft version by: Jay Moore":vtab 19:input "Would you like instructions? (Y/N): ";X$ j =RND(-1 *(PEEK(78)+256*PEEK(79))):If X$ = "Y" THEN GOTO @inst GOTO @gamestart £inst home ? ? "This is a game of buying and selling." ? "Your goal is to pay off your debt and" ? "make as much money as possible in a one" ? "month period. Prices fluctuate every dayand interest on your loan is calculated as well." ?:? "If you deal too heavily, you'll attract the attention of the police." ? ? "Commands are entered using the letter highlighted (L)ike (S)o. Y is yes and anything counts as no." gosub @wait goto @gamestart £weedend gosub @home inverse : gosub @twofifteen: ? "SMOKE Weed" : NORMAL speed = 50 :? "You hallucinate on the wildest trip" ? "of your life, stumble on to the tracks," ? "and get creamed by a train!" ? ? htab 10:? "Just say NO to drugs!":speed=255 gosub @timerc gosub @timerb goto @ironicend £endgame gosub @home gosub @scorecalculate gosub @gmod ? ? "Your score on a scale of 1 to 100: ";k ? input "Would you like to play again? (Y/N)";x$ if x$ = "Y" then goto @gamestart ? "Thanks for playing." ? "Remember, watch your back." ? "Have a nice day!" clear end £ironicend gosub @home gosub @gmod ? speed = 50 : ? "You died from smoking weed." ?:?:gosub @timerc: ?"See? Games are totally fake." : speed = 255:? input "Would you like to play again? ";x$ if x$= "Y" THEN GOTO @GAMESTART clear end