1 | /* |
1 | /* |
2 | parse_driver.c - Part of psiconv, a PSION 5 file formats converter |
2 | parse_driver.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
81 | } |
81 | } |
82 | |
82 | |
83 | int psiconv_parse_clipart_file(const psiconv_buffer buf,int lev, |
83 | int psiconv_parse_clipart_file(const psiconv_buffer buf,int lev, |
84 | psiconv_u32 off, psiconv_clipart_f *result) |
84 | psiconv_u32 off, psiconv_clipart_f *result) |
85 | { |
85 | { |
|
|
86 | int res=0; |
|
|
87 | int i; |
|
|
88 | psiconv_jumptable_section table; |
|
|
89 | psiconv_clipart_section clipart; |
|
|
90 | psiconv_u32 *entry; |
|
|
91 | |
|
|
92 | psiconv_progress(lev+1,off,"Going to read a clipart file"); |
86 | (*result) = malloc(sizeof(**result)); |
93 | (*result) = malloc(sizeof(**result)); |
|
|
94 | |
|
|
95 | psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); |
|
|
96 | res |= psiconv_parse_jumptable_section(buf,lev+2,off, NULL,&table); |
|
|
97 | |
|
|
98 | psiconv_progress(lev+2,off,"Going to read the clipart sections"); |
|
|
99 | (*result)->sections = psiconv_list_new(sizeof(*clipart)); |
|
|
100 | for (i = 0; i < psiconv_list_length(table); i ++) { |
|
|
101 | entry = psiconv_list_get(table,i); |
|
|
102 | psiconv_progress(lev+3,off,"Going to read clipart section %i",i); |
|
|
103 | psiconv_parse_clipart_section(buf,lev+3,*entry,NULL,&clipart); |
|
|
104 | psiconv_list_add((*result)->sections,clipart); |
|
|
105 | } |
|
|
106 | |
|
|
107 | psiconv_free_jumptable_section(table); |
|
|
108 | psiconv_progress(lev+1,off,"End of clipart file"); |
87 | return 0; |
109 | return res; |
88 | } |
110 | } |
89 | |
111 | |
90 | int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off, |
112 | int psiconv_parse_mbm_file(const psiconv_buffer buf,int lev, psiconv_u32 off, |
91 | psiconv_mbm_f *result) |
113 | psiconv_mbm_f *result) |
92 | { |
114 | { |
93 | int res=0; |
115 | int res=0; |
94 | int i; |
116 | int i; |
95 | psiconv_mbm_jumptable_section table; |
117 | psiconv_jumptable_section table; |
96 | psiconv_paint_data_section paint; |
118 | psiconv_paint_data_section paint; |
97 | psiconv_u32 *entry; |
119 | psiconv_u32 *entry; |
98 | psiconv_u32 sto; |
120 | psiconv_u32 sto; |
99 | |
121 | |
100 | psiconv_progress(lev+1,off,"Going to read a mbm file"); |
122 | psiconv_progress(lev+1,off,"Going to read a mbm file"); |
… | |
… | |
103 | psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); |
125 | psiconv_progress(lev+2,off,"Going to read the offset of the MBM jumptable"); |
104 | sto = psiconv_read_u32(buf,lev+2,off); |
126 | sto = psiconv_read_u32(buf,lev+2,off); |
105 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
127 | psiconv_debug(lev+2,off,"Offset: %08x",sto); |
106 | |
128 | |
107 | psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); |
129 | psiconv_progress(lev+2,off,"Going to read the MBM jumptable"); |
108 | res |= psiconv_parse_mbm_jumptable_section(buf,lev+2,sto, NULL,&table); |
130 | res |= psiconv_parse_jumptable_section(buf,lev+2,sto, NULL,&table); |
109 | |
131 | |
110 | psiconv_progress(lev+2,off,"Going to read the picture sections"); |
132 | psiconv_progress(lev+2,off,"Going to read the picture sections"); |
111 | (*result)->sections = psiconv_list_new(sizeof(*paint)); |
133 | (*result)->sections = psiconv_list_new(sizeof(*paint)); |
112 | for (i = 0; i < psiconv_list_length(table); i ++) { |
134 | for (i = 0; i < psiconv_list_length(table); i ++) { |
113 | entry = psiconv_list_get(table,i); |
135 | entry = psiconv_list_get(table,i); |
114 | psiconv_progress(lev+3,off,"Going to read picture section %i",i); |
136 | psiconv_progress(lev+3,off,"Going to read picture section %i",i); |
115 | psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,&paint); |
137 | psiconv_parse_paint_data_section(buf,lev+3,*entry,NULL,0,&paint); |
116 | psiconv_list_add((*result)->sections,paint); |
138 | psiconv_list_add((*result)->sections,paint); |
117 | } |
139 | } |
118 | |
140 | |
119 | psiconv_free_mbm_jumptable_section(table); |
141 | psiconv_free_jumptable_section(table); |
120 | psiconv_progress(lev+1,off,"End of mbm file"); |
142 | psiconv_progress(lev+1,off,"End of mbm file"); |
121 | return res; |
143 | return res; |
122 | } |
144 | } |
123 | |
145 | |
124 | int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev, |
146 | int psiconv_parse_sketch_file(const psiconv_buffer buf,int lev, |