1 DEFINTA-G:DEFSTRH:DEFSNGI-Z:DIM A[8],AX[8],BX[8],AY[8],BY[8]:COLOR15,0,0:SCREEN7:FORA=1TO15:READB,C,D:COLOR=(A,B,C,D):NEXT:AW=512:AH=212:KX=-1.5:KY=-.8:LX=1.25:LY=.8:FORF2=0TO1STEP0:AX[0]=0:AY[0]=0:BX[0]=AW:BY[0]=AH:F=0:G=0:CLS:GOSUB4:'A TO1STEP-1:Z=ZX:ZX=Z*Z-ZY*ZY+P:ZY=2*Z*ZY+Q:IF(ZX*ZX+ZY*ZY)<25THENNEXT:RETURNELSERETURN
I *really* didn't know that BASIC arrays could used with [] instead of () !!! Amazing.
ricbit you don't even have to give a size to the array as far as I know.
I just discovered a little bug in my brainfuck interpreter, which caused some programs to be read incorrectly. The first version also entered in an endless loop after executing all source code. I removed those 3 extra pokes from line 1, and added an termination clause to line 2, so when a BF program ends, the interpreter stops as well. Here's the 2nd version:
1 IFGTHENPRINTCHR$(VAND(-255*(C=46)));:RESUMENEXTELSEDEFINTA-Z:ONERRORGOTO1:G=&H 9000:FORD=GTO&H9100:POKED,0:NEXT:INPUT"File:";H$:OPENH$FORINPUTAS1:Q=&HA000:P=Q- 1:FORA=0TO1:POKEQ,ASC(INPUT$(1,1)):Q=Q+1:A=-EOF(1):NEXT:CLOSE:PRINT"Running..." 2 P=P+1:IFP=QTHENENDELSEC=PEEK(P):G=G+(C=60)-(C=62):V=PEEK(G):POKEG,V+(C=45)-(C= 43):POKEG,ASC(INPUT$(-(C=44))):IFC=91ANDV=0ORC=93ANDVTHENL=1:I=92-C:FORA=0TO1:P= P+I:C=PEEK(P):L=L-(C=91)*I+(C=93)*I:A=-(L=0):NEXT:GOTO2ELSEGOTO2
Here's another sample program (which runs correctly now ):
>++++++++++>>+<+[[+++++[>++++++++<-]>.<++++++[>--------<-]+<<]>.>[->[<++>-]<[>+< -[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>+<-[>[-]>[-]++<<-[>+<-]]]]]]]]]]]+>>]<<]
This program (not made by me) calculates and displays powers of two.
Thanx Arjan for taking one thing out of my TODO list. It is already big enough
You're welcome
btw, could everybody please format their programs nicely (ie, 80 characters per line) so that they won't mess up the forum layout?
This forum needs a codebox!
Which is a limited-sized frame with a vertical and horizontal scrollbar with text of any dimensions inside
hmm, for some reason I just *have* to toy around with these little programs... I keep thinking what I coded is the best that can be done in 2 lines of basic code, but then I find another cool thing that can be implemented without crossing my 2-line limit
So, another update. This time the program shows the PC and the current instruction. The "Running..." message had to be removed for this, but it's nicer this way since you can see the program is actually running
1 IFGTHENKEY1,HEX$(P)+K$:PRINTCHR$(VAND(-255*(C=46)));:RESUMENEXTELSEDEFINTA-Z:O NERRORGOTO1:G=&H9000:FORD=GTO&H9100:POKED,0:NEXT:INPUT"File:";H$:OPENH$FORINPUTA S1:Q=&HA000:P=Q-1:FORA=0TO1:POKEQ,ASC(INPUT$(1,1)):Q=Q+1:A=-EOF(1):NEXT:CLOSE 2 P=P+1:IFP=QTHENENDELSEC=PEEK(P):K$=":"+CHR$(C):G=G+(C=60)-(C=62):V=PEEK(G):POK EG,V+(C=45)-(C=43):POKEG,ASC(INPUT$(-(C=44))):IFC=91ANDV=0ORC=93ANDVTHENL=1:I=92 -C:FORA=0TO1:P=P+I:C=PEEK(P):L=L-(C=91)*I+(C=93)*I:A=-(L=0):NEXT:GOTO2ELSEGOTO2
some work-in-progress stuff:
1 'Bomberman Battle IOMBCC 2 'todo: random map 3 ' graphics 4 ' optimize char codes to use to display things 5 ' optimize, optimize, optimize! 10 DEFINTA-Z:ONERRORGOTO80:SCREEN1:WIDTH32:KEYON:LOCATE5,5:PRINT"--------------- ---";:C(0)=6408:C(1)=6408+8+64:S$=CHR$(10)+CHR$(13)+SPACE$(5)+"-"+"W"+SPACE$(15) +"-":S$=S$+S$:PRINTS$;S$;S$;S$:PRINTSPACE$(5);"------------------":P=1 41 GOSUB50:GOSUB50:VPOKEC(0),88:VPOKEC(1),88:GOTO41 50 P=1-P:A=STICK(P):N=C(P)-(A=3)+(A=7)+(A=1)*32-(A=5)*32 60 H=0:M=H:S=M:W=VPEEK(N):IFW=32ORW=42ANDC(P)<>NTHENVPOKEC(P),32:C(P)=N 70 IFSTRIG(P)ANDT(P)=0THENT(P)=50:B(P)=C(P)ELSEIFT(P)>0THENVPOKEB(P),79+32*(T(P) AND1):T(P)=T(P)-1:E(P)=-15*(T(P)=0) 80 IFHTHENV=B(P)+S:S=S*2:R=VPEEK(V):IFR<>45ANDM=0THENVPOKEV,G:RESUMENEXTELSEM=1: IFR=87THENVPOKEV,32:RESUMENEXTELSERESUMENEXTELSEW=E(P):IFW>0THENW=W-1:E(P)=W:IFW =14ORW=0THENG=42+(W=0)*10:H=1:X:S=-1:X:X:M=0:S=1:X:X:M=0:S=-32:X:X:M=0:S=32:X:X 90 IFVPEEK(C(P))=42THENY(1-P)=Y(1-P)+1:KEY2-P,HEX$(Y(1-P)):RETURNELSERETURN
Did we really need 5 years to code Bombaman?!?
Arjan.. if you place a bomb when the explosion occurs you explosion does not dissapear. So just wait until the exploision has cleared. The count in in hexadecimals too
Nice entry
(ps a key off would help too for people who did not do a set screen)
AuroraMSX: you're right, I totally overlooked the mini manual... hit me please!
/me reaches out from Munich to Nijmegen
Darn. Too far away...