{{htmlmetatags>metatag-robots=() metatag-title=( | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(An isomorphic language for retrocomputers) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=( | ugBASIC User Manual) metatag-og:description=(An isomorphic language for retrocomputers) }} ====== ugBASIC Manuale Utente ====== ===== ===== ==== SCOPO ==== ==== SORGENTE ==== 'DEFINE STRING SPACE 512 'DEFINE STRING COUNT 32 'DEFINE SCREEN MODE UNIQUE OPTION DEFAULT TYPE INTEGER TILEMAP ENABLE: CLS 10 PRINT SPC((TILES WIDTH - 8)/2);"HAMURABI" 20 PRINT SPC((TILES WIDTH - 18)/2);"CREATIVE COMPUTING" PRINT SPC((TILES WIDTH - 22)/2);"MORRISTOWN, NEW JERSEY" 30 PRINT:PRINT:PRINT 80 PRINT "TRY YOUR HAND AT GOVERNING ANCIENT SUMERIA"; 90 PRINT " FOR A TEN-YEAR TERM OF OFFICE.":PRINT REM Initializes random number generator in a way that works for emulators too PRINT "PRESS A KEY...": WAIT KEY RELEASE: RANDOMIZE RASTER LINE 95 dead=0: DIM percStarved AS FLOAT: percStarved=0: DIM app AS FLOAT 100 year=0: population=95: store=2800: harvested=3000: eaten=harvested-store 110 bpa=3: acres=harvested/bpa: babies=5: plagueRoll=1: REM this is a value in [-3,16] that when <=0 will cause a plague 210 starved=0 CLS 215 PRINT:PRINT:PRINT "HAMURABI: I BEG TO REPORT TO YOU, ";: year=year+1 217 PRINT "IN YEAR ";year;", ";starved;" PEOPLE STARVED,";babies;" CAME TO THE CITY.": PRINT 218 population=population+babies 227 IF plagueRoll>0 THEN 230 228 population=population/2 229 PRINT "A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED." 230 PRINT "POPULATION : ";population PRINT "ACRES OWNED: ";acres PRINT "HARVESTED : ";bpa;" BUSHELS/ACRE" PRINT "RATS ATE : ";eaten;" BUSHELS" PRINT "STORE : ";store;" BUSHELS": PRINT 270 IF year=11 THEN 860 REM Check whether player wants to buy land 310 c=RND(10): bpa=c+17 312 PRINT "LAND PRICE : ";bpa;" BUSHELS/ACRE." 320 PRINT "BUY HOW MANY ACRES? "; 321 INPUT q: IF q<0 THEN 850: REM Get angry and leave 322 IF bpa*q<=store THEN 330 323 GOSUB 710: REM Error message 324 GOTO 320 330 IF q=0 THEN 340 331 acres=acres+q: store=store-bpa*q: c=0 334 GOTO 400 REM Check whether player wants to sell land 340 PRINT "SELL HOW MANY ACRES? "; 341 INPUT q: IF q<0 THEN 850: REM Get angry and leave 342 IF q0 THEN 530 525 eaten=store/c 530 store=store-eaten+harvested 531 GOSUB 800 533 babies=INT((20.0*acres+store)*c/population/100.0+1.0) 540 fed=q/20 REM This is indeed 20% chance 542 plagueRoll=RND(20)-3: 550 IF population(0.45*population) THEN 560 553 percStarved=(percStarved*(year-1)+100.0*starved/population)/year 555 population=fed: dead=dead+starved: GOTO 215 560 PRINT: PRINT "YOU STARVED ";starved;" PEOPLE IN ONE YEAR!!!" REM Impeachment message 565 PRINT "DUE TO THIS EXTREME MISMANAGEMENT YOU HAVE NOT ONLY "; 566 PRINT "BEEN IMPEACHED AND THROWN OUT OF OFFICE BUT YOU HAVE "; 567 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!": GOTO 990 REM Asked to sell too many bushels 710 PRINT "YOU HAVE ONLY "; 711 PRINT store;"BUSHELS OF GRAIN." 712 RETURN REM Asked to sell too many acres 720 PRINT "YOU OWN ONLY ";acres;" ACRES." 730 RETURN REM Roll a 6-side dice in c 800 c=RND(5)+1 801 RETURN REM An invalid order was entered (e.g. buy a negative quantity of acres) 850 PRINT: PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH." 855 PRINT "GET YOURSELF ANOTHER STEWARD!!!!!" 857 GOTO 990 REM End of game 860 PRINT: PRINT "IN YOUR TERM "; INT(percStarved); "% "; 862 PRINT "PEOPLE DIED ON AVERAGE EACH YEAR. A TOTAL OF "; 865 PRINT dead;"!!": app=acres/population 870 PRINT "YOU STARTED WITH 10 ACRES/PERSON AND ENDED WITH "; 875 PRINT INT(app);" ACRES/PERSON.": PRINT 880 IF percStarved>33.0 THEN 565: REM Impeachemnt message 885 IF app<7.0 THEN 565 890 IF percStarved>10.0 THEN 940 892 IF app<9.0 THEN 940 895 IF percStarved>3.0 THEN 960 896 IF app<10.0 THEN 960 900 PRINT "A FANTASTIC PERFORMANCE!!! CHARLEMANGE, DISRAELI, AND "; 905 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!":GOTO 990 940 PRINT "YOUR HEAVY-HANDED PERFORMANCE SMACKS OF NERO AND IVAN IV. "; 945 PRINT "THE PEOPLE (REMIANING) FIND YOU AN UNPLEASANT RULER, AND, "; 950 PRINT "FRANKLY, HATE YOUR GUTS!!":GOTO 990 960 PRINT "YOUR PERFORMANCE COULD HAVE BEEN SOMEWHAT BETTER, BUT "; 965 PRINT "REALLY WASN'T TOO BAD AT ALL. ";INT(0.8*RND(population));" PEOPLE "; 970 PRINT "WOULD DEARLY LIKE TO SEE YOU ASSASSINATED BUT WE ALL HAVE OUR "; 975 PRINT "TRIVIAL PROBLEMS." 990 PRINT: FOR n=1 TO 10: 'BELL: NEXT n 995 PRINT "SO LONG FOR NOW.": PRINT 999 END ==== FILE ==== * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/bug905.bas|bug905.bas]]'' ==== COME ESEGUIRLO ==== === Atari 400/800 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore Altirra, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.atari bug905.bas -o example.xex altirra example.xex # Windows ugbc.atari.exe bug905.bas -o example.xex altirra example.xex === Atari 600XL/800XL/1200XL/XG(SE) === Per poter eseguire l'esempio, è necessario disporre dell'emulatore Altirra, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.atarixl bug905.bas -o example.xex altirra example.xex # Windows ugbc.atarixl.exe bug905.bas -o example.xex altirra example.xex === Commodore 64 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.c64 bug905.bas -o example.prg x64sc example.prg # Windows ugbc.c64.exe bug905.bas -o example.prg x64sc example.prg === Commodore 64+REU === Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.c64reu bug905.bas -o example.prg x64sc -reu example.prg # Windows ugbc.c64reu.exe bug905.bas -o example.prg x64sc -reu example.prg === Commodore PLUS/4 === == Usando YAPE == Per poter eseguire l'esempio, è necessario disporre dell'emulatore YAPE, e in particolare che l'eseguibile ''yape'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.plus4 bug905.bas -o example.prg yape example.prg # Windows ugbc.plus4.exe bug905.bas -o example.prg yape example.prg == Usando VICE == Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile ''xplus4'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.plus4 bug905.bas -o example.prg xplus4 example.prg # Windows ugbc.plus4.exe bug905.bas -o example.prg xplus4 example.prg === Dragon 32 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore XROAR, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.d32 bug905.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d32.exe bug905.bas -o example.bin xroar.exe -rompath (percorso ROM) example.bin === Dragon 64 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore XROAR, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.d64 bug905.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d64.exe bug905.bas -o example.bin xroar.exe -rompath (percorso ROM) example.bin === PC128 Olivetti Prodest === Per poter eseguire l'esempio, è necessario disporre dell'emulatore DCMOTO, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi i seguenti comandi: # Linux ugbc.pc128op bug905.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe bug905.bas -o example.bin dcmoto example.bin (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC === Thomson MO5 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore DCMOTO, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi i seguenti comandi: # Linux ugbc.mo5 bug905.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.mo5.exe bug905.bas -o example.bin dcmoto example.bin (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC === Commodore VIC-20 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore XEMU, e in particolare che l'eseguibile ''xmega65'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.vic20 bug905.bas -o example.prg xvic --memory 24k example.prg # Windows ugbc.vic20.exe bug905.bas -o example.prg xvic --memory 24k example.prg === ZX Spectrum === Per poter eseguire l'esempio, è necessario disporre dell'emulatore Speccy, e in particolare che l'eseguibile ''speccy'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.zx bug905.bas -o example.tap Speccy example.tap # Windows ugbc.zx.exe bug905.bas -o example.tap Speccy example.tap === ColecoVision === Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore openMsx oppure il BlueMSX, e in particolare che il suo eseguibile sia accessibile. Dopo di che, digita questo comando sulla linea di comando: == openMSX == # Linux ugbc.coleco bug905.bas -o example.rom openmsx -machine \"COL - ColecoVision\" -cart example.rom # Windows ugbc.coleco.exe bug905.bas -o example.rom bluemsx -machine \"COL - ColecoVision\" example.rom == blueMSX == # Linux ugbc.coleco bug905.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom # Windows ugbc.coleco.exe bug905.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom === SEGA SC-3000 === Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore BlueMSX, e in particolare che il suo eseguibile sia accessibile. Dopo di che, digita questo comando sulla linea di comando: # Linux ugbc.sc3000 bug905.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom # Windows ugbc.sc3000.exe bug905.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom === SEGA SG-1000 === Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore BlueMSX, e in particolare che il suo eseguibile sia accessibile. Dopo di che, digita questo comando sulla linea di comando: # Linux ugbc.sg1000 bug905.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom # Windows ugbc.sg1000.exe bug905.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom ==== PROBLEMI? ==== Se hai trovato un problema nel cercare di eseguire questo esempio, se pensi che ci sia un bug o, più semplicemente, vorresti che fosse migliorato, [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=MIGLIORARE |apri una segnalazione]] su GitHub per questo specifico esempio. Grazie!===== POWERED BY ===== [[:it:ugbasic:user:examples|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]