# Qbasicnews.com

Full Version: QB Obfuscation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Heres a quick challenge I hope a few of you will enter.

Obfuscation of Qb code!

I got the idea when Nathan mention the IOCCC (The International Obfuscated C Code Contest). (if you dont know what obfuscated code looks like, try this and look at the .c files. they are all working programs.)
The point is to make your code as hard to read and different looking from the normal properly formattted language. Unfortunately this is quite hard in QB, and is really suited for C, but I thought we could have a go =)

I have written a small 3D wireframe app:
Code:
```TYPE pt: x AS SINGLE: y AS SINGLE: z AS SINGLE: END TYPE READ dps: DIM p(dps) AS pt: TYPE ln: l1 AS INTEGER: l2 AS INTEGER: END TYPE FOR i = 1 TO dps: READ p(i).x, p(i).y, p(i).z: NEXT: READ dls DIM l(dls) AS ln: FOR i = 1 TO dls: READ l(i).l1, l(i).l2: NEXT pc = 3.14 / 180: zm = 20: SCREEN 7, , 1, 0: DO: kp = INP(96): d\$ = INKEY\$ SELECT CASE kp: CASE 1: CLS : END: CASE 78: zm = zm - 1: CASE 74: zm = zm + 1 CASE 72, 75, 73: d = 5: CASE 80, 77, 81: d = 355: END SELECT: SELECT CASE kp CASE 75, 77: FOR i = 1 TO dps: nx = COS(d * pc) * p(i).x - SIN(d * pc) * p(i).z nz = SIN(d * pc) * p(i).x + COS(d * pc) * p(i).z: p(i).x = nx: p(i).z = nz NEXT: CASE 72, 80: FOR i = 1 TO dps: nz = COS(d * pc) * p(i).z - SIN(d * pc) * p(i).y ny = SIN(d * pc) * p(i).z + COS(d * pc) * p(i).y: p(i).z = nz: p(i).y = ny NEXT: CASE 73, 81: FOR i = 1 TO dps: ny = COS(d * pc) * p(i).y - SIN(d * pc) * p(i).x nx = SIN(d * pc) * p(i).y + COS(d * pc) * p(i).x: p(i).y = ny p(i).x = nx: NEXT: END SELECT: FOR i = 1 TO dls IF p(l(i).l1).z + zm > 0 AND p(l(i).l2).z + zm > 0 THEN x11 = p(l(i).l1).x * 256: xy11 = (p(l(i).l1).z + zm): y11 = p(l(i).l1).y * 256 x21 = p(l(i).l2).x * 256: xy21 = (p(l(i).l2).z + zm): y21 = p(l(i).l2).y * 256 x1 = x11 / xy11 + 160: y1 = y11 / xy11 + 100: x2 = x21 / xy21 + 160 y2 = y21 / xy21 + 100: LINE (x1, y1)-(x2, y2) END IF: NEXT: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: PCOPY 1, 0: CLS : LOOP DATA 8,-5,2,-5,5,2,-5,-5,-2,-5,5,-2,-5,-5,2,5,5,2,5,-5,-2,5,5 DATA -2,5,12,1,2,4,2,6,2,7,3,1,3,4,3,6,5,8,6,8,7,5,7,4,8,5,1```

Your entry does not have to be big, but can be a even a small algo for (for example) printing the Fibbonachi numbers or working out prime numbers etc.
I demand that this post gets deleted at once, i almost became blind looking at that. I'm not kidding. QBers write obfuscated code without trying, there's no need to make it any worse.
Oh come on Blitz, dont be a grumpy old fart. =P 100% of my code is clean, properly formatted, commented and indented, so I thought, wheres the harm in writing something completely opposite for once. Sheesh.

Oh well, at least if it provked you to complain, it means that the point of it worked He He... If you want obfuscation you may dig for GW-BASIC code. This is a very old game I coded in 1994 or 1995:

Code:
```10 DATA 176,177,14,219,220,223,176,196,79,111,88,60,62,250,32,65,66,67,68,69,70,71,72,73,74 20 SCREEN 0, 0, 0: WIDTH 80: COLOR 7, 0, 1 80 DIM C\$(25): RESTORE 10: FOR N = 1 TO 25: C\$(N) = "": READ P: C\$(N) = CHR\$(P): NEXT 120 CLS 130 DATA 8,1,9,3,11,7,15 140 RESTORE 130 150 FOR N = 1 TO 7: READ COL: LOCATE N * 3 - 1: COLOR COL: PRINT STRING\$(240, "Â±"): NEXT 200 LOCATE 1, 1 210 PRINT "FALL IV (C) 1995 por JFK designs B.A.S.I.C. division, CO. LTD." 220 DATA "oooooo  ooooooo  o        o          ooooo   o      o " 230 DATA "opppppp opppppop op       op          poppp  op     op" 240 DATA "ooooo   ooooooop op       op           op    op     op" 250 DATA "oppppp  opppppop op       op           op     op   op" 260 DATA "op      op    op op       op           op      o  o p" 270 DATA "op      op    op ooooooo  ooooooo    ooooo      oo p" 275 DATA " p       p     p  ppppppp  ppppppp    ppppp      pp" 280 FOR N = 1 TO 7: READ P\$: FOR A = 1 TO LEN(P\$): M\$ = MID\$(P\$, A, 1): LOCATE 5 + N, 10 + A 330 IF M\$ = "o" THEN COLOR 5: PRINT "Ã" 340 IF M\$ = "p" THEN COLOR 1: PRINT "Ã" 350 NEXT: NEXT 370 COLOR 14: LOCATE 5, 66: PRINT "TM" 390 LOCATE 14, 10: PRINT "Programado por na_th_an en Marzo de 1995." 395 COLOR 15 400 LOCATE 17, 15: PRINT "Keyboard O left P right": LOCATE 19, 19: PRINT "Press J Play Q Quit" 440 LET Z\$ = INKEY\$ 450 IF Z\$ = "j" THEN GOTO 500 460 IF Z\$ = "q" THEN GOTO 480 470 GOTO 440 480 COLOR 0, 7, 10 490 CLS 500 ' Game start 501 CLS : INPUT "Difficulty level? (5000 megahard, 0 megaeasy)"; nivel 502 INPUT "Amount of different bricks? (4 to 25)"; NUM 503 IF NUM < 4 OR NUM > 25 THEN 502 510 CLS: FOR N = 1 TO 21: COLOR 1, 0: LOCATE N, 1: PRINT STRING\$(8, "Â±"); : COLOR 0, 4: PRINT "Â²Â²"; : COLOR 7, 0: PRINT SPACE\$(20); : COLOR 0, 4: PRINT "Â²Â²"; : COLOR 1, 0: PRINT STRING\$(48, "Â±"); : NEXT 640 PRINT STRING\$(8, "Â±"); : COLOR 0, 4: PRINT STRING\$(24, "Â²"); : COLOR 1, 0: PRINT STRING\$(48, "Â±"): PRINT STRING\$(80, "Â±") 662 COLOR 0, 7: LOCATE 4, 42: PRINT "/--------------------\": LOCATE 5, 42: PRINT "|                    |": LOCATE 6, 42: PRINT "|                    |": LOCATE 7, 42: PRINT "|                    |": LOCATE 8, 42: PRINT "\--------------------/": LOCATE 5, 45: PRINT "PuntuaciÂ¢n:" 680 LET SCORE = 0: LOCATE 7, 50: PRINT SCORE 700 ' Game itself 710 ' Select brick 720 LET PIEZA = INT(RND * NUM) + 1 740 LET Y = 1: LET X = 18 750 ' start 760 ' check if there's somethin' under the brick 790 ' move brick down 800 Y = Y + 1 801 LET CHAR = SCREEN(Y + 2, X): IF CHAR <> 32 THEN GOTO 1040 810 ' draw brick 815 GOSUB 1150 819 K = PI + 8 820 LOCATE Y, X: COLOR K, PI: PRINT C\$(PIEZA) + C\$(PIEZA) 821 LOCATE Y + 1, X: COLOR K, PI: PRINT C\$(PIEZA) + C\$(PIEZA) 830 ' delete prev brick 840 LOCATE Y - 1, X: COLOR 7, 0: PRINT "  " 850 ' left or right 860 TECLADO\$ = INKEY\$ 870 IF TECLADO\$ = "o" AND X > 10 AND SCREEN(Y, X - 2) = 32 THEN X = X - 2: LOCATE Y, X: COLOR PI, 0: PRINT C\$(PIEZA) + C\$(PIEZA); : COLOR 7, 0: PRINT "  ": LOCATE Y + 1, X: COLOR 0, PI: PRINT C\$(PIEZA) + C\$(PIEZA); : COLOR 7, 0: PRINT "  " 880 IF TECLADO\$ = "p" AND X < 28 AND SCREEN(Y, X + 2) = 32 THEN LOCATE Y, X: COLOR 7, 0: PRINT "  "; : COLOR 0, PI: PRINT C\$(PIEZA) + C\$(PIEZA): LOCATE Y + 1, X: COLOR 7, 0: PRINT "  "; : COLOR 0, PI: PRINT C\$(PIEZA) + C\$(PIEZA): X = X + 2 890 ' delay 891 FOR i% = 0 TO 10 - (nivel \ 500) 892 WAIT &H3DA, 8 893 WAIT &H3DA, 8, 8 1000 NEXT 1010 ' print score 1011 COLOR 0, 7 1020 LOCATE 7, 50: PRINT SCORE 1030 GOTO 750 1040 ' something 1045 K = PI + 8 1050 LOCATE Y - 1, X: COLOR 7, 0: PRINT "  " 1060 LOCATE Y, X: COLOR K, PI: PRINT C\$(PIEZA) + C\$(PIEZA) 1070 LOCATE Y + 1, X: COLOR K, PI: PRINT C\$(PIEZA) + C\$(PIEZA) 1080 SCR = SCREEN(Y + 2, X) 1090 IF SCR = ASC(C\$(PIEZA)) THEN PLAY "l64c": LOCATE Y, X: COLOR 7, 0: PRINT "  ": LOCATE Y + 1, X: PRINT "  ": LOCATE Y + 2, X: PRINT "  ": SCORE = SCORE + ASC(C\$(PIEZA)) + Y 1100 PLAY "l64b" 1110 IF Y = 2 THEN LOCATE 11, 1: COLOR 0, 4: PRINT "<<<<<<<<<<<<<<<<<<<<<<<             GAME OVER               >>>>>>>>>>>>>>>>>>>>": GOTO 1130 1120 GOTO 700 1130 IF INKEY\$ = "" THEN 1130 1140 RUN 1150 IF PIEZA < 8 THEN PI = PIEZA: RETURN 1160 IF PIEZA < 15 THEN PI = PIEZA - 7: RETURN 1170 IF PIEZA < 22 THEN PI = PIEZA - 14: RETURN 1180 IF PIEZA < 26 THEN PI = PIEZA - 21: RETURN 1190 RETURN```

:barf:
Heh heh! I like your code =) Esp. the way it wasnt even written especially to be confusing! Brilliant!

Any more people?
Hehe that's the funny part: I just sucked coding Quote:I demand that this post gets deleted at once, i almost became blind looking at that. I'm not kidding. QBers write obfuscated code without trying, there's no need to make it any worse.
LOL Come on people! Stop being lazy! Especially as this challenge is so utterly undemanding =P And Rel, you posted in the thread so now you have to enter, ok? =)
Quote:......The point is to make your code as hard to read and different looking from the normal properly formattted language. Unfortunately this is quite hard in QB....
Oh yeah, take a look at some of the examples in some of the posts here, like: "Why doesn't my program work?". You look at it and decide that it's a miracle that the convoluted mess even compiles."
*****
Ok, ok, I meant compared to making something as f*cked up as this:

Code:
```char*d,A;char*d,A;char*d,A;char*d,A;char*d,A;char e;b;*ad,a,c;  te;b;*ad,a,c;  te;*ad,a,c;  w,te;*ad,a,  w,te;*ad,and,  w,te;*ad, r,T; wri; ;*h; r,T; wri; ;*h; r; wri; ;*h;_, r; wri;*h;_, r; wri;*har;_, r; wri   ;on; ;l ;i(V)  ;on; ;l ;i(V)  ;o ;l ;mai(V)  ;o  ;mai(n,V)    ;main (n,V)        {-!har  ;      {-!har  ;      {har  =A;      {h  =A;ad        =A;read       (0,&e,o||n -- +(0,&e,o||n -- +(0,&o||n ,o-- +(0,&on ,o-4,- +(0,n ,o-=94,- +(0,n ,l=b=8,!( te-*A,l=b=8,!( te-*A,l=b,!( time-*A,l=b, time)|-*A,l= time(0)|-*A,l= ~l),srand  (l),~l),srand  (l),~l),and  ,!(l),~l),a  ,!(A,l),~l)  ,!(d=A,l),~l) ,b))&&+((A + te,b))&&+((A + te,b))+((A -A+ te,b))+A -A+ (&te,b+A -A+(* (&te,b+A )=+ +95>e?(*& c)=+ +95>e?(*& c) +95>e?(*& _*c) +95>(*& _*c) +95>(*&r= _*c) +95> 5,r+e-r +_:2-195,r+e-r +_:2-195+e-r +_:2-1<-95+e-r +_-1<-95+e-r ++?_-1<-95+e-r |(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d==d),!n ?*d||(d= *( (char**)+V+ *( (char)+V+ *( (c),har)+V+  (c),har)+ (V+  (c),r)+ (V+  (  c), +0,*d-7 ) -r+8)+0,*d-7 -r+8)+0,*d-c:7 -r+80,*d-c:7 -r+7:80,*d-7 -r+7:80,*d++-7 +7+! r: and%9- +7+! rand%9-85 +7+! rand%95 +7+!!  rand%95 +7+  rand()%95 +7+  r -(r+o):(+w,_+ A-(r+o)+w,_+*( A-(r+o)+w,_+ A-(r=e+o)+w,_+ A-(r+o)+wri,_+ A-(r+o) +(o)+b)),!write+(o)+b,!wri,(te+(o)+b,!write+(o=_)+b,!write+(o)+b,!((write+(o)+b -b+*h)(1,A+b,!!-b+*h),A+b,((!!-b+*h),A+b,!!-b+((*h),A+b,!!-b+*h),A-++b,!!-b+*h) , a >T^l,( o-95, a >T,( o-=+95, a >T,( o-95, a)) >T,( o-95, a >T,(w? o-95, a >T ++  &&r:b<<2+a ++  &&b<<2+a+w ++  &&b<<2+w ++  ) &&b<<2+w ++  &&b<<((2+w ++  && !main(n*n,V) , !main(n,V) , !main(+-n,V) ,main(+-n,V) ) ,main(n,V) ) ,main),(n, l)),w= +To +l)),w= +T>o +l)),w=o+ +T>o +l,w=o+ +T>o;{ +l,w=o+T>o;{ +l,w &=o+ !a;}return _+= !a;}return _+= !a;}return _+= !a;}return _+= !a;}return _+= !a;}```
Pages: 1 2 3