;================================= ; Source de BINGO v0.7 ;But : aider ceux qui veulent ;débuter à comprendre comment ca ;marche. ; ;================================= include "tios.h" include "flib.h" include "hexlib.h" XDEF _main XDEF _comment WriteStr MACRO move.w \3,-(a7) pea \4(PC) move.w \2,-(a7) move.w \1,-(a7) jsr tios::DrawStrXY lea 10(a7),a7 ENDM SetFont MACRO move.w \1,-(a7) jsr tios::FontSetSys lea 2(a7),a7 ENDM _main: jsr flib::zap_screen ;on efface l'écran init: move #0,d0 ; on initialise les scores move.b d0,score1 ; les nombres et move.b d0,score2 ; le nombre de coups move.b d0,i11 ; et toutes les vars nécessaires move.b d0,i12 move.b d0,i13 move.b d0,i22 move.b d0,i23 move #5,d0 move.b d0,i21 jsr affhigh ttd: move.w #5,d0 ;Initialise le nouveau nombre à trouver jsr flib::random move.w d0,rep1 move.w #9,d0 ;composé de 3 nombres jsr flib::random move.w d0,rep2 move.w #9,d0 jsr flib::random move.w d0,rep3 deb: SetFont #2 ;affichage - présentation WriteStr #0,#0,#0,m_title ;Pas terrible d'ailleurs WriteStr #0,#102,#1,interval WriteStr #0,#112,#0,tent SetFont #0 WriteStr #0,#122,#1,sstt SetFont #1 WriteStr #0,#12,#1,choix move #10,a6 move #0,nb1 move #0,nb3 move.b score1,d0 ;on affiche le score actuel move.l #14,d1 ;Un peu lourd, mais bon ... move.l #28,d2 move.l #0,d4 jsr hexlib::put_hex move.b score2,d0 move.l #14,d1 move.l #27,d2 move.l #0,d4 jsr hexlib::put_hex move.b i11,d0 ;et les bornes (min et max) du BINGO move.l #13,d1 ;3 variables pour chaque chiffre move.l #6,d2 ; soit 6 variables move.l #0,d4 jsr hexlib::put_hex move.b i12,d0 move.l #13,d1 move.l #7,d2 move.l #0,d4 jsr hexlib::put_hex move.b i13,d0 move.l #13,d1 move.l #8,d2 move.l #0,d4 jsr hexlib::put_hex move.b i21,d0 move.l #13,d1 move.l #19,d2 move.l #0,d4 jsr hexlib::put_hex move.b i22,d0 move.l #13,d1 move.l #20,d2 move.l #0,d4 jsr hexlib::put_hex move.b i23,d0 move.l #13,d1 move.l #21,d2 move.l #0,d4 jsr hexlib::put_hex jsr flib::idle_loop ;on demande le premier chiffre à trouver move.b d0,nb1 cmp #$108,d0 ;c'est ESC ? -> on sort beq fin cmp #$10C,d0 beq clearhigh cmp #'h',d0 ;c'est h ? -> on affiche l'about box beq about cmp #$30,d0 ;c'est un chiffre ? blt deb ;(code touche compris entre 30 et 39 en hexa cmp #$39,d0 bgt deb move a6,-(a7) move d0,-(a7) WriteStr a6,#24,#1,nb1 move (a7)+,d0 move (a7)+,a6 bsr convert move.w d0,hex1 add #6,a6 ssls: jsr flib::idle_loop ; idem pour le deuxième chiffre move.b d0,nb2 cmp #$108,d0 beq fin cmp #$D,d0 ;sauf qu'on vérifie si ENTER est pressé beq dec1 ;->on décale le nombre (proc dec1) cmp #$30,d0 blt ssls cmp #$39,d0 bgt ssls move a6,-(a7) move d0,-(a7) WriteStr a6,#24,#1,nb2 move (a7)+,d0 move (a7)+,a6 bsr convert move.w d0,hex2 add #6,a6 heho: jsr flib::idle_loop ;le dernier chiffre idem move.b d0,nb3 cmp #$108,d0 beq fin cmp #$D,d0 beq dec2 cmp #$30,d0 blt heho cmp #$39,d0 bgt heho move a6,-(a7) move d0,-(a7) WriteStr a6,#24,#1,nb3 move (a7)+,d0 move (a7)+,a6 bsr convert move.w d0,hex3 onreprend: move.b score1,d0 ;On incrémente le score quoi qu'il arrive add #1,d0 move.b d0,score1 cmp #$a,d0 BEQ isc2 test1: ; movem a0-a6/d0-d6,-(a7) move.w hex1,d0 ;Debut des tests : on compare chaque chiffre 1 à 1 cmp.w rep1,d0 BGT moins ; c'est moins ? -> on affiche moins BEQ test2 ; Egal -> on teste chiffre suivant BLT plus ; plus -> devinez ! test2: move.w hex2,d0 ; on teste le 2e chiffre cmp.w rep2,d0 bgt moins beq test3 blt plus test3: move.w hex3,d0 ; et le dernier cmp.w rep3,d0 bgt moins beq gagne ;Egal ? -> on a gagné !!! blt plus gagne: SetFont #2 WriteStr #40,#40,#0,cgagne ; on affiche BINGO jsr flib::idle_loop jsr flib::zap_screen ; On efface tout move.b score2,d0 ;on teste le highscore cmp.b high1,d0 blt new ;Le score est inférieur -> nouveau highscore !! beq ssit ;Egal ? -> on teste le 2e chiffre bgt ssfn ssit: move.b score1,d0 cmp.b high2,d0 blt new ;plus petit ? -> nouveau highscore ! ssfn: WriteStr #0,#70,#1,text1 ; on affiche le highscore actuel move.b high1,d0 move.l #9,d1 move.l #28,d2 move.l #0,d4 jsr hexlib::put_hex ;avec les 2 chiffres move.b high2,d0 move.l #9,d1 move.l #29,d2 move.l #0,d4 jsr hexlib::put_hex WriteStr #0,#80,#1,higdet ;on affiche le détenteur actuel du highscore WriteStr #98,#80,#1,nom1 ;Stocké avec 3 lettres (nom1,nom2,nom3) WriteStr #106,#80,#1,nom2 WriteStr #114,#80,#1,nom3 jsr flib::idle_loop ; jsr flib::zap_screen ; movem (a7)+,a0-a6/d0-d6 WriteStr #10,#24,#1,mb jmp init new: WriteStr #0,#60,#0,hmess ;"NOUVEAU HIGHSCORE" move.b score1,d0 move.b d0,high2 ; on l'enregistre... avec ses 2 variables move.b score2,d0 move.b d0,high1 jsr flib::idle_loop SetFont #2 WriteStr #0,#0,#0,prpt1 ;on demande le nom du recordman jsr flib::idle_loop ;qui se compose de 3 lettres que l'on demande move.b d0,nom1 ;successivement toujours avec idle_loop WriteStr #176,#0,#0,nom1 jsr flib::idle_loop move.b d0,nom2 WriteStr #184,#0,#0,nom2 jsr flib::idle_loop move.b d0,nom3 WriteStr #192,#0,#0,nom3 jsr flib::idle_loop jmp ssfn moins: WriteStr #0,#40,#0,cmoins ; on affiche c'est moins move.b nb1,d0 ;on met à jour la borne inférieure move.b d0,i21 move.b nb2,d0 move.b d0,i22 move.b nb3,d0 move.b d0,i23 jmp ssuite plus: move.b nb1,d0 ;on met à jour la borne supérieure move.b d0,i11 move.b nb2,d0 move.b d0,i12 move.b nb3,d0 move.b d0,i13 WriteStr #0,#40,#0,cplus ssuite: WriteStr #10,#24,#4,mb ; jsr flib::zap_screen ; movem (a7)+,a0-a6/d0-d6 jmp deb convert: ; Procédure de conversion des codes des touches cmp #'0',d0 ; des chiffres du clavier en leur véritable valeur. beq zero cmp #'1',d0 ;(pour pouvoir comparer ensuite) beq un cmp #'2',d0 beq deux cmp #'3',d0 beq trois cmp #'4',d0 beq quatre cmp #'5',d0 beq cinq cmp #'6',d0 beq six cmp #'7',d0 beq sept cmp #'8',d0 beq huit cmp #'9',d0 beq neuf rts zero: move.w #0,d0 jmp ff un: move.w #1,d0 jmp ff deux: move.w #2,d0 jmp ff trois: move.w #3,d0 jmp ff quatre: move.w #4,d0 jmp ff cinq: move.w #5,d0 jmp ff six: move.w #6,d0 jmp ff sept: move.w #7,d0 jmp ff huit: move.w #8,d0 jmp ff neuf: move.w #9,d0 ff: rts isc2: move #0,d0 move.b d0,score1 move.b score2,d0 add #1,d0 move.b d0,score2 jmp test1 dec1: ;on décale tout car on a appuyé sur entré, donc on met move.b nb1,d0 ;2 zéros en 1e position, et le 1e chiffre en dernière move.b d0,nb3 bsr convert move.w d0,hex3 move.b #'0',nb2 move.b #'0',nb1 WriteStr #10,#24,#1,nb1 WriteStr #16,#24,#1,nb2 WriteStr #22,#24,#1,nb3 ; jsr flib::idle_loop move.w #0000,hex2 move.w #0000,hex1 jmp onreprend dec2: ;Pareil sauf, qu'on décale les 2 premiers chiffres et on move.b nb1,d0 ;insert 1 seul 0 au début move.b nb2,d1 move.b d0,nb2 move.b d1,nb3 move.b #'0',nb1 move.b nb2,d0 bsr convert move.w d0,hex2 move.b nb3,d0 bsr convert move.w d0,hex3 WriteStr #10,#24,#1,nb1 WriteStr #16,#24,#1,nb2 WriteStr #22,#24,#1,nb3 move.w #0000,hex1 jmp onreprend affhigh: SetFont #0 ;procédure d'affichage du highscore en bas de WriteStr #130,#122,#0,h ;l'écran et en tout petit WriteStr #150,#122,#0,nom1 WriteStr #154,#122,#0,nom2 WriteStr #158,#122,#0,nom3 rts clearhigh: jsr flib::zap_screen ;si touche F1, on demande confirmation WriteStr #0,#0,#1,delhigh jsr flib::idle_loop cmp #$108,d0 ;si c'est ESC, on annule tout beq init move #9,d2 ;sinon on efface le highscore actuel... move.b d2,high1 ;le nombre du highscore move.b d2,high2 move #0,d2 move.w d2,nom1 ;et le détenteur move.w d2,nom2 move.w d2,nom3 jmp init about: ;Affiche l'"about box" jsr flib::zap_screen WriteStr #0,#0,#0,mab1 WriteStr #0,#20,#1,mab2 WriteStr #0,#30,#1,mab3 WriteStr #0,#40,#1,mab4 jsr flib::idle_loop jsr flib::zap_screen jmp init fin: rts _comment dc.b "Bingo v0.7 Beta - Français",0 choix dc.b "Entrez un nombre (< 500) :",0 m_title dc.b " BINGO Par C.FONDACCI ",0 interval dc.b " < BINGO < ",0 tent dc.b "Nombre de tentatives :",0 mb dc.b " ",0 cgagne dc.b "Bingo, c'est gagné",0 cplus dc.b " C'est plus ",0 cmoins dc.b " C'est moins ",0 blanc dc.b " ",0 sstt dc.b "BINGO Copyright @1998",0 hmess dc.b " NOUVEAU HIGHSCORE ",0 text1 dc.b "Le highscore actuel est de",0 hsc dc.b "Highscore :",0 mab1 dc.b " BINGO v0.7 Final Beta ",0 mab2 dc.b " Conçu pour Fargo II v0.2.6 ",0 mab3 dc.b " Créé par Christophe FONDACCI ",0 mab4 dc.b " Copyright Mars @1998 ",0 prpt1 dc.b "Entrez vos initiales : ",0 delhigh dc.b "Effacer les highscore ?",0 h dc.b "High ",0 higdet dc.b "Détenu par :",0 score1 dc.b 0 score2 dc.b 0 high1 dc.b 9 high2 dc.b 9 i11 dc.b 0 i12 dc.b 0 i13 dc.b 0 i21 dc.b 5 i22 dc.b 0 i23 dc.b 0 rep1 dc.w 0 rep2 dc.w 0 rep3 dc.w 0 hex1 dc.w 0 hex2 dc.w 0 hex3 dc.w 0 nb1 dc.b 0 nb2 dc.b 0 nb3 dc.b 0 nom1 dc.w 0 nom2 dc.w 0 nom3 dc.w 0 end