| > programmation de jeux > Programmez vos Joysticks (PASE) |
| 2 messages 1 page |  |
LadyWasky (admin) D'autr'questions ? | posté le dimanche 9 décembre 2007 19h29 |  |
 255 messages | Je vous conseille attentivement le chapitre dédié de "Au coeur de L'Oric Atmos" de Gilles Bertin.
On peut le trouver scanné ici :
http://www.abandonware-france.org/ltf_manuels/manuels.php?id_manuel=497#497
Exemple de programme en BASIC (l'auteur propose une version améliorée avec de l'assembleur) :
10 REM Main Program
20 POKE 618,2
30 REPEAT
40 GOSUB 1000
50 PRINT LEFTJOY,RIGHTJOY
60 UNTIL KEY$<>""
70 POKE 618,3
80 END
90 REM
1000 REM Sub Program --> Read Joysticks
1010 POKE 782,64
1020 V1=PEEK(771):V2=PEEK(769)
1030 POKE 771,192
1040 POKE 769,128:LEFTJOY=PEEK(769)-128
1050 POKE 769,64:RIGHTJOY=PEEK(769)-64
1060 POKE 771,V1:POKE 769,V2
1070 POKE 782,192
1080 RETURN
On peut trouver l'ouvrage en téléchargement sur le net, ici par exemple :
http://www.abandonware-france.org/ltf_manuels/manuels.php?id_manuel=497#497
Bon dev 
IN ENGLISH :
Title : Program your Joysticks
I advise you to read carefully the book "Au coeur de L'Oric Atmos" by Gilles BERTIN (book in French), particularly the chapter dealing with joystick interface programming (starting page 40).
You can find the book for download here :
http://www.abandonware-france.org/ltf_manuels/manuels.php?id_manuel=497#497
The sample given above is a BASIC program that polls the joysticks states. In the book, A faster and improved listing is proposed combining BASIC and machine code instructions (lines of DATA, POKE of memory).
Enjoy !
 Y'a t'il d'autres oriciennes ? Je me sens seule ! ^^ |
LadyWasky (admin) D'autr'questions ? | posté le jeudi 14 février 2008 22h38 |  |
 255 messages | Here the improved program dealing with some machine code (faster than the one above) :
10 PRINT "Loading machine code"
100 ' Read Joystick MC routine
110 POKE 618,2
120 GOSUB 1000
130 REPEAT
140 CALL#404
145 PRINT "Values : ";
150 FOR I=#400 TO #403
160 PRINT PEEK(I);" ";
170 NEXT I
180 PRINT
190 UNTIL KEY$<>""
200 POKE 618,3
210 END
1000 REM Poke machine code
1010 A=#400:READ COD$
1020 REPEAT
1030 FOR I=1 TO LEN(COD$) STEP 2
1040 B=VAL("#"+MID$(COD$,I,2))
1050 POKE A,B
1060 A=A+1
1070 NEXT I
1080 READ COD$
1090 UNTIL COD$="END"
1095 RETURN
1100 DATA 000000004898488A48AD0103
1110 DATA 48AD030348A9C08D0303A940
1120 DATA 203C048D00048E0104A98020
1130 DATA 3C048D02048E0304688D0303
1140 DATA 688D010368AA68A86860EAEA
1150 DATA 8D0103AD0103A82920AA984A
1160 DATA 290C8D520498290318690CA8
1170 DATA B9600460EAEAEAEAEAEAEAEA
1180 DATA 000000000002080100040605
1190 DATA 00030709,END
And here it is in C language if you like to program with DBug's OSDK :
#include <lib.h>
//procedure that read joystick status
void readjoy(int *ljoy,int *rjoy)
{
int V1,V2;
//Read Joysticks
poke(782,64);
V1=peek(771);
V2=peek(769);
poke(771,192);
poke(769,128);
*ljoy=peek(769)-128;
poke(769,64);
*rjoy=peek(769)-64;
poke(771,V1);
poke(769,V2);
poke(782,192);
}
void main()
{
char left_joy,right_joy;
//initialization of the printer port
poke(618,2);
cls();
while (key()!=32) {
//We read Joystick ports
readjoy(&left_joy,&right_joy);
//We print the values
printf("%d %d\n",left_joy,right_joy);
}
//"release" of the printer port
poke(618,3);
}
With all of this, I am sure you will bring life to your PASE Joysticks 
 Y'a t'il d'autres oriciennes ? Je me sens seule ! ^^ |
| 2 messages 1 page |  |
| > programmation de jeux > Programmez vos Joysticks (PASE) |