/[projet1]/public/pc/tools/osdk/main/tap2cd/sources/tap2cd.c
Defence Force logotype

Diff of /public/pc/tools/osdk/main/tap2cd/sources/tap2cd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1183 by dbug, Sun Nov 24 13:29:03 2013 UTC revision 1184 by Jylam, Wed Sep 17 20:18:26 2014 UTC
# Line 16  Line 16 
16  FILE *in,*out;  FILE *in,*out;
17  int file_size=0;  int file_size=0;
18  unsigned char header[9];  unsigned char header[9];
19  unsigned char Mem[48*1024],name[18];  unsigned char Mem[48*1024];
20    char name[18];
21  int check_crc=0;  int check_crc=0;
22  int df_loader=0;  int df_loader=0;
23    
# Line 38  struct { Line 39  struct {
39    
40    
41  // These files are created by 'CreateLoader.bat'  // These files are created by 'CreateLoader.bat'
42  #include "loader_df.h"        #include "loader_df.h"
43  #include "loader_crc.h"  #include "loader_crc.h"
44  #include "loader_nocrc.h"  #include "loader_nocrc.h"
45    
# Line 102  void emit_standard_short_level() { emit_ Line 103  void emit_standard_short_level() { emit_
103  void emit_standard_long_level() { emit_level(10); }  void emit_standard_long_level() { emit_level(10); }
104    
105  void emit_standard_bit(int bit)  void emit_standard_bit(int bit)
106  {    {
107    emit_standard_short_level();    emit_standard_short_level();
108    if (bit==0) emit_standard_long_level();    if (bit==0) emit_standard_long_level();
109    else emit_standard_short_level();    else emit_standard_short_level();
# Line 123  write routine adds half a bit (half a pe Line 124  write routine adds half a bit (half a pe
124  one byte out of two, the second half of the period (the one that differentiates 0 and 1)  one byte out of two, the second half of the period (the one that differentiates 0 and 1)
125  is written as the high level instead of the low level. When reading, the high level is  is written as the high level instead of the low level. When reading, the high level is
126  always considered as the first part of the period, so in one byte out of two, the part  always considered as the first part of the period, so in one byte out of two, the part
127  of the period that was written in second place becomes the first part when reading  of the period that was written in second place becomes the first part when reading
128  (it is associated with the first part of next bit). So, thanks to a scheme where  (it is associated with the first part of next bit). So, thanks to a scheme where
129  the first part written is always the same duration, the bits read are the same than  the first part written is always the same duration, the bits read are the same than
130  the ones written, except that a variable number of stop bits are read between two  the ones written, except that a variable number of stop bits are read between two
131  consecutives bytes (3 and half stop bits are written between two consecutive bytes,  consecutives bytes (3 and half stop bits are written between two consecutive bytes,
132  but the read routines detects alternately 3 and 4 stop bits between two bytes).  but the read routines detects alternately 3 and 4 stop bits between two bytes).
133    
134  This inversing "feature" is corrected here (there's no additional half period),  This inversing "feature" is corrected here (there's no additional half period),
135  but it seems that the waveform emitted by a number of player devices is reversed  but it seems that the waveform emitted by a number of player devices is reversed
136  (all the high levels become low levels, and low levels become high levels),  (all the high levels become low levels, and low levels become high levels),
137  so it's good to keep this asymetric coding for the standard format.  so it's good to keep this asymetric coding for the standard format.
138  */  */
139    
140  void emit_standard_byte_with_no_stop_bit(int val)  void emit_standard_byte_with_no_stop_bit(int val)
# Line 166  void emit_fast_byte(int val) Line 167  void emit_fast_byte(int val)
167  void emit_fast_synchro()  void emit_fast_synchro()
168  {  {
169  /*  /*
170  The turbo fast format is not affected by the waveform inversion because each high or  The turbo fast format is not affected by the waveform inversion because each high or
171  low level is measured independently. However when the standard bytes are read,  low level is measured independently. However when the standard bytes are read,
172  we don't know if the waveform is inversed or not, and thus we don't know if the first turbo  we don't know if the waveform is inversed or not, and thus we don't know if the first turbo
173  fast level will be a high or a low level... So, an additional 1/2 bit is used here to be sure the  fast level will be a high or a low level... So, an additional 1/2 bit is used here to be sure the
174  last bit (parity bit) is complete in standard format: if the waveform is reversed, the last  last bit (parity bit) is complete in standard format: if the waveform is reversed, the last
175  part of the parity bit will be associated to the first part of the bit that follows.  part of the parity bit will be associated to the first part of the bit that follows.
176  A standard short level is thus written to complete last bit in case the waveform will be  A standard short level is thus written to complete last bit in case the waveform will be
177  inversed, and then a small synchro is written, consisting in a sequence of very short levels  inversed, and then a small synchro is written, consisting in a sequence of very short levels
178  (2 samples each) followed by a longer level (5 samples long).  (2 samples each) followed by a longer level (5 samples long).
179  */  */
# Line 214  int compute_crc8(int start, int size) Line 215  int compute_crc8(int start, int size)
215        shifter<<=1;        shifter<<=1;
216        crc<<=1;        crc<<=1;
217        if ((shifter&0x100)!=0) crc|=1;        if ((shifter&0x100)!=0) crc|=1;
218        if ((crc&0x100)!=0)        if ((crc&0x100)!=0)
219          crc^=0x1D5;  /* x^8+x^7+x^6+x^4+x^2+1 polynomial */          crc^=0x1D5;  /* x^8+x^7+x^6+x^4+x^2+1 polynomial */
220      }      }
221    }    }
222    return crc;    return crc;
223  }  }
224          
225  void emit_fast_page(int adr,int size)  void emit_fast_page(int adr,int size)
226  {  {
227    int i;    int i;
# Line 252  void emit_standard_header(char header[]) Line 253  void emit_standard_header(char header[])
253    
254  void emit_loader()  void emit_loader()
255  {  {
256    int nb_lines = sizeof(loader_no_check) / sizeof(char *);    int i;
257      char loader_header[9]={
   int i,addr=0x0100;  
   char loader_header[9]={  
258      0, /* not an array of integers */      0, /* not an array of integers */
259      0, /* not an array of strings */      0, /* not an array of strings */
260      0x80, /* memory block */      0x80, /* memory block */
# Line 267  void emit_loader() Line 266  void emit_loader()
266    
267    
268    if (check_crc){    if (check_crc){
269            loader_header[5]=sizeof(loader_check_crc)-1 & 0xFF;            loader_header[5]=(sizeof(loader_check_crc)-1) & 0xFF;
270        emit_standard_header(loader_header);        emit_standard_header(loader_header);
271        emit_standard_gap(30);        emit_standard_gap(30);
272            for (i=0;i<sizeof(loader_check_crc);i++) emit_standard_byte(loader_check_crc[i]);            for (i=0;i<sizeof(loader_check_crc);i++) emit_standard_byte(loader_check_crc[i]);
273    }else{    }else{
274             if (df_loader){             if (df_loader){
275                     loader_header[5]=sizeof(loader_df)-1 & 0xFF;                     loader_header[5]=(sizeof(loader_df)-1) & 0xFF;
276                     emit_standard_header(loader_header);                     emit_standard_header(loader_header);
277                     emit_standard_gap(30);                     emit_standard_gap(30);
278                     for (i=0;i<sizeof(loader_df);i++) emit_standard_byte(loader_df[i]);                     for (i=0;i<sizeof(loader_df);i++) emit_standard_byte(loader_df[i]);
279             }else{             }else{
280                     loader_header[5]=sizeof(loader_no_check)-1 & 0xFF;                     loader_header[5]=(sizeof(loader_no_check)-1) & 0xFF;
281                     emit_standard_header(loader_header);                     emit_standard_header(loader_header);
282                     emit_standard_gap(30);                     emit_standard_gap(30);
283                     for (i=0;i<sizeof(loader_no_check);i++) emit_standard_byte(loader_no_check[i]);                     for (i=0;i<sizeof(loader_no_check);i++) emit_standard_byte(loader_no_check[i]);
284             }             }
285    }    }
286    
287    
288  }  }
289    
290  void emit_fast_prog(int start,int end)  void emit_fast_prog(int start,int end)
# Line 296  void emit_fast_prog(int start,int end) Line 295  void emit_fast_prog(int start,int end)
295            emit_standard_gap(2000);            emit_standard_gap(2000);
296    else    else
297            emit_standard_gap(100);            emit_standard_gap(100);
298      
299    emit_fast_page(0x2A8,9);      /* header is emitted as a small 9-bytes page */    emit_fast_page(0x2A8,9);      /* header is emitted as a small 9-bytes page */
300    
301    if (df_loader){    if (df_loader){
# Line 324  void ask_name(char *name) Line 323  void ask_name(char *name)
323  {  {
324    char reply[80];    char reply[80];
325    do {    do {
326      if (name[0])      if (name[0])
327        printf("Stored name is %s, enter new name (or RETURN to keep): ",name);        printf("Stored name is %s, enter new name (or RETURN to keep): ",name);
328      else      else
329        printf("Program has no stored name, enter a name: ");        printf("Program has no stored name, enter a name: ");
330      gets(reply);      gets(reply);
331      if (reply[0]) strcpy(name,reply);      if (reply[0]) strcpy(name,reply);
# Line 338  int main(int argc,char *argv[]) Line 337  int main(int argc,char *argv[])
337    int start,end;    int start,end;
338    int firstprog=TRUE;    int firstprog=TRUE;
339    int i;    int i;
340      
341    check_args(argc,argv);    check_args(argc,argv);
342    
343    while (!feof(in)) {    while (!feof(in)) {

Legend:
Removed from v.1183  
changed lines
  Added in v.1184

  ViewVC Help
Powered by ViewVC 1.1.26