include "flib.h" include "tios.h" xdef _main xdef _comment ;***************************************; 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 ;***************************************; _main: move.w #2,-(a7) jsr tios::FontSetSys lea 2(a7),a7 jsr flib::clr_scr NewFile: bsr OpenFile tst.l start_adr beq Exit clr.b mode move.w #0,-(a7) jsr tios::FontSetSys lea 2(a7),a7 lea str(PC),a0 move.l start_adr,d0 moveq #5,d1 bsr ConvHex clr.b (a0) lea str(PC),a0 WriteStrA #0,#123,#4,a0 move.w #2,-(a7) jsr tios::FontSetSys lea 2(a7),a7 MainLoop: bsr PrintScreen jsr flib::idle_loop cmp.w #270,d0 beq NewFile cmp.w #344,d0 bne NoDown8 add.w #8,position NoDown8: cmp.w #4096+344,d0 bne NoDown120 add.w #120,position NoDown120: cmp.w #338,d0 bne NoUp8 sub.w #8,position NoUp8: cmp.w #4096+338,d0 bne NoUp120 sub.w #120,position NoUp120: CheckDown: move.w filesize,d1 subq.w #7,d1 andi.w #$FFF8,d1 cmp.w position,d1 bge OkDown move.w d1,position OkDown: CheckUp: tst.w position bge OkUp clr.w position OkUp: cmp.w #264,d0 bne MainLoop Exit: rts ;***************************************; PrintScreen: movem.l d0-d5/a0,-(a7) clr.l d0 move.w position,d4 move.l start_adr,a1 adda.w d4,a1 clr.l d3 moveq #11,d5 RepShow: lea str(PC),a0 clr.l d0 move.w d4,d0 moveq #4,d1 bsr ConvHex cmp.w filesize,d4 ;plus dans le fichier (aprŠs) ? bne NotEOF_1 move.b #$20,-4(a0) ;oui=>on n'affiche plus l'addresse move.b #$20,-3(a0) move.b #$20,-2(a0) move.b #$20,-1(a0) NotEOF_1: move.b #32,(a0)+ ;s‚parateur addresse/hexad‚cimal move.b #32,16(a0) ;s‚parateur hexad‚cimal/ascii lea 17(a0),a2 moveq #2,d1 clr.l d0 moveq #7,d2 PutLoop: cmp.w filesize,d4 ;on est … la fin du fichier ? beq EOF ;oui=>on affiche pas la suite de la m‚moire move.b (a1)+,d0 bsr ConvHex ;octet affich‚ en hexad‚cimal cmp.b #32,d0 bge NoDot move.b #46,d0 NoDot: move.b d0,(a2)+ ;et ascii ("." si <32) addq.w #1,d4 ;position+1 dbra d2,PutLoop bra NotEOF_2 EOF: ;" " en cas de fin de fichier move.b #32,(a0)+ move.b #32,(a0)+ move.b #32,(a2)+ dbra d2,EOF NotEOF_2: clr.b (a2) lea str(PC),a0 movem.l d0-d2/a1,-(a7) WriteStrA #0,d3,#4,a0 movem.l (a7)+,d0-d2/a1 add.w #10,d3 ;ordonn‚e dbra d5,RepShow EndShow: movem.l (a7)+,d0-d5/a0 rts ConvHex: lea 0(a0,d1),a0 movem.l d0-d3/a0,-(a7) moveq #$F,d3 subq.w #1,d1 RepConv: move.l d0,d2 and.l d3,d2 ;on les isole cmp.b #10,d2 ;>9 (A-F) ? blt NoLetter addq.b #7,d2 ;oui=>saute caractŠres entre 0 et A dans la table NoLetter: add.b #48,d2 move.b d2,-(a0) ;caractŠre dans a0 lsr.l #4,d0 dbra d1,RepConv movem.l (a7)+,d0-d3/a0 rts OpenFile: ;a6:pointe sur repertoires ;d6:cur rep ;d4:max rep ;a5:pointe sur fichiers ;d5:cur file ;d3:max file lea dialog(PC),a6 jsr flib::show_dialog lea foldmsg(PC),a0 WriteStrA #36,#54,#4,a0 lea filemsg(PC),a0 WriteStrA #36,#64,#4,a0 clr.l start_adr lea empty(PC),a4 moveq #$08,d0 ; *** Plus *** tios::DEREF d0,a6 ;a6 sur la liste des r‚pertoires lea 2(a6),a6 move.w (a6)+,d4 sub.w #1,d4 clr.w d6 move.w 12(a6),d0 ; *** Plus *** tios::DEREF d0,a5 lea 2(a5),a5 move.w (a5)+,d3 subq.w #1,d3 clr.w d5 clr.w d0 RepChoose: cmp.w #338,d0 ;FlŠche haut ? bne NoPreviousFolder tst.w d6 beq NoPreviousFolder sub.w #1,d6 lea -14(a6),a6 ; *** Plus *** move.w 12(a6),d0 ; *** Plus *** tios::DEREF d0,a5 lea 2(a5),a5 move.w (a5)+,d3 subq.w #1,d3 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 ; *** Plus *** move.w 12(a6),d0 ; *** Plus *** tios::DEREF d0,a5 lea 2(a5),a5 move.w (a5)+,d3 subq.w #1,d3 clr.w d5 NoNextFolder: move.w d0,-(a7) ;affiche r‚pertoire courant WriteStrA #108,#54,#4,a4 clr.b 8(a6) ;pas … 0 si 8 caractŠres (?) WriteStrA #108,#54,#0,a6 move.w (a7)+,d0 tst.w d3 blt NoFiles cmp.w #337,d0 ;FlŠche PS ? bne NoPreviousFile tst.w d5 beq NoPreviousFile sub.w #1,d5 lea -14(a5),a5 ; *** Plus *** NoPreviousFile: cmp.w #340,d0 ;FlŠche RPR ? bne NoNextFile cmp.w d3,d5 beq NoNextFile add.w #1,d5 lea 14(a5),a5 ; *** Plus *** NoNextFile: move.w d0,-(a7) WriteStrA #108,#64,#4,a4 WriteStrA #108,#64,#0,a5 move.w (a7)+,d0 bra OkFiles NoFiles: move.w d0,-(a7) lea nofiles(PC),a0 WriteStrA #108,#64,#4,a0 move.w (a7)+,d0 OkFiles: jsr flib::idle_loop cmp.w #264,d0 ;ESC ? beq NoFileSelected ;-> pas de fichier s‚lection‚ tst.w d3 ;pas de fichier ? blt RepChoose ;-> on doit choisir autre chose ! (pas ENTER) cmp.w #13,d0 bne RepChoose move.w 12(a5),d0 ; *** Plus *** tios::DEREF d0,a0 move.w (a0)+,filesize move.l a0,start_adr clr.w position NoFileSelected: rts ;***************************************; start_adr dc.l 0 position dc.w 0 filesize dc.w 0 mode dc.b 0 str ds.b 41 strend ;***************************************; EVEN dialog: dc.w 30,48,210,80,0,0 dc.l dialog,0 foldmsg dc.b "Folder : (",19,20,")",0 filemsg dc.b "File : (",17,18,")",0 nofiles dc.b "",0 empty dc.b " ",0 _comment: dc.b "v1.0 by Thomas FERNIQUE ",169,"1998",0 end