charognard37 Vivement la retraite ! | Le même casse brique mais développé par mes soins en Basic/C/assembleur Z80 sur mon Sharp 850V.
En version automatique, parce que là ça va trop vite
Aller mon côté hebdogiciel
Ce casse brique programmé en Basic
Code :
- 10CLS
- 20S=1
- 30PRINT "SCORE:0"
- 40DIM VI$(5)*80
- 50RA$="0207070707070200
- 60FOR A=1 TO 5
- 70VI$(A)=VI$(A-1)+RA$
- 80NEXT
- 85VI$(0)="0000000000000000
- 90GCURSOR (2,18)
- 100GPRINT VI$(5)
- 110LINE (59,0)-(59,30)
- 120LINE (135,0)-(135,30)
- 130LINE (60,0)-(134,3),BF
- 140LINE (60,6)-(134,9),BF
- 150LV=5:SC=0
- 160BX=96:OBX=BX
- 170Y=10:OX=X:OY=Y:RX=-3:RY=2:RX=(2* RND (2)-3)*RX:X=99-RX*( RND (6)+4)
- 180LINE (BX,30)-(BX+8,30)
- 190X=X+RX:Y=Y+RY
- 200IF X<60 OR X>132 BEEP S,10,10:RX=-RX:X=X+2*RX
- 210IF Y<30 THEN 250
- 220IF (BX<=OX) AND OX<BX+9 BEEP S,20,10:RY=-RY:Y=OY+RY:GOTO 250
- 230IF (OX+RX=BX) OR X-RX=BX+9 BEEP S,20,10:RY=-RY:RX= RX:Y=OY+RY:X=OX+RX: GOTO 250
- 240GOTO 410
- 250IF Y=-2 BEEP S,20,10:RY=-RY:Y=OY+RY
- 260IF POINT (X,Y)=0 THEN 310
- 270BEEP S,10,10
- 280SC=SC+5:LOCATE 6,0:PRINT STR$ SC
- 290LINE (X-RX,Y)-(X-RX+2,Y+1),R,B
- 300Y=Y-2*RY:RY=-RY
- 310GOSUB 360
- 320LINE (OX,OY)-(OX+2,OY+1),R,B
- 330LINE (X,Y)-(X+2,Y+1),B
- 340OX=X:OY=Y
- 350GOTO 190
- 360A$= INKEY$ :A= ASC A$
- 370BX=BX+6*(A=13)*(BX<123)-6*(A=32)*(BX>63)
- 380LINE (OBX,30)-(OBX+8,30),R:LINE (BX,30)-(BX+8,30)
- 390OBX=BX
- 400RETURN
- 410LINE (OX,OY)-(OX+2,OY+1),R,B
- 420LINE (X,Y)-(X+2,Y+1),B
- 430LV=LV-1
- 440GCURSOR (2,18):GPRINT VI$(LV);"00000000000000"
- 450FOR P=1 TO 255 STEP 3:BEEP S,P,2:NEXT
- 460LINE (X,Y)-(X+2,Y+1),R,B
- 470LINE (BX,30)-(BX+8,30),R
- 480IF LV>0 FOR P=1 TO 1000:NEXT :GOTO 160
- 490END
|
En C (et oui le G850V est programmable en C)
Code :
- 10 #define M 65535
- 20 #define VIT 250
- 30 #define INKEY call((int)ink,0)
- 40 void vie(int nbr)
- 50 {
- 60 int b;
- 70 gcursor(2,18);
- 80 for(b=1;b<=nbr;b++) {
- 90 gprint("0207070707070200" );
- 100 }
- 110 gprint("0000000000000000" );
- 120 }
- 130 main()
- 140 {
- 150 char *ink="\xCD\x53\xBE\x6F\x26\x00\xC9";
- 160 int vi=5,sc=0,x=96,y=10,ox=x,oy=y,rx=3,ry=2,bx=x,obx=x,b;
- 170 printf("Score:1" );
- 180 line(59,0,59,30,0,M,0);
- 190 line(135,0,135,30,0,M,0);
- 200 line(60,0,134,3,0,M,2);
- 210 line(60,6,134,9,0,M,2);
- 220 vie(vi);
- 230 do
- 240 {
- 250 line(bx,30,bx+8,30,0,M,0);
- 260 for(b=1;b<VIT;++b){}
- 270 x+=rx;y+=ry;
- 280 if(x<60|x>132)
- 290 {
- 300 beep(10,10,1);
- 310 rx=-rx;x+=2*rx;
- 320 }
- 330 if(y>=30)
- 340 {
- 350 if(bx<=ox&&ox<bx+9)
- 360 {
- 370 beep(10,20,1);
- 380 ry=-ry;y=oy+ry;
- 390 } else if (ox+rx==bx||x-rx==bx+9)
- 400 {
- 410 beep(10,20,1);
- 420 ry=-ry;rx=-rx;y=oy+ry;x=ox+rx;
- 430 } else {
- 440 line(ox,oy,ox+2,oy+1,1,M,1);
- 450 line(x,y,x+2,y+1,0,M,1);
- 460 vie(--vi);
- 470 for(b=1;b<256;b+=3)
- 480 {
- 490 beep(2,b,1);
- 500 }
- 510 line(x,y,x+2,y+1,1,M,1);
- 520 line(bx,30,bx+8,30,1,M,0);
- 530 x=96;y=10;ox=x;oy=y;rx=3;ry=2;bx=x;obx=x;
- 540 }
- 550 } else {
- 560 if(y==-2)
- 570 {
- 580 beep(10,20,1);
- 590 ry=-ry;y=oy+ry;
- 600 }
- 610 if (point(x,y))
- 620 {
- 630 beep(10,10,1);
- 640 sc+=5;
- 650 gotoxy(6,0);printf("%d",sc);
- 660 line(x,y,x+2,y+1,1,M,1);
- 670 y-=ry;ry=-ry;
- 680 }
- 690 b=INKEY;
- 700 bx=bx+6*(b==34)*(bx<123)-6*(b==33)*(bx>63);
- 710 line(obx,30,obx+8,30,1,M,0);
- 720 line(bx,30,bx+8,30,0,M,0);
- 730 obx=bx;
- 740 line(x,y,x+2,y+1,0,M,1);
- 750 line(ox,oy,ox+2,oy+1,1,M,1);
- 760 ox=x;oy=y;
- 770 }
- 780 }
- 790 while(vi>0);
- 800 }
|
Et en Assembleur (Aussi dans le G850V)
Code :
- 10 ORG 0100H
- 20GRAPH EQU 093CBH
- 30PRINT EQU 0BFF1H
- 40 JR START
- 50SC: DB 0,0,0,0
- 60X: DB 0
- 70Y: DB 0
- 80OX: DB 0
- 90OY: DB 0
- 100RX: DB 0
- 110RY: DB 0
- 120PROV:DB 0,0
- 130TXT1:DB 'SCORE:'
- 140START:CALL CLS
- 150 LD B,6
- 160 LD DE,0000H
- 170 LD HL,TXT1
- 180 CALL PRINT
- 190 LD HL,59
- 200 LD DE,0
- 210 LD IX,135
- 220 LD IY,30
- 230 LD A,1
- 240 LD B,1
- 250 CALL LINE
- 260 LD HL,60
- 270 LD DE,0
- 280 LD IX,134
- 290 LD IY,3
- 300 LD A,1
- 310 LD B,2
- 320 CALL LINE
- 330 LD HL,60
- 340 LD DE,6
- 350 LD IX,134
- 360 LD IY,9
- 370 LD A,1
- 380 LD B,2
- 390 CALL LINE
- 400 LD A,0
- 410 LD (SC),A
- 420 LD A,48
- 430 LD (SC+1),A
- 440 LD (SC+2),A
- 450 LD (SC+3),A
- 460 LD A,99
- 470 LD (X),A
- 480 LD (OX),A
- 490 LD A,10
- 500 LD (Y),A
- 510 LD (OY),A
- 520 LD A,-3
- 530 LD (RX),A
- 540 LD A,2
- 550 LD (RY),A
- 560REP: LD A,(RY)
- 570 LD B,A
- 580 LD A,(Y)
- 590 ADD A,B
- 600 LD (Y),A
- 610 LD A,(RX)
- 620 LD B,A
- 630 LD A,(X)
- 640 ADD A,B
- 650 LD (X),A
- 660 CP 60
- 670 JR C,OK1
- 680 CP 133
- 690 JR C,SU1
- 700OK1: LD A,(RX)
- 710 NEG
- 720 LD (RX),A
- 730 ADD A,A
- 740 LD B,A
- 750 LD A,(X)
- 760 ADD A,B
- 770 LD (X),A
- 780SU1: LD A,(Y)
- 790 CP 30
- 800 JR NC,OK2
- 810 CP -2
- 820 JR NZ,SU2
- 830OK2: LD A,(RY)
- 840 NEG
- 850 LD (RY),A
- 860 LD B,A
- 870 LD A,(OY)
- 880 ADD A,B
- 890 LD (Y),A
- 900SU2: LD A,(X)
- 910 LD E,A
- 920 LD A,(Y)
- 930 LD D,A
- 940 CALL POI
- 950 CP 1
- 960 JR NZ,SU3
- 970 LD A,(SC)
- 980 ADD A,5
- 990 LD (SC),A
- 1000 CALL SCOR
- 1010 LD B,3
- 1020 LD DE,0006H
- 1030 LD HL,SC+1
- 1040 CALL PRINT
- 1050 LD A,(X)
- 1060 LD H,0
- 1070 LD L,A
- 1080 ADD A,2
- 1090 LD (PROV),A
- 1100 LD IX,(PROV)
- 1110 LD A,(Y)
- 1120 LD D,0
- 1130 LD E,A
- 1140 ADD A,1
- 1150 LD (PROV),A
- 1160 LD IY,(PROV)
- 1170 LD A,0
- 1180 LD B,1
- 1190 CALL LINE
- 1200 LD A,(RY)
- 1210 LD B,A
- 1220 LD A,(Y)
- 1230 SUB B
- 1240 LD (Y),A
- 1250 LD A,(RY)
- 1260 NEG
- 1270 LD (RY),A
- 1280SU3:LD A,(X)
- 1290 LD H,0
- 1300 LD L,A
- 1310 ADD A,2
- 1320 LD (PROV),A
- 1330 LD IX,(PROV)
- 1340 LD A,(Y)
- 1350 LD D,0
- 1360 LD E,A
- 1370 ADD A,1
- 1380 LD (PROV),A
- 1390 LD IY,(PROV)
- 1400 LD A,1
- 1410 LD B,1
- 1420 CALL LINE
- 1430 LD A,(OX)
- 1440 LD H,0
- 1450 LD L,A
- 1460 ADD A,2
- 1470 LD (PROV),A
- 1480 LD IX,(PROV)
- 1490 LD A,(OY)
- 1500 LD D,0
- 1510 LD E,A
- 1520 ADD A,1
- 1530 LD (PROV),A
- 1540 LD IY,(PROV)
- 1550 LD A,0
- 1560 LD B,1
- 1570 CALL LINE
- 1580 LD A,(X)
- 1590 LD (OX),A
- 1600 LD A,(Y)
- 1610 LD (OY),A
- 1620 LD A,(SC)
- 1630 CP 205
- 1640 JP C,REP
- 1650 RET
- 1660CLS: LD A,020H
- 1670 LD B,144
- 1680 LD DE,0
- 1690 CALL 0BFEEH
- 1700 RET
- 1710POI: LD H,0
- 1720 LD L,E
- 1730 LD E,D
- 1740 LD D,0
- 1750 CALL PNT
- 1760 AND C
- 1770 RET Z
- 1780 LD A,1
- 1790 RET
- 1800PNT: CALL GRAPH
- 1810 DB 0EH
- 1820 DW 0CA08H
- 1830PSET:LD H,0
- 1840 LD L,E
- 1850 LD E,D
- 1860 LD D,0
- 1870 LD (7967H),HL
- 1880 LD (7969H),DE
- 1890 LD IX,0FFFFH
- 1900 LD (777DH),IX
- 1910 LD (777FH),A
- 1920 CALL GRAPH
- 1930 DB 0DH
- 1940 DW 0C595H
- 1950 RET
- 1960LINE:LD (7967H),IX
- 1970 LD (7969H),IY
- 1980 LD IX,0FFFFH
- 1990 LD (777DH),IX
- 2000 LD (777FH),A
- 2010 LD A,B
- 2020 CP 1
- 2030 JR C,LIN
- 2040 JR Z,BOX
- 2050FBOX:CALL GRAPH
- 2060 DB 0DH
- 2070 DW 0C4CBH
- 2080 RET
- 2090LIN: CALL GRAPH
- 2100 DB 0DH
- 2110 DW 0C595H
- 2120 RET
- 2130BOX: CALL GRAPH
- 2140 DB 0DH
- 2150 DW 0C442H
- 2160 RET
- 2170SCOR:LD A,(SC+3)
- 2180 CP 48
- 2190 JR Z,SCO1
- 2200 LD A,(SC+2)
- 2210 CP 57
- 2220 JR Z,SCO2
- 2230 INC A
- 2240 LD (SC+2),A
- 2250 LD A,48
- 2260 LD (SC+3),A
- 2270 RET
- 2280SCO1:LD A,53
- 2290 LD (SC+3),A
- 2300 RET
- 2310SCO2:LD A,48
- 2320 LD (SC+2),A
- 2330 LD (SC+3),A
- 2340 LD A,(SC+1)
- 2350 INC A
- 2360 LD (SC+1),A
- 2370 RET
|
Message édité par charognard37 le 03-03-2018 à 23:04:15
|