11#include <stdio.h>
2+ #include <conio.h>
23#include <string.h>
34#include <peekpoke.h>
45#include "version.h"
@@ -121,8 +122,7 @@ NOTES IMPORTANTES : Les octets des mots sont stockés sous la forme (c.-à-d.,
121122
122123
123124
124- void vhi_file ()
125- {
125+ void vhi_file () {
126126 printf ("VHI file\n" );
127127 printf ("Format : " );
128128 if (chars [3 ]== 0 )
@@ -140,8 +140,7 @@ void vhi_file()
140140
141141
142142
143- void orix_file ()
144- {
143+ void orix_file () {
145144 if (chars [2 ]== 'o' && chars [3 ]== 'r' && chars [4 ]== 'i' ) {
146145 printf ("Orix File\n" );
147146 printf ("CPU Type : " );
@@ -155,30 +154,29 @@ void orix_file()
155154 printf ("Unknown CPU type\n.Orix won't start this binary\n" );
156155 return ;
157156 }
158- if (chars [7 ]== SEDORIC_FILE ) {
159- printf ("Sedoric File (encapsulated in Orix header)\n" );
160- if (chars [13 ]== 1 )
161- printf ("- Machine code\n" );
157+ // Version 1
158+ if (chars [5 ]== 1 ) {
159+ printf ("Loading adress : $%02hhX%02hhX\n" ,chars [15 ],chars [14 ]);
160+ printf ("End of loading adress : $%02hhX%02hhX\n" ,chars [17 ],chars [16 ]);
161+ printf ("Starting adress : $%02hhX%02hhX\n" ,chars [19 ],chars [18 ]);
162+ printf ("Size : %u bytes\n" ,(chars [16 ]+ chars [17 ]* 256 )- (chars [14 ]+ chars [15 ]* 256 ));
163+ return ;
162164 }
163- if (chars [7 ]== STRATSED_FILE )
164- printf ("Stratsed File (encapsulated in Orix header)\n" );
165- if (chars [7 ]== FTDOS_FILE )
166- printf ("FTDOS File (encapsulated in Orix header)\n" );
167-
168- printf ("Loading adress : $%02hhX%02hhX\n" ,chars [15 ],chars [14 ]);
169- printf ("End of loading adress : $%02hhX%02hhX\n" ,chars [17 ],chars [16 ]);
170- printf ("Starting adress : $%02hhX%02hhX\n" ,chars [19 ],chars [18 ]);
171- printf ("Size : %u bytes\n" ,(chars [16 ]+ chars [17 ]* 256 )- (chars [14 ]+ chars [15 ]* 256 ));
165+
166+ if (chars [5 ]== 2 ) {
167+ printf ("Format version 2 : reloc binary\n" );
168+ printf ("Map size : $%02hhX%02hhX\n" ,chars [19 ],chars [18 ]);
169+ return ;
170+ }
171+
172+ printf ("Unknown format" );
172173 return ;
173174 }
174- else
175- raw_file ();
176-
177- return ;
175+ printf ("Unknown format" );
176+ return ;
178177}
179178
180- void usage ()
181- {
179+ void usage () {
182180 printf ("usage:\n" );
183181 printf ("file FILENAME\n" );
184182 printf ("file -v|--version : displays version\n" );
@@ -190,24 +188,19 @@ int main(int argc,char *argv[])
190188{
191189 FILE * fp ;
192190 int nb ;
193- unsigned char val ;
194191
195-
196- if (argc == 2 && (strcmp (argv [1 ],"--version" )== 0 || strcmp (argv [1 ],"-v" )== 0 ))
197- {
192+ if (argc == 2 && (strcmp (argv [1 ],"--version" )== 0 || strcmp (argv [1 ],"-v" )== 0 )) {
198193
199194 version ();
200195 return 0 ;
201196 }
202197
203- if (argc == 2 && (strcmp (argv [1 ],"--help" )== 0 || strcmp (argv [1 ],"-h" )== 0 ))
204- {
198+ if (argc == 2 && (strcmp (argv [1 ],"--help" )== 0 || strcmp (argv [1 ],"-h" )== 0 )) {
205199 usage ();
206200 return 0 ;
207201 }
208202
209- if (argc != 2 )
210- {
203+ if (argc != 2 ) {
211204 usage ();
212205 return (1 );
213206 }
@@ -218,23 +211,18 @@ int main(int argc,char *argv[])
218211 printf("%c",val);
219212 }
220213 */
214+
221215 fp = fopen (argv [1 ],"r" );
222- if (fp == NULL )
223- {
216+ if (fp == NULL ) {
224217 printf ("Can't open %s\n" ,argv [1 ]);
225- /*
226- for (nb=0;nb<10;nb++)
227- {
228- val=PEEK(0x0590+nb);
229- printf("%c",val);
230- } */
231218 return (1 );
232219 }
233-
220+
221+
222+
234223 nb = fread (chars ,SIZE_HEADER_TO_READ ,1 ,fp );
235224
236- switch (chars [0 ])
237- {
225+ switch (chars [0 ]) {
238226 case '#' :
239227 if (chars [1 ]== '!' )
240228 script_file ();
@@ -249,8 +237,7 @@ int main(int argc,char *argv[])
249237 break ;
250238
251239 case 1 :
252- if (chars [1 ]== 0 )
253- {
240+ if (chars [1 ]== 0 ) {
254241 orix_file ();
255242 }
256243 break ;
@@ -274,4 +261,4 @@ int main(int argc,char *argv[])
274261 fclose (fp );
275262
276263 return 0 ;
277- }
264+ }
0 commit comments