rem Drugwar/64 - Version 1.01 rem Codebase: Drugwar//e 1.03 rem Ported by: Jay Moore rem "Damn that was annoying" rem 28-OCT-2018 rem Copyright 2018 Jay Moore rem Released under GPL v3 rem drugwar2e.sourceforge.io rem twitter: _nq4t poke 646,1 : poke 53281,0 : poke 53280,0 {set border,bg,text colors} rv=1.01 goto @instructions {because we're sticking subroutines up here} £titlebar {this literally just draws the game title at the top of the screen} poke 214,0:poke 211,14:sys 58640 : ?"drugwar/64" print CHR$(18)" " return £wait {ubiquitious "Press ENTER to continue} print input "Press enter to continue.";x$ return £twofifteen POKE 214,1 : poke 211,14:sys 58640 return £twosixteen POKE 214,1:poke 211,15:sys 58640 return £twoseventeen POKE 214,1:poke 211,16:sys 58640 return £twoeighteen POKE 214,1: poke 211,17:sys 58640 return £twonineteen POKE 214,1:poke 211,18:sys 58640 return £jetalthere gosub @twonineteen:print CHR$(18)"Jet" 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} print "You can afford ";j print "You can carry ";f £howmanybuy print input "How many? (Enter 0 cancel): ";k if K=0 goto @menu if k>f THEN print CHR$(18)"You can't carry that much!" : goto @howmanybuy if k>j THEN print CHR$(18)"You can't afford that much!" : goto @howmanybuy return £howmuchsell {common sell code} print "You can sell: ";j print £howmanysell input "How many? (Enter 0 to cancel.): ";k If k>j then print "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 gosub @twofifteen: print CHR$(18)"Being Chased" return £gmod gosub @twosixteen:print chr$(18)"Game Over" return £bronxcheck if p$ = "THE BRONX" then return print "you need to head to the bronx" print "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 {the only time we'll call this outside of the subway} goto @menu {the real start of the game} £menu {main menu. everything should loop back here} PRINT CHR$(147) gosub @freespace gosub @titlebar POKE 214,1:POKE 211,3:SYS 58640:print CHR$(18)"Day: "D POKE 214,1:POKE 211,17:SYS 58640:print CHR$(18)"Location: "p$ print print "(C)heck Prices" print "(T)renchcoat" print "(B)uy" print "(S)ell" print "(J)et" print "See (L)oan shark" print "(V)isit Bank" print 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 {if x$="debug" goto @debug} goto @menu [ £debug print "Testing Screen" print print "(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 PRINT CHR$(147) gosub @titlebar gosub @twoeighteen:print CHR$(18)"Prices" print print"cocaine:","$"c print"heroin:","$"h print"acid:","$"a print"weed:","$"z print"speed:","$"s print"ludes:","$"l print"wallet:","$"w gosub @wait goto @menu £inventory PRINT CHR$(147) gosub @titlebar gosub @twosixteen :print CHR$(18)"Trenchcoat" print print"cocaine:",m print"heroin:",n print"acid:",o print"weed:",u print"speed:",t print"ludes:",q print"free space:",f gosub @wait goto @menu £buy PRINT CHR$(147) gosub @titlebar gosub @twonineteen: print CHR$(18)"Buy" print print"What do you want to buy?" print print "(C)ocaine" print "(H)eroin" print "(A)cid" print "(W)eed" print "(S)peed" print "(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 PRINT CHR$(147) gosub @titlebar gosub @twoeighteen: print CHR$(18)"Sell" print print "What would you like to sell?" print print "(C)ocaine" print "(H)eroin" print "(A)cid" print "(W)eed" print "(S)peed" print "(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 print "Invalid Selection!" goto @sellsel £jet PRINT CHR$(147) gosub @titlebar gosub @jetalthere print print "(B)ronx" print "(G)hetto" print "(C)entral Park print "(M)anhattan" print "Coney (I)sland" print "Broo(K)lyn" print "(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 PRINT CHR$(147) gosub @titlebar Gosub @twosixteen:print CHR$(18)"Loan Shark" print gosub @bronxcheck print "Your debt is: $";v print "You have: $";w print 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 PRINT CHR$(147) gosub @titlebar gosub @twofifteen: print CHR$(18)"Bank O'Murica" print gosub @bronxcheck print "Your balance: $";e print "Your wallet: $";w print 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 PRINT CHR$(147) gosub @titlebar gosub @twosixteen: print CHR$(18)"Buy Cocaine" print 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 PRINT CHR$(147) gosub @titlebar gosub @twosixteen: print CHR$(18)"Buy Heroin" print j=int(w/h) gosub @howmuchbuy n=n+k : w=w-(h*k) goto @menu £acidbuy PRINT CHR$(147) gosub @titlebar gosub @twoseventeen:print CHR$(18)"Buy Acid" print j=int(w/a) gosub @howmuchbuy o=o+k : w=w-(a*k) goto @menu £weedbuy PRINT CHR$(147) gosub @titlebar gosub @twoseventeen: print CHR$(18)"Buy Weed" print j=int(w/z) gosub @howmuchbuy u=u+k : w=w-(z*k) goto @menu £spdbuy PRINT CHR$(147) gosub @titlebar gosub @twoseventeen: print CHR$(18)"Buy Speed" print j=int(w/s) gosub @howmuchbuy t=t+k : w=w-(s*k) goto @menu £ludbuy PRINT CHR$(147) gosub @titlebar gosub @twoseventeen: print CHR$(18)"Buy Ludes" print j=int(w/l) gosub @howmuchbuy q=q+k : w=w-(l*k) goto @menu £cokesell PRINT CHR$(147) gosub @titlebar gosub @twofifteen:print CHR$(18)"Sell Cocaine" print j=m {write amount to variable} gosub @howmuchsell {some buy logic} m=m-k {sub sends back here if valid, adjusts inventory} w=w+(c*k) {adds money to wallet} goto @menu £hersell PRINT CHR$(147) gosub @titlebar gosub @twoseventeen:print CHR$(18)"Sell Heroin" print j=n gosub @howmuchsell n=n-k w=w+(h*k) goto @menu £acidsell PRINT CHR$(147) gosub @titlebar gosub @twoseventeen: print CHR$(18)"Sell Acid" print j=o gosub @howmuchsell o=o-k w=w+(a*k) goto @menu £weedsell PRINT CHR$(147) gosub @titlebar gosub @twoseventeen:print CHR$(18)"Sell Weed" print j=u gosub @howmuchsell u=u-k w=w+(z*k) goto @menu £spdsell PRINT CHR$(147) gosub @titlebar gosub @twosixteen:print CHR$(18)"Sell Speed" print j=t gosub @howmuchsell t=t-k w=w+(s*k) goto @menu £ludsell PRINT CHR$(147) gosub @titlebar gosub @twosixteen:print CHR$(18)"Sell Ludes" print j=q gosub @howmuchsell q=q-k w=w+(l*k) goto @menu £alreadythere PRINT CHR$(147) gosub @titlebar gosub @jetalthere print print "You're already in:" print " ";p$ gosub @timerc goto @jet £subway PRINT CHR$(147) gosub @daily {b=ev debugging code} V=int(V*1.1+.5) {loan calculation} E=int(E*1.06+.5) {savings calculation} gosub @titlebar gosub @twoeighteen:print CHR$(18)"Subway" print 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 print {the only way you should wind up here is if nothing happens} print "Welcome to ";p$ {i hope} print gosub @timerc goto @menu £cheapludes print "Rival dealers are selling cheap ludes!" l=2 gosub @timerc goto @menu £cheepweed print "Weed prices have bottomed-out!" z=122 gosub @timerc goto @menu £pigheroin print "Pigs are selling cheap heroin" print "from last week's raid!" h=int((rnd(9)*1150)+850.5) gosub @timerc goto @menu £heroinbust print "Addicts are buying heroin" print "at outrageous prices!" h=int((rnd(9)*25000)+18000.5) gosub @timerc goto @menu £cokebust print "Pigs made a big coke bust!" print "Prices are outrageous!!!!" c=int((rnd(9)*60000)+80000.5) {the infamous line 930} gosub @timerc goto @menu £mugged print "You got mugged!" print j=int(w/3) j=int(j*2) k=int(w-j) print "You lost $";k w=j gosub @timerc gosub @menu £cops k=m+n+u+o+t+p {cops only active when inventory > 50} [ my improved revisions will likely add some additional conditions on how/when we run cops ] if k<50 then goto @nothinghappened if b=9 then b = 2 if b=10 then b=4 if b=11 then b=5 print "It's the cops!" print print "Officer Hardass and ";B-1;" of his" print "deputies are after you!" print gosub @timerc goto @police £police PRINT CHR$(147) gosub @titlebar gosub @chase print print print "View (G)uns" print "View (D)amage" print "(N)umber of pigs" print "(R)un" print "(F)ight" print 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 PRINT CHR$(147) gosub @titlebar gosub @chase print print print "You have ";g;" guns. print gosub @wait goto @police £damage PRINT CHR$(147) gosub @titlebar gosub @chase print print print "Your current damage is ";bb;"." print print "50 and you die!" print gosub @wait goto @police £ncops PRINT CHR$(147) gosub @titlebar gosub @chase print print print "There are ";b;" pigs still chasing you!" print print gosub @wait goto @police £run PRINT CHR$(147) gosub @titlebar gosub @chase print print print "RUNNING..." gosub @timera if k = 0 then print "You lost them in an alley!" : goto @loserun print "You can't shake them!" print gosub @wait goto @police £loserun print gosub @wait goto @menu £fight if g>0 then goto @fightc print print "YOU DON'T HAVE ANY GUNS!" gosub @wait goto @police £fightc PRINT CHR$(147) gosub @titlebar gosub @chase print print "You shoot!" gosub @timera If K=0 THEN GOTO @miss print "You got one!" : b = b-1 : goto @next £miss print "You missed!" £next print print If b <= 0 THEN goto @allgone gosub @timerb print "They're firing at you!" gosub @timera if k=0 then goto @theymiss print "You've been hit!" bb=bb+3 if bb >= 50 goto @ded goto @nexta £theymiss print "They missed!" £nexta gosub @wait goto @police £ded print print "You've been killed!" gosub @wait goto @endgame £allgone print "You killed all of them!" print gosub @timera j=int(((rnd(7)*1250)+750)+.5) w=w+j print "You found $";j;" on officer Hardass'" print "carcass!" if w>=1200 then goto @doctor goto @menu £doctor gosub @timerc print print "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=0 £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" print "Will you buy a ";y$ input "for $400? (Y/N)";x$ if x$ <> "Y" then goto @menu g = g+1 w = w-400 {i = i-5} goto @menu £dedweed {don't smoke the weed} print "There's some weed here that smells" print "like good stuff!!" print 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} print "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$ = "Cocaine" print "You found ";j;" units of" print " ";y$ print "on a dead dude in the subway!" print gosub @timerc goto @menu £homeacid print "The market has been flooded" print "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 PRINT:PRINT "YOU DON'T HAVE THAT MUCH!" : GOSUB @timerb : GOTO @LOAN IF k>v THEN PRINT:PRINT "YOU DON'T OWE THAT MUCH!" : GOSUB @timerb : GOTO @LOAN W=W-k v=v-k PRINT:PRINT "THANK YOU." GOSUB @timerc GOTO @MENU £borrow print Input "How much do you want? ";K print j=int((rnd(10)*10000)+5000) if K>14000 then print "He's not that stupid!" : gosub @timerc : goto @menu if K > J then print "He doesn't feel like it." : gosub @timerb : goto @menu v=v+k w=w+k print print "Here's your money." : PRINT : PRINT "Remember, I break thumbs." gosub @timerc goto @menu £deposit print INPUT "How much? ";j If j>w then print "You don't have that much cash." : goto @deposit e=e+j w=w-j print Print "Thank you for your deposit." gosub @timerc goto @menu [ £egg print "You found the easter egg!" print print "$1,000,000 has been deposited in to your account." gosub @timerc goto @bank ] £mymoney print INPUT "How much? ";j If j>e then print "You don't have sufficient funds." : goto @mymoney e=e-j w=w+j print print "Thank you for your business." gosub @timerc goto @menu £instructions PRINT CHR$(147) poke 211,3:sys 58640:print "welcome to drugwar/64 version";rv poke 211,5:sys 58640: print "ported from drugwar//e v 1.03":?:?:?:?:? ?: ? : poke 211,5:sys 58640:? "based on the ti-basic clone of" poke 211,7:sys 58640:print "john e. dell's 1984 drugwar" poke 211,11:sys 58640:print "for ibm and trs-80":?:? ?:?:poke 211,6:sys 58640:?"applesoft version by jay moore" poke 211,10:sys 58640: print "c64 port by jay moore" poke 211,1 : poke 214,23 : sys 58640 input "would you like instructions? (y/n)";x$ j=RND(-TI) {c64} {j =RND(-1 *(PEEK(78)+256*PEEK(79))) - applesoft} If X$ = "Y" THEN GOTO @inst GOTO @gamestart £inst PRINT CHR$(147) gosub @titlebar print print "This is a game of buying and selling." print "Your goal is to pay off your debt and" print "make as much money as possible in a one" print "month period. Prices fluctuate every day" print "and interest on your loan is calculated as well." print:print "If you deal too heavily, you'll attract the attention" PRINT "of the police." print print "Commands are entered using the letter" print "highlighted (L)ike (S)o. Y is yes and" print "anything counts as no." gosub @wait goto @gamestart £weedend PRINT CHR$(147) gosub @titlebar gosub @twofifteen: print CHR$(18)"SMOKE Weed" print "You hallucinate on the wildest trip" print "of your life, stumble on to the tracks," print "and get creamed by a train!" print print poke 211,7:sys 58640:? "Just say NO to drugs!" gosub @timerc gosub @timerb goto @ironicend £endgame PRINT CHR$(147) gosub @titlebar gosub @scorecalculate gosub @gmod print print "Your score on a scale of 1 to 100: ";k print input "Would you like to play again? (Y/N)";x$ if x$ = "Y" then goto @gamestart print "Thanks for playing." print "Remember, watch your back." print "Have a nice day!" end £ironicend PRINT CHR$(147) gosub @titlebar gosub @gmod print print "You died from smoking weed." print print gosub @timerc: print"See? Games are totally fake." print input "Would you like to play again? ";x$ if x$= "Y" THEN GOTO @GAMESTART end