! The dimensions of the screen (and mad global abuse) Global height = 0; ! The height of the screen Global width = 0; ! The width of the screen Global borders = 1; ! Do we have borders? Global cargoindent = 5; ! How far in are the cargo names? Global valueindent = 13; ! How far in are the cargo quantities? Global whindent = 21; ! How far in are the warehouse stats? Global gunindent = 17; ! How far in are the gun stats? Global shipwidth = 28; ! Width of the ship data Global column = 30; ! Where does the second column start? Global seccol = 0; ! Are holdings doubled up, and if so how? Global trunc = 0; ! Truncate second column? Global isbreak = 1; ! When no borders, do we have a line anyways? Global isfirm = 1; Global enemywidth=7; Array shipstrings --> SHIP7LINE1 SHIP7LINE2 SHIP7LINE3 SHIP7LINE4 SHIP7LINE5 SHIP6LINE1 SHIP6LINE2 SHIP6LINE3 SHIP6LINE4 SHIP6LINE5 SHIP5LINE1 SHIP5LINE2 SHIP5LINE3 SHIP5LINE4 SHIP5LINE5 SHIP4LINE1 SHIP4LINE2 SHIP4LINE3 SHIP4LINE4 SHIP4LINE5; [SetScreen num; height = 0->32; width = 0->33; if (width<28 || height<13) { print "Your interpreter-provided screen dimensions are insufficient to play Taipan. I am ignoring these dimensions, and will prompt you for input.^^"; width = 0; height = 0; } if (width==0) { print "Your interpreter has not provided a screen width. In order to display correctly, I must know your screen width in characters. Please type it in now, or type 0 to quit: "; num=0; while (~~num) { typebuf->0=5; read typebuf 0; num=TryNumber(typebuf); if(num==0) quit; if(num==-1000) { print "Please enter a number, or 0 to quit: "; num=0; } } width = num; print "^"; } if (height==0) { print "Your interpreter has not provided a screen height. In order to display correctly, Taipan must know your screen height in characters. Please type it in now, or type 0 to quit: "; num=0; while (~~num) { typebuf->0=5; read typebuf 0; num=TryNumber(typebuf); if(num==0) quit; if(num==-1000) { print "Please enter a number, or 0 to quit: "; num=0; } } height = num; print "^"; } if (width<28 || height<11) { print "Your interpreter window is not large enough to play Taipan.^"; quit; } height=height-2; if (height>16) height=16; if (width>=40) width=40; if (width<40) { shipwidth=width/5-1; if (width>=35) { ! Compress whitespace only whindent=width-19; gunindent=width-23; shipwidth=width-12; column=width-10; if (width<=38) { cargoindent=width-33; valueindent=width-25; } } else if (width>=32) { ! Compress whitespace and truncate second column trunc=1; whindent=width-16; gunindent=width-20; shipwidth=width-9; column=width-7; cargoindent=2; valueindent=10; } else if (width==31) { ! Compress whitespace and truncate second column (special case) trunc=1; whindent=16; gunindent=12; shipwidth=23; column=24; cargoindent=2; valueindent=10; } else if (width>=29) { ! Compress borders and whitespace trunc=1; borders=0; whindent=15; gunindent=11; shipwidth=width-9; column=width-7; cargoindent=1; valueindent=9; } else { ! Screw it, eliminate all whitespace. trunc=1; borders=0; whindent=14; gunindent=10; shipwidth=20; column=21; cargoindent=1; valueindent=9; } } if (height<16) borders=0; if (height<14) isbreak=0; if (height<13) isfirm=0; if (height<11) { cargoindent=1; valueindent=9; seccol=13; } ]; [DrawTopWindow i j; @split_window height; @erase_window 1; @set_window 1; @buffer_mode 0; font off; if(isfirm) { i=(width-(firm->0+15))/2; @set_cursor 1 i; print "Firm: "; style bold; font off; print (arrayp) firm; style roman; font off; print ", Hong Kong"; } if(borders) { @set_cursor 2 1; print "+"; for(i=2:ij; @set_cursor i valueindent; print whcargo-->j; } i=1+2*isfirm+borders; @set_cursor i whindent; print "In use:"; i++; @set_cursor i whindent; print " ",WAREHOUSE_CAPACITY-whvacancy; i++; @set_cursor i whindent; print "Vacant:"; i++; @set_cursor i whindent; print " ",whvacancy; i=5+2*isfirm+2*borders; j=borders+1; @set_cursor i j; print "Hold: "; if (fpclassify(holdfree) & (FP_NORMALM | FP_SUBNORMALM)) { style reverse; font off; print "Overload"; style roman; font off; } else print (fp) holdfree; @set_cursor i gunindent; print "Guns: ", guns; i++; if (seccol) { @set_cursor i cargoindent; print (string) scargonames-->0; @set_cursor i valueindent; print (fp) cargo; @set_cursor i seccol; print (string) scargonames-->1; @set_cursor i 18; print (fp) cargo+2; i++; @set_cursor i cargoindent; print (string) scargonames-->3; @set_cursor i valueindent; print (fp) cargo+6; @set_cursor i seccol; print (string) scargonames-->2; @set_cursor i 18; print (fp) cargo+4; i++; } else { for(j=0:j<4:j++) { @set_cursor i cargoindent; print (string) scargonames-->j; @set_cursor i valueindent; print (fp) cargo+4*j; i++; } } i=i+borders; @set_cursor i 1; print "Cash: ", (fpword) cash; @set_cursor i whindent; print "Bank: ", (fpword) bank; i++; @set_cursor i 1; for(i=1:i<=width:i++) print "-"; i=isfirm+borders+1; @set_cursor i column; spaces 3-trunc; print "Date"; i++; @set_cursor i column; if (~~trunc) print "15 "; style reverse; font off; print (string) monthnames-->month; style roman; font off; print " ",year; i=i+1+isfirm; @set_cursor i column; spaces 1-trunc; print "Location"; i++; @set_cursor i column; spaces (locindent->location)-trunc; style reverse; font off; print (string) locnames-->location; style roman; font off; i=i+1+borders; @set_cursor i column; spaces 3-trunc; print "Debt"; i++; @set_cursor i column; typebuf-->0=254; @output_stream 3 typebuf; print (fpword) debt; @output_stream -3; spaces (10-typebuf-->0)/2-trunc; style reverse; font off; print (warrayp) typebuf; style roman; font off; i=i+1+(seccol==0); @set_cursor i column; if (trunc) print " Status "; else print "Ship status"; i++; @set_cursor i column; j=100-(dam2*10-shipsize/10)/(shipsize/5); if(j<0) j=0; spaces 3*trunc; if(j<40) { style reverse; font off; } if(~~trunc) print (string) qualnames-->(j/20),":"; print j; style roman; font off; @set_window 0; @buffer_mode 1; font on; ]; [ LowerWindowSetup i; @erase_window 0; font off; if (i==0) print "Comprador's Report^^"; else if (i==1) print " Captain's Report^^"; else if (i==2) { print "Comprador's Report^^"; font on; print "Taipan, present prices per unit here are^"; font off; @output_stream 3 typebuf; print " ", (string) scargonames-->0,": ", (fp) prices; @output_stream -3; print (warrayp) typebuf; spaces 17-typebuf-->0; print (string) scargonames-->1,": ", (fp) prices+4,"^"; @output_stream 3 typebuf; print " ", (string) scargonames-->2,": ", (fp) prices+8; @output_stream -3; print (warrayp) typebuf; spaces 17-typebuf-->0; print (string) scargonames-->3,": ", (fp) prices+12,"^"; } font on; ]; [ DrawFightWindow i; @set_window 1; @buffer_mode 0; font off; @set_cursor 1 1; print " ships attacking, Taipan!"; @set_cursor 2 1; print "Your orders are to:"; i=width-8; @set_cursor 1 i; print "| We have"; @set_cursor 2 i; print "| guns"; @set_cursor 3 i; print "+--------"; @set_window 1; @buffer_mode 0; ]; [ RedrawFightWindow ships; @buffer_mode 0; font off; @set_cursor 1 1; if (ships<10) print " ", ships; else if (ships<100) print " ", ships; else if (ships<1000) print " ", ships; else print ships; ships=width-7; @set_cursor 2 ships; if (guns<10) print " ", guns; else if (guns<100) print " ", guns; else print guns; ]; [ DrawShip i j; @set_window 1; @buffer_mode 0; font off; if (i<5) { j=(enemywidth+1)*i+1; for(i=6:i<=10:i++) { @set_cursor i j; print (string) shipstrings-->((6-enemywidth)*5+i-1); } } else { j=(enemywidth+1)*(i-5)+1; for(i=12:i<=16:i++) { @set_cursor i j; print (string) shipstrings-->((5-enemywidth)*5+i-2); } } ]; [ EraseShip i j; @set_window 1; @buffer_mode 0; font off; if (i<5) { j=(enemywidth+1)*i+1; for(i=6:i<=10:i++) { @set_cursor i j; spaces enemywidth; } } else { j=(enemywidth+1)*(i-5)+1; for(i=12:i<=16:i++) { @set_cursor i j; spaces enemywidth; } } ]; [ SinkShip i j k; @set_window 1; @buffer_mode 0; font off; if (i<5) { j=(enemywidth+1)*i+1; for(k=1:k<=5:k++) { for(i=6:i<=10:i++) { @set_cursor i j; if(i-6((6-enemywidth)*5+i-1-k); } i=random(3); if(fightmode==2) @read_char 1 i rettrue -> i; } } else { j=(enemywidth+1)*(i-5)+1; for(k=1:k<=5:k++) { for(i=12:i<=16:i++) { @set_cursor i j; if(i-12((5-enemywidth)*5+i-2-k); } i=random(3); if(fightmode==2) @read_char 1 i rettrue -> i; } } ]; [ ShootShip i j k; @set_window 1; @buffer_mode 0; j=(i/5)*6+random(5)+5; i=(i%5)*(enemywidth+1)+random(enemywidth); @set_cursor j i; style reverse; font off; print "*"; if(fightmode==2) @read_char 1 1 rettrue -> k; @set_cursor j i; style roman; font off; print "*"; ]; [ ReturningFire i j k; for(i=0:i<6:i++) { if(i%2) style reverse; else style roman; for(k=1:k<6:k++) { @set_cursor k 1; for(j=0:j j; } style roman; for(i=1:i<6:i++) { @set_cursor i 1; spaces width; } ]; [ WinScreen; @split_window 0; @erase_window 0; print "Your final status:^^"; fadd(real2,cash,bank); fsub(real1,real2,debt); fitos(real4,100); fdiv(real2,real1,real4); ! Eeeagh we need time^1.1. I've settled for time^35/32. fitos(real3,time); fsqrt(real4,real3); fsqrt(real5,real4); fsqrt(real4,real5); fsqrt(real5,real4); fmul(real6,real3,real5); fsqrt(real4,real5); fmul(real3,real6,real4); fdiv(real4,real2,real3); frnd(real2,real4); print "Net Cash: ", (fpword) real1; print "^^Ship size: ", shipsize, " units with ", guns," guns^^"; print "You traded for ", time/12, " year"; if (time<12 || time>23) print "s"; print " and ", time%12, " month"; if (time%12~=1) print "s"; print "^^"; style reverse; print "Your score is ",(fp) real2; style roman; print "^^"; fitos(real1,99); fitos(real3,0); if(fge(real2,real3) && flt(real2,real1)) print "Have you considered a land based job?^"; else if(flt(real2,real3)) print "The crew has requested that you stay on shore for their safety!!^"; print "^"; print "Your rating:^"; font off; print "+-------------------------------+^|"; fitos(real3,5000); fitos(real4,10); fmul(real1,real3,real4); if (fge(real2,real1)) style reverse; font off; print "Ma Tsu"; style roman; font off; print " 50,000 and over |^|"; fitos(real3,8000); if (fge(real2,real3) && flt(real2,real1)) style reverse; font off; print "Master Taipan"; style roman; font off; print " 8,000 to 49,999|^|"; fitos(real1,1000); if (fge(real2,real1) && flt(real2,real3)) style reverse; font off; print "Taipan"; style roman; font off; print " 1,000 to 7,999 |^|"; fitos(real3,500); if (fge(real2,real3) && flt(real2,real1)) style reverse; font off; print "Compradore"; style roman; font off; print " 500 to 999|^|"; if (flt(real2,real3)) style reverse; font off; print "Galley Hand"; style roman; font off; print " less than 500|^"; print "+-------------------------------+^"; ];