;Th.FERNIQUE include "tios.h" include "flib.h" xdef _main xdef _comment ;************ CONSTANTES ***************; max_speed equ 1120 ;vitesse maximale gazon_speed equ 380 ;minimum de r‚duction de vitesse par le gazon acceleration equ 38 ;acc‚l‚ration (LOCK) freinage equ 10 ;freinage par la piste gazon_freine equ 80 ;freinage par le gazon braquage equ 5 ;quanta de rotation view_width equ 30 ;largeur en octets et paire ! view_height equ 118 delay equ 11 ;350/11 = 31.8 images/s ;***************************************; WriteStrA MACRO move.w \3,-(a7) move.l \4,-(a7) move.w \2,-(a7) move.w \1,-(a7) jsr tios::DrawStrXY lea 10(a7),a7 ENDM ;*************** CODE ******************; _main: bset.b #5,flag NewTrack: move.w #1,-(a7) ;selectionne fontes jsr tios::FontSetSys lea 2(a7),a7 bsr Menu ;si d6=0, a0 pointe sur le circuit choisi tst.w d7 bne Exit ;si d6<>0, pas de circuit choisi => fin ! move.w track_width,d0 mulu track_height,d0 move.l d0,-(a7) jsr tios::HeapAlloc ;m‚moire pour le circuit d‚compress‚ lea 4(a7),a7 tst.l d0 bne OkMem lea memdialog(PC),a6 jsr flib::show_dialog jsr flib::idle_loop bra NewTrack OkMem: move.w d0,hnum tios::DEREF d0,a0 move.l a0,hptr bsr LoadTrack ;charge le circuit dans le handle (le d‚compresse) move.w #$0700,d0 ;redirige int1 pour temporisation trap #1 move.l $64,oldint#1 bclr.b #2,$600001 move.l #newint#1,$64 bset.b #2,$600001 trap #1 jsr flib::zap_screen lea LCD_MEM+118*30,a0 move.w #14,d0 \RepLine: move.w #$FFFF,(a0)+ dbra d0,\RepLine lea status(PC),a0 WriteStrA #2,#120,#4,a0 ;**** Initialisation des variables *****; clr.w vitesse clr.w curline clr.b flag move.w #999,yourbestlap clr.w racetimer clr.w laptimer lea lapline(PC),a1 lea borne(PC),a0 ;affiche les 2 premiers drapeaux move.w (a1),d0 move.w 2(a1),d1 bsr XorPut move.w 4(a1),d0 move.w 6(a1),d1 bsr XorPut MainLoop: ;********** Acc‚l‚ration ***************; bsr GetKeyStat sub.w #freinage,vitesse ;frottements... tst.w vitesse ;on avance encore ? bge ok_slow ;oui=>suite clr.w vitesse ;non=>on s'arrˆte.(pas de vitesse n‚gative!) btst.b #3,flag ;course finie ? bne QuitTrack ;oui=>fin ok_slow: btst.b #3,flag ;course finie ? bne PasAccelere ;oui=>on n'acc‚lŠre plus btst.b #3,keystat ;LOCK enfonc‚e ? bne PasAccelere ;non=>on n'accelŠre pas add.w #acceleration,vitesse ;oui=>on acc‚lŠre, cmp.w #max_speed,vitesse ;mais pas trop :) bset.b #4,flag blt ok_fast move.w #max_speed,vitesse ok_fast: PasAccelere: ;************** Rotation ***************; btst.b #4,keystat ;fleche gauche ? bne noleft sub.w #braquage,angle ;angle decroŒt tst.w angle bge noleft add.w #360,angle ;modulo 2ã noleft: btst.b #6,keystat ;fleche droite ? bne noright add.w #braquage,angle ;angle croŒt cmp.w #360,angle blt noright sub.w #360,angle ;modulo 2ã noright: ;********* Chgt des coordon‚es *********; move.w angle,d0 clr.l d1 lea costab(PC),a0 ;cosinus entre 0 et 90ø (chaque 1ø) a0_90: cmp.w #90,d0 bgt a90_180 move.b 0(a0,d0),d1 mulu vitesse,d1 add.l d1,x ;x=x+cos(angle) clr.l d1 moveq #90,d2 sub.w d0,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 add.l d1,y ;y=y+sin(angle) bra afin a90_180: cmp.w #180,d0 bgt a180_270 move.w #180,d2 sub.w d0,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 sub.l d1,x ;cos(à+90)=-cos(90-à) clr.l d1 move.w d0,d2 sub.w #90,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 add.l d1,y ;sin(à+90)=cos(à) bra afin a180_270: cmp.w #270,d0 bgt a270_360 move.w d0,d2 sub.w #180,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 sub.l d1,x ;cos(à+180)=-cos(à) clr.l d1 move.w #270,d2 sub.w d0,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 sub.l d1,y ;sin(à+180)=-cos(90-à) bra afin a270_360: move.w #360,d2 sub.w d0,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 add.l d1,x ;cos(à+270)=cos(90-à) clr.l d1 move.w d0,d2 sub.w #270,d2 move.b 0(a0,d2),d1 mulu vitesse,d1 sub.l d1,y ;sin(à+270)=-cos(à) afin: ;****** Validit‚ des coordonn‚es *******; tst.l x ;(x,y) sur l'‚cran ? bgt c1 ;si non, on y rem‚die. clr.l x c1: move.w track_width,d0 lsl.w #3,d0 sub.w #9,d0 ext.l d0 lsl.l #6,d0 lsl.l #8,d0 cmp.l x,d0 bge c2 move.l d0,x c2: tst.l y bgt c3 clr.l y c3: move.w track_height,d0 sub.w #9,d0 ext.l d0 lsl.l #6,d0 lsl.l #8,d0 cmp.l y,d0 bge c4 move.l d0,y c4: ;******** Passage d'un contr“le ********; moveq #14,d4 move.l x,d0 lsr.l d4,d0 move.l y,d1 lsr.l d4,d1 movem.w d0-d1,-(a7) btst.b #3,flag ;course finie ? bne EndCheck ;oui->on se fout de cette partie :) move.l lastx,d2 lsr.l d4,d2 move.l lasty,d3 lsr.l d4,d3 move.l x,lastx ;remet … jour lastx et lasty move.l y,lasty lea lapline(PC),a1 move.w curline,d4 lsl.w #3,d4 adda.w d4,a1 lea coord(PC),a0 ;charge les 4 pts dans coord move.l (a1),(a0) ;drapeau gauche (A) move.l 4(a1),4(a0) ;drapeau droit (B) move.w d2,8(a0) ;position pr‚c‚dente de la voiture (C) move.w d3,10(a0) move.w d0,12(a0) ;nouvelle position (D) move.w d1,14(a0) bsr CheckPass btst.b #1,flag ;on a pass‚ un contr“le ? ([AB]ï[CD]={I}) beq EndCheck ;non->saute la suite du test ! bclr.b #1,flag lea borne(PC),a0 ;efface les 2 drapeaux move.w (a1),d0 move.w 2(a1),d1 bsr XorPut move.w 4(a1),d0 move.w 6(a1),d1 bsr XorPut add.w #1,curline cmp.w #4,curline ;passe contr“le ou ligne de tour ? blt JustPassControl clr.w curline sub.w #1,laps2go move.w laptimer,d0 clr.w laptimer cmp.w yourbestlap,d0 bge NoYourBestLap move.w d0,yourbestlap NoYourBestLap: lea strend(PC),a0 moveq #3,d1 bsr ConvStr WriteStrA #44,#120,#4,a0 ;affiche temps de tour... move.w yourbestlap,d0 lea strend(PC),a0 moveq #3,d1 bsr ConvStr WriteStrA #68,#120,#4,a0 ;et votre meilleur tour clr.l d0 move.w racetimer,d0 move.w nlaps,d1 sub.w laps2go,d1 divu d1,d0 andi.l #$FFFF,d0 lea strend(PC),a0 moveq #3,d1 bsr ConvStr WriteStrA #92,#120,#4,a0 move.w racetimer,d0 lea strend(PC),a0 moveq #5,d1 bsr ConvStr WriteStrA #2,#120,#4,a0 ;affiche temps de course... move.w laps2go,d0 lea strend(PC),a0 moveq #2,d1 bsr ConvStr WriteStrA #226,#120,#4,a0 ;et tours restant. tst.w laps2go ;c'‚tait le dernier tour ? bne NoEndRace bset.b #3,flag ;oui => course finie bra EndCheck NoEndRace: JustPassControl: lea lapline(PC),a1 move.w curline,d1 lsl.w #3,d1 adda.w d1,a1 lea borne(PC),a0 ;affiche les 2 drapeaux suivants move.w (a1),d0 move.w 2(a1),d1 bsr XorPut move.w 4(a1),d0 move.w 6(a1),d1 bsr XorPut EndCheck: movem.w (a7)+,d0-d1 ;*********** Affichage auto ************; lea auto(PC),a0 move.w angle,d2 ext.l d2 divu #22,d2 and.w #%111,d2 lsl.w #3,d2 adda.w d2,a0 bsr XorPut tst.w d4 beq SurPiste cmp.w #gazon_speed,vitesse ;en dessous certaine vitesse, blt gazon_pas_freine ;le gazon ne freine plus la voiture sub.w #gazon_freine,vitesse gazon_pas_freine SurPiste: ;********** Affichage ‚cran ************; movem.l d0-d1/a0,-(a7) sub.w #view_width*4,d0 sub.w #view_height/2,d1 tst.w d0 bge ok1 clr.w d0 ok1: move.w track_width,d7 lsl.w #3,d7 sub.w #view_width*8,d7 cmp.w d7,d0 ble ok2 move.w d7,d0 ok2: tst.w d1 bge ok3 clr.w d1 ok3: move.w track_height,d7 sub.w #view_height,d7 cmp.w d7,d1 ble ok4 move.w d7,d1 ok4: move.w d0,xecran move.w d1,yecran bsr Handle2Screen ;affiche le tout … l'‚cran movem.l (a7)+,d0-d1/a0 bsr XorPut ;efface l'auto tout de suite ;********** Synchronisation ************; \delay: ;vitesse cte pour ti92 II,+,boost‚es cmp.w #delay,sync blt \delay clr.w sync ;********** Compteurs temps ************; move.b flag,d0 andi.b #%11000,d0 cmp.b #%10000,d0 ;bits 3 … 0 et 4 … 1 ? (course en cours) bne NoIncTimers ;non=>timers ne bougent pas ! cmp.w #999,laptimer beq NoIncTimers add.w #1,laptimer cmp.w #30000,racetimer beq NoIncTimers add.w #1,racetimer NoIncTimers: btst.b #6,keystat+8 ;ESC ? bne MainLoop ;non => on continue ;********* Fin de la boucle ************; QuitTrack: bsr GetKeyStat btst.b #6,keystat+8 beq QuitTrack move.w hnum,-(a7) ;libŠre m‚moire jsr tios::HeapFree addq #2,a7 move.w #$0700,d0 ;remet l'ancienne int1 en place trap #1 bclr.b #2,$600001 move.l oldint#1(pc),$64 bset.b #2,$600001 trap #1 btst.b #3,flag beq NewTrack clr.w d1 move.l track_adr,a1 move.w racetimer,d0 cmp.w (a1),d0 ;meilleur temps de course ? bge NoBestRace ;non=>pour la prochaine fois move.w d0,(a1) ;oui=>p'tain la vache chuis c‚lŠbre ! moveq #1,d1 NoBestRace: move.w yourbestlap,d0 cmp.w 6(a1),d0 bge NoBestLap move.w yourbestlap,6(a1) addq.w #2,d1 NoBestLap: tst.w d1 beq NewTrack bsr InputInitials lea str(PC),a0 cmp.w #2,d1 beq NoBestRaceInitials move.w (a0),2(a1) move.w 2(a0),4(a1) NoBestRaceInitials: cmp.w #1,d1 beq NoBestLapInitials move.w (a0),8(a1) move.w 2(a0),10(a1) NoBestLapInitials: bra NewTrack Exit: rts ;************* PROCEDURES **************; ;*********** Handle -> Ecran ***********; Handle2Screen: ;(d0,d1)=(x,y) movem.l d0-d7/a0-a1,-(a7) lea LCD_MEM,a0 move.l hptr,a1 move.w track_width,d7 mulu d7,d1 sub.w #view_width,d7 add.l d1,a1 ;a1 pointe sur la bonne ligne move.w d0,d2 ;deplacement x en word lsr.w #3,d2 ;div 8 and.w #$FFFE,d2 ;supprime bit 1 adda.w d2,a1 ;et sur le bon word move.w d0,d2 ;d‚placement par rapport au plus proche word and.w #%1111,d2 ;garde bits 1-4 (0-15) cmp.w #8,d2 ;s‚paration en deux cas (<>8) pas n‚cessaire, bgt suite2 ;mais ‡a va plus vite (rol.w d2,d0 : 6+2*d2 cycles) Suite1: move.w #$FFFF,d3 ; #%1111111111111111 lsr.w d2,d3 ; #%0000011111111111 -> move.w d3,d4 not.w d4 ; #%1111100000000000 move.w #view_height-1,d6 ;lignes balay‚es-1 nextline1: move.w #view_width/2-1,d5 nextword1: move.w (a1)+,d0 move.w (a1),d1 and.w d3,d0 and.w d4,d1 add.w d1,d0 rol.w d2,d0 move.w d0,(a0)+ dbra d5,nextword1 adda.w d7,a1 dbra d6,nextline1 bra Fin suite2: eori.w #%1111,d2 move.w #$FFFF,d4 ; #%1111111111111111 lsl.w d2,d4 ; #%1111111111100000 <- move.w d4,d3 not.w d3 ; #%0000000000011111 move.w #view_height-1,d6 ;lignes balay‚es-1 nextline2: move.w #view_width/2-1,d5 nextword2: move.w (a1)+,d0 move.w (a1),d1 and.w d3,d0 and.w d4,d1 add.w d1,d0 ror.w d2,d0 move.w d0,(a0)+ dbra d5,nextword2 adda.w d7,a1 dbra d6,nextline2 Fin: movem.l (a7)+,d0-d7/a0-a1 rts ;***** Convertit nombre en chaine ******; ConvStr: movem.l d0-d2,-(a7) clr.b (a0) repconv: divu #10,d0 move.l d0,d2 swap d2 add.b #48,d2 move.b d2,-(a0) sub.w #1,d1 and.l #$FFFF,d0 bne repconv tst.w d1 beq CS_Done sub.w #1,d1 FillOut: move.b #48,-(a0) dbra d1,FillOut CS_Done: movem.l (a7)+,d0-d2 rts ;********* Scanne le clavier ***********; GetKeyStat: movem.l d0-d1/a0,-(a7) lea keystat(PC),a0 move.w #$FFFE,d0 moveq #9,d1 GetKeys: move.w d0,$600018 nop nop nop nop nop nop move.b $60001B,(a0)+ rol.w #1,d0 dbra d1,GetKeys movem.l (a7)+,d0-d1/a0 rts ;***** Affichage voiture/contr“les *****; XorPut: movem.l d0-d2/a0-a1,-(a7) move.l hptr,a1 ;destination du dessin... mulu track_width,d1 add.l d1,a1 ;a1 pointe sur la bonne ligne move.w d0,d2 lsr.w #3,d2 adda.w d2,a1 and.w #%111,d0 ;garde bits 1-3 (0-7) move.w d0,d1 ;teste le pixel dessous add.w #3,d1 move.w #3,d2 mulu track_width,d2 btst.b d1,0(a1,d2) sne d4 ;noir=>d4=$FF eori.b #%111,d0 move.w d0,d1 moveq #7,d2 \nb: clr.w d0 move.b (a0)+,d0 ;lit le dessin lsl.w d1,d0 rol.w #8,d0 ;hi(d0)<=>lo(d0) eor.b d0,(a1)+ ;OU exclusif ror.w #8,d0 eor.b d0,(a1)+ move.w track_width,d0 sub.w #2,d0 adda.w d0,a1 ;ligne suivante dbra d2,\nb movem.l (a7)+,d0-d2/a0-a1 rts ;******* Chargement du circuit *********; LoadTrack: ;a0=pointeur sur le circuit compress‚ movem.l d0-d4/a0-a1,-(a7) move.l track_adr,a0 lea 12(a0),a0 move.w (a0)+,nlaps ;nombre de tours pour une course move.w nlaps,laps2go move.w (a0)+,d0 ;lit les coordon‚es et l'angle de d‚part ext.l d0 lsl.l #8,d0 move.l d0,x move.w (a0)+,d0 ext.l d0 lsl.l #8,d0 move.l d0,y move.w (a0)+,angle lea lapline(PC),a1 ;lit les contr“les : 4*((x1,y1)(x2,y2)) moveq #15,d2 readlapline: move.w (a0)+,(a1)+ dbra d2,readlapline move.l hptr,a1 ;handle destination (circuit d‚compress‚) move.w #$FFFF,d2 ;couleur de d‚part (noir) clr.w d0 moveq #15,d3 ;compteur des pixels ChgtColor: clr.w d4 move.b (a0)+,d4 ;lit nb pixels cons‚cutifs ^m couleur cmp.b #$FF,d4 bne NoWordCount move.b (a0)+,d4 lsl.w #8,d4 move.b (a0)+,d4 NoWordCount: tst.w d4 beq EndLoad ;0=fin de fichier subq.w #1,d4 Pixel_Suivant: ;dessine tous les pixels cons‚cutifs d'une mˆme couleur tst.w d3 ;pixel suivant pas dans mˆme word ? bne toujours_m_word ;non=>toujours_m_word moveq #16,d3 ;oui, word suivant : move.w d0,(a1)+ SearchFullWords: cmp.w #16,d4 blt NoFullWord move.w d2,(a1)+ sub.w #16,d4 bra SearchFullWords NoFullWord: clr.w d0 toujours_m_word: subq.w #1,d3 ;pixel suivant. tst.w d2 ;pixel … effacer ? beq pixel_blanc bset.w d3,d0 pixel_blanc: dbra d4,Pixel_Suivant not.w d2 ;chgt de couleur bra ChgtColor EndLoad: movem.l (a7)+,d0-d4/a0-a1 rts ;****** Passage entre deux bornes ******; CheckPass: movem.l d0-d5/a0,-(a7) lea coord(PC),a0 ;a0 pointe sur les coordonn‚es des pts ;DET(AB,AC) = ab*ac*sin(AB,AC) move.w 4(a0),d1 ;b.x sub.w (a0),d1 ;-a.x move.w 10(a0),d0 ;c.y sub.w 2(a0),d0 ;-a.y muls d0,d1 ;d1.l=(b.x-a.x)*(c.y-a.y) move.w 6(a0),d0 ;b.y sub.w 2(a0),d0 ;-a.y move.w 8(a0),d5 ;c.x sub.w (a0),d5 ;-a.x muls d5,d0 ;d7.l=(b.y-a.y)*(c.x-a.x) sub.l d0,d1 ;d1=Ka1 ;DET(AD,AB) = ab*ac*sin(AD,AB) =0 <=> D sur [AB] move.w 12(a0),d2 ;d.x sub.w (a0),d2 ;-a.x move.w 6(a0),d0 ;b.y sub.w 2(a0),d0 ;-a.y muls d0,d2 ;d2.l=(d.x-a.x)*(b.y-a.y) move.w 14(a0),d0 ;d.y sub.w 2(a0),d0 ;-a.y move.w 4(a0),d5 ;b.x sub.w (a0),d5 ;-a.x muls d5,d0 ;d7.l=(d.y-a.y)*(b.x-a.x) sub.l d0,d2 ;d2=Ka2 ;DET(CA,CD) = ab*ac*sin(CA,CD) move.w (a0),d3 ;a.x sub.w 8(a0),d3 ;-c.x move.w 14(a0),d0 ;d.y sub.w 10(a0),d0 ;-c.y muls d0,d3 ;d3.l=(a.x-c.x)*(d.y-c.y) move.w 2(a0),d0 ;a.y sub.w 10(a0),d0 ;-c.y move.w 12(a0),d5 ;d.x sub.w 8(a0),d5 ;-c.x muls d5,d0 ;d7.l=(a.y-c.y)*(d.x-c.x) sub.l d0,d3 ;d3=Ka3 ;DET(CD,CB) = ab*ac*sin(CD,CB) move.w 12(a0),d4 ;d.x sub.w 8(a0),d4 ;-c.x move.w 6(a0),d0 ;b.y sub.w 10(a0),d0 ;-c.y muls d0,d4 ;d4.l=(d.x-c.x)*(b.y-c.y) move.w 14(a0),d0 ;d.y sub.w 10(a0),d0 ;-c.y move.w 4(a0),d5 ;b.x sub.w 8(a0),d5 ;-c.x muls d5,d0 ;d7.l=(d.y-c.y)*(b.x-c.x) sub.l d0,d4 ;d4=Ka4 bclr.b #1,flag ;met … 0 indic passage contr“le tst.l d1 ble \PasPasse tst.l d2 blt \PasPasse ;BLE -> BLT !!!!! tst.l d3 ble \PasPasse tst.l d4 ble \PasPasse bset.b #1,flag ;si les 4 Ka sont >0, les segments se coupent \PasPasse: movem.l (a7)+,d0-d5/a0 rts ;** choix du circuit (env.730 octets) **; Menu: ;d3/d5/a5 : utilis‚s pour les variables ;d4/d6/a6 : utilis‚s pour les r‚pertoires ;d7=0 si un circuit est s‚lection‚, 1 sinon. lea empty(PC),a4 lea dialog(PC),a6 jsr flib::show_dialog lea foldrmsg(PC),a0 WriteStrA #57,#42,#4,a0 lea trackmsg(PC),a0 WriteStrA #57,#52,#4,a0 lea brmsg(PC),a0 WriteStrA #39,#66,#4,a0 lea blmsg(PC),a0 WriteStrA #39,#76,#4,a0 moveq #$08,d0 ; tios::DEREF d0,a6 ;a6 sur la liste des r‚pertoires lea 2(a6),a6 move.w (a6)+,d6 sub.w #1,d6 move.w d6,d4 clr.w d6 move.w 12(a6),d0 ; bsr FindTracks clr.w d5 btst.b #5,flag bne NoSavedChoices lea choices(PC),a0 move.l 8(a0),a6 move.w 12(a6),d0 ; bsr FindTracks move.w (a0)+,d5 move.w (a0)+,d6 move.l (a0)+,a5 NoSavedChoices: clr.w d0 moveq #1,d7 RepChoose: cmp.w #338,d0 ;FlŠche haut ? bne NoPreviousFolder tst.w d6 beq NoPreviousFolder sub.w #1,d6 lea -14(a6),a6 ; move.w 12(a6),d0 ; bsr FindTracks clr.w d5 NoPreviousFolder: cmp.w #344,d0 ;FlŠche bas ? bne NoNextFolder cmp.w d4,d6 beq NoNextFolder add.w #1,d6 lea 14(a6),a6 ; move.w 12(a6),d0 ; bsr FindTracks clr.w d5 NoNextFolder: move.w d0,-(a7) ;affiche r‚pertoire courant WriteStrA #111,#42,#4,a4 clr.b 8(a6) ;pas … 0 si 8 caractŠres (?) WriteStrA #111,#42,#0,a6 move.w (a7)+,d0 tst.w d3 ;y'a ti des circuits dans ce r‚pertoire ? blt NoTrack ;non->on affiche "none" cmp.w #337,d0 ;FlŠche PS ? bne NoPreviousTrack moveq #-14,d2 ; bsr SearchNextTrack NoPreviousTrack: cmp.w #340,d0 ;FlŠche RPR ? bne NoNextTrack moveq #14,d2 ; bsr SearchNextTrack NoNextTrack: move.w d0,-(a7) ;affiche circuit courant WriteStrA #111,#52,#4,a4 WriteStrA #111,#52,#0,a5 move.w 12(a5),d2 ; tios::DEREF d2,a2 lea strend(PC),a0 move.w 8(a2),d0 moveq #5,d1 bsr ConvStr WriteStrA #111,#66,#4,a0 move.l a2,a0 lea 10(a0),a0 WriteStrA #165,#66,#4,a0 lea strend(PC),a0 move.w 14(a2),d0 moveq #3,d1 bsr ConvStr WriteStrA #105,#76,#4,a0 move.l a2,a0 lea 16(a0),a0 WriteStrA #147,#76,#4,a0 move.w (a7)+,d0 bra S1 NoTrack: lea notrack(PC),a0 WriteStrA #111,#52,#4,a0 S1: jsr flib::idle_loop cmp.w #264,d0 ;ESC ? beq NoTrackSelected ;-> pas de circuit s‚lection‚ tst.w d3 ;pas de circuit ? blt RepChoose ;-> on doit choisir autre chose ! (pas ENTER) cmp.w #13,d0 bne RepChoose lea choices(PC),a0 move.w d5,(a0)+ move.w d6,(a0)+ move.l a5,(a0)+ move.l a6,(a0)+ bclr.b #5,flag move.w 12(a5),d0 ; tios::DEREF d0,a0 lea 4(a0),a0 move.w (a0)+,track_width move.w (a0)+,track_height move.l a0,track_adr lea 12(a0),a0 clr.w d7 NoTrackSelected: rts ;a0 : pointeur sur le circuit choisi FindTracks: ;d0:handle du r‚pertoire ou chercher movem.l d0-d2/a0,-(a7) moveq #-1,d3 tios::DEREF d0,a0 lea 2(a0),a0 move.w (a0)+,d0 tst.w d0 ;d0=nombre de fichiers ds le rep beq NoTrackFound sub.w #1,d0 clr.w d5 SearchTracks: move.w 12(a0),d2 ; tios::DEREF d2,a2 cmp.w #$5343,2(a2) bne OtherFile tst.w d5 bne NoFirstTrack move.l a0,a5 NoFirstTrack: add.w #1,d5 OtherFile: lea 14(a0),a0 ; dbra d0,SearchTracks tst.w d5 beq NoTrackFound sub.w #1,d5 move.w d5,d3 NoTrackFound: movem.l (a7)+,d0-d2/a0 rts ;a5:pointeur ds VAT sur 1er circuit SearchNextTrack: tst.l d2 blt SearchUp cmp.w d3,d5 beq EndSearch add.w #1,d5 bra RepSearch SearchUp: tst.w d5 beq EndSearch sub.w #1,d5 RepSearch: add.l d2,a5 move.w 12(a5),d2 ; tios::DEREF d2,a2 cmp.w #$5343,2(a2) bne RepSearch EndSearch: rts InputInitials: movem.l d0-d4/a0,-(a7) move.w #2,-(a7) ;selectionne fontes jsr tios::FontSetSys lea 2(a7),a7 lea inputdialog(PC),a6 jsr flib::show_dialog move.w #176,d3 ;x move.w #59,d1 ;y clr.w tios::kb_vars+$1C lea str(PC),a0 clr.l d4 Input: jsr flib::idle_loop cmp.w #13,d0 beq InputDone cmp.w #257,d0 beq BackSpace cmp.w #32,d0 bcs Input cmp.w #256,d0 bcc Input cmp.w #3,d4 beq Input move.b d0,(a0)+ move.w d0,d2 move.w d3,d0 bsr WriteChar addq #8,d3 addq #1,d4 bra Input BackSpace: tst.w d4 beq Input clr.b -(a0) subq #8,d3 move.w d3,d0 moveq #32,d2 bsr WriteChar subq #1,d4 bra Input InputDone: clr.b (a0) movem.l (a7)+,d0-d4/a0 rts WriteChar: movem.l d0-d2/a0,-(a7) move.w #$00FF,-(a7) clr.w -(a7) move.w #$00FF,-(a7) move.w #4,-(a7) move.w d1,-(a7) move.w d0,-(a7) move.w d2,-(a7) jsr tios::DrawCharXY lea 14(a7),a7 movem.l (a7)+,d0-d2/a0 rts ;****** Nouvelle interruption #1 *******; newint#1: add.w #1,sync rte ;************ Variables ****************; oldint#1 dc.l 0 hptr dc.l 0 track_adr dc.l 0 x dc.l 0 y dc.l 0 lastx dc.l 0 lasty dc.l 0 hnum dc.w 0 xecran dc.w 0 yecran dc.w 0 angle dc.w 0 vitesse dc.w 0 curline dc.w 0 laptimer dc.w 0 yourbestlap dc.w 0 bestlap dc.w 0 racetimer dc.w 0 bestrace dc.w 0 laps2go dc.w 0 nlaps dc.w 0 sync dc.w 0 track_width dc.w 0 track_height dc.w 0 flag dc.b 0 ; 0 : 1=erreur : pas assez de m‚moire ; 1 : 1=contr“le pass‚ ; 2 : ; 3 : 1=course finie ; 4 : 1=course d‚but‚e ; 5 : 1=pas de circuit d‚j… choisi choices ds.l 3 lapline ds.w 16 str ds.b 8 strend coord ds.w 8 keystat ds.b 10 ;************** Donn‚es ****************; costab: dc.l $40404040,$40404040,$3F3F3F3F,$3F3E3E3E dc.l $3E3D3D3D,$3C3C3B3B,$3A3A3A39,$39383737 dc.l $36363534,$34333232,$3130302F,$2E2D2C2C dc.l $2B2A2928,$27272625,$24232221,$201F1E1D dc.l $1C1B1A19,$18171615,$14131211,$0F0E0D0C dc.l $0B0A0908,$07060403,$02010000 auto: dc.l $0066FFFF,$FFFF6600,$60F0FEFF,$FF7F0F06 dc.l $70F8F8FE,$7F1F1F0E,$78FCFC7C,$3E3F3F1E dc.l $3C7E7E3C,$3C7E7E3C,$1E3F3F3E,$7CFCFC78 dc.l $0E1F1F7F,$FEF8F870,$060F7FFF,$FFFEF060 borne: dc.l $3C42BDA5,$A5BD423C inputdialog: dc.w 34,53,206,75,6,6 dc.l inputtxt,0 dialog: dc.w 33,36,207,89,0,0 dc.l dialog,0 memdialog: dc.w 58,53,182,75,6,6 dc.l memtxt,0 memtxt dc.b "Not enough mem",0 inputtxt dc.b "Enter Initials :",0 status dc.b "00000 000/000/000",0 empty dc.b " ",0 notrack dc.b "none ",0 foldrmsg dc.b "Folder : (",19,20,")",0 trackmsg dc.b "Track : (",17,18,")",0 brmsg dc.b "Best Race : by",0 blmsg dc.b "Best Lap : by",0 _comment: dc.b "v1.0 by Thomas FERNIQUE ",169,"1998",0 ;*********** Fin du programme **********; end