1 /**
2  * @namespace   biew_plugins_auto
3  * @file        plugins/bin/mov.c
4  * @brief       This file contains implementation of decoder for MOV
5  *              file format.
6  * @version     -
7  * @remark      this source file is part of movary vIEW project (BIEW).
8  *              The movary vIEW (BIEW) is copyright (C) 1995 Nickols_K.
9  *              All rights reserved. This software is redistributable under the
10  *              licence given in the file "Licence.en" ("Licence.ru" in russian
11  *              translation) distributed in the BIEW archive.
12  * @note        Requires POSIX compatible development system
13  *
14  * @author      Nickols_K
15  * @since       1995
16  * @note        Development, fixes and improvements
17 **/
18 #include <stddef.h>
19 
20 #include "bconsole.h"
21 #include "biewhelp.h"
22 #include "colorset.h"
23 #include "biewutil.h"
24 #include "reg_form.h"
25 #include "bmfile.h"
26 #include "bswap.h"
27 #include "biewlib/kbd_code.h"
28 #include "plugins/disasm.h"
29 #include "plugins/bin/mmio.h"
30 
31 #define MOV_FOURCC(a,b,c,d) ((a<<24)|(b<<16)|(c<<8)|(d))
32 
mov_find_chunk(__filesize_t off,unsigned long id)33 static __filesize_t __FASTCALL__ mov_find_chunk(__filesize_t off,unsigned long id)
34 {
35     unsigned long ids,size;
36     bmSeek(off,BM_SEEK_SET);
37     while(!bmEOF())
38     {
39 	size=be2me_32(bmReadDWord());
40 	if(size < 8) return -1;
41 	ids=be2me_32(bmReadDWord());
42 	if(ids==id) return bmGetCurrFilePos()-8;
43 	bmSeek(size-8,BM_SEEK_CUR);
44     }
45     return -1;
46 }
47 
48 
mov_check_fmt(void)49 static tBool  __FASTCALL__ mov_check_fmt( void )
50 {
51     __filesize_t moov,mdat;
52     moov=mov_find_chunk(0,MOV_FOURCC('m','o','o','v'));
53     mdat=mov_find_chunk(0,MOV_FOURCC('m','d','a','t'));
54     if(moov != -1 && mdat != -1) return True;
55     return False;
56 }
57 
mov_init_fmt(void)58 static void __FASTCALL__ mov_init_fmt( void ) {}
mov_destroy_fmt(void)59 static void __FASTCALL__ mov_destroy_fmt(void) {}
mov_platform(void)60 static int  __FASTCALL__ mov_platform( void) { return DISASM_DEFAULT; }
61 
Show_MOV_Header(void)62 static __filesize_t __FASTCALL__ Show_MOV_Header( void )
63 {
64     ErrMessageBox("Not implemented yet!","MOV format");
65     return BMGetCurrFilePos();
66 }
67 
68 
69 REGISTRY_BIN movTable =
70 {
71   "MOV file format",
72   { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
73   { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
74   mov_check_fmt,
75   mov_init_fmt,
76   mov_destroy_fmt,
77   Show_MOV_Header,
78   NULL,
79   NULL,
80   mov_platform,
81   NULL,
82   NULL,
83   NULL,
84   NULL,
85   NULL,
86   NULL,
87   NULL,
88   NULL,
89   NULL
90 };
91